From 81fd9428cab4be7eee7ddeb564bf91f282cae475 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 23 Aug 2019 15:25:13 -0400 Subject: [PATCH 01/13] Updated some of the flatworm docs. --- docs.wrm/api/providers/api-providers.wrm | 33 +- docs.wrm/api/signer.wrm | 11 +- docs.wrm/api/utils/bignumber.wrm | 6 +- docs.wrm/logo.ai | 1782 ++++++++++++++++++++++ 4 files changed, 1820 insertions(+), 12 deletions(-) create mode 100644 docs.wrm/logo.ai diff --git a/docs.wrm/api/providers/api-providers.wrm b/docs.wrm/api/providers/api-providers.wrm index 0dee525d1..080a0a5f5 100644 --- a/docs.wrm/api/providers/api-providers.wrm +++ b/docs.wrm/api/providers/api-providers.wrm @@ -12,18 +12,43 @@ resiliance, security and increase the amount of required trust. To mitigate these issues, it is recommended you use a [Default Provider](get-default-provider). + _subsection: EtherscanProvider -Tra la la... +The **EtherscanProvider** is backed by a combination of the various +[Etherscan APIs](https://etherscan.io/apis). + +_property: provider.getHistory(address) => Array + _subsection: InfuraProvider -Tra la la... +The **InfuraProvider** is backed by the popular [INFURA](https://infura.io) +Ethereum service. + +It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, +Görli and Kovan). + _subsection: NodesmithProvider -Tra la la... +The **NodesmithProvider** is backed by [Nodesmith](https://nodesmith.io). + +It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, +Görli and Kovan), as well as the Ethereum-like network [Aion](https://aion.network). + _subsection: AlchemyProvider -Tra la la... +The **AlchemtProvider** is backed by [Alchemy](https://alchemyapi.io). + +It supports Mainnet (homestead) and all common testnets (Ropsten, Rinkeby, +Görli and Kovan). + + +_subsection: CloudfrontProvider + +The CloudfrontProvider is backed by the +[Cloudflare Ethereum Gateway](https://developers.cloudflare.com/distributed-web/ethereum-gateway/). + +It only supports Mainnet (homestead). diff --git a/docs.wrm/api/signer.wrm b/docs.wrm/api/signer.wrm index 1b1f64836..54a5a751f 100644 --- a/docs.wrm/api/signer.wrm +++ b/docs.wrm/api/signer.wrm @@ -4,23 +4,24 @@ _section: Signers Tra la la... -_subsection: Signer +_subsection: Signer @ -_property: signer.connect(provider) => Signer +_property: signer.connect(provider) => [[signer]] TODO _heading: Blockchain Methods -_property: signer.getBalance([ blockTag = "latest" ]) => Promise(BigNumber) +_property: signer.getBalance([ blockTag = "latest" ]) => Promise<[[bignumber]]> TODO -_property: signer.getTransactionCount([ blockTag = "latest" ]) => Promise(number) +_property: signer.getTransactionCount([ blockTag = "latest" ]) => Promise TODO _subsection: Wallet inherits Signer -Wallet is... +The Wallet class inherits [[signer]] and can sign transactions and messages +using a private key as a standard Externally Owned Account (EOA). _heading: Creating an Instance diff --git a/docs.wrm/api/utils/bignumber.wrm b/docs.wrm/api/utils/bignumber.wrm index 5d22b611a..42cd2492c 100644 --- a/docs.wrm/api/utils/bignumber.wrm +++ b/docs.wrm/api/utils/bignumber.wrm @@ -84,9 +84,9 @@ the //bitcount// least significant bits set to zero. _heading: Two's Compliment [Two's Complicment](https://en.wikipedia.org/wiki/Two%27s_complement) -is a method used to encode and decode fixed-width values which can be -positive or negative, without requiring a separate sign bit. Most users -will not need to interact with these. +is an elegant method used to encode and decode fixed-width signed values +while efficiently preserving mathematic operations. +Most users will not need to interact with these. _property: bignumber.fromTwos(bitwidth) => [[bignumber]] Returns a BigNumber with the value of //bignumber// converted from twos-compliment with //bitwidth//. diff --git a/docs.wrm/logo.ai b/docs.wrm/logo.ai new file mode 100644 index 000000000..f7a4fa995 --- /dev/null +++ b/docs.wrm/logo.ai @@ -0,0 +1,1782 @@ +%PDF-1.5 % +1 0 obj <>/OCGs[5 0 R 6 0 R 7 0 R 33 0 R 34 0 R 35 0 R 60 0 R 61 0 R 84 0 R]>>/Pages 3 0 R/Type/Catalog>> endobj 2 0 obj <>stream + + + + + application/pdf + + + logo + + + Adobe Illustrator CC 23.0 (Macintosh) + 2019-08-22T04:20:18-04:00 + 2019-08-23T15:09:47-04:00 + 2019-08-23T15:09:47-04:00 + + + + 256 + 164 + JPEG + /9j/4AAQSkZJRgABAgEASABIAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEA AQBIAAAAAQAB/+4ADkFkb2JlAGTAAAAAAf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoK DBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8f Hx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8AAEQgApAEAAwER AAIRAQMRAf/EAaIAAAAHAQEBAQEAAAAAAAAAAAQFAwIGAQAHCAkKCwEAAgIDAQEBAQEAAAAAAAAA AQACAwQFBgcICQoLEAACAQMDAgQCBgcDBAIGAnMBAgMRBAAFIRIxQVEGE2EicYEUMpGhBxWxQiPB UtHhMxZi8CRygvElQzRTkqKyY3PCNUQnk6OzNhdUZHTD0uIIJoMJChgZhJRFRqS0VtNVKBry4/PE 1OT0ZXWFlaW1xdXl9WZ2hpamtsbW5vY3R1dnd4eXp7fH1+f3OEhYaHiImKi4yNjo+Ck5SVlpeYmZ qbnJ2en5KjpKWmp6ipqqusra6voRAAICAQIDBQUEBQYECAMDbQEAAhEDBCESMUEFURNhIgZxgZEy obHwFMHR4SNCFVJicvEzJDRDghaSUyWiY7LCB3PSNeJEgxdUkwgJChgZJjZFGidkdFU38qOzwygp 0+PzhJSktMTU5PRldYWVpbXF1eX1RlZmdoaWprbG1ub2R1dnd4eXp7fH1+f3OEhYaHiImKi4yNjo +DlJWWl5iZmpucnZ6fkqOkpaanqKmqq6ytrq+v/aAAwDAQACEQMRAD8A9U4q7FXYq7FXYq7FXYq7 FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX Yq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXY q7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq 7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7 FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX Yq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXY q7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq 7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7 FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX Yq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXY q7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq 7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7 FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX Yq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXY q7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq 7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7 FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FX//2Q== + + + + proof:pdf + uuid:65E6390686CF11DBA6E2D887CEACB407 + xmp.did:923b62f5-2195-4695-a9d0-6d3f540d180d + uuid:cf83d2c6-60f0-5c43-88aa-628cdb6ac2fb + + xmp.iid:4f57d6ec-2e1a-4525-9451-f3bcec76e5c6 + xmp.did:4f57d6ec-2e1a-4525-9451-f3bcec76e5c6 + uuid:65E6390686CF11DBA6E2D887CEACB407 + proof:pdf + + + + + saved + xmp.iid:0935b35a-dbf5-4b15-bc5a-22d4ced74c25 + 2019-08-14T14:43:52-04:00 + Adobe Illustrator CC 23.0 (Macintosh) + / + + + saved + xmp.iid:923b62f5-2195-4695-a9d0-6d3f540d180d + 2019-08-22T04:20:17-04:00 + Adobe Illustrator CC 23.0 (Macintosh) + / + + + + Web + Document + 1 + False + False + + 100.000000 + 58.000000 + Pixels + + + + + Default Swatch Group + 0 + + + + White + RGB + PROCESS + 255 + 255 + 255 + + + Black + RGB + PROCESS + 0 + 0 + 0 + + + RGB Red + RGB + PROCESS + 255 + 0 + 0 + + + RGB Yellow + RGB + PROCESS + 255 + 255 + 0 + + + RGB Green + RGB + PROCESS + 0 + 255 + 0 + + + RGB Cyan + RGB + PROCESS + 0 + 255 + 255 + + + RGB Blue + RGB + PROCESS + 0 + 0 + 255 + + + RGB Magenta + RGB + PROCESS + 255 + 0 + 255 + + + R=193 G=39 B=45 + RGB + PROCESS + 193 + 39 + 45 + + + R=237 G=28 B=36 + RGB + PROCESS + 237 + 28 + 36 + + + R=241 G=90 B=36 + RGB + PROCESS + 241 + 90 + 36 + + + R=247 G=147 B=30 + RGB + PROCESS + 247 + 147 + 30 + + + R=251 G=176 B=59 + RGB + PROCESS + 251 + 176 + 59 + + + R=252 G=238 B=33 + RGB + PROCESS + 252 + 238 + 33 + + + R=217 G=224 B=33 + RGB + PROCESS + 217 + 224 + 33 + + + R=140 G=198 B=63 + RGB + PROCESS + 140 + 198 + 63 + + + R=57 G=181 B=74 + RGB + PROCESS + 57 + 181 + 74 + + + R=0 G=146 B=69 + RGB + PROCESS + 0 + 146 + 69 + + + R=0 G=104 B=55 + RGB + PROCESS + 0 + 104 + 55 + + + R=34 G=181 B=115 + RGB + PROCESS + 34 + 181 + 115 + + + R=0 G=169 B=157 + RGB + PROCESS + 0 + 169 + 157 + + + R=41 G=171 B=226 + RGB + PROCESS + 41 + 171 + 226 + + + R=0 G=113 B=188 + RGB + PROCESS + 0 + 113 + 188 + + + R=46 G=49 B=146 + RGB + PROCESS + 46 + 49 + 146 + + + R=27 G=20 B=100 + RGB + PROCESS + 27 + 20 + 100 + + + R=102 G=45 B=145 + RGB + PROCESS + 102 + 45 + 145 + + + R=147 G=39 B=143 + RGB + PROCESS + 147 + 39 + 143 + + + R=158 G=0 B=93 + RGB + PROCESS + 158 + 0 + 93 + + + R=212 G=20 B=90 + RGB + PROCESS + 212 + 20 + 90 + + + R=237 G=30 B=121 + RGB + PROCESS + 237 + 30 + 121 + + + R=199 G=178 B=153 + RGB + PROCESS + 199 + 178 + 153 + + + R=153 G=134 B=117 + RGB + PROCESS + 153 + 134 + 117 + + + R=115 G=99 B=87 + RGB + PROCESS + 115 + 99 + 87 + + + R=83 G=71 B=65 + RGB + PROCESS + 83 + 71 + 65 + + + R=198 G=156 B=109 + RGB + PROCESS + 198 + 156 + 109 + + + R=166 G=124 B=82 + RGB + PROCESS + 166 + 124 + 82 + + + R=140 G=98 B=57 + RGB + PROCESS + 140 + 98 + 57 + + + R=117 G=76 B=36 + RGB + PROCESS + 117 + 76 + 36 + + + R=96 G=56 B=19 + RGB + PROCESS + 96 + 56 + 19 + + + R=66 G=33 B=11 + RGB + PROCESS + 66 + 33 + 11 + + + + + + Grays + 1 + + + + R=0 G=0 B=0 + RGB + PROCESS + 0 + 0 + 0 + + + R=26 G=26 B=26 + RGB + PROCESS + 26 + 26 + 26 + + + R=51 G=51 B=51 + RGB + PROCESS + 51 + 51 + 51 + + + R=77 G=77 B=77 + RGB + PROCESS + 77 + 77 + 77 + + + R=102 G=102 B=102 + RGB + PROCESS + 102 + 102 + 102 + + + R=128 G=128 B=128 + RGB + PROCESS + 128 + 128 + 128 + + + R=153 G=153 B=153 + RGB + PROCESS + 153 + 153 + 153 + + + R=179 G=179 B=179 + RGB + PROCESS + 179 + 179 + 179 + + + R=204 G=204 B=204 + RGB + PROCESS + 204 + 204 + 204 + + + R=230 G=230 B=230 + RGB + PROCESS + 230 + 230 + 230 + + + R=242 G=242 B=242 + RGB + PROCESS + 242 + 242 + 242 + + + + + + Web Color Group + 1 + + + + R=63 G=169 B=245 + RGB + PROCESS + 63 + 169 + 245 + + + R=122 G=201 B=67 + RGB + PROCESS + 122 + 201 + 67 + + + R=255 G=147 B=30 + RGB + PROCESS + 255 + 147 + 30 + + + R=255 G=29 B=37 + RGB + PROCESS + 255 + 29 + 37 + + + R=255 G=123 B=172 + RGB + PROCESS + 255 + 123 + 172 + + + R=189 G=204 B=212 + RGB + PROCESS + 189 + 204 + 212 + + + + + + + Adobe PDF library 15.00 + 21.0.0 + + + + + + + + + + + + + + + + + + + + + + + + + endstream endobj 3 0 obj <> endobj 9 0 obj <>/Resources<>/ExtGState<>/Properties<>>>/Thumb 90 0 R/TrimBox[0.0 0.0 100.0 58.0]/Type/Page>> endobj 86 0 obj <>stream +H4R;n1 u +_j2#EHR9ߣ5Č( wot{ }~xB٤"t9~Пq:ס +ߏBpVpr8c_#. ,%Pئ^8HMqqN#K<[ +8QMH'9 +Y/}kS!k4Viֽ̹ @@#7,`>pU.p eXc 'p}l5hpCla &ڡ0xb`4"XS$E#NC`mhhy.Z'-.\XA3nXX?ǯOe|yO2;sU endstream endobj 90 0 obj <>stream +8;Xp,Sb`=/^]:i&7Z@~> endstream endobj 91 0 obj [/Indexed/DeviceRGB 255 92 0 R] endobj 92 0 obj <>stream +8;X]O>EqN@%''O_@%e@?J;%+8(9e>X=MR6S?i^YgA3=].HDXF.R$lIL@"pJ+EP(%0 +b]6ajmNZn*!='OQZeQ^Y*,=]?C.B+\Ulg9dhD*"iC[;*=3`oP1[!S^)?1)IZ4dup` +E1r!/,*0[*9.aFIR2&b-C#soRZ7Dl%MLY\.?d>Mn +6%Q2oYfNRF$$+ON<+]RUJmC0InDZ4OTs0S!saG>GGKUlQ*Q?45:CI&4J'_2j$XKrcYp0n+Xl_nU*O( +l[$6Nn+Z_Nq0]s7hs]`XX1nZ8&94a\~> endstream endobj 84 0 obj <> endobj 93 0 obj [/View/Design] endobj 94 0 obj <>>> endobj 89 0 obj <> endobj 88 0 obj [/ICCBased 95 0 R] endobj 95 0 obj <>stream +HyTSwoɞc [5laQIBHADED2mtFOE.c}08׎8GNg9w߽'0 ֠Jb  + 2y.-;!KZ ^i"L0- @8(r;q7Ly&Qq4j|9 +V)gB0iW8#8wթ8_٥ʨQQj@&A)/g>'Kt;\ ӥ$պFZUn(4T%)뫔0C&Zi8bxEB;Pӓ̹A om?W= +x-[0}y)7ta>jT7@tܛ`q2ʀ&6ZLĄ?_yxg)˔zçLU*uSkSeO4?׸c. R ߁-25 S>ӣVd`rn~Y&+`;A4 A9=-tl`;~p Gp| [`L`< "A YA+Cb(R,*T2B- +ꇆnQt}MA0alSx k&^>0|>_',G!"F$H:R!zFQd?r 9\A&G rQ hE]a4zBgE#H *B=0HIpp0MxJ$D1D, VĭKĻYdE"EI2EBGt4MzNr!YK ?%_&#(0J:EAiQ(()ӔWT6U@P+!~mD eԴ!hӦh/']B/ҏӿ?a0nhF!X8܌kc&5S6lIa2cKMA!E#ƒdV(kel }}Cq9 +N')].uJr + wG xR^[oƜchg`>b$*~ :Eb~,m,-ݖ,Y¬*6X[ݱF=3뭷Y~dó ti zf6~`{v.Ng#{}}jc1X6fm;'_9 r:8q:˜O:ϸ8uJqnv=MmR 4 +n3ܣkGݯz=[==<=GTB(/S,]6*-W:#7*e^YDY}UjAyT`#D="b{ų+ʯ:!kJ4Gmt}uC%K7YVfFY .=b?SƕƩȺy چ k5%4m7lqlioZlG+Zz͹mzy]?uuw|"űNwW&e֥ﺱ*|j5kyݭǯg^ykEklD_p߶7Dmo꿻1ml{Mś nLl<9O[$h՛BdҞ@iءG&vVǥ8nRĩ7u\ЭD-u`ֲK³8%yhYѹJº;.! +zpg_XQKFAǿ=ȼ:ɹ8ʷ6˶5̵5͵6ζ7ϸ9к<Ѿ?DINU\dlvۀ܊ݖޢ)߯6DScs 2F[p(@Xr4Pm8Ww)Km endstream endobj 87 0 obj <> endobj 96 0 obj <> endobj 97 0 obj <>stream +%!PS-Adobe-3.0 %%Creator: Adobe Illustrator(R) 17.0 %%AI8_CreatorVersion: 23.0.4 %%For: (Richard Moore) () %%Title: (logo.ai) %%CreationDate: 2019-08-23 3:09 PM %%Canvassize: 16383 %%BoundingBox: 12 -73 95 -20 %%HiResBoundingBox: 12.9287460258338 -72.3800000000065 94.4504859345379 -20.9999999999973 %%DocumentProcessColors: %AI5_FileFormat 13.0 %AI12_BuildNumber: 589 %AI3_ColorUsage: Color %AI7_ImageSettings: 0 %%RGBProcessColor: 0 0 0 ([Registration]) %AI3_Cropmarks: 0 -76 100 -17.9999999999991 %AI3_TemplateBox: 50.5 -50.5 50.5 -50.5 %AI3_TileBox: -346 -353 446 259 %AI3_DocumentPreview: None %AI5_ArtSize: 14400 14400 %AI5_RulerUnits: 6 %AI9_ColorModel: 1 %AI5_ArtFlags: 0 0 0 1 0 0 1 0 0 %AI5_TargetResolution: 800 %AI5_NumLayers: 1 %AI9_OpenToView: -33.2073410669591 11.8088050870001 7.10328968964765 1428 803 18 0 0 6 43 0 0 0 1 1 0 1 1 0 1 %AI5_OpenViewLayers: 7 %%PageOrigin:-350 -350 %AI7_GridSettings: 72 8 72 8 1 0 0.800000011920929 0.800000011920929 0.800000011920929 0.899999976158142 0.899999976158142 0.899999976158142 %AI9_Flatten: 1 %AI12_CMSettings: 00.MS %%EndComments endstream endobj 98 0 obj <>stream +%%BoundingBox: 12 -73 95 -20 %%HiResBoundingBox: 12.9287460258338 -72.3800000000065 94.4504859345379 -20.9999999999973 %AI7_Thumbnail: 128 84 8 %%BeginData: 1864 Hex Bytes %0000330000660000990000CC0033000033330033660033990033CC0033FF %0066000066330066660066990066CC0066FF009900009933009966009999 %0099CC0099FF00CC0000CC3300CC6600CC9900CCCC00CCFF00FF3300FF66 %00FF9900FFCC3300003300333300663300993300CC3300FF333300333333 %3333663333993333CC3333FF3366003366333366663366993366CC3366FF %3399003399333399663399993399CC3399FF33CC0033CC3333CC6633CC99 %33CCCC33CCFF33FF0033FF3333FF6633FF9933FFCC33FFFF660000660033 %6600666600996600CC6600FF6633006633336633666633996633CC6633FF %6666006666336666666666996666CC6666FF669900669933669966669999 %6699CC6699FF66CC0066CC3366CC6666CC9966CCCC66CCFF66FF0066FF33 %66FF6666FF9966FFCC66FFFF9900009900339900669900999900CC9900FF %9933009933339933669933999933CC9933FF996600996633996666996699 %9966CC9966FF9999009999339999669999999999CC9999FF99CC0099CC33 %99CC6699CC9999CCCC99CCFF99FF0099FF3399FF6699FF9999FFCC99FFFF %CC0000CC0033CC0066CC0099CC00CCCC00FFCC3300CC3333CC3366CC3399 %CC33CCCC33FFCC6600CC6633CC6666CC6699CC66CCCC66FFCC9900CC9933 %CC9966CC9999CC99CCCC99FFCCCC00CCCC33CCCC66CCCC99CCCCCCCCCCFF %CCFF00CCFF33CCFF66CCFF99CCFFCCCCFFFFFF0033FF0066FF0099FF00CC %FF3300FF3333FF3366FF3399FF33CCFF33FFFF6600FF6633FF6666FF6699 %FF66CCFF66FFFF9900FF9933FF9966FF9999FF99CCFF99FFFFCC00FFCC33 %FFCC66FFCC99FFCCCCFFCCFFFFFF33FFFF66FFFF99FFFFCC110000001100 %000011111111220000002200000022222222440000004400000044444444 %550000005500000055555555770000007700000077777777880000008800 %000088888888AA000000AA000000AAAAAAAABB000000BB000000BBBBBBBB %DD000000DD000000DDDDDDDDEE000000EE000000EEEEEEEE0000000000FF %00FF0000FFFFFF0000FF00FFFFFF00FFFFFF %524C45FDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFF %FDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFF %FDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFF %FDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFFFDFCFF %FDFCFFFDFCFFFDFCFFFDA7FFFF %%EndData endstream endobj 99 0 obj <>stream +%AI12_CompressedDataxe&(nNNnOcV. BCJENe +Ty-{JA;q~O?˷?ww~sOO}o޿G'~[ ûo^}C{~WzרPޞ_u{=j'|̧O&/oyMx|v7_z>tO?ZgWrH}A{wŴOs8hB}'o_~Û{on޾~Lx^?YYu_\WIe ?}Ox%/~>{ߜ.aPʯ峇?_n߽kyj?>|kLO4gLZᵤ'>$)뫬S?}3rj!` |w{4Yo|x_b_{,߾MX0{7~xǷ]gg֤4ٞ=Sdl{gk+sBO8)e`vWϧYmk)V^՛` 'ûW_ݩ?OOM69Da߿xS'{=iοr˛_qqf|}uR΋ȧ^a?JMߢ޽߾ӯ՛֝D>{_߾ /<w^byÿ/>xO|%^/m9)>ۇðׯwoۯ7j7/-Q vȆ=\|>KdM3o_ׯjyɧXW/_?|o?to|۷nwUˌԏS8|?=6H|97/^~w/G9_n˄7zok<ٳt+ 6h^O՛/q,>u~5~'\U6l݋/_Wo_) x>]9djRᄌ~7Mq⥄mOڔ)\mʵm-wrMv%$&%oJٔ{e7f)vvw((w~[S'k?~S (2\ޔyS6ZNV_q]!LֵX ΛƿnY֥fUna_1k&YfX(*smN򟻺Ul(K%+Rt +hkĵV]-,wv-R_\|1ʭ& 03 |<;k[bȡ+p=&W 1xoPnYrH1TuI{bB Kuɷbz TrU.cisDf|7mpU*W5=v xsc'm0b \\cYYpwMη׷7wX|w]F)wtwwwqiO(x{ ޣkiwr)7r)W22៲)ySҮM 7pwIYvw۟]27jSM)7%mJ]6nYKfSܭ~kVkDeRL/~][i:nmY5u3qU,ԒZb-AMrl-B՞~\2K)lO'" +^EIo#m-deO2[+٪Y1ȼY;k2ɻGyW!gaa/w̛kЮ4,_'P@̄tYѻ+ 0(:F v,sV + 7ֻú܀^ 7A-{[u. )GonqcbbAgH~H&3aao5.9\)F\qvƥ2r! n.}]q +Rp3%\9ånp$_nʫ /b%]ڊZN/uoW\)Gnp"ׯ_d% RkƦ +Np+a#;Bn2r9T՛\"^Ekȳy-]n;/]@1ʃ5r'lC\X ȳi<)JyzޣR/o.op\߭,YB+L~cQNn˴)k\Q4k/藏fBW˴,EjKT7^liκUV/T4TyC"D r٩ +E"Q,R +(Q{% +ʥ(%eΆ\2yJ%,ӣ4倒9XKWrs \H[İ '}~Fg (?A0LɎ,Sg}['ɇm?y36 rkys 7 GHqAS6.߬K|+R?vDc4igZb?^3,.}#r}86c?{W_zjS8Sޚ D016/VKAKonww4tA7}Jv;Z'z;.tzC/bН_}ٚy1T>-T^#,tIi 0(x-qLK^ y'Lc,`,b,HTHV<[Χ2^r=ǮԱFofqGp :∦D +xܻhq.zkִ['7d+붿/_-,}E_͍ !ZcC6ȍ>zc mS~qĹəbڜ$lU3nyT LN7np^9 #OEТ|f&苖 J4 +T|-yQ'6o3D1}wR[|W塀_DKVZ)[횪,QyS8k rc[KmpW\EҼ ,]~v6vyp'Ixȃꧫ=ZD/-aB)UiF͐Wx}kI\Ke7,kq'/e^R2-~,S2݇MrXJܕte>(WSͅrHY{ӱkA}"y*(Pi[o pi 3[$DQo:$}xV jWOJhz1Qg5H|{P[׋, [z}D=Gv+KkrE:d?U[}չa7};av# LZb:+j8V+j6o RWijз5=Ls[UژNhˢG]Qx;eKΎvmhu ^]Mu n5m:u*ܬbp&H01uϫW{+Z/Vc% Lwtaz/NH +HՐE^&^%Pl}%x{jZ楔wz ǥLU2_sVZkʲF +ٕ\uLBNe岰AkWw.rM!w<^"Y.u 6-*ϭnUչStMl5U[\G'u!'7KUYwv-"Bi&BU}F½ +5Z?8ըf16CQ^N* m*Xs/RD}hL+bVJWĮ$ѥjưX!jIb0[Zn\r-֫sm-T%*x?"U&ڇ0^ +bmSbg}rHk|hRl|f;!YǍ8?^d߻xD$@EE:8)դMBoIls]Y/-M-ZV/'zhDh4-ϴ8:eQqҢ24.vgGe8&fcBT5Dȱ-M`\vx=2K+"p}6%],r.V+wh| ez^_:,L=SU1#TwM5!SĚ[_ϱj;r%MմP*-vvKo AZ?[pjKKJiˁeBY5ae2ezw-?Q +iEkKUDiB!E*NdJD,H~^ +hȖCKRP5Vi㓻 3hREŹGLUպyGiJOYvf;sP:J3}"tlt@/Iؓ4/~ؕg<;WjE\=0WԌ*čEhYwWrU Dyzܫ$&w )^vɌ J%ITM hbДv-PlVAJI$UN +B[f/LgP=j67ݸg2=}2="{on". 1~o+*\48#8pעK lV\ho~ip`iHAlnb_[qjմ<׺G^טƚ]| )v@pU `k(U:VW3wе5s5mM\;VoM[ZSgֺdڙgMYGgXn'{y.hA:p9P_(/#<P_(/=[ôWœٚcz(EB>HH0J}Иn.nY0^ʦ[4j'~htkjZ{ ɞ)p +GH3z2g|<OwttAʽs"~!E )}oN5ͥf=뵤4U6Cb8]-Yu4ʽMv.EB0s&ZEV@i@8߷?ޛI4>I e  zT&gR%dX cPM!I43z#.O Rp2gtbOV_qI§lħ{|F/]}ołl%M^M!Zs}6/~)-fmzC Xuieh}ŏL +Uj~ +uWu=$ -A7T)h\c jk&~W*V3O LIiMW\U|eꑙLN'8U4|-B&piiK-}Σ;__w{@ rV +.p%agń-\f?LwC^v ^b5&IJ6=_sZ wvNb5aT{]=9.=)m<wC6əI{|ʫ"J٦.nb2J@禚 ,nSp_'%x{՞N` a_v KE sH=bq Wv##X6^9@{O-P5&Ј' ~W~ P W˓m\Up>W:ٰ&ktɰGJ(4E?';6quIKȈ񰄩Ò>LC +Xj5;cp5=,&$Сat~nBMm˳bd>V4$&hO݀'4do}>H~u͋%f~/ mֺ)Z2Ok%ƚU|.ط4~(e:LA?p-Uw#v,6s-EaYL$MKJ5)l*(fSipp[-f*{[-,7rċd^6S0/w\ C_:T +C5KԼʂEvkB`?㰅l#ޢ]aR$SڇíZg- nm˴1-~~[wf- ct=ݴiZӒiMV!=ﶦ0$^05`qL@]{g犿O"B S4$A;~HDrK']QTg|)iV Ei9+秼Tjպ xU?*w5-|p|#Gl+5ȇ<|V |{Qo`:ʂ3oVmUl'qRZ4MZ",rOYS?W1n.dk l-E$5r>w j?f?!WWUI2/†NrRĄT\pTcDQX 39(eʴfH"P*"`ho$ch `M$PʾlUdވڊ7bW#>*[L*. 0wG2*M|#k +TpDVY,U3B^LU겒mS_L +͘P`jޥP ͹l۷c$$0\J$}^k^Yr9ӊvlcޘ<G M `uD5_t3qϠ86Ӂv|&·SO!q/>UYɅs޽׏e4GFø>; 0zzxx-^o[W̊vڱ@jrJsܼst;x&z2]zo3o)yM}R$qż<7#Smn6&c2sq F\׎)lM`ٹqD`ɶnRf-X9ȣ"?v~g0#K/H)ǧ,?nuӟX5ޚﺢ㷔xeI&ki[Q(hOЬBCơݖTh>dCs|l^곉}l#` #Kes^{1D82LwG ;kYY`1+A<7/<<nNcf*,lR5nVSSv4ša"Òcʛp O2xT"C5k"#;ng3?T8uB7.Gxn7A%ǰ&bxl+<`;Lu!-] T(GIF`G?_# VU͊Ӳ/qQ5qY#׀#Z5}juwk$0U]i8m+,T8L> tLZc%,ջZ%jݤQMgj|,~ +l_%Po@cͧ^y͟>d#o+5^k>}û7^o^@<'hO.3XǠyr666%2+ +،9_7]TuT[[O"<8/Aذ/;2{pc,wN(tԛbM!bgDo(*ιԟ`gv4p&* mYZp]:'%N Մqa, +=G [JO :i# L42sJ&1$I{7Y AcbI|uTd32nq6SpLLW[oC]``q)36v8CNcp0_n[X}/<´At1v8G_V=H#w +ߐX1gTQix`˷ +_8VP +~+(a1ulYW3n +[,Ϲ0qmf?z63o 7ooMxۯ9g_?xxĎkOǓ 0x{'iHfC6ŀ. ahiĥi{qaqvT%s#L"S& zJBЄBRAnT+~! F*X\N*qK[ll~*Tl)GP1oHw}%H2k#=S0|L*dH|1K%t8P& (z +T t7r>r G2@bdp!oTρ'-J +*(IHA$St1B3_RpXƇ*%8X@:2T0`.qrK¼wlif3@/3찯8[1k8+<*w 6ހ9_ɕ{~"^gu`Y_M#{J4Uhoy=]}\!xv[)h_+_9y{#0|t A {nVRDe󜾢N+GW+ouxHnUS0zYAE? "0(I @a'Š9W~? ˚Ou;`J'NJ2ϓa'xx@n2o&# Cv_|&d"L]t5Y0ߙa g'[Nw1aXE@/x 6lT9y|t8uA;Ck91tSr3 xRɃ% 89]C'h<ؠ@bC:StЍêT)#* N^."P|:{ܦ`^kcf~$OH[A@u hr.BH`dp,Jd IZ8ư~N48ZihMidfz Hy; > +( @F r:x>ɟAA-0TJhۣ -ihO0avZe=Anui *8T2vS$[ 8oA^*] +|,Jn*T45NΙY΋"= ], Y4F֖rMǑ3Lc,Feg#WDUI3Yu1c}"M=A +M{o dCe3^q'DRKu|ȿ֛WKS3*V,j*6Z4[W?}lxK\ Kxyl+r~ ;+{pV.2 [Fǝ +c}_1>d5>mLc˫,w^0S{Y~z;(&68`d]@i3{IhQxVV׀'eT>joA\U)8̔φ4Xmn3(_$0tPtB{R4tUQjr{PS~&>!9XyRny0 +$0ؚqH% m b}'SVB簜-l>.wlԈ+ ,CY!V31ԄЉ;"Q AW=홛LHB?!t=Gqñ-wj~]^PSNXJe_4;-I ЏuR? wi[!8p;B +ڑƴH؄8;E&P[ ;zj󥖂FqܓFkd8u>"oQ GgDdBȒ4^(娷YNt30).שEfpX$Hr<#E򜖴\cÈ8Hfxٻ(R3I9Z"օ޻^ѐy@7A;^|DYd(@\▃@zusKVtΐ"Gh΃I >RFH+P8vm=Y ipA쁿d\$Gb8 W&:y bLT})G>9Urh28+invv;\fe٘itS' +^9ElLzӉSX> p9g6w JBl8^ fe +WX<7ﵭsT}:fSJUoQF0Yufle%D>9tɆ/Ge_qlIKO~fA+PsݫVJbc8Q 5xYL~*?$O?:rq$=r"nFVseE9!>8UB.>2ܽTљ^1Āv(VձU4c;nڂ\}hq>;!cc<'d%96Aٰ˜{jLZ xG5}JK.TϏ_}!-W9qoF'{: +W+>0V'˒{#b悡U3 ^3*vD4&[{X2~F^@%lU"޶ hXSSb^0뛽`07]xn hk0S5}x8sj}qMC8Nl]:_"~OuoNjȣ^c^%/VQ9{Pp[.UbTQ=y`To9놡 -4:0^?ёq`a M u PfwJEoPI7Aqe"?cHW߽N"wmf%f<0A4-nRny|WF"CHaV`ev&ӋK`<pvg0n!g3 ruL#WGqxT7D>u5xPkBӅ[D +W hPSx9J1βVw1VWxGw1Hoe rV"=nPpQ Q `⋹(0a]PkPI itXVfy>╯~GiDmxm4~Uo&J閭 Õ\7ng?J pv_7WC8,^.Jh|숣Ag=5-هz#RX3:fȒ S$MVƷ3.t +lݚ5[3ɞIawbM 1jֲGpW&pJO^6GA0SXj;VFg=YԘ§Obw4Q4d1aVTGKw^,6ΜF A~LRN3eA\ zr}  +/t4EN)(fC8v+jީkѨQ77C?cyj>: +$lx [o5e +JWJ^N`:D8%$E3 v6((W6 ]/j)H.pZ3n6 Ôf@"xRNO>h鞝eNTԪ2ij^ +Mo&+DhI(\3Qi5<@SL:h1 MSδWR&iZ2W6 [eʞHyʪ%_$VNN(h"mY/3VI~yJU֡,IcDxu0 /N^cvKj|3Z +CIpRiN3c[ nZH7Jk]CڗhUK~[|?uLj +ƕJ=,b- ++E4YH՚X?:5X*#ǝ/{)%˅YأZ胆v+x6BEYvPؒ[ՙ!C^?H70Pe0@~lqa11vKI74L 8EJI]Z0cat_ogffa(OҲ Ph&S%Պ0ŘF,^Ad2(DJtEφv Kэ蓆Vɕz q,ޠwjڭ8cDtp*45#1B]JV +5BgaF(1YBPE]C~5k/N : +7~ǀ6Ovv+bMә,\]+a0HleGP9Qֈ.TӚ07g3Ǡ./L2 rܣá|"}XmF6G9xKcZ$@5lWoZ43&%7 ʞ%s MƩ!ds^L0{p9:2X k!۫Uvk[cv(fhj1(snېݢ1@^ 7rWiy2G2c`?{9$h#.g,#@:wp &#q@8s`{5Y9mvlwo: -qV@}r +n)R,jԌp d [x{ q$1 v͡ETMOpj18hEDp <F>{;C;V cEZVO)p NADuövCG݃ WzƁ-z9։ΗbWZG:1Eqbg 7LK0@\'c??!TD ""b;ĈoA"$b@"CAow 1 ^1C (z87C}C Q|Jw p_1 mA"$!  $Ă#A4@4ܿx +a pu(P\``?p 0QC +b84lazCvpn ~Ab8P|1&OxQPBeMa&!<"  O0bi3PW,PЧVtE9IF;-Yp@ +\!"y/&} ա͔QkEߍ y|0EFfęA>a(hgq[5QBߨ~nǑ] !:4iR#e6=kZeigr[%.hf=.abrQkGhRSYT >uZ3-u8ywR6Lŕ6+Кj_{CJ ɚf[d^VSPsqW-3UkʶȤ_VbD1#SCəQ \K2.s5lPih? ױig] !|0Z"J/|K[D4-j]uN.@oEC'عDu֎Uejv )U$Ec^,fEɎcZtUV@7ҨyXJ벟ŕa|E⺹wSssݞriEUGnkc+W%†Ƃz§A`Y]EXAàEO?h`[Y`VHVH LkӬѵ)c0 +Q ( ޻uBEwVv0[Y6eI<_{IUf[a +9kZf鰶@uk9Iϟ>fCpnQ m=VT@j`HKrc,z>ZWEqE"!Y T鎕Oe(V/jseqdEt(Uj UHUF+t)R1CQ]`ԑ<à +!GS\Ú$Wg40I&=Л +aJV;?uA7;)XP%mxe%3񂤻Cs׃>=U%W;wZ+;0%Ɇ<܀ N<ɢ D(;kǬFke>TZwȴQWA3&Fe:[Z+{h#q:E"^=I}t*qZeQԞ3#rqzISrhHRq@~h`hKL8Z+;hE i[Yfcj+Dkek#E[9KZ!@`k9M.mm_Z*{T@|WXpF紊# r³<,c ,/,uizT'S5Dalc0Uшp +H1 lvc% +TA ,=B`"r}q'?=?惓=|w__`޾yٵ}Zh9^?|_^O>WW|?M[Ɵ{W^S;VXnx??k}DԔyWwo_n\ _Ӈw/޼_wK{7owo_ֿM7_WI#ڢW'.(`AOBc%rm*-˿A_4ǝ~iN_j##音3>:Z o9滞/͟t}rϼxN!1x9 +F—-s @Nx0AjCj@j?t<㑷31 5 nd%^dhtCtYaUJzT*x| ~6(q? + +i.W%7z8'!|ۘy'8H#%/H3Y5OȚѢ-JÒI_G@$!M: w,-2 Z%Tkw˄ SBQ + -/^ +yJ*:РV <C8bVQqXƵ93Un$Дңd*>#dZ.ɃV-xqS% 6gըgNmQ}O2€Uߒ<86iު\aB8>@2ݳH$bC Pinjbd=H ES[ Su"|hj#11Ű ,iV[ƱEd|+ 'dan /r,ThLqcLW)"ToX&tA/q–*CM8 ̈$L)'I4d5e%G(>M_V 3&]<Ң!5Bn$,j-h^eq{'uhQ(7Da0GǩwKZF-siYt+LsϛiF,4NĆdc:Yf%|\@Q6L L8ޕ54΁YRzrY$<3DY:3\ ZRo,RJlCyh*)z0dr$ܙ@(IH1њĀ-)I}ͤY"E%Na3UTHƷ^A3RQP^LEQDmE Z*xn;\uqdz ߜNyS/FQy y4B!1!-&QuDbiɊdBуZw,j<Й@Q:JZRaAqKt%?#TBI1fo@E s$-ZHm 0/7Vڝ1!ƷV4>4X翬{’ ю%(w%h;o1 +5$"ؑDɳtlC}9A\͜vtk~84GIKDʕ`3+IYI蹦 ɕ[6seѲ7*J_F;ůPȏT&N@Tٓis޺'{wy "7I"0T%VY5f'*s6<&39ўm:EEc5N!>3>G 5K]p\f\@Xg(iJ0^V*ĜD^ *n\Q n Sp-)DƟI4tt%-WY'Nn@N]fh%Mkr pv + + *neb☒R ,s\A{5?! qIhhf$WQRtK +蕫WbW$(ɉl,~8끒EU#H?kgfI|bb;I +桂L2#"^B&F6sOV aI[T69K=VzQV*V QMATZ/^@@rc#\w5Ņ/L1Fe0e ++/AxCU!Q]U8VowC %oOᓗ!#j%\B[.|"&HpxY3t+RaVtz,2+ f9"ʉiaFڙ$L1"BV0auNPC+YM"Ĺ[4rRuy$\q?o?2̶,Qayz~K@Ya.Q*zIZd,c *>TrK*GJT*M^V/.bN-Q}N6!ƭ2qPoTҦO#[t4Ýd$I$(*4i/aG1R"7K]f+9Ns؎$)v&<u5HEBhdȊ^N/%f?Tr\[@[TVa7QOP 0+˥uR$^u:1;&uħ +ri5Z8 nz` ҃1HsPs#MoFjRQuO,(YVFѢi)Y|挠kD),[5(jď&sxI +uIDHe +LKRĘ7PÊ\ ?Bw$݁4,^d"itY𷰃 -.Y>\d)%3@] D%.e($!WjӪ[&H zfhdd$PA=yą"X+^/r"NP+*2zE$M(LqO +q +`q嗶CHs\TvBaQ: +b ԟmTI4KEVYU vbm!fmLF],'33N9]͒#PQ&1Lz@:];Lpg]͕{&>Qa3Rڶ\/JVP{!^WTNDݕ`˷ '#ArdܘK31xJ"f9NA$ \ƞS8TӜfʦ dEdfp}k|9&xQk9IŌMf`Mj3sCsnv%͞0T&(+mr:}qJeJz|MiaN*ƠTKI)ɁPx +Aw;2 s P5S͒$.XywQ/Ht˯'O0( ?*[6Iz +N4F`/R&3 +f$-rJh(9zs_aWHW3VZ2@gL$ղNtujjgx`(hV*12)ʠ"EZXuoiCmLKeю1HҦ"_τcE02lքcE9C6ՓC/{Ф )gg+2=DE /(^3eyV^p'hަq +:- +bÓꑞմm+9,YDA#D<ۊ1knI@1G9OS, [a늰BtC-1Bd/dUÐC㧦aOZF-QI06X=6d 霘4l0 R҅`I#ĕu=ADv#&L*PsDXHo)!Y}yT4835V_]m^25A밫X5"t%%8 ?31TDӒi1QE,T:I",5ðh}- +oȍ nԩ\:x +|ra(௺O 7{o+;] }'a3A . {&3sI͈d2`ĊnI9í9WGP`HZ0ZNA5B-8X."W:q32^xf8yh$M#96tG d. M'{Fy]ە3\2i7vh{E +X0m"rav)67e<zEkBVh8^GelĐs6^Ws|0 狫.-Wrl2+pc蕱`s.mJrSÀSա`/ 6U<1w:@]e= INRdLquWoh;2Fti>3 0ng=ܞq9 l8E +2B%5ܼhd%Y (:26PjܧBr:fi+`n ^֍=2-NoMFJ}䌘Xe@ #3Yrwǧgy8h8+[ZoZcȒKZ,j"ke%> 3=`c`<{X o|ADy=yӣuj_ʅI3bws7L{j˷}.uF=qR*Tz>nzGu$imy/uڈb\_b}}8B8͂j,adۭ٘Vh$z5rIB@ 1>UsBnN=Ѐ8Nv&&.seK + ȇe~FwC<"xՙ_q?*mD#ߞ+#QZ9N,czA-^7t6lN B{wqes P)|ïMCcK-8>4 34Lh=et/Y HW,7)ӣ3?P8*!FVd% Hi&v * r*Y3lE9&8v56)f+Liq;;\?ӕTJD1g"VTn#~y^vuI=(7|bql#5O[ Rbee8<0 9Ȇs'qˢ46e& ` Ǵݷ}I|]zHV6wS@>CeHta{Ew"/ D0d}Ld"!1qf0K)EvtLW2r TDd2Z n֩$nJbymf1:"{X?5ߣ4L. e_' Y #pT\V}fK3 +kL5 eR3a5 nޙtETU# D}}~OԻEN.iCVHU`] +ƀ-9/p;10 +cvpO59J\) +|ڱ!d8 Q]Jnhr1pDwa}KqY%|e5ͳ[. +lxxhXpw)~*Xsop3>o(rACVEsص yne{dNZ]ʂ:gadhR! qG(ND̗:urƪ%6 !'wGk̷ʙU 9L#N>]V^~Z/A5Pa.ku!I#o`{EcO +P7*X%lA #f0o2yWPkQExwJr~Di.Eh[p&ڰmm-N P"ˌ١q6X\Ѽ?`E{vpNZ ˟O Fqht_,RwΝ563AEy- >R(==%4;NK/L⮒=~WG(tϰfSTŒ楴sN\ϳeGZ7+3k&Z^|1" 8yLs۩[^UATzm{&i$ +$ǜLYM`HerHIxz8Y֙_tŬG_*]=4 рkT&h;T6 ` w`~븯C"Wc\jsCyjWdcYʢ[ރ+7>Fȅ lΤh-ĨЁTz 1^UYЎJѼ`B]QbfSZllr{csK exٵt$)<`pC7-J/j="GBK<ךc@QZqxu汓!eu<ȮtV*G"5JH1_LXӼ#^d܉ˬNUtB,^㈏U|y]QUꀊ>cA+j>#vz]uK*=רP_aD\t+Hw2v>I*#U@Q`SDRZq"N]^1;L0GMi '#(oǾ]+AEog ܂!/ lע #k!;VlP{P;/]‚9e!qLl9~6?P*!6ĖYw:6nȴ%E`Ҋ +9OW^AV + { +1-w݄9IXeYe4a/"$)a'F{^żJ!l}jYtst*?~N!$s0 ͵ +ks{ʒ9 H?֚2e)>tXWft;]uR]H-.́7*vgِ 28 8L| T`ӣu2 M`+V]AވB|,^ i^o,P* <æB˽ɎX@kV4c XIT"? +[8yKz=l8 +C:Z-bÜ4_~$ar8ǁT:_IΦEG$F#^6boeoaBa +*W8{qpGA,A5~YvqT$z0ҋ9SZEfNQYZ9ni)h6# AzJ h;Pihv%l5Dx,AV$_kdt-OZ نJ) `G sjQ$NXV..yyF')$2WwSx7K-H\J`Uҝl<[48.QL!/)np'Hf>H:i*V̥W|hp}{]WD$©~EjȈQf91jbУt<ޒI'==[,40zr/e9!wP—u\hրFf5KxL2tq_ä/SP +Nlr +QZLsUFï1, UVRpϻs E +n8vJұ~]ߒI  +LN + 9qTT|;6|ˉӡ/t?{^{HiYHu+Wbp2`tԊ32Xw=goEHm|uP=XHQ"Ucc``:WGNozGXSL2f-03XZ9^/|%K@]fGzqeCCbClcظ5DLlrHteUaZd,/J'Gop# +'Yy"CoB}d0 E4#c94s Swg޽o.HfKH\5%ckԴT\E@s.E.\Bg֕guק+TJ,UA3;è߽(gjE>R^E +*_N5@$adPL?aBnnNݯ yZH]UlC?JKb͐Cenx %'B q + K<0a6Fvg+#$UJ-9 Cܧ@ۂ6Rms倊 +: @gʽzA ^rDb`[BD(I>!⛒"@vW._Cgz#_i[p!TG^f #xEe-i,jꩨ?є&,(S57TXXT4Ersh2Gaɳ͇Iy6N*_l뫤[U>Cp#+\59j3*cJƛBv3sUaT i|q/\FUDQ%pƀ`ɑ' +nU"_eWRIU|,5C9\K_p"%e9j(p3/<7^zweN3MdnM"0RuG[DI}iQfQ50AsU *++'t0nLc18ɢBX ~Gx7f#wyraCI:We! +>OKU$V(5ڟ 0F;ڒՆ ă蜉<#;P6ԧj_3 +mϚenzdlh A>zҨO8 T~(PiCB\$ͮyΠ(ct%@GhET¹NTjL]PX L6r4c t\Vh`&NG4=ʊg#Ke^d54ӰNLpǎܙ? .%uW^DGs8gc^Yi:(~bǯH,=Bl_ٺ%80نENؚC: +ح(KBWgRX"i⛏=3CeaP$: QnH&h߼ezxW% PxzI/MX  @PxLS.p䤠=HjoZy;.`i`#.JQ ܦÂ)f:S_,3GHņj@uQżqΐXu=!X%4$N#"OAҝ4 p\lwOgn0.PSV<S72=rop甪ծSd<35k3;U;kb SRy$1s^Y!$(yk^[K&]mCsỤ 5a8_ߊ9}uO?B!Y}ukFhpĮIoVH)a-ƾd2I/^r8rFx#l:X9n0 (d{6iWXunW5@L䬢n%h}ܬE2b/v4xSy`!ΤWw}5u:|x^˕:O&?gkSsOZGO7Z,ܽm_2)&>%\P梆ka_~ + z~`?݌# [RMAM)\{G1qNDn㱪)X_e~OWZlG|/8fB#+K2F}x)|mn T'IJi#JQ-kTd9Ub; E 'gIzk!PG~$ U{\cZ`8 p}4ABzx~ROާ*uQ`$A 7H aCq&v)8u9SaWxeq(]3נHd+Uv rR*uiatR<ӟYwΝ QÍ'o6 bX\EoT#~E?6^-YOqyT둬e78\AeaNhR,ל.m qSd#)ʧ7Po*f.x#ւ1~8"Ps9*\ٳ| njO[bE <rAU8 Z H n8H85Z]!p -7, 83cIE:U4+ƂFKhS]6 b$}ʱ3R^F‘#=Uo!rDL(2>pC +,wP7$:Z¢K X.2FiE{V}U MS b%N: ;"iQ}41G5O[<4fH)ʦ>;i_oeiVe҇qW¿#1Wf*KϡĥϜFݯ;Cѹf޹zna&4S6vO([eB.E>) dǠX}|L`&vC)xx+z d/|*j2s}trWmF&RK#ѱА#h v>MIoi˩I&#w@[5*_qw)9q9O?~?ӿ??__|?ӿ??_ׯon7? _>߹)ٶ=ʨQAȷ@.FP]@z@ެk0<~^gG` k1+'i(mϷ +}#?ؘ#uZplE#pr#P"tFe?8:O]W|eq8Egf',;C+O(++.P +& 2atMԪb6AWqڗ{[S1T{|ۣZf׳q_h(LBvBF *}3m}3on0eG)&a7)q\w,I2o"Kx -~{ͼ .<ߦ|ģ+&A#!~Ӽ?ċ,^ //wV"=P\~FiY\vlXi#v~[{?;v4nЅf? Gif۝lT^@Gpn/vdo3z?x:MA[*ٝ tU?7>m<dsݵC:q{ Dx@<Ӎ,P7;"rޞF`gSL_TTqY5xO2]^1N( #_=mt~^ co(~)6H7p:4ЂSz4R-X)۩uח9ߣBBOt(Ry;Rg68]gPIN?IZ̗vHGY=ś-OG Xtȗls`fy\F2l}HP/KscCmfz_Ht;vv+'p9=1P;:r$ar7#&ohqvi6ޢd-Ƒ[8-oF򵗑x&?ȭkD5ߠmޅ#7\->#8$'KWXBD Uc}w#e]UnooƆi}g9y Nޕ}*9zvS aM@K:imJ]s͹?]: 5!Y=QQ'1oD/?OmUʏTmgIzk[J56߃&vn9mqqZjQAB~~d#FJFRv< #i\HKO0Vj)ovOWzf־|XWW8m]=řp;V7)Q59*45(۟-wiKMFLv4RG{ m9ݪ4YNaFm W0v0Ho;iX.d="miofbc,j6͡1lfr~zBcBŲv#VC/MaV_~:v<7s&`b:(l+g>š0p."qm.Hm\4hG̐XuϝHެ)r{/ԉp75m.ZK>:^݅pUft|7e\‰9?9e|8=mYP6X(nw&i1mL).oȀJq[ Ro|豤0Yncr7Xr7L>e~Zc۹rut GI,^޶7}l#Yo5̞×Zv.-fI[4jSP7/aND"J|a'}O8ȹ[0QUIU޼1C%jyx{3 +U:u2?o_fQO_v=+i~01>-~4&}e. }xǗN%{!;lif(m^bYM5/˭7G^~ҢO6S/WӨlwO3BCd8 =hh@!tǶ.3f>o:/r/lvkqia{{rp҇r{bE +qu0q{2Xtч-TbmX~ǖ=mcq3d-yɧ]i)8Xɷ+mK{hoWZ@{f,OCG/3Z>Ebe{&^3PmnBkT-ait[H&5?ς1TcLl?xoY{K@g ش#a>d_׷lmuXq?tT^t*Ή*y\o&:Jƒ,/Z{q}Xr@e92?LeȂ3CA'a*˭d> +jGS-?d/V1>,d)Pq,oS\pa;~ÞQ +K/;ب]`ѸԎl4< +?_毢y;D>_*5"륖VNd-d.WiD-+'8"GznM9xF-Α6qeVvxM\? w!BO1PVvs9YٟfP#u\m8t6&6sc;?\JnQY!U>ʝBN\@=|෫+wI@=@ӷ+s9w(ڮJ1%R>R)pD)?]]mTJخ,Jg}ںҨG5mjȁWm]mh%7[WJ )ػlWlT@Gbե?^Ӕ )e꧌9秬&-d%HҘAA)Z*^ڧ+AD)^qog_}:b9mWTx$`Ҩrlפy%Ai>yȵtܭyk4Frկ)*`rp֯4dxY`.<_٠lNz dk(P`c_yhF̛k\ݙ/Qn+D/3:b ;X ۞N>Ȩi'ِ X"Yƛxqz`*vX#7/X(q/3``^ r]/}L(&1&<:Y7;" ~1U叾L`!#!}o3X;yJԯ`%h/3X$4-kg3X@8Yx?` BtZxe+?&@\`9윎)9686N +bz$0]v6~MVlWe9>۷+=w1}XR@=Y;&;mLw> 5mJ ]uvm;ƻH Oaj#;ѡY-_꠫T^ޯ4b{y +;m8ohh~~mWnWG>^ jގyl[ J/VV3+&} qmY(=|\9FFqٷQ +e#^-2u˸iwOP +OCN+%GTGuUѫCy(l\>LUO#G֓Bu(}[sazZ>l{p2ݨ:<~>Oyz. :=UoƦB:)"MwOYSPB>ȳ/h /p/qu" N椤S@eOsEdpứ/ P| sA.g 6ׄ b{jb=IYnMV@oayZ.$Rzxb^*_&mF- 0<0i1 rm+L!T8E z&L F\0ugESg=m'xDaxDP2Tt`g=&=R|j#BY^Z>g@E>!YRXC$Wβ4 .~?*MmW-NkTScU:k!ㆢ{[8s#Yp˰ 7ӈ ݧ=#2Bn+ckg1ⅅ`[h&wjЉbA@z|I7E﨓oŽP'>}@{"%W0(H=]9ƫy{&r%H7, S²J;5^D$KokqT3enDz^k7h6=EFu78q~]!N0ıeZU*~] wr’0Q̊)eMè#5b<)ת1g!|dۀ6]'%57'B&pDt96tPߤGϧ!hz!#GBFA^8- ˁeGJaAt $$ +tЪh̨k v<-,_6U%"~; +Q4)Nہr^o?Ec0i7Hygsj.-i /0h)Hi/+AN'Adbox]*i9q W O)/<}~#.ndZ,q9o. M_.ɗwxX+> onQMt7O`Y<J ?M=NVzvѸC v:t4la<K +(^1=- bh% HC Jos@7VY*oހFe HShCixN^Os^X P7 +H+,?Tz=mtmh ,YWjxoVF+b B͆eˉެM +y':ƶk^EO]oN|Vuuܧ*o>jг `@(kHr zM.4Q1Rxs1.02ڲ N% 'SdEȃ|[jL)|ѯ͛ `VOS. 'fnbo zk+hJkY;+04VQ޵bj,f#mNO# +CCiq]`N~:ͼ3OͶ )C i2fkO$! sE8Ӯ~~|3kz HׂYm@jy60QeaDZ$mmzaJ@ 9~臽ѨE Oypm?_8~Eѩ+@<^96<)Q@A-$m\*yvҭu@<6w}l%-6z~‘2gƚoS?C7׳m'A]cݹWWgS%867 I@`AFv)Ep\]r]ćϤy=" N#]s~r'7/?5ݔ\^~0[n3?b7r\ ̏(9^f~6t% G Y.z>]ZBC~bd rZM&!&KcҊ>]TstWnW?)C7F{( r$z֏] Pʤ,iǻXu?eTB+ߏ>svA`6viQNQӟWSrDnmN|@y9# s;07mt+Rafᑯ_2j/u7?*f9uj3‡b~.7? Kj>W_Ϋ4|*m޼hG?{9~Z_I0 vfK\ 9&vљ[\rS1+ 1e?á4vS: xMgi·Vz ո}Q2~{5~]>nj㯚E7Z{_Hۥ۴yGqw>*2%3_Vmwޛlrq) ,S? aVWso_c|<+!g{j(7V5am$"f^dI==.˺4rbފa2j{ud..BMo\ _ZvbU>\PLSKBL]XhYnm/-2\%z e0>|BӒ3^>Zpjy"W57+ LY[nCPz`^U^+vRΊQ0mq+XX[!BqG+xmdj∐RߪCQn*laաSQ{\NUP5hMB!Lg/`7o) R$Sr@l)m)f-,iۢwcwCxF͢Tͤj-T6w +e Vtaqݞ.6y&Zok'jiz :Z۫( +Om +7|/3O&X?=O+}l;0n/lTuR6Kw}l*i(uKi,sdBp!%̽4>"R>21 %}Lٞ7"ZIV.v @̛uVݖE_NEz 4(:Ţzh}[Ðc*qKMLtRn`\ې~R#m!)c\Z1QȻ{? +'okj>mJhvA&Wrʳ!?y`NbϗO?~N vSNE69S\j/#e? ?OQ?y >my|~0K2 INѿ=w\>vXe_2͗0E>TB3^ ʑȩrj*43 RSsh?i*z?yDh>#?߁%ЭSC'zhΤX? =lf4{SQB(!Cd1h_x)X;a<ؖfSׯ0Ś{ +Bp>#<ҰLunOF.slꞑTӲYϡ]eWG΁5XEKR=Mè^AOxDq_=. +9O^qի !g:fzUzΛNqhmљ4Td͡zkpF^W9{|}O6{)fF֋( v%];TJ ͕(L6{PZ k"@Gbf9] +$%6L~Iuر9؛a:[:Y 9>>HAm"T)P' VA>o+j\!P:0Jx7̹%rG/ a_ >Ctbp>D7Uy)pht5U/fs[V4 +Jyl/jy,?0c0C9)F4W=jv|{h?ɛ`ɴ%f9/,-iuDʲj=m4Mљq3o(u#$JCi|3svN vP =^gsAfT(BatWT\x41=3mMj uc`iЬY:H8hCϗ"fZ< +zWKC0{R<Cܬ)7.|o6*z47p Iu{~:\U9c% ,Nv SF9oVJ.@"Qd9k͉tDN~~_[>'TeypNYp*N-ƳʗqЦ"rYEAkzF).894zS8yML!7ՐTM_:lyrlF¶8X[KCneQ3ֆ Gvc*i^Gx[8xK{E>/Bt8O8@ +6C%ϑɜ@SWySңqè:D C'<|@ͥ^nqYJ/ + qa\Wp)b*2*5x>7 Ck 5ή_X^N'U'ƫoLϧZ ,B`pO"?:Kz+ +PSܾ*=]8p-07^1Cx-e;-[Ct{>; \٩r`t8qLYgL$"R`qBEpĝTWYsVsΥ εg^1x#|Lk5A0r#f`svheYlRPo脞wwGt~udy:h}D9o%7hqj8Orރ*>;~@?깅5XfՋ.<_kW!9%sCj!~,n04&?.4w%R?@! =UV-!iNY9qemI;7p{ ;&QY=?J*+Ys i1"< @aK`H%dD$՝g`]}3,``;w+(s{- L;D >GU2$JGlfhds-}@0,uټ}mY0":$kKֻӲ!!\ SQ _<ғ9jN5=HNv oV{# `%@Ǽ^V{ 9I+A|u˚CH AX(y޴@&NsЀ"I=1DNM`zglb.5sF;^ȌG/ӎuoR#uу[K|my("~)f0 ).w5TM5GIb?G}ulғG| W8y24@uhWZZ eS/!Ĺ~tqʕkX' Yi!k,Ғ3:zX'u >S׽;b.jev޳SxΝAgtÐѮ/:⋮lC劶N]ozazT#j.wW1U.Z`xVäOfN{41C*~G:՟za!6'Jece>T|V5ei8E)\:sb8l̼cKP2p6 _M|P/CS2Gy)|B6D)tSφDl((%L')@1|džc"/S[YVJrf]H=W^CBo m0k\;5 + -ՠkK fpeЂXF{ɫ,LҩL@:R!-!p ;Bq_J$ȣϗl{2HY5 _g|p +I_R:ŚɆlDi[e"gv擙sM2;&~Ry3;rdPc$<ƶ0ۂe)]ȣRVe +P1/"΢iŅ]׾KnlDY+Ba>$].LvkrƷR%RZZq{ޓ~5us?tdAqp='M_c : 骚2+5 LGMIki\5c9M4(F06G'sڮb3~`Ŕ3PŠTsMdȋl!;}MB&`k{8H+JbO_&9أzT`2h7d[Ŵ %lg憜\N3bLQwPh,FijкM;G+38Dtnu -zp#e4rhέ q\ ʸx朳WCL!FRt񽆲@]XNf@܁)l0צ.;|7yPlC\L*B1[TfY~K\eANҕCc5MN~%DU{ h͔F | {>H -cA4gڞî 25n);N5 +.f:lqǶê7t;_M7~fDSM%=Ѿ𔏣t̡Ѳ*s b:{;MQ;!^e:l!dV=3dowՄQlHY^4fnPv\7 5FHb\Q'/1\ZzYN6 W|#¥0g #hR`vPi 㡭@lXY-ۗ=C%#SBFQM/].97a x2 BlUw/}nR0 +9i;a+$S(0`W7IZ R|߈UvJ?0esK?"[,%u=M=_^ -m(S$æ\@$"e;wR4#ZOr_)S-3~zG7`6hCƒ27~zn7XsxB@s} bϯSzyqլ)`.dv)#d9\<7F3#n $퐃3w3<9R 3,?5OGI"Tw,mr!$BV= c rs7ٲ>h#P#@?mù*[zc&0^R48v)ǹk"f-=^ rxrJ װaYÐM'8rVgӚ(ƚ(arXHu2 #r{a] ;OlE͐ –|Jɩ/P,"11P٨^„BKJg?)aѲ| ܩi)^82Gv!&/?|6((<(q.c/.uKښ;|n|K_o ɴor '؋-jzWuP[ \EYYLSVWp-;eOn:nuꁒl*A,]Z81J2K0|)t55Z|S8loKI'orJ! {TIΞk::8M2G¤ht}ywlcVq Gv2h>_bi]nDŽ5F^1IMeVՉ): JGȖq~{ RSdQ\Dר_u(c]zqpo&BBC"^dԃKJ 3 =H|Ty_TaDku]w9zUOeDDӺԾt-w8/n0Xx)o56T^>ڼ<H `@Y +0R\Ai}Ws9*Um>=R]vP]U0{ +sT GLFtyY[ΖEJ+MM +Hm')umZ͇y!U!F'v-EpRVfgF 'eBp +9JDjjݞg)ÞV% 5#uAj|@%Rk.#ZǣGur1RR籷mrIi}9m3zX@m_NISK;sA5ÚVt3Ebv%V IcGRz V>]0(&h;nM+eBҤ !c@.( c>{Dl9s@꒩+N$`$IC"Dn>D!Fp,̢D=bԕR~<9loE c2ɂ!Qf8c5?zzy棆?6sވT=ϫT%*n",]d h$lb5k^]l5]R#[ y P `N">ɵJm&u12I쉃BK?]Zp$v0' nTbs +ܲt}T5E>#hx4TCm8DuXX+A~&"X$zArR "I ΀[%z 3k B,)D<"D77}8U<ּm.eऋj3;SDD`;ak5Әvwxc/pC)Hҍ! tTBycy)t(vKY }Gd%;^\7~(?#ėh(l/]j&ӒHyﲂ>?#Y+#dK+/rx ,^kM/̍n% س4xfi,ђx$')YG*4- 2~&3`E~y[j!_W/9}聎+)5hNj6lq8\t F}kpf9 F=0 3":AM"||0[ +P{,J#m FbW:G,Do[\?A?jnmA덲l1X~հySldz$Pǡw6{Evj8ďWD?8/=\EH̀L2f8ȅ0^R]Z:K#(NwmO+w x'v'&}B{I:SB!_<cmhkN:8Ps,krcY$Sf2 V"@~r(.l##?cF1,d}ϣiBz*;jPf$TsԗNoJ pY)JV\z/{ذ R~IT^J8D44!Rz)jbC%817V9OR:W"ކn0 ZFD }òHͧ瞨CЋ sR6A‚ϼAǘǸ$k0!Y2M͆b{_-eוƁB # +c:+ݷ0ā| sMe +-΂)m!wݪp +meԆ%=M),*YKj%f6"#X $qur>JvXNp(Ospߠ9 crR!SHܤQt)sUHy@uw鋈-ٌGi"$w%?4D{CoãZCd?%O@>"g +byc}nvh=~,1"hя~R\C0E Q0SŶ|i goW+e={!7uNKbҪU Yj[B $@O˶A9n|wssS`^{7P2,F<$7iiʖ1`YXR$*Sss +<ւL\l_^]]]A)#:Z!Y@|Rfv0FiAXgco-Z +KGUKDioɊЂ,bu d|Ћ9eY"Ƥ$+ +T-Bd]S\ tչ0 RZV@cc[͍I7ì%^_"XFro;R^/a3yL6p&-ӆKG\R[X>V>u% " $*aI쉎(jR^6q&y*!xT{'}D3G/3(J +%t,T-J {]w)-0]xjsh5rq2!YI4]tfrZxp%*V *CȸKoIcR cpC=E#X^)Y =5,uWH1ڂ0|V:|9$0%"yq#z L#m$T,;@DyK59ZJ" ccV呒h8iSd>Ee\*_McYAYpwPϐ{JF m X9!!J9Ep&YqܵO{S3 +m=E4Tkr`)a(0 W4Dѭ?9hZL5%!޻ 8Nѫy9rKF٣a&!FD,5/d /iJםꕭ#QS +/Z'&V8~P򪁪b/!@HLIS3,K0;֪SK0 +-p0{ jEXC7.DL3tM@˼nKÝSKHHa% dc(|Q$੦LsB/+fevYX,#oV֢'2ȇP.~*@j6MG*f`e60#\j^-效BR&7zIOP"[#zУ"DV+?KWpBj"%^ FpC"Y/I՚GH)xTǫnVvj)[x'jW~C$\{j-A!Ӆ<@'k"͍AND N!}Ѯr>@ވ,l4y_a9KR)C*9>|^^Yx{T0 $4kZ1\,zxW{K(eߙwE ;o}pYB> +K٫v5|kidv5Nޏ[4`bDIL>^eh +=~ŵa>TtANظƖ#o=4[|+y\zTq֌k% +|-^5\|6 Y \2Ua͓e Ag@vɷTz!(vX9)T7Tx.'/^Z$`kՕPv0*0^a N +WwM# N$F@8 >P'>>O5B #b!N +F,PD͸ g䐽/PcogwZIk ',+JxEM޾`~b:.ݕd-z$ >cI'y3+jQ045 eV%*J'P۽.9'Yf. \|QP!mݠJZ͹*Ԛ!„Pnľ+7 C@%m%@~Tڼ ]J#Z{xcmXE=$$/WGJKC1N[muTdI0<,a?Sy^^եRY:Ġe[W7`|Y,,X'I8-]5buޓڽ''\ rBal8'>ch]+YJϳM=\PBr]J"SFuٙGslw>!ʫ{wgL3SWCAe] {D8/|9v'7)- DSSK:!zt7kq@=s%gn4]tk 荣w;;':-q8seAtSCW +>bgC/X&uybҔ &ɞ0kP˨DEbE&^$%Q=o01Hi$u(D6}\dH?zQ(AڷӡmvT)p{)0z\ݼnDy??[{hm"rʀIA=&.w瑻bq>D u%z)Qql8WqY +AY{8RCX; \+z0VpdCt;=q8vO#eN!s^&B +u5EZ xY#84!Ar[G|$u5n37 JAU}DoňC[ȭxpH +{6<(Tq.S< XRu 5{ʄR F~3*nԢcICM`=E4t1ƹjgTϱ%BSz'si!NU|Z&C XR\X&kH + d+RlLU(^Al ÝE]oeJ@[L.AfkM40JQ9+_\ܪ*/ֺw5L9lmW8u!;caUQ'}Kiv^p#[tKq,y}ux q7YEFu0h: +%ZlRK*s"nmkAz&AA"s?Pr%NOzQݨ)WEݕ[#I>e=| R +NE;z.VŒF4)j9[?٣yYoA)G0P]޴K ehՉv6Xo `܎<{ DVȌaZlU E`?*O1o6ޔ˼%@aB^ %3Kc/|{9NuŦ8r^`hi=cQ_2o,-+f +OIKbaC%(qWM0Mf +ppZAah+ss#D[:jؖ+R?u5쁖SqIk5Ua =:~I bi WeWɪK9 +.)&,vD ]|!HS*<4['_ދ}"8Stms?)$pd!44 |#Y%! +ص{F'`UODy> ۫nr"B7-$<&(po;Yi)7b/(!']})a%p#ĸYٰգ[!*2KvKGLY%7gM.O%;6+U +?,\=xz Y"447wU k`Aݣ?aJ1Ք% u?aɑ(}m5OonhJL|g8ol{#_5$σ) 39۴Q"{ƕ̸TQBԦc+i{ǜc'-~{j GqA{A=$ԨKk|D=^W"vnGXh\Ж82Q1gRkZy.K9G:Xq˂;m! X´/Shp^˞^=$kƁBתl6z@*!k^!5'%.jrkD/I.-|aR'˲)C ]3F+= +%< ٌl^KaÍx]®>N.A;$EsMd.IRS|M>FQ|@{-V"O %D AYR!4c'"f|lxmBb!بÉhPT$i.DN~}dc/=#M' } +U Zt&QPBFad]֢r@s:'Sc"u[rEO{'F"r#e!׌=#{mZu5 ==Cw&K^TzH=p-جizsO) e߽>j/!3["#1uj`Rdk\9J*>5(B:B M 1qy[%?7g]0Nf0>)>V+s}G7Y:!"m(J@ rq" |YF<6'xlKR\UB}k{o[ +a.vMcAd*R%^*h Y @!xa7.w Gx-lbZj=L/^HS Of'! -ᶥeQtn{l"p^Ļ;eхy#0^K, @ROVfF +bZ<& +R +7@0AxUU=f_u(zh=ٜV+}ҔPexrW[BOE3*3 OrG@~-!eǟϺk,ΈjvLq=-  drl^CÙ .8(LP}qBaBv,QE%єUy۲j aޫR?apY*XkI۹!8vdFoS1QCUdS%| ,e1XzX&z~w#]Iꈷx[ڜºhi-I=|QCX3~U*%x\4ӆJg(=PzLb$8SGCz\U" MYc$-&.zZZ kQ D͓pw.WbiU/f~ňHI3iX~۰~Cdߑoҍ{|aHepeZS&ռJD[8_i[9AOE7=X&޵v$P.qb{/I}Lg RoRvi7w*xD(2 l0xֽȋ2׬ʵTjTrBC9-Ná69/"G5J& CR12c ׃@>5%ŸnsRyWuP\n @U۾rB\ParY4وz"]\ 14vV=áoJ=&}z7o|R_k0:Q篺 6ͦY`j~ +*ѧqoL%[T38+P?o۷C3|VJjwpՉ=ISi69hR֞=~ZGLKɈf?2a#xSͧkZ ]f[=vw5{Vv|k8``{(=Fxl; 2À{?#K C/٦GbS]MkOv3O:h>stream +ҎWUЈw{H8K{hzHo`gQ4J~˃[2uoFfY|H &!JPNTIt w%@mB֥Y*ǵ*WYY W5R/g|f6-Xbj~npت")q)* SadH +rsrt?Olcp3EEG z9E ErJU ;6B*.=R|>U=h \<poB`FGF$ H3$b533n}|BX߲sn Zd)eմOVRO~4{.4QެnT!LjнI~Q3`?+#@BXGz,eh4 pSX0әxIUdHKUj;!Yw 9]Mx W=@.#;ɴ`NWDm[W0_;TʁmΕ.PD_ O9瑒9Fq:v_5쿌o1IEȨ>.2 #xwו7Ҽ?TFs,+t|%xzAYq5F4V"0PyށW +5}KG9`A >-FiOep*a3RiG۰[#En$H#DX5{-s5zHE~<{|@-^>0(9w+M蠫l´)o@.5,D2Wׇ>V "~F<}P)4o|+`ž9p-CmKܹ;>_=Ԗ_kN@ʽ;pyv]%,Cg@CauaH' +u{x7yhg,QِIJDޞގ$$$2}>) 6CJ.T $K$p* +;G2#Jw$8)+,#">B5 KjKjQd8cX:ZL5T'rYflZߏ&Kpr"`!lDT PJ_:>bOmw;2|ؠ)Fوӓ5z;mV%BV z)% +ʶ-{ +fA7(س6xbuWZ9pŚfq6eS79ܾvʕCM~o۰|sK XD"w0-h#.lGsvrj@ҤFZHFi!dӈ; If-֘P1z P<:$ތd/#̙O5hSI-'/){yIVN 3Q2s<CWƄ9j;V2DN8%n)N.Kְ:RmkzQQֺ]R5ϥG#c+G8BNJ4kXNl{`8x$VQNFn;=YZ+I YK(uڋHd¼٩o"&aQ ڑk!@vϛ|H{4,ȅ;-(>'4eC~2Vezj۽%v GUT.[$Ҥ:990j*C{/²j ep bR=WLL0Q9V06pU$Ȥ>\<2 gkAgq5RHT#mz.I. a&gB/2xTR +~9UBt5iꚈ̟et>O@O5U"w(9=RAdO5z F1a>I-G*CcP@;J`hz86Pr"GC9) 6 ) Kg_hRD,3=Yv i4-\Q>}!aJPg,6؍ZCi2Lw[k 9?!i}YG/fḰ<.XYǐe^ y`.N Aeb3e!J5%>b6(r6zN` +:PhqIG9F7ԽtK hYw(cO +=Snr06jG%z"zXsĢHcL'$ +J?jB\+ٻgM0DDb`,Z=O(Kfꅊ#+\ (w{JtY #SW7[8R*仉lb!ou3d[|;RI-J}(YHlZշ]ثK!9/[tRڕ9FRxJU{jil#]Q2!N,jJJQ@s.]b^t$Z)eJX\uNHAtjT:!XcPJ$C/()[؈P*NSNȘOX<Ck &q8h:hıb;mZkEPDQsOĕ z2412Z;e=E6+\1cXZRruس?3jM=;.#` Qb +M,+1;Xak}]bB+tS4=ĒD#v`0MKƕPQ/VRn!Udޥ#U=& |naK֭+Rdk' P_' a%/ ܼ4u[Qs3R-(h.+y<[-m|!O1<Ο4 ^¨$Px +[4 +" +'B .X=q@JOTӭw(0PrHq U:(4⒟j@[3-Idn۪ʙ5 ?oVaѢ@#{R!:x(dS`Ha/G-D^ 9~8:?ؕ/ x*L+(yM`k )Kv/ SHc?@GVR@a'I*:?@`?4@'<CU PI^$D[:(T+#;[pKQ9fDmMGA/jH@k7E{"ZzQ}Jd+cl\# Fpv;!G]#9mܑ怄B N.pReO(=]QZQǪc$jһZtq0h>`lPuHtSfi;w Yx G[KCVP1u Qo$%a)A\vfPƀ0t[. ڍQ=ߪ#$˗6ޜ&_7H:lߏ.3#,Cҭjvg~Ю/R#!:NJLj!oG|> вO8WLE (1-,Enf&E JZ +/ek]*#ļ5A$#)3el   66iie#'-m=:%Hd9Mjw/_ йbLsWF>PV^Wq ӱ*Dk +I}&e":<,]]C*l:|DhjWza#= jV1]K*`K:m8w[CEf wU=_JbC(/Pńr'9K_#@yEL!C]ג \q35A/ L۫oc#&Ɉ + UMiy>}ݼ`$F# _px=G^A )#" u=9B,hqpcHsYj8AV PΊX@ 8 Z۔q < +wal'2+8D3nǁ@Aǜ;2\CQp7FXI)[%A:A_GC8F"x']zɦAZFdtEwIKe7[ycZ$u8;t{T{Qi`b*X{ +qeĞi=U֌9n)) .X==P4)$2d(Pbx3[}uG؟*sʼ2}>PAҶ=E["Fd:b( w8FL"6%L^휱{L'[9oٛ $k "+u0(/KU@گ%R(LS"GCkVkVPIk:LkV#UTJ5r+JiPPi˖}~_U؄DasfyDY(\e w$teD^]%be ݫttk>Ok|ﰰxPF̈YƤgae]2RiQOUkQ{yqSB۶9ecՆdߤgG {Nv71@[Q3ŞӼQT.p›D4<e]`QxLXʾI6td/(8{3]u(BeEM0!ґK} ePɿ"?~jq&KPfM O芒T 6i|G4rP[4!8ε\i-x*0tݦ͢L﹈ l/r@8a !9?)|l u`N>[?1u"X(95F,$Z%b4HnEGz8KQLO JXF( +5ץ@=}@} !P5WKs5p]$ +ZyR;`!ʶei͔NJD%!|_P$kR2َ1fIrF2uΞQ4L1VXHnOBY)ڰb* tFT&)qW[pH Tkrޟa2BϮMWlIi[g|v. )+YРK{'-$NJϳ&U']}+%Fu ~gV0R":Zyu/X_4qU1E +cKԬ'(0te_| %iO&2W p$>;,Ha=W Z8J;3\`\3+B +|@:l܏#(an㝋R$bٛn +@mS"7Áɹr̓I]ss.y- w"{]NS +ؿ\/.s^ ռfu&i3U(7U)7u;m9r`ό|u͎%0NKTШbӋrU-g1 NKW%.R4B`8tYq*H.(bObNHN _&{F-HILLȤ 3+s렗>O2 FޏVHR=7!빼ֺ};4)3E$ GC^KFnj ?*B҂l%bk|TgثhPnp?v$D].JCrZ 'z˺#!!\A5v:9-k:[>oy8)]ii_I-Z~D :펈vP/l$Y{B9% 췌4T gR,C"/~mb>m^xŔe~k<ʨUm\i|iȈ>hzD_!wv2iO9ٰZt@ H-y%Ż*yO=yXDR,1ߴ`sco4[Ą!#,VNQurl.<<]{$)W*o5=EBlrD|/px?4X|P";B(S׌|#*Dk@evdiE;,!?K K$4$JD(`6M-2|kXOyCƑQ')TX^{8y^jZ ^-R%w Kc;Y|;"MZB>sM`8 .UX!E~GLⲼ +:d(kLm!0_}.5< yc!N\VϋS-~ʏxIRFPxoE![p׷m9#nsc`ڻua8DʂUW):[ȪCKLTGn-Mn'uQ%vfܶZ[ +y1}9kBD%40>D|LLcϑo29|QH9Əwɲ# ]H[XTl{ KU$maDX* +rtJ:p@=Yw>?sP5%0 Ob^L-$R)lIgѐ\)QAfHOI(E_+09=3K΀9|Vy}ż/9/]V\[4_1-s`ðIv ,Y)X6Un%ձϢ}ge0_fذ+4CAk3E]0$--S_i/DVF؎ +A4 74!b-vxnI6Sk. @;Cp4Idncx-`뤆!G0ݰÎ},@)DZL$Dg<aO~?,f?Qtm +C?=ƕa%-ٷ|Ĩ6kK >yO-|=ܫ6RLGɾث%S6+Q|zDdΈ~eV05.k1WjԐոb#'jc#CwhHp>-r̓t&H ԃW`z("zDTQfvh3zR؁њ$%Ŋ;¼$cņHr]tE2H s e@ruMd W;X6_ P$Zeu[|9bG˛GdtPbKRJP,H(iy> ΋QϦYL|?$A$.|Ԁemn^mU͙ +pQ.<ﰋ)?.td0 5lUhKA̲dSzN -*+O,ce#g鶒{a%EkXQ,a(\ \$,nOovw\{).XZ&w 3K$hRM9.!QJӺM3P$|ce̗'N>c{om}٧zXn>T&/Z6&c_~i%~4EbFSVbp;'q(ym]H%%(62秚oJt+W(i@˥IC>W.9l6ɝO{_\H+zA/9G 6wD# K{\} ֌^Ł;E#(*8@P<^D@<܃ qo5 w?6S8L{i4)"Bp FYHoJ\)Z8ɜh5B%P) +$D3CTT%F Bl⯌Y):DBW供V?J:oSpb!!@!R Z~ +704OUX $:-r +m 9_Pi3Tpg%!2#X|vE}v{D%n +|O],fɒ#eYQDždAT.L{AI2 &bJ]J e!JrC(6%h*7R nQW(Yn7y  +/@E+އ9'(>$0ѫB/\ hRvp-GoXx6 +>]iu+j=(76B_r-u{qS]EiԲ@- s/*@| r m LH~djv_jB#xx$HbUXd4;l1x>%EhJ1lc D1ބD4 ҋaUlN/fçe|Ō8E#(:DqF/)ߑY64,kad@C D@ܡs3˅Pր{sY?eXp0&QN tUzirCv ng$%@]Y%}'B,sTCXMzW`cgn?.cq uwb!{y~e-#<5(b݄]F ߸m#l( M/0+UVɛ"p ++fur+0YE:DL'Y݀~@?,<%b',D{?(*Lv+Dlȴ9$9Z fDÄbc jոHuZ%ֽįSdoTa\A!`͇֋I|fcȸ_?/::=˃zʥrKG67L-L+nޑBr`.5UP>`Npc8cJC)(-Pl iqacO4xKZr,UyHfK 4X|yj(77_=!E&TGћ">(wSZx #BߏV껛 +?5U56POT;w@ xLc0M)Fe]M^}ѷ0á2qc#s/Yo&IM@%N5XYMՌ',Fd +b ϱ^BXAADKī)+QX<cµux~wVYJzG4iґjwAFO"\YQEUwLCzٿDZ#[lg W05$5!<*.%h.M(W\YTѧ+zt a50߻}Ȥ W]` 5l?.ވ5-3.\'k5φc1%fA0$]m"q-l\BǁvÍ$PblR^6v)sAK (#*mH&V>ه/$Gya+ؽ~bO\/S8XQғ젴/%vZZ*_ÛML.Vz 6[Cbܦҥ|A-$.*J(Ika*wO-Qt+baOQYWP3 +lqAYdcW7Bxksn֯xQ td|:'$烟B;gcyJ"1 ` <7 EW6 +`1 %%A"B(ΤWꀑ K5d=Ͱuٱv%Jas[;o \)q۟?۟_/~_ooկ~2g}{̟?˯̯~_׿rÿ|{__7%th?rJ׿oxw Ϟ W7?~_?<ڿݾ*߹o?g>9Ο/ïֿݿB2.?奮r?oo?+o^%x%~YɜjC, ?|_C˯5C&HD?m08c^'QD$F?JТ~a8u]A|=L-Uȍ`X(}`T}fݼ<Ku377"V?F< 8Ս~)kBq`;f;cL}x`=-z_Te+緌u[)H )n8,*eZy0xxLy&K煜[ =OOߺou{xh$6X􍞝cCR֏}وN4!ӈ7kX +st:<қs!# FRZh=%4ߨA5OOg?냙ZoRU٘6jqƷNMͷς{c OS,w+*C'ȩ[6^< k|nl~KABd3h^|7:k,+`jq-cu@Jҧ&VbnGۈR5Xi,7q2_9&UώL=1 xf&ќZkgnrnڛ]ïn؇ W5~l=_3^󰚟Xrgn_4jEM6S=n~<=ީt/Ը\ǡl-KI!e3S2s[SCZhganl|槁WǍ/7ќ1ۭKqɍˍGvj8v3ޯRs?|㶖g3Y˿z ym"~kjk@4 6&!̾XD#hl b +DsJl6FckAKcϘo渽{ܢ}= Nl} ǁs +s.DwVghnɤ@}#ra3\;l+x} +62>o3ٌ}͹is^?_7~w2}lzHb[ + ++حƖJ'~Q6vn޽h@Z1ꕏAۯKR<^\@>^@>dP9_$=5Gh+S[+`bb{=]μqzk+O]_3=Sᒽ/"~9xlyLfϾ%#-ͯ +U>hWXJuB@8_J9@-%?ciz7f(;A8Hg`?hsbbp[u'F|(yZc9ťqzMr6[\"'7bB%I9fTJ]~99e(&[u3?(IW^Y)˓А\NoO\,ṳ=Ps,g1sz3#uqZ[CZsa}YnjBŠJмrgJlb΅=o|a2'0kBqz&JƝ92lU5u ;_Cdl7D[^7[߽F_eb%xN s|ev\S$wt \_-Ј[r|Kq ~n\lJ:JkC=r'9+U,XWK]4S<yJK1`~|-3->>O $u<[T{,"U^nn3^!8W'k+'8+~ȤLW(hLލL֑(5Iw b *gfqFOp z"%ڪNcx:"}o:񼈢Y#C+׆k 9oi5f_'1pcu #vnmUo?uϧeHnQNYrr6(-꣱yl)ԑ>ڰjpc.e''(Ԡد\#DX:*z^H# +'s:M.x83=`޳׸3n2EU+b'wnlWt=g5@r1~R_$|crrN^C)H}Riܕ_Z\128Ӳxvgq盡={gsHבunmdApUiqEܐXej+ <̃g!.[r:RO)8wq9Yr yf~xNGrrVq$ZTG):5hXrnb.4֏o$A.n}} +wy9Fidr9D mc|qhBa17X@3̠c?i+B0(-=e Ak_a]<AR |4K&j$X^_Ǚ֙ݜ D:rzֻ\-gZ`(Oiejgh#>syEL5UBTGǔՎ+sr+c rYwO6Yw?.k"jR\~H'@!][xuʙxml5^i4\"N ]9q' y-FJk3 [;7~ӟm\u,ˏ#o%}U]xqs,QY3'0^gOGc{QUNXh< <+\r? v㬙.l-ʱjm +b>x' 9rP~Z {^o4[Z5 hV2X+{vw4WL\^Sߖ:eؾW#El~ex}r?WȦMl p:1͹8?fdY1[Jn^?7?EߌD7HL-˪|+i'o q&"+fvr'?(_,8-@ҥȶWʜ XW:ņMyrGJ+Ȱm: \ͶϜTJ\E?} i >cG"婴Fu?$f׺+]'7i oĽ= Vdr [C#*o1A{,ؿi8 M_=a+fT4iϸY ,(Nq|4֞{q2wvtȮ3Xn4*93c/2ڍ̜j PU8HDBr|"\~Ӽ_s^fQ;hx;=OY"CzR8l:%oy88ށ,&X:Lɹ .:W߼rl'g[bՆb9'pBq +[գoKFlQr9@ykh.W˩<K4"awƭٳHq_u1sH:x; xW\:g o{"ěUkX @ ؊ӽeǞAgu&uD/26GV+^z_ٚ'^_b ;ۨ">'fo7.y 1|yڻbH{ Y.s;g v_@<|7bSoFq +~5)U{7wu9ūD513'F\:Uas]A6'"#qt["\] Q{R;9=/R2|B'h-Ğd~Wv'{R$lHzWc@X,՞?x]jZ^KL&)3UJ+Lad'9(ohi_(ڻ%**c2j mkAe<4=]_N0uŊNƄ"Z8\;hRǡҰ'SNvx ]Bak߫nf9lqk"N7 +͈71Ո|JN#*UbԕhL?K&֥ḽ]^ {1f)MC3bZ\YWAxXykuz}ĉtM5"?J=Q +")#+P >UAELu#t[܇UOn\j;f6g:A ΝBVoD=dɶrFrDSp.X~ԉ8_'0W3 g˴ΔVrouxz$GbוEw=4֚$5:h4r;״A?kr,r''W^\_J!(c8s0#{ES.MEsr6=uΌw㶳wSއ4O@cF&Lqx>Ilՙ_l7Α_Esw}=nϨ>xX"{ 33,+uc.ڷ?.Ds}/Nj-]kpF\KW~5kWrXH?g1Oc!u>6dW(}>{3Yw?QI}oHs)A%Mg(2"^S|O=X=.b9I6ΕZ-OqjH뎈P4'4{{^'d bT\NmQ}k=DڞiMVd@^J`A41$5wp5WH͞XrNz|8Lj(e(2\dy$fy@jndV yBi|W՘G9kO*I<9{H3v.rsBE2~ϡˬ~" +Qc9/ "@#"K/l#HlO/BG +78k0jhI/T/|h?n^i^,(Jt}ўNxRPuȶ?{'GcmYԚ㗹 ];(|,f 2zxpc؆8W-g'r e| +I؍;s7wќtf3L)A=._g};ւ9n\G1i[_&dcppzz\DŽMtS-jZɸuީG;(~J!!`08zdaC4W#qU@h]I!sW-[IvyÁqFΧ+jVI1\BJN|N2Ku&j< Y2)`ŸLF O?~깩&Lgycϯ؝T@ufc}PC+99%>ywH`JK<8ah\yj7auP N'ey>nD8߁_XF6gVI,!F;sޑܞI75ܩ\#~mI:TJьC@^5ECb~ͣ6`GrYpv(p,}n/zתI# 5;?{6<=%TV+{\w}^29I9=kX\81\ĞðC#6jhm7HBoa?S9@BQ I`9UH)vqת/w7JbDKSKNLCWͬF-F}rBweIMفpTP]k"b`$AW0Ӫnf*ATsS1( R#|Tܙ)K* $@TWO{=^B_,O!k^A) EʂT0UTuĩ-_( : ,E!FP͢Ź2Pfm+@U3o sSD:a+ipbH + }K-&۪5*G7TpXN_+UnT5@S:q (IB ݤjV*h ' Ek,\+(=(9u57>Am㓧P*K=q=e2 +4uy h6^zCI TPPOamd -?v uC@(!Z>]#eMH.j@O(gEEkeyBI2oZElo *iʥ%ēzn zT`h4sPƀw6}C=ZS1L@:gB ZWX6X="Զj +U[PHLn'QXiF} +oZ*$5KhKhD(&*f +ra7B 57j(i8oTը>A PX* +rm)!JǙ +eb4ᐉJ@XJMIRaȅl,<$%ZEJVfaj#,5PS)[]T{T]” u*;Bo.DC0cB'=cQK)bm*[%VxFz}p:Po4;0k8xT0ЁzP|> B&b #40hVnU 5TE'p%q#T\ʪLz-ONsZ_Z,4o4yz۶xʺԶOBVOzU {LÛLW%Bk2Q֪;"cSrY CBF|"FCTXśP +©pڗ>@ t!*nwjnPWkQeQ7GTnlu9YL+=V1sM9o*:!jU(:+B}jNG-¥/WB8Oߤ"0qB|PðO"bPX TX,{.w!P]/תX$Nb*񰹿>ZJn_O}Ƞpi-HP +I A[A *K")`$j#IMLDҩ* {Dtx`u(XU ̓ O\Jé+>tRm~{U#[Dϕj\ۺzoɡzH]/4F2C}ybMyg,訓p!R (&bz@ EЬ'OlR5SU bBWTZyFYPeT\}]&b}DОF} 1+dKj}h=MzjĉJ +{<:\'+cԛV]bkSl rh4$AaT#UD֠!Zu,X8TYB%BzEfѷxK>oN`Luס?6{5VX;nS6ttvym<tpjA z:+z:* ↚ttu6밼|jbv.&zpF+ܲ-pnQſm #YWjVv~譆ӡ [1qfzebbܥp3^}FZ4z&x %fOC=$cè o %kVmlLJ6[; 5೙٪a.Ҿfs~72$fY̥ct)j))C磱fdw%Ғ-{- +-2wfd +K ĂwѰrӶ֔{ % 6w he#lUbκiXkXkm6Q֒56VKYt 47mXҮܶء|h8EXEL4:d4r xGpۢr~|l4.+E\P1 /y %hZ&|>q EMr:Op3r06~nX!lD>n:Q8sq.'my_tьH;r@=y6V4qAq`a<}Fl| :+2 y8埃!cI瘁6M+;/M;z(V<,EńdaF1ʟĔ}Egs>I#X0o&AjXN9d[:т5w9a!Grl6$$5)CCأ1EdAK֬$O3tM,wM,mxh˜Id +7M+k5A匲4HV3lBhҟٖ=Ey&Q^_sn*saxx9amEZSp-f= Hi27 Oo*CA EVOcu|PX$|HX#hԟ +d=lU6+`2䣲'54z[ #p 2B_3OZX= 2oZ0I1 g3}r{/-O[-Wh66mɺ{`7 +LEd>p?uD y8S2ge<".~iH}y{%gl&C'{هA%Ϩ!W`s.zS3Mm%BƳ~# \Lt6k Sq;*s\:x"5jͣ@@Dg@[7MjǔOeG"S!|lt: e$4 "y#m=X'm:n2?ĂqX ȵ+7>Pˊ֔1h.cŸilHl$2~26M3lּ}? Bbw]5d[}(rm3y(8;$Y2At`9n5 @O{)r ArKd\ҤCnCd57 f<#p!q}P!?1Ϥ˦혣@g0>MgGSHl`8$s54g^ڒwsisHF9|DD X" :7L+v(? rH!} 2% Y*%2vfrnF< +|`?e3 fs=dImw6s65. =kB5|Ć\tZSq_{m Deb* Wƙ,6qU4 G{' #}RQ)/4Sتlx&277*>PyD :q@9{j3U_Q@֚K6YIH;/-dq=!ټI!1H'2IZZs2;7MSKf멹\&4Hǰk ?}[@aM{& e3^3GP~^C1[`1?6m.$V9 +e8;Xn%g5]:s@7aF-|1 å}ͥdqGٛltd.|*i[@.(o,U>Y!ne\K3t:6XX-Wo0.,c1  ZԖ9l|<~4PxL`hx'XK\lELցt.Ѐ(x~碫BTαL\T'v(.eԦYt|rl>v"aXKsP;i83A/e4 VmhSNE*F)ĺ?70ƃt `M)Yv(WdܢHFI-zk(ZאҋrU !4oփ}0Q N"DOGѨ_9r`mr[P6vt:\6<6piM#] +֤ :4X~ƳH>87$eM].sA_rrC1.1 `dˣ&) 6x<`!;v(Qeܱ`HBs!icđ\` E2tֱ"K&-y`CRFu3Za߰^a]2A9nDfpqU9alٰ |쎙L9llxF Gd#љP'RR+&OЙps60dN#&s)H@5t?o0:hk&uV2=;n: +ˀ/Ѡ7q0[@>2qh!} z% #"G 4ې@Ekq!R݈6L%d-S*R: z*'i'PoҞͭ@OkٜKٜK%6Z1r@j^g= @Z\xW@Wޡl]4'd/K7`D; N&d\8Ev d CkG<&h}|b cAiM cɂCd~uDl,~$gXf/f2^Er +|z6m\4$/lEe^HXJYD ]Z2ʅa]?A1tR߈RgSqSl$+$9qL:wHArr'̱tαElT͟s@x>7e86 +/Ǡu%~M{J!NAo"rK!]cYziʜAW`kKʩ +nI{jX!%a̭؞H=*.%n}äG `>ƿaR̦O,ZgPȒ TX8*p,]|IW0C8C Rxi&q2Nap~٣Y1X!e@Hv[&,g7Tm +̿]CaW^yuDީEllTOu@Fc9@ 5p"¡y`#vs Y" enva a1AV#thLs߁k +3T?M@-iꑩѷD`)>vL5lHmXg0.pO7 6)d4G$JZ9 s=X[>aؐѠOidciW9M":p O {Ly!IzDd!B_Bx6xx鈋3Y`ĦZ l37a0I;w-G rא2Gm ˭YM7AnKBhY_giǀOl5i6=ӮAn8n#iɻfՏt|豨܉猪f]Xc]”JjAח}e0hW˒Q] Kt@h6p!71* +e[LU!L1 + K| LAyF5#'6eA[fEza { =ú,dblrt6cњE[ n kF!j=%*&|;ykaHaTPhAx/qH@-:Xe,ɣillyFWM⫧!3E .2˩_'*oA 'W`ӛפg+e;^ *nyΜɸ'[K F `CK'^%n Il)QY&qU;Qb ;tLm* +4]*>m|l+b`|>lхt%Tu#-2 2@.6o):+XS Dk=y@{go!&z+ߊ}XtL8v!%B﬑OX5@ drdDCӚנ]1i#Y P/  ش8&FUNfGpޑCĚi=͈Ț/'#ǁYp% ÁO>}!힏IS02|}KAxu/ndS?g~Ezs(י}?6b<u!,ҍ|Ž#K=䆙 7A%(mW/C?ҹǗP-:LXWaNЙu/S%Li`IT ]yeFtT`h ټsu`WW}'b&2Pǖ02q Hn1>[VzPV-j=j0K:|$Mcqx:00`a'cV#\T`1£yg0G0A)w&l")EX&pet/V/-2Hޑ qxX/s U|=bk2:k#0ɀqb:h"Q|Zb{CA]GVO"s@;E$NG ;9Ħ8$\`h>++|| y/s4xUO>P} A_ | hL2wys?tM陬@'׍K, # (9pM|L쪑)~h.=lm{;$\J, x%ٔ}M Ft:W`%[xrx>` #25kT!]?Q%mX3TblVM/:`S3bњ  A?&pqu+ >kZ&.P'?Sbކcsv YץWgDN^fZ7V):hGG3)!;pdwNn2Gg2vcRv|L@s_ö>`wɩWd5L̽shW4;!zk& ya +#a6( uOBdXfŕNa1_|I9u!:a*R!wj O¥GOW9܇u!Qsk Q׽ aŠ:>[!r.bSU׌w~^Ef)G\\.!|0H =7qaC`@iGOgW0](!`C)'tшMgr-Jշ$*>}ش]s5m[ޯi,qE|0d wT*fL[FUt~OdS-fju@0uVs-O,alҋX>΅ }̡-c[uj~u`&_tHy ۅjClvDwgÑny?dsn)GxF<vI@ke6mɣ䢩TM~WdK,,8 )<Na=̫HK"~8E +w֐O3E؅)DLh *6k Y}[R6+F84yy1Qyϔ9J +*c܍:@GIh}# YП;ԱhxB.!bH.ڐ+~"W09k[;3[CSMFp3򪻦֍]Nߥ[mXKd[h{/m>ZtĮM,O3%ob W{'\~ Q\dv":KD bJ_4OnqY,_<%l/$H.y5B}4]sփp35Z!!"Dr*2|RXf==;怋)lW562g2+j(laM F8s@ѷ?/M]XG7q,,w^A0y=+ȂzGNqԄ* OGކ"Yl|s59ԳV^LhN3G^y asdmS!bKiJ] +~(>m<>j3a )J͚V= wͅS@U`40ޅ0dŝo4gg9J&pIR/V;ޘ W_5Y=lYK4t,ǜ K>Db$΋-GՁts +{"2bLҎd-)c3yT0 iŹj[c.Yjd:K9㡀;ɺˈCǁ˚@٧?9! dt O#. YG^rȶa{hX\+um_l [^.3[5om3d0=wGVM-a +Nsf'kyȅ<|mVr^Bmq/9M@Wb= [vޔ)dׁ; 9gHpɵ3Y,+?K6gvtm63%  9$C̎Jl֡R͢~`^-̉;:)- CD % "SΑ=C 0ٷϟ;eLELC.cB ہs{"_EYE] g>nب)lҾ9'WtsȜ3<zhf d@hopAX{kYR,@e&5oEA܌uG(vx/ckȖ]]2 CU21Ui`~嗥TI=.u<. 9G|Jl>RPb~QYqH I ~pmk+9;aq`}6!8thСɣ]훙smSw#7$$8j} 㡙 kY|݈k΄{D$X4SqSù=|ߐ{QӕS ܑdpX*&`<|^\BtSUzlu OeO+5w VJ=0(#lZduA[V+v|5:Tqf2 &5}xd5kȺete#6|6k8V8|tW03jLu.#qħ.>!m!<=R B%dZNF\lY\N@>^d9)l>u6`?9mz2Zjr# +Py̮.KrGZ?"aPuW;)k GHn[drw!.8GeZ@'r1tD,g0uA.@7љ25S=38.CJ0dX8km1ȖbwndVߓqր|X} 4s6ĉI#xeMs/~ +/}Beg]e:?A([!N= r:Wx ιM4|J#!XgOddWqS *9c1363f'!kz (lK +9U ؤu;pbX_){?gLa+1SZE|Tޱl|Ϡ +-7 mLM:h,]~⪦A'}Nzo: E rdYDU]O߳A8.I?f5~3td.ίAR[g#Π&FE)6 +xwxo"DWO'(0laI85n +hp 'e6MIV6r7c[tܛ;)6{xCmC8dA_)%x+RS|#B{ b8 W \1=6b[YC +Gk!?y& A^| :8e֣9 2w\Ĺ؟q$S?e'VN'WR/]蔃sєWxfcg:70`wAd O_S z\$? :"68䇑e?MOW[_(c:]#kd_~i6 _6ƹY{AX^[)m"EL^/ OqȒ+d vS?{as%kXLylDd?s4V4|Eh qo 10s>TMwOB%Qw (Gٸ)sdm >crrȥJO/ewa-mװF:p1tT$K)ǠdT̐uz Y|Ϙҭ א'jP5楀cM;bJYly\Ʊt#YN'wd!AFi /ty)_"G::c +ַd)}C>!&qG'O 3d9)[y%CC=iTy1~Y~Ř*: zDz:dZ3cZd!80eTJ  &E]"j3en!߬'j:r{| Yv͈-YF!!٤@/ />ІgDoȴ晐wm6wcV oS0!*f@k&ɻ&d65mb#1O/ߡq@%a0ޫg&}:A%8'tpQ#bGN;::_^ 5b<`Y;5]^|@zr-ֻY#;-_mK>/-_V_[s};Q'z8:Ʒ6)C/sWјLO]sbc®ܮ[q} ;VUx%Q;ϰ /}ec9[^nZn߯ꞯ |{a=ؽlY#kA^~ܓKA/րnj#^myK߷Rq'g6Ypz)YzHr%صlZ϶v3Ȇ'3]^kr!w5u[1G:KudUϾ:Ɔҏɝv<}胮d.grh-}E#o;LZZF{Egcd g++SM#U2{RV|MI^fsd/kɼlyl%pL+" ]pl(!MS!E؂m||PT9?M$c[;˓ʹ|gqw̿eą_yڑu߭zg?G0o^RODW{)݉G19>w#OCMV|Uzk5=¼yQϖs;-mw<&kK+W#s'%IhB Nœ>>e3/;3;_DǵD͓oeM{^XчSCl~$~ COYp7kw=ӏ=bwWr9*G]K1rǫL332/@6(v}-еt݈_m2Y_.7]ijr כ>n"}LlNϼCz Mߺ^mew<`=QpǻǟrWVc>f_ODҗ>;ˮV~, @7(ݛK` ]A8gki iK>_eS>@K5b6(faSp^|3dؖ7[7ftɅTXx:\=_ToJ/ƗȆ7[^!`jZjܪ]?{?P?'?ux{rLEϓ\Ww]?HBȑ?ƍ$Lq×=Wh;vsK!v'np*-?̥nԙw +{9ž܍őƇΛ+q_ď.WQw_{/nFPg_ڑOuϿ7}Y :C_pܱ.;pM>(oYŴ<3W 8}ם9"$wlf<'#v̙v_?o=G_XO&_o=~ԭ^ԃ_G:D{_'˘ yˁz4yՕlV!#GmDtH= ~|H,@64l"2ib]p)WY<\l?=<^A|գTE~['Fم(u?VY [iPP;޺`{v8w݃Ų/,1Vn49z q;*ۍe~՞|S V6v6etKGTD\g^ݍ+ 璉+%>3{ߕH[ۧLQOOoONOV?.wz^8ԍ֙].\ͳ{8q1۱%nǔlP]_#u|}rÃ\Cwë TPcj^K%CyvTVso-*j[";+x֖sũ*wmӎxՓonڲ=+_lOBv AxA kՅz8թRˣXg^RFy>mh_^}?2=:=ƿrOr/ϳ_e99^Y_lWbq_=?sG!;q~|!w+f#v?4?u?e7qyܿ߹͜zk'kJYͥܫo-$Ipyy*Eϝle{ͧ;E55IkeԵU$?nL%?p8#>IZYaG|Ys[Lqk{TE}KRef(ɺVlE۷^ُvB7awÕ>M{-ϝ֟zC_^zvQݽֳ{_0ev?^{ך7Z {Yַ7Kޜ/nF~+eAz=Ү`n1JJܞ jY\0$InQ΃{E]z3(z[XC< ɻ}AhD5߉+ɹ^Xnb=b>kE?ԁ_XDVfg 5W$uWȿa^=M_L?<'?g~zp݃bHy)g/{(nl?\+oϭzݲRt7g]^t~,iQyCm\ɿ84ң3mEGѺkxWn\iݽY/s2[]r>lv޾`q="Z*yU\k;ܑ]A6| 1]/f.=sucΟRޱLWg|@g]dz}#]x"'youT?(Pp+ys*+:IfEm9 $ w#ߌ8s3;%n/vf1/R=ۏB[!ܽ6o ,͸Qp/"-fbyֽX{:{\~ʹ^Uq=l%Hjkպg#>~|weݿ@ߞڲwe?l_ӫetǽ0]G0O hèbG])h*s~sM^W o_bl?ʍj+zV^u;zbIă2'u%Oܺ[oڿ9S̿_vf2;{9}ם߮j˷;WLE?Bwo_r{ڿ?Qlݲ3asኸ'E;m_J1ػqK˯-o mU;vK]ĻWQvVw&TT>/uz_lzmo|˘}6굷߽mIomIT5H:ڿaݞzXR_r/n|EXgEA3~"} בTVTzbBT"}B^+eNv6d>hm/xRNu +żD^ӛc[++*ʟW$?άftg z~ zkz?nʯ1wה 7{WXm7㋑+{=8NVgWSSϞ"D0GdǝΞh[|VdѫqšSFb+dc_/q?7# Zκ 4SWPgt]rٿ>lxke[o};:˯w/>^ە\v7ACOW?#p["sGs\m5'1Yi&1J +F%Fe~k"NZ>]K"&NA {L,)QZq)Jbq嬲:[*wom^/ty~ᢪ; ג+ߊ/݅pCٽ +y֝q|` H )8,$Biw}\,#5^2]2^2E2F Jْ+Y.Bc"^HɜQS$%U$4KFj|%#2pDg)Iޒiǭ?^Fk̵m{n^K,r-ͨw N߈*_Vv'"AVMkWH)/Zbywq]yO5T%x^~_>jhЦߘ}ClϺGjvs[Jf,̜Dg,$$C$C%$gX8ɬ1:Ɩl 4Ե],~f{o͇syיLM2E})mٕUגK/'レPbIғ7Yf| gx%ʭ†%+{_{<~Y=[jtUcB}J2wdy5v>v7Kh5LstHp@D KOjz0?&n6lDW|Kdj>лy=|Vq̒eKnT\I-~%dĒCK]->v9Ÿhm[|zLɵ;i_zҙb7ς˺bֿ򽍛dޤyHGgJ''QmJaF%5LHD Y6#zrwg?]z)k %7K)<= ~NSIws+A6O\.:x#fRY?;3;s+^vsuS $:@;E7~w??`8!Ylܚ |u{&+^<ȱzG/",djj)ыy]zrlI貞E盙?M=^zC7gXTٶ=JT bE13TQU+V HF%fj6ݶݦ;ts1ާϽ=w7OI֚c02#sT_3qЌh{:ZWxwk'vl9tSN]8z-/XؼZESh]۶[ZvvnOne"6.ZMV@lPls;9Y&82 +7^UMF3+YV?RS?|ͧ5W kW< pˠĹWs~sk&8gt?~,ͨzPX/dNu,&^{u=8_6vޚh+M ẉ U?KѼUaA J[7ʌ%hmavܸ\ᣫ;~QFr[_)hrraˎe->%h[_u9i>xr? 941 -uݭA3-ϖP~R[zGw~˥MQ4Zی{S⦰{(}Y?>1oF޳ڟTi*$5K4AI8OCFH_h-@M<Ѽa KEܛKy8oibBsVw#Ձ<ل}Li+{q_9.[/_iz4q?935 wjjo9JxT{%8'deh23ZL'#Xo12,Dd \+mQOUّ3;p{EK;VZɮoo|w`gwrvuA|[b<T +&Qȏ㧪9%$ud4n2ҲEƺKd W4~h)ףS]]ߏP y*?[ oQͼkۿȵK؟oQR4o\#gxM5f)x̍쐅2Xg!Kk!2#Bdj&MBsXdSV>s\$L^Ùf|&]/iyf+.b7n6?"y|Vަj։yO<:|AmL@T'#3mdfO^fќqh]~D#yRd>FgSh4dꆦL$?[$jEk} }r2kzʵ{ms\?gfP WHx^9g6 oc8?YI -E&f+}:aGS! hs._rh.ݍV]֏(0o]^ECC57puۉy-'qr$9oMvEl”yo!R"S`{4[gTC9o0;Fsa-R`m_7?1gsT'4 #2}zd2gy皅d>e4uD3rf,B6nh-p\uiѭKi;TN]ʥϲ_(+аlm틥W/緞P"%D;(/.}(2r㖫Fz3mZ$;/M,S' 9dzDyh}(5WfL[,47yːŔ8 4}vJB kBmLmi+ݕ*8SwJA!x}[@}ְ6>w~K{qOv{Ac߭[ͬ^VI/MoM):$!!ias <M<-28ںUN['s̡ V]~rNǕs](W& W?^- ~鶤'MPAMI]/|~-qfv9G~||6~`3G ь>#ЙhND=Zs\ݶZJ_~J}QYeW=]^Hwy+2.s(s>u~\~ڱ˰r#RTɋ?(5Bwy9#Ӑ{~JNYϧXYإ*3Lq><LsC6B49--֡e{kRZ?r*T[$BvfU{5诫xnIRxE$C*bogMK6Wm# $K?y}7?%;C0\q^$U(V3VL3?KT+>?YǠVTxk|;Yllт9n622񗼈/KV. f߈R(dD`ܓ9W +|\/3D7rɝ_7r_()ktdVgXR6{yHg&27_f- @K=b=UV9huLkPsU)*?l~hVI{ߞf]'e ϚK>Z[0V +NP0DP{/u ֟Y"~DȄ/wOҙ9w5CTS{4V->/zVz} URTtKߕ246 ol-j*W(pPS{PyR *Ee~WJGhUe+>JH?qd/fǭ=᏿`Lg DԌ[TfkAaj894s9UԾ4/!_¿(W<ƾ򿥤|o(ʬ1[JSVXrRxo )3D/ѾÿVx'n;:9r?@zL~jvKlè=["S6j7j#Jvj怺ۺkT;x> <)z1-8j{^>վNŇKO%ol*MR4-ǭ}*OJ's凧z?$C]먽zIj%!YlÕOc/Cbd7F_'5ʅ!>gL> qXHVq*Ng'Q:|TL} Z&q"ž7xm2XVZ5>|/i{O؛-w J{w }*.X}tWZ*l8=[鯞g_'o$E|$RĨ$/d:f쯸$Mq~jICߤf5~Ihjd=]w@p\ ͱjǖo8Q.py\WBWo/= ~q0ަW~M^'{X>,;^Fm6qA^+fu O"Qz>AK..sgK-uLJ{*gs#k2/nf\-UyRQ_R7InօmzdĹh<'I80|o /7{%Z +7֗쉎bB34AKyvg.e^?ػSW&QJ՟ɛ!y&U2}T~MUj+7Q_aS8 +Oyɖ߫A)rb+GnC H0X-# +KԎ؜;),| +э2J6:#/"xMR}t$ʐ=>D@h64ons%T IT{ZtvbŇiԙbQY+..8n,W]@ql2=BU7u?\q?blFLM6)`'A\{v.7Nm32'3{-}L\r[q L*Q2EK헖w\>]&qa9 {%G%OUnXC=m - }:|{)ܠn4n.ٺ2)4I +Cm SnO*Yw]PN¼ ZIOϣKz-PgJuAS /GF^!W:(a2/#O7N }d9U{܆<Nxhhݼe BR #B'*j'_}GA/E=I-ak+쫕]r;{z߿ZGЛMl-&qjf{_j{t\A7+Ǖ#JW_W{vQ<>()}})})}+9YV~ j!j^hռiy &낆&pD/" +IVS;=*S6Hh$}y)ew1-f goDŽrY9Z$ YZޗc!=Q-+h)s+pu- ΧaQ{g[mLy"{[OcC9Ηk%_a?Oɢst'itϾKe+e07?e~ -X^cd`C??s٫JA?WjA.3A~pϫ˄mF;&I |U~ Zxl'O0-v"zR;<3{zQ 'lNs.akdwbiFmP uUԉD?[/љ9-]}_|#$RI)է +vZ3gUȟ-뇅³JgJ7 :G!o&Q?{b1lY(4KC.7:98Z9Q2.P43@ IPWVj?[z}#؝=ABq\< ]NJk̖ L^/}/=L|;"l gR;1'_k$GCSE9ݓ d6RSq*>,5+ S6;G3InZd8vE.k $A* ==_P١ +BIV teh#]zpU +۪rznp~K:sex&hR'-OnG~q q Q~Kqv$I|DŽRM㳩*}{ +oج0oIijLAȁ|٠gD?%޹Co9ĉ|4)LA݈N577KqQ}oew +rܛ ◑wb_濫}ubKu`aPo{~~1Bō\ؿ?U jG3|ire(jxf̀Du*<]SHQwtvC\ب*}&!_G +OӖfTTǦiV?X(;X:*밠3j ]=@אI6s2]䧮E^=]u3#̮wЃ4ݷgjesCsq0W4fCQ)v7\/حFkV 'O' +S>KQLl[dmf-Z@~X3]"ɓo=a˵YX6<WIx*Չ!0K'J̹˘+$q.m /c'>w[ZZ(0I@ן^Hx~ƓC6̖ө֑'/$0W TKqLVpg @>`<}"30t舼q& +8UzSL1~^Z}+{*&OJ*e +psfa%|Fg>F }ާk$glEjY|N!a񊭨 -{'jgͤͦ*>%iXp/ihٜx^"/_cΏ8 Ow"ah$@6h-KR"{pUk{J?sn*@3_~`T +V ZsS@@"=P{.c|+s=atǽUp :3jx5;0yjHjFu& ޒ0aH:]_1[s{hlz3X#e[ȻKnЁ^H@f~ _s680m2e,%OW?P߹uٲ;Lx6ڐO!MK`ձTtLtLW3R;t "IMlPeS:mN(M=qP#pLr7\w_*Nk0 w$o$Gfy]f3$mFNN~r_닀 /ıGW%F'64S]b6eGi%,͒n<~j!݄wn_ +͙u\ڠ٬Sl~ٌt浙-It|_Cv*?!SP@k}Q%ސ }ҠUWN( TŁ왊+asxAƙ|&}rp6hN34@{nӰ^yp/%rx;'fۧAw↤eԡ~ԁ$חR}f&h1{r*=Ў\ U6o7I˵teTdxoAׇG\rDn Цki¥75BԀAw:4Cϖ}i=Jqw\^&GJkd5|聘֓>?w@,UWJ> c)\&e2v̾7ЋKG;dAu$Jڙ Ũ)c3%;5 э,3s as hW xxǯEA /޷o@یj{h Zt,`bp]X3E8žn223&TR0 :>HN,գq ..pCTfC+5Ήx:\QT*uN5{f!6dh0O<ɎnW 'Z)PgW}O.EE8|F87؋Q>ed%_bʁV= il 7߮T>Gty4HL,<^U#~3=~;+N.(>QgLoLq[mE\ŠKJTe"ȏb֠aT㜲ljQ,\r=l5Y!qOmڢTJDq\E:l,ui$_`xn]ܑdB]IP3me+%;FWiij}#Fd涛ѩ!-%gAUFQ%Q XρJfk:V9$,KI1`"ƉhSāV~n)Wk&׃n"'{ۑk8hm/ BJ2*6de0G% ? >>=AǕ +ƾlրcT3֪6|%*k|Ѫ9+z?$ +KԼp)Ĺ4!Q-&7O~)hӡb:R٤g3U&r|3d.,F}ß|H pHNo9:eO6$k +EW 8Qd_$2u8iQ]L«P1hu> XjD6 ϥsvta[ˌsh6$AU[$9h \b5Am? y- | r3 %Vsz,UQz!Kw\[ sMT&-ӑh+Km M1B.DژIXB%V̦2}QO_z$ֻhȚf-Dpnt`uqi&0 +-els6_vJ{M]!3mW=7r:uj0*j9!~244RjcV4NФbZix 8\ * t9CT1jtZ!uL&tAKp* e9u3_@@ +W؏1޻.L|SR9&9|1&J U\{lx"i<yz +wpɬVJ|*hyl].!] +N rȻ;?]vD$k>zu}}=~q&$j8 zsYItȫ/C*ٞ{"zkfS$$Fpv̐nAv73ƇNDlL6LӦ]i-x _?bZqQ14&bwA߰9]Sؼ^s~ܑ}!}+}^,DiF1W7 AG31S0`Ir+\{;"λ>BiQTy~ilugkۦ=pnÔ횎c\WLLZv7-`i$'a?e,XaJЩ TB!SS8uEkVGpOȟT;h1=OAǗ\#\ +E,c5Q!?kOh)ՆM9\ /re%2t}Y]LmTw譀9n F8LJDIg؉KEi6[(-P!U|| R=FZܠ7L'j-CVs4G _q>UZrJ6x_ȃ"Z0m dw_u`rmөz&>y:W +4!S2['*lCVPYDnࡋԼ̂u1W:8l^ؾglu>7df[%ւN( ׹|5l+~ >(6טr4`Úl%Lߨl0p#FwXV-hq% ҁ}ݨ븲Cq5ѷ~!P.I Br#n"Ej\w]mPD.ɈǯOt$NFz1U@P^}ltl.@P9Qnv_/_em7%Z_AzS>0θYT+N< #j= e?U@SW=U^o +VKЃXK8ނ.>ae We;v8wb"yB`|&c#]pgiqۇrGgǃ7ǴGoHw&ZPS>]k襠9lS>s+"3ho@^^?b=2[̦c+ušiPDZ4<]Zw:a\hsp-춄u=#;=rFnد8'3 7+X)NQZ0dAct ; ҡ"c<Yšp1j6Z%`Mِ4MhM孃3yDZDpgF+mPOŻgVO +tk?gSC/<'E]?}x +m2pw9 ~`3~0p#1c4agM8CS%vO,w.P-_JcR + l<=`S6<ѥ +`{d\gĎl[ȀհvҢi<-.<{]=#1b6L[^g6X3}J!2c?0Ot^5.w_p ,;O]c{&,-g3޺ +@Gر#DZ[w'+( pU? a=_,C`..\/ #?_TgU(JvL:m +q lYa{ +f}5[y`g^I.PYC ",/*#Yj b=`4a lX4O`waW "09p:GqUhF{ |9hs>֮LH(yG .#p9o|kYd! h4 u}堍|DT;E{gS;m@YR(WwYV7aSoCYr';h%3;+vV8&0Jbqm)y;a ߀X`r??hE +rWOyɘ2|-:O2632vjRAjH2U"kq;B +!cXG.aw +ONWuw=%,H;;+EKAYJNɒ'%*ށ JY e{ L."|kRg5O&zW!-{6yd~v{ τ8v\[1]WRXyq --y(8]ϖ1ꊍYڸ^ڮõ_rvuW>ҡgH(Х#rlj"5`} w怭p9V} +/v4!WuyA|bs;)봂߅!Wͱ򶛁/Cԁ{==w` a4Y\gL1u(+G\Sϊ᪒0U$McwBT͚r}oY'|2|Y? *6%C,jBq1ynT#q\#]XuO1~ɠ5$hC4\ yfd밄XA")UcL1֟ K\  z, uM͗WAU\'L6E[`\kO_'Ø09p_i| v}Ïb =\\^hY3d\VgUa,Yc,l#z+vKkbȇv|>|itš/%kOl3mG#ƩKDa4i,N\yqucS D(v0q=|,%>|ςn\dxiف٤fn? l0+628& +n~%lDsC11rX81%W!,O[oBr`S9Z֢ `m~d>Cfr(y:pG!zI9 8k d|Y;gE vQ~bd,P z` tn,$hp[{2ְ>G/ϗlPgȹx|ACn50KwZ99r"xVv 90 wWϓV\Jk8'Wj!{kb WZwwJRrO'<> Gfc*#܉/IfhHԠnc8dV{f +ɽK븦p pU 8촢:59aqV6T5 +1Zdc3[v"|8CRgBYF) +(W&qͥ oJn*חUEGuYu>\3z?>" P@ $a2mc_3iQTek 7\ +=[kػ +/@ HMO4${1c} +hLg-8Fˆt š CasO#`bG8Wuv<Ǥia; E`Z4~rB|-~ |'P:{8'>tC?cq {iu:<XtW*Nvmr?l;:77_%JRa[mAb5|\69rn'؊LNhuO熾е0iYq`./'㋔x|<>x|<>x|<>x|<>x|<>?fŅ'뱞zEÓf.rJJv +M Nʰro~opFxR@Vl,O?kKƒcl^ +J) G[X o9)eap2~J7sӷm0+]+ms[9Kl+jb+?+|UHv%VXb+V}>ǟ.{TLاl~6sa=Fq>Vʖ\??+.[loo%Z^nÿ J+;$WΊެY=m8X-Y^bc8LEDÏQP**~O$Ty7)єDdkR5DU7'ZysȟVW$KUݽY<݅4Մ M jTldc b"D_~J!h0 9:Dk!A?X&CkmM7W_DjSQڒt  I@K_Tk#g~ M>f̀-ѕ|P$yr >GTuFDk6ct)esIL`/~Ʋ^+FU#ʨ0bҴ4M)KA"Btn< ~öťkA:)"}c3ztyz1h MAo=CЕԘ8 3&B""}iDo6.Yz1lؤ :_>Ά'j4Fj+ϗY(Ok6csums }#-!}&o"XlS;h5_ZɷH.wL{I,X`{ ؞h3>\\6],1tMR'rƓF"b4s.HGȇ;zcD oTu&X&S!7߇c(ԈMx*BJ@迲a㠟-M?x!D]f|ͥ6qZby йfitLcڠ_ $6:ctcD&a?.X#K>ITe(֑EghAo"Ƅ މLM岷3{<>ڄǁW˒+ h6N"49z'z["/k#vb|޹2 s<zusd3b3C;،<zaI?3B5̀*#Yr4)_ق1Ϫ!o|YY0d;gfX57+&Enk@'!1Oﰀ5?]?C +=ghoDA<&Wphvq%9uҔ 0A'*h{x, Oл`#c5wt&W@Jb[Ix|$ )/¶}Чђ#m=d6F%sVY@zx-.G)gNKxm#V6z uy lqΙ,/3Km o\)>TI=hn*'1= +}fm#>ZЁm :ρs.f*l`p\ؘ zL`: :MGcHɢT!^H]'а=x\G7L +4Mf* ¹ĕ낖i#a_JzM 4~SZM^jl**~ JԠc:\ .C_8I'y,6On0!9 tsqNfAfaMk2\4Jl5#=8~CncH4YrpQgB4RJ&R+ Q$&a>C0rHO7YeʋzˊE +t+ H>DTxDw~,h#}`y8h:̠iVmF>hBocA%~LlkEZ2}9ؾ,TGeC֠[ +_@jCK.ң6gB \/s cһdzGcDoK55PxtkoWնOs 4fDTTCcэv"HH;}}X-s}wzLg5 g A³Ѥ%X"lPjx9h8?Ɂg]FًX ߉SAW~m" yq[9W+V镾Ȉ1C@"x C>"XcZV/~^rA9lEӄ/a l!f& c>qJ 4 @' +h3'OzF0)>(ɤ(ێ =!pZQΗ xi6h:ֆHjQ\ 5;A +yt!>qHQ[!N T&A|Nfz0b4I,/BT_ ćb{8)gnuayc1A:i%4!&!g?0_`NA~z,W=|n^ tҩ[ˠ~w;0w@twk΁!0ϰ6/88Iy w8.K[biG{*=@5=8I 4[P=.O\d  +WLA/ p!m =xq9 '|rdLj|ﮄ4eٳ~)iIsCq=8;ٍs:tҴkgc!q#>tğeAp+  Aw%r.C +O٠1 +}nB +z)o FX +V6sHW'1>~i4#ݯ,zgX(u!?;h"3!Yk_.L*ss2c+'Я~<) xA`VU[/Pv񳘈ɔec0RQͳB83M (RNM%a# aDN!3ׂa=6Ђ]~pOJ7 RwacgF_gCD zc,e646 ,XM q\M-|{t7wL14 +>ܤCވ/D+6 xޜ!!ʷ# Etv IuqЯBXEG(Bd=}CWtQJe} ݿ<&XsѴ) f +uKb :7amJkbN3O銵=W5u(AȷXkO5!] fG4~CVp8+ rWCNb1!1!'S?0GmFaHO#F%-O {wm8jEvY tQ:$頋it0╨f@l)SK%'JWGFu G+V&*kb|kc"m)q/c_|0Sثlb]No֋ܓĮ^ZAAk(&&jYhWC"=< Egِ{k3 oa0_Ɓ=^_Cqb쒾P=uSg-;{e-|^;0Qwu9K>^"LTe +o5Lf 1q C##g凴TG9 &x_Lj\+g@? Ń0bW\A,#C><r(H^n?4Cs5K1W>5eC B*b'xQ- yL LlO:#DŽ_<&cuIЦ?=&&P Q 8;ؿ9Ĕ ! Q|0Y 4ǡ2[O3Ԃ +~%T؁qk,%wY}|ŀy\_*uKTXOl5eo1IL]Xt1#nbdM/j0{C^m{cѰ>akXl%x#X%A~)8BM}~4hԒ6#`ma#Tw>܀ GKr;E{(BPL/hb $zLD?/v(`s#})@Pg`>Bm`U5'/Nt{αsYY+ endstream endobj 101 0 obj <>stream +.P`shčX*8Br)6X>^Kluqiy`=YźG`ކ=&"1 ~\ ah(&pLz 8~zL 6_t2mx\_&B؅)DtZ]rVP [(𻠧=XITo!yЯk ^53QO4Q΄,ֶ_eSk"ŒF-**-֣Ext@!앀>p~4€o>L[xlSFࣹK9^O= A>5_"LU?^ =Kw-d|~Ziл4Dx[_S {LWSPkWHWܛsM̫A_QG(<l%>@uI.g,חBf _c9O(.%g&֠{[`!O? +w>,Aq?<&RDi5Z]_yy3Ї <&` 1>1j@q#Fhّ<#1@zXD#Jt)tث o5ҵ)k2֟`q +W~72'.=< @oJQꠑ +\:*g`h@Q!/MؿSطkoakE5==|@LP7%Ѫ&٧ -7f tcB&tu(=j?Z +^(_KaW/qԑ 8alh(nsB<Ÿldd/ES !x=^ Qcx6At!orŢFJѩAWmhחqc-݁=&:Ƅ, ϶gnCcj$mrLxքQcv;X;qr#sF)=o-cR:WzUKܮ-:$̡:5 s^Ё7zL"lf/pu +zhbK%g'}^-n xe.ykSC&C|4 U5MBKӈ0`Ptr2ׂ:Y|"F1J". .N)d Qmýwxr8l\M!!fzLX8?Z=&n~y)[D5%1s$ +pK#%spŐX\xd,\F! &uIQ;xQ@N{%-dAf_¹6LY]&Wge/Bn`Azx?`D^aF(̀$4uqH<&b OI"Z[\\Q-X- {YwkP{{Pw +ؔ25:\ztxFX_ͥdB.*p=s9w)t5QV%wm)`:a>/g.fcv U*yh[Xރ`yطbB({]\{nבܭ1hҁOV6 UTDXY 7bL8 BkB4E}Z._+s~S`RՄ!~Xҟk 0>dL&D`ϑ#frI@:1i;.xO=vl㸇='5kފ$Z]Sgm ;nx/=SlP +Zy! K0˖Z_Q/RM&oǞYAG_@6TEM_o+1GyԹ>[=&laz^bcccB${|$?+\SX&Wꘟ4š OO^Z:CZxA|kZ*&M:p&^= +ziPGݬL:#yX}Ab-cZ5/usq.vNtjĻ6ƒu_)O;PG(x_=|.W#[{~P]6_*KX}`WX^19Ol> :YE }m(&ػ< ׀\ :M ^08 `EKIb;Ɩj/}PzؤȆ*u*=m 5'dཕsKo'ܨFlY!Z=za6\zt x _<&(_G|C>!+>u)PendhזaOH N9π^ 셡mf[53!倣DM:BD +~X}9Gdg'~<Ĥ^5/kp X: G2?`N{6= +ث vOV{KASG=2C37W+q'2 b5ZTxic|N虀=a~] |60+1s\м,rK&LݵdZ^2tsc m5D Ӌ؋!T <П񻳂y؀&Iug"o/.}w%Tz~af2yg/Aa`}W  +x]"xO7uS)a{šs}cxoc\XC/emyyxOR8.YJ̀;isqm>6KNcvnC/K~/;[}s+G{P~<(>AyDk`la1a q_LQk )85CBiBkAb )Oɔ*ekrF~(~ŸoƾAWVgawCg'Zՠx\Ϻ+>+ ;/74_6ƹ7Z1{Oxr6<EпZ}X煞ǡ +7=ZS(cx$ar}b1zEh,@a)l:FM{upޣ~e,E>Оz3á7>#=cXH%%e.s bO;X/V(ؗ†0tfAM {#+-(B\>QcEĉE>y`Mqpe1xlְ[1ffO*/% .I@/6_Gu9Oxgx#^CaMg2'TϨt-xDNu~QuOc^lVq[F䮇LšYf__1-Vgvd4)33BPԲ֤ _V}:ظ}J%VB5k+aXGEx3EWC# {@Z!P\#Wu\&kڣ„n2ao6ї3v3Yk}f=[Fx 8y~%XdϪ\_(vJ{Ȱx~dAG<]1u%B& w)C0Mi6rHI'#6>o}UЧ^}3?Y'2~*s@?i>"yUo)~ty)f2z4٘/'-} w3Dt0z6IMz2ͮL MSxbewl<]ꘀ1J*f7gD7 *f7x aΉ=^ä3`?y.EdLKA2;!0I-* ;gbߛ+q/|e/ÞeﶒQifaf.F {N&T8R;T`}6s$?w m']yc,*~-<%~roN1{Y ݌6Rdb TdLv^ge:<=!ɫ1,#ɩ%Z6UJ{ YqB~6!{GV-Z$DYOYLM'(߫:d|0U)Z"gk[B2^y1w | + +5Yv5EVo(JтsRğf.YhIϼq qꂧ?owS+83틽7ɑ`{'(sW: +ӏD~yI铺Swk̤3<"( PXf%.7yɓ%w=&j+Q/>J=6_E6]w𔼑p𴄵P"k + canT|C$n$WhaZ(Gf,2:d+% EyhQz(ڣ*KCٰ#y ?/]>d3Tk;U2X|ý7bAΆ`ȣ/$U>_ +{Kl/ϊJkMLO|omR|FJf}Q$^Kj7{I*fg,jGyPzF`z)M:CXԤoĹ&u%/O K>"KE^)>0c ڏ3EGK]1oƂ_T'SB^#x+*g7|كZdr2~̽N}!5Y&MTfHV>)?!зkz~i)u6y{r;nz'fXwg癪γ1@m{>^.h>4Z ߅-3?_`:m׽OZtv3&B}~/f ՄIQEG/.J47k^~f4?7UALV~ⷝA-iV+izƸ"wR;ړ["Qv*Wz5ѨαZn_'&Ր,fF~vz(, ~z+~f<e۲#ϴɼ*/)~w5y?֤]Ckٟ뼈zМ}9xX}6"ydaRX$}z\ <5YZ셯[NJIl$Վ&EZ$/,Do,Mgٗ뮃 (+OI +J-ŅU(et_‹ȻuΈ*;"jovHCDM>¾qOSގ_7S~&d/텃Oաbğg=Rzf=jUQ^=k47~YqAB[yXrXzN)]>~/%vVsQAmD:;<_e^TW"m1.8N⩶kG{#VzjW}&6KŤMġ'o&XY5$]mJ=і-3a?xj={B3S)~mmP.|5xb֞iZWiWf;AwS*B!zMˉn,֛ujdՔ~AqC/5V %d$E &~Wk͆["3lGs1 }xi_c2%nsT;wEKJܨc7c$UC]/eL /ӥk +w1W0yR{^~2Z^DZoϼYюƽF7qWQ1=$Sf%vw19X&)7M fa{?9^OfƦV$T$'oII4#R&$ pAԹm92ӾGG o\b mCu~@S`R +ݣkV:ZIz$]MKEJ])~vʸMRV$|T>AD:2h /: )+s?i‘gβ@Z/ MuIuծ^uoiHFjZNz+d*}db~x~Aa J6l\?msy+=<(ѐI.E3² aWC_*TJ|p~VE2]gɧIQAIi;oIuIH-YWu=Iz}<9}'Hhֈj:FWM֡Ek~Mh~Mj\4R\e宲 +7WU@SAA'4 +]ʩ + y%E-gMJKMM;J"Do,jdF8Y ~~XRtA\j/f:πJTTӶHa~ Ćm_4ǽ"asUSrɶI&(GD6ɕ6\bc-Z%Bzcwݛ<c\"oT;q!/Jc8:EƖyDȉ}l v4{Ik/ OKE507"K.UEWƺT&xT']\^s|^w(OA^2(_II>IѹQzo8=ל%ۧnTX0ʍf+lB3axYeq1"%n}DquXjc;1ԯ=cF}8]$r6XP_Ye_mِu!%xKvCQYHɇ@IKᯇ>YsY3- G߉9<Ї>l7ѷ#df}#:F-G5vG:ź6D\5ϿlE|}I7U!zOt] mrqwߌ4;~:Djs gf;kbU{߫=/_Z9nT2&!qIIMֻ5Q)QމnMaC [a'r6mHrHMQ.{9º!gphܘ -I~.'۳b߻/ӝž&;+{bNg]hipO~j?Sxu~1sopnhLZ%*iѯUAޕ1i%nE(v* 8՜ay=`>2>FutNGMP"ȗ"r\e߸5чP+WSdACX6YU6!>:zZ9wHMٕFK"sEE߫ESwyB~y=|1}6y^b}ƭ{5[U[ eq)Y[QiP_:"_zn +/ +="C /#p)+V׸2hXC|RxŦs ] 8+]d/Q~{dv:vu8G/j:"b\%bpb>@%ѡ_9z6nb>%ӔMK%o"&+f3+sG/%%LXLl1 T8ۥW ]ZQoC7-L:Ff)|1.[Lj +2X婢D7^1Eƽ;`HKt_}SXLm󥐆֋hœ?ܴ99=x}Md= +:osN*cbu™%fqxb 1OtBI~xn$L^ҳ49M/iޯqQoi]%8f7^Qi׊#Q^,=*q|!J[Ǒϊ#_:s O-wEUzŵ\-B$w.dgJ܉E5mmةF,[D^P7򼪠9]Jdb"1E 0B+UE5$_>XQDV #_D>,.~{9*[^u#n[ȼG\#y%~sԛ2pxks/'׋1ZP n}c|X>k9éFWc3pÈMQærO3SVk"{U+PP:,k 8z-6;#9<{T[(c_;yTŚ~xY)[ϨYQ_[ߛ[8GΝ/{=w]Bi t DgO@4ET|?\_{h.{Pk~[?e;?xI;ZEk͑]żz,I"oc+Bg֞ s@:lZ&ֹƚF"|!V:jެ~8:Zz W{C=ߙEʨC9H絎OaFbFhz8íBVGGqx156-]Kt=Æb"w ѯ޸D=.t%{t9e 1c4<:1?t$D5qfb2B"I8lO&7O3g~ws_٭/^ž)pM(/pK)+qNzVWRX[ePUohq:m__P6,/c:{cѻa3I8MC9ii#/&&/"YMT8@Tv!v}=B[8!Ԅ(hDzA'3"Qzre +*#k_A!R 9["dz߹iҖ3'_Ɔ/~^<\%̉wm'gl#n!OXOL:n-1P~OAX8[~ܠ;ft+TPfw{F%VR5ǕU.齵N)-U eeNUp['ɏA>)0^#)O(BGSn%×F&YCL9w?`9~F6yaܮ)z_83akؗ~Q^{[^[QPQ9%[O_uwjuk+oB3ߏyd'qTiδ\Ĭ{9Kԉy YĬņub-b2XJrl['~)yP-E>Q +]"6ŔxD" v/{UWUT1Rwplj`Ev:߾.ȓqfʁCsp,F#r3Yc#K,Y#!m?M,lĜ"bB$f7 f(gE&4fMw/[T&<*}=-ŎKb*bkbkKj$ h~ǡso )YĜqKYWSעܼPͿĬ ik܄HL,\wXKl>tW~Gp\nnGȑA)pi@TS^s1)>Majuܞ%ױ9t?gSfSCBjsNBǴQWkH(ڊSŤ>1{ 1o`#DߟX+$b!P.6н%.&xFCث]ۃwNGƕ8c+c+b󋜣Gv͚4{T ő 5F8>UC%,Gݸu(on&(%/$ENKZ5\%j.|eb-A7ΐ6I1 ;*.r:WOb3מ.2 徱VM񱅈'4>*%fkp#5ղqJ(/"/Dy~>86r +3-"[r#:&$HPZcJ(5'l8I,L,֏ hkomPSA8癚WQ{DVr5k+wR&S]|]ryCbR{я kD1_d A5͵h gc/ux穡!f8ee=r>1g68[P\A(7!Ds(x ;r+6ï4o[_pYrg+QFT;&t:$;$OrNt^RV+gHi5nDt-}_A(J,PBסB̚r20叙PD ͵vsf%)sLjZA +hFB[|;}Fn@θAŅя_e<㴍#~Q fɝ(xOS6CȒc1ʂ +=IajbK6+5%̈%+x{y(_ΙP6sgoGҀX&KUkt,S?fsj}A/wyfةC]#N5eǦMz{j釒(rېJ}Az& |89`G] ]d:Fڇ7stN}G~ivPs~7 r'6G!NYK,\CѴ$S620bC5oFn{7fǛ.=ň-^c0~[Gf_[H%EA-[Yi4pvN ܥ51Yາvv +1 -}iH7 /[-ZK9l*HNŜ8@~\3mo$~Q V$jkxV=LjU)bjubr bV! Q;lKBjNM3L/ߝ;n>ZN+mvrjf2Рyq Tq=4ڬL#$ٮ62ʠh q) a4uN3g+dQ vPĮw\ĭ sOO\*ޟp5s9wN;|L91F¹ĶSFl똸3SDg;;kvs{8u?6u9n.5AnCFۦ|0hLyݜ`O{ {o 9M m u}dZ +j.cts":aހ1Yvoc8jFCb΄)pXIrڧAϗ߹Sr:(q~9G 83ggŝ4(X5wlWqYڹ9n5U%m~>@?d1[黵FbIyiCAq)4 c@2ٰok,ʋG#N\xbJb ۼ+_Ԫ]h>x9\Ա.u_qLs݉㥃@V30R48st9Ξueyt9maw'`x/Z<zᵿ%XMo_5b_-'.e\NfuQW> ?H9S.{܂e{1׏f^' v~T_L_ũ|F1bCTw/ܨo(7h^]Eغcoq~ΖYͱɇzdWJNqyz9W~jF'K 8@=`{}Fۿkc RzR$K<:qs훾uEiaE~.qFqSuF߭wX0k3>g\ &ˣ6sl. "뙭[ +~lwgo3xkl]wz0w1SauK~9hALF2_l8d=-ecvgҢRbO0Gfu'cKo,95ۦ{c0yJ5bUZ8ˣУXnNhX˙NÎ#tMj|ˆgBv\S +Km f;!vñb6oAo?N?d>]'z$h +;Յ)L؋tjF3Tw[ϒ'^Mz/tq4*9Ueҩ;o?=|'rFi\z0I_Ѓnǹ&,jwS6^oe}NꏽFޭBSMl3$kn8/cJ_yjo.T? \Jn2{403:R6}q$#s/&+,/z^%i[k);˭WKQmJXjJl>6L5VQF5W3QOT4Qc](\]`:0bW?XAڥΤ.LcmfҎvҧ'P"w%xڨ^ TN 5c +7c 6 +6S17 ^o!3{՘,CU/`\QW4%OjUU0.-qX s}t ݳfhK~.1A6C7 T '7s?p 35]T EAؓG<ӧ=ǃ:eNY!疽:|ЀO@A%c˶Ayi;D-fY6l'k<n.:񵻩'k$9CMUn)se'qsH{giNk]ʙbp߸iw^c磧W" y~Frrmؾdw&B*a"6?tiyi-'KfRIE`Q #s>k +.#s7; `_7 ^L&Am+7PIi1] ~j..3K { gaaxۯcoսm(vjsڿrbANO}tJ8DIH}3 yg䵵4+m# őY >"/;x~8 !u-囱-8+2g33)u=%9n"%@P^.|ǭ$UnR}OiA{]_H[O<[nX/p5OQy1wZ-%ǫ]*z ľZ0ѐJoVX:5K x&G  ,s^F?랪fesd%yMT:(w%<"Imԇg؜&#&$ ٯMǷ$ufaϧmyޭ5xi;ɐ+WsIU!LLѸi67,5sl@hJ}%yޅ:"b65B瀄T"TVo&4'Tw# Efg&.6 ͅg٫w~V8F+PW~TDl /FO /$Y/ٍ\nHSݩ:BdAV*}xhfn1sbBtqM´Tj z/z4 %5r=HzO"1+zpjeSf|7Qf>l5|ye@~)䧶Iѣ,B{oUV=;HZ#.ݍq7ܡFFս9c;T3FQ RIZ|lk]vaW Rǹ](35‹O4?hO<=RS3g8V7tٳEg6A/!qp ĖQ"xY1F;@w f̰4K#W +}zDڡvEFsVkR/4݋5|R֎KO̓v w7k?\wSߡ8?G[xv.m>1oE|fk +=W|aJuӬ=Xe$ !w:.fCψ.>g~slv+7̙z<)Bnt1v\=Ok?t6mo{?w4w~>6N{?])3c7YdwP7?77'a>3~~7K{<>OY6if,tQ MօYZrA:c{5;ܱa ظ +!&NlX!G'٪%Č +M-$h%'z||Ja}5+ʙ'{ 7> f^ ~  ~xPueXY%T_Xړߥ=Jcڼޕ[u[568oٯ9 4Ü6f݂嚹5iW]K+1g8z}`oŲ_V/kDc%i_4Fo&VxVK/׵>X77ϼnvp.7WpOrO짵^}aP?;qwxpVx{WA? +,&n +g" +lp}u :#1|fTF#P;# c- +س[N!]\Edpq/|D!#.:*t-C<?^>p'4Ϸo-מmP̷oF]k?^V>h>:FP?37*/,.7}J3S_v*s4l]Fq;qbˏ}$Ч48B{3Z֟sZ{ sǝx܅} n.&N'~i8w_eCsĒ|W=1W_¹3a|͸r^b`u_|}ڪ;Uwyѧ-33Xsw}dK.AayFʙ 4[yMHhë:?uUtW5>^x9 S0HY)d5M +:f;oك;WbZ$=/&U:L^VTot+.Z7\!͗~wgOO\pB/CkkR-2;pdc +젩Ky#ŬibE܉6B\h>̱́"2FB;R,<7Wt3 ׽\fVk P`}?Z~a>׊,kZD̯ =g]V$]|}~tпҝm7fu -0}Hz^j9鴴]j#;/r6Ͷe5.[3j~~|⤘<4uX=rYbvҒLmGvS"3v,1Zx Q;n9iI˕c +Fpf:_ 왋ʷ;aNeovsCw._mw}f5w}ЫŗzW᭗n7g步НC7i-w׃ܹ}Ꙃ>8̞ۑCpm6c~zЎԩljǡ7f;Z.`>AF/#́6T7]ˉRrx\c]DHo6 z T\"ս:$Y%-m+t>۫Ŗ7w 'I}_ϟSQgƯ>.SkO\!dv g~9Y\zNNٻظS%t[ b\nT}yE]w꫁ F/ cP9r Қ&BS\%> =AF8¾^<_u8Cیk~Zt`-qr ,βBdBh(֌2MrY}X3VHuQ"{`pq !e.ԏ|+3.xH]3UT꜖O7/>`3AcHL, TW:ЌF4*,K73`NOƝ>]˭X30%@ " eP$ ΁BCʲ̡KևgNdk{Tziwf}> H gBG:@BTX'bJuV<$A1Ԍ]+g -璖 +,=@./W^XJZ)rn&H3_q? ~+ARS7ң`Z\P?:|PY9hA +=Ao]_BmX=ޚmK7iXMM'Gl6>ofF HT`vZx-R7Km|xR۫KM%彵ߵ¥E(8B%)Y%&֍Q̐g"΢?w\B]T6vb$uI2&S[&Cd1P/iL5fOXAK!u:8RRh9ltA\vf!X s6id ́EX5:~|bxg-.K|\(_a6BcJ}Mb҉^J|d&@ Ze}#! 晏_9l@@-kCV:eS?L,spX ɼps#ӭBHN:E&IeXݾbW{Ir0;SO?z[o$mb[_X.h顆|Yct!j4zU|zDfl^IwA60Jgpc,f9Jmo4? RhV:>Ĝ?tJN/T[&g g _re]X6?+_H>˕/2d-Vpg1W6$zVH2u,gۂEXBx̾ 奓5¡pK9Xb1i@HtY-"+ժˡfm :r٥74 Gqc_l`r3h7;4`**ÔODMX`pZ +T!aYlL+CJl &l [:dƅXKI8Rc wXGC'{;BTRK=e=g7rkKcm;s{q7>{Uz@?J~LCNTr=67RNrx`6uIO/LLvq7/ѷ@zBq,qO}j>ԎOlpb*é^vͶ;5Brlt|[+jH+0*PHlZq-ԾosO_@΂vw:(ѩ3I¯^•_xkCK c9*@'],DKQVYǦs:9gy8K~fcD܄7ZdʉJ-mĀ+u^S{6[ӆ_JwW}O\3_y5ז :Ɵbtrs~'h>#@gL(<5[L띪NcŌ1{~v?l 9w=؂,ŨW446oZobϋb۽`ȇ3F֌N}Wۡ_\s; ]_ =߹1jp +='j羳:w葠t>˷~VrhIgbwB_r=쐊/̧qɹowꕗ 3_W7)ZׇՀ{I͠(%4'I0ciuw + WWH c1JFN~ujz$BF|<0Τ?Y [$4ffg!#FZH1mkiH Tc։ЃE%'^jXjcW߶J]-v0j(/x06mޗ!Ť-֞\,[y~gvsvxMZܽw] |O7j;Y G#![؋Y6wb=tIV{/QOVrO&eYDyDͥ%-e._mM- ^ +2 0j`qYJu_Kv5T;j桖Xu!!qrk& 7:v.t;?;:"dvNv0j;_j../-2ܸpV3Z!|RL  ļ끏;;W.uVbykޜ!&AB\$nVlXR'Ah ֝;Zbq&v_=)'k'}fy Y lu` n=nCt!4Ҕ=d-m(T>:4O>7IcgA0VmS@‚yTQ{ŭ .Ng|˒`3.y2@]~n!_O=Z'|Wd1Y,fg(e*YzC agOeCoy(W2@ll{) O}3 {R۾v^5#̶kTҪ' Vg=I!6RP ]W!x}N 4#~ e cHR:^JAQx<ҝiԝpE@Gwr'^bչ7ppXH}Ū˄G/\` c'^8ox@Hp5Hī:0Zdv\=*b5;,ګy'C3֐,1N.z /|YHVZ6`cqz"ţ0KMo'-npX7d xuuSգ'ɍl]~r!W#/2XUh'?z ̂ k ˡYhL1Sa vagbg5x?(%ex{g4.컁8F&Κ v镾fge4fvTn3ZxF:ayJoJ Xrf@Kߐ|!Jhw x=M5>g4ab4䒱} |;??u׺kwwCw6^RT3ۧ+}!IFH Վfyr̼x?3=8j_nB+wOEۏL ~fZavbI#ŞT4ViaH3ڰ^Z">sE{C9w?tjΚbQWK9!(u!$b%SGGM|Ʃjn O1:xJ'l,g~`tcRs~Rqn 1ۊZg ]qRhqKՎIتv87Bl7wpt4mI,'3)Ffgu=->ڏ^kv⭒P;,W ,Q7;+2z/ŘX=ALڅz9|!y&Қ3k08CHA-zߤx=բ9&fr7:[rzQ5= aWWyg/Ȃ 6Nw)Gq`%?~ rK2?S4RjG=uLl %{o性V#C, AG]NlSĝs; lаǙԬܙݤ;k;g%%_sb6D,7wCB851oD_h=r`mD vrY<0P9fmwHmmUInhqBr/|s 67 v;##ӥd򭻻YM 9v~)S|3X]_>0tOo x|2]N\R;k%sjٕe=w&",a鶬^.5 9jY_xr > FL(>8k6$ي W*힯V[N$՞Y4PvqؕJL(GĐ$xwqcۜ +x\UWW^XfN/VCos/(v~ 5sK0ަj|xb8Gޘ$X$ so9b'O*j|Ā4kCd[Czd0O Kޯ2*gϗJ 9C7؃\ +q̐1b$kEϓm8~_24W}Qs ozl2[g P+TX +&pCb(~C@L0xX.\N}a`\o0ꐇMWW>ڌ\*`ǃΏX}%&2m_}J?~,1 .A͉]5K>R2{'Bt-wW͟m;pꩠ ,b|HEsв|k1 +A?gI/LU`bgZ/ 1,P>-ȇ7ustϖzfkhhxctMĵŞK|Xc6+;H,w?wηU}u)xv|__aHm"GZgy#/F]\ۇj,5ʯ,[?!h $/7&ZJyࠪ)R{|{yK&n"rC>ެ^3 07} sakjvj>9sr̘P)\et3 +y1`-)b?Qyb`2 nAOD)7|BG/柘f5͹xA@5TL 37CzY|86ȋDv67}Nf0KP/~.7=vKQz1jr 7a/,ZZuW#w<܌]jg9:4':%fgvHšjEu``̄=P-uBrFfc۔PϪb b3g6pX-pr!ϟ΃뼻gV\_A&SrF|FL}{Y= _fu`}vK{㬛=R)>j;[Ԇ:crjbX9%2Psޗ:Nk#s '} VOq3byߥ +痈ITyc`)GsE/J k S~kXuy)zbh gG{JG^0f6fgEC0a%חCmr)u4Pqy95MqDZ} +).^MY)IpG<׊2r+1{C Ubۥw i-(g< \<õ|oYLjB;Ig#RR +RylÉ[玽u:% +bB>gX7#غ.Y~ꖵ'O,B2F}8b?Ƅ0˃n,U4fcNg♿B8=TA"gTb4r$7CɅJ (SK.-R&Lec~>WfTI,L;/w׃yD K?1u6#g xyu#!n5EsYB|×-`5TVev V<*!\\'"-\G,a>b'>ΐ ϑX ̳SSOPKRe?&Y5 +{o/M)1v%r|Tt󱚉 :\#<A.;$JfTm05S;g,a"7 +xZqfK-ꛋXWx/VOLD < t,,8+)RjD0'YVsmZ8b5~k5q^3ay(ָT{>e>8W`Ţ֘Į]>3V / hjGBj3$σ>yrX+e9lJY=,:a.|<$밶:?\YJyWp yA/ص2t̤Tyq91gv!;-XW^_,&7G>G ^>߂D+pµ'ݡtKB!$!ؽNi==]@cQ.~n}k{]_\8-:w*N[9W^촌}k9G8-2T'N^q!Q싺 ӷneOVZbU6^vź57:Ek6Xjrl| |C Q>-vUNAkAqa7vٯt J sPp=UNMqZ߿U+6lr28fݰx ط~lrZ~M?_U;ĭn E7nf.[1|܋7 0;lCָh5F?l ʶƘ>8Za LVc:{ivnۯqs4|1Sn.j\}4]5@66"laE^AVZ_AC>-A#~ɖ>} g4{w?)c8~}jXCĐZ9EƜ֙Ǩ+FaF[Tx)ƃq㘆Y58$(Rx4$O"m! K#՗Va,#drd-IP?T%% 'E$~ N)6F:O(w$iGA:F3N 0X+blX +T4W34|h5G23l0. UL'21>tQ=I-;ؐ3 >j`i% =~Bq=㎎% Jl)uP W׍R !9#} QmbGdF)t $k5@Ήey:{xp ^3A δ!c0r&W#2mG!E8(K1( +J27]T]ZaH:6Q̲3maFAhL/q"9Dm9ݳH؇䖻0(e"Q:h83oz@JpnQ4jZh%%’F( ^}q+)ko-rg>Uz3$Zj e%ǞZ9McI%5`5[\57Bd(Hxsf>B(πe)ag3Yw@#Jxd!aT4Z IJX^Щ̏F[*ayvjrC\a`՘Z5Q +C5\dF%4$ϓ\1^/s!I%6N4Yz{%F1QT%]WHP0ߋqCEk GO/VIʡ!#92ie>Lh,+1d5N&/#l CRm30&gMRFc}C~_xK#uπ}BB ¨d!`W^Z $"F/3Y ?$;<߬"-1BPmY[nxd+bmaDƚ{-ER+An:P!Oé +fBrm9XKs *$|!|j %`4|#FŰ $%]s1 ےÙ}IcO ˃qZ)$}$ɇ%҈hpJb :g}X~0Bji|2&""CR#+bzdFSմ ʑrJȀ  30v|fKX![?$F2kR&B k cJťe4rpg-Ʊ0>1'3$>?9c13Jfvq5biB58%ȃho$&hc&l}l +˅;|W\\K>K?b,~f %f^ht_QgA#k,,62USjW3QJ($OHB ļ$W@/x4“s /W2sTc)k0~,Ʊ56MnҠj\)>2x4rk0Id5RBhh$+J +⾹>br/jG4ײK$z HxkE@FX~L'/Vbfd`SƋS3;Yst bl=Zc9rRz&3269vqd,V >  l;9z', ߢ 9,,Sl%i-XARnO\N鏯 +Mzg\7zos9_u~!7$Ȱ{v Q9e&Xa75 +FɇNA-RG#l})))`1V +e5IB8[A)#cu躷*zI _Z)!a搷pBLfRvi b3$`$O|?C?ܒ ZR<8R6 M-d .7%X7!D~ ިו( /!)\7o$I2RhHH20-`yZ@"pO˪u=&??: )L 6NYHnBH U\`z8cFoR=U +OL11d[jZ83@@kjVkr6$R@)!#, U&7L _b%6 ͓jIp4IY'_:ʇxI$S<5ɷ==5.Nk)P[+-u<9AB#dv i@*|4@k|h!*k I>>dqCKB i$ZIil.oĶ?!Zi>pH>j|3d_3 Jt$uHsJ ZcXc>}KNVYR8_hdȑQwX=9*HQ4YO2G@j\H0_/uj` c + d߄%@!-zOƜYE!j, " $p^/vT-N/7m> y,zjZDCjIV1n +˥s{ }T>L(n .>^-njfi^< +.4cDWn>\'e4OF~(fTb+sa^_"YjK|Gn d!+Qt$+@)s=K+clpkˀ]ЛufWXS`u?Iȇ%Ddhm2G)Afu dѷCb3 5$ A$%4Pn-T_F0daqc}̥,9%0k$lC GWfvߙQ?Y-;o@rĂ1H$>4v>ȝ;Ϟ_w u`j9FkEXOP~ܦGOϱE_R2z} 襰|!Boܐb*ǴMrC,e~jR[}Cm@``.ɓ$Q5B>bZx)/IGǢ*& 8m/-Θ'M\_䞜= Tqm.؃Mb~LE9m*wI}jG>ż:a(ۥ6J^ɮ,]XdH> mG W +\o/黟o%I,[Pu:$˛-oOTJZ ׂA\X-IJ1cd>RrɅB;+䲫KwJfLk1Ik&)[! j, $3X/JH }vP2xh.Q$7lSF$tspʕF~}}G +, 8bN>R㈸e8YIϱ72;$ +*wφ+IqWNH9(c-Xu{Xxo$:C.jT7ggG=|5g+.O[>(־RD.óA<:d {g#?BGwOi2b٥BLbzJN͖sN9!NS-b:d̀;jX]b6jQHv+O~HӺfqMl` H۴IgEnm^y욢^'D8[i$\w}Rubu\H+";k%jVz{:Sj%H$tLHPvY.%ƂW,Lҧg> kבS~D $U~Jj +TCuQO΃e~Du>%j,/Zz5N8^I`~8vJLFrzg"'LH|>$C`*!; ,UEVVcW]+I=x^`UDfg; 1M6$Qxb罝b[I2oDR]_C_[GYvv!hZխR]4\91L]jzo?ij<.vE^cGC wl +/HHr !L/mT !Zr G՞GLGth=Q=eT|fTqe)=U!mYm$Kfɗw"#G`u6$ 9}?%̀dT}k%#"V!t1QVTq8@B4ުl +9NAH)@B_#!3Fd-]g((KlW@Hl>4}8ckW`kFpfy&B}ҾhKS)7V~]3틭\ gͺۑwm}nгZ] ߀+O/BEh'%7s&Ր<8=,=7@*ug GB6#M.CIN`NI[c@D3evi.vbkeBP>tB΄z {\Xl!#7<5Bo A2j{ !pԜEB,ҁٍ1@!i#Š8k/vBH<2Rw ; ﭦ~Bh~S)!OX*IaU O3~5@ת ʫy"a ?90Iˢ~e1B`^ r`;d`199j^U⺐g=s5Hl ! kN4@05!!^#izkONMQVgp0v|H"!-^"rN:jF<~gL$7^cLmNG%yƆk!=c + Ou^B\ۃM`D*;kB gx*">afBH<BW$Dk$Dj+abOyV'%wRϠ"9ӎMR/u~r{~wF_Z?=Wl& } +ռFaI̸1t."~rPzhjpHCth yYRt.2||اV 5߷KgmK +PBף|9zX:Xk'/بp8Zb4>}wz6꽧V?ȁlkp!!j.pDBi $ĹWKǢck2p +ycHڴA#Tj'=\σۛ6sp?:>E-Ic}U^s_׶iHoooCK:9SQƞk$HHv?+CqvI%C?bͅؼFBm϶.2P}n!n:wڳw֩R|:=6]= ލuѹ\[V%W,#Uqy1b(7>} +IwIvҎOD݀z=> MJ7K g_BͥBj$!Αp. G3avDdy[/sdы~;V兆++E)9R>5P:#~3`?z.kpj !ԃ@gͳ % WWL)AwKR=TÀDn|hI)uDCýJgM5;i8qao>z} +GpO-O?>(zhq7G}4@Y/\ =G\dv' jڏ^0fK}Qզ,W<幁o\,eڟTXBBV:rpz^jA,BB6@,7$z ۉkN%IaRg^O;c`k7X܏V0I9Y +5C.>ոZ{KCR5|qN H =/Y>rZwըL;# # qtX)hNr;2aqQrBK6QbKA~|[0zlFVGX G 3 ckUjJWG~iIЋyI~$zbE߇J/c꠻^Dz;@8V]^,^`6;7(G/.VR{i У i_<_i_c'_lV,"J옍L.V91S~@y˅#f#{_lpNにEX;5skX;ä5E:O,!DI*:3g2&WB?@m&'U^H3sS3&ׂ0Bڱ +,#Ry,WDCqy!Y hc3p{L0U8П5חS Qә)YAgtqr |r( +Tz8t9ѹrTXˣ # kH>5#Ӏ~C֐4C-?{E 3Vv'Q*38B}Ƕ[3=vX_%gҙ?}ԳU@WgWrZV +`g-_Z>}Q8zvzlDpD t{2&A:~6p:ϔ_\7Y&@HEu@0Wn(;8.b픞"zP.tx>VBr`kq=ZGEM;$ C( #lkVtѢ>>>Q-u\˥s!3{SlηxCaQv*$O% +Ku+zRQuu)Kp8k,t}V+Wb{@/s/=S{i/=,RrX@$a6Z{}O>Wa\“_X_Y:Ol 8;|'rbeʈiu 6)`'*r{Oíu}m1j6F ܃^X80K*s9+z/7UwVS_ CMynE+&<{`ۘy3ɥg,ϋ>Z' xYYIw.^XdtL#4KZdO@47B{ Zvr1~?ڦӿIaE3꡹8>7t> %oz\T-j 80%Rn 5‰/7b-?zsȋq6t/˨ΥHW)q +Fcgvs]s.EזbO$Z~mY6L' Y$9"^ /ݳxP`u$bLhPp+SO{BwDϸ{O,_o}bΰϯ\Z~X{-oh_[Xb!, /,?~}bl|/۰'%~ p^RtrbZvyT}%@>ԛoE8:8PUEYQ¥|O/:? XZ!x1cT|znAѩ߈. D>~A4{f7 gD$W_ey;(?$#V^]g9kjD.~,9Y;5k;_=uW?=͗/kIɿzpCu+Q|bxI(U}R[}K:#ЗBUR=ƓOx{ʡ{]N'Ԍ7f5F]w<چRsk-e𝏶C5'?{ٍ}<+"?b$h\]KK5o "v#093yыT|fPsp \w绅^Ǟ{ J ^qg~ҕD|ݧ槛)\A28pQréǜ0~3j%p@VzrCJ,OܡBY\ѵ9ޭOV{_wS7/|oC{ {w˿f >5xnzq|`ozͯ"}/= +0?5t>/v?wag++_{sj:o t~T\Z/}!fߑbG߂ro O!>g#]Fw=|"&X9-w|U.̷Z7!ww/?<ų/#]V.z(_knvDOU6Ggk_ ?ܱ_+ 4|ޗǮ|]}R/wbςn'7nݩ?xSͺ=5\[KzIFb--uJTŽu{ofRO%ԫâ=[]8}Y*~nI=wzhYp韛+{>9+MWvWֺ*u4Rz\RP+%MȜ~tnTLV ظ#G ]'2t) ,Si]|K{%SH}j歳YN]8 |/vⒼfj7q}T5HҊtg!+ʈmC"QeD EY >mAMa.~}xoqN<F\ۿ8o>#]7Mᢾ!*)؏bWKe)QADz~"ge'wXajnZ@z0usZ3s:8WjmnKQIdס-\#nwŅmG$/Zc'CRmIt@J<gﭨ7]GȢO6ۡCdEI||/L  z$]$˃DUnDA1һa?DMPދ,-i]֦s:҇5}KTowĭ^SZ }kvY7bM]^^=R U@Uu&{O5ΐݧb~/b|@  +4͚l8K LjGZ…[>;6x'"Pׄ.Ci(>*~t:kӅj'G/$ɍdõ[ߌ/?aB0q` nQ4SwDŬDzyQy1ɭ6()\Cu=dsb+I ;ae߬^Oa⑊0Ӈ` SK0u"9|tGZ$l{$?5N/.n#j׸&zbkQAZXc#)h1ޫ2+ v^za+zrBq{+ `OKԸ뽥m,zKb|(H6z^Dp}&PTL4;OR}b^$Оt95ɱ1)TkhgnpQ$9/l&hG|:JMuu7lH]2D .EZu,Cl&XwJ\%-8MA|kQ&f lE7 _wJ;ۚm լ,5V;.k5~z]hT,}UsƓ!?Co=֕m.1< >"$٠Mߝ87ђOo#ܚdMVxݩ.whH@-뺙(Z'[]c<0wx9q勾3v?buϾκ`gI?N6;Z|=͗,J$=udY<>,ҙo1(FP0/\qa'ztЃ5Td}Fl̽!ZfvI(I2Rj z◝f5Oq0W-al,:|d4V4PdiweCCHeckjj@cXcXjz<1,SQvh:c1T*iʸ|)!7j,#Fg,loКK,RD ٰi1z';N;A]o7}l 0.מɧگ;ٷLte+&6j~ᙼ`tYxW>v:Z[';Ȳd0_nEti)v]?;u/l[VkLX^{[v=9)|tqktEsdmsd%%-~GJ CKVЫHpCUcIcM@>v[yydWq^AFЕݎp#/j"}C2]7&zpLV~Q2Ti>N|)L{g񒁒 g{ LpMS.+it.nqz>5D5D=s-.'>'>7>64QMyy&}wX$?d)k%~~ʼϼ$}Y]Ia6vyP[&?첑muØ򋕤1 &$ӫ^iY":b36}%V߳:o@_X`>X+iW->5[Б.*| RCI޲u1(u}eEig|AL^w}~cG(-PZ_w~e/ht8ܐ]v\W%'V=ަ9rdyI`Bv{SKiG#^&kD$3#:o^)LZUgqBZޱwbKZ3[<$;3NO^C#$Z<@| Յ} ?}+j=sԴ}P]OslYS+ƈm'K*#m'mi"|hO_&4N ޚ]r%GUd gü!:@LP.0.덿[?qWy^\)X쭗uWLqGLfo|\M`R{c%ӡǺ3b81GeiV'vQش[X]XT4țawuye )`FU`](2|el8[OJk}U`f؃(ͬKd/Beg!q7A7Aq 㳋⮼SG|b ܼ]-W-Rmh2;ǩ#!U;NQ m^ grJhѹgȶxx3UyCכ"& +S$0Jqi:9u-X qc>F<zrB/ĚFϛ5m5^?Qlό=4'G郔lXv͘u>rKEN8t܍:U {w-q E) Mp KS{4Ty$z3qO|JI`#t@OTc_nMcQ>mdx1Qu+XBVi8-T}Wy&[Ӟzⵯ7e^iϊ}2dձq ]P'iXYnOoĞ?Ÿ +3ty` 8Nj'́1~PSY&+/cׂ3`*o O`<@1!λ:*A2lE2c@_5('}kq\ Xs:ƛ|glt>,c(3&_7_~+^y:z%&1I[i,@}0Cu6q#6zP6K7[fJnζV}ݕ(yc_[7ߗd_cX?2S8,8Q + +f,%0k)+H( +蘨 3yx[s23Pq _`.V^+mglch-al/ 1gPf?86 +ƭnsfI⭶8 +9q0s9f.:`l} ׳qF3X޹P4$Rk7)0_x>Tx&׸'5ʇS*5Mr`vH,㄀UT2XMVOF:@%(;T6&&mXl9̽`{?1##CU./zp>9Vg5ߐGj:Pi6i0bO\>v%po~s+3c?XK;>`7Xp9븂X⮠U!0tYz_QlR7.*G5CDUlk Un: efmc2kF/e/ PW^ hYTi3`oǔ`4,`Ѧc`>/ uw6Yh<^yWaqj^7öUyZ-e`0l8|_qo՘MQv?b1[٬p]ͺx.. +.)Jx7^Pݒ14N_n^ٯqDM}]?cX6;D^re=L4cZ0elj]glX/A9Gui*`2Gu`ڤu`"#̏O>W58}5fJOxĬ؛Yej;#{򮚰ܣ1jgVld4M?1x@ZeC595ڵ;YGle[L[{pWZCg]۫\ g,G2csܩ5F`Iw+lZލ\>v1=VBe[`ոm!5OQ:fs51n0K4gh3+=fFhňZ0œsOE9 jW.̝jhӐ\o/Bh'%+/vȎa>Oz_Ƌ>%DXWZSy>ҿ&=݈?l|#n.ن^L\ւ6`s+m4j7K b~a8 S` 3=1nCq3IhB4į]VTI1qyi~o:XN6~%^9qtE+u?TaXAvQ +/&e4>2R)! k1]7_ۈ1 wm3*E^';r2>6qQy& +̋y>=4sJTR22LzL$!w<"eyGIZ$#_W5i"o+\+KӅt~'9+ Bn,6:7}6My"v743WkF`2k ֗0C24176*@_[L-NXN'TBEs^t tvL^U$ل ^?h^}c,a< +dn:W~hȺ޳Sbѯ |5ċGlGnc[hTPù{h{dj_#þZl૛=/w#/N=F4~S{j gs<~ryf}bw55w~1UGzo=De|oezAB+Q+G)vKn/qI&'0ɏ/}5: -F )Xc5bM 2ZA3A]YٯW{g/w&n ȼExrrw _\3g⎉jKL<\xD}mw?xBQ(P$|7 o6 Rlnކ]&uQ4{]EO<NF}o `\207f0Bf)\K'>`ܲl;OWu;Q3 S0<`h=]<^i(ր&0[)Y;zڞT<5E>O{]K?j6ca!K\t]7]~baj6Աnc ̖=ac,XVz7o;>˻e|ۍ1[u0/Xo11lfK#Kȴ/#' MNxX9(ZP24V/Z;vC.NS^C }e/H9[<"\N@:'Lf4;W^IYB %/YV<ğn/FwXKj}uRW@Ѿ8* }W/(/2xu~-cΙodt4L`t@k tpK^-<{8I,NN2\j៷ + FE{.câ;ĂBBY&)AMp"t3du93c/|Sf>sAKxM[y?M}=`T{yx;'.N!eKi$%#pe+^w.n*sKTO.tʣm4;6npvc^6ғ8!;|k 5TA;AlX̃uw%f:1pK6yv1{kC؛nsۆ؃|oڂy_Uy.<&]Kx&xq6`}y.?y_*i` i`'~p}u-0$N*rΥM1-daOs'V*BsОa*XrJ|CE^/tMm i#."mUtR\!|Am |.j=2EǴ૎MZ1O<]x"p<#?7 4NxAՌsKYP"Vn=X`\9LUݴҫĹЩ{:ݤ-y\jkUǮn3ĕ!=򽵘5 "/d.ģ_n$oy*~ ~|S8UټKgSu`uػ]h&|kϒ,pq҉j`픹`?P~e松Hygړ'`%g6?ҀUfYH Lo*"~aFKC/H*(l@W:!TdG?Y4Қٹ~{%q",ryӔ)DcK tz wc~rz.yOENݳg#nn9KAq\?3|o֣}+DްT;9;?΄6g.>2p Vh"w7>p>}C}ŒChe5ij!>~u{'!wVs5+#Z^]&ng]~@$WX-+6uK7=7c8c̏ M)`!.ꄒ9FA{kHJC߃(q SmvM!Kkm]2(g %XF~.7XG,'B}HDC,n%n O7ㇽ\) \a9[x}]GT4Z+,)cGFڴl٦C)H##5ġCBP +L`0bfB_^80~im{#FXG]<:|:ċ'BU=yl~v )\=߈v6vKO)qÊ|sehxS@C71.*a1G2p%иb¼b>q*t2~2hn5;6#IK)-=Q +v0IZӅ-鋚xA0| c0*7_#^x Lf| i|ڦ b RAk\"iWng4=f;+k5{C֖>pqC%xvRcQ!"Jbf91;2VDY+J9d-&* bcxPb,e?ѠAv}T赕'gj7m|A&g- !*n=.zvhs^3;7G ؽˏ‚?`ѰY3sU2 q[wឩ-KT}x"/>#(̏,841SY~)XGò*NS(<<2z\:=(o|4*RFO#]Q$gL<sq+ HY,K%v:~u,~o< ~}trX3h>bT Bo +}w`Y+pf3vw<6AGm!=j3#hG]F52n=*ӄ,:%JpuHxqP&݂4n~2ƕm<2gu5s +}ff>C`qGH5K{%|Zfue%[C~c hXc#PgP#6%嗽 \4ǂccfgVǕf\i &(4o5t3b '˸Zأ,K +ARAV^8w67;=zCI^ʮ#.]W*( 6G-^8S[D3J\0F{q?ytp @dh9=/yg.:&\TW iķaY=F)y ĔGJH:CS6h(:fXb4E4 cq$l1py1b*JJ tqn*>H:GOC[!M,Kq<(VQ8s;CH 1HGɈBxoL?h4KT# f4Z;aB!W".{g6$<dvAs1(?sk<-ؕd%Hw2&C@dFC;1× #NG=>֠.YYzؔ +2q8=i`!>!paQEψ&y=)eĒ!Y~%,K=^[Ne/CoaY)W`q/6"1ol=T#+an}%)ĩh +wMjc^ckNsϩ$Jv\";V'P@LnğFRǭΨCi9|rsۄǕmh% :Z]蟼mD?4ßBftq铹gbϨ΢}Hu uq +Fxjn2Vff{%ALqѭ&O*݉0&`_"TL%\bgUVjl"CGY*`GGZB Ӂ0? X뱱)J žyKX?\júґVE48jx_Iu](^=ٌ쒆s"h'^AQN'j=@'~4e-Ϻ9!Hk߅_[D{&AfpP'GcGǚ+bΣc/T yuہ&rZ*,)NѪĥK ǰXS= +iMEz\ φTпQPCl!*NYt}0j7y>`A<$’v#1!dF21A6r8782?JR_iё7 &lϨ >PL+;_G 6J,މgE: 9bEH@R]z>ӣG0IhyL9LY,[tɜC"om,)R.pysJSa-{tИ4&"~c5O!Sgs|=z*CғdK2H Q6\Xg@|c;{s_Mƕm> %Y\Zr'¹^4_5[](ӢS+m`s2WX41}dΐ7`-:)A ظ +ז3c*:;2KZ(h;9wBrG,0"Uq|>u-O^iT_`5Άڴpgv^G:?]Ky$ q|w{K>k+:cOClI'/@i'".=e{\#n+m+~pKM2W@ˑD1!Ec};F*_( -( :2UDoq16Wj6g<'"m +VfGgd{igY;sO+ +m!y1j8>"ߌ蜨Cc)H_^pE!cZoAAˑa9ak'[Eiu:Keu!#z<;E9ѕ[Y_ma7WH1Z]W +\KĿچ6g똆y9뒬&.st9Yb4Ŷ5l'G!]$VA[%vs.|bYo +AY0s(IW"<")eeXˤd>cșɘeτ,:6ōt`Fى S^[l񥼕tlN +V +z.ʑwY̙~Y,gi>#5:]ڟs؅'ΊG6A igILF#. CqHlnܟY3v+K;m=}(Vor1g,8V5i6< XJeK_}!Wx־^lGp{{<ĬFMzTɥfi)unʪ<wZs盵w^]{)B1 ihS押$GΏΆt87W"5kK誝(ϥ]3fp/NYY-vbyzmh_j=t=H[sXGPb!Y\pt0*$q#9:VbŲ;D։Bnf5Wtѵ7h)pUMoFiƉyG׍XYz 58{i2fuBr1igiYh-/,oEg#Ր=ӮӐ^Bzɨ6O,ߟYRXSFE>v.bO\o|Vl=r3Q젭\F[fN3o?xq@bf5P!{KZµ"Y-؋Wu~."X~N@ȟn])ez Q4U@#ZibSgQEP.I0єgL `BzHI2Cꟲ頣6Eq͕hՂpcbأk +P͊]7b^nAzH;v#jgH]r6DM;xs;HvEZPiwALe/EHC];Gf5}HUt.v+s!Ҩ3tP@9bsR5( `2:ۈt9aU%͕o;c」ʺ#sNm9: +$I%"gDsΊ"A(s/{=wwx{y%PU眽Zsל$6bEyKvo?8YwjgqQ\hgio\\}cMTQ,%RvW]=Y m9GrKv`^h77IMg(h+п'y`OQ[]*`O8=>ApbDܗ9x3RykwfYqˏ?[kc<<ųZ{&1S6'^cd"gU[ġ#" i ?#ēӡWmeM2xsMqH)j*|)$q[?!>2w*~+yy*a_tg[ES/.vF4YuùCokJR%-vQ}ke|yQKCW@3F){8_.׭c Ƚ94)uKS3K*k4ԗYY;wW9!h>z90OrYF;Y? /6Lp 駰 if#wU; %hP}IRYRh(CC3 gBRt 쇽b㨛(C̳5Rݘ|}CW=ǦKA)#EV߂={q Wd%ktZ!GH;SR gPu +-bK'`ErI{EsN~9[-b'ſIy=ǘmYPDG~Kd> !AZŶ^GtBU|k7!X +qLX=$Q]#>XP<SsDBMp`iB 8j@` `M;0 = Fp>=WȼX*Ў. +t~smB[ƟƢBOFIe*OB?N@GvD>Ƅu u)6j<T:\,9_FzV<2rMz2-roA$+rPI>4[ Tr%qTk>rqa}k5QTA$?_|Q*~'Ey3g=Iqgg+}rFv.:BiH+hmcoJyT߉X4׈;5SȻu{pP[y@GrTɻrwPZ%㛪, eĶY% #ԍG`TԿ20w4 Ec!DVG 3^Qt #0ĖĄ3A5޷r6^Qǧp&"F77G|p_R=մ%"@5Pè3P!mS}{Aׇ\'/|򉙨iHǛ$:WZ]f&0X5Q/2.y[hh!zNUQg]MU8g")p Kr ǔM^7>ud2͙s-}UZ,T:t>t8b?q%YlhΘΧ'1;u O4+Q-OYbL[a$J0[`4G)GH.Zg-O1. 9r{w(c ]::е^hR叅j%R.ĚRLi[(fM8: ĐQ2/.Pk]#ϽXo}iL?<~XJDqJ@wB}&D""y9?YG>o.hAjB}^T!LAni K<<#- 'xe{⼱h @9 _\ \qj7\ڍW}!c{¾PB_xo|*]Fދgm]u'pq;t,4~Y#kk`"# v5f!=sCPC$0֟jb sSF"f\YE쏜}b> {"8>7t,8)B5/BEy]ʉrkor6r Vs@K!qF=\ S~تIRz]+SU̫/:=kØw&FbYD<?] \8 +sܫH9p4󑜉p/mٌ153M'a'6oMm䞉aEc/ݿxq~ +bϖwn`^<^,ze!wq#h{%%ql({%>Ѓ3~<-@5Z!Ts+j&b)g5ڧQ+hŢN昸ܻ0bg$?. hqyͻXH"AA?èN=L}6!X/6ܷ=&Ca/n($han|jwh"B7/E1Wi\J8>jkv[1A|a"4+c(6{ jlٻ@'lϲύ ͊SX=GntzHF#]̜oǷv|;ߎoǷv|;ߎoǷv|;ߎoǷv|;ߎoǷv|;ߎImYkJۨ;iզEg3;m=tt'YYsNVgEi2[m=,Z,U͵ @~;M&y1r֟yS}k}c{Isk+g[K$Y?̛s,a¹_D?>=o,wӚo߿6]VwR9VWOߑjLv߮yr-TV.6Y}isWz/7|Hڭ?ooכlӧ;w4?o5_g䋻f;8.|KˠkmНvC~>g+3ES?/|RqmGm7_|]Z?;i=?2/^mqˬ[cl2dCsn&V-cU7#Snv6nk"c&68ev=dv=lvHZV3+od6#S7#IkǬ]el\o€DMv%1f3 x+B+se=,o6m`$aά[|5cLy{-4t`-5C7w(}I=HK C6Y4>cS5McDFOV"Ay4\49Np C5Wѧ ʢ+x=yvPm 7d+[@_J` +U7h%&6:hDC4o$fr[9kɃ(p조8 {2nnK)KǢTrZ{4^{t$%A+ǞA)pV1L"ϧSL۵AH˻d #wJ94Eg&-4Ѝ pVZ ~4Qk ƦvL̬m6IwD[DB e cEm5g|[A,kY>r>^: %71#S9jȜAc8#i`qʻ=q3yOƹjA|TS{yݦ5 &Ȗ-vugnY;cp_KP?3jE`*ln藪2rDR@(eH>Hxuyλ{+v|#wђR1Be`H'of JVH 4d yca>i#UJJ cd;B ڡbE(,Y:)h`vzSQh& +}m;zp6WoٺB"+jg'f+wg .}9׀>s4(h M.;C6p8mJ%c)Wܚh5${X?s% bz'g4GI߇6D V={&4qv:(%`~37fLp"c<G-C#1iyT۵)n2筻U dq~ l{urAܦ)kߍDk@36+}o\額E &DM84!9y#$7msQ ch_+e#~Wr&[Oo&hi@@@Ƨ @J;cF_=BHAٻ蠉+ƌ3T2FcE')=tdJ;-J`,rVغtGSfcch=X g86A3hÖk95+a@2qg`nZKZ"C-ݻxK ./|AUѿ7- hȆm N>x҆Q B0o׋N͋Ȋɴ 5R JQ{'|0dIRIRMR̡E1AٹІ42-=t+ w S_hT[B/&v@ ']dU&%4܊'ffk h84pP1xosGScp?1`1A:/"Y1м%E1>m4{cɽw&DS!ʍ6Jx _GA  v7T 9ĹV ٟEL~` +d vb_~ @=;Mr^:~ "FJ wėҦW2'-@. Cc8[-J@$g鮣Pjɵ .A8{Q( ("<`ԞAzC~ݭY +Q>#is#vCJ@pw%(BmGAl C#is9+ÊIaEhL db^@ 7 )QE8OJmb M!9أSA r-.T~ +IEdR: 1H1@2 Y^r[#\}Dr4z[ nh6AlvW`JvzddLI@ r?ӎ7x{:H _E9y4sH8-7F~_l#ğ ȣ$t!ғ'_d>J~ߩM,i܉hX\] ۔@XgiS)G \K6 (`2?(! Bh$Q/؁"|%Ry{}h|̀RN\hS6<,/b#%L>5ߴبB}%}X(\Aܱ)iBFSܣ6ަ7I8vu++2}F`u3#X"_IMy-3$ %{`sf:HindmM1>y}hxnȸ,> *E@H< $9h]\ICAr2v=@"$LB +G_p{P_7i(%(j[Eo4&<^Eʅ }RQ\ ;`+|_C'p"mbh%E ~bbT|% M6Bә N}(!<% I! o0_0Ȓq[Txl]xt +709; _Gl9x`QِY9#G1 >4o$rY;hs=w`*@b,@rX'2l{(H<`ߑ0h7\Ea $BkYˌ'y `Dgg -ƞ r[#n%^%r.s.qNr A5Q`UXzv7A.n6fm!}Yi8Xn㡃70~4LC ٣AM0?ի3 `@܎9EskD V&$G)z Ȃ +%JF}-Y_vO|hr"rf@I#Pk L))%q|M rwB|{b{k.Nkn `+Qrۓ`ϴ p %&$0GuWCn郹ۤ> >if.A \٥ex;-)6O| + 3 #s'Hm$6%9c*Xwy>n][ D{ A*|z`,wtsX-;Iם?#t!:02F +$Q' g$9.%؃ cGܢH!UTB3 cvF@,Rؐ p+1DZ==%w@$l˩i }i5$T$!T发 +Ǣf(&)}4#)^)(:z&%'VLaw)>[( +WO6dST?Z{Bp x;O|::pgJ Q\@#9;˪Y<])5 +jWECHJHh䥔dKw ߫O1yqgIgs2`e|!y?%w xCDI'ѹIux[@p|+־=Ӂ +Jg:ւ[@eԄAHA8朵[3P q%prG$Ձ]ZO! t!nW@`=Jʲ3l%((^o'яFw+Ya?I uY^Qrzs'(>Vz4飆4ZO@v H;bow/ > J..{E/$qni]I$yYy խb +շP"H]1(ezl6<@D@Jpf~˲.HҜ[]us' nB +q?Ri< c ,̹ }s5؁H|.HcSؔKӅYzWO +fsSjȁɽve끤W;۵A|$/oo )c~^CkėQhgO6](粇:U7@U삷 Z b;r:aG`-6w#?ڔD쐒s03de)(j_8 `чuR.M F)C1UH<́d4ZCh9|M酄3p)p +?p|zRBʈq'aEwC0=1uK쏘ڵޡ i.Ib: &l$wm_A Kʫ_->]` !k׸trn,2oRCo}sc pMپO;ׁyT"_Ndλ +gERhXOi$0(iKpgB4o#H!r>x/#_SNΆxo阫@|%/G؉ERph[|dli9r"͗΀B u&*vQ5I(['V=1ʹdwR rm#8GtVHRWsxu`*䏈 D\gDAH<7K;4 endstream endobj 102 0 obj <>stream +M +-|= 9|5DC#um!P[Gj\d5 D|vDm+&ш]LyJk}*[*v!}ߛIl,gX+/bQ'~)!v!ܡB*e+,4bb~*u 爡| T*Sy$N*wЂB1Ik@+ڂF$Uw'G %HIQ1Gԍ@Gl +e ٥b1EEFx/I. +lnjq#'_akOJB;DkCS5|>H@چC~Ċg`R_ +߉@r6Tt9}=]K2X>Zp =(\y{b W~(}8!s {xSCd"^ >W=^IA֊\HMĘ1b FpaԍXf62E"e9z$F kXx``JL !GEP D^ARM LD/}ȻMdN-7.7ܢ,@\?ȵ؅l٬`mT!'yxu :Lz]*wQ?DEEb/s k3A1o`&XGēgMʛ򘒉bYFeEӘ-^_ =4Yw]R ?cf# HtՂQߑ "C.B5b?]}Z:h+DG-w&L<[#}o)Op' +?BsNR)\IZ~kEUKa'!$Gs^z#_0"aQ?BIv^1 ƅOF]^3e LrڰΘYfi)c;PN +邘5,s{|"|<{$ƵK%5[$h'q(]^`Җˋ~vnb)gf"v] ig |R` ʀQJnZ\p[KSQ}칈(_{~ĮW +7BJ1C>E*fY΅ܡ6ca_f/DͫY5YW7pUO @.%ָӐ ƚW ]3VT ײ5Ŷm=὿]-%O)!Ltd2,u4$ )g +iJqGgP <@bC=Ɗ-\([×ԬaK̦ߚݑG& ~TݞE&]I}TiN, W"a}7`yطGlBȺXܸجNk 9x Fe^:1'MN/w; 5{*IסqJ>4`pFu ┛7la nL>\,o4=6SB \}o1HAM# E0a]TCrSåC +U:Q6V>wbG@sS !4J?]Dh.Ĭs!hAWz| D +ˑ<%u4?)i]5AOFC:12c5tAX }ϭ])l`So}5!a-9:ji$G4*.\wUk1;f|u6]45/u/.x} ݀A[pH;*:yWz$}bxhJ#-ÞDǝ )5!_*05J^1Jh[`o3')Q @ ) 5luuMTM92B`($EaWpK_%"NWU}hkyw]u*CD5v Nxr:wٲueW{O#+'P`GsХk$v +]( avK p #wKld4yl[^*v8x)GgW!f+#&}Ҝ6b2W`TX^,_}>`߁V*t1ԏ-RăӨwq%*yh@WxiP< +v܌+oB)#;s" }j- f3@b9pe@"jOr^ a%sjh3꙼&=5{h gg:{5{><^Ƅӳ @a([w` +{XB{b}XZ,Q^ICX=Pvx䍂jP)t N [`aWYy +Ga{x?1Zw̯[ oGN}h +|6$ޕtB03l@ak +;K;1[^<vIO0-ՅT) u8D{C(9ɳΣuc:2Ќ?5BC>E̝{_* +5.DryB$ sq XGEN/{8tO7 *uOq4cYg^tok`h"Q섨s QrIO;,R/$W/FKm+xH~pZ寧Ԙ#Shxze >p2{׊Y7 "!%'ƟŚ5(XD{|QOBX3%壆#8D(ğ M9; +!u Tx :B1OT;L4l}} j\ľ|^}BG^hxmKzȷ)M8<kTxR6=_L!0/󢦁8llMƥA +kW5E]c 1ǦoԊDׁh]JJEbOA;^d=֮Q[2pFX=ާ!‡Rog-\̉.\*2d=Va_ +rudDL=H g%ť?b+vw9+Gv[ !NB5Oa cއ/=dT#ؓ tKs);χ%&" ꓫ'L(+W,=odn槭ET.~}Q{W=%SKs5OVUֲZUi{o^L +,yrg+ /CQx9DhI=_| Wf3WnWܱ&x@,NK[к4|~s| WԶIGZ*/z|Q&iY˟Vf+Z7UBEXʋ~9~s/+wƀ;flsy۟eϖɫX]zm!{Efϝz GȃVyт?*{&OX^rԇs0e{%<XFyQV$| +D׀˺T*[+z&^˸e\qj\]lq +6۲忭gS̅wy6+xi9?;m}z -F 8$bY*{j"ބ}r2ɟF!cذcgƛ=grkek+wjN_vY~^??uoqT5aR]cp{^z/IWUXxl*o4S7S=ȕ%G"LJi_徧 +cq6rE˰ʀ䑖;[WLұv| +QAtܡNc{StϟnK[ŋO텫vNzEaӏ+Cf#c(?X~7#'SN=ʜ?.'$F˫;ij'{_"9.\%lrPBU'lHQ:\'p+2ZW`B^|jײmb2Eq䓡'c{-yŕOJm♗[ţw(3M*lVlĞxi e3_o~7K晧TSoy.ˋ+׫m\M87>BW>R\NVl=Xmu1mjX u[uMGVkGWuC<ޮTk:e뵛VݥU_ +-4Wiy+W>^jBeC&}eVGm-?V!d:cfVKGfmU^|t 7_9rުsxr5Ñٖޞ{ڝ{֍l7~]UPl=z٣|+?.?bU7ɋ;~^|g;%L窞mWX#T>3V}.>rsW±V:b%\R@~!C8i.?JN͖ڍb+W|'WCqĝy!6)'Ʉm{Նkj^FY.}lNu5v)5nUM#1/{2iR_Np)Ufig5JvV?Y%i~ o]_We,bߗ7*V'UwX N͇~ҕFgVQ4Xe X7LX7F׸DvOy_?_ +pEHjU]ʲjEl{q$K!һdr-_?PKotn|}UZ^ajGA7쩏 ++Izm^$մ 7\g;}-nE<מwI7[7^j8M]i}hGYŵaYQ 9ϷkwN~3*OyX>lhY!mqU}X#/FjI:lwZvIILIdB]|icuճ{j3'6-u=w(y8?;Rd7-UgH5ؼ>ۚUX$$7Ix[{eP[ "s󞄨7q> <kWs/Ueέt<)~jO:[T[.'fo?憺:u|V\m\vxmjnHCjnQuDNBm|!M.s.m?%=Ͻ^DVLb_EEu{ɹ)>| 6eh|P;ۥXiJCIܞ){y:oj ZqZ_ǁ{kC2N4gkN+m̶}0>nTQ:a9bӋ}6Կ%-+}w2C 3h2x 6)htBos}}tZftJ3ff Dr ]/ӏ!PF_{3q>3g)eJVkɯ]x%E|*^h.^w&8 +ʬkkە-?Hp~Qn.w1'ɧۼek)2ܵ6E3W{X}f ӟdt.m~W ?iNcZku W_MP^TߊUgߊ̾{;&k}"2O ˼r+D}VHu/8n|/M??nιFbݩ٭_udL9`r8䬴U`lδ~-z5x%.ӳ ?C?i3bLf"fmT7>ve+kKpj?[u3"U2Iz/0-.)ͅGysw2VVGf:uTf +'m jIkxa.Y7F/i o^{3䚆LnƮyad.ٙYlغ]Ӎ>tm_Ru'Y_ph?՘$+ueMb sdaO_Ⱥv;|[!A/dHmyśr6gӃˌAdoF/w|gz='11{1?6 Xk#?χEⲎ݈Ⱦx+$Ͱ Nξz+4ε7C3SǪCRskbjc*HU>\QTe[]EWk{ӳ6E6S|נ=n{<׋K.335|-3G'fU_^Z>x^hFRu\s{E&a,2{eƒxZٛ4X;Ihj/U^=njzﻓ?_p_~!w7^G /ڛ?KeGu%{m~2գ~ojͥ7 +~Jư^HA띰 &uvhVV(aCz݁keL{ HL7EL[Y vk/]vGbf}FX[nT]{vHfHu`mF&auI$6tm1e:4P?i/C~ۗm3L{ 3!'"1~,3Dg3DfP!̲m7tVÿDpĄ̐lSMŇIέjc2/_YB| 0>[oWZ2ӻ-#.e'hdFhJ5^`kk3满˘C~`[ ^ ՝ 9w63#[Lo,^{k.. RN\, ٝm";ͣ!{6"Z]۵xS0^uA݇QD'Sk%caݧ2Czd 71z-3n*~냙|qEB֏ e-{-.7CsɭZP0(;wBrOɼEAYx>AzMGתsV߄C={/~q3Ө! z fFMZnj`Œ`Όh 6n3z +ڜخn+Iٓyv`5="`3 μs/(\z][:%kMXց낟E=Cwj`F0ôF0#LeFÌ33ivfB;pbFMQ̈rfXcfuwmc,zyw]-'jK .g>t#VX7? P/ÓƇARNXd3|A. FHfTI~әg<4̿˙C3CLmTKf?Džf,94ՠZlX`W#r +i"& &(sI`YGCPIGݚ KĦyӤ׶V``m!y5̹cscd ǐafk\LsI#̘n̸Ձ$xfLS1/j-O˰5]ط^oDIO`rmge'1:0&0Um`nG]@;;g|G=c=%뒈_;S3kT] ]e-֚}:tw.Jv%jb;jwM11jv. g?y/7gWs.c'L71rXf²,fZf{13zy6Ìe&YVz0YưJ~57v֕^in|xʕ-6ުnI{*ʣ됚.V56l:\ 9"^$Y9 1Khbm$&7j C|#y 'ɗq8Έb̎c--b63c|kQG]*X-;bJxݗumlTM/W}??Y[?/m隬1́\؂kd ч(fHt8c;5Gnj%Ȍ   Œ^D\P3'ɼ6z Ö6qmpQ'=몯4mr .\gw v|s??>kNQ׷ A5n&{-9}XOfG1c}y2F_<.gyFaK×1C\cD;'䱖v03W2SrgF-m9^ +g/OW_njxaæ/w_Z-꛿)>6 _ä/_}m̵ܰ!6cm4;Y"pf1#H<?;Ōw gOV1cG/ea7<2#/ 93M`0Ru q^ɜ|hư+Êw(kC7?ܻ5Ot^ji%iώnl.~yVN(?9=3C9́ #|ؙNgc8҆-=`#$&.a6ՀŷftN&|`p !EgCӵ?ܘd&sɑkAzx o~ooi{g#7i{,}"3g3r fT?fW23f&F52ON|,}wfYәUܲWz^#yϺgQmg W<0,Y~`^ ^~ KAV3df֌絏Ew)%OCw̟U\0rKc:f냆|x+3x3d"U0ӸJf{e}%=1[qǰoqc0F --i@m?\y0'~1~{.t[]槓&?6U/#d& _Cs?'_gh?yN AZ{9a=3ͮaF91SC'8fg63]ULNcf,a:i̤I̴235Zzœk+c]CCPkC(ӯQ_jxR/Y쏿=7H{:wi~ 7 JAu>~(=y/}uom돶E׃Y :oo^ޭo}3ƌuKcTm$ @q̈s9^ W,qm X' *͟s?a~/[Y7ՠѠՠ!UY+Cw'#-6_5o"cPiCؗ[>ڒkgGk&6Ͻ*<3jŴNdF qa&LWJc亞 +Mfkrw&4N9 'zK(=`;I\i\ۅAS׵[B}R+&TjRl"ixb[uqby^/3َ!u1S|EnW}Q|uNUB~E*SŚ4sEQSN 'ғc|T&0,Ty˸Ilٰ\37҅ҵgqnf{=kw~ٯ+?7\jeÎČi3YfȭBw ~?A?R*I]? >9=z1fR͂N<^|ogӖOmxVq a_e Kί(MP~7ї"AѿpSLXǙPNNj/?_xM +jOl$ 3̙hn]1MH\:2 F[v0a_ z,h} ͸'y^&<>Hߴw OJu7Ij~n~ϢWm<^g2ۢvep{5y\A|KJyCcR7[~ ];c9dfwf_$p|gH} +kto +o 8Ef>! R0bkcR*epfѸ<&g_z'&5v\Þ ' +GwAGᡮ8ʆؘ3"Wfpߊ-R՞z7?Yŧr3Hl>u93-qk4rx1tˆe^WM,=<+ue݃{v:(St=pV|Hd.s(m>T(8 )$x0K1*_TJF 5fBI-Qę\vyܞ≗2WnqN筗ܽ7o rm7tW@_lH-;s݅a+L-A6 uY +ƭjDJ7-R]6A nVUZ۰e + ` +z0\,^!ʎ+4TVoAoGr-7qNM(V~Nzsqz0W/`^魚CƖtPo9;N ~z:_WfVՐNYaO0K(`ios[_ggԭV.aPhT49;Wc,2 \ƄhM" R %nʷi1gpTqR{rj; V`_-{Oնs\z{6>Kȳr;/TߞjG s6>^b|R@]*}s? ŝ1^>4gk^-9+q[d +MBSrmCJ:DžLFoq$zJѝ-:/=tc6u:֚Wݕgu1ܺc#cNʎcyyPY]o0$eA O+wSmB>\e޶lΎAlFi:!2~t|Ɵ;>/zeTk:?G}|,{&ȇ}pM GHMBvo㪺Gcq>:DU\ +wtE|E+BZ-Wk푋p;ʘoNyVyia|dA' ^sƪ\36$Tɯ6v[FLf9Gٽ߸aJF`f[,%k>+w;o]w{?rW;_Q(:T,^/Kv9 {'?vJfbӄu'sߺ g՝/~}7sE-CU탔GG+OTd4& +>_aĦoSiu[Ȍ3Dꦙv+EK?+#NkBuqk"xr'T؂KYk+'[gX{_wvs=xy>l7|Rj9bS/ôǞu䚮Jbq`r)N#A]e#cUeyV?)5 zOMjla\ѱ+U1#yBǰ k$h+Qб<{'zsq{_'>E(n)f37 s6ٳIU~oAЁ77J++utho7˭P#eH }?=\ŧk,.)OCCq^hfڐqTH_dT199Aɦ\dZfƒYFZc+$YB+ KmzՌɶM JZ7A\EH>NpBf9~]wzTskc~rfzФ#cM]NG,a$OU̠v{+k/8S[{zy1d;ț PERWaxblK_ϼHL\ĕsPǕZ(Xc/OtU0 +pc)FQ}B  F [z&rq\JPIQn,doNNo-:~'Jփ򶏼 +>V> t7B-=o]?y1?UޏM̷jOduv[n&W{tWxvYo)\b̝8n?q7YܘSESKOW]撊}Ouok`b^'e8XC|V8'/k5;; G^^FKUwq[wsKPG+#͔r/a 4mUvaf,ZOF$ڪt=5n-8tX=Y4 wM@)MC6b;?n|GŜ!y/fў4il99|~tnP _}dz˸c +ǾUr~r窎;ҧ(UƪlS.* 2IV`C_XsX}r|$%㓫m"K../ؑba'vㅴĿ`ݩ;:ۉ凫c>+np2zѿ&\2\g7uAujS{z/7+\ +3i(Ɣrs _5<($t?fɴ.ULgpc6ԖIk\KUt)4()%"ÌjjN\W}F`mtVl aβЯ+\ |!|\eB}Wqs_J&'w=q>UvSq{AsIUW +Ǯb^'y(p| +{]>=Rwܟhe4qo/7_wf SWfnȸpf<3֗ZM~أGSG2JMta^\ͥrFY))J.7)֟o"z7˥BNT~d6F{1wIh0!`&Kw ,A|bXjEy;?D5נ*\sI'?5YhTjE3Pb%|Q]}޷ldzRՑ `S ttc !~[/ÚK"@<ϼ >{޸ ? +Ospn1+u56k@gKCp-D8x`Gdśp96v\o6.%:ȓ)u}{,ؔRihr-K4SUx 4;AL Mm9`I],m+ԭW窻,!ql|{j뎇;o7/ro|Z+S5Bd: _?g,sYΰ5B7+Ľ/wgOcӷ!\`|ʍ71FkSMGˇ¢+Wfܶ._Y đ2V(9B(!q"BަRF{!o`GvBZ9ĚO.I ..tC6XjG+ƍ~ +Ts*@꜖.>tyƐ^ З'ZG:5j0vBB5';z7] AxR'py;/ƜLLJTy ەba'Z54=ca`hp *|1 s6/v(2]2/?Hft3t(p>TiJ71ƈ\ tCSL)?{egU{\{t*e?:|a6.ObNO =Y؇(XK' +ګt/? +}yr`hї=vG3XR;>sQw}xjuy_w7%dƇ`:Ѹ\f=b]2,ONf8#g=r7JN-+ +%`Y >ۺЇ,Vj<3 \:0KscoU?-ʏ9a/ԒYbz mr=,juX)ܚ*0 gXenFgJ 8Tctȁ%DPiHH%2⼠ +\}p"xu$2vE^g!XlףeZSm8yt9>e5c…6Lb%1cBo$(DQ}CĂa|zu?ep<ՐVGͳƔQ%P)3|XH2X.jM,syX'Sʱ$G0b#rͅBtnK9EXMCHݾDqo WlʼthvBO{>elKs1GٖΈkѧW!$&BF;G +)uVn 7r],X"2Ժ$R{+I.MrHM VF`r? ~)|x6֘Y셚m7ߘ;@x&uL²_g^"5xU'Ӹ}ܖܪT3,5Q1Tb^酖#LŤzľReF5SS\*l=4M\fCaIfWLmݑrAJI4Nlt\wh*ڔ놾vcuT7hp05Gkgy(`C#` +MB|f )jl0/R:˜j u8 +k*lU!$?!_z4g4 ][DfJ[FBjIV:$F@oKX4j;h+O<)s6)w)n:7v)# ۮ,w~zPE dJS=4eض }?z9n#nғ'b˭Ac.*˜õ0QHqg\&cNxf 33u uKgTi7z@ gWGA[H3M)lEsupnEjl0#W@l^^,`wE c=t4qZF-MщyRRfFJۯ.ѵ]Z!8v-D&nPl/``kml ttō#e;@@WslX|Յ}To5lX)91Vg*tŽ}~4w?u,Ę +K1В#OE\it~%rM⠣1ZD➯)7b~pc7| ~2ٌ'zk^^,X]V0G<د$;T]'}iW`qcM EM_W WJ(ō6`:O1 +9]`>#3&#t gr̡GbFp-rD'綏;PB3 bt|ؼ'Xob/A@^~КvZv?X +N(Du<$=[Gj%y;!R3{9iO:oiU'hx-fx|:XwRA'{UdM7~rWJaן=ΗˤqeП"R` z#?TeZ7Ԁ]WHA6 S$4cݩhco5C[B]Y5y-Ķ˵wOC( 5kmq&m%yّJvYȣxM$0E[|utC@lujnx .>ˮ 7}q3x]_MMW\a<\ h|Bc#ӂ`eq=Kcn$,=_iv:-,nԔOzGkm0[j/:'lz]Y8zu'f{_)?FS|` ո<0E4x| +!lK-%CqCG[}j_V4 +C h^Ae${ԍv`\m]Cm^;iG89X M6Ӧ -wsgqğmLuG̷X7~:[81ApT&Ov?v՝~|U3Wg9mBsĵX׃>w^/AJ"yhzs[!* qf%V +ߩAL6\G rS,:ziz~v<YJ-Жe8V5[Xf) eʆeKi[lMDFEpCgFA4VqR--,3.8vPHB-4U4TҟrRt]dzu .eq?@JYT+jۤ@jS.m(a{hgi?Z)|1*1ޘ%yF OkJ:F;IхRd^Zﯔ;^xBbofx 1X|Y~\]Bۓ$Q<qG;{*ĺÓ!tbi–KL3X&y9⺮cV9^1tp2Vk#hGܫ͡Djj'vs͞gT;\?jEbڭ#咸vWn"ypJcQG>+8D +7kY\ {x$5Ԋ~\jS3M[.̣,nl8Gpbe5 ׮$7_Y Žg"{)#^Gr2+9MZo/Yh>st0kXgS}l5yVYM⾇~X2g +dNA/ qHivPhgQ^Yy};Gi;KOВxF9ZRݮTC1w=t,uś_HUSjE|~/}}~հo1jfݺ 7}Cw uSq?;w +pg1 #5ݣLsIsHi㡛ȅ)#:j[ ʹG䘫#J;1:kQ-ڢm^6uǧ]OVBj@[: +?YjIk +5"DE PeεdYh"Q}ᣡM k9T\[iEhP>}z;Z?0E鬋f隚Sf[yha]OZ)XR;'ͤnI)Za*[ Dž'R-'3iC;kr=oxI{skW,%6/^,=CL_昻`k!ՕlEr6 #>p(b݇jogl׃G-9mه\c兺h g[ud{Oyw +pd mﺴqYV!16h#ňD3M">Y DhѵsmL~c)]5̓EШ;ny }T`sS}umcn-T#;FJɷnl- +jG{'~hA^qZr-5EVT,&45yۆ?+|\H Z i}p IM TrZf,ckН"HuTU@ϓe|XAq0}KJe*sI-#g5P?v=uw?Y`eYvVjgi8MfCݡ{ܦ u N-ִ<[-z$AW@ɛ9$?qPlDyCho4t- sh-%5}4,y{V]RgLs-I6Rvc r0ԲYκLY >ZI|TAUtS,/As+Uu][?RuǦART`bX7;OؙTlws;4;9Kma0b ^c +-K-\X_ܡ%X@|說{j׶9՝N!v95+:\ iG#vL:{?O R9J[Էr0Mű닰&) oo8h Ả~dHhV>ƫ^Pv-@e dlʍ$n >ձA^T(kOk#f$v4ih=֋wVH Jfpj5 _yC_jMM;Kl0mk[F g#g.DFe$3[C+MS'<-U>FԶTc][۩};Gh-}Ŗ.JhB׬j{&=6\{yob;.o.;s֜AMfS:٤#FXA!7|g"mAKrWu^7)Z3\\n֯6HNM5v;BwK$gc &Q1KyX d53Z4U]Nз%IT{vys ,֢83hmzj6|8S`*Ř Nl +eCTHQ^hRm 5mLn{VTkSeCZWoM{sK:N|0vOM*ik/3b9&B K1d4¾@ݑGG +bك5;}rRig˴U&RMshޒ欵G&c!|xh`w?uZ>L{ʬhL94~&lS7ו9{BĿ-q:y&TS*ڰe" y2źCDe. DC>{&y @;X"n4sK\$|{= beg#gRC{/}4a +u57Tzo:4u/b,_L4Þ CH YcVj"n +M QM|}HNa5.p9s^=ghjN*A"gԤRM,#*z&j~㓥A!XjcI+pI ~)7}<GT?Z[І:u6\@dk8:խf{.'RP};/ZOSCr *!n<6|wW ܫZ_vt $7០yw)~9N&2z[GXzsQG}Js'r8.<ˌխ1A-*ЄsI4D&VknAm:5[lLt|sڈ[EbY.GS?_O졨mTĵ__ĵ\m^T1.b|jx=$kWJe +5&TSaƽ7Mi5ځrIQm#:hA^k}i Rs h&wqݑ'~DlVJȶ ir4%GNȳ"7|zZgK[턽W_:37Hގ9|F{i+)Rv`h:S=aW,hZ>йmN@D}+LH9.՟G>%>\A+di2ȵ+!vFEAR?qDN(~<_@ރ'~(΃u^)ɉϦ0}tB&ɷ\u'@>]z{IЮܦa㉩t? ~A/#k +jERTnXj{g'aa>Q$3脫z\~UUD!:!؍N|`b-t^ix?x?x?x?x??#!behjm3g^0*tMjdMn)+cScBSWb?q$ЬȔY ';.v3{V0yɎSg͘8S8M?;*Rbc/qO]L6̞=w\9v5yَ,1gޜَqu_'_&qYe#$,t4Qlf9E$^ +ϘE\Iׅ:c@ߒb,) z 1RaF":c'f[j6 V+. mf==u]E)PzQAduVa+n o(e5 E}t & JI֔uNi55A@byS9|p /E "(H +5SjЖJ(1_@e9ě|prMAXϠDW!ܒd2@V\eXjP/} :5' +/,s9q_f͊PgҧbJhDtSAd*DekWY 5i `s5 Ӝ%K&^c]F=ȌdUm2, smNpr}Gh@(:RBMYg]A08q>9Fi\oZ1Yk Z A`!<!c -ŔktRDZbʷt#mͬ-UkA]8S12 M&U;>Cy_`%&[@h^V`Wj uī͟,[n.ATKK:2hq*gtޖwE*%Y.2;]qh):/"A+7ډg&!ŗX)HcOW_#=@.T%'r,TSLthG*+16/:a3Z*)5]=35b7u54)E6sx/J˜ѮQnx]Yx5mq[vuaeG_lj~ɅrQHtN犮t#y0A+12]jr~M~ ¯XѩC|d +1: ]n B|=-zLaez3Ve Cљ}`?lj>2]~ + #s!D[|61>$ ][莢M%;q~e֚ځ څ&D?^ 3֠c&ؒ I6PI #ٖ#hRJ72*γ@7r:`[r,O2pyI+E䰌zݧ/3vIqn֛Vt#hBڪښcU'2@h-5}ЕY?Hf9a @a&tM@ע:bQHQ.90Б9>v6]N,t p{nS1]E֚BbwT-V*bx]^:g \BwTn r*{0G7r;!<.a01צW#bQ4AG |,Pa䩬J;]1ڒvGtF2_1/AD +Jr> +ߓ@&vZ,F;aN>2 dЧ' :>vS sK3#\ b_ASJmFE+Dn''Ag!bvߥp +VndLA K,'O]rMH U^lEo'ufҹEjF:ȿ k}Ph& +מB;l֡ҺJ ם:[ +~:D8XtLtkWk :AC(OƓ2k_d>jsח_#2K <\!>5s@i%GA7lt IY\2?(1BrB:O)> +RRGI㕶GR1y?:Ca3"D||ڵLrHv@%ȍ'MUjꩯ;)f ,GA;G'B@\>9Rl%Wg,2 J5}4t)d b @AW*F@ՖsmSAgn"\ۦ!&`l 1EjJDeW"VdSv +T$+'U )XE/V۫AitV*/l:6 . ?o(W/}8j1P(zAFj w ǃo$͡*&u@k+m֡'#'dz⿣r eGZ?ZRoP z_BRڟ;&ۂD2܎{@NI}@Y#|jPސ[`| [`C,@nђq=Y_d_iAl7]$oqGK){JT%_$5/SryJ"F[ŮPќ;21w| h);" RgF985HEtS: ,Lk=}N'&ʎ*+Ő$!̃,sc(j>5댮u%Kj>kI ݄`q*)!A]'@~q&> 1S0ARdR +\T)lJ~\L9h H]KK3ڄPjŇ*QkLB11Snlp 荔Kt)&/hzT bR㖒1BV<K+8yw{_v_=m_.a̓ Ik6aeg)ΎH1rr5& Bj#Ag )ZiSS5 R@6ǜIdӺ [U?)(PRef kÎ: `gO͔)5^tw}-~NT5%Ȯ):`Ȼ;JB#χĺPr-*C5Aفm2MrPRH^ UJbM-'$[b6%sAz?I\c0lHg(Οt3(&JQRl%D| +?@9#2 HdmLRPU}9RWFfp#J$Wۍ55:(&T>lsC6d)cb{48_f< GFAb(hWB|q%Ը/^Gߨn9CQuB +PbM41bA>t䭰GNiIړhhߠz6 ]CrCAuvRh[A[c4Xjs6 e7|ˉob)U=X?뙔P2FSgy| w~W+cR9ʱֈPb@m(C!&/¶OQ*Ե +Gm9ºS-7J;_TK+$qu$RJq 'ݎ4?&S f de.zU u?ǯ|COѹIXzk IHJww`JtwH}ys}}{79x1d)x<\JNӾOփڞ*~`A/g* +RvJ^~Qd5zW.-i}g*yK&*>GVR5{ؚLpviXv~Dփt:A6zxВ\7cgF_ĸ bu簔E n600`a$U_>1b H?XA\/rZ-:6: +%ɬ"g#6 +:iy $bdBaXFҟ|8pBl%\ۑK 7MT _l7ȴMvcn72pt SoIAG琛uu`?AU ' +y9Fs57Qly`oVC|}p,7{C|эe;x-SӸp>5wWyeHFnnÚvLb@ultI\9rySb2@ eh+AZ|sonjE" E>:y%5M(9'P %/S`G@)s5:wJtH.÷V +0g*”O{yd_T%N=j,A[bXEcB̃@WEЉ׀"QЛ-o\  +SmI\|_||{ԍ 8*`!ntkxa;$-؇)疋;-2vfJę85e +uqz~Avj c g~cqssgIyc{_L| :UA<Ix={Y%q 'ס+#!|xPlA +} qJa\quy4a[HƔU92Yc!5`r1ۓaN B/jا,0"0W2=%l@ B|jNi>q`bڐ8FUۤCis_ +ǠUP!#1~\q731U{ D\,9(J:O ؆N~;[LG~uqBˠ[N 2VW{@Voφ +}[wW@ye:!]<:19DEGIנ_ d S[R廽n 1ǶKm;E^!č^S]h95T5XGq E8 ~#sO +kqy:ǭ#1nw2W/C=38`+y0s YΖr6\W~s\b|#Nٍ<)*1YvGpSOq*AHqk +9')lPR06z嫭R;+0#Ŝbi9%ՠBFE7Z .t>f<&«bPr 1^(+fBlB +Ȧ\ ?D dGUs[s,Cбl +a@ĉgnN=WGt)yʁ6yz(B@] +yPmx,FP&N1H q@c*:bzNy?3*d7ܬJD$6KC 495!j` we"#=1>T .i~@&ǫˣ %~ QK<+:rSC.\~3: _@3xu)=6oyĩpqC )P2ΜUġá6SjUjjm:\/5qy46Pdb +" y@a? x#yNʡZ:K߫@=bc>{!n9,;_τx!(q ^ƀ}&`ryS%<gr^6S@  x x\AOsj:%shn`{'^ 5NྚJ|P=smy2g8ll8.X'sLQ aN6P6uQ!uf Ĥ@~ېCY`[~#~8BK  "r ~g9˩AP%;95̟Bȁ"(BSvZ*+_ qi$erL.䄱"Jw3a;;ǝ`G8i qo?t ;^"Kuhy5%ye2Wa0x9ďNC_-=scUA:RA۔y)q7'_rLNST41ǹ|(N*Z:Bra HP:7>O6CQ襑 0vI|&M}{:&*qU{vmN /k-jA\- n7@lM 'kJmJ +p㑫 '>xr =\$/[땳C4,g(0w!^6E ßo4D)M0*Reiz9_Wq Q@@e]r #cߐK jti<2_HiTa-yvH =NIAz<οc_&Vr把.#PcKը2_=Sy!w#ek{ˉd@FzrZFy>Zj8ly /DW硬Bgo|=n=&Dwj6]jSfb e@]J9F0#NoEAC"=NQB2הe15@ABS&3@F&(yg@ Bb 5G2Eˤ^Ycb|c +c |a@w܋ō؊4J]^wcmVKݒA̞SОS!ꍌO*vu!ި@eK(9 M1T;8FP.TХGR&EpM1i 6UPr%qP~"i>yw2Vsj8啺b^稅ː8(>p1^|1^S^<&g*Uu7B{@ю ?S.S~ Pp f߇*FM?<X;\NTu +bi1G߫!M=#}Zuѣ +{YO[*@{<ɜ-]ԩ5X:Eb߱'?'..=q!weP({d:$/_N r_s b`sr$.vRѷoǩ, auiXzpquȢ@^d=8 Ģ9Ikϙ\?an'%M +,-BS&AlEZ*M6e&(OI|3s5m 9@g\&p9Q 1B.1 A0d;(ʑ'kd`(Asј-~^o-uM_*iSʒJ ql*v_vMFUѮNc?k }{?zg r s-X[/׋lº{܌NndY)5TmPgp5P蕵 7@ F +8E *aG]F8x סlpFl"j%WC}/ ꍀa&U0]Q8<j F;FU삘 tl;pb_j +=v>|WAQ?{=($䘴xHGDln]FỲ!%"3ԔS W%xd"l#Bs6qqP:ss"đ9IkA \~g5WuP{edRQj +H_9&Pp: Ƽm_yTj0 7vs! 9?aWGsq G ܇ǡ3s'j7$P%c,퐦(- +Cd8g&pxIy'K8s^ +Vp|;k ZuxoBo@EO&g:[YCS8&/!^5wN]Ņ gm/ˇg0WO(#A֨ߓR!咰S&{|8&qCȅO!AQtg*}v31{AU>tn0 `}6)_ qnL@[9lkkA}(P-5.) $EX]Sf{os8Jsvm =^wzY/@bPCoһ15;EfǸZI)Bƃk1s9UY+{` ΍p9gl$VqQO8crW~a,Ԣ@Mh||p- C̘8m;8b9AqOnʶ^1.\N}e|gԥ0~9Al=C ׋TpvP"_S vvuL>*ӂ(y7%2|7YJ`!Vy]o->Gh d dt.fbNbUO$v'U耒m>B +~ u5d:m3qJh/Nnet.纀@0 R!Hu˝UqXbj8P瀚d>YGa;ŴW*"Y-#f6(njDpg-n7uaOwc2A*n}%> Sԙ]ɋ#ҷu$OO;$tr&aeS .ծgjx7nՑ⃉iB)_Q)_.1J2zgľ@][T8Ή=QNѥ鸶7 8;جLhB>"K36$Sб* +9$VsT^4s1ʸYF@+M&-qzOڠ +D\^Gѕ`&UvգCkJ4#!H'jEР_v ?^` +:NI^6Ң{¿+ͬ1f4 JMǝ4_oOLew2җ5'fe5ڣ-LkU*HPk@DW=n1tD!Ѵt\~a乛wSqƏ*gViP~AWj=]n>[ w | (TВbEXg(Nֆ}r̟fQi)[ ņu —?R7S*ﻹo -Us; NV^$5VɒkҨ*uilt۞0ߋtl$$Ƕi=_hXj;Tce@pJM y:v}߈jcEQNv;I h1ɝ*̝v>󰍦xD7'#2sl]iXY"ͮ9dStA҄Nj!Tk{%1*SCܪZQz;M٭RvBD'h M*`Dlb!gA$~T&R{ 2P]ă='}'_Ƽv!_2o{;1fzIAIzɇ7}a7tDXw7M^|8-ͬѷm7&0w+ί`|D|LBmE&Ll)y#KA}ryWgEY2ɽv4ުD:n&[xԬWPEJh`6/xm'?jS j¨{? XĞqU_-I|=C6>9S}Ezo.wutmˉU(};(>.)i8/lԘf:&i9ɣjU]ӺKtS ˮ9%Ȉ(!CYJ~a2Tb:k!Cz—d5sjKsN 3#~R/esܮ^j7cڎӹSGstqYcdwߍoϦtYYi[Mi{)#DG]"n2e50tz.ڡ&JkɞV-{QvBwQ;E(FS6S7">s .Q32e3tNjtey7{䣏BiPYD5[.:܌% >f,5'\;wɌTaANx?zDYRiAg9WQӵ{?4uoJ0WI}8nP[B>:.+(4.-t>0.xKۛ<ڎ+y 3o ~'T9gMdZ.¤GR|MRZRekRw]\|I}YInyM9$NJSҼss%wx>^Əu ֈ,;"nwu]7E}7%ݍ^TGkAL%% +>~&lp~7z.CU|dOc˼i5TT\V;Ț*ovsvǑބ%-n m Sziv0~t7'D۽͉c"/Fo8њj$S[:LJ6]BW ?)GM{xvmZX1*p}z1(s9E:3^jLJ:$Ƹsj4gI]mv~ t-=bP0XH?< V̭%!IΡgäx +9v/\_+o:&ngzdMaLnr*嫖ɋLj?AU녯Ӳ*WG۟GVZ$7vvVyE~7&'KšG:CCե׌~%Wo1Li觲A.oԈr +H51c̻KVH>yz~r1>xkFi߳@Aϣ~W|IZ?YnJwr>QTt-qjPצDW#>(>iJ޴2(uV؉ +~/ *@o ^ R_Fz%(q3, ZRWV m)Aյ]4fX`SXj}pzm + <ސ^!^7CևyP%gWҗ 'oJ H^6c6S̝f#F k|q9#|sJ[I;=/'% +k~#*~5a5x] S>h|(PwN(s.wW,~qPt!M]r}DM>7󣋴_ܟq}iV-6W  q^IYS iI`8 Ru +~~+3H׽0˖pjЇU6 o- :KZKUׂKt M*s +w +u +}啲"ÀU[рXPLR|ޤ٤۴(H0}@HS7 %OK /KO~LZSU`_`Z,m=AMGS]xW,jjt^Io!a&}EAo~BBck"kcζI:cQM.wlʬ zMٵ"Ev%v.!3BğZDMn뢼SZ qqx]{z{9G8TG{{P=FX=~'2BBPbc+nF gyX}asO5>H8z/ټ3+i(]tOyMuj۠r5ׂ +,lÎtgt;njqBlo׶*(«fxTsHjKȵʐsq!Î7z +|ͺ_K{ͭ"]WfM!4G~uȡaO7_-n'*#C'Pt1 e8>x_탓>>0GgċvyE6fTZ 6]Bl\<ÅnaF?KG:4؅6]``'Q-Qt XeW$ͣg\+u]h*ڸu/Z6*2a;L)i[Qj_J%$0#4"=41%?+:g"D=]G2#0./uNxTqCXkoYOV53B4C|)W6Y#m59M=Z>efߚ&DYѼˑhh*e,bkv~+vq|r֤Cp{lJ^| -w + +uQT->7N;"*x1 _}_}N: ,O+ZwX&Oַ{8SN׍Yߦݥ^\ -U܀Zg.c&qh<kIMG3ihv#$@^Q5XMïi/qk?qoqY&n:^*Ȩn!y. ] Iw }Vd&0)WmʜBC*"/{]gYwdG|o65wJ,mڥV,WDk׭D]oqN~J~BE4MD(4 >GqaHϟWQſ5$Ͻ6. +m,FIO5BW!yay!aDMw Is y:!8;![ǠL79?.y_z-fW]ޝ㕖^kb G+gp*QQ܌0F O`5l +:fMYo;U`1auXuvDzKH~}`{N!TDsi( ( |*\e ؓv1M3( -^lk\E&wZ2K%o6{0>C;FMR4c4nowv8Ә?t$͍>qVhRHbMea7ܻ=~kX;yeyNE#B]m˃Br =89P}?RVw͊q YCyeNX89e,4C~>4l&i&>~!6b4|)(M͚V+;]GߍPc70yvc>!ġ?Lx dSr01!/nl `l[lŜӢ9(T{X#:R4K~en_l`L +Y9wv ̩ QqT~&4sm7y+Mм%x)Jm=P~o,v"V{H-wr\">666&">buT{vIsykO5]^)\4 cOzOnRCVYo+-q2}y:gC?~˖ a1x6l.)L͕|5ulilS ܥ:Ha*RX63FOdok;[ݬZn7I[7 =bciFÚl;klb{l]侮XRv [ߚ7Cc" FW!h6 +P +e4sckfAsCTм<4o>V;xhfћz.ؓs|vf~i6n{.07'<50>;PA鏃Wc/d[:S%>&,5pXey9i-MhZ -[GE󱽜;umAТb\ Ys^/{s=|/T]ZءA#ވ}w3tӭhӞڠ2+ +K">ܤwHn<8<)pcq_>b> ~T@SGO\f/EK1>>z^{o _+O*?cW]vuMP6~gzOQfWeU> ?gD_ Lo +>3>\ l* )$6٨OYc>+MYE4ϡ%Zad_~f1[\ޏp 9#<~{mF+YR1a3vZv]vOL vf-[ +X^+ WTfqcl_Σ ~4wDdW!eѕaKV֥7g`g(`<3|g)j,ߐ .da;{\uRo!s~k7OTMsz=dC۳OX#D۝#".6&Ɲhc`C'F7I2IE06K1㖮c" +usoގ>qW</,+{H'{X+R-cwG-k3"*}ăo מvvVkbM]9$߫}o?aU Oȩnفt4:F"Q +|Il{ ({LI9[$NS5v!;aڔ8 cI+m"8VnO4p/Yal jY %Y}zL8Zu'ye,c2 n[g9нUPaA෱'2P2tRGn#o}Ѣ2MDLHA"-+fZ%zi+&ڴ鍗̛Wқvb8I~:qТպh%~7jnxZoؽZN%sxՠʭO|%}V,;st8¥<{׉zK +YQW+bcx=s6_ Z 7}³>GЁu;D;ŒM63Q>DZI]A2A׬ʁ } Bj3@%}a^K %~w":a۠mukMs28{q^-qs-i MqzCO +ViOY[ caOj/iQoĕiFBDNs}C|*a7}]Y~An,"G^*yrHZYuA|NbRT׫,j HGc5dMҸ>^1 +|J!m1RWcRGj;v(LjRk(!8'EHvfES괍Is Cܤ {𺽌xs"a;Z O phI_g7JYu~*m0}85'">]#g_1U;{Р5}ݢ[Ti2iJb&v+xӴeW4t%<򲜞aˡS'*ţ7m>vA<1Oh2tqݘ,>|r +/nD9pfI֓fWIȈwֱ3i*Še(9)G*n;(l)9(4FRH<7enMF_ l?)؈r+Dg\>ӌ:f91;3\t `(y 2;yTAR.*KRWl:5f/U= +4y]zJׄ3hTpv*z"f#` C6YL;1Y"1EM󅭻%5K  snc._NNb!n8'dQ-cpPhى\/B¸:Y8 yO_cu0ʭ/̃RҲt@w xM{`%u#yVjD=jRo;L. +]s|I1<򄜦4Tx}9&M&m@(n:mi9BP[V[{ +x!Τ,lO"l7߼ӡK#ӻչ~ G8!o# zѯ瀀B7_&Hzm7?i:Ixf p0m@H}3  G˄6w,1UmYm_޸8piZطa|c  +ii𐖎!24;#/ +mhLcC)1 MfUMuGy/o7HUaiK9KtV(ήZ$ԽIH g EIϔ%[Fm~{Y).]kл(oBC6# Et:87ȝ #Me=l74"7}}_!_(CF< +qz?}y$/s,l(ئA]"rm@ Wrgl#p&`W3kz#b=喱tTұ12 jčK__v^GX'N3gAO=ɣi۸{J"V Ÿbuky}"y~,qhI["nɝANWVbg,ͮ<$jr*Έ%3{[hOWD8Fk7g|S*y|[0n֔#@X9BŖ%dd9 YY !–@v ZJ+mK/-eiK){}ʒ#ؒ9Xs=tehχS1~ꛁ-/\?>5o\^>}S_?4^봦W6߂?OGo ]wy]1]~_co`w|>zs~sxB7'зW6/{iU^jMUXk}|{o~b,< 9S/An}&xf}xSd醳+OlxM=7=[v_{׮Z;LJV>M'Ckr 2{К.\+v}#Yyj sogw'Gw:sc|sT< |{ߙ}o3𷏙kB~ן^b\/gZ|v v<k{(g|97C|þ>-wǼso4?xf7?_}B5/6 uӟ8ܑ]'~< 4M~;;YfVωTs[JM@vGRk=-}<Ճ9ێ^}s`Oq{ri^>;x %ég?g_ +>k~Z#r?xpg?ۀ>27 ` +Z^VpƬ@-U]<Бbu/jK<uљX +PM/\CkTǜXW ^7;茼t|٘=n=ioe_E5 )+|fpa""+\u`-yG 8'^F஍؃.. :VOӭ#~eT!svBbXbm&1Z,|#o+F;B<1ys={3X$vR?fq*a3ٵg?})-uzhWa;A k<%(W:eX޼hI͋ל`mk5U͸yVU*ےq c`zX 7W:5'\57saN@<{" Q篢\*~k"[Ol{zʕk"˟۾ɎDgS> +??t>+Jb}Cc6 /eߡymZiU7^Ts:Ѿy׆3qKfl܉s@nUږw=?Nw:º%C?|%'___.|tSɿ=>ƿ7߾7mS>}&dywcP mz*gѮ-H=Wc@Cgk@f?=ns#or ;;pIkOX +}~%Vt%X tYy/#[^6MˑܕQΨ%cC|w7c}TwG+i{h3yΔVs,^GJh]cl &Ƅ:V{Hh KE5}]DyvǝR/=uya"SΏy!V~Ⱡ#in_yRw9Ε'‹)OQs~-] v-71goo`N{?Io_G)7x\ͻ"^ "?cC,[tBp飰?$~+:m1X_^T͸enUSqfZw[#ҠCFT9>srci_mq@q>(1oSĖW>E0[7P O_xD5'|33p'оV07 +sXsIf7U\:eV=}iX3Hy1^%jE -pv( ki͞.>F e:{zɱ`^.YJfNqb&ٔ}B~x9~LXc5@`w؋rr֬nkzW4KudǪ|c17ά:#ܽTwy~y仓q,оn_OS+0yql+@˃o܀{Wc/|8Yg6/HHu7=secБ<94Ŵ饫CM9 J[x7Fv~(c8s4Mzϳ)ț={/ +9p1~揷FiVˁ?Էm}poZLJ;x92H/]-7;xӡ}}ozGS쑷Ŏ|z`tofRŚo`W5)z/s"G|f'xѫ(݋_6׉ط>o Mʅ+Lqkg?5m;TwF,ԣ]'1o"-]ֲl71O^`qb^|b9G&ǞtfTMg_E-[bXv*q,rq9:)g>J={UZ.ClywDtϧR.n)99Hgݙ[K~[6z|k][-v/躗_uYDzo^4Dc.Ofؖ܀os81@|L y`_|Hs1%$k z9-z1:!>$džw;rp>=eߧ[|4sbgw? pϾ1wp`7v n5~ 6C[ߜaG{.lz?;~ >{Ib9< ݻRa};BuOfϸj MaCcԛk^f#3Eu׶sV +ߩArթbugE>9V1/7uYѣ6aБ?||mKNڲ ͡c1wKfÙ-uc)`Iai ʩ#k@,t6:36kPmMgRuɶoܙ^s&T>pj#wt~9k;VeyUZ.@{R=l~1+獭>!أvTghvVsK;Ίjg5uhּz?JZT+jTcm + Oyi_Y7=ǰƛB]c,-Qyμyef[_㵱$b _X\+n oJ#r 8o:'+:X11k']rs/$Djt{hͲc_̥YFvwc>y mY ^;+xzs7WcC-p'ۺa|EȯΥxO$,rщX szS'~$R.n4kl>յqQ쁣#~1֣b4gYU37IjОPYyq^9k1v}^A5>/^{֎eVz R5,=t }(ֵ4vX;Nˢ;~(_51({O]+\D5Wnu,[=v)oY5t?=gii9x)FeWm>״3#fw?4]-束^|= khy×7w.; }͋>9йcݬycwi:jtUds#+\ }/x瘦hɉTgYT}sbke^޼.xX>{ 9o\U?6 4YWĆyhc,O-t<%hHNJSPFc-nOfEuO]3Yq*Th~2[E5>ȁb+G~&QͶ{.>LA_)/y {?:)ɵRkNǸoڿk]},[D{&FF}rRYF{99rxW^2fVZ`ߙ:KF}Iv1gmYeT.# Hۊo]ۣ۸J̹M5Px'j˾Եn~cgL`s9o GkbmB56ޱKGqנo}X;c,^{w]غ +G&u>Fccs'L~K +)T;knu\.\TvV OYY-Yv֒!-c΋>s)`-a}k+P{;"E'c. To{z55@/?u hZ{:'K50?eNϧbC'`|yFvBW)x UMkW/{x#> ;o'/ ouXksϙ\5gvsۡR;/m}a"%ʓA-Yja?Lu0زZ}IvVjg}zs=^wFcMO1jg kP}Lm&v#~O>e7`h30V 8MZs@1൸wD^. QGX ܇wOVљ;\dcr;S ԽT~{=- .Ώ4 m: -^y/>N1 UѴ`LZ6mG.'(~}gs)2U,3q/dNh-ӈ1?.X꽗 E'mR~ɑeaAˊ/`k\N=$b۾=9 +*AVSxZ*CQOP(Xt kb Fg,f0kԡz-&*x. + |{2&֖YE{5u+gп܆uCΉM$ 5cGz6g8'=T>vVˋ6?X;++ 9x v +AփN/κOybhO# +{~˚ݗ rk>|{BdZLzW ?Bum%k>~[N pZof|xS롷zvX=ŶmYԅq^}? ^D?HT l,5~Ȟ_y)'54ū/; }>=/?eXz׍TK.{Fכ-UXXQU} B/vߥXs#+3?zUէEZ{aTx)Ԇ['67EjԬ}"uP 'jgv'ݗDv͢>޼c'5Z|ݬavֆ}W`m0~H5c=wː:^6͚cjx׏Hg!ն 6;k4l}@?p +{7|YW?:?ÿ{heQlKa.&`[s)M^C6Ox|EcSS {{Vy9 +4*رdԏKDؓ'-c'+z/QMmzORĚ#XSs[}Q8>ɡߺ}GOu"Q3׮(t֋5묡o%gVT}߾. Xe~߄[::rM˃ߪAFZ2]G}z;oo8:\yjhAv\to`\O?kywskh*A՝~ MysXt>Y6 QD=y1 +==>&.7ӳ Ӟ+סG]*|9E-Йߙ:h]c~T}dަr- BA=}h+C£>zhs8n= =mX0~g~}cx\ *{wΟ$W=r>/KzO@i(Sl:8^c`"3c2uBw5j5W>qTAl,رĹ6Z3e37˓Їg3FϤXGcktJ蟉n69)o`LDkiXGu>Z{NGeXa- Φs0X x[57>{(TQS-LE؆=UoQ}9SQE]*^5OY=Z\=A_#myebxX|º?y/c?Lg;ƴ{.s@G`/t=aHwl>rm斞ЖUs`MG`y?#o {ޓ>vI Ec a/ǿg2O5?{1Þ#L%?YPjթX3ԵNpCr WFuO|kF6mς }zI7/Xo*ڽP3KYdK6i4UW ڻHwԓ5 <N8xkL͢]$ZX{0L7Lܗr_}/ܗr_}/ܗr_}/ܗr_}/ܗr_}0aF}z<V=al7{rl esӓmd&.LAPhntDi['yz&N2~.eܔ<N=!LkڥS_u2EDt!彼̉6p +k`~V' ;UIPoPޞ?mu^&ݘMstgMM^u/@53BN6?M2 G~b/JV67AB|e}h[LgiLYnmLo^Y63ٟN5>I3ݒxWkA]FFuiV)vraG'g21Yl-t~uYc0\sqys Æ2}ᖋf8%B6ӛr>>/̵ ,zd*\v 9{r%%`fo2+ˈNq[I&Mۜ}Z ;zSpS<33 `SF< $Ng$ӝsY9V Ӄz;6Lo-1+^lsV Xtugz2N0yz35\" 蚀 蚀t,+tƬL #e= ڀe&]еG QmbI"[o,'d5ܨ1Qg QHۨ5-<,m)W'>=$` ;r R^! aV'Oc9*؎ٮ>sDKeeV]e::zWF°} +.lˤ2)Kjw)a=q =َx[BuU^#WH|\zm sy;6mT<[Ii6#R;N Ka%Y*`)V8ʊ0=Rp)ogGX*܎>.Hc&՗8>ʄO_QyڞLŝqWY: +#R)g̴v/̤21[\VAmȴQLG\6 Vh -ɸ2_u*fŗV,J -a&}8*d\C+/ׁcntsEиSJJٙ*9k P6W3#s*Q88JQcTfL-Ӊ/J*l8ǬO%daێ'{SDW"﮼=y +>yN+}rX)wU)"+]9EMsLT9i+1AcJH69P./L'#mqujk0Dz(?yLgKZum2wL9ˎly`+]NWa3ef絍UKRfJr_%nLŅ8OVyq3Lh q.G*eoheΔ\e83TQ8#7p qgJAeFqL bE8S8SNb(?gF]s*E# )a*K!#44w2*7GȎaԤ6u:i-Ϳ4ʂX dI8O7JKq%=+7,#7Wی,\mTΩ+\J7nJ7WmI7QkiL9FV)JXDy9F]D"?xDǡM%D7Z J֘\H5[K{sd=ёLZ@9՝禗~b5tc9w9;8 lI:DkANe+Fdn⨹eA*޶xGem)%{rSr3]JJYT%!U)kj&2b-4*فwZq5v=kn4C}Ch]&M۝} kvԖ.,!GCJq_@p0lؑt ӛ툷%JFp)pl\PyaXZHvpd^?+9NBH\Îft\TIR#K9;Nkr^+OsW{(au+Epl4(*l8b9cYw&VCW{r=qS|R\it(!4<*ثxS\>stream +؎ +'خR4XO t(xVM*԰n+/̅h]V_xyPn[7b~j<ӼFS8 +@STΎ:'$AxW$YH!EjdLG=fHXf(΍ +AQ?*ོ<#Jԏ> qrY𬗗U]Hc<BՊ'bݾ/n7BX00gdMp" HaZCZY[)-$46F"g.&1+HFAHN&ܔmh]fF0jٴK%`&$(sBn$e)$Y‌ɵL*i|Mk63W欎zkV .0 9+brtkf Xmzu׏$M$ ðSZ<'?{p{~5ͣ)k~޴F(aXT޸'}+a7F{C=Mw6n +Gc9*[ ϳа ߀ADAXK"nq9|hBG#f8ԇuڀ*rl + +G~&!4ftz]Fә'P$'=zj;Q1PQID8),, +# 5mmw]y][[} h]I?d5F<(,*|7x0UmcM_uN3"vֱ!p%3 \ e?WpbB`M~]0,fgO<ta>ؑ>겉dS϶;>ůI$L`Aiʩdr";ڒ<47EW2ٙ;{q:k$lMnM=F/X(6py˰AwVŋo> )klmj~J>o42m]7I#5YGzDDg{;jMnC9ޯʞLx.13HYUeAF8ls^)E.adQYXʉ`A? ʕAhrvrej$m&A7&:EU`Br s3a+xe+@1#=ʲJƛW¡ hԿ>&p]*ӎF8ص"X:id$ . .ht, M=u2lr0%C*C2}T"$ :ywHE(e3|GW'QPA_( +: +;(3퀷O>iXr a 1A\*H>MHE)B)Ei y]Y]YMyX+c5.X1VEp4m1dFcYqW IZcF֣Ov̘q`>(Yo""q c#>e; +}JBŮ3~Oq=v,?z9^d^pU'N<͵NJc5d +;ÎYW.D<۱- +Ǐ%'UYB?+E(k43:nYh2")hX+J7CX, vh_`jOY}kq1zu`iР;Ɇmc7jtS˃*Ņ:הyynH$ܟZ4yqp ݰj|f3K<] f 'MqDnr*E*ԛ+H\L\Uct!+phmA$/f s ٕq;U#jvc g@ ^ }E9x"n2#$+vZ[[oWS&g>j -=erMLćƖdE+W%t!*#ig#2hS˶g$ZV[aTպuvd %SO8A1gUCh^~0M5-6)::|$Y mt8}U=v]uJ1 FJ&N}i̵3Gh1RR%Eq!s 5~ioZJs:e(,C +imqiWb$on~Vu.m'}%GWux)!fs-VV(%Y;mL^ Ķ)}7k'gWV cYMLxeIh1 +-tS|_u"Sӯ|$B.Cl2,)230J< *# +2+>󢢈--2rx 23Um,xVjސ:)T& 6DbG,cȮƠJ$3"VbcY#܁LQXD | aA?P{ٰjA,i3$AT/'qtdmPv ,f +>'Q16 +0NʊɲD2`q` +'R/'yaY 'bH!ipsQŪ<#Pf({"KTYTKؿTNYzFdYV0`]aU|.CRAaU@|B& +/3aWdQdEXEqkK' rP}x/s  AJ%ƈ ݁ʎojrAnz!Ᵽ"X Vd䪜Ym9ZA4yng0cdzq][࡛h8󠰊S/=i+ fmi%IJp5tRDZ0ӑAvb[\8 4\| +HN>+{? s[__bT +(n3L5BKKR=3{WXAai|&T5qN/IdsP5ӓ=tץݠYZ;}n ?`*QsCTl^x]/bZ7o' +,|J@Ӳmռ(޼(зl@KҞB׹,uMh *Ux8u/0SgQ8O;tMhIKeO324mgZo.DSrE²1 =D{+E=6a=]?]Yx&ǘ +~2T^"L+o.{z6h(yF&)vtU/un``<ꝛe6Hm3lc6P.= QӐ`DF Pj'W}5:ebk)zUXm&Ȣ D(T0oo#9LLd̖zvAJqY {`n!r6~m +`&R]'Xmhe6AZ[ tZ2eQH7AL\.mu +](d@ t E\q.cQPx,:Fי>LI"Dk}w4}dm l>:cD %3I1;<>L`iiT}s`_ǪO}"P'W'w>Vex=`:?b! +Y:cbE_@K8ƅG0! ,8u~Ct(1Ũ?`ƒ;lYxXB Z.rt|9(tYN>bSpvP9:>>c M*8:vJ~DfvB~LfvB|Tf)v:~\VHT;K?HS;!K?LtP;!K?PR;%K?T+O/qWzԳԇotWƳɁ2I ^jJi9<8n". &Ԟa*F{*Os':XSIoܵ 6bytÕ*02lCL1`7 ++UN7*Tc|_x` jA (gPѡq.VESdE] 0FfU5mU߲#1+@t,5w豢4]Zfy#g~]Q+^| L +mƬ"}#E' +%5%Ղ4>՛ҾX]w]Wmܮ68D;UK׉V5AkH@"9N$*R;S1'8sXPkU b0&cO0ۦшȚ,Mp(u@mKH;(,k<`)Kw`Mvwg6WZjkkΌ)3X`ą}m9v*)j-ZtP1+by޽:{^JkwU}䄹j̵w%>u6a)56gcZ+4qXb +79{?y7Z-?*8 #-:*,Ol +&Ibn6c/u_GAS91A9լϊˈ~zy%Yfn!HlAMA<SװWA_vjRgh[D˨zU5+]R0גݥ8jH,Ǝ +'H\5vJi5gVgbE// Vu8}bFcu:fWQ b_͋~lְ*x,U\ ,RT(żk@y:ބpvR_L{ZмFeBhGesZmm賾.$75yߍ>X̚7╈Կ!cCw#^5 5xHqE5> "',n}P}zZ֙jO}W(=735JKL4,q7^P BZTY +"mTG`%U0;1ƍڪM/s @aY>y1Z[=33-mK%ZIzfFT:\EL +G3;ASq(yp jw iC+**x-L?c%eb.%bṕN[`(peINa,B~Lc\<.貔hGH]j(`XLo &T]UR/W$,oS$k + VTqk01 p%G6]~yH +8"bw#'kENUEe4K#_"m[8z9 (1QJ,lr)١D$c-EÞ.Zˊ|b8}0d˰0 +T7h:Da&1YXXch@&py[b#N&F*[1* S$3 U=H=a"Z?}"/xP=\8hWcw\ O0b-IVLQOgV|nna@8/X*ND, 8VOjt1yRE͞XZ|6"eS(io4 ޢJggע@I="}^A,IπSMqoZ  +AJI2! 5@t*4"8Β5e9ޜ +;j< .I), +`Z.ӊGt kZZAE\ +"eX{ZF26xCҳTlU Ĝ,,z~o-Rg4 Uh5#VW8:Uщ@UpUF0+P˕Wab|BԜȎjqaxdZ/u jEOp0͗Z&vyq*B4 0Y06C.QȳH(`LndZ)GT;``yj=o68RoHZUGASE [OAD4&u`M*4`!OFʴ 䱺cVw=!wAӿjO +Ɠ hwR KĉBU,_0t>LX`JWnVm|afcsبNKr< |FS^0 Lu1Zp)R8 + B̞PIo\ׅR[VT҂0ZSV>O0!: T +E cY[d hW1z2ve ᲂ^mQ}1ZE_"uȺ3^ĒmXmD]P;BN>Dcكa@Q],*ϘMP1:4w4C2C613@E[FwFc}`nWpi=@d,;x&_oܔ0) +.#WNSd5:D-?q mJǭ_h_a2KNMuoNBMl_m.9- + +7`;n34etfI_!h^>a SY D^DY(,NOP6՝KL7! F@J㮮BM;pѭ}!<-dl!]1#Dagޜ2.%]PpYPeU2!ZPA'CWA4~RAg*X#ȂiV-Q И"RC5k5WB={ߔ !VBe%vQ_M9,7-vdz{Zxڄf"sp A*ytT f(+ejةɬ'4 <<ȯ=\A6qKFVEC &YD9Hgi]X_/5/~7<m<*ڹ %R862iĂT[m?T_T/mX(і֞f{{zDӐmGo<ڏuT* Ld~e3`?{s^OS7>I XfnLs^ߜm[X3uѳh ԐX״na<ۖ<5D-2.oǫ> k{s7a\OqDk$W-޼:s`nS_qnퟥ<0uH2"yn HMseBH8Ѯ 5ovֆ+Q@=ϴ٭YP\WJHV FJ8bw P?d=PYC=I&e)E^,xy6G#@ *("(q/B,`U"JzrVdX/g-t&tV25 lm*n?FL +-<"R=yƲD[/~B2,̣Oⲡ'DO{]iWzI6&k)71?O=P369Л30=ӝ/׾N:\vg8C\uv$;xNnS 54prxTNrwwWqwwW)f.Iĝ)Jٔ){dӉl`v*KI7]|Wө 8 ;BWk{J RT(W#D /3 a8A"S8TUM-df/wylvÙڱ}@4+u~$J0WU>Q6D]y˓To3/QJ#,P0K֎[5+,e IV),)[)vH'`)S C;ٯ.F"(JXGTY2f_$ +aXcdEV|ŧCƚ U%ԾPi_.kГM$*хYHID+۩SW_?C#fQ-ԓQV yO@ ++T$c9H>SS.5f5Tds(- |eE[6"[_ džZ[8"˝`sJ$xW`Iʓ̓Ü%Q|2XAe%JKX? $B*&Oa0e\۷ZMX2R$U 'qJ + A+Ƭ"g$h%l'"}ar%qe%KzX6~l,ے S/WQ~D^ DЀ,{#jM "*Pѐ&jX xbg0l&\8n{3ٟNe#>ˀb*mg`;ӝD7,5lLר)āU՜fyQd@:CHрNO'{Z2):(⍍ڎ(*AZ &*ZiНSU3+A`ȒȱCiVdd*68UJ_3bsk"Kڅx]6/gjRɮI'"[uw 2=9`^l_V%N*i Bf{q FEnq# NJ$ bSarSA\r|D/WL";Ǽr 慙t{| 홥ql9XVE]kmɶk s;ޖKY%54f+&ihI4kDԀC iKES3og!O棻$MmA*M,JABS=虱;6ё&*`MxxTUr,~ 0xګr<,t̫= \A4='_Wʚ/zqR ]1XfbpVjc +I9W4ޛʵTh)Fr WB1 Y*th{jy_AQ6v+ ]D.ih\pĨ={$"FhEu_xuc[!L .Loz_4;pnMj=Mv}$**,Ji0"p{'+ rBo.Z @ :j?lmHxz^דXHhB ʘAl +%! +AݞBhŵA&#S${HB70t>"?z0H}At|1aZ n+!xraƔa38 :~zқV`~˙ H:DdO*4c/-e(4%; ޑ<o1x%5$ޏ8bOaR88 6"Whh`64a> fE +  Ti! F%P# ppjG#a!B0 +?r!4J>wü2N* Qx`3Er,BW8 + @=qD Y#C[L @ebE'ݲ@sDGGi^?.AjA44w,DaSB+O㥧y  S|fAa6I0h + V2 JPj l)w#Ch(0$*edқsHGH|`䣠šBCdOIh[A0>^J|S +G֑ iP-4 +fBiY0@( ӛr4*Q[?fTEI?A@04 iJ%Y0Q3?:HPٟ3>G4 kʣ$P! J $EI@-"$EWWpBAXそge@j3*Xƒ5˯\i?"w,47Fs yBP$b.g>?#H+&ਚ7°t ^,Iq +!%$".&a0}ܱUARiT~ +l4 Y"}ӒApr9&^؀逆ՏSa${tAe{4V6J2YAG )Bsi 1`g0`v>ЪlQU0mmA6`l #y@#!W$ o nPfAѢ(ep)C0}Ú$1'\؊f"CВ(h +<bK+ \wYHP?1`#uӤ1H +<ˁcKy3e <S#E4:@{W9襱#AàAPV1glb'qC VYZh0 3fXA{Xj )ɏvf|q"hm'4r?s4<>EѠ}a!Ĉ~dRU0йy;E &"o`gvn\YQ10BbL+!@3෠F@F(!Ṭn3,ă +"\a]%kPB8&p0a*a|<u VJSN@;O 9b_@0FI* |f] - qBװ@[;U'|-/g9Hh91DAo +\gt`Ḟa3`H瀬yK9RShbhb @p*2HJ=8`>Ń_q+y/Ķ?s^54c` +('0p>_c*r1V*Fi. /&- bܐ8 SRy<&LU46Xq͞q(-2DNIh*jszLgC͗f{|('5@%T6"^ G:k#l:S>!`WJH^⚲v-_[ YiU ܌6)aB@B>CfAxز_8+XB>2uD_`K(*#O0~I?aF^)&?oƀA)P?fAΐkݓI'^dd#tŽB ŌG\ȑch$roPAu@3UU(|[Z=-ai2wShXG=SFR)?#Y[ۿSr{-y~#גuu3h\YxnR@$ %-F=4B·Xp^ gm}[/\qœ=X=l|jmG(WKB2Mo~'qoЄa959^'3ro59&zspT%!cn>Q,B?{Flr{yozábvaa>NX:'tItNq4Np:x ᦷ͖EEJ~[6=C7!+@73X~ gqCkcn)2[kI@cctlDh +ko6 tJnQ}cT$*HLho#:pnˣ }CAW/R7;="i`QHҝ/8lO\ MԪ#uBbϓ"|EHh6\oVѿz(ðQP$@0L$ɅD/lgz^4TVI/>o(ֳnk"/C>.d~@`{ *;S"n`֫ù`隷&w/  h_`O@*) xk L`"h* $IS8IF+e jI\FQ #-@VQYEdF,=Jg>= a Y0r -x}{254l!-)2`6LsOr㱇݊B͗|'m.64oۣ5QGh)G3"N8n YxXVp +݃ uw9!͖k&Іέ3Iɮ43!V WyF%Pg֤Fstl ٶBz`}A_%@*@3F(cZ f*I-9no8&+8dsۢ"{YQcn+ZY/1\Wt9nQjyl%8JvYo;7 ǠmVnN0ԉG68Ȥv(s 6Im3XԈ -:-zm\;N Ϝev։zLEd@ + כT v*+  4qD{A2ߙKD>=DԵ%v%{cNDʆ-ߨOMʉoHbAN@a-|wR7+\wBc?uC.k93&}Иi=$iOK]sDxY:3.!g7fWzȌ;m&H,^t2o_̀,$6 y|'S )w.pV^zÍ9ms-=u#Ѥ8S/g"m}ΥGGU4M#Ao>͜qyB& o³00[[!YnX~HqJߘV'\ Kg2ˏ،a1 +s&=2] XGL&Yۃ%+15J-ڒkٜHv`] +SI?=LMm|e Z@;Bx#ְLS%E-9mЃO nrc&ƂvsQS-ӮJt_gYTMO2W3|˾|(bVDSgg/:3ndm"mvP7ltRb.N}JP?`.gjR^B9I<õq/l47|jmc}>}g&1BnF~0eFڅ`7a ;$48CC=T +CAoKQ h9qmj=ßl,>߬|/\D ,d\ A<`\8':v,`AEcs9x.zπϊ{* +PC, eNrN"X|cL5E* 79eɾ;v!]<(u9"^UwGv 9V^C $Rv.x P^0_☒ar;Dž?ò$+24Rö'r՜|zlrp"`~(,9PosXv.OYW`' HgjN @.)vv'ڐ`<9[@IDJFpqd#?umij!@vFȱ9B|.ݐD(jsD#AhG, `ܘCzD1e^ag:FIK54W0Ľ䜽278{ - 7UN1>a]!݉cnB@|zD<>#t8 ڎRjx P]eXNtH)pg &YdП$/9aWf}Pƌ5vx} t7גE2M͉3ߨLY13E .%V̸ߘu'AmaK\drb@ l CGm;tHNxÊ.UG1/PLsz@ybHFh`3-,1cͻwζ%~@8W4Gwj$@/@<\}MD6!|j\;.В >pp9o7k.= +̓LL- A~fpiL aΨO/4JLӆi*D8g/cu~a{0R6?[Oˡܞ3E]r:>&9N]au6ѽGw.h}ۈ-ovd宑, #9>l?ݘ'l6-ݖ(GeV_?K';`"& +/ 23dG'$OB&" ECݽr5Y/~7mЕab[ŔYu͔3D<ʼGv-@ba:a~.[E s>Yz%03\\=  |u>9_V~w/X|\gơ"w̡6K.VF > ?R)eM5eɱ-N֍m @,?S-ggQn:u$K=Ri)fP{%}|.\gNΡ ni:LfHVX&CӏGS.S4rK{4IЩ7߉93> ,dt{HD,ȒGhy4Olm ABJE\oxqݯPe7e !rKzNjɞT |ǻhLț h/:;l=Jd': +6ps+f Db7#Рm™ +CT.23p!"cZ}0d"0NRKc[`)%6?֗|x:i |rdi dZ"S>3E-A Qr[b( <s,grf4DtJ>9!KR(=QxG% A3?>%1&$(%Y<;([fl٘>.<^٧ks0Og9BW4^gCdM=:6]_RE?6TxowC\=<;͸fVA Ts= l~dd;3[fu\:jiVNqKkqc[{'%62T ҽy1(eƅ1<49zɠcD<[c7eI-՝ɭПM{j9E\nҐɘs^cpf"2d}] +sˌpFYW'~ZY{?f鿌mkwe}0\.NΙۧ{0}AD~RxH|tz=Eϵ8ٕ36L0&3`o@g*!g.3aI@c9d;N:_s>Df|&Koikvp0~t3D\ +Kr짙]KԶd]h6|rLgjV@kUNO`Vrּ9kRdzfx8 q^a7$K#ѿ+L\'w0erZo2*-QcʀQQic؞ស{\s=vD-{Nh"V{c9Fv?rn9nwunNvӉRb2w ŝ{},@=#lwl\ +_.i.zF6Ō|vwL + \;uB[0~=?Wu* lg#vahg:/PE[nS-)-%w⩱D[o?jN7[2_a|6kRh*({PJTCCu|T1Snƅ=*Tg^Sʉ)eP- ІW;f0P^q:>"yK5S< 6ap5r)4?1_a5 >HpE_I3Y1(cDcV+kM=Ze7au&O>،h2X'{ }mޘVO7izDogӳ]Ӌ3{$~K?3~lC)jx.!Y<=ϥǝo4o\4sHzNyݵdggeS +pmdww)O2LΤ02BeW?6qYƝzܘ_h9o쏂w[@ɈmӴ>ok թvI~-%Ը2z}'{K*5xlϧ3Dz#|+:K Hk +2Gg&\4W@|;2Np0l9;/ ~Ab 7ffm:&6Υv4v;,M%R=T}uH^McXogzzGV͝XЩ:=OE\^'ԙR|ܺQbЙT.)4N &`i0 L4M =[+c4_~ pȁi+8AL9:H'v/}D܈  Ḷr fXa"o/ lcmp"ɘ2Z-#mvw2e@6 9`[ECe40dwk&*!=φOCd02,mVlbHH!vd wSאl O`| +ՍPrr5<;톚%P0<3CPgCm4]Y[76(/όiaj]~0 _6w0^6L׽an! a] ?aB`4mR%emӗg3}O;󗑨"F,oFwh >ZmHxa[{QcbcLO c3:P5VxZ~> 0t%@G +q ,MqS 0;w?5g?wpΐֻ:龫8kk{ov ƕn;my9nfcM͕Rnn0ո1.?,`~̛`i1 {>u>|x,ˍ#p|$fIۍْJ|eiZ\1So3e2[VrpVˮGX#OkY Z[3yVӺ,>z۰))"`ۧJF55ؽigΔqcdvg>mPMbYsXM@'dYѧ}8λc;II]gwfѕY8ەgܙߕǹ7֙5\T芺.7sU;S]/:Zmq՜̈́Iw.-kwA>S7LW<KIL7SjڞV9z镞=?@~OOl(A?Ľ#hM2mD%[Lv/kاdGT5C}2&We%)*fuRuvAҟԋÓaJ3ٿ뙮1" %$3čݧXNq^v};玽?f|:m?{v=!?.p8R ȥ@ "z0_ ه9g ӊSsf];J>˦{ÐלEPq4]~w3_?|<*2e?,I, I>HCm~Yl45l])*Gپl n_˱.1֤ n?챁#m}|7ܘ;p(wLUs8l`#e +}Bwh{oZw(Ԟzo [ѯ֍yؑu\ӀwW$Z-5Z#13W/|'4E&Ն;ֆ)Lkeko3߇=2{zVe>A\~o&˻6km?5X{ny xErR=ayI;x`9 덕OX;mƾ? ! 3VS`Zo' l3^k@bx8^ |Q~pw\}/DpTdsS?%rvE6`2ɤ/"oz{w'E(w/YU#gūPG~w_vP|FJќ"Pj+m?-3VJZ o5vVƲ@^!4m9h4Ӏsxc" {}'rhM2d=fR(8ҹ^GD&m<H.W3oٹf?9з8Q.hq6ӇKx"i)+ϾO6䁖o%g(lB3rs@y_ɧG4 þQο ;)mS%iKl9dm @Eh;iΈ7W $\ oa+@ᅵ(`?ϤOhi8@_l@/2s m6G@gLSNc0:L:tr``r=l9}usjk*uIg}܀k΁;%LuY:pQ,l9z`٘W;`N0uYd-jlxe!Pj2P%fڢ? xDh"x:yZ[JPaܧgZol?m%L9?o rUy:(?=yVo姍V(tzz11ͦnUŧ۽ZUF&ш$}P~ھݩ< |Ny0(?};v9>m?'#ŧqH_S~;?+?M|>姏qz1(> [6SřO3*9/},O7 p^R|cn@>UVSܧ;x53s2Ө;͠`9|-[ӹA&I `waYu)kfm/f7V軸Ģ9B{[ A5&b?GhtcFNVC(Z(sD,< 4BƝ5?%:XL'Y Ows=ֿPRU +s1sֿP0 )V2PdSI=u?9sJW_%&tH|9IvI^ }I飻Jo7Rvgj{d2(nŐ% ?Ōmxj ߤƞ@E|؆MbƽcJazx)t1?#vr9{YN4xqUr )St=.睳 7lIܟKUK͐ʧZ?QnVg[![Ab=j],ebvVg}Mf;o̗RVģs$x`L:C,~bѓ=p5^][!~case7]-M`^qq'3KuJ6'35Qnjg\1SEej,-NKWcjʗ,{#LH(uOsB:?-O/D%ƤrHrlBS6lb/?u6#Y-TTP\W7f$|3bIUh>uP;v? ;#"(5j/]PA6rg2.y퟽g#vY+$ӵ3vNSYR-I^ +N>|'Ap4-FI0σZ(2sd9jȨ+2ue~Ai C_xNJEV}5bh^ޙW}\7uF\c0F]c0Ʃe\Z{YuFuL^CΠUc{n[+'bO/\Q4zٛ4d4:vQU+Υɺ"ru9h0d r% Eb[j N4|ÞqQQ8tTmQS-O FMziads-Z "A ̥Qr)VPr@m̏o5+ FR-_z4!1\PɁ"YY>pYX\Ebdq'aq.9h;i%!Y,X})|SQdg!Y9ɿ,-Mg;MMĕJHղjx8 ŃإՄB?Ăҩ}xsWGƬq#A6 `G%b#' +D)=77%11 @& ~&MIeOJS "'%|>eS:P/kd3+5:/cT) r Fn:m˖%زhJ|~Mnt_R nr|OC]wzEGuY&4~I!Y5sSGS(Ƭ( ;sw@q=z(*aqk؛7:HUh. +q/quh{R=>ET6VrY*ZsH#]`I ސK4١K4|1k!=  ^"Nvz9hr4h)IDCn5%TƔmȎ,!tœDPN!:|;S01yB%+ +ɐ)d/q9@ Qf= Q3~3\qcNxrv%N=Nr{ïs3޿Щg+ЩgЉCAwcNzY/s3@Z^%N=<[w9ttSȡSϠ$r~C_:Ɂs}͟w$cmWh)g`!!L"lNkuDzf^t|N̤xRGebE~F/ aQ˜;?69\]tɐwFt#]#r/$)Ͳzv.Hd.}f%U&VWA܍F#Hcj7(%ilLvӊd?^]U_?b79J(ӈ`98 VdDrZ>.82}n/$>f$ + @=3&O?yp{sf"ld._]KъB/tm:R'%g/H.DC2)tSG0ծfX?Ty͟üzN k[^Й- +]ɝOF߂pɸNT3f.ŘVH&) ?L({&y(W %[>c +]heI:%"B?9s' j!)VL H+)N%O\lsJp}mtrTvy$YrMiOb\v^w[9Vb;R9G8QFFzXlYe}~=ٛ!.(iO̱eeݘ/eD^nPEdT$SxQ.4#2ŋ"2es [,95 K} 9wa˩e&x>/#2T׈ GdBazzE9h.^zl8MX[Ēޓ 3WJ^˦{Î9d{ґ=QI' )<9\a`Cօf^ݥgϽ$])$g1n]غMf}_2p])Kf];rM> Uv|P՟z|8]#\=N,-:k>V ˇS8|sO\H/3um+mDJlK|v3'7/ZrҜ*Z ܏z֍~c/[yw:JnӺ 71ʝ"džiPq]h2 +A&_j#|ҍw Q/&sI"R&W]^0L{3mW(TV+QWYÔ9sTҨqT(J}zPԞq#F\h_)#}2RWHm]-t䯉Lr !l \rӶMcŮ + +w_)ٵRpR{c*_yT8SX])6 SKes/7% :R 1 0tHbݯq'5lWUwr@CPD%gPO܋jɒ3l_j71WO]5] eQ94jpMOxWFPIq9-s[#i +V3R|YhQ+qd9Ihdz,ޕT2vܷZB%Cq4+$P&ǙJ3|WEr  +@q=T;SͰ]_z|#3UQZ*~= s5$:hUG!<-=6\*üϷ<,W=L?ٗf;=(#)1E-r$#gw-X=ֵZU͚E|+ y_^ҕ*e6 +DR< Ptd}Z9Gk\w`D'bm+G5u/:*2'iwl:Qql:9?,M'J6\Y?fQ{6\.]7ϦK6LWn˦˥S?l:}6j}l:9Y+M'@Q-N.N)gt'ZxصV_+N.l7trtX\5Nn0\5NRR6\W;ΦJtWØMx ~M+gαҝM''oM'KwYl:圑kf~ +ei:{l::ZW˦W1Netr\zQhx;Y|X&E/ ^.8OYi⬆uzuruzu +օf:x*IOچ, ׯ즺C:;R<$=,LQ1$^t֐ʾF(2Ql/PR~0qS/twI.[NΈ/,sP-K\I'KܩO>C[E]entCkY8Bw>Z}%i~R]gA?3:_&XI%SU Nly5k{|,P'V#+xCdGiT'uGfW>EOCAg: U[< #4;iHK~9IDd:Nv݊@\*Pzcf ݭHW) ShWo_+i'pPJMSɇ >%4r,SG(%)gz'HIs:J ymz`",7W.tR4)5|Jua n\ ɪ"tcyhwc՘AG;7 ',%<.DuOպT4X5Rt;CͅGWV1[Kb (6]tJ[4$jdOBɪYAwVeGTZYiSĥ>?g{P‘MX<#]~H.C:q-~;u\gc%յ:W1/f/ +n~^gߚͮ5Y5zثk_#5ѳYQO>,u XWbue#xJK&$]q9ɑij]g|9\G]EG)wʧ. Vo9 r.HzۂUzu!8|,V>?)o{O1<}QIŃ{T@D;}ݩ+*.6+S!QG1H3Nqe?(.U~ec;LhHQF$/lgB^g˯UC xY1%kdm(ȳ+'zQ>:)ʇohŮՋ)FZO6gERR(qAh4s]?~WPu ~]n(ź~Q!ۺ~U~u7L]?pR~uԫd]GU~iE.JHJU._\\gu]~B7u]ZOSO]hl#+ +u-~8o]Nc'xwq]?^-_uߏ;V~M{jgWO~y~oܔ$+ZyҪ~uI:G ]uNm[?S +nשDlU?Ռ 7ʱ_ OPW}=Kk +zALuT_'nwٍ:P%dLޫސ\]?u3B]?~שǧߢYz|"{љ+~ec㿨맞 K{]?UScS'yS]?u]~].^qK1c]?'ֺm^o]sPXO1Wº~2 +7fuBTjSOc'v +F/망]{~ {{RȟU[^ZO"QբW᷉rV7˸i) 2wЮ{6n)N\IN 1/Bd;!f3 -O(!6XvmIwncT*y+gn<p,)gE<D˺2C6;}Dt[p/GL|E?(mv}gڤ>nl%qPڛ۰uR KE\D% ;\Eà䐅_ۓL%DyӺCIzHٛΘ׍Qٜlۻ}#7`g>,V" x@Ql ʪ +0(>$^ҕJUR$" +`{[e% ?&LBT;̗m~Y(n49;~őgLAy|sL䒑I!Z:<]=>]׸ű5 LRrFV5Vt {:\ #v&۬[PMk%ݻ8>U4#|V5ngˡ! YNP8M svwX~VB9G}JROg_UIڈ @z7{ +r-/xZU,<㺔}xxq+eㄳ2b594Wl*)1V߈TtGBzSŢ$9o!\Y)ab _O {_F9?"]ߓ600IԪSψ^u#XBĞ#پ 9 眖MLΙ\g;π7ДM +GjL\3bdO¡A9pPJ4 +uI>7^˜{L{/<quPuݳR?œy|9:lO[7SfRO]W)\\O嶒ӌH|r' d3,g9s$Wc"`Up=҉MbVשJغe$b z=k 8+듸R8^`!D䃈յN=UvowBbː,|t}gA ck 4&sJ\oI\P:zHbGroUb_Mn"JGv˾"O'x i52bCgH뭌׭Ʌ !Vsw>lw__[nBY{ݦ{W㋃7);> ]z.!wìp429t h U&ֹDrg$K^bS^ro|'jR8/ҜwUݰ9#+eTu,ڻɷ#n)RD߲7z/ԣ\6!4L@PW<[xS@{-:G;DN':Y"<ķoVP7rՖhF[;γLR-:ǜǼ->EE I9-qi%-T.2#ƊӤSŖd&ڰ$@SJ?Yxdct ŏz1y +~0WAa]; '8T/=Xw=Mdcl9]Nrxa_KkTO:7?>pzo|Je(Z%m]:e.fG+7 긔9Z?H -rw"=|1l/l +[,G\Ыֺ|xQOpFeQw`o2(ŷ@V҆DoE|߆|׊cCi‰b:O>>Ob5qmsgA(\JH~@.y|*yJpڞqز5*(2xLyj{l6KEV_KH,RbW)r/(2kF$V*!zx0s=S+/437e~apE&eY>Q`rn3݈, <7aCl= +7\+>y MwpnPQ{]w"/Ӗ}s-q_͵{ūn*S{^'Ɵ1>煇z60cBt¾ut.k5~bQz"$sb=9מ1 ,sy 2KX`8zc^& ++XZ)^v<.'CH6ˎmʎDGs\rV897'njd6beRb[oglЉ;2GuvnfWW\êskbVMI*Liױ+/ϣ,o ȸtrX͵b&iq.Z+r*]S/fYj&ao:vßz(&onf]̬S_k-˒7egqKJ'?}6twXJ'ǩ\;W~>OYB ee덿Woe캿^qh|ՌJJO^'qZ]@t>WAߛKQ9{"%sl늂]OjU1,Wá<럗~c;"`}O岔輎VՖ r|vvWrٙkۍ5'= ST0mqk-('4GޝRyjO9vK3Iȩ/TXh\~\)-g=VdCKi*ҽv+j_B=𒠅ל7)e{@ԞWty^VrN)p' ,\2E# J֢KFZyKFhdᒑ@/.Yd$7,\22dE# 梑KFtƦMu"݁gWĮ͑T WS#b펦JpV9a[ i3TKw}+ (9afXjyD7FHv"YŊ24ZqЙXrTw9 +oݾa=&ʀ^Bg^ӱ*`f`{w6f?Deo<A_npP!㿆 M?-wQQ6cr"-u8=?T;)WsljAix! +>JF J 7Gp b< ޣ`],0 1S((`5% 1VLtLL'$2bhDHG +0kȲtH"Iu R\SƠ`Ye0ˠb # 4{KC`C-RC@0HbQ#04dj1] ]06LTSfYg1CL=Ƞ3#ML3b2##S P1M ݲL4銉7Kd U- ʘ&": j@@D3uF@ش0J6e<9"#h`hOcZX3M˴4c(İ @KaU B33#ZbgX7Lm5 an1X@-^M j€< ġaࡩPA! X?iH3 bL@Ԃfi +ёE8?lAÈR0,a q-.HKYEaL A hc +p x&}A)DT >`Js1t & *X# j8 ) fԁ8XWQ΃ @d CCb@1M>!KTE1"\(}F7)LS'S#NMn- Pw + l8P%p\7 ȇB, =*2j=@nMlhw2t6A@Zp +H% *YhT +Yw5l?J~ =}Ӱ7>qrZ endstream endobj 5 0 obj <> endobj 6 0 obj <> endobj 7 0 obj <> endobj 33 0 obj <> endobj 34 0 obj <> endobj 35 0 obj <> endobj 60 0 obj <> endobj 61 0 obj <> endobj 72 0 obj [/View/Design] endobj 73 0 obj <>>> endobj 70 0 obj [/View/Design] endobj 71 0 obj <>>> endobj 48 0 obj [/View/Design] endobj 49 0 obj <>>> endobj 46 0 obj [/View/Design] endobj 47 0 obj <>>> endobj 44 0 obj [/View/Design] endobj 45 0 obj <>>> endobj 21 0 obj [/View/Design] endobj 22 0 obj <>>> endobj 19 0 obj [/View/Design] endobj 20 0 obj <>>> endobj 17 0 obj [/View/Design] endobj 18 0 obj <>>> endobj 85 0 obj [84 0 R] endobj 104 0 obj <> endobj xref +0 105 +0000000004 65535 f +0000000016 00000 n +0000000258 00000 n +0000035771 00000 n +0000000008 00000 f +0000346567 00000 n +0000346637 00000 n +0000346707 00000 n +0000000010 00000 f +0000035822 00000 n +0000000011 00000 f +0000000012 00000 f +0000000013 00000 f +0000000014 00000 f +0000000015 00000 f +0000000016 00000 f +0000000023 00000 f +0000347944 00000 n +0000347975 00000 n +0000347828 00000 n +0000347859 00000 n +0000347712 00000 n +0000347743 00000 n +0000000024 00000 f +0000000025 00000 f +0000000026 00000 f +0000000027 00000 f +0000000028 00000 f +0000000029 00000 f +0000000030 00000 f +0000000031 00000 f +0000000032 00000 f +0000000036 00000 f +0000346777 00000 n +0000346848 00000 n +0000346919 00000 n +0000000037 00000 f +0000000038 00000 f +0000000039 00000 f +0000000040 00000 f +0000000041 00000 f +0000000042 00000 f +0000000043 00000 f +0000000050 00000 f +0000347596 00000 n +0000347627 00000 n +0000347480 00000 n +0000347511 00000 n +0000347364 00000 n +0000347395 00000 n +0000000051 00000 f +0000000052 00000 f +0000000053 00000 f +0000000054 00000 f +0000000055 00000 f +0000000056 00000 f +0000000057 00000 f +0000000058 00000 f +0000000059 00000 f +0000000000 00000 f +0000346990 00000 n +0000347061 00000 n +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000347248 00000 n +0000347279 00000 n +0000347132 00000 n +0000347163 00000 n +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000000000 00000 f +0000037346 00000 n +0000348060 00000 n +0000036204 00000 n +0000040329 00000 n +0000037646 00000 n +0000037533 00000 n +0000036626 00000 n +0000036785 00000 n +0000036833 00000 n +0000037417 00000 n +0000037448 00000 n +0000037681 00000 n +0000040403 00000 n +0000040669 00000 n +0000041813 00000 n +0000043910 00000 n +0000109498 00000 n +0000175087 00000 n +0000240676 00000 n +0000306265 00000 n +0000348085 00000 n +trailer <<9FA9B9F100344ACFA1DF9FF32EBFB5DA>]>> startxref 348296 %%EOF \ No newline at end of file From 73a0077fd38c6ae79f33a9d4d3cc128a904b4a6c Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 25 Aug 2019 02:39:20 -0400 Subject: [PATCH 02/13] Major overhaul in compilation to enable ES6 module generation. --- admin/build.js | 40 +- admin/cmds/reset-build.js | 5 + admin/cmds/update-versions.js | 5 +- admin/local.js | 11 +- package.json | 44 +- packages/abi/{ => lib.esm}/_version.d.ts | 0 packages/abi/lib.esm/_version.js | 1 + packages/abi/{ => lib.esm}/abi-coder.d.ts | 0 packages/abi/lib.esm/abi-coder.js | 91 + .../abi/lib.esm/coders/abstract-coder.d.ts | 41 + packages/abi/lib.esm/coders/abstract-coder.js | 109 + packages/abi/lib.esm/coders/address.d.ts | 6 + packages/abi/lib.esm/coders/address.js | 21 + packages/abi/lib.esm/coders/anonymous.d.ts | 7 + packages/abi/lib.esm/coders/anonymous.js | 15 + packages/abi/lib.esm/coders/array.d.ts | 10 + packages/abi/lib.esm/coders/array.js | 126 + packages/abi/lib.esm/coders/boolean.d.ts | 6 + packages/abi/lib.esm/coders/boolean.js | 13 + packages/abi/lib.esm/coders/bytes.d.ts | 10 + packages/abi/lib.esm/coders/bytes.js | 25 + packages/abi/lib.esm/coders/fixed-bytes.d.ts | 8 + packages/abi/lib.esm/coders/fixed-bytes.js | 21 + packages/abi/lib.esm/coders/null.d.ts | 6 + packages/abi/lib.esm/coders/null.js | 17 + packages/abi/lib.esm/coders/number.d.ts | 9 + packages/abi/lib.esm/coders/number.js | 38 + packages/abi/lib.esm/coders/string.d.ts | 7 + packages/abi/lib.esm/coders/string.js | 14 + packages/abi/lib.esm/coders/tuple.d.ts | 7 + packages/abi/lib.esm/coders/tuple.js | 24 + packages/abi/{ => lib.esm}/fragments.d.ts | 0 packages/abi/lib.esm/fragments.js | 752 + packages/abi/{ => lib.esm}/index.d.ts | 0 packages/abi/lib.esm/index.js | 5 + packages/abi/{ => lib.esm}/interface.d.ts | 0 packages/abi/lib.esm/interface.js | 342 + packages/abi/lib/_version.d.ts | 1 + packages/abi/{ => lib}/_version.js | 0 packages/abi/lib/abi-coder.d.ts | 15 + packages/abi/{ => lib}/abi-coder.js | 0 packages/abi/lib/coders/abstract-coder.d.ts | 41 + packages/abi/lib/coders/abstract-coder.js | 133 + packages/abi/lib/coders/address.d.ts | 6 + packages/abi/lib/coders/address.js | 38 + packages/abi/lib/coders/anonymous.d.ts | 7 + packages/abi/lib/coders/anonymous.js | 33 + packages/abi/lib/coders/array.d.ts | 10 + packages/abi/lib/coders/array.js | 147 + packages/abi/lib/coders/boolean.d.ts | 6 + packages/abi/lib/coders/boolean.js | 30 + packages/abi/lib/coders/bytes.d.ts | 10 + packages/abi/lib/coders/bytes.js | 45 + packages/abi/lib/coders/fixed-bytes.d.ts | 8 + packages/abi/lib/coders/fixed-bytes.js | 40 + packages/abi/lib/coders/null.d.ts | 6 + packages/abi/lib/coders/null.js | 34 + packages/abi/lib/coders/number.d.ts | 9 + packages/abi/lib/coders/number.js | 57 + packages/abi/lib/coders/string.d.ts | 7 + packages/abi/lib/coders/string.js | 31 + packages/abi/lib/coders/tuple.d.ts | 7 + packages/abi/lib/coders/tuple.js | 43 + packages/abi/lib/fragments.d.ts | 76 + packages/abi/{ => lib}/fragments.js | 0 packages/abi/lib/index.d.ts | 4 + packages/abi/{ => lib}/index.js | 0 packages/abi/lib/interface.d.ts | 70 + packages/abi/{ => lib}/interface.js | 0 packages/abi/package.json | 7 +- packages/abi/src.ts/coders/abstract-coder.ts | 2 +- packages/abi/test-coder.js | 4 - packages/abi/tsconfig.json | 9 +- .../{ => lib.esm}/_version.d.ts | 0 .../abstract-provider/lib.esm/_version.js | 1 + .../{ => lib.esm}/index.d.ts | 0 packages/abstract-provider/lib.esm/index.js | 78 + packages/abstract-provider/lib/_version.d.ts | 1 + .../abstract-provider/{ => lib}/_version.js | 0 packages/abstract-provider/lib/index.d.ts | 138 + packages/abstract-provider/{ => lib}/index.js | 0 packages/abstract-provider/package.json | 7 +- packages/abstract-provider/tsconfig.json | 7 +- .../{ => lib.esm}/_version.d.ts | 0 packages/abstract-signer/lib.esm/_version.js | 1 + .../abstract-signer/{ => lib.esm}/index.d.ts | 0 packages/abstract-signer/lib.esm/index.js | 168 + packages/abstract-signer/lib/_version.d.ts | 1 + .../abstract-signer/{ => lib}/_version.js | 0 packages/abstract-signer/lib/index.d.ts | 39 + packages/abstract-signer/{ => lib}/index.js | 0 packages/abstract-signer/package.json | 7 +- packages/abstract-signer/tsconfig.json | 7 +- packages/address/{ => lib.esm}/_version.d.ts | 0 packages/address/lib.esm/_version.js | 1 + packages/address/{ => lib.esm}/index.d.ts | 0 packages/address/lib.esm/index.js | 128 + packages/address/lib/_version.d.ts | 1 + packages/address/{ => lib}/_version.js | 0 packages/address/lib/index.d.ts | 8 + packages/address/{ => lib}/index.js | 0 packages/address/package.json | 7 +- packages/address/tsconfig.json | 5 +- packages/base64/.gitignore | 3 +- packages/base64/{ => lib.esm}/_version.d.ts | 0 packages/base64/lib.esm/_version.js | 1 + packages/base64/lib.esm/browser.js | 18 + packages/base64/{ => lib.esm}/index.d.ts | 0 packages/base64/lib.esm/index.js | 9 + packages/base64/lib/_version.d.ts | 1 + packages/base64/{ => lib}/_version.js | 0 packages/base64/{ => lib}/browser.js | 0 packages/base64/lib/index.d.ts | 3 + packages/base64/{ => lib}/index.js | 0 packages/base64/package.json | 7 +- packages/base64/tsconfig.json | 7 +- packages/basex/{ => lib.esm}/_version.d.ts | 0 packages/basex/lib.esm/_version.js | 1 + packages/basex/{ => lib.esm}/index.d.ts | 0 packages/basex/lib.esm/index.js | 118 + packages/basex/lib/_version.d.ts | 1 + packages/basex/{ => lib}/_version.js | 0 packages/basex/lib/index.d.ts | 52 + packages/basex/{ => lib}/index.js | 0 packages/basex/package.json | 7 +- packages/basex/tsconfig.json | 7 +- .../bignumber/{ => lib.esm}/_version.d.ts | 0 packages/bignumber/lib.esm/_version.js | 1 + .../bignumber/{ => lib.esm}/bignumber.d.ts | 0 packages/bignumber/lib.esm/bignumber.js | 210 + .../bignumber/{ => lib.esm}/fixednumber.d.ts | 0 packages/bignumber/lib.esm/fixednumber.js | 305 + packages/bignumber/{ => lib.esm}/index.d.ts | 0 packages/bignumber/lib.esm/index.js | 2 + packages/bignumber/lib/_version.d.ts | 1 + packages/bignumber/{ => lib}/_version.js | 0 packages/bignumber/lib/bignumber.d.ts | 29 + packages/bignumber/{ => lib}/bignumber.js | 0 packages/bignumber/lib/fixednumber.d.ts | 35 + packages/bignumber/{ => lib}/fixednumber.js | 0 packages/bignumber/lib/index.d.ts | 2 + packages/bignumber/{ => lib}/index.js | 3 + packages/bignumber/package.json | 7 +- packages/bignumber/src.ts/index.ts | 2 +- packages/bignumber/tsconfig.json | 9 +- packages/bytes/{ => lib.esm}/_version.d.ts | 0 packages/bytes/lib.esm/_version.js | 1 + packages/bytes/{ => lib.esm}/index.d.ts | 0 packages/bytes/lib.esm/index.js | 363 + packages/bytes/lib/_version.d.ts | 1 + packages/bytes/{ => lib}/_version.js | 0 packages/bytes/lib/index.d.ts | 39 + packages/bytes/{ => lib}/index.js | 0 packages/bytes/package.json | 7 +- packages/bytes/tsconfig.json | 7 +- packages/cli/.gitignore | 3 +- packages/cli/.npmignore | 2 + packages/cli/{ => lib.esm}/_version.d.ts | 0 packages/cli/lib.esm/_version.js | 1 + packages/cli/lib.esm/bin/ethers-ens.js | 836 + packages/cli/lib.esm/bin/ethers-ts.js | 151 + packages/cli/lib.esm/bin/ethers.js | 844 + packages/cli/{ => lib.esm}/cli.d.ts | 0 packages/cli/lib.esm/cli.js | 860 + packages/cli/{ => lib.esm}/prompt.d.ts | 0 packages/cli/lib.esm/prompt.js | 125 + packages/cli/{ => lib.esm}/solc.d.ts | 0 packages/cli/lib.esm/solc.js | 73 + packages/cli/{ => lib.esm}/typescript.d.ts | 0 packages/cli/lib.esm/typescript.js | 122 + packages/cli/lib/_version.d.ts | 1 + packages/cli/{ => lib}/_version.js | 0 packages/cli/{ => lib}/bin/ethers-ens.js | 0 packages/cli/{ => lib}/bin/ethers-ts.js | 0 packages/cli/{ => lib}/bin/ethers.js | 0 packages/cli/lib/cli.d.ts | 81 + packages/cli/{ => lib}/cli.js | 0 packages/cli/lib/index.d.ts | 5 + packages/cli/lib/index.js | 17 + packages/cli/lib/prompt.d.ts | 9 + packages/cli/{ => lib}/prompt.js | 0 packages/cli/lib/solc.d.ts | 14 + packages/cli/{ => lib}/solc.js | 0 packages/cli/lib/typescript.d.ts | 3 + packages/cli/{ => lib}/typescript.js | 0 packages/cli/package.json | 13 +- packages/cli/src.ts/index.ts | 13 + packages/cli/tsconfig.json | 11 +- .../constants/{ => lib.esm}/_version.d.ts | 0 packages/constants/lib.esm/_version.js | 1 + packages/constants/{ => lib.esm}/index.d.ts | 0 packages/constants/lib.esm/index.js | 15 + packages/constants/lib/_version.d.ts | 1 + packages/constants/{ => lib}/_version.js | 0 packages/constants/lib/index.d.ts | 11 + packages/constants/{ => lib}/index.js | 0 packages/constants/package.json | 7 +- packages/constants/tsconfig.json | 7 +- .../contracts/{ => lib.esm}/_version.d.ts | 0 packages/contracts/lib.esm/_version.js | 1 + packages/contracts/{ => lib.esm}/index.d.ts | 0 packages/contracts/lib.esm/index.js | 703 + packages/contracts/lib/_version.d.ts | 1 + packages/contracts/{ => lib}/_version.js | 0 packages/contracts/lib/index.d.ts | 119 + packages/contracts/{ => lib}/index.js | 0 packages/contracts/package.json | 7 +- packages/contracts/tsconfig.json | 7 +- packages/errors/{ => lib.esm}/_version.d.ts | 0 packages/errors/lib.esm/_version.js | 1 + packages/errors/{ => lib.esm}/index.d.ts | 0 packages/errors/lib.esm/index.js | 245 + packages/errors/lib/_version.d.ts | 1 + packages/errors/{ => lib}/_version.js | 0 packages/errors/lib/index.d.ts | 29 + packages/errors/{ => lib}/index.js | 0 packages/errors/package.json | 7 +- packages/errors/tsconfig.json | 7 +- packages/ethers/dist/ethers.esm.js | 19283 +++++++++++++++ packages/ethers/dist/ethers.esm.min.js | 1 + packages/ethers/dist/ethers.umd.js | 20648 ++++++++++++++++ packages/ethers/dist/ethers.umd.min.js | 1 + packages/ethers/{ => lib.esm}/_version.d.ts | 0 packages/ethers/lib.esm/_version.js | 1 + .../{ => lib.esm}/browser-platform.d.ts | 0 packages/ethers/lib.esm/browser-platform.js | 2 + packages/ethers/{ => lib.esm}/ethers.d.ts | 0 packages/ethers/lib.esm/ethers.js | 39 + packages/ethers/{ => lib.esm}/index.d.ts | 0 packages/ethers/lib.esm/index.js | 4 + packages/ethers/{ => lib.esm}/platform.d.ts | 0 packages/ethers/lib.esm/platform.js | 2 + packages/ethers/{ => lib.esm}/utils.d.ts | 0 packages/ethers/lib.esm/utils.js | 31 + packages/ethers/lib/_version.d.ts | 1 + packages/ethers/{ => lib}/_version.js | 0 packages/ethers/lib/browser-platform.d.ts | 1 + packages/ethers/{ => lib}/browser-platform.js | 0 packages/ethers/lib/ethers.d.ts | 20 + packages/ethers/{ => lib}/ethers.js | 0 packages/ethers/lib/index.d.ts | 3 + packages/ethers/{ => lib}/index.js | 0 packages/ethers/lib/platform.d.ts | 1 + packages/ethers/{ => lib}/platform.js | 0 packages/ethers/lib/utils.d.ts | 27 + packages/ethers/{ => lib}/utils.js | 0 packages/ethers/package.json | 7 +- packages/ethers/tsconfig.json | 7 +- .../experimental/{ => lib.esm}/_version.d.ts | 0 packages/experimental/lib.esm/_version.js | 1 + .../{ => lib.esm}/brain-wallet.d.ts | 0 packages/experimental/lib.esm/brain-wallet.js | 55 + .../experimental/{ => lib.esm}/index.d.ts | 0 packages/experimental/{ => lib.esm}/index.js | 0 .../{ => lib.esm}/metamask-provider.d.ts | 0 .../experimental/lib.esm/metamask-provider.js | 66 + .../{ => lib.esm}/nonce-manager.d.ts | 0 .../experimental/lib.esm/nonce-manager.js | 54 + .../{ => lib.esm}/retry-provider.d.ts | 0 .../experimental/lib.esm/retry-provider.js | 27 + packages/experimental/lib/_version.d.ts | 1 + packages/experimental/{ => lib}/_version.js | 0 packages/experimental/lib/brain-wallet.d.ts | 6 + .../experimental/{ => lib}/brain-wallet.js | 0 .../lib/index.d.ts} | 0 packages/experimental/lib/index.js | 1 + .../experimental/lib/metamask-provider.d.ts | 12 + .../{ => lib}/metamask-provider.js | 0 packages/experimental/lib/nonce-manager.d.ts | 15 + .../experimental/{ => lib}/nonce-manager.js | 0 packages/experimental/lib/retry-provider.d.ts | 14 + .../experimental/{ => lib}/retry-provider.js | 0 packages/experimental/package.json | 7 +- packages/experimental/tsconfig.json | 9 +- packages/hash/{ => lib.esm}/_version.d.ts | 0 packages/hash/lib.esm/_version.js | 1 + packages/hash/{ => lib.esm}/index.d.ts | 0 packages/hash/lib.esm/index.js | 50 + packages/hash/lib/_version.d.ts | 1 + packages/hash/{ => lib}/_version.js | 0 packages/hash/lib/index.d.ts | 6 + packages/hash/{ => lib}/index.js | 0 packages/hash/package.json | 7 +- packages/hash/tsconfig.json | 7 +- packages/hdnode/{ => lib.esm}/_version.d.ts | 0 packages/hdnode/lib.esm/_version.js | 1 + packages/hdnode/{ => lib.esm}/index.d.ts | 0 packages/hdnode/lib.esm/index.js | 288 + packages/hdnode/lib/_version.d.ts | 1 + packages/hdnode/{ => lib}/_version.js | 0 packages/hdnode/lib/index.d.ts | 36 + packages/hdnode/{ => lib}/index.js | 0 packages/hdnode/package.json | 7 +- packages/hdnode/tsconfig.json | 7 +- .../json-wallets/{ => lib.esm}/_version.d.ts | 0 packages/json-wallets/lib.esm/_version.js | 1 + .../json-wallets/{ => lib.esm}/crowdsale.d.ts | 0 packages/json-wallets/lib.esm/crowdsale.js | 48 + .../json-wallets/{ => lib.esm}/index.d.ts | 0 packages/json-wallets/lib.esm/index.js | 21 + .../json-wallets/{ => lib.esm}/inspect.d.ts | 0 packages/json-wallets/lib.esm/inspect.js | 48 + .../json-wallets/{ => lib.esm}/keystore.d.ts | 0 packages/json-wallets/lib.esm/keystore.js | 332 + .../json-wallets/{ => lib.esm}/utils.d.ts | 0 packages/json-wallets/lib.esm/utils.js | 57 + packages/json-wallets/lib/_version.d.ts | 1 + packages/json-wallets/{ => lib}/_version.js | 0 packages/json-wallets/lib/crowdsale.d.ts | 12 + packages/json-wallets/{ => lib}/crowdsale.js | 0 packages/json-wallets/lib/index.d.ts | 7 + packages/json-wallets/{ => lib}/index.js | 0 packages/json-wallets/lib/inspect.d.ts | 3 + packages/json-wallets/{ => lib}/inspect.js | 0 packages/json-wallets/lib/keystore.d.ts | 26 + packages/json-wallets/{ => lib}/keystore.js | 0 packages/json-wallets/lib/utils.d.ts | 5 + packages/json-wallets/{ => lib}/utils.js | 0 packages/json-wallets/package.json | 7 +- packages/json-wallets/tsconfig.json | 9 +- .../keccak256/{ => lib.esm}/_version.d.ts | 0 packages/keccak256/lib.esm/_version.js | 1 + packages/keccak256/{ => lib.esm}/index.d.ts | 0 packages/keccak256/lib.esm/index.js | 6 + packages/keccak256/lib/_version.d.ts | 1 + packages/keccak256/{ => lib}/_version.js | 0 packages/keccak256/lib/index.d.ts | 2 + packages/keccak256/{ => lib}/index.js | 0 packages/keccak256/package.json | 7 +- packages/keccak256/tsconfig.json | 7 +- packages/logger/{ => lib.esm}/_version.d.ts | 0 packages/logger/lib.esm/_version.js | 1 + packages/logger/{ => lib.esm}/index.d.ts | 0 packages/logger/lib.esm/index.js | 264 + packages/logger/lib/_version.d.ts | 1 + packages/logger/{ => lib}/_version.js | 0 packages/logger/lib/index.d.ts | 42 + packages/logger/{ => lib}/index.js | 0 packages/logger/package.json | 7 +- packages/logger/tsconfig.json | 7 +- packages/networks/{ => lib.esm}/_version.d.ts | 0 packages/networks/lib.esm/_version.js | 1 + packages/networks/{ => lib.esm}/index.d.ts | 0 packages/networks/lib.esm/index.js | 171 + packages/networks/{ => lib.esm}/types.d.ts | 0 packages/networks/lib.esm/types.js | 1 + packages/networks/lib/_version.d.ts | 1 + packages/networks/{ => lib}/_version.js | 0 packages/networks/lib/index.d.ts | 9 + packages/networks/{ => lib}/index.js | 0 packages/networks/lib/types.d.ts | 7 + packages/networks/{ => lib}/types.js | 0 packages/networks/package.json | 7 +- packages/networks/tsconfig.json | 7 +- packages/pbkdf2/.gitignore | 3 +- packages/pbkdf2/{ => lib.esm}/_version.d.ts | 0 packages/pbkdf2/lib.esm/_version.js | 1 + packages/pbkdf2/lib.esm/browser.js | 43 + packages/pbkdf2/{ => lib.esm}/index.d.ts | 0 packages/pbkdf2/lib.esm/index.js | 9 + packages/pbkdf2/lib/_version.d.ts | 1 + packages/pbkdf2/{ => lib}/_version.js | 0 packages/pbkdf2/{ => lib}/browser.js | 0 packages/pbkdf2/lib/index.d.ts | 2 + packages/pbkdf2/{ => lib}/index.js | 0 packages/pbkdf2/package.json | 7 +- packages/pbkdf2/tsconfig.json | 7 +- .../properties/{ => lib.esm}/_version.d.ts | 0 packages/properties/lib.esm/_version.js | 1 + packages/properties/{ => lib.esm}/index.d.ts | 0 packages/properties/lib.esm/index.js | 100 + packages/properties/lib/_version.d.ts | 1 + packages/properties/{ => lib}/_version.js | 0 packages/properties/lib/index.d.ts | 11 + packages/properties/{ => lib}/index.js | 0 packages/properties/package.json | 7 +- packages/properties/tsconfig.json | 7 +- .../providers/{ => lib.esm}/_version.d.ts | 0 packages/providers/lib.esm/_version.js | 1 + .../{ => lib.esm}/alchemy-provider.d.ts | 0 .../providers/lib.esm/alchemy-provider.js | 38 + .../{ => lib.esm}/base-provider.d.ts | 0 packages/providers/lib.esm/base-provider.js | 843 + .../browser-ipc-provider.d.ts} | 0 .../{ => lib.esm}/browser-ipc-provider.js | 0 packages/providers/lib.esm/browser-net.d.ts | 0 .../providers/{ => lib.esm}/browser-net.js | 0 .../{ => lib.esm}/cloudflare-provider.d.ts | 0 .../providers/lib.esm/cloudflare-provider.js | 21 + .../{ => lib.esm}/etherscan-provider.d.ts | 0 .../providers/lib.esm/etherscan-provider.js | 324 + .../{ => lib.esm}/fallback-provider.d.ts | 0 .../providers/lib.esm/fallback-provider.js | 296 + .../providers/{ => lib.esm}/formatter.d.ts | 0 packages/providers/lib.esm/formatter.js | 378 + packages/providers/{ => lib.esm}/index.d.ts | 0 packages/providers/lib.esm/index.js | 31 + .../{ => lib.esm}/infura-provider.d.ts | 0 packages/providers/lib.esm/infura-provider.js | 41 + .../providers/{ => lib.esm}/ipc-provider.d.ts | 0 packages/providers/lib.esm/ipc-provider.js | 54 + .../{ => lib.esm}/json-rpc-provider.d.ts | 0 .../providers/lib.esm/json-rpc-provider.js | 400 + .../{ => lib.esm}/nodesmith-provider.d.ts | 0 .../providers/lib.esm/nodesmith-provider.js | 35 + .../{ => lib.esm}/url-json-rpc-provider.d.ts | 0 .../lib.esm/url-json-rpc-provider.js | 41 + .../{ => lib.esm}/web3-provider.d.ts | 0 packages/providers/lib.esm/web3-provider.js | 63 + packages/providers/lib/_version.d.ts | 1 + packages/providers/{ => lib}/_version.js | 0 packages/providers/lib/alchemy-provider.d.ts | 7 + .../providers/{ => lib}/alchemy-provider.js | 0 packages/providers/lib/base-provider.d.ts | 98 + packages/providers/{ => lib}/base-provider.js | 0 .../providers/lib/browser-ipc-provider.d.ts | 0 .../providers/lib/browser-ipc-provider.js | 2 + packages/providers/lib/browser-net.d.ts | 0 packages/providers/lib/browser-net.js | 2 + .../providers/lib/cloudflare-provider.d.ts | 5 + .../{ => lib}/cloudflare-provider.js | 0 .../providers/lib/etherscan-provider.d.ts | 10 + .../providers/{ => lib}/etherscan-provider.js | 0 packages/providers/lib/fallback-provider.d.ts | 13 + .../providers/{ => lib}/fallback-provider.js | 0 packages/providers/lib/formatter.d.ts | 50 + packages/providers/{ => lib}/formatter.js | 0 packages/providers/lib/index.d.ts | 16 + packages/providers/{ => lib}/index.js | 0 packages/providers/lib/infura-provider.d.ts | 7 + .../providers/{ => lib}/infura-provider.js | 0 packages/providers/lib/ipc-provider.d.ts | 7 + packages/providers/{ => lib}/ipc-provider.js | 0 packages/providers/lib/json-rpc-provider.d.ts | 42 + .../providers/{ => lib}/json-rpc-provider.js | 0 .../providers/lib/nodesmith-provider.d.ts | 6 + .../providers/{ => lib}/nodesmith-provider.js | 0 .../providers/lib/url-json-rpc-provider.d.ts | 12 + .../{ => lib}/url-json-rpc-provider.js | 0 packages/providers/lib/web3-provider.d.ts | 15 + packages/providers/{ => lib}/web3-provider.js | 0 packages/providers/package.json | 7 +- packages/providers/tsconfig.json | 7 +- packages/random/.gitignore | 3 +- packages/random/{ => lib.esm}/_version.d.ts | 0 packages/random/lib.esm/_version.js | 1 + packages/random/lib.esm/browser.js | 26 + packages/random/{ => lib.esm}/index.d.ts | 0 packages/random/lib.esm/index.js | 7 + packages/random/{ => lib.esm}/shuffle.d.ts | 0 packages/random/lib.esm/shuffle.js | 11 + packages/random/lib/_version.d.ts | 1 + packages/random/{ => lib}/_version.js | 0 packages/random/{ => lib}/browser.js | 0 packages/random/lib/index.d.ts | 2 + packages/random/{ => lib}/index.js | 0 packages/random/lib/shuffle.d.ts | 1 + packages/random/{ => lib}/shuffle.js | 0 packages/random/package.json | 7 +- packages/random/tsconfig.json | 7 +- packages/rlp/{ => lib.esm}/_version.d.ts | 0 packages/rlp/lib.esm/_version.js | 1 + packages/rlp/{ => lib.esm}/index.d.ts | 0 packages/rlp/lib.esm/index.js | 113 + packages/rlp/lib/_version.d.ts | 1 + packages/rlp/{ => lib}/_version.js | 0 packages/rlp/lib/index.d.ts | 3 + packages/rlp/{ => lib}/index.js | 0 packages/rlp/package.json | 7 +- packages/rlp/tsconfig.json | 7 +- packages/sha2/.gitignore | 3 +- packages/sha2/{ => lib.esm}/_version.d.ts | 0 packages/sha2/lib.esm/_version.js | 1 + packages/sha2/lib.esm/browser.js | 30 + packages/sha2/{ => lib.esm}/index.d.ts | 0 packages/sha2/lib.esm/index.js | 30 + packages/sha2/lib/_version.d.ts | 1 + packages/sha2/{ => lib}/_version.js | 0 packages/sha2/{ => lib}/browser.js | 0 packages/sha2/lib/index.d.ts | 9 + packages/sha2/{ => lib}/index.js | 0 packages/sha2/package.json | 7 +- packages/sha2/tsconfig.json | 9 +- packages/shims/package.json | 7 +- .../signing-key/{ => lib.esm}/_version.d.ts | 0 packages/signing-key/lib.esm/_version.js | 1 + packages/signing-key/{ => lib.esm}/index.d.ts | 0 packages/signing-key/lib.esm/index.js | 74 + packages/signing-key/lib/_version.d.ts | 1 + packages/signing-key/{ => lib}/_version.js | 0 packages/signing-key/lib/index.d.ts | 15 + packages/signing-key/{ => lib}/index.js | 0 packages/signing-key/package.json | 9 +- packages/signing-key/tsconfig.json | 7 +- packages/solidity/{ => lib.esm}/_version.d.ts | 0 packages/solidity/lib.esm/_version.js | 1 + packages/solidity/{ => lib.esm}/index.d.ts | 0 packages/solidity/lib.esm/index.js | 87 + packages/solidity/lib/_version.d.ts | 1 + packages/solidity/{ => lib}/_version.js | 0 packages/solidity/lib/index.d.ts | 3 + packages/solidity/{ => lib}/index.js | 0 packages/solidity/package.json | 7 +- packages/solidity/tsconfig.json | 7 +- packages/strings/{ => lib.esm}/_version.d.ts | 0 packages/strings/lib.esm/_version.js | 1 + packages/strings/{ => lib.esm}/bytes32.d.ts | 0 packages/strings/lib.esm/bytes32.js | 31 + packages/strings/{ => lib.esm}/idna.d.ts | 0 packages/strings/lib.esm/idna.js | 187 + packages/strings/{ => lib.esm}/index.d.ts | 0 packages/strings/lib.esm/index.js | 5 + packages/strings/{ => lib.esm}/utf8.d.ts | 0 packages/strings/lib.esm/utf8.js | 191 + packages/strings/lib/_version.d.ts | 1 + packages/strings/{ => lib}/_version.js | 0 packages/strings/lib/bytes32.d.ts | 3 + packages/strings/{ => lib}/bytes32.js | 0 packages/strings/lib/idna.d.ts | 4 + packages/strings/{ => lib}/idna.js | 0 packages/strings/lib/index.d.ts | 4 + packages/strings/{ => lib}/index.js | 1 - packages/strings/lib/utf8.d.ts | 13 + packages/strings/{ => lib}/utf8.js | 0 packages/strings/package.json | 7 +- packages/strings/src.ts/index.ts | 2 +- packages/strings/tsconfig.json | 7 +- packages/testcases/.gitignore | 3 +- .../testcases/{ => lib.esm}/_version.d.ts | 0 packages/testcases/lib.esm/_version.js | 1 + .../testcases/{ => lib.esm}/browser-fs.json | 0 packages/testcases/{ => lib.esm}/browser.d.ts | 0 packages/testcases/lib.esm/browser.js | 15 + .../lib.esm/generation-scripts/abi.js | 523 + .../lib.esm/generation-scripts/hdnode.js | 106 + .../lib.esm/generation-scripts/nameprep.js | 6 + .../lib.esm/generation-scripts/units.js | 6 + .../lib.esm/generation-scripts/wallets.js | 26 + .../lib.esm/generation-scripts/wordlists.js | 13 + packages/testcases/{ => lib.esm}/index.d.ts | 0 packages/testcases/lib.esm/index.js | 43 + packages/testcases/lib/_version.d.ts | 1 + packages/testcases/{ => lib}/_version.js | 0 packages/testcases/lib/browser-fs.json | 1 + packages/testcases/lib/browser.d.ts | 3 + packages/testcases/{ => lib}/browser.js | 0 .../{ => lib}/generation-scripts/abi.js | 4 +- .../{ => lib}/generation-scripts/hdnode.js | 0 .../{ => lib}/generation-scripts/nameprep.js | 0 .../{ => lib}/generation-scripts/units.js | 0 .../{ => lib}/generation-scripts/wallets.js | 0 .../{ => lib}/generation-scripts/wordlists.js | 0 packages/testcases/lib/index.d.ts | 62 + packages/testcases/{ => lib}/index.js | 4 +- packages/testcases/package.json | 7 +- .../src.ts/generation-scripts/abi.ts | 4 +- packages/testcases/src.ts/index.ts | 4 +- packages/testcases/tsconfig.json | 6 +- packages/tests/.gitignore | 3 +- packages/tests/lib.esm/_version.d.ts | 1 + packages/tests/lib.esm/_version.js | 1 + packages/tests/lib.esm/browser-ethers.d.ts | 0 .../{tests => lib.esm}/browser-ethers.js | 0 packages/tests/lib.esm/browser.d.ts | 9 + packages/tests/lib.esm/browser.js | 11 + packages/tests/lib.esm/test-account.js | 29 + .../tests/lib.esm/test-contract-interface.js | 477 + packages/tests/lib.esm/test-contract.js | 119 + packages/tests/lib.esm/test-hdnode.js | 83 + packages/tests/lib.esm/test-providers.js | 487 + packages/tests/lib.esm/test-utils.js | 319 + packages/tests/lib.esm/test-wallet.js | 182 + packages/tests/lib.esm/test-wordlists.js | 31 + packages/tests/lib.esm/utils.d.ts | 5 + packages/tests/lib.esm/utils.js | 61 + packages/tests/lib/_version.d.ts | 1 + packages/tests/{tests => lib}/_version.js | 0 packages/tests/lib/browser-ethers.d.ts | 0 packages/tests/lib/browser-ethers.js | 4 + packages/tests/lib/browser.d.ts | 9 + packages/tests/{tests => lib}/browser.js | 0 packages/tests/{tests => lib}/test-account.js | 0 .../{tests => lib}/test-contract-interface.js | 0 .../tests/{tests => lib}/test-contract.js | 0 packages/tests/{tests => lib}/test-hdnode.js | 0 .../tests/{tests => lib}/test-providers.js | 0 packages/tests/{tests => lib}/test-utils.js | 0 packages/tests/{tests => lib}/test-wallet.js | 0 .../tests/{tests => lib}/test-wordlists.js | 0 packages/tests/lib/utils.d.ts | 5 + packages/tests/{tests => lib}/utils.js | 0 packages/tests/package.json | 7 +- packages/tests/tests/reporter.js | 111 - packages/tests/tsconfig.json | 11 +- .../transactions/{ => lib.esm}/_version.d.ts | 0 packages/transactions/lib.esm/_version.js | 1 + .../transactions/{ => lib.esm}/index.d.ts | 0 packages/transactions/lib.esm/index.js | 145 + packages/transactions/lib/_version.d.ts | 1 + packages/transactions/{ => lib}/_version.js | 0 packages/transactions/lib/index.d.ts | 29 + packages/transactions/{ => lib}/index.js | 0 packages/transactions/package.json | 7 +- packages/transactions/tsconfig.json | 7 +- packages/units/{ => lib.esm}/_version.d.ts | 0 packages/units/lib.esm/_version.js | 1 + packages/units/{ => lib.esm}/index.d.ts | 0 packages/units/lib.esm/index.js | 77 + packages/units/lib/_version.d.ts | 1 + packages/units/{ => lib}/_version.js | 0 packages/units/lib/index.d.ts | 6 + packages/units/{ => lib}/index.js | 6 +- packages/units/package.json | 7 +- packages/units/src.ts/index.ts | 2 +- packages/units/tsconfig.json | 7 +- packages/wallet/{ => lib.esm}/_version.d.ts | 0 packages/wallet/lib.esm/_version.js | 1 + packages/wallet/{ => lib.esm}/index.d.ts | 0 packages/wallet/lib.esm/index.js | 131 + packages/wallet/lib/_version.d.ts | 1 + packages/wallet/{ => lib}/_version.js | 0 packages/wallet/lib/index.d.ts | 29 + packages/wallet/{ => lib}/index.js | 0 packages/wallet/package.json | 7 +- packages/wallet/src.ts/index.ts | 2 +- packages/wallet/tsconfig.json | 7 +- packages/web/.gitignore | 1 - packages/web/browser-xmlhttprequest.js | 8 - packages/web/{ => lib.esm}/_version.d.ts | 0 packages/web/lib.esm/_version.js | 1 + packages/web/{ => lib.esm}/index.d.ts | 0 packages/web/lib.esm/index.js | 200 + packages/web/lib/_version.d.ts | 1 + packages/web/{ => lib}/_version.js | 0 packages/web/lib/index.d.ts | 23 + packages/web/{ => lib}/index.js | 0 packages/web/package.json | 7 +- packages/web/tsconfig.json | 9 +- .../wordlists/{ => lib.esm}/_version.d.ts | 0 packages/wordlists/lib.esm/_version.js | 1 + packages/wordlists/{ => lib.esm}/browser.d.ts | 0 packages/wordlists/lib.esm/browser.js | 7 + packages/wordlists/{ => lib.esm}/index.d.ts | 0 packages/wordlists/lib.esm/index.js | 23 + packages/wordlists/{ => lib.esm}/lang-en.d.ts | 0 packages/wordlists/lib.esm/lang-en.js | 30 + packages/wordlists/{ => lib.esm}/lang-es.d.ts | 0 packages/wordlists/lib.esm/lang-es.js | 68 + packages/wordlists/{ => lib.esm}/lang-fr.d.ts | 0 packages/wordlists/lib.esm/lang-fr.js | 67 + packages/wordlists/{ => lib.esm}/lang-it.d.ts | 0 packages/wordlists/lib.esm/lang-it.js | 30 + packages/wordlists/{ => lib.esm}/lang-ja.d.ts | 0 packages/wordlists/lib.esm/lang-ja.js | 126 + packages/wordlists/{ => lib.esm}/lang-ko.d.ts | 0 packages/wordlists/lib.esm/lang-ko.js | 61 + packages/wordlists/{ => lib.esm}/lang-zh.d.ts | 0 packages/wordlists/lib.esm/lang-zh.js | 65 + .../wordlists/{ => lib.esm}/wordlist.d.ts | 0 packages/wordlists/lib.esm/wordlist.js | 52 + packages/wordlists/lib/_version.d.ts | 1 + packages/wordlists/{ => lib}/_version.js | 0 packages/wordlists/lib/browser.d.ts | 5 + packages/wordlists/{ => lib}/browser.js | 0 packages/wordlists/lib/index.d.ts | 5 + packages/wordlists/{ => lib}/index.js | 0 packages/wordlists/lib/lang-en.d.ts | 8 + packages/wordlists/{ => lib}/lang-en.js | 0 packages/wordlists/lib/lang-es.d.ts | 8 + packages/wordlists/{ => lib}/lang-es.js | 0 packages/wordlists/lib/lang-fr.d.ts | 8 + packages/wordlists/{ => lib}/lang-fr.js | 0 packages/wordlists/lib/lang-it.d.ts | 8 + packages/wordlists/{ => lib}/lang-it.js | 0 packages/wordlists/lib/lang-ja.d.ts | 10 + packages/wordlists/{ => lib}/lang-ja.js | 0 packages/wordlists/lib/lang-ko.d.ts | 8 + packages/wordlists/{ => lib}/lang-ko.js | 0 packages/wordlists/lib/lang-zh.d.ts | 10 + packages/wordlists/{ => lib}/lang-zh.js | 0 packages/wordlists/lib/wordlist.d.ts | 10 + packages/wordlists/{ => lib}/wordlist.js | 0 packages/wordlists/package.json | 7 +- packages/wordlists/tsconfig.json | 7 +- rollup.config.js | 115 + tsconfig.package.json | 20 +- 686 files changed, 58756 insertions(+), 447 deletions(-) create mode 100644 admin/cmds/reset-build.js rename packages/abi/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/abi/lib.esm/_version.js rename packages/abi/{ => lib.esm}/abi-coder.d.ts (100%) create mode 100644 packages/abi/lib.esm/abi-coder.js create mode 100644 packages/abi/lib.esm/coders/abstract-coder.d.ts create mode 100644 packages/abi/lib.esm/coders/abstract-coder.js create mode 100644 packages/abi/lib.esm/coders/address.d.ts create mode 100644 packages/abi/lib.esm/coders/address.js create mode 100644 packages/abi/lib.esm/coders/anonymous.d.ts create mode 100644 packages/abi/lib.esm/coders/anonymous.js create mode 100644 packages/abi/lib.esm/coders/array.d.ts create mode 100644 packages/abi/lib.esm/coders/array.js create mode 100644 packages/abi/lib.esm/coders/boolean.d.ts create mode 100644 packages/abi/lib.esm/coders/boolean.js create mode 100644 packages/abi/lib.esm/coders/bytes.d.ts create mode 100644 packages/abi/lib.esm/coders/bytes.js create mode 100644 packages/abi/lib.esm/coders/fixed-bytes.d.ts create mode 100644 packages/abi/lib.esm/coders/fixed-bytes.js create mode 100644 packages/abi/lib.esm/coders/null.d.ts create mode 100644 packages/abi/lib.esm/coders/null.js create mode 100644 packages/abi/lib.esm/coders/number.d.ts create mode 100644 packages/abi/lib.esm/coders/number.js create mode 100644 packages/abi/lib.esm/coders/string.d.ts create mode 100644 packages/abi/lib.esm/coders/string.js create mode 100644 packages/abi/lib.esm/coders/tuple.d.ts create mode 100644 packages/abi/lib.esm/coders/tuple.js rename packages/abi/{ => lib.esm}/fragments.d.ts (100%) create mode 100644 packages/abi/lib.esm/fragments.js rename packages/abi/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/abi/lib.esm/index.js rename packages/abi/{ => lib.esm}/interface.d.ts (100%) create mode 100644 packages/abi/lib.esm/interface.js create mode 100644 packages/abi/lib/_version.d.ts rename packages/abi/{ => lib}/_version.js (100%) create mode 100644 packages/abi/lib/abi-coder.d.ts rename packages/abi/{ => lib}/abi-coder.js (100%) create mode 100644 packages/abi/lib/coders/abstract-coder.d.ts create mode 100644 packages/abi/lib/coders/abstract-coder.js create mode 100644 packages/abi/lib/coders/address.d.ts create mode 100644 packages/abi/lib/coders/address.js create mode 100644 packages/abi/lib/coders/anonymous.d.ts create mode 100644 packages/abi/lib/coders/anonymous.js create mode 100644 packages/abi/lib/coders/array.d.ts create mode 100644 packages/abi/lib/coders/array.js create mode 100644 packages/abi/lib/coders/boolean.d.ts create mode 100644 packages/abi/lib/coders/boolean.js create mode 100644 packages/abi/lib/coders/bytes.d.ts create mode 100644 packages/abi/lib/coders/bytes.js create mode 100644 packages/abi/lib/coders/fixed-bytes.d.ts create mode 100644 packages/abi/lib/coders/fixed-bytes.js create mode 100644 packages/abi/lib/coders/null.d.ts create mode 100644 packages/abi/lib/coders/null.js create mode 100644 packages/abi/lib/coders/number.d.ts create mode 100644 packages/abi/lib/coders/number.js create mode 100644 packages/abi/lib/coders/string.d.ts create mode 100644 packages/abi/lib/coders/string.js create mode 100644 packages/abi/lib/coders/tuple.d.ts create mode 100644 packages/abi/lib/coders/tuple.js create mode 100644 packages/abi/lib/fragments.d.ts rename packages/abi/{ => lib}/fragments.js (100%) create mode 100644 packages/abi/lib/index.d.ts rename packages/abi/{ => lib}/index.js (100%) create mode 100644 packages/abi/lib/interface.d.ts rename packages/abi/{ => lib}/interface.js (100%) delete mode 100644 packages/abi/test-coder.js rename packages/abstract-provider/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/abstract-provider/lib.esm/_version.js rename packages/abstract-provider/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/abstract-provider/lib.esm/index.js create mode 100644 packages/abstract-provider/lib/_version.d.ts rename packages/abstract-provider/{ => lib}/_version.js (100%) create mode 100644 packages/abstract-provider/lib/index.d.ts rename packages/abstract-provider/{ => lib}/index.js (100%) rename packages/abstract-signer/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/abstract-signer/lib.esm/_version.js rename packages/abstract-signer/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/abstract-signer/lib.esm/index.js create mode 100644 packages/abstract-signer/lib/_version.d.ts rename packages/abstract-signer/{ => lib}/_version.js (100%) create mode 100644 packages/abstract-signer/lib/index.d.ts rename packages/abstract-signer/{ => lib}/index.js (100%) rename packages/address/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/address/lib.esm/_version.js rename packages/address/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/address/lib.esm/index.js create mode 100644 packages/address/lib/_version.d.ts rename packages/address/{ => lib}/_version.js (100%) create mode 100644 packages/address/lib/index.d.ts rename packages/address/{ => lib}/index.js (100%) rename packages/base64/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/base64/lib.esm/_version.js create mode 100644 packages/base64/lib.esm/browser.js rename packages/base64/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/base64/lib.esm/index.js create mode 100644 packages/base64/lib/_version.d.ts rename packages/base64/{ => lib}/_version.js (100%) rename packages/base64/{ => lib}/browser.js (100%) create mode 100644 packages/base64/lib/index.d.ts rename packages/base64/{ => lib}/index.js (100%) rename packages/basex/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/basex/lib.esm/_version.js rename packages/basex/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/basex/lib.esm/index.js create mode 100644 packages/basex/lib/_version.d.ts rename packages/basex/{ => lib}/_version.js (100%) create mode 100644 packages/basex/lib/index.d.ts rename packages/basex/{ => lib}/index.js (100%) rename packages/bignumber/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/bignumber/lib.esm/_version.js rename packages/bignumber/{ => lib.esm}/bignumber.d.ts (100%) create mode 100644 packages/bignumber/lib.esm/bignumber.js rename packages/bignumber/{ => lib.esm}/fixednumber.d.ts (100%) create mode 100644 packages/bignumber/lib.esm/fixednumber.js rename packages/bignumber/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/bignumber/lib.esm/index.js create mode 100644 packages/bignumber/lib/_version.d.ts rename packages/bignumber/{ => lib}/_version.js (100%) create mode 100644 packages/bignumber/lib/bignumber.d.ts rename packages/bignumber/{ => lib}/bignumber.js (100%) create mode 100644 packages/bignumber/lib/fixednumber.d.ts rename packages/bignumber/{ => lib}/fixednumber.js (100%) create mode 100644 packages/bignumber/lib/index.d.ts rename packages/bignumber/{ => lib}/index.js (63%) rename packages/bytes/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/bytes/lib.esm/_version.js rename packages/bytes/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/bytes/lib.esm/index.js create mode 100644 packages/bytes/lib/_version.d.ts rename packages/bytes/{ => lib}/_version.js (100%) create mode 100644 packages/bytes/lib/index.d.ts rename packages/bytes/{ => lib}/index.js (100%) create mode 100644 packages/cli/.npmignore rename packages/cli/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/cli/lib.esm/_version.js create mode 100644 packages/cli/lib.esm/bin/ethers-ens.js create mode 100644 packages/cli/lib.esm/bin/ethers-ts.js create mode 100644 packages/cli/lib.esm/bin/ethers.js rename packages/cli/{ => lib.esm}/cli.d.ts (100%) create mode 100644 packages/cli/lib.esm/cli.js rename packages/cli/{ => lib.esm}/prompt.d.ts (100%) create mode 100644 packages/cli/lib.esm/prompt.js rename packages/cli/{ => lib.esm}/solc.d.ts (100%) create mode 100644 packages/cli/lib.esm/solc.js rename packages/cli/{ => lib.esm}/typescript.d.ts (100%) create mode 100644 packages/cli/lib.esm/typescript.js create mode 100644 packages/cli/lib/_version.d.ts rename packages/cli/{ => lib}/_version.js (100%) rename packages/cli/{ => lib}/bin/ethers-ens.js (100%) mode change 100755 => 100644 rename packages/cli/{ => lib}/bin/ethers-ts.js (100%) mode change 100755 => 100644 rename packages/cli/{ => lib}/bin/ethers.js (100%) mode change 100755 => 100644 create mode 100644 packages/cli/lib/cli.d.ts rename packages/cli/{ => lib}/cli.js (100%) create mode 100644 packages/cli/lib/index.d.ts create mode 100644 packages/cli/lib/index.js create mode 100644 packages/cli/lib/prompt.d.ts rename packages/cli/{ => lib}/prompt.js (100%) create mode 100644 packages/cli/lib/solc.d.ts rename packages/cli/{ => lib}/solc.js (100%) create mode 100644 packages/cli/lib/typescript.d.ts rename packages/cli/{ => lib}/typescript.js (100%) create mode 100644 packages/cli/src.ts/index.ts rename packages/constants/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/constants/lib.esm/_version.js rename packages/constants/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/constants/lib.esm/index.js create mode 100644 packages/constants/lib/_version.d.ts rename packages/constants/{ => lib}/_version.js (100%) create mode 100644 packages/constants/lib/index.d.ts rename packages/constants/{ => lib}/index.js (100%) rename packages/contracts/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/contracts/lib.esm/_version.js rename packages/contracts/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/contracts/lib.esm/index.js create mode 100644 packages/contracts/lib/_version.d.ts rename packages/contracts/{ => lib}/_version.js (100%) create mode 100644 packages/contracts/lib/index.d.ts rename packages/contracts/{ => lib}/index.js (100%) rename packages/errors/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/errors/lib.esm/_version.js rename packages/errors/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/errors/lib.esm/index.js create mode 100644 packages/errors/lib/_version.d.ts rename packages/errors/{ => lib}/_version.js (100%) create mode 100644 packages/errors/lib/index.d.ts rename packages/errors/{ => lib}/index.js (100%) create mode 100644 packages/ethers/dist/ethers.esm.js create mode 100644 packages/ethers/dist/ethers.esm.min.js create mode 100644 packages/ethers/dist/ethers.umd.js create mode 100644 packages/ethers/dist/ethers.umd.min.js rename packages/ethers/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/ethers/lib.esm/_version.js rename packages/ethers/{ => lib.esm}/browser-platform.d.ts (100%) create mode 100644 packages/ethers/lib.esm/browser-platform.js rename packages/ethers/{ => lib.esm}/ethers.d.ts (100%) create mode 100644 packages/ethers/lib.esm/ethers.js rename packages/ethers/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/ethers/lib.esm/index.js rename packages/ethers/{ => lib.esm}/platform.d.ts (100%) create mode 100644 packages/ethers/lib.esm/platform.js rename packages/ethers/{ => lib.esm}/utils.d.ts (100%) create mode 100644 packages/ethers/lib.esm/utils.js create mode 100644 packages/ethers/lib/_version.d.ts rename packages/ethers/{ => lib}/_version.js (100%) create mode 100644 packages/ethers/lib/browser-platform.d.ts rename packages/ethers/{ => lib}/browser-platform.js (100%) create mode 100644 packages/ethers/lib/ethers.d.ts rename packages/ethers/{ => lib}/ethers.js (100%) create mode 100644 packages/ethers/lib/index.d.ts rename packages/ethers/{ => lib}/index.js (100%) create mode 100644 packages/ethers/lib/platform.d.ts rename packages/ethers/{ => lib}/platform.js (100%) create mode 100644 packages/ethers/lib/utils.d.ts rename packages/ethers/{ => lib}/utils.js (100%) rename packages/experimental/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/experimental/lib.esm/_version.js rename packages/experimental/{ => lib.esm}/brain-wallet.d.ts (100%) create mode 100644 packages/experimental/lib.esm/brain-wallet.js rename packages/experimental/{ => lib.esm}/index.d.ts (100%) rename packages/experimental/{ => lib.esm}/index.js (100%) rename packages/experimental/{ => lib.esm}/metamask-provider.d.ts (100%) create mode 100644 packages/experimental/lib.esm/metamask-provider.js rename packages/experimental/{ => lib.esm}/nonce-manager.d.ts (100%) create mode 100644 packages/experimental/lib.esm/nonce-manager.js rename packages/experimental/{ => lib.esm}/retry-provider.d.ts (100%) create mode 100644 packages/experimental/lib.esm/retry-provider.js create mode 100644 packages/experimental/lib/_version.d.ts rename packages/experimental/{ => lib}/_version.js (100%) create mode 100644 packages/experimental/lib/brain-wallet.d.ts rename packages/experimental/{ => lib}/brain-wallet.js (100%) rename packages/{providers/browser-ipc-provider.d.ts => experimental/lib/index.d.ts} (100%) create mode 100644 packages/experimental/lib/index.js create mode 100644 packages/experimental/lib/metamask-provider.d.ts rename packages/experimental/{ => lib}/metamask-provider.js (100%) create mode 100644 packages/experimental/lib/nonce-manager.d.ts rename packages/experimental/{ => lib}/nonce-manager.js (100%) create mode 100644 packages/experimental/lib/retry-provider.d.ts rename packages/experimental/{ => lib}/retry-provider.js (100%) rename packages/hash/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/hash/lib.esm/_version.js rename packages/hash/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/hash/lib.esm/index.js create mode 100644 packages/hash/lib/_version.d.ts rename packages/hash/{ => lib}/_version.js (100%) create mode 100644 packages/hash/lib/index.d.ts rename packages/hash/{ => lib}/index.js (100%) rename packages/hdnode/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/hdnode/lib.esm/_version.js rename packages/hdnode/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/hdnode/lib.esm/index.js create mode 100644 packages/hdnode/lib/_version.d.ts rename packages/hdnode/{ => lib}/_version.js (100%) create mode 100644 packages/hdnode/lib/index.d.ts rename packages/hdnode/{ => lib}/index.js (100%) rename packages/json-wallets/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/json-wallets/lib.esm/_version.js rename packages/json-wallets/{ => lib.esm}/crowdsale.d.ts (100%) create mode 100644 packages/json-wallets/lib.esm/crowdsale.js rename packages/json-wallets/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/json-wallets/lib.esm/index.js rename packages/json-wallets/{ => lib.esm}/inspect.d.ts (100%) create mode 100644 packages/json-wallets/lib.esm/inspect.js rename packages/json-wallets/{ => lib.esm}/keystore.d.ts (100%) create mode 100644 packages/json-wallets/lib.esm/keystore.js rename packages/json-wallets/{ => lib.esm}/utils.d.ts (100%) create mode 100644 packages/json-wallets/lib.esm/utils.js create mode 100644 packages/json-wallets/lib/_version.d.ts rename packages/json-wallets/{ => lib}/_version.js (100%) create mode 100644 packages/json-wallets/lib/crowdsale.d.ts rename packages/json-wallets/{ => lib}/crowdsale.js (100%) create mode 100644 packages/json-wallets/lib/index.d.ts rename packages/json-wallets/{ => lib}/index.js (100%) create mode 100644 packages/json-wallets/lib/inspect.d.ts rename packages/json-wallets/{ => lib}/inspect.js (100%) create mode 100644 packages/json-wallets/lib/keystore.d.ts rename packages/json-wallets/{ => lib}/keystore.js (100%) create mode 100644 packages/json-wallets/lib/utils.d.ts rename packages/json-wallets/{ => lib}/utils.js (100%) rename packages/keccak256/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/keccak256/lib.esm/_version.js rename packages/keccak256/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/keccak256/lib.esm/index.js create mode 100644 packages/keccak256/lib/_version.d.ts rename packages/keccak256/{ => lib}/_version.js (100%) create mode 100644 packages/keccak256/lib/index.d.ts rename packages/keccak256/{ => lib}/index.js (100%) rename packages/logger/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/logger/lib.esm/_version.js rename packages/logger/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/logger/lib.esm/index.js create mode 100644 packages/logger/lib/_version.d.ts rename packages/logger/{ => lib}/_version.js (100%) create mode 100644 packages/logger/lib/index.d.ts rename packages/logger/{ => lib}/index.js (100%) rename packages/networks/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/networks/lib.esm/_version.js rename packages/networks/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/networks/lib.esm/index.js rename packages/networks/{ => lib.esm}/types.d.ts (100%) create mode 100644 packages/networks/lib.esm/types.js create mode 100644 packages/networks/lib/_version.d.ts rename packages/networks/{ => lib}/_version.js (100%) create mode 100644 packages/networks/lib/index.d.ts rename packages/networks/{ => lib}/index.js (100%) create mode 100644 packages/networks/lib/types.d.ts rename packages/networks/{ => lib}/types.js (100%) rename packages/pbkdf2/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/pbkdf2/lib.esm/_version.js create mode 100644 packages/pbkdf2/lib.esm/browser.js rename packages/pbkdf2/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/pbkdf2/lib.esm/index.js create mode 100644 packages/pbkdf2/lib/_version.d.ts rename packages/pbkdf2/{ => lib}/_version.js (100%) rename packages/pbkdf2/{ => lib}/browser.js (100%) create mode 100644 packages/pbkdf2/lib/index.d.ts rename packages/pbkdf2/{ => lib}/index.js (100%) rename packages/properties/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/properties/lib.esm/_version.js rename packages/properties/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/properties/lib.esm/index.js create mode 100644 packages/properties/lib/_version.d.ts rename packages/properties/{ => lib}/_version.js (100%) create mode 100644 packages/properties/lib/index.d.ts rename packages/properties/{ => lib}/index.js (100%) rename packages/providers/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/providers/lib.esm/_version.js rename packages/providers/{ => lib.esm}/alchemy-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/alchemy-provider.js rename packages/providers/{ => lib.esm}/base-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/base-provider.js rename packages/providers/{browser-net.d.ts => lib.esm/browser-ipc-provider.d.ts} (100%) rename packages/providers/{ => lib.esm}/browser-ipc-provider.js (100%) create mode 100644 packages/providers/lib.esm/browser-net.d.ts rename packages/providers/{ => lib.esm}/browser-net.js (100%) rename packages/providers/{ => lib.esm}/cloudflare-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/cloudflare-provider.js rename packages/providers/{ => lib.esm}/etherscan-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/etherscan-provider.js rename packages/providers/{ => lib.esm}/fallback-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/fallback-provider.js rename packages/providers/{ => lib.esm}/formatter.d.ts (100%) create mode 100644 packages/providers/lib.esm/formatter.js rename packages/providers/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/providers/lib.esm/index.js rename packages/providers/{ => lib.esm}/infura-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/infura-provider.js rename packages/providers/{ => lib.esm}/ipc-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/ipc-provider.js rename packages/providers/{ => lib.esm}/json-rpc-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/json-rpc-provider.js rename packages/providers/{ => lib.esm}/nodesmith-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/nodesmith-provider.js rename packages/providers/{ => lib.esm}/url-json-rpc-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/url-json-rpc-provider.js rename packages/providers/{ => lib.esm}/web3-provider.d.ts (100%) create mode 100644 packages/providers/lib.esm/web3-provider.js create mode 100644 packages/providers/lib/_version.d.ts rename packages/providers/{ => lib}/_version.js (100%) create mode 100644 packages/providers/lib/alchemy-provider.d.ts rename packages/providers/{ => lib}/alchemy-provider.js (100%) create mode 100644 packages/providers/lib/base-provider.d.ts rename packages/providers/{ => lib}/base-provider.js (100%) create mode 100644 packages/providers/lib/browser-ipc-provider.d.ts create mode 100644 packages/providers/lib/browser-ipc-provider.js create mode 100644 packages/providers/lib/browser-net.d.ts create mode 100644 packages/providers/lib/browser-net.js create mode 100644 packages/providers/lib/cloudflare-provider.d.ts rename packages/providers/{ => lib}/cloudflare-provider.js (100%) create mode 100644 packages/providers/lib/etherscan-provider.d.ts rename packages/providers/{ => lib}/etherscan-provider.js (100%) create mode 100644 packages/providers/lib/fallback-provider.d.ts rename packages/providers/{ => lib}/fallback-provider.js (100%) create mode 100644 packages/providers/lib/formatter.d.ts rename packages/providers/{ => lib}/formatter.js (100%) create mode 100644 packages/providers/lib/index.d.ts rename packages/providers/{ => lib}/index.js (100%) create mode 100644 packages/providers/lib/infura-provider.d.ts rename packages/providers/{ => lib}/infura-provider.js (100%) create mode 100644 packages/providers/lib/ipc-provider.d.ts rename packages/providers/{ => lib}/ipc-provider.js (100%) create mode 100644 packages/providers/lib/json-rpc-provider.d.ts rename packages/providers/{ => lib}/json-rpc-provider.js (100%) create mode 100644 packages/providers/lib/nodesmith-provider.d.ts rename packages/providers/{ => lib}/nodesmith-provider.js (100%) create mode 100644 packages/providers/lib/url-json-rpc-provider.d.ts rename packages/providers/{ => lib}/url-json-rpc-provider.js (100%) create mode 100644 packages/providers/lib/web3-provider.d.ts rename packages/providers/{ => lib}/web3-provider.js (100%) rename packages/random/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/random/lib.esm/_version.js create mode 100644 packages/random/lib.esm/browser.js rename packages/random/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/random/lib.esm/index.js rename packages/random/{ => lib.esm}/shuffle.d.ts (100%) create mode 100644 packages/random/lib.esm/shuffle.js create mode 100644 packages/random/lib/_version.d.ts rename packages/random/{ => lib}/_version.js (100%) rename packages/random/{ => lib}/browser.js (100%) create mode 100644 packages/random/lib/index.d.ts rename packages/random/{ => lib}/index.js (100%) create mode 100644 packages/random/lib/shuffle.d.ts rename packages/random/{ => lib}/shuffle.js (100%) rename packages/rlp/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/rlp/lib.esm/_version.js rename packages/rlp/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/rlp/lib.esm/index.js create mode 100644 packages/rlp/lib/_version.d.ts rename packages/rlp/{ => lib}/_version.js (100%) create mode 100644 packages/rlp/lib/index.d.ts rename packages/rlp/{ => lib}/index.js (100%) rename packages/sha2/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/sha2/lib.esm/_version.js create mode 100644 packages/sha2/lib.esm/browser.js rename packages/sha2/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/sha2/lib.esm/index.js create mode 100644 packages/sha2/lib/_version.d.ts rename packages/sha2/{ => lib}/_version.js (100%) rename packages/sha2/{ => lib}/browser.js (100%) create mode 100644 packages/sha2/lib/index.d.ts rename packages/sha2/{ => lib}/index.js (100%) rename packages/signing-key/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/signing-key/lib.esm/_version.js rename packages/signing-key/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/signing-key/lib.esm/index.js create mode 100644 packages/signing-key/lib/_version.d.ts rename packages/signing-key/{ => lib}/_version.js (100%) create mode 100644 packages/signing-key/lib/index.d.ts rename packages/signing-key/{ => lib}/index.js (100%) rename packages/solidity/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/solidity/lib.esm/_version.js rename packages/solidity/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/solidity/lib.esm/index.js create mode 100644 packages/solidity/lib/_version.d.ts rename packages/solidity/{ => lib}/_version.js (100%) create mode 100644 packages/solidity/lib/index.d.ts rename packages/solidity/{ => lib}/index.js (100%) rename packages/strings/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/strings/lib.esm/_version.js rename packages/strings/{ => lib.esm}/bytes32.d.ts (100%) create mode 100644 packages/strings/lib.esm/bytes32.js rename packages/strings/{ => lib.esm}/idna.d.ts (100%) create mode 100644 packages/strings/lib.esm/idna.js rename packages/strings/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/strings/lib.esm/index.js rename packages/strings/{ => lib.esm}/utf8.d.ts (100%) create mode 100644 packages/strings/lib.esm/utf8.js create mode 100644 packages/strings/lib/_version.d.ts rename packages/strings/{ => lib}/_version.js (100%) create mode 100644 packages/strings/lib/bytes32.d.ts rename packages/strings/{ => lib}/bytes32.js (100%) create mode 100644 packages/strings/lib/idna.d.ts rename packages/strings/{ => lib}/idna.js (100%) create mode 100644 packages/strings/lib/index.d.ts rename packages/strings/{ => lib}/index.js (97%) create mode 100644 packages/strings/lib/utf8.d.ts rename packages/strings/{ => lib}/utf8.js (100%) rename packages/testcases/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/testcases/lib.esm/_version.js rename packages/testcases/{ => lib.esm}/browser-fs.json (100%) rename packages/testcases/{ => lib.esm}/browser.d.ts (100%) create mode 100644 packages/testcases/lib.esm/browser.js create mode 100644 packages/testcases/lib.esm/generation-scripts/abi.js create mode 100644 packages/testcases/lib.esm/generation-scripts/hdnode.js create mode 100644 packages/testcases/lib.esm/generation-scripts/nameprep.js create mode 100644 packages/testcases/lib.esm/generation-scripts/units.js create mode 100644 packages/testcases/lib.esm/generation-scripts/wallets.js create mode 100644 packages/testcases/lib.esm/generation-scripts/wordlists.js rename packages/testcases/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/testcases/lib.esm/index.js create mode 100644 packages/testcases/lib/_version.d.ts rename packages/testcases/{ => lib}/_version.js (100%) create mode 100644 packages/testcases/lib/browser-fs.json create mode 100644 packages/testcases/lib/browser.d.ts rename packages/testcases/{ => lib}/browser.js (100%) rename packages/testcases/{ => lib}/generation-scripts/abi.js (99%) rename packages/testcases/{ => lib}/generation-scripts/hdnode.js (100%) rename packages/testcases/{ => lib}/generation-scripts/nameprep.js (100%) rename packages/testcases/{ => lib}/generation-scripts/units.js (100%) rename packages/testcases/{ => lib}/generation-scripts/wallets.js (100%) rename packages/testcases/{ => lib}/generation-scripts/wordlists.js (100%) create mode 100644 packages/testcases/lib/index.d.ts rename packages/testcases/{ => lib}/index.js (92%) create mode 100644 packages/tests/lib.esm/_version.d.ts create mode 100644 packages/tests/lib.esm/_version.js create mode 100644 packages/tests/lib.esm/browser-ethers.d.ts rename packages/tests/{tests => lib.esm}/browser-ethers.js (100%) create mode 100644 packages/tests/lib.esm/browser.d.ts create mode 100644 packages/tests/lib.esm/browser.js create mode 100644 packages/tests/lib.esm/test-account.js create mode 100644 packages/tests/lib.esm/test-contract-interface.js create mode 100644 packages/tests/lib.esm/test-contract.js create mode 100644 packages/tests/lib.esm/test-hdnode.js create mode 100644 packages/tests/lib.esm/test-providers.js create mode 100644 packages/tests/lib.esm/test-utils.js create mode 100644 packages/tests/lib.esm/test-wallet.js create mode 100644 packages/tests/lib.esm/test-wordlists.js create mode 100644 packages/tests/lib.esm/utils.d.ts create mode 100644 packages/tests/lib.esm/utils.js create mode 100644 packages/tests/lib/_version.d.ts rename packages/tests/{tests => lib}/_version.js (100%) create mode 100644 packages/tests/lib/browser-ethers.d.ts create mode 100644 packages/tests/lib/browser-ethers.js create mode 100644 packages/tests/lib/browser.d.ts rename packages/tests/{tests => lib}/browser.js (100%) rename packages/tests/{tests => lib}/test-account.js (100%) rename packages/tests/{tests => lib}/test-contract-interface.js (100%) rename packages/tests/{tests => lib}/test-contract.js (100%) rename packages/tests/{tests => lib}/test-hdnode.js (100%) rename packages/tests/{tests => lib}/test-providers.js (100%) rename packages/tests/{tests => lib}/test-utils.js (100%) rename packages/tests/{tests => lib}/test-wallet.js (100%) rename packages/tests/{tests => lib}/test-wordlists.js (100%) create mode 100644 packages/tests/lib/utils.d.ts rename packages/tests/{tests => lib}/utils.js (100%) delete mode 100644 packages/tests/tests/reporter.js rename packages/transactions/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/transactions/lib.esm/_version.js rename packages/transactions/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/transactions/lib.esm/index.js create mode 100644 packages/transactions/lib/_version.d.ts rename packages/transactions/{ => lib}/_version.js (100%) create mode 100644 packages/transactions/lib/index.d.ts rename packages/transactions/{ => lib}/index.js (100%) rename packages/units/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/units/lib.esm/_version.js rename packages/units/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/units/lib.esm/index.js create mode 100644 packages/units/lib/_version.d.ts rename packages/units/{ => lib}/_version.js (100%) create mode 100644 packages/units/lib/index.d.ts rename packages/units/{ => lib}/index.js (90%) rename packages/wallet/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/wallet/lib.esm/_version.js rename packages/wallet/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/wallet/lib.esm/index.js create mode 100644 packages/wallet/lib/_version.d.ts rename packages/wallet/{ => lib}/_version.js (100%) create mode 100644 packages/wallet/lib/index.d.ts rename packages/wallet/{ => lib}/index.js (100%) delete mode 100644 packages/web/.gitignore delete mode 100644 packages/web/browser-xmlhttprequest.js rename packages/web/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/web/lib.esm/_version.js rename packages/web/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/web/lib.esm/index.js create mode 100644 packages/web/lib/_version.d.ts rename packages/web/{ => lib}/_version.js (100%) create mode 100644 packages/web/lib/index.d.ts rename packages/web/{ => lib}/index.js (100%) rename packages/wordlists/{ => lib.esm}/_version.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/_version.js rename packages/wordlists/{ => lib.esm}/browser.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/browser.js rename packages/wordlists/{ => lib.esm}/index.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/index.js rename packages/wordlists/{ => lib.esm}/lang-en.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-en.js rename packages/wordlists/{ => lib.esm}/lang-es.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-es.js rename packages/wordlists/{ => lib.esm}/lang-fr.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-fr.js rename packages/wordlists/{ => lib.esm}/lang-it.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-it.js rename packages/wordlists/{ => lib.esm}/lang-ja.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-ja.js rename packages/wordlists/{ => lib.esm}/lang-ko.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-ko.js rename packages/wordlists/{ => lib.esm}/lang-zh.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/lang-zh.js rename packages/wordlists/{ => lib.esm}/wordlist.d.ts (100%) create mode 100644 packages/wordlists/lib.esm/wordlist.js create mode 100644 packages/wordlists/lib/_version.d.ts rename packages/wordlists/{ => lib}/_version.js (100%) create mode 100644 packages/wordlists/lib/browser.d.ts rename packages/wordlists/{ => lib}/browser.js (100%) create mode 100644 packages/wordlists/lib/index.d.ts rename packages/wordlists/{ => lib}/index.js (100%) create mode 100644 packages/wordlists/lib/lang-en.d.ts rename packages/wordlists/{ => lib}/lang-en.js (100%) create mode 100644 packages/wordlists/lib/lang-es.d.ts rename packages/wordlists/{ => lib}/lang-es.js (100%) create mode 100644 packages/wordlists/lib/lang-fr.d.ts rename packages/wordlists/{ => lib}/lang-fr.js (100%) create mode 100644 packages/wordlists/lib/lang-it.d.ts rename packages/wordlists/{ => lib}/lang-it.js (100%) create mode 100644 packages/wordlists/lib/lang-ja.d.ts rename packages/wordlists/{ => lib}/lang-ja.js (100%) create mode 100644 packages/wordlists/lib/lang-ko.d.ts rename packages/wordlists/{ => lib}/lang-ko.js (100%) create mode 100644 packages/wordlists/lib/lang-zh.d.ts rename packages/wordlists/{ => lib}/lang-zh.js (100%) create mode 100644 packages/wordlists/lib/wordlist.d.ts rename packages/wordlists/{ => lib}/wordlist.js (100%) create mode 100644 rollup.config.js diff --git a/admin/build.js b/admin/build.js index 9e912a0fa..a410d202c 100644 --- a/admin/build.js +++ b/admin/build.js @@ -4,7 +4,9 @@ const fs = require("fs"); const resolve = require("path").resolve; const spawn = require("child_process").spawn; -const local = require("./local"); +const { dirnames } = require("./local"); +const { loadPackage } = require("./depgraph"); +const { loadJson, saveJson } = require("./utils"); function run(progname, args, ignoreErrorStream) { return new Promise((resolve, reject) => { @@ -46,8 +48,37 @@ function run(progname, args, ignoreErrorStream) { }); } -function runBuild() { - return run("npx", [ "tsc", "--build", resolve(__dirname, "../tsconfig.project.json") ]); +function setupConfig(outDir, moduleType, targetType) { + // Configure the tsconfit.package.json... + const path = resolve(__dirname, "../tsconfig.package.json"); + const content = loadJson(path); + content.compilerOptions.module = moduleType; + content.compilerOptions.target = targetType; + saveJson(path, content); + + dirnames.forEach((dirname) => { + if (loadPackage(dirname)._ethers_nobuild) { return; } + + let path = resolve(__dirname, "../packages", dirname, "tsconfig.json"); + let content = loadJson(path); + content.compilerOptions.outDir = outDir; + saveJson(path, content); + }); +} + +function setupBuild(buildModule) { + if (buildModule) { + setupConfig("./lib.esm/", "es2015", "es2015"); + } else { + setupConfig("./lib/", "commonjs", "es5"); + } +} + +function runBuild(buildModule) { + setupBuild(buildModule); + + // Compile + return run("npx", [ "tsc", "--build", resolve(__dirname, "../tsconfig.project.json"), "--force" ]); } function runDist() { @@ -57,5 +88,6 @@ function runDist() { module.exports = { run: run, runDist: runDist, - runBuild: runBuild + runBuild: runBuild, + setupBuild: setupBuild }; diff --git a/admin/cmds/reset-build.js b/admin/cmds/reset-build.js new file mode 100644 index 000000000..d9bf95a65 --- /dev/null +++ b/admin/cmds/reset-build.js @@ -0,0 +1,5 @@ +"use strict"; + +const { setupBuild } = require("../build"); + +setupBuild(false); diff --git a/admin/cmds/update-versions.js b/admin/cmds/update-versions.js index 3515db523..dc420353c 100644 --- a/admin/cmds/update-versions.js +++ b/admin/cmds/update-versions.js @@ -41,7 +41,6 @@ if (process.argv.length > 2) { } (async function() { - let progress = getProgressBar(colorify("Updating versions", "bold")); for (let i = 0; i < dirnames.length; i++) { @@ -85,7 +84,9 @@ if (process.argv.length > 2) { progress(1); try { - log(""); + log(""); + await runBuild(true); + log(""); await runBuild(); log(""); let content = await runDist(); diff --git a/admin/local.js b/admin/local.js index 415951cf2..4bc42b0f9 100644 --- a/admin/local.js +++ b/admin/local.js @@ -2,7 +2,16 @@ const packlist = require("npm-packlist"); const tar = require("tar"); -const keccak256 = require("../packages/keccak256").keccak256; + +const keccak256 = (function() { + try { + return require("../packages/keccak256").keccak256; + } catch (error) { + console.log("Cannot load Keccak256 (maybe not built yet? Not really a problem for most things)"); + return null; + } +})(); + const { dirnames, loadPackage, ROOT } = require("./depgraph"); const { resolve, saveJson } = require("./utils"); diff --git a/package.json b/package.json index 9a9959d16..4b2445cee 100644 --- a/package.json +++ b/package.json @@ -2,19 +2,30 @@ "name": "root", "private": true, "scripts": { - "auto-build": "npm run build -- -w", - "bootstrap": "node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", + "auto-build": "node ./admin/cmds/reset-build.js && npm run build -- -w", + "bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", "build": "tsc --build ./tsconfig.project.json", - "clean": "tsc --build --clean ./tsconfig.project.json", - "_dist": "npm run clean && npm run bootstrap && npm run build && lerna run dist", - "test": "npm run _dist && npm run test-check", - "test-check": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi", - "test-node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js", - "test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js", - "test-aion": "npm run dist && npm run test-aion-node", - "test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js", - "update-versions": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-versions", - "publish-all": "node ./admin/cmds/publish" + "clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json", + + "_dist_prepare": "npm run clean && npm run bootstrap && npm run build", + "_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify", + "_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", + + "_test_prepare": "npm run _dist_prepare && npm run _dist_tests", + "_test_node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js", + "test_node": "npm run _test_prepare && npm run _test_node", + + "_dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist", + "old-test": "npm run _dist_old && npm run test-check", + "old-test-check": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi", + "old-test-node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js", + "old-test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js", + "old-test-aion": "npm run dist && npm run test-aion-node", + "old-test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js", + + "update-versions": "npm run _dist_prepare && node ./admin/cmds/update-versions", + "publish-all": "node ./admin/cmds/publish", + "build-docs": "flatworm docs.wrm docs" }, "devDependencies": { "@types/assert": "^1.4.1", @@ -30,6 +41,13 @@ "scrypt-js": "2.0.4", "semver": "^5.6.0", "tar": "4.4.8", - "typescript": "3.3.3" + "typescript": "3.3.3", + "rollup": "1.20.1", + "rollup-plugin-commonjs": "10.0.2", + "rollup-plugin-json": "4.0.0", + "rollup-plugin-node-resolve": "5.2.0", + "rollup-plugin-terser": "5.1.1", + "rollup-plugin-uglify": "6.0.2", + "rollup-pluginutils": "2.8.1" } } diff --git a/packages/abi/_version.d.ts b/packages/abi/lib.esm/_version.d.ts similarity index 100% rename from packages/abi/_version.d.ts rename to packages/abi/lib.esm/_version.d.ts diff --git a/packages/abi/lib.esm/_version.js b/packages/abi/lib.esm/_version.js new file mode 100644 index 000000000..0096028ad --- /dev/null +++ b/packages/abi/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "abi/5.0.0-beta.136"; diff --git a/packages/abi/abi-coder.d.ts b/packages/abi/lib.esm/abi-coder.d.ts similarity index 100% rename from packages/abi/abi-coder.d.ts rename to packages/abi/lib.esm/abi-coder.d.ts diff --git a/packages/abi/lib.esm/abi-coder.js b/packages/abi/lib.esm/abi-coder.js new file mode 100644 index 000000000..545ce292b --- /dev/null +++ b/packages/abi/lib.esm/abi-coder.js @@ -0,0 +1,91 @@ +"use strict"; +// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI +import { arrayify } from "@ethersproject/bytes"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { Reader, Writer } from "./coders/abstract-coder"; +import { AddressCoder } from "./coders/address"; +import { ArrayCoder } from "./coders/array"; +import { BooleanCoder } from "./coders/boolean"; +import { BytesCoder } from "./coders/bytes"; +import { FixedBytesCoder } from "./coders/fixed-bytes"; +import { NullCoder } from "./coders/null"; +import { NumberCoder } from "./coders/number"; +import { StringCoder } from "./coders/string"; +import { TupleCoder } from "./coders/tuple"; +import { ParamType } from "./fragments"; +const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); +const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); +export class AbiCoder { + constructor(coerceFunc) { + logger.checkNew(new.target, AbiCoder); + defineReadOnly(this, "coerceFunc", coerceFunc || null); + } + _getCoder(param) { + switch (param.baseType) { + case "address": + return new AddressCoder(param.name); + case "bool": + return new BooleanCoder(param.name); + case "string": + return new StringCoder(param.name); + case "bytes": + return new BytesCoder(param.name); + case "array": + return new ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); + case "tuple": + return new TupleCoder((param.components || []).map((component) => { + return this._getCoder(component); + }), param.name); + case "": + return new NullCoder(param.name); + } + // u?int[0-9]* + let match = param.type.match(paramTypeNumber); + if (match) { + let size = parseInt(match[2] || "256"); + if (size === 0 || size > 256 || (size % 8) !== 0) { + logger.throwArgumentError("invalid " + match[1] + " bit length", "param", param); + } + return new NumberCoder(size / 8, (match[1] === "int"), param.name); + } + // bytes[0-9]+ + match = param.type.match(paramTypeBytes); + if (match) { + let size = parseInt(match[1]); + if (size === 0 || size > 32) { + logger.throwArgumentError("invalid bytes length", "param", param); + } + return new FixedBytesCoder(size, param.name); + } + return logger.throwError("invalid type", "type", param.type); + } + _getWordSize() { return 32; } + _getReader(data) { + return new Reader(data, this._getWordSize(), this.coerceFunc); + } + _getWriter() { + return new Writer(this._getWordSize()); + } + encode(types, values) { + if (types.length !== values.length) { + logger.throwError("types/values length mismatch", Logger.errors.INVALID_ARGUMENT, { + count: { types: types.length, values: values.length }, + value: { types: types, values: values } + }); + } + let coders = types.map((type) => this._getCoder(ParamType.from(type))); + let coder = (new TupleCoder(coders, "_")); + let writer = this._getWriter(); + coder.encode(writer, values); + return writer.data; + } + decode(types, data) { + let coders = types.map((type) => this._getCoder(ParamType.from(type))); + let coder = new TupleCoder(coders, "_"); + return coder.decode(this._getReader(arrayify(data))); + } +} +export const defaultAbiCoder = new AbiCoder(); diff --git a/packages/abi/lib.esm/coders/abstract-coder.d.ts b/packages/abi/lib.esm/coders/abstract-coder.d.ts new file mode 100644 index 000000000..6ff64f603 --- /dev/null +++ b/packages/abi/lib.esm/coders/abstract-coder.d.ts @@ -0,0 +1,41 @@ +import { BytesLike } from "@ethersproject/bytes"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +export declare type CoerceFunc = (type: string, value: any) => any; +export declare abstract class Coder { + readonly name: string; + readonly type: string; + readonly localName: string; + readonly dynamic: boolean; + constructor(name: string, type: string, localName: string, dynamic: boolean); + _throwError(message: string, value: any): void; + abstract encode(writer: Writer, value: any): number; + abstract decode(reader: Reader): any; +} +export declare class Writer { + readonly wordSize: number; + _data: Uint8Array; + _padding: Uint8Array; + constructor(wordSize?: number); + readonly data: string; + readonly length: number; + _writeData(data: Uint8Array): number; + writeBytes(value: BytesLike): number; + _getValue(value: BigNumberish): Uint8Array; + writeValue(value: BigNumberish): number; + writeUpdatableValue(): (value: BigNumberish) => void; +} +export declare class Reader { + readonly wordSize: number; + readonly _data: Uint8Array; + readonly _coerceFunc: CoerceFunc; + _offset: number; + constructor(data: BytesLike, wordSize?: number, coerceFunc?: CoerceFunc); + readonly data: string; + readonly consumed: number; + static coerce(name: string, value: any): any; + coerce(name: string, value: any): any; + _peekBytes(offset: number, length: number): Uint8Array; + subReader(offset: number): Reader; + readBytes(length: number): Uint8Array; + readValue(): BigNumber; +} diff --git a/packages/abi/lib.esm/coders/abstract-coder.js b/packages/abi/lib.esm/coders/abstract-coder.js new file mode 100644 index 000000000..179513240 --- /dev/null +++ b/packages/abi/lib.esm/coders/abstract-coder.js @@ -0,0 +1,109 @@ +"use strict"; +import { arrayify, concat, hexlify } from "@ethersproject/bytes"; +import { BigNumber } from "@ethersproject/bignumber"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "../_version"; +const logger = new Logger(version); +export class Coder { + constructor(name, type, localName, dynamic) { + this.name = name; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + _throwError(message, value) { + logger.throwArgumentError(message, this.localName, value); + } +} +export class Writer { + constructor(wordSize) { + defineReadOnly(this, "wordSize", wordSize || 32); + this._data = arrayify([]); + this._padding = new Uint8Array(wordSize); + } + get data() { return hexlify(this._data); } + get length() { return this._data.length; } + _writeData(data) { + this._data = concat([this._data, data]); + return data.length; + } + // Arrayish items; padded on the right to wordSize + writeBytes(value) { + let bytes = arrayify(value); + if (bytes.length % this.wordSize) { + bytes = concat([bytes, this._padding.slice(bytes.length % this.wordSize)]); + } + return this._writeData(bytes); + } + _getValue(value) { + let bytes = arrayify(BigNumber.from(value)); + if (bytes.length > this.wordSize) { + logger.throwError("value out-of-bounds", Logger.errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes.length + }); + } + if (bytes.length % this.wordSize) { + bytes = concat([this._padding.slice(bytes.length % this.wordSize), bytes]); + } + return bytes; + } + // BigNumberish items; padded on the left to wordSize + writeValue(value) { + return this._writeData(this._getValue(value)); + } + writeUpdatableValue() { + let offset = this.length; + this.writeValue(0); + return (value) => { + this._data.set(this._getValue(value), offset); + }; + } +} +export class Reader { + constructor(data, wordSize, coerceFunc) { + defineReadOnly(this, "_data", arrayify(data)); + defineReadOnly(this, "wordSize", wordSize || 32); + defineReadOnly(this, "_coerceFunc", coerceFunc); + this._offset = 0; + } + get data() { return hexlify(this._data); } + get consumed() { return this._offset; } + // The default Coerce function + static coerce(name, value) { + let match = name.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { + value = value.toNumber(); + } + return value; + } + coerce(name, value) { + if (this._coerceFunc) { + return this._coerceFunc(name, value); + } + return Reader.coerce(name, value); + } + _peekBytes(offset, length) { + let alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + logger.throwError("data out-of-bounds", Logger.errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); + } + return this._data.slice(this._offset, this._offset + alignedLength); + } + subReader(offset) { + return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); + } + readBytes(length) { + let bytes = this._peekBytes(0, length); + this._offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + } + readValue() { + return BigNumber.from(this.readBytes(this.wordSize)); + } +} diff --git a/packages/abi/lib.esm/coders/address.d.ts b/packages/abi/lib.esm/coders/address.d.ts new file mode 100644 index 000000000..d2ae49050 --- /dev/null +++ b/packages/abi/lib.esm/coders/address.d.ts @@ -0,0 +1,6 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class AddressCoder extends Coder { + constructor(localName: string); + encode(writer: Writer, value: string): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/address.js b/packages/abi/lib.esm/coders/address.js new file mode 100644 index 000000000..e4d9391bc --- /dev/null +++ b/packages/abi/lib.esm/coders/address.js @@ -0,0 +1,21 @@ +"use strict"; +import { getAddress } from "@ethersproject/address"; +import { hexZeroPad } from "@ethersproject/bytes"; +import { Coder } from "./abstract-coder"; +export class AddressCoder extends Coder { + constructor(localName) { + super("address", "address", localName, false); + } + encode(writer, value) { + try { + getAddress(value); + } + catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + } + decode(reader) { + return getAddress(hexZeroPad(reader.readValue().toHexString(), 20)); + } +} diff --git a/packages/abi/lib.esm/coders/anonymous.d.ts b/packages/abi/lib.esm/coders/anonymous.d.ts new file mode 100644 index 000000000..ccfffbb4f --- /dev/null +++ b/packages/abi/lib.esm/coders/anonymous.d.ts @@ -0,0 +1,7 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class AnonymousCoder extends Coder { + private coder; + constructor(coder: Coder); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/anonymous.js b/packages/abi/lib.esm/coders/anonymous.js new file mode 100644 index 000000000..6f3433803 --- /dev/null +++ b/packages/abi/lib.esm/coders/anonymous.js @@ -0,0 +1,15 @@ +"use strict"; +import { Coder } from "./abstract-coder"; +// Clones the functionality of an existing Coder, but without a localName +export class AnonymousCoder extends Coder { + constructor(coder) { + super(coder.name, coder.type, undefined, coder.dynamic); + this.coder = coder; + } + encode(writer, value) { + return this.coder.encode(writer, value); + } + decode(reader) { + return this.coder.decode(reader); + } +} diff --git a/packages/abi/lib.esm/coders/array.d.ts b/packages/abi/lib.esm/coders/array.d.ts new file mode 100644 index 000000000..c101cbae6 --- /dev/null +++ b/packages/abi/lib.esm/coders/array.d.ts @@ -0,0 +1,10 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare function pack(writer: Writer, coders: Array, values: Array): number; +export declare function unpack(reader: Reader, coders: Array): Array; +export declare class ArrayCoder extends Coder { + readonly coder: Coder; + readonly length: number; + constructor(coder: Coder, length: number, localName: string); + encode(writer: Writer, value: Array): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/array.js b/packages/abi/lib.esm/coders/array.js new file mode 100644 index 000000000..5b64c9424 --- /dev/null +++ b/packages/abi/lib.esm/coders/array.js @@ -0,0 +1,126 @@ +"use strict"; +import { Logger } from "@ethersproject/logger"; +import { version } from "../_version"; +const logger = new Logger(version); +import { Coder, Writer } from "./abstract-coder"; +import { AnonymousCoder } from "./anonymous"; +export function pack(writer, coders, values) { + if (Array.isArray(values)) { + // do nothing + } + else if (values && typeof (values) === "object") { + let arrayValues = []; + coders.forEach(function (coder) { + arrayValues.push(values[coder.localName]); + }); + values = arrayValues; + } + else { + logger.throwArgumentError("invalid tuple value", "tuple", values); + } + if (coders.length !== values.length) { + logger.throwArgumentError("types/value length mismatch", "tuple", values); + } + let staticWriter = new Writer(writer.wordSize); + let dynamicWriter = new Writer(writer.wordSize); + let updateFuncs = []; + coders.forEach((coder, index) => { + let value = values[index]; + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + let dynamicOffset = dynamicWriter.length; + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + // Prepare to populate the correct offset once we are done + let updateFunc = staticWriter.writeUpdatableValue(); + updateFuncs.push((baseOffset) => { + updateFunc(baseOffset + dynamicOffset); + }); + } + else { + coder.encode(staticWriter, value); + } + }); + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach((func) => { func(staticWriter.length); }); + let length = writer.writeBytes(staticWriter.data); + length += writer.writeBytes(dynamicWriter.data); + return length; +} +export function unpack(reader, coders) { + let values = []; + // A reader anchored to this base + let baseReader = reader.subReader(0); + // The amount of dynamic data read; to consume later to synchronize + let dynamicLength = 0; + coders.forEach((coder) => { + let value = null; + if (coder.dynamic) { + let offset = reader.readValue(); + let offsetReader = baseReader.subReader(offset.toNumber()); + value = coder.decode(offsetReader); + dynamicLength += offsetReader.consumed; + } + else { + value = coder.decode(reader); + } + if (value != undefined) { + values.push(value); + } + }); + // @TODO: get rid of this an see if it still works? + // Consume the dynamic components in the main reader + reader.readBytes(dynamicLength); + // Add any named parameters (i.e. tuples) + coders.forEach((coder, index) => { + let name = coder.localName; + if (!name) { + return; + } + if (name === "length") { + name = "_length"; + } + if (values[name] != null) { + return; + } + values[name] = values[index]; + }); + return values; +} +export class ArrayCoder extends Coder { + constructor(coder, length, localName) { + const type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); + const dynamic = (length === -1 || coder.dynamic); + super("array", type, localName, dynamic); + this.coder = coder; + this.length = length; + } + encode(writer, value) { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + let count = this.length; + //let result = new Uint8Array(0); + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + logger.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); + let coders = []; + for (let i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + } + decode(reader) { + let count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + } + let coders = []; + for (let i = 0; i < count; i++) { + coders.push(new AnonymousCoder(this.coder)); + } + return reader.coerce(this.name, unpack(reader, coders)); + } +} diff --git a/packages/abi/lib.esm/coders/boolean.d.ts b/packages/abi/lib.esm/coders/boolean.d.ts new file mode 100644 index 000000000..bce9af23b --- /dev/null +++ b/packages/abi/lib.esm/coders/boolean.d.ts @@ -0,0 +1,6 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class BooleanCoder extends Coder { + constructor(localName: string); + encode(writer: Writer, value: boolean): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/boolean.js b/packages/abi/lib.esm/coders/boolean.js new file mode 100644 index 000000000..3264a68f3 --- /dev/null +++ b/packages/abi/lib.esm/coders/boolean.js @@ -0,0 +1,13 @@ +"use strict"; +import { Coder } from "./abstract-coder"; +export class BooleanCoder extends Coder { + constructor(localName) { + super("bool", "bool", localName, false); + } + encode(writer, value) { + return writer.writeValue(value ? 1 : 0); + } + decode(reader) { + return reader.coerce(this.type, !reader.readValue().isZero()); + } +} diff --git a/packages/abi/lib.esm/coders/bytes.d.ts b/packages/abi/lib.esm/coders/bytes.d.ts new file mode 100644 index 000000000..02d94fcb0 --- /dev/null +++ b/packages/abi/lib.esm/coders/bytes.d.ts @@ -0,0 +1,10 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class DynamicBytesCoder extends Coder { + constructor(type: string, localName: string); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} +export declare class BytesCoder extends DynamicBytesCoder { + constructor(localName: string); + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/bytes.js b/packages/abi/lib.esm/coders/bytes.js new file mode 100644 index 000000000..762b5e32d --- /dev/null +++ b/packages/abi/lib.esm/coders/bytes.js @@ -0,0 +1,25 @@ +"use strict"; +import { arrayify, hexlify } from "@ethersproject/bytes"; +import { Coder } from "./abstract-coder"; +export class DynamicBytesCoder extends Coder { + constructor(type, localName) { + super(type, type, localName, true); + } + encode(writer, value) { + value = arrayify(value); + let length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + } + decode(reader) { + return reader.readBytes(reader.readValue().toNumber()); + } +} +export class BytesCoder extends DynamicBytesCoder { + constructor(localName) { + super("bytes", localName); + } + decode(reader) { + return reader.coerce(this.name, hexlify(super.decode(reader))); + } +} diff --git a/packages/abi/lib.esm/coders/fixed-bytes.d.ts b/packages/abi/lib.esm/coders/fixed-bytes.d.ts new file mode 100644 index 000000000..19c368726 --- /dev/null +++ b/packages/abi/lib.esm/coders/fixed-bytes.d.ts @@ -0,0 +1,8 @@ +import { BytesLike } from "@ethersproject/bytes"; +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class FixedBytesCoder extends Coder { + readonly size: number; + constructor(size: number, localName: string); + encode(writer: Writer, value: BytesLike): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/fixed-bytes.js b/packages/abi/lib.esm/coders/fixed-bytes.js new file mode 100644 index 000000000..88d255b25 --- /dev/null +++ b/packages/abi/lib.esm/coders/fixed-bytes.js @@ -0,0 +1,21 @@ +"use strict"; +import { arrayify, hexlify } from "@ethersproject/bytes"; +import { Coder } from "./abstract-coder"; +// @TODO: Merge this with bytes +export class FixedBytesCoder extends Coder { + constructor(size, localName) { + let name = "bytes" + String(size); + super(name, name, localName, false); + this.size = size; + } + encode(writer, value) { + let data = arrayify(value); + if (data.length !== this.size) { + this._throwError("incorrect data length", value); + } + return writer.writeBytes(data); + } + decode(reader) { + return reader.coerce(this.name, hexlify(reader.readBytes(this.size))); + } +} diff --git a/packages/abi/lib.esm/coders/null.d.ts b/packages/abi/lib.esm/coders/null.d.ts new file mode 100644 index 000000000..4ce6570a3 --- /dev/null +++ b/packages/abi/lib.esm/coders/null.d.ts @@ -0,0 +1,6 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class NullCoder extends Coder { + constructor(localName: string); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/null.js b/packages/abi/lib.esm/coders/null.js new file mode 100644 index 000000000..201c39e5f --- /dev/null +++ b/packages/abi/lib.esm/coders/null.js @@ -0,0 +1,17 @@ +"use strict"; +import { Coder } from "./abstract-coder"; +export class NullCoder extends Coder { + constructor(localName) { + super("null", "", localName, false); + } + encode(writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes([]); + } + decode(reader) { + reader.readBytes(0); + return reader.coerce(this.name, null); + } +} diff --git a/packages/abi/lib.esm/coders/number.d.ts b/packages/abi/lib.esm/coders/number.d.ts new file mode 100644 index 000000000..3bae1ef65 --- /dev/null +++ b/packages/abi/lib.esm/coders/number.d.ts @@ -0,0 +1,9 @@ +import { BigNumberish } from "@ethersproject/bignumber"; +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class NumberCoder extends Coder { + readonly size: number; + readonly signed: boolean; + constructor(size: number, signed: boolean, localName: string); + encode(writer: Writer, value: BigNumberish): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/number.js b/packages/abi/lib.esm/coders/number.js new file mode 100644 index 000000000..544257976 --- /dev/null +++ b/packages/abi/lib.esm/coders/number.js @@ -0,0 +1,38 @@ +"use strict"; +import { BigNumber } from "@ethersproject/bignumber"; +import { MaxUint256, NegativeOne, One, Zero } from "@ethersproject/constants"; +import { Coder } from "./abstract-coder"; +export class NumberCoder extends Coder { + constructor(size, signed, localName) { + const name = ((signed ? "int" : "uint") + (size * 8)); + super(name, name, localName, false); + this.size = size; + this.signed = signed; + } + encode(writer, value) { + let v = BigNumber.from(value); + // Check bounds are safe for encoding + let maxUintValue = MaxUint256.maskn(writer.wordSize * 8); + if (this.signed) { + let bounds = maxUintValue.maskn(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(One).mul(NegativeOne))) { + this._throwError("value out-of-bounds", value); + } + } + else if (v.lt(Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + v = v.toTwos(this.size * 8).maskn(this.size * 8); + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + return writer.writeValue(v); + } + decode(reader) { + let value = reader.readValue().maskn(this.size * 8); + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + return reader.coerce(this.name, value); + } +} diff --git a/packages/abi/lib.esm/coders/string.d.ts b/packages/abi/lib.esm/coders/string.d.ts new file mode 100644 index 000000000..36f293b4f --- /dev/null +++ b/packages/abi/lib.esm/coders/string.d.ts @@ -0,0 +1,7 @@ +import { Reader, Writer } from "./abstract-coder"; +import { DynamicBytesCoder } from "./bytes"; +export declare class StringCoder extends DynamicBytesCoder { + constructor(localName: string); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/string.js b/packages/abi/lib.esm/coders/string.js new file mode 100644 index 000000000..5245acdf8 --- /dev/null +++ b/packages/abi/lib.esm/coders/string.js @@ -0,0 +1,14 @@ +"use strict"; +import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings"; +import { DynamicBytesCoder } from "./bytes"; +export class StringCoder extends DynamicBytesCoder { + constructor(localName) { + super("string", localName); + } + encode(writer, value) { + return super.encode(writer, toUtf8Bytes(value)); + } + decode(reader) { + return toUtf8String(super.decode(reader)); + } +} diff --git a/packages/abi/lib.esm/coders/tuple.d.ts b/packages/abi/lib.esm/coders/tuple.d.ts new file mode 100644 index 000000000..e7b67bb85 --- /dev/null +++ b/packages/abi/lib.esm/coders/tuple.d.ts @@ -0,0 +1,7 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class TupleCoder extends Coder { + readonly coders: Array; + constructor(coders: Array, localName: string); + encode(writer: Writer, value: Array): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib.esm/coders/tuple.js b/packages/abi/lib.esm/coders/tuple.js new file mode 100644 index 000000000..7d736d181 --- /dev/null +++ b/packages/abi/lib.esm/coders/tuple.js @@ -0,0 +1,24 @@ +"use strict"; +import { Coder } from "./abstract-coder"; +import { pack, unpack } from "./array"; +export class TupleCoder extends Coder { + constructor(coders, localName) { + let dynamic = false; + let types = []; + coders.forEach((coder) => { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + let type = ("tuple(" + types.join(",") + ")"); + super("tuple", type, localName, dynamic); + this.coders = coders; + } + encode(writer, value) { + return pack(writer, this.coders, value); + } + decode(reader) { + return reader.coerce(this.name, unpack(reader, this.coders)); + } +} diff --git a/packages/abi/fragments.d.ts b/packages/abi/lib.esm/fragments.d.ts similarity index 100% rename from packages/abi/fragments.d.ts rename to packages/abi/lib.esm/fragments.d.ts diff --git a/packages/abi/lib.esm/fragments.js b/packages/abi/lib.esm/fragments.js new file mode 100644 index 000000000..5cf8c485d --- /dev/null +++ b/packages/abi/lib.esm/fragments.js @@ -0,0 +1,752 @@ +"use strict"; +import { BigNumber } from "@ethersproject/bignumber"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +; +const _constructorGuard = {}; +let ModifiersBytes = { calldata: true, memory: true, storage: true }; +function checkModifier(type, name) { + if (type === "bytes" || type === "string") { + if (ModifiersBytes[name]) { + return true; + } + } + else if (type === "address") { + if (name === "payable") { + return true; + } + } + if (ModifiersBytes[name] || name === "payable") { + logger.throwArgumentError("invalid modifier", "name", name); + } + return false; +} +// @TODO: Make sure that children of an indexed tuple are marked with a null indexed +function parseParamType(param, allowIndexed) { + let originalParam = param; + function throwError(i) { + throw new Error("unexpected character '" + originalParam[i] + "' at position " + i + " in '" + originalParam + "'"); + } + param = param.replace(/\s/g, " "); + function newNode(parent) { + let node = { type: "", name: "", parent: parent, state: { allowType: true } }; + if (allowIndexed) { + node.indexed = false; + } + return node; + } + let parent = { type: "", name: "", state: { allowType: true } }; + let node = parent; + for (let i = 0; i < param.length; i++) { + let c = param[i]; + switch (c) { + case "(": + if (!node.state.allowParams) { + throwError(i); + } + node.state.allowType = false; + node.type = verifyType(node.type); + node.components = [newNode(node)]; + node = node.components[0]; + break; + case ")": + delete node.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + if (checkModifier(node.type, node.name)) { + node.name = ""; + } + node.type = verifyType(node.type); + let child = node; + node = node.parent; + if (!node) { + throwError(i); + } + delete child.parent; + node.state.allowParams = false; + node.state.allowName = true; + node.state.allowArray = true; + break; + case ",": + delete node.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + if (checkModifier(node.type, node.name)) { + node.name = ""; + } + node.type = verifyType(node.type); + let sibling = newNode(node.parent); + //{ type: "", name: "", parent: node.parent, state: { allowType: true } }; + node.parent.components.push(sibling); + delete node.parent; + node = sibling; + break; + // Hit a space... + case " ": + // If reading type, the type is done and may read a param or name + if (node.state.allowType) { + if (node.type !== "") { + node.type = verifyType(node.type); + delete node.state.allowType; + node.state.allowName = true; + node.state.allowParams = true; + } + } + // If reading name, the name is done + if (node.state.allowName) { + if (node.name !== "") { + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + if (node.indexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + else if (checkModifier(node.type, node.name)) { + node.name = ""; + } + else { + node.state.allowName = false; + } + } + } + break; + case "[": + if (!node.state.allowArray) { + throwError(i); + } + node.type += c; + node.state.allowArray = false; + node.state.allowName = false; + node.state.readArray = true; + break; + case "]": + if (!node.state.readArray) { + throwError(i); + } + node.type += c; + node.state.readArray = false; + node.state.allowArray = true; + node.state.allowName = true; + break; + default: + if (node.state.allowType) { + node.type += c; + node.state.allowParams = true; + node.state.allowArray = true; + } + else if (node.state.allowName) { + node.name += c; + delete node.state.allowArray; + } + else if (node.state.readArray) { + node.type += c; + } + else { + throwError(i); + } + } + } + if (node.parent) { + throw new Error("unexpected eof"); + } + delete parent.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(originalParam.length - 7); + } + if (node.indexed) { + throwError(originalParam.length - 7); + } + node.indexed = true; + node.name = ""; + } + else if (checkModifier(node.type, node.name)) { + node.name = ""; + } + parent.type = verifyType(parent.type); + return parent; +} +function populate(object, params) { + for (let key in params) { + defineReadOnly(object, key, params[key]); + } +} +export const FormatTypes = Object.freeze({ + // Bare formatting, as is needed for computing a sighash of an event or function + sighash: "sighash", + // Human-Readable with Minimal spacing and without names (compact human-readable) + minimal: "minimal", + // Human-Readble with nice spacing, including all names + full: "full", + // JSON-format a la Solidity + json: "json" +}); +const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); +export class ParamType { + constructor(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + throw new Error("use fromString"); + } + populate(this, params); + let match = this.type.match(paramTypeArray); + if (match) { + populate(this, { + arrayLength: parseInt(match[2] || "-1"), + arrayChildren: ParamType.fromObject({ + type: match[1], + components: this.components + }), + baseType: "array" + }); + } + else { + populate(this, { + arrayLength: null, + arrayChildren: null, + baseType: ((this.components != null) ? "tuple" : this.type) + }); + } + this._isParamType = true; + Object.freeze(this); + } + // Format the parameter fragment + // - sighash: "(uint256,address)" + // - minimal: "tuple(uint256,address) indexed" + // - full: "tuple(uint256 foo, addres bar) indexed baz" + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + let result = { + type: ((this.baseType === "tuple") ? "tuple" : this.type), + name: (this.name || undefined) + }; + if (typeof (this.indexed) === "boolean") { + result.indexed = this.indexed; + } + if (this.components) { + result.components = this.components.map((comp) => JSON.parse(comp.format(format))); + } + return JSON.stringify(result); + } + let result = ""; + // Array + if (this.baseType === "array") { + result += this.arrayChildren.format(format); + result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; + } + else { + if (this.baseType === "tuple") { + if (format !== FormatTypes.sighash) { + result += this.type; + } + result += "(" + this.components.map((comp) => comp.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ")"; + } + else { + result += this.type; + } + } + if (format !== FormatTypes.sighash) { + if (this.indexed === true) { + result += " indexed"; + } + if (format === FormatTypes.full && this.name) { + result += " " + this.name; + } + } + return result; + } + static from(value, allowIndexed) { + if (typeof (value) === "string") { + return ParamType.fromString(value, allowIndexed); + } + return ParamType.fromObject(value); + } + static fromObject(value) { + if (ParamType.isParamType(value)) { + return value; + } + return new ParamType(_constructorGuard, { + name: (value.name || null), + type: verifyType(value.type), + indexed: ((value.indexed == null) ? null : !!value.indexed), + components: (value.components ? value.components.map(ParamType.fromObject) : null) + }); + } + static fromString(value, allowIndexed) { + function ParamTypify(node) { + return ParamType.fromObject({ + name: node.name, + type: node.type, + indexed: node.indexed, + components: node.components + }); + } + return ParamTypify(parseParamType(value, !!allowIndexed)); + } + static isParamType(value) { + return !!(value != null && value._isParamType); + } +} +; +function parseParams(value, allowIndex) { + return splitNesting(value).map((param) => ParamType.fromString(param, allowIndex)); +} +export class Fragment { + constructor(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + throw new Error("use a static from method"); + } + populate(this, params); + this._isFragment = true; + Object.freeze(this); + } + static from(value) { + if (Fragment.isFragment(value)) { + return value; + } + if (typeof (value) === "string") { + return Fragment.fromString(value); + } + return Fragment.fromObject(value); + } + static fromObject(value) { + if (Fragment.isFragment(value)) { + return value; + } + if (value.type === "function") { + return FunctionFragment.fromObject(value); + } + else if (value.type === "event") { + return EventFragment.fromObject(value); + } + else if (value.type === "constructor") { + return ConstructorFragment.fromObject(value); + } + else if (value.type === "fallback") { + // @TODO: + return null; + } + return logger.throwArgumentError("invalid fragment object", "value", value); + } + static fromString(value) { + // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space + value = value.replace(/\s/g, " "); + value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); + value = value.trim(); + if (value.split(" ")[0] === "event") { + return EventFragment.fromString(value.substring(5).trim()); + } + else if (value.split(" ")[0] === "function") { + return FunctionFragment.fromString(value.substring(8).trim()); + } + else if (value.split("(")[0].trim() === "constructor") { + return ConstructorFragment.fromString(value.trim()); + } + throw new Error("unknown fragment"); + } + static isFragment(value) { + return !!(value && value._isFragment); + } +} +export class EventFragment extends Fragment { + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + return JSON.stringify({ + type: "event", + anonymous: this.anonymous, + name: this.name, + inputs: this.inputs.map((input) => JSON.parse(input.format(format))) + }); + } + let result = ""; + if (format !== FormatTypes.sighash) { + result += "event "; + } + result += this.name + "(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") "; + if (format !== FormatTypes.sighash) { + if (this.anonymous) { + result += "anonymous "; + } + } + return result.trim(); + } + static from(value) { + if (typeof (value) === "string") { + return EventFragment.fromString(value); + } + return EventFragment.fromObject(value); + } + static fromObject(value) { + if (EventFragment.isEventFragment(value)) { + return value; + } + if (value.type !== "event") { + throw new Error("invalid event object - " + value.type); + } + return new EventFragment(_constructorGuard, { + name: verifyIdentifier(value.name), + anonymous: value.anonymous, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + type: "event" + }); + } + static fromString(value) { + let match = value.match(regexParen); + if (!match) { + throw new Error("invalid event: " + value); + } + let anonymous = false; + match[3].split(" ").forEach((modifier) => { + switch (modifier.trim()) { + case "anonymous": + anonymous = true; + break; + case "": + break; + default: + logger.warn("unknown modifier: " + modifier); + } + }); + return EventFragment.fromObject({ + name: match[1].trim(), + anonymous: anonymous, + inputs: parseParams(match[2], true), + type: "event" + }); + } + static isEventFragment(value) { + return (value && value._isFragment && value.type === "event"); + } +} +function parseGas(value, params) { + params.gas = null; + let comps = value.split("@"); + if (comps.length !== 1) { + if (comps.length > 2) { + throw new Error("invalid signature"); + } + if (!comps[1].match(/^[0-9]+$/)) { + throw new Error("invalid signature gas"); + } + params.gas = BigNumber.from(comps[1]); + return comps[0]; + } + return value; +} +function parseModifiers(value, params) { + params.constant = false; + params.payable = false; + params.stateMutability = "nonpayable"; + value.split(" ").forEach((modifier) => { + switch (modifier.trim()) { + case "constant": + params.constant = true; + break; + case "payable": + params.payable = true; + params.stateMutability = "payable"; + break; + case "pure": + params.constant = true; + params.stateMutability = "pure"; + break; + case "view": + params.constant = true; + params.stateMutability = "view"; + break; + case "external": + case "public": + case "": + break; + default: + console.log("unknown modifier: " + modifier); + } + }); +} +function verifyState(value) { + let result = { + constant: false, + payable: true, + stateMutability: "payable" + }; + if (value.stateMutability != null) { + result.stateMutability = value.stateMutability; + result.constant = (result.stateMutability === "view" || result.stateMutability === "pure"); + if (value.constant != null) { + if ((!!value.constant) !== result.constant) { + throw new Error("cannot have constant function with mutability " + result.stateMutability); + } + } + result.payable = (result.stateMutability === "payable"); + if (value.payable != null) { + if ((!!value.payable) !== result.payable) { + throw new Error("cannot have payable function with mutability " + result.stateMutability); + } + } + } + else if (value.payable != null) { + result.payable = !!value.payable; + result.stateMutability = (result.payable ? "payable" : "nonpayable"); + result.constant = !result.payable; + if (value.constant != null && (value.constant !== result.constant)) { + throw new Error("cannot have constant payable function"); + } + } + else if (value.constant != null) { + result.constant = !!value.constant; + result.payable = !result.constant; + result.stateMutability = (result.constant ? "view" : "payable"); + } + return result; +} +export class ConstructorFragment extends Fragment { + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + return JSON.stringify({ + type: "constructor", + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payble: this.payable, + gas: (this.gas ? this.gas.toNumber() : undefined), + inputs: this.inputs.map((input) => JSON.parse(input.format(format))) + }); + } + if (format === FormatTypes.sighash) { + logger.throwError("cannot format a constructor for sighash", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "format(sighash)" + }); + } + let result = "constructor(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") "; + if (this.stateMutability && this.stateMutability !== "nonpayable") { + result += this.stateMutability + " "; + } + return result.trim(); + } + static from(value) { + if (typeof (value) === "string") { + return ConstructorFragment.fromString(value); + } + return ConstructorFragment.fromObject(value); + } + static fromObject(value) { + if (ConstructorFragment.isConstructorFragment(value)) { + return value; + } + if (value.type !== "constructor") { + throw new Error("invalid constructor object - " + value.type); + } + let state = verifyState(value); + if (state.constant) { + throw new Error("constructor cannot be constant"); + } + return new ConstructorFragment(_constructorGuard, { + type: value.type, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + payable: state.payable, + gas: (value.gas ? BigNumber.from(value.gas) : null) + }); + } + static fromString(value) { + let params = { type: "constructor" }; + value = parseGas(value, params); + let parens = value.match(regexParen); + if (!parens) { + throw new Error("invalid constructor: " + value); + } + if (parens[1].trim() !== "constructor") { + throw new Error("invalid constructor"); + } + params.inputs = parseParams(parens[2].trim(), false); + parseModifiers(parens[3].trim(), params); + return ConstructorFragment.fromObject(params); + } + static isConstructorFragment(value) { + return (value && value._isFragment && value.type === "constructor"); + } +} +export class FunctionFragment extends ConstructorFragment { + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + return JSON.stringify({ + type: "function", + name: this.name, + constant: this.constant, + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payble: this.payable, + gas: (this.gas ? this.gas.toNumber() : undefined), + inputs: this.inputs.map((input) => JSON.parse(input.format(format))), + ouputs: this.outputs.map((output) => JSON.parse(output.format(format))), + }); + } + let result = ""; + if (format !== FormatTypes.sighash) { + result += "function "; + } + result += this.name + "(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") "; + if (format !== FormatTypes.sighash) { + if (this.stateMutability) { + if (this.stateMutability !== "nonpayable") { + result += (this.stateMutability + " "); + } + } + else if (this.constant) { + result += "view "; + } + if (this.outputs && this.outputs.length) { + result += "returns (" + this.outputs.map((output) => output.format(format)).join(", ") + ") "; + } + if (this.gas != null) { + result += "@" + this.gas.toString() + " "; + } + } + return result.trim(); + } + static from(value) { + if (typeof (value) === "string") { + return FunctionFragment.fromString(value); + } + return FunctionFragment.fromObject(value); + } + static fromObject(value) { + if (FunctionFragment.isFunctionFragment(value)) { + return value; + } + if (value.type !== "function") { + throw new Error("invalid function object - " + value.type); + } + let state = verifyState(value); + return new FunctionFragment(_constructorGuard, { + type: value.type, + name: verifyIdentifier(value.name), + constant: state.constant, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []), + payable: state.payable, + stateMutability: state.stateMutability, + gas: (value.gas ? BigNumber.from(value.gas) : null) + }); + } + static fromString(value) { + let params = { type: "function" }; + value = parseGas(value, params); + let comps = value.split(" returns "); + if (comps.length > 2) { + throw new Error("invalid function"); + } + let parens = comps[0].match(regexParen); + if (!parens) { + throw new Error("invalid signature"); + } + params.name = parens[1].trim(); + if (!params.name.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + params.name + "'"); + } + params.inputs = parseParams(parens[2], false); + parseModifiers(parens[3].trim(), params); + // We have outputs + if (comps.length > 1) { + let returns = comps[1].match(regexParen); + if (returns[1].trim() != "" || returns[3].trim() != "") { + throw new Error("unexpected tokens"); + } + params.outputs = parseParams(returns[2], false); + } + else { + params.outputs = []; + } + return FunctionFragment.fromObject(params); + } + static isFunctionFragment(value) { + return (value && value._isFragment && value.type === "function"); + } +} +//export class ErrorFragment extends Fragment { +//} +//export class StructFragment extends Fragment { +//} +function verifyType(type) { + // These need to be transformed to their full description + if (type.match(/^uint($|[^1-9])/)) { + type = "uint256" + type.substring(4); + } + else if (type.match(/^int($|[^1-9])/)) { + type = "int256" + type.substring(3); + } + // @TODO: more verification + return type; +} +const regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); +function verifyIdentifier(value) { + if (!value || !value.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + value + "'"); + } + return value; +} +const regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); +function splitNesting(value) { + value = value.trim(); + let result = []; + let accum = ""; + let depth = 0; + for (let offset = 0; offset < value.length; offset++) { + let c = value[offset]; + if (c === "," && depth === 0) { + result.push(accum); + accum = ""; + } + else { + accum += c; + if (c === "(") { + depth++; + } + else if (c === ")") { + depth--; + if (depth === -1) { + throw new Error("unbalanced parenthsis"); + } + } + } + } + if (accum) { + result.push(accum); + } + return result; +} diff --git a/packages/abi/index.d.ts b/packages/abi/lib.esm/index.d.ts similarity index 100% rename from packages/abi/index.d.ts rename to packages/abi/lib.esm/index.d.ts diff --git a/packages/abi/lib.esm/index.js b/packages/abi/lib.esm/index.js new file mode 100644 index 000000000..acc20f1c9 --- /dev/null +++ b/packages/abi/lib.esm/index.js @@ -0,0 +1,5 @@ +"use strict"; +import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, ParamType } from "./fragments"; +import { AbiCoder, defaultAbiCoder } from "./abi-coder"; +import { Indexed, Interface } from "./interface"; +export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed }; diff --git a/packages/abi/interface.d.ts b/packages/abi/lib.esm/interface.d.ts similarity index 100% rename from packages/abi/interface.d.ts rename to packages/abi/lib.esm/interface.d.ts diff --git a/packages/abi/lib.esm/interface.js b/packages/abi/lib.esm/interface.js new file mode 100644 index 000000000..e9b99cc03 --- /dev/null +++ b/packages/abi/lib.esm/interface.js @@ -0,0 +1,342 @@ +"use strict"; +import { getAddress } from "@ethersproject/address"; +import { BigNumber } from "@ethersproject/bignumber"; +import { arrayify, concat, hexDataSlice, hexlify, hexZeroPad, isHexString } from "@ethersproject/bytes"; +import { id } from "@ethersproject/hash"; +import { keccak256 } from "@ethersproject/keccak256"; +import { defineReadOnly, Description, getStatic } from "@ethersproject/properties"; +import { defaultAbiCoder } from "./abi-coder"; +import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType } from "./fragments"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export class LogDescription extends Description { +} +export class TransactionDescription extends Description { +} +export class Indexed extends Description { + static isIndexed(value) { + return !!(value && value._isIndexed); + } +} +export class Result { +} +export class Interface { + constructor(fragments) { + logger.checkNew(new.target, Interface); + let abi = []; + if (typeof (fragments) === "string") { + abi = JSON.parse(fragments); + } + else { + abi = fragments; + } + defineReadOnly(this, "fragments", abi.map((fragment) => { + return Fragment.from(fragment); + }).filter((fragment) => (fragment != null))); + defineReadOnly(this, "_abiCoder", getStatic((new.target), "getAbiCoder")()); + defineReadOnly(this, "functions", {}); + defineReadOnly(this, "errors", {}); + defineReadOnly(this, "events", {}); + defineReadOnly(this, "structs", {}); + // Add all fragments by their signature + this.fragments.forEach((fragment) => { + let bucket = null; + switch (fragment.type) { + case "constructor": + if (this.deploy) { + logger.warn("duplicate definition - constructor"); + return; + } + defineReadOnly(this, "deploy", fragment); + return; + case "function": + bucket = this.functions; + break; + case "event": + bucket = this.events; + break; + default: + return; + } + let signature = fragment.format(); + if (bucket[signature]) { + logger.warn("duplicate definition - " + signature); + return; + } + bucket[signature] = fragment; + }); + // Add any fragments with a unique name by its name (sans signature parameters) + [this.events, this.functions].forEach((bucket) => { + let count = getNameCount(bucket); + Object.keys(bucket).forEach((signature) => { + let fragment = bucket[signature]; + if (count[fragment.name] !== 1) { + logger.warn("duplicate definition - " + fragment.name); + return; + } + bucket[fragment.name] = fragment; + }); + }); + // If we do not have a constructor use the default "constructor() payable" + if (!this.deploy) { + defineReadOnly(this, "deploy", ConstructorFragment.from({ type: "constructor" })); + } + defineReadOnly(this, "_isInterface", true); + } + static getAbiCoder() { + return defaultAbiCoder; + } + static getAddress(address) { + return getAddress(address); + } + _sighashify(functionFragment) { + return hexDataSlice(id(functionFragment.format()), 0, 4); + } + _topicify(eventFragment) { + return id(eventFragment.format()); + } + getFunction(nameOrSignatureOrSighash) { + if (isHexString(nameOrSignatureOrSighash)) { + return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + return (this.functions[nameOrSignatureOrSighash.trim()] || null); + } + // Normlize the signature and lookup the function + return this.functions[FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + } + getEvent(nameOrSignatureOrTopic) { + if (isHexString(nameOrSignatureOrTopic)) { + return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrTopic.indexOf("(") === -1) { + return this.events[nameOrSignatureOrTopic]; + } + return this.events[EventFragment.fromString(nameOrSignatureOrTopic).format()]; + } + getSighash(functionFragment) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return this._sighashify(functionFragment); + } + getEventTopic(eventFragment) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + return this._topicify(eventFragment); + } + _encodeParams(params, values) { + return this._abiCoder.encode(params, values); + } + encodeDeploy(values) { + return this._encodeParams(this.deploy.inputs, values || []); + } + encodeFunctionData(functionFragment, values) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return hexlify(concat([ + this.getSighash(functionFragment), + this._encodeParams(functionFragment.inputs, values || []) + ])); + } + decodeFunctionResult(functionFragment, data) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + let bytes = arrayify(data); + let reason = null; + let errorSignature = null; + switch (bytes.length % this._abiCoder._getWordSize()) { + case 0: + try { + return this._abiCoder.decode(functionFragment.outputs, bytes); + } + catch (error) { } + break; + case 4: + if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") { + errorSignature = "Error(string)"; + reason = this._abiCoder.decode(["string"], bytes.slice(4)); + } + break; + } + return logger.throwError("call revert exception", Logger.errors.CALL_EXCEPTION, { + method: functionFragment.format(), + errorSignature: errorSignature, + errorArgs: [reason], + reason: reason + }); + } + encodeFilterTopics(eventFragment, values) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (values.length > eventFragment.inputs.length) { + logger.throwError("too many arguments for " + eventFragment.format(), Logger.errors.UNEXPECTED_ARGUMENT, { + argument: "values", + value: values + }); + } + let topics = []; + if (!eventFragment.anonymous) { + topics.push(this.getEventTopic(eventFragment)); + } + values.forEach((value, index) => { + let param = eventFragment.inputs[index]; + if (!param.indexed) { + if (value != null) { + logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + } + return; + } + if (value == null) { + topics.push(null); + } + else if (param.type === "string") { + topics.push(id(value)); + } + else if (param.type === "bytes") { + topics.push(keccak256(hexlify(value))); + } + else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { + logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + } + else { + // Check addresses are valid + if (param.type === "address") { + this._abiCoder.encode(["address"], [value]); + } + topics.push(hexZeroPad(hexlify(value), 32)); + } + }); + // Trim off trailing nulls + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + return topics; + } + decodeEventLog(eventFragment, data, topics) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (topics != null && !eventFragment.anonymous) { + let topicHash = this.getEventTopic(eventFragment); + if (!isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { + logger.throwError("fragment/topic mismatch", Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); + } + topics = topics.slice(1); + } + let indexed = []; + let nonIndexed = []; + let dynamic = []; + eventFragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(ParamType.fromObject({ type: "bytes32", name: param.name })); + dynamic.push(true); + } + else { + indexed.push(param); + dynamic.push(false); + } + } + else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + let resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, concat(topics)) : null; + let resultNonIndexed = this._abiCoder.decode(nonIndexed, data); + let result = []; + let nonIndexedIndex = 0, indexedIndex = 0; + eventFragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (resultIndexed == null) { + result[index] = new Indexed({ _isIndexed: true, hash: null }); + } + else if (dynamic[index]) { + result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); + } + else { + result[index] = resultIndexed[indexedIndex++]; + } + } + else { + result[index] = resultNonIndexed[nonIndexedIndex++]; + } + //if (param.name && result[param.name] == null) { result[param.name] = result[index]; } + }); + return result; + } + parseTransaction(tx) { + let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); + if (!fragment) { + return null; + } + return new TransactionDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), + functionFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment), + value: BigNumber.from(tx.value || "0"), + }); + } + parseLog(log) { + let fragment = this.getEvent(log.topics[0]); + if (!fragment || fragment.anonymous) { + return null; + } + // @TODO: If anonymous, and the only method, and the input count matches, should we parse? + return new LogDescription({ + eventFragment: fragment, + name: fragment.name, + signature: fragment.format(), + topic: this.getEventTopic(fragment), + values: this.decodeEventLog(fragment, log.data, log.topics) + }); + } + /* + static from(value: Array | string | Interface) { + if (Interface.isInterface(value)) { + return value; + } + if (typeof(value) === "string") { + return new Interface(JSON.parse(value)); + } + return new Interface(value); + } + */ + static isInterface(value) { + return !!(value && value._isInterface); + } +} +function getFragment(hash, calcFunc, items) { + for (let signature in items) { + if (signature.indexOf("(") === -1) { + continue; + } + let fragment = items[signature]; + if (calcFunc(fragment) === hash) { + return fragment; + } + } + return null; +} +function getNameCount(fragments) { + let unique = {}; + // Count each name + for (let signature in fragments) { + let name = fragments[signature].name; + if (!unique[name]) { + unique[name] = 0; + } + unique[name]++; + } + return unique; +} diff --git a/packages/abi/lib/_version.d.ts b/packages/abi/lib/_version.d.ts new file mode 100644 index 000000000..f83da36bc --- /dev/null +++ b/packages/abi/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "abi/5.0.0-beta.136"; diff --git a/packages/abi/_version.js b/packages/abi/lib/_version.js similarity index 100% rename from packages/abi/_version.js rename to packages/abi/lib/_version.js diff --git a/packages/abi/lib/abi-coder.d.ts b/packages/abi/lib/abi-coder.d.ts new file mode 100644 index 000000000..63daf5efc --- /dev/null +++ b/packages/abi/lib/abi-coder.d.ts @@ -0,0 +1,15 @@ +import { BytesLike } from "@ethersproject/bytes"; +import { Coder, Reader, Writer } from "./coders/abstract-coder"; +import { ParamType } from "./fragments"; +export declare type CoerceFunc = (type: string, value: any) => any; +export declare class AbiCoder { + readonly coerceFunc: CoerceFunc; + constructor(coerceFunc?: CoerceFunc); + _getCoder(param: ParamType): Coder; + _getWordSize(): number; + _getReader(data: Uint8Array): Reader; + _getWriter(): Writer; + encode(types: Array, values: Array): string; + decode(types: Array, data: BytesLike): any; +} +export declare const defaultAbiCoder: AbiCoder; diff --git a/packages/abi/abi-coder.js b/packages/abi/lib/abi-coder.js similarity index 100% rename from packages/abi/abi-coder.js rename to packages/abi/lib/abi-coder.js diff --git a/packages/abi/lib/coders/abstract-coder.d.ts b/packages/abi/lib/coders/abstract-coder.d.ts new file mode 100644 index 000000000..6ff64f603 --- /dev/null +++ b/packages/abi/lib/coders/abstract-coder.d.ts @@ -0,0 +1,41 @@ +import { BytesLike } from "@ethersproject/bytes"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +export declare type CoerceFunc = (type: string, value: any) => any; +export declare abstract class Coder { + readonly name: string; + readonly type: string; + readonly localName: string; + readonly dynamic: boolean; + constructor(name: string, type: string, localName: string, dynamic: boolean); + _throwError(message: string, value: any): void; + abstract encode(writer: Writer, value: any): number; + abstract decode(reader: Reader): any; +} +export declare class Writer { + readonly wordSize: number; + _data: Uint8Array; + _padding: Uint8Array; + constructor(wordSize?: number); + readonly data: string; + readonly length: number; + _writeData(data: Uint8Array): number; + writeBytes(value: BytesLike): number; + _getValue(value: BigNumberish): Uint8Array; + writeValue(value: BigNumberish): number; + writeUpdatableValue(): (value: BigNumberish) => void; +} +export declare class Reader { + readonly wordSize: number; + readonly _data: Uint8Array; + readonly _coerceFunc: CoerceFunc; + _offset: number; + constructor(data: BytesLike, wordSize?: number, coerceFunc?: CoerceFunc); + readonly data: string; + readonly consumed: number; + static coerce(name: string, value: any): any; + coerce(name: string, value: any): any; + _peekBytes(offset: number, length: number): Uint8Array; + subReader(offset: number): Reader; + readBytes(length: number): Uint8Array; + readValue(): BigNumber; +} diff --git a/packages/abi/lib/coders/abstract-coder.js b/packages/abi/lib/coders/abstract-coder.js new file mode 100644 index 000000000..2666235e7 --- /dev/null +++ b/packages/abi/lib/coders/abstract-coder.js @@ -0,0 +1,133 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var bignumber_1 = require("@ethersproject/bignumber"); +var properties_1 = require("@ethersproject/properties"); +var logger_1 = require("@ethersproject/logger"); +var _version_1 = require("../_version"); +var logger = new logger_1.Logger(_version_1.version); +var Coder = /** @class */ (function () { + function Coder(name, type, localName, dynamic) { + this.name = name; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + Coder.prototype._throwError = function (message, value) { + logger.throwArgumentError(message, this.localName, value); + }; + return Coder; +}()); +exports.Coder = Coder; +var Writer = /** @class */ (function () { + function Writer(wordSize) { + properties_1.defineReadOnly(this, "wordSize", wordSize || 32); + this._data = bytes_1.arrayify([]); + this._padding = new Uint8Array(wordSize); + } + Object.defineProperty(Writer.prototype, "data", { + get: function () { return bytes_1.hexlify(this._data); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Writer.prototype, "length", { + get: function () { return this._data.length; }, + enumerable: true, + configurable: true + }); + Writer.prototype._writeData = function (data) { + this._data = bytes_1.concat([this._data, data]); + return data.length; + }; + // Arrayish items; padded on the right to wordSize + Writer.prototype.writeBytes = function (value) { + var bytes = bytes_1.arrayify(value); + if (bytes.length % this.wordSize) { + bytes = bytes_1.concat([bytes, this._padding.slice(bytes.length % this.wordSize)]); + } + return this._writeData(bytes); + }; + Writer.prototype._getValue = function (value) { + var bytes = bytes_1.arrayify(bignumber_1.BigNumber.from(value)); + if (bytes.length > this.wordSize) { + logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes.length + }); + } + if (bytes.length % this.wordSize) { + bytes = bytes_1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]); + } + return bytes; + }; + // BigNumberish items; padded on the left to wordSize + Writer.prototype.writeValue = function (value) { + return this._writeData(this._getValue(value)); + }; + Writer.prototype.writeUpdatableValue = function () { + var _this = this; + var offset = this.length; + this.writeValue(0); + return function (value) { + _this._data.set(_this._getValue(value), offset); + }; + }; + return Writer; +}()); +exports.Writer = Writer; +var Reader = /** @class */ (function () { + function Reader(data, wordSize, coerceFunc) { + properties_1.defineReadOnly(this, "_data", bytes_1.arrayify(data)); + properties_1.defineReadOnly(this, "wordSize", wordSize || 32); + properties_1.defineReadOnly(this, "_coerceFunc", coerceFunc); + this._offset = 0; + } + Object.defineProperty(Reader.prototype, "data", { + get: function () { return bytes_1.hexlify(this._data); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Reader.prototype, "consumed", { + get: function () { return this._offset; }, + enumerable: true, + configurable: true + }); + // The default Coerce function + Reader.coerce = function (name, value) { + var match = name.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { + value = value.toNumber(); + } + return value; + }; + Reader.prototype.coerce = function (name, value) { + if (this._coerceFunc) { + return this._coerceFunc(name, value); + } + return Reader.coerce(name, value); + }; + Reader.prototype._peekBytes = function (offset, length) { + var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + logger.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); + } + return this._data.slice(this._offset, this._offset + alignedLength); + }; + Reader.prototype.subReader = function (offset) { + return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); + }; + Reader.prototype.readBytes = function (length) { + var bytes = this._peekBytes(0, length); + this._offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + }; + Reader.prototype.readValue = function () { + return bignumber_1.BigNumber.from(this.readBytes(this.wordSize)); + }; + return Reader; +}()); +exports.Reader = Reader; diff --git a/packages/abi/lib/coders/address.d.ts b/packages/abi/lib/coders/address.d.ts new file mode 100644 index 000000000..d2ae49050 --- /dev/null +++ b/packages/abi/lib/coders/address.d.ts @@ -0,0 +1,6 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class AddressCoder extends Coder { + constructor(localName: string); + encode(writer: Writer, value: string): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/address.js b/packages/abi/lib/coders/address.js new file mode 100644 index 000000000..6269674d7 --- /dev/null +++ b/packages/abi/lib/coders/address.js @@ -0,0 +1,38 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var address_1 = require("@ethersproject/address"); +var bytes_1 = require("@ethersproject/bytes"); +var abstract_coder_1 = require("./abstract-coder"); +var AddressCoder = /** @class */ (function (_super) { + __extends(AddressCoder, _super); + function AddressCoder(localName) { + return _super.call(this, "address", "address", localName, false) || this; + } + AddressCoder.prototype.encode = function (writer, value) { + try { + address_1.getAddress(value); + } + catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + }; + AddressCoder.prototype.decode = function (reader) { + return address_1.getAddress(bytes_1.hexZeroPad(reader.readValue().toHexString(), 20)); + }; + return AddressCoder; +}(abstract_coder_1.Coder)); +exports.AddressCoder = AddressCoder; diff --git a/packages/abi/lib/coders/anonymous.d.ts b/packages/abi/lib/coders/anonymous.d.ts new file mode 100644 index 000000000..ccfffbb4f --- /dev/null +++ b/packages/abi/lib/coders/anonymous.d.ts @@ -0,0 +1,7 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class AnonymousCoder extends Coder { + private coder; + constructor(coder: Coder); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/anonymous.js b/packages/abi/lib/coders/anonymous.js new file mode 100644 index 000000000..6c71bf02a --- /dev/null +++ b/packages/abi/lib/coders/anonymous.js @@ -0,0 +1,33 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +// Clones the functionality of an existing Coder, but without a localName +var AnonymousCoder = /** @class */ (function (_super) { + __extends(AnonymousCoder, _super); + function AnonymousCoder(coder) { + var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this; + _this.coder = coder; + return _this; + } + AnonymousCoder.prototype.encode = function (writer, value) { + return this.coder.encode(writer, value); + }; + AnonymousCoder.prototype.decode = function (reader) { + return this.coder.decode(reader); + }; + return AnonymousCoder; +}(abstract_coder_1.Coder)); +exports.AnonymousCoder = AnonymousCoder; diff --git a/packages/abi/lib/coders/array.d.ts b/packages/abi/lib/coders/array.d.ts new file mode 100644 index 000000000..c101cbae6 --- /dev/null +++ b/packages/abi/lib/coders/array.d.ts @@ -0,0 +1,10 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare function pack(writer: Writer, coders: Array, values: Array): number; +export declare function unpack(reader: Reader, coders: Array): Array; +export declare class ArrayCoder extends Coder { + readonly coder: Coder; + readonly length: number; + constructor(coder: Coder, length: number, localName: string); + encode(writer: Writer, value: Array): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/array.js b/packages/abi/lib/coders/array.js new file mode 100644 index 000000000..e1689dce3 --- /dev/null +++ b/packages/abi/lib/coders/array.js @@ -0,0 +1,147 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var logger_1 = require("@ethersproject/logger"); +var _version_1 = require("../_version"); +var logger = new logger_1.Logger(_version_1.version); +var abstract_coder_1 = require("./abstract-coder"); +var anonymous_1 = require("./anonymous"); +function pack(writer, coders, values) { + if (Array.isArray(values)) { + // do nothing + } + else if (values && typeof (values) === "object") { + var arrayValues_1 = []; + coders.forEach(function (coder) { + arrayValues_1.push(values[coder.localName]); + }); + values = arrayValues_1; + } + else { + logger.throwArgumentError("invalid tuple value", "tuple", values); + } + if (coders.length !== values.length) { + logger.throwArgumentError("types/value length mismatch", "tuple", values); + } + var staticWriter = new abstract_coder_1.Writer(writer.wordSize); + var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize); + var updateFuncs = []; + coders.forEach(function (coder, index) { + var value = values[index]; + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + var dynamicOffset_1 = dynamicWriter.length; + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + // Prepare to populate the correct offset once we are done + var updateFunc_1 = staticWriter.writeUpdatableValue(); + updateFuncs.push(function (baseOffset) { + updateFunc_1(baseOffset + dynamicOffset_1); + }); + } + else { + coder.encode(staticWriter, value); + } + }); + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach(function (func) { func(staticWriter.length); }); + var length = writer.writeBytes(staticWriter.data); + length += writer.writeBytes(dynamicWriter.data); + return length; +} +exports.pack = pack; +function unpack(reader, coders) { + var values = []; + // A reader anchored to this base + var baseReader = reader.subReader(0); + // The amount of dynamic data read; to consume later to synchronize + var dynamicLength = 0; + coders.forEach(function (coder) { + var value = null; + if (coder.dynamic) { + var offset = reader.readValue(); + var offsetReader = baseReader.subReader(offset.toNumber()); + value = coder.decode(offsetReader); + dynamicLength += offsetReader.consumed; + } + else { + value = coder.decode(reader); + } + if (value != undefined) { + values.push(value); + } + }); + // @TODO: get rid of this an see if it still works? + // Consume the dynamic components in the main reader + reader.readBytes(dynamicLength); + // Add any named parameters (i.e. tuples) + coders.forEach(function (coder, index) { + var name = coder.localName; + if (!name) { + return; + } + if (name === "length") { + name = "_length"; + } + if (values[name] != null) { + return; + } + values[name] = values[index]; + }); + return values; +} +exports.unpack = unpack; +var ArrayCoder = /** @class */ (function (_super) { + __extends(ArrayCoder, _super); + function ArrayCoder(coder, length, localName) { + var _this = this; + var type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); + var dynamic = (length === -1 || coder.dynamic); + _this = _super.call(this, "array", type, localName, dynamic) || this; + _this.coder = coder; + _this.length = length; + return _this; + } + ArrayCoder.prototype.encode = function (writer, value) { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + var count = this.length; + //let result = new Uint8Array(0); + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + logger.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); + var coders = []; + for (var i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + }; + ArrayCoder.prototype.decode = function (reader) { + var count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + } + var coders = []; + for (var i = 0; i < count; i++) { + coders.push(new anonymous_1.AnonymousCoder(this.coder)); + } + return reader.coerce(this.name, unpack(reader, coders)); + }; + return ArrayCoder; +}(abstract_coder_1.Coder)); +exports.ArrayCoder = ArrayCoder; diff --git a/packages/abi/lib/coders/boolean.d.ts b/packages/abi/lib/coders/boolean.d.ts new file mode 100644 index 000000000..bce9af23b --- /dev/null +++ b/packages/abi/lib/coders/boolean.d.ts @@ -0,0 +1,6 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class BooleanCoder extends Coder { + constructor(localName: string); + encode(writer: Writer, value: boolean): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/boolean.js b/packages/abi/lib/coders/boolean.js new file mode 100644 index 000000000..b1fb92fa8 --- /dev/null +++ b/packages/abi/lib/coders/boolean.js @@ -0,0 +1,30 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +var BooleanCoder = /** @class */ (function (_super) { + __extends(BooleanCoder, _super); + function BooleanCoder(localName) { + return _super.call(this, "bool", "bool", localName, false) || this; + } + BooleanCoder.prototype.encode = function (writer, value) { + return writer.writeValue(value ? 1 : 0); + }; + BooleanCoder.prototype.decode = function (reader) { + return reader.coerce(this.type, !reader.readValue().isZero()); + }; + return BooleanCoder; +}(abstract_coder_1.Coder)); +exports.BooleanCoder = BooleanCoder; diff --git a/packages/abi/lib/coders/bytes.d.ts b/packages/abi/lib/coders/bytes.d.ts new file mode 100644 index 000000000..02d94fcb0 --- /dev/null +++ b/packages/abi/lib/coders/bytes.d.ts @@ -0,0 +1,10 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class DynamicBytesCoder extends Coder { + constructor(type: string, localName: string); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} +export declare class BytesCoder extends DynamicBytesCoder { + constructor(localName: string); + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/bytes.js b/packages/abi/lib/coders/bytes.js new file mode 100644 index 000000000..67633b1c4 --- /dev/null +++ b/packages/abi/lib/coders/bytes.js @@ -0,0 +1,45 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var abstract_coder_1 = require("./abstract-coder"); +var DynamicBytesCoder = /** @class */ (function (_super) { + __extends(DynamicBytesCoder, _super); + function DynamicBytesCoder(type, localName) { + return _super.call(this, type, type, localName, true) || this; + } + DynamicBytesCoder.prototype.encode = function (writer, value) { + value = bytes_1.arrayify(value); + var length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + }; + DynamicBytesCoder.prototype.decode = function (reader) { + return reader.readBytes(reader.readValue().toNumber()); + }; + return DynamicBytesCoder; +}(abstract_coder_1.Coder)); +exports.DynamicBytesCoder = DynamicBytesCoder; +var BytesCoder = /** @class */ (function (_super) { + __extends(BytesCoder, _super); + function BytesCoder(localName) { + return _super.call(this, "bytes", localName) || this; + } + BytesCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, bytes_1.hexlify(_super.prototype.decode.call(this, reader))); + }; + return BytesCoder; +}(DynamicBytesCoder)); +exports.BytesCoder = BytesCoder; diff --git a/packages/abi/lib/coders/fixed-bytes.d.ts b/packages/abi/lib/coders/fixed-bytes.d.ts new file mode 100644 index 000000000..19c368726 --- /dev/null +++ b/packages/abi/lib/coders/fixed-bytes.d.ts @@ -0,0 +1,8 @@ +import { BytesLike } from "@ethersproject/bytes"; +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class FixedBytesCoder extends Coder { + readonly size: number; + constructor(size: number, localName: string); + encode(writer: Writer, value: BytesLike): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/fixed-bytes.js b/packages/abi/lib/coders/fixed-bytes.js new file mode 100644 index 000000000..277de2fc8 --- /dev/null +++ b/packages/abi/lib/coders/fixed-bytes.js @@ -0,0 +1,40 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var bytes_1 = require("@ethersproject/bytes"); +var abstract_coder_1 = require("./abstract-coder"); +// @TODO: Merge this with bytes +var FixedBytesCoder = /** @class */ (function (_super) { + __extends(FixedBytesCoder, _super); + function FixedBytesCoder(size, localName) { + var _this = this; + var name = "bytes" + String(size); + _this = _super.call(this, name, name, localName, false) || this; + _this.size = size; + return _this; + } + FixedBytesCoder.prototype.encode = function (writer, value) { + var data = bytes_1.arrayify(value); + if (data.length !== this.size) { + this._throwError("incorrect data length", value); + } + return writer.writeBytes(data); + }; + FixedBytesCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, bytes_1.hexlify(reader.readBytes(this.size))); + }; + return FixedBytesCoder; +}(abstract_coder_1.Coder)); +exports.FixedBytesCoder = FixedBytesCoder; diff --git a/packages/abi/lib/coders/null.d.ts b/packages/abi/lib/coders/null.d.ts new file mode 100644 index 000000000..4ce6570a3 --- /dev/null +++ b/packages/abi/lib/coders/null.d.ts @@ -0,0 +1,6 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class NullCoder extends Coder { + constructor(localName: string); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/null.js b/packages/abi/lib/coders/null.js new file mode 100644 index 000000000..0408da3a1 --- /dev/null +++ b/packages/abi/lib/coders/null.js @@ -0,0 +1,34 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +var NullCoder = /** @class */ (function (_super) { + __extends(NullCoder, _super); + function NullCoder(localName) { + return _super.call(this, "null", "", localName, false) || this; + } + NullCoder.prototype.encode = function (writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes([]); + }; + NullCoder.prototype.decode = function (reader) { + reader.readBytes(0); + return reader.coerce(this.name, null); + }; + return NullCoder; +}(abstract_coder_1.Coder)); +exports.NullCoder = NullCoder; diff --git a/packages/abi/lib/coders/number.d.ts b/packages/abi/lib/coders/number.d.ts new file mode 100644 index 000000000..3bae1ef65 --- /dev/null +++ b/packages/abi/lib/coders/number.d.ts @@ -0,0 +1,9 @@ +import { BigNumberish } from "@ethersproject/bignumber"; +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class NumberCoder extends Coder { + readonly size: number; + readonly signed: boolean; + constructor(size: number, signed: boolean, localName: string); + encode(writer: Writer, value: BigNumberish): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/number.js b/packages/abi/lib/coders/number.js new file mode 100644 index 000000000..12fa44554 --- /dev/null +++ b/packages/abi/lib/coders/number.js @@ -0,0 +1,57 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var bignumber_1 = require("@ethersproject/bignumber"); +var constants_1 = require("@ethersproject/constants"); +var abstract_coder_1 = require("./abstract-coder"); +var NumberCoder = /** @class */ (function (_super) { + __extends(NumberCoder, _super); + function NumberCoder(size, signed, localName) { + var _this = this; + var name = ((signed ? "int" : "uint") + (size * 8)); + _this = _super.call(this, name, name, localName, false) || this; + _this.size = size; + _this.signed = signed; + return _this; + } + NumberCoder.prototype.encode = function (writer, value) { + var v = bignumber_1.BigNumber.from(value); + // Check bounds are safe for encoding + var maxUintValue = constants_1.MaxUint256.maskn(writer.wordSize * 8); + if (this.signed) { + var bounds = maxUintValue.maskn(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { + this._throwError("value out-of-bounds", value); + } + } + else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + v = v.toTwos(this.size * 8).maskn(this.size * 8); + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + return writer.writeValue(v); + }; + NumberCoder.prototype.decode = function (reader) { + var value = reader.readValue().maskn(this.size * 8); + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + return reader.coerce(this.name, value); + }; + return NumberCoder; +}(abstract_coder_1.Coder)); +exports.NumberCoder = NumberCoder; diff --git a/packages/abi/lib/coders/string.d.ts b/packages/abi/lib/coders/string.d.ts new file mode 100644 index 000000000..36f293b4f --- /dev/null +++ b/packages/abi/lib/coders/string.d.ts @@ -0,0 +1,7 @@ +import { Reader, Writer } from "./abstract-coder"; +import { DynamicBytesCoder } from "./bytes"; +export declare class StringCoder extends DynamicBytesCoder { + constructor(localName: string); + encode(writer: Writer, value: any): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/string.js b/packages/abi/lib/coders/string.js new file mode 100644 index 000000000..ba395a3af --- /dev/null +++ b/packages/abi/lib/coders/string.js @@ -0,0 +1,31 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var strings_1 = require("@ethersproject/strings"); +var bytes_1 = require("./bytes"); +var StringCoder = /** @class */ (function (_super) { + __extends(StringCoder, _super); + function StringCoder(localName) { + return _super.call(this, "string", localName) || this; + } + StringCoder.prototype.encode = function (writer, value) { + return _super.prototype.encode.call(this, writer, strings_1.toUtf8Bytes(value)); + }; + StringCoder.prototype.decode = function (reader) { + return strings_1.toUtf8String(_super.prototype.decode.call(this, reader)); + }; + return StringCoder; +}(bytes_1.DynamicBytesCoder)); +exports.StringCoder = StringCoder; diff --git a/packages/abi/lib/coders/tuple.d.ts b/packages/abi/lib/coders/tuple.d.ts new file mode 100644 index 000000000..e7b67bb85 --- /dev/null +++ b/packages/abi/lib/coders/tuple.d.ts @@ -0,0 +1,7 @@ +import { Coder, Reader, Writer } from "./abstract-coder"; +export declare class TupleCoder extends Coder { + readonly coders: Array; + constructor(coders: Array, localName: string); + encode(writer: Writer, value: Array): number; + decode(reader: Reader): any; +} diff --git a/packages/abi/lib/coders/tuple.js b/packages/abi/lib/coders/tuple.js new file mode 100644 index 000000000..7d9253883 --- /dev/null +++ b/packages/abi/lib/coders/tuple.js @@ -0,0 +1,43 @@ +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); +var abstract_coder_1 = require("./abstract-coder"); +var array_1 = require("./array"); +var TupleCoder = /** @class */ (function (_super) { + __extends(TupleCoder, _super); + function TupleCoder(coders, localName) { + var _this = this; + var dynamic = false; + var types = []; + coders.forEach(function (coder) { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + var type = ("tuple(" + types.join(",") + ")"); + _this = _super.call(this, "tuple", type, localName, dynamic) || this; + _this.coders = coders; + return _this; + } + TupleCoder.prototype.encode = function (writer, value) { + return array_1.pack(writer, this.coders, value); + }; + TupleCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, array_1.unpack(reader, this.coders)); + }; + return TupleCoder; +}(abstract_coder_1.Coder)); +exports.TupleCoder = TupleCoder; diff --git a/packages/abi/lib/fragments.d.ts b/packages/abi/lib/fragments.d.ts new file mode 100644 index 000000000..873ceb77a --- /dev/null +++ b/packages/abi/lib/fragments.d.ts @@ -0,0 +1,76 @@ +import { BigNumber } from "@ethersproject/bignumber"; +export interface JsonFragmentType { + name?: string; + indexed?: boolean; + type?: string; + components?: Array; +} +export interface JsonFragment { + name?: string; + type?: string; + anonymous?: boolean; + payable?: boolean; + constant?: boolean; + stateMutability?: string; + inputs?: Array; + outputs?: Array; + gas?: string; +} +export declare const FormatTypes: { + [name: string]: string; +}; +export declare class ParamType { + readonly name: string; + readonly type: string; + readonly baseType: string; + readonly indexed: boolean; + readonly components: Array; + readonly arrayLength: number; + readonly arrayChildren: ParamType; + readonly _isParamType: boolean; + constructor(constructorGuard: any, params: any); + format(format?: string): string; + static from(value: string | JsonFragmentType | ParamType, allowIndexed?: boolean): ParamType; + static fromObject(value: JsonFragmentType | ParamType): ParamType; + static fromString(value: string, allowIndexed?: boolean): ParamType; + static isParamType(value: any): value is ParamType; +} +export declare abstract class Fragment { + readonly type: string; + readonly name: string; + readonly inputs: Array; + readonly _isFragment: boolean; + constructor(constructorGuard: any, params: any); + abstract format(format?: string): string; + static from(value: Fragment | JsonFragment | string): Fragment; + static fromObject(value: Fragment | JsonFragment): Fragment; + static fromString(value: string): Fragment; + static isFragment(value: any): value is Fragment; +} +export declare class EventFragment extends Fragment { + readonly anonymous: boolean; + format(format?: string): string; + static from(value: EventFragment | JsonFragment | string): EventFragment; + static fromObject(value: JsonFragment | EventFragment): EventFragment; + static fromString(value: string): EventFragment; + static isEventFragment(value: any): value is EventFragment; +} +export declare class ConstructorFragment extends Fragment { + stateMutability: string; + payable: boolean; + gas?: BigNumber; + format(format?: string): string; + static from(value: ConstructorFragment | JsonFragment | string): ConstructorFragment; + static fromObject(value: ConstructorFragment | JsonFragment): ConstructorFragment; + static fromString(value: string): ConstructorFragment; + static isConstructorFragment(value: any): value is ConstructorFragment; +} +export declare class FunctionFragment extends ConstructorFragment { + constant: boolean; + outputs?: Array; + format(format?: string): string; + static from(value: FunctionFragment | JsonFragment | string): FunctionFragment; + static fromObject(value: FunctionFragment | JsonFragment): FunctionFragment; + static fromString(value: string): FunctionFragment; + static isFunctionFragment(value: any): value is FunctionFragment; +} diff --git a/packages/abi/fragments.js b/packages/abi/lib/fragments.js similarity index 100% rename from packages/abi/fragments.js rename to packages/abi/lib/fragments.js diff --git a/packages/abi/lib/index.d.ts b/packages/abi/lib/index.d.ts new file mode 100644 index 000000000..91d6e9077 --- /dev/null +++ b/packages/abi/lib/index.d.ts @@ -0,0 +1,4 @@ +import { ConstructorFragment, EventFragment, FormatTypes, Fragment, FunctionFragment, JsonFragment, JsonFragmentType, ParamType } from "./fragments"; +import { AbiCoder, CoerceFunc, defaultAbiCoder } from "./abi-coder"; +import { Indexed, Interface } from "./interface"; +export { ConstructorFragment, EventFragment, Fragment, FunctionFragment, ParamType, FormatTypes, AbiCoder, defaultAbiCoder, Interface, Indexed, CoerceFunc, JsonFragment, JsonFragmentType }; diff --git a/packages/abi/index.js b/packages/abi/lib/index.js similarity index 100% rename from packages/abi/index.js rename to packages/abi/lib/index.js diff --git a/packages/abi/lib/interface.d.ts b/packages/abi/lib/interface.d.ts new file mode 100644 index 000000000..2c41d2cd6 --- /dev/null +++ b/packages/abi/lib/interface.d.ts @@ -0,0 +1,70 @@ +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { BytesLike } from "@ethersproject/bytes"; +import { Description } from "@ethersproject/properties"; +import { AbiCoder } from "./abi-coder"; +import { ConstructorFragment, EventFragment, Fragment, FunctionFragment, JsonFragment, ParamType } from "./fragments"; +export declare class LogDescription extends Description { + readonly eventFragment: EventFragment; + readonly name: string; + readonly signature: string; + readonly topic: string; + readonly values: any; +} +export declare class TransactionDescription extends Description { + readonly functionFragment: FunctionFragment; + readonly name: string; + readonly args: Array; + readonly signature: string; + readonly sighash: string; + readonly value: BigNumber; +} +export declare class Indexed extends Description { + readonly hash: string; + static isIndexed(value: any): value is Indexed; +} +export declare class Result { + [key: string]: any; + [key: number]: any; +} +export declare class Interface { + readonly fragments: Array; + readonly errors: { + [name: string]: any; + }; + readonly events: { + [name: string]: EventFragment; + }; + readonly functions: { + [name: string]: FunctionFragment; + }; + readonly structs: { + [name: string]: any; + }; + readonly deploy: ConstructorFragment; + readonly _abiCoder: AbiCoder; + static _isInterface: boolean; + constructor(fragments: string | Array); + static getAbiCoder(): AbiCoder; + static getAddress(address: string): string; + _sighashify(functionFragment: FunctionFragment): string; + _topicify(eventFragment: EventFragment): string; + getFunction(nameOrSignatureOrSighash: string): FunctionFragment; + getEvent(nameOrSignatureOrTopic: string): EventFragment; + getSighash(functionFragment: FunctionFragment | string): string; + getEventTopic(eventFragment: EventFragment | string): string; + _encodeParams(params: Array, values: Array): string; + encodeDeploy(values?: Array): string; + encodeFunctionData(functionFragment: FunctionFragment | string, values?: Array): string; + decodeFunctionResult(functionFragment: FunctionFragment | string, data: BytesLike): Array; + encodeFilterTopics(eventFragment: EventFragment, values: Array): Array>; + decodeEventLog(eventFragment: EventFragment | string, data: BytesLike, topics?: Array): Array; + parseTransaction(tx: { + data: string; + value?: BigNumberish; + }): TransactionDescription; + parseLog(log: { + topics: Array; + data: string; + }): LogDescription; + static isInterface(value: any): value is Interface; +} diff --git a/packages/abi/interface.js b/packages/abi/lib/interface.js similarity index 100% rename from packages/abi/interface.js rename to packages/abi/lib/interface.js diff --git a/packages/abi/package.json b/packages/abi/package.json index fe92773c5..b32ecef7b 100644 --- a/packages/abi/package.json +++ b/packages/abi/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/abi", - "version": "5.0.0-beta.136", + "version": "5.0.0-beta.137", "description": "Utilities and Classes for parsing, formatting and managing Ethereum ABIs.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -30,5 +30,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x9585dafdf431d8f83f4eb02869142a31ef6dfec6638c5706517d012eb363ad47" + "module": "./lib.esm/index.js", + "tarballHash": "0x39e9e020225c070444d3030a0423e986c5c8b25ee3279341641f4b6bf343f4a2" } diff --git a/packages/abi/src.ts/coders/abstract-coder.ts b/packages/abi/src.ts/coders/abstract-coder.ts index 0b5702bda..704eefeb1 100644 --- a/packages/abi/src.ts/coders/abstract-coder.ts +++ b/packages/abi/src.ts/coders/abstract-coder.ts @@ -1,4 +1,4 @@ -"use trict"; +"use strict"; import { arrayify, BytesLike, concat, hexlify } from "@ethersproject/bytes"; import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; diff --git a/packages/abi/test-coder.js b/packages/abi/test-coder.js deleted file mode 100644 index 6969951d2..000000000 --- a/packages/abi/test-coder.js +++ /dev/null @@ -1,4 +0,0 @@ -let { defaultAbiCoder } = require("."); - -console.log(defaultAbiCoder); -console.log(defaultAbiCoder.encode([ "uint256", "bytes" ], [ 42, "0x1234" ])); diff --git a/packages/abi/tsconfig.json b/packages/abi/tsconfig.json index bbf8508be..483148b9f 100644 --- a/packages/abi/tsconfig.json +++ b/packages/abi/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts", - "./src.ts/coders/*.ts" + "./src.ts/*.ts", + "./src.ts/coders/*.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/abstract-provider/_version.d.ts b/packages/abstract-provider/lib.esm/_version.d.ts similarity index 100% rename from packages/abstract-provider/_version.d.ts rename to packages/abstract-provider/lib.esm/_version.d.ts diff --git a/packages/abstract-provider/lib.esm/_version.js b/packages/abstract-provider/lib.esm/_version.js new file mode 100644 index 000000000..78745f9d3 --- /dev/null +++ b/packages/abstract-provider/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "abstract-provider/5.0.0-beta.130"; diff --git a/packages/abstract-provider/index.d.ts b/packages/abstract-provider/lib.esm/index.d.ts similarity index 100% rename from packages/abstract-provider/index.d.ts rename to packages/abstract-provider/lib.esm/index.d.ts diff --git a/packages/abstract-provider/lib.esm/index.js b/packages/abstract-provider/lib.esm/index.js new file mode 100644 index 000000000..e54bdcc71 --- /dev/null +++ b/packages/abstract-provider/lib.esm/index.js @@ -0,0 +1,78 @@ +"use strict"; +import { isHexString } from "@ethersproject/bytes"; +import { Description, defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +; +; +//export type CallTransactionable = { +// call(transaction: TransactionRequest): Promise; +//}; +export class ForkEvent extends Description { + static isForkEvent(value) { + return !!(value && value._isForkEvent); + } +} +export class BlockForkEvent extends ForkEvent { + constructor(blockhash, expiry) { + if (!isHexString(blockhash, 32)) { + logger.throwArgumentError("invalid blockhash", "blockhash", blockhash); + } + super({ + _isForkEvent: true, + _isBlockForkEvent: true, + expiry: (expiry || 0), + blockHash: blockhash + }); + } +} +export class TransactionForkEvent extends ForkEvent { + constructor(hash, expiry) { + if (!isHexString(hash, 32)) { + logger.throwArgumentError("invalid transaction hash", "hash", hash); + } + super({ + _isForkEvent: true, + _isTransactionForkEvent: true, + expiry: (expiry || 0), + hash: hash + }); + } +} +export class TransactionOrderForkEvent extends ForkEvent { + constructor(beforeHash, afterHash, expiry) { + if (!isHexString(beforeHash, 32)) { + logger.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + } + if (!isHexString(afterHash, 32)) { + logger.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + } + super({ + _isForkEvent: true, + _isTransactionOrderForkEvent: true, + expiry: (expiry || 0), + beforeHash: beforeHash, + afterHash: afterHash + }); + } +} +/////////////////////////////// +// Exported Abstracts +export class Provider { + // Alias for "on" + addListener(eventName, listener) { + return this.on(eventName, listener); + } + // Alias for "off" + removeListener(eventName, listener) { + return this.off(eventName, listener); + } + constructor() { + logger.checkAbstract(new.target, Provider); + defineReadOnly(this, "_isProvider", true); + } + static isProvider(value) { + return !!(value && value._isProvider); + } +} diff --git a/packages/abstract-provider/lib/_version.d.ts b/packages/abstract-provider/lib/_version.d.ts new file mode 100644 index 000000000..81d34fa12 --- /dev/null +++ b/packages/abstract-provider/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "abstract-provider/5.0.0-beta.130"; diff --git a/packages/abstract-provider/_version.js b/packages/abstract-provider/lib/_version.js similarity index 100% rename from packages/abstract-provider/_version.js rename to packages/abstract-provider/lib/_version.js diff --git a/packages/abstract-provider/lib/index.d.ts b/packages/abstract-provider/lib/index.d.ts new file mode 100644 index 000000000..aae2ba804 --- /dev/null +++ b/packages/abstract-provider/lib/index.d.ts @@ -0,0 +1,138 @@ +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { BytesLike } from "@ethersproject/bytes"; +import { Network } from "@ethersproject/networks"; +import { Description } from "@ethersproject/properties"; +import { Transaction } from "@ethersproject/transactions"; +import { OnceBlockable } from "@ethersproject/web"; +export declare type TransactionRequest = { + to?: string | Promise; + from?: string | Promise; + nonce?: BigNumberish | Promise; + gasLimit?: BigNumberish | Promise; + gasPrice?: BigNumberish | Promise; + data?: BytesLike | Promise; + value?: BigNumberish | Promise; + chainId?: number | Promise; +}; +export interface TransactionResponse extends Transaction { + hash: string; + blockNumber?: number; + blockHash?: string; + timestamp?: number; + confirmations: number; + from: string; + raw?: string; + wait: (confirmations?: number) => Promise; +} +export declare type BlockTag = string | number; +interface _Block { + hash: string; + parentHash: string; + number: number; + timestamp: number; + nonce: string; + difficulty: number; + gasLimit: BigNumber; + gasUsed: BigNumber; + miner: string; + extraData: string; +} +export interface Block extends _Block { + transactions: Array; +} +export interface BlockWithTransactions extends _Block { + transactions: Array; +} +export interface Log { + blockNumber?: number; + blockHash?: string; + transactionIndex?: number; + removed?: boolean; + transactionLogIndex?: number; + address: string; + data: string; + topics: Array; + transactionHash?: string; + logIndex?: number; +} +export interface TransactionReceipt { + to?: string; + from?: string; + contractAddress?: string; + transactionIndex?: number; + root?: string; + gasUsed?: BigNumber; + logsBloom?: string; + blockHash?: string; + transactionHash?: string; + logs?: Array; + blockNumber?: number; + confirmations?: number; + cumulativeGasUsed?: BigNumber; + byzantium: boolean; + status?: number; +} +export interface EventFilter { + address?: string; + topics?: Array>; +} +export interface Filter extends EventFilter { + fromBlock?: BlockTag; + toBlock?: BlockTag; +} +export interface FilterByBlockHash extends EventFilter { + blockhash?: string; +} +export declare abstract class ForkEvent extends Description { + readonly expiry: number; + readonly _isForkEvent: boolean; + static isForkEvent(value: any): value is ForkEvent; +} +export declare class BlockForkEvent extends ForkEvent { + readonly blockhash: string; + constructor(blockhash: string, expiry?: number); +} +export declare class TransactionForkEvent extends ForkEvent { + readonly hash: string; + constructor(hash: string, expiry?: number); +} +export declare class TransactionOrderForkEvent extends ForkEvent { + readonly beforeHash: string; + readonly afterHash: string; + constructor(beforeHash: string, afterHash: string, expiry?: number); +} +export declare type EventType = string | Array> | EventFilter | ForkEvent; +export declare type Listener = (...args: Array) => void; +export declare abstract class Provider implements OnceBlockable { + abstract getNetwork(): Promise; + abstract getBlockNumber(): Promise; + abstract getGasPrice(): Promise; + abstract getBalance(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + abstract getTransactionCount(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + abstract getCode(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + abstract getStorageAt(addressOrName: string | Promise, position: BigNumberish | Promise, blockTag?: BlockTag | Promise): Promise; + abstract sendTransaction(signedTransaction: string | Promise): Promise; + abstract call(transaction: TransactionRequest, blockTag?: BlockTag | Promise): Promise; + abstract estimateGas(transaction: TransactionRequest): Promise; + abstract getBlock(blockHashOrBlockTag: BlockTag | string | Promise): Promise; + abstract getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise): Promise; + abstract getTransaction(transactionHash: string): Promise; + abstract getTransactionReceipt(transactionHash: string): Promise; + abstract getLogs(filter: Filter): Promise>; + abstract resolveName(name: string | Promise): Promise; + abstract lookupAddress(address: string | Promise): Promise; + abstract on(eventName: EventType, listener: Listener): Provider; + abstract once(eventName: EventType, listener: Listener): Provider; + abstract emit(eventName: EventType, ...args: Array): boolean; + abstract listenerCount(eventName?: EventType): number; + abstract listeners(eventName?: EventType): Array; + abstract off(eventName: EventType, listener?: Listener): Provider; + abstract removeAllListeners(eventName?: EventType): Provider; + addListener(eventName: EventType, listener: Listener): Provider; + removeListener(eventName: EventType, listener: Listener): Provider; + abstract waitForTransaction(transactionHash: string, timeout?: number): Promise; + readonly _isProvider: boolean; + constructor(); + static isProvider(value: any): value is Provider; +} +export {}; diff --git a/packages/abstract-provider/index.js b/packages/abstract-provider/lib/index.js similarity index 100% rename from packages/abstract-provider/index.js rename to packages/abstract-provider/lib/index.js diff --git a/packages/abstract-provider/package.json b/packages/abstract-provider/package.json index 930048648..5ded80d7e 100644 --- a/packages/abstract-provider/package.json +++ b/packages/abstract-provider/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/abstract-provider", - "version": "5.0.0-beta.130", + "version": "5.0.0-beta.131", "description": "An Abstract Class for describing an Ethereum Provider for ethers.", - "main": "index.js", + "main": "./lib/index.js", "browser": { "net": "./browser-net.js", "./ipc-provider": "./browser-ipc-provider" @@ -32,5 +32,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x38d6dbab6c91fea9f20ed556d76842c9ac28e4542b997401d3e965156d1373e6" + "module": "./lib.esm/index.js", + "tarballHash": "0x4b955417ad50b4c8fa7d7ac8f3de84a9f7948381e3f79f6e301a1bdfdd95066c" } diff --git a/packages/abstract-provider/tsconfig.json b/packages/abstract-provider/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/abstract-provider/tsconfig.json +++ b/packages/abstract-provider/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/abstract-signer/_version.d.ts b/packages/abstract-signer/lib.esm/_version.d.ts similarity index 100% rename from packages/abstract-signer/_version.d.ts rename to packages/abstract-signer/lib.esm/_version.d.ts diff --git a/packages/abstract-signer/lib.esm/_version.js b/packages/abstract-signer/lib.esm/_version.js new file mode 100644 index 000000000..200176e25 --- /dev/null +++ b/packages/abstract-signer/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "abstract-signer/5.0.0-beta.131"; diff --git a/packages/abstract-signer/index.d.ts b/packages/abstract-signer/lib.esm/index.d.ts similarity index 100% rename from packages/abstract-signer/index.d.ts rename to packages/abstract-signer/lib.esm/index.d.ts diff --git a/packages/abstract-signer/lib.esm/index.js b/packages/abstract-signer/lib.esm/index.js new file mode 100644 index 000000000..2b39c01de --- /dev/null +++ b/packages/abstract-signer/lib.esm/index.js @@ -0,0 +1,168 @@ +"use strict"; +import { defineReadOnly, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +const allowedTransactionKeys = [ + "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" +]; +// Sub-Class Notes: +// - A Signer MUST always make sure, that if present, the "from" field +// matches the Signer, before sending or signing a transaction +// - A Signer SHOULD always wrap private information (such as a private +// key or mnemonic) in a function, so that console.log does not leak +// the data +export class Signer { + /////////////////// + // Sub-classes MUST call super + constructor() { + logger.checkAbstract(new.target, Signer); + defineReadOnly(this, "_isSigner", true); + } + /////////////////// + // Sub-classes MAY override these + getBalance(blockTag) { + this._checkProvider("getBalance"); + return this.provider.getBalance(this.getAddress(), blockTag); + } + getTransactionCount(blockTag) { + this._checkProvider("getTransactionCount"); + return this.provider.getTransactionCount(this.getAddress(), blockTag); + } + // Populates "from" if unspecified, and estimates the gas for the transation + estimateGas(transaction) { + this._checkProvider("estimateGas"); + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + return this.provider.estimateGas(tx); + }); + } + // Populates "from" if unspecified, and calls with the transation + call(transaction, blockTag) { + this._checkProvider("call"); + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + return this.provider.call(tx); + }); + } + // Populates all fields in a transaction, signs it and sends it to the network + sendTransaction(transaction) { + this._checkProvider("sendTransaction"); + return this.populateTransaction(transaction).then((tx) => { + return this.signTransaction(tx).then((signedTx) => { + return this.provider.sendTransaction(signedTx); + }); + }); + } + getChainId() { + this._checkProvider("getChainId"); + return this.provider.getNetwork().then((network) => network.chainId); + } + getGasPrice() { + this._checkProvider("getGasPrice"); + return this.provider.getGasPrice(); + } + resolveName(name) { + this._checkProvider("resolveName"); + return this.provider.resolveName(name); + } + // Checks a transaction does not contain invalid keys and if + // no "from" is provided, populates it. + // - does NOT require a provider + // - adds "from" is not present + // - returns a COPY (safe to mutate the result) + // By default called from: (overriding these prevents it) + // - call + // - estimateGas + // - populateTransaction (and therefor sendTransaction) + checkTransaction(transaction) { + for (let key in transaction) { + if (allowedTransactionKeys.indexOf(key) === -1) { + logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + } + } + let tx = shallowCopy(transaction); + if (tx.from == null) { + tx.from = this.getAddress(); + } + return tx; + } + // Populates ALL keys for a transaction and checks that "from" matches + // this Signer. Should be used by sendTransaction but NOT by signTransaction. + // By default called from: (overriding these prevents it) + // - sendTransaction + populateTransaction(transaction) { + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + if (tx.to != null) { + tx.to = Promise.resolve(tx.to).then((to) => this.resolveName(to)); + } + if (tx.gasPrice == null) { + tx.gasPrice = this.getGasPrice(); + } + if (tx.nonce == null) { + tx.nonce = this.getTransactionCount("pending"); + } + // Make sure any provided address matches this signer + if (tx.from == null) { + tx.from = this.getAddress(); + } + else { + tx.from = Promise.all([ + this.getAddress(), + this.provider.resolveName(tx.from) + ]).then((results) => { + if (results[0] !== results[1]) { + logger.throwArgumentError("from address mismatch", "transaction", transaction); + } + return results[0]; + }); + } + if (tx.gasLimit == null) { + tx.gasLimit = this.estimateGas(tx).catch((error) => { + logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { + tx: tx + }); + }); + } + if (tx.chainId == null) { + tx.chainId = this.getChainId(); + } + return resolveProperties(tx); + }); + } + /////////////////// + // Sub-classes SHOULD leave these alone + _checkProvider(operation) { + if (!this.provider) { + logger.throwError("missing provider", Logger.errors.UNSUPPORTED_OPERATION, { + operation: (operation || "_checkProvider") + }); + } + } + static isSigner(value) { + return !!(value && value._isSigner); + } +} +export class VoidSigner extends Signer { + constructor(address, provider) { + logger.checkNew(new.target, VoidSigner); + super(); + defineReadOnly(this, "address", address); + defineReadOnly(this, "provider", provider || null); + } + getAddress() { + return Promise.resolve(this.address); + } + _fail(message, operation) { + return Promise.resolve().then(() => { + logger.throwError(message, Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); + }); + } + signMessage(message) { + return this._fail("VoidSigner cannot sign messages", "signMessage"); + } + signTransaction(transaction) { + return this._fail("VoidSigner cannot sign transactions", "signTransaction"); + } + connect(provider) { + return new VoidSigner(this.address, provider); + } +} diff --git a/packages/abstract-signer/lib/_version.d.ts b/packages/abstract-signer/lib/_version.d.ts new file mode 100644 index 000000000..a69dc5165 --- /dev/null +++ b/packages/abstract-signer/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "abstract-signer/5.0.0-beta.131"; diff --git a/packages/abstract-signer/_version.js b/packages/abstract-signer/lib/_version.js similarity index 100% rename from packages/abstract-signer/_version.js rename to packages/abstract-signer/lib/_version.js diff --git a/packages/abstract-signer/lib/index.d.ts b/packages/abstract-signer/lib/index.d.ts new file mode 100644 index 000000000..6d4da3af6 --- /dev/null +++ b/packages/abstract-signer/lib/index.d.ts @@ -0,0 +1,39 @@ +import { BlockTag, Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { BigNumber } from "@ethersproject/bignumber"; +import { Bytes } from "@ethersproject/bytes"; +export interface ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; +} +export declare abstract class Signer { + readonly provider?: Provider; + abstract getAddress(): Promise; + abstract signMessage(message: Bytes | string): Promise; + abstract signTransaction(transaction: TransactionRequest): Promise; + abstract connect(provider: Provider): Signer; + readonly _isSigner: boolean; + constructor(); + getBalance(blockTag?: BlockTag): Promise; + getTransactionCount(blockTag?: BlockTag): Promise; + estimateGas(transaction: TransactionRequest): Promise; + call(transaction: TransactionRequest, blockTag?: BlockTag): Promise; + sendTransaction(transaction: TransactionRequest): Promise; + getChainId(): Promise; + getGasPrice(): Promise; + resolveName(name: string): Promise; + checkTransaction(transaction: TransactionRequest): TransactionRequest; + populateTransaction(transaction: TransactionRequest): Promise; + _checkProvider(operation?: string): void; + static isSigner(value: any): value is Signer; +} +export declare class VoidSigner extends Signer { + readonly address: string; + constructor(address: string, provider?: Provider); + getAddress(): Promise; + _fail(message: string, operation: string): Promise; + signMessage(message: Bytes | string): Promise; + signTransaction(transaction: TransactionRequest): Promise; + connect(provider: Provider): VoidSigner; +} diff --git a/packages/abstract-signer/index.js b/packages/abstract-signer/lib/index.js similarity index 100% rename from packages/abstract-signer/index.js rename to packages/abstract-signer/lib/index.js diff --git a/packages/abstract-signer/package.json b/packages/abstract-signer/package.json index e46520dfe..ca2b3e339 100644 --- a/packages/abstract-signer/package.json +++ b/packages/abstract-signer/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/abstract-signer", - "version": "5.0.0-beta.131", + "version": "5.0.0-beta.132", "description": "An Abstract Class for desribing an Ethereum Signer for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x31639d3ac33e6e5a890cfa5dda469e77ea71ab285dcde95222d58b80d7aff82b" + "module": "./lib.esm/index.js", + "tarballHash": "0xaa4a4086f9fea3265ac7918227914cf63bf4dc082ea2bc4457dc009fafb51437" } diff --git a/packages/abstract-signer/tsconfig.json b/packages/abstract-signer/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/abstract-signer/tsconfig.json +++ b/packages/abstract-signer/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/address/_version.d.ts b/packages/address/lib.esm/_version.d.ts similarity index 100% rename from packages/address/_version.d.ts rename to packages/address/lib.esm/_version.d.ts diff --git a/packages/address/lib.esm/_version.js b/packages/address/lib.esm/_version.js new file mode 100644 index 000000000..af90c9cd6 --- /dev/null +++ b/packages/address/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "address/5.0.0-beta.127"; diff --git a/packages/address/index.d.ts b/packages/address/lib.esm/index.d.ts similarity index 100% rename from packages/address/index.d.ts rename to packages/address/lib.esm/index.d.ts diff --git a/packages/address/lib.esm/index.js b/packages/address/lib.esm/index.js new file mode 100644 index 000000000..706b3a2c5 --- /dev/null +++ b/packages/address/lib.esm/index.js @@ -0,0 +1,128 @@ +"use strict"; +// We use this for base 36 maths +import * as BN from "bn.js"; +import { arrayify, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes"; +import { keccak256 } from "@ethersproject/keccak256"; +import { encode } from "@ethersproject/rlp"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +function getChecksumAddress(address) { + if (!isHexString(address, 20)) { + logger.throwArgumentError("invalid address", "address", address); + } + address = address.toLowerCase(); + let chars = address.substring(2).split(""); + let hashed = new Uint8Array(40); + for (let i = 0; i < 40; i++) { + hashed[i] = chars[i].charCodeAt(0); + } + hashed = arrayify(keccak256(hashed)); + for (let i = 0; i < 40; i += 2) { + if ((hashed[i >> 1] >> 4) >= 8) { + chars[i] = chars[i].toUpperCase(); + } + if ((hashed[i >> 1] & 0x0f) >= 8) { + chars[i + 1] = chars[i + 1].toUpperCase(); + } + } + return "0x" + chars.join(""); +} +// Shims for environments that are missing some required constants and functions +const MAX_SAFE_INTEGER = 0x1fffffffffffff; +function log10(x) { + if (Math.log10) { + return Math.log10(x); + } + return Math.log(x) / Math.LN10; +} +// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number +// Create lookup table +let ibanLookup = {}; +for (let i = 0; i < 10; i++) { + ibanLookup[String(i)] = String(i); +} +for (let i = 0; i < 26; i++) { + ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); +} +// How many decimal digits can we process? (for 64-bit float, this is 15) +let safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); +function ibanChecksum(address) { + address = address.toUpperCase(); + address = address.substring(4) + address.substring(0, 2) + "00"; + let expanded = ""; + address.split("").forEach(function (c) { + expanded += ibanLookup[c]; + }); + // Javascript can handle integers safely up to 15 (decimal) digits + while (expanded.length >= safeDigits) { + let block = expanded.substring(0, safeDigits); + expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); + } + let checksum = String(98 - (parseInt(expanded, 10) % 97)); + while (checksum.length < 2) { + checksum = "0" + checksum; + } + return checksum; +} +; +export function getAddress(address) { + let result = null; + if (typeof (address) !== "string") { + logger.throwArgumentError("invalid address", "address", address); + } + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + // Missing the 0x prefix + if (address.substring(0, 2) !== "0x") { + address = "0x" + address; + } + result = getChecksumAddress(address); + // It is a checksummed address with a bad checksum + if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { + logger.throwArgumentError("bad address checksum", "address", address); + } + // Maybe ICAP? (we only support direct mode) + } + else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + // It is an ICAP address with a bad checksum + if (address.substring(2, 4) !== ibanChecksum(address)) { + logger.throwArgumentError("bad icap checksum", "address", address); + } + result = (new BN.BN(address.substring(4), 36)).toString(16); + while (result.length < 40) { + result = "0" + result; + } + result = getChecksumAddress("0x" + result); + } + else { + logger.throwArgumentError("invalid address", "address", address); + } + return result; +} +export function isAddress(address) { + try { + getAddress(address); + return true; + } + catch (error) { } + return false; +} +export function getIcapAddress(address) { + let base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + while (base36.length < 30) { + base36 = "0" + base36; + } + return "XE" + ibanChecksum("XE00" + base36) + base36; +} +// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed +export function getContractAddress(transaction) { + let from = null; + try { + from = getAddress(transaction.from); + } + catch (error) { + logger.throwArgumentError("missing from address", "transaction", transaction); + } + let nonce = stripZeros(arrayify(transaction.nonce)); + return getAddress(hexDataSlice(keccak256(encode([from, nonce])), 12)); +} diff --git a/packages/address/lib/_version.d.ts b/packages/address/lib/_version.d.ts new file mode 100644 index 000000000..bf93f2acf --- /dev/null +++ b/packages/address/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "address/5.0.0-beta.127"; diff --git a/packages/address/_version.js b/packages/address/lib/_version.js similarity index 100% rename from packages/address/_version.js rename to packages/address/lib/_version.js diff --git a/packages/address/lib/index.d.ts b/packages/address/lib/index.d.ts new file mode 100644 index 000000000..7cef8f243 --- /dev/null +++ b/packages/address/lib/index.d.ts @@ -0,0 +1,8 @@ +import { BigNumberish } from "@ethersproject/bignumber"; +export declare function getAddress(address: string): string; +export declare function isAddress(address: string): boolean; +export declare function getIcapAddress(address: string): string; +export declare function getContractAddress(transaction: { + from: string; + nonce: BigNumberish; +}): string; diff --git a/packages/address/index.js b/packages/address/lib/index.js similarity index 100% rename from packages/address/index.js rename to packages/address/lib/index.js diff --git a/packages/address/package.json b/packages/address/package.json index 36364edf6..1a297f7dc 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/address", - "version": "5.0.0-beta.127", + "version": "5.0.0-beta.128", "description": "Utilities for handling Ethereum Addresses for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -27,5 +27,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x55cfa7f3239ac053ed675090677f4c64b9fae6e1d0a7cd5431742c7b7e6267f8" + "module": "./lib.esm/index.js", + "tarballHash": "0xf52fe7ac31abf75d751e23e06fad681acee39ae9d1153f9c24d5feae7018f22d" } diff --git a/packages/address/tsconfig.json b/packages/address/tsconfig.json index f7c84c603..0a9d2f16c 100644 --- a/packages/address/tsconfig.json +++ b/packages/address/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ "./thirdparty.d.ts", "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/base64/.gitignore b/packages/base64/.gitignore index aa5c62527..ac0298ec4 100644 --- a/packages/base64/.gitignore +++ b/packages/base64/.gitignore @@ -1 +1,2 @@ -browser.d.ts +lib/browser.d.ts +lib.esm/browser.d.ts diff --git a/packages/base64/_version.d.ts b/packages/base64/lib.esm/_version.d.ts similarity index 100% rename from packages/base64/_version.d.ts rename to packages/base64/lib.esm/_version.d.ts diff --git a/packages/base64/lib.esm/_version.js b/packages/base64/lib.esm/_version.js new file mode 100644 index 000000000..158fb79e5 --- /dev/null +++ b/packages/base64/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "base64/5.0.0-beta.125"; diff --git a/packages/base64/lib.esm/browser.js b/packages/base64/lib.esm/browser.js new file mode 100644 index 000000000..eb92126c7 --- /dev/null +++ b/packages/base64/lib.esm/browser.js @@ -0,0 +1,18 @@ +"use strict"; +import { arrayify } from "@ethersproject/bytes"; +export function decode(textData) { + textData = atob(textData); + let data = []; + for (let i = 0; i < textData.length; i++) { + data.push(textData.charCodeAt(i)); + } + return arrayify(data); +} +export function encode(data) { + data = arrayify(data); + let textData = ""; + for (let i = 0; i < data.length; i++) { + textData += String.fromCharCode(data[i]); + } + return btoa(textData); +} diff --git a/packages/base64/index.d.ts b/packages/base64/lib.esm/index.d.ts similarity index 100% rename from packages/base64/index.d.ts rename to packages/base64/lib.esm/index.d.ts diff --git a/packages/base64/lib.esm/index.js b/packages/base64/lib.esm/index.js new file mode 100644 index 000000000..b5c5fa4ad --- /dev/null +++ b/packages/base64/lib.esm/index.js @@ -0,0 +1,9 @@ +"use strict"; +import { arrayify } from "@ethersproject/bytes"; +export function decode(textData) { + return arrayify(new Uint8Array(Buffer.from(textData, "base64"))); +} +; +export function encode(data) { + return Buffer.from(arrayify(data)).toString("base64"); +} diff --git a/packages/base64/lib/_version.d.ts b/packages/base64/lib/_version.d.ts new file mode 100644 index 000000000..6ed346171 --- /dev/null +++ b/packages/base64/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "base64/5.0.0-beta.125"; diff --git a/packages/base64/_version.js b/packages/base64/lib/_version.js similarity index 100% rename from packages/base64/_version.js rename to packages/base64/lib/_version.js diff --git a/packages/base64/browser.js b/packages/base64/lib/browser.js similarity index 100% rename from packages/base64/browser.js rename to packages/base64/lib/browser.js diff --git a/packages/base64/lib/index.d.ts b/packages/base64/lib/index.d.ts new file mode 100644 index 000000000..c42641f48 --- /dev/null +++ b/packages/base64/lib/index.d.ts @@ -0,0 +1,3 @@ +import { BytesLike } from "@ethersproject/bytes"; +export declare function decode(textData: string): Uint8Array; +export declare function encode(data: BytesLike): string; diff --git a/packages/base64/index.js b/packages/base64/lib/index.js similarity index 100% rename from packages/base64/index.js rename to packages/base64/lib/index.js diff --git a/packages/base64/package.json b/packages/base64/package.json index 41a2823be..926930af2 100644 --- a/packages/base64/package.json +++ b/packages/base64/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/base64", - "version": "5.0.0-beta.125", + "version": "5.0.0-beta.126", "description": "Base64 coder.", - "main": "index.js", + "main": "./lib/index.js", "browser": "browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -23,5 +23,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x8eaae303c42d86ca952abb6fd18217861e916141e565fd66f8024b4b7e870062" + "module": "./lib.esm/index.js", + "tarballHash": "0xf6efb1c57508f4e699d90f6423068a95189bc5b750430f294661e2dcf75d919c" } diff --git a/packages/base64/tsconfig.json b/packages/base64/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/base64/tsconfig.json +++ b/packages/base64/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/basex/_version.d.ts b/packages/basex/lib.esm/_version.d.ts similarity index 100% rename from packages/basex/_version.d.ts rename to packages/basex/lib.esm/_version.d.ts diff --git a/packages/basex/lib.esm/_version.js b/packages/basex/lib.esm/_version.js new file mode 100644 index 000000000..5dab71afb --- /dev/null +++ b/packages/basex/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "basex/5.0.0-beta.126"; diff --git a/packages/basex/index.d.ts b/packages/basex/lib.esm/index.d.ts similarity index 100% rename from packages/basex/index.d.ts rename to packages/basex/lib.esm/index.d.ts diff --git a/packages/basex/lib.esm/index.js b/packages/basex/lib.esm/index.js new file mode 100644 index 000000000..061f15b2b --- /dev/null +++ b/packages/basex/lib.esm/index.js @@ -0,0 +1,118 @@ +/** + * var basex = require("base-x"); + * + * This implementation is heavily based on base-x. The main reason to + * deviate was to prevent the dependency of Buffer. + * + * Contributors: + * + * base-x encoding + * Forked from https://github.com/cryptocoinjs/bs58 + * Originally written by Mike Hearn for BitcoinJ + * Copyright (c) 2011 Google Inc + * Ported to JavaScript by Stefan Thomas + * Merged Buffer refactorings from base58-native by Stephen Pair + * Copyright (c) 2013 BitPay Inc + * + * The MIT License (MIT) + * + * Copyright base-x contributors (c) 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ +import { arrayify } from "@ethersproject/bytes"; +import { defineReadOnly } from "@ethersproject/properties"; +export class BaseX { + constructor(alphabet) { + defineReadOnly(this, "alphabet", alphabet); + defineReadOnly(this, "base", alphabet.length); + defineReadOnly(this, "_alphabetMap", {}); + defineReadOnly(this, "_leader", alphabet.charAt(0)); + // pre-compute lookup table + for (let i = 0; i < alphabet.length; i++) { + this._alphabetMap[alphabet.charAt(i)] = i; + } + } + encode(value) { + let source = arrayify(value); + if (source.length === 0) { + return ""; + } + let digits = [0]; + for (let i = 0; i < source.length; ++i) { + let carry = source[i]; + for (let j = 0; j < digits.length; ++j) { + carry += digits[j] << 8; + digits[j] = carry % this.base; + carry = (carry / this.base) | 0; + } + while (carry > 0) { + digits.push(carry % this.base); + carry = (carry / this.base) | 0; + } + } + let string = ""; + // deal with leading zeros + for (let k = 0; source[k] === 0 && k < source.length - 1; ++k) { + string += this._leader; + } + // convert digits to a string + for (let q = digits.length - 1; q >= 0; --q) { + string += this.alphabet[digits[q]]; + } + return string; + } + decode(value) { + if (typeof (value) !== "string") { + throw new TypeError("Expected String"); + } + let bytes = []; + if (value.length === 0) { + return new Uint8Array(bytes); + } + bytes.push(0); + for (let i = 0; i < value.length; i++) { + let byte = this._alphabetMap[value[i]]; + if (byte === undefined) { + throw new Error("Non-base" + this.base + " character"); + } + let carry = byte; + for (let j = 0; j < bytes.length; ++j) { + carry += bytes[j] * this.base; + bytes[j] = carry & 0xff; + carry >>= 8; + } + while (carry > 0) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (let k = 0; value[k] === this._leader && k < value.length - 1; ++k) { + bytes.push(0); + } + return arrayify(new Uint8Array(bytes.reverse())); + } +} +const Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); +const Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); +export { Base32, Base58 }; +//console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) +//console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) diff --git a/packages/basex/lib/_version.d.ts b/packages/basex/lib/_version.d.ts new file mode 100644 index 000000000..b49400d11 --- /dev/null +++ b/packages/basex/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "basex/5.0.0-beta.126"; diff --git a/packages/basex/_version.js b/packages/basex/lib/_version.js similarity index 100% rename from packages/basex/_version.js rename to packages/basex/lib/_version.js diff --git a/packages/basex/lib/index.d.ts b/packages/basex/lib/index.d.ts new file mode 100644 index 000000000..25d0f654a --- /dev/null +++ b/packages/basex/lib/index.d.ts @@ -0,0 +1,52 @@ +/** + * var basex = require("base-x"); + * + * This implementation is heavily based on base-x. The main reason to + * deviate was to prevent the dependency of Buffer. + * + * Contributors: + * + * base-x encoding + * Forked from https://github.com/cryptocoinjs/bs58 + * Originally written by Mike Hearn for BitcoinJ + * Copyright (c) 2011 Google Inc + * Ported to JavaScript by Stefan Thomas + * Merged Buffer refactorings from base58-native by Stephen Pair + * Copyright (c) 2013 BitPay Inc + * + * The MIT License (MIT) + * + * Copyright base-x contributors (c) 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ +import { BytesLike } from "@ethersproject/bytes"; +export declare class BaseX { + readonly alphabet: string; + readonly base: number; + private _alphabetMap; + private _leader; + constructor(alphabet: string); + encode(value: BytesLike): string; + decode(value: string): Uint8Array; +} +declare const Base32: BaseX; +declare const Base58: BaseX; +export { Base32, Base58 }; diff --git a/packages/basex/index.js b/packages/basex/lib/index.js similarity index 100% rename from packages/basex/index.js rename to packages/basex/lib/index.js diff --git a/packages/basex/package.json b/packages/basex/package.json index 45a5ba0d8..7267b0b7b 100644 --- a/packages/basex/package.json +++ b/packages/basex/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/basex", - "version": "5.0.0-beta.126", + "version": "5.0.0-beta.127", "description": "Base-X without Buffer.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -23,5 +23,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xd04ba5a2e481158ac1193a90cf3888d364ee3ed32c4c04a34d6cc22c29d35c8a" + "module": "./lib.esm/index.js", + "tarballHash": "0x07d12f5f71d62ecbc4240de5bc05e6031f4e0e0620e280eba2c18b2e294d4ff5" } diff --git a/packages/basex/tsconfig.json b/packages/basex/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/basex/tsconfig.json +++ b/packages/basex/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/bignumber/_version.d.ts b/packages/bignumber/lib.esm/_version.d.ts similarity index 100% rename from packages/bignumber/_version.d.ts rename to packages/bignumber/lib.esm/_version.d.ts diff --git a/packages/bignumber/lib.esm/_version.js b/packages/bignumber/lib.esm/_version.js new file mode 100644 index 000000000..6854014f4 --- /dev/null +++ b/packages/bignumber/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "bignumber/5.0.0-beta.129"; diff --git a/packages/bignumber/bignumber.d.ts b/packages/bignumber/lib.esm/bignumber.d.ts similarity index 100% rename from packages/bignumber/bignumber.d.ts rename to packages/bignumber/lib.esm/bignumber.d.ts diff --git a/packages/bignumber/lib.esm/bignumber.js b/packages/bignumber/lib.esm/bignumber.js new file mode 100644 index 000000000..5e15d18a5 --- /dev/null +++ b/packages/bignumber/lib.esm/bignumber.js @@ -0,0 +1,210 @@ +"use strict"; +/** + * BigNumber + * + * A wrapper around the BN.js object. We use the BN.js library + * because it is used by elliptic, so it is required regardles. + * + */ +import * as BN from "bn.js"; +import { hexlify, isBytes, isHexString } from "@ethersproject/bytes"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +const _constructorGuard = {}; +const MAX_SAFE = 0x1fffffffffffff; +export function isBigNumberish(value) { + return (value != null) && (BigNumber.isBigNumber(value) || + (typeof (value) === "number" && (value % 1) === 0) || + (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || + isHexString(value) || + (typeof (value) === "bigint") || + isBytes(value)); +} +export class BigNumber { + constructor(constructorGuard, hex) { + logger.checkNew(new.target, BigNumber); + if (constructorGuard !== _constructorGuard) { + logger.throwError("cannot call consturtor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); + } + this._hex = hex; + this._isBigNumber = true; + Object.freeze(this); + } + fromTwos(value) { + return toBigNumber(toBN(this).fromTwos(value)); + } + toTwos(value) { + return toBigNumber(toBN(this).toTwos(value)); + } + abs() { + if (this._hex[0] === "-") { + return BigNumber.from(this._hex.substring(1)); + } + return this; + } + add(other) { + return toBigNumber(toBN(this).add(toBN(other))); + } + sub(other) { + return toBigNumber(toBN(this).sub(toBN(other))); + } + div(other) { + let o = BigNumber.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + } + mul(other) { + return toBigNumber(toBN(this).mul(toBN(other))); + } + mod(other) { + return toBigNumber(toBN(this).mod(toBN(other))); + } + pow(other) { + return toBigNumber(toBN(this).pow(toBN(other))); + } + maskn(value) { + return toBigNumber(toBN(this).maskn(value)); + } + eq(other) { + return toBN(this).eq(toBN(other)); + } + lt(other) { + return toBN(this).lt(toBN(other)); + } + lte(other) { + return toBN(this).lte(toBN(other)); + } + gt(other) { + return toBN(this).gt(toBN(other)); + } + gte(other) { + return toBN(this).gte(toBN(other)); + } + isZero() { + return toBN(this).isZero(); + } + toNumber() { + try { + return toBN(this).toNumber(); + } + catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + } + toString() { + // Lots of people expect this, which we do not support, so check + if (arguments.length !== 0) { + logger.throwError("bigNumber.toString does not accept parameters", Logger.errors.UNEXPECTED_ARGUMENT, {}); + } + return toBN(this).toString(10); + } + toHexString() { + return this._hex; + } + static from(value) { + if (value instanceof BigNumber) { + return value; + } + if (typeof (value) === "string") { + if (value.match(/-?0x[0-9a-f]+/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + } + return logger.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof (value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + return BigNumber.from(String(value)); + } + if (typeof (value) === "bigint") { + return BigNumber.from(value.toString()); + } + if (isBytes(value)) { + return BigNumber.from(hexlify(value)); + } + if (value._hex && isHexString(value._hex)) { + return BigNumber.from(value._hex); + } + if (value.toHexString) { + value = value.toHexString(); + if (typeof (value) === "string") { + return BigNumber.from(value); + } + } + return logger.throwArgumentError("invalid BigNumber value", "value", value); + } + static isBigNumber(value) { + return !!(value && value._isBigNumber); + } +} +// Normalize the hex string +function toHex(value) { + // For BN, call on the hex string + if (typeof (value) !== "string") { + return toHex(value.toString(16)); + } + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { + logger.throwArgumentError("invalid hex", "value", value); + } + // Call toHex on the positive component + value = toHex(value); + // Do not allow "-0x00" + if (value === "0x00") { + return value; + } + // Negate the value + return "-" + value; + } + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + // Normalize zero + if (value === "0x") { + return "0x00"; + } + // Make the string even length + if (value.length % 2) { + value = "0x0" + value.substring(2); + } + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + return value; +} +function toBigNumber(value) { + return BigNumber.from(toHex(value)); +} +function toBN(value) { + let hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new BN.BN("-" + hex.substring(3), 16)); + } + return new BN.BN(hex.substring(2), 16); +} +function throwFault(fault, operation, value) { + let params = { fault: fault, operation: operation }; + if (value != null) { + params.value = value; + } + return logger.throwError(fault, Logger.errors.NUMERIC_FAULT, params); +} diff --git a/packages/bignumber/fixednumber.d.ts b/packages/bignumber/lib.esm/fixednumber.d.ts similarity index 100% rename from packages/bignumber/fixednumber.d.ts rename to packages/bignumber/lib.esm/fixednumber.d.ts diff --git a/packages/bignumber/lib.esm/fixednumber.js b/packages/bignumber/lib.esm/fixednumber.js new file mode 100644 index 000000000..284dd6736 --- /dev/null +++ b/packages/bignumber/lib.esm/fixednumber.js @@ -0,0 +1,305 @@ +"use strict"; +import { arrayify, hexZeroPad, isBytes } from "@ethersproject/bytes"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { BigNumber, isBigNumberish } from "./bignumber"; +const _constructorGuard = {}; +const Zero = BigNumber.from(0); +const NegativeOne = BigNumber.from(-1); +function throwFault(message, fault, operation, value) { + let params = { fault: fault, operation: operation }; + if (value !== undefined) { + params.value = value; + } + return logger.throwError(message, Logger.errors.NUMERIC_FAULT, params); +} +// Constant to pull zeros from for multipliers +let zeros = "0"; +while (zeros.length < 256) { + zeros += zeros; +} +// Returns a string "1" followed by decimal "0"s +function getMultiplier(decimals) { + if (typeof (decimals) !== "number") { + try { + decimals = BigNumber.from(decimals).toNumber(); + } + catch (e) { } + } + if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + return logger.throwArgumentError("invalid decimal size", "decimals", decimals); +} +export function formatFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + let multiplier = getMultiplier(decimals); + // Make sure wei is a big number (convert as necessary) + value = BigNumber.from(value); + let negative = value.lt(Zero); + if (negative) { + value = value.mul(NegativeOne); + } + let fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { + fraction = "0" + fraction; + } + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + let whole = value.div(multiplier).toString(); + value = whole + "." + fraction; + if (negative) { + value = "-" + value; + } + return value; +} +export function parseFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + let multiplier = getMultiplier(decimals); + if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + logger.throwArgumentError("invalid decimal value", "value", value); + } + if (multiplier.length - 1 === 0) { + return BigNumber.from(value); + } + // Is it negative? + let negative = (value.substring(0, 1) === "-"); + if (negative) { + value = value.substring(1); + } + if (value === ".") { + logger.throwArgumentError("missing value", "value", value); + } + // Split it into a whole and fractional part + let comps = value.split("."); + if (comps.length > 2) { + logger.throwArgumentError("too many decimal points", "value", value); + } + let whole = comps[0], fraction = comps[1]; + if (!whole) { + whole = "0"; + } + if (!fraction) { + fraction = "0"; + } + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); + } + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { + fraction += "0"; + } + let wholeValue = BigNumber.from(whole); + let fractionValue = BigNumber.from(fraction); + let wei = (wholeValue.mul(multiplier)).add(fractionValue); + if (negative) { + wei = wei.mul(NegativeOne); + } + return wei; +} +export class FixedFormat { + constructor(constructorGuard, signed, width, decimals) { + this.signed = signed; + this.width = width; + this.decimals = decimals; + this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + this._multiplier = getMultiplier(decimals); + Object.freeze(this); + } + static from(value) { + if (value instanceof FixedFormat) { + return value; + } + let signed = true; + let width = 128; + let decimals = 18; + if (typeof (value) === "string") { + if (value === "fixed") { + // defaults... + } + else if (value === "ufixed") { + signed = false; + } + else if (value != null) { + let match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + logger.throwArgumentError("invalid fixed format", "format", value); + } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + let check = (key, type, defaultValue) => { + if (value[key] == null) { + return defaultValue; + } + if (typeof (value[key]) !== type) { + logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat(_constructorGuard, signed, width, decimals); + } +} +export class FixedNumber { + constructor(constructorGuard, hex, value, format) { + logger.checkNew(new.target, FixedNumber); + this.format = format; + this._hex = hex; + this._value = value; + this._isFixedNumber = true; + Object.freeze(this); + } + _checkFormat(other) { + if (this.format.name !== other.format.name) { + logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + } + addUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + } + subUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + } + mulUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + } + // @TODO: Support other rounding algorithms + round(decimals) { + if (decimals == null) { + decimals = 0; + } + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + logger.throwArgumentError("invalid decimal cound", "decimals", decimals); + } + // If we are already in range, we're done + let comps = this.toString().split("."); + if (comps[1].length <= decimals) { + return this; + } + // Bump the value up by the 0.00...0005 + let bump = "0." + zeros.substring(0, decimals) + "5"; + comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); + // Now it is safe to truncate + return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); + } + toString() { return this._value; } + toHexString(width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + logger.throwArgumentError("invalid byte width", "width", width); + } + let hex = BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return hexZeroPad(hex, width / 8); + } + toUnsafeFloat() { return parseFloat(this.toString()); } + toFormat(format) { + return FixedNumber.fromString(this._value, format); + } + static fromValue(value, decimals, format) { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && !isBigNumberish(decimals)) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); + } + static fromString(value, format) { + if (format == null) { + format = "fixed"; + } + let fixedFormat = FixedFormat.from(format); + let numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + let hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } + else { + hex = numeric.toHexString(); + hex = hexZeroPad(hex, fixedFormat.width / 8); + } + let decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + } + static fromBytes(value, format) { + if (format == null) { + format = "fixed"; + } + let fixedFormat = FixedFormat.from(format); + if (arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + let numeric = BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + let hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + let decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + } + static from(value, format) { + if (typeof (value) === "string") { + return FixedNumber.fromString(value, format); + } + if (isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + try { + return FixedNumber.fromValue(value, 0, format); + } + catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== Logger.errors.INVALID_ARGUMENT) { + throw error; + } + } + return logger.throwArgumentError("invalid FixedNumber value", "value", value); + } + static isFixedNumber(value) { + return !!(value && value._isFixedNumber); + } +} diff --git a/packages/bignumber/index.d.ts b/packages/bignumber/lib.esm/index.d.ts similarity index 100% rename from packages/bignumber/index.d.ts rename to packages/bignumber/lib.esm/index.d.ts diff --git a/packages/bignumber/lib.esm/index.js b/packages/bignumber/lib.esm/index.js new file mode 100644 index 000000000..7f4c67923 --- /dev/null +++ b/packages/bignumber/lib.esm/index.js @@ -0,0 +1,2 @@ +export { BigNumber } from "./bignumber"; +export { FixedNumber } from "./fixednumber"; diff --git a/packages/bignumber/lib/_version.d.ts b/packages/bignumber/lib/_version.d.ts new file mode 100644 index 000000000..923bdbe4a --- /dev/null +++ b/packages/bignumber/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "bignumber/5.0.0-beta.129"; diff --git a/packages/bignumber/_version.js b/packages/bignumber/lib/_version.js similarity index 100% rename from packages/bignumber/_version.js rename to packages/bignumber/lib/_version.js diff --git a/packages/bignumber/lib/bignumber.d.ts b/packages/bignumber/lib/bignumber.d.ts new file mode 100644 index 000000000..a1806c414 --- /dev/null +++ b/packages/bignumber/lib/bignumber.d.ts @@ -0,0 +1,29 @@ +import { Bytes, Hexable } from "@ethersproject/bytes"; +export declare type BigNumberish = BigNumber | Bytes | string | number; +export declare function isBigNumberish(value: any): value is BigNumberish; +export declare class BigNumber implements Hexable { + readonly _hex: string; + readonly _isBigNumber: boolean; + constructor(constructorGuard: any, hex: string); + fromTwos(value: number): BigNumber; + toTwos(value: number): BigNumber; + abs(): BigNumber; + add(other: BigNumberish): BigNumber; + sub(other: BigNumberish): BigNumber; + div(other: BigNumberish): BigNumber; + mul(other: BigNumberish): BigNumber; + mod(other: BigNumberish): BigNumber; + pow(other: BigNumberish): BigNumber; + maskn(value: number): BigNumber; + eq(other: BigNumberish): boolean; + lt(other: BigNumberish): boolean; + lte(other: BigNumberish): boolean; + gt(other: BigNumberish): boolean; + gte(other: BigNumberish): boolean; + isZero(): boolean; + toNumber(): number; + toString(): string; + toHexString(): string; + static from(value: any): BigNumber; + static isBigNumber(value: any): value is BigNumber; +} diff --git a/packages/bignumber/bignumber.js b/packages/bignumber/lib/bignumber.js similarity index 100% rename from packages/bignumber/bignumber.js rename to packages/bignumber/lib/bignumber.js diff --git a/packages/bignumber/lib/fixednumber.d.ts b/packages/bignumber/lib/fixednumber.d.ts new file mode 100644 index 000000000..aac299914 --- /dev/null +++ b/packages/bignumber/lib/fixednumber.d.ts @@ -0,0 +1,35 @@ +import { BytesLike } from "@ethersproject/bytes"; +import { BigNumber, BigNumberish } from "./bignumber"; +export declare function formatFixed(value: BigNumberish, decimals?: string | BigNumberish): string; +export declare function parseFixed(value: string, decimals?: BigNumberish): BigNumber; +export declare class FixedFormat { + readonly signed: boolean; + readonly width: number; + readonly decimals: number; + readonly name: string; + readonly _multiplier: string; + constructor(constructorGuard: any, signed: boolean, width: number, decimals: number); + static from(value: any): FixedFormat; +} +export declare class FixedNumber { + readonly format: FixedFormat; + readonly _hex: string; + readonly _value: string; + readonly _isFixedNumber: boolean; + constructor(constructorGuard: any, hex: string, value: string, format?: FixedFormat); + _checkFormat(other: FixedNumber): void; + addUnsafe(other: FixedNumber): FixedNumber; + subUnsafe(other: FixedNumber): FixedNumber; + mulUnsafe(other: FixedNumber): FixedNumber; + divUnsafe(other: FixedNumber): FixedNumber; + round(decimals?: number): FixedNumber; + toString(): string; + toHexString(width?: number): string; + toUnsafeFloat(): number; + toFormat(format: FixedFormat | string): FixedNumber; + static fromValue(value: BigNumber, decimals?: BigNumberish, format?: FixedFormat | string): FixedNumber; + static fromString(value: string, format?: FixedFormat | string): FixedNumber; + static fromBytes(value: BytesLike, format?: FixedFormat | string): FixedNumber; + static from(value: any, format?: FixedFormat | string): FixedNumber; + static isFixedNumber(value: any): value is FixedNumber; +} diff --git a/packages/bignumber/fixednumber.js b/packages/bignumber/lib/fixednumber.js similarity index 100% rename from packages/bignumber/fixednumber.js rename to packages/bignumber/lib/fixednumber.js diff --git a/packages/bignumber/lib/index.d.ts b/packages/bignumber/lib/index.d.ts new file mode 100644 index 000000000..1c8551bc5 --- /dev/null +++ b/packages/bignumber/lib/index.d.ts @@ -0,0 +1,2 @@ +export { BigNumber, BigNumberish } from "./bignumber"; +export { formatFixed, FixedFormat, FixedNumber, parseFixed } from "./fixednumber"; diff --git a/packages/bignumber/index.js b/packages/bignumber/lib/index.js similarity index 63% rename from packages/bignumber/index.js rename to packages/bignumber/lib/index.js index 909fc4872..c874ceda7 100644 --- a/packages/bignumber/index.js +++ b/packages/bignumber/lib/index.js @@ -3,4 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); var bignumber_1 = require("./bignumber"); exports.BigNumber = bignumber_1.BigNumber; var fixednumber_1 = require("./fixednumber"); +exports.formatFixed = fixednumber_1.formatFixed; +exports.FixedFormat = fixednumber_1.FixedFormat; exports.FixedNumber = fixednumber_1.FixedNumber; +exports.parseFixed = fixednumber_1.parseFixed; diff --git a/packages/bignumber/package.json b/packages/bignumber/package.json index c26788d4d..7c9374a4d 100644 --- a/packages/bignumber/package.json +++ b/packages/bignumber/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/bignumber", - "version": "5.0.0-beta.129", + "version": "5.0.0-beta.130", "description": "BigNumber library used in ethers.js.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x24cb6b119b3bd1798855c867c5ac09b14b9f7a219b2be49f2371eb9c6fc043e8" + "module": "./lib.esm/index.js", + "tarballHash": "0x78dadd02c7c23e71e8bc51a5a21843437363b7ab29d16de0290e25f12d7fe6f6" } diff --git a/packages/bignumber/src.ts/index.ts b/packages/bignumber/src.ts/index.ts index a80c3ba53..1c8551bc5 100644 --- a/packages/bignumber/src.ts/index.ts +++ b/packages/bignumber/src.ts/index.ts @@ -1,2 +1,2 @@ export { BigNumber, BigNumberish } from "./bignumber"; -export { FixedNumber } from "./fixednumber"; +export { formatFixed, FixedFormat, FixedNumber, parseFixed } from "./fixednumber"; diff --git a/packages/bignumber/tsconfig.json b/packages/bignumber/tsconfig.json index f09aa6ba8..cf84c4c52 100644 --- a/packages/bignumber/tsconfig.json +++ b/packages/bignumber/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts", - "./thirdparty.d.ts" + "./src.ts/*.ts", + "./thirdparty.d.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/bytes/_version.d.ts b/packages/bytes/lib.esm/_version.d.ts similarity index 100% rename from packages/bytes/_version.d.ts rename to packages/bytes/lib.esm/_version.d.ts diff --git a/packages/bytes/lib.esm/_version.js b/packages/bytes/lib.esm/_version.js new file mode 100644 index 000000000..88d7a6999 --- /dev/null +++ b/packages/bytes/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "bytes/5.0.0-beta.128"; diff --git a/packages/bytes/index.d.ts b/packages/bytes/lib.esm/index.d.ts similarity index 100% rename from packages/bytes/index.d.ts rename to packages/bytes/lib.esm/index.d.ts diff --git a/packages/bytes/lib.esm/index.js b/packages/bytes/lib.esm/index.js new file mode 100644 index 000000000..0c2d2ea4b --- /dev/null +++ b/packages/bytes/lib.esm/index.js @@ -0,0 +1,363 @@ +"use strict"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +/////////////////////////////// +function isHexable(value) { + return !!(value.toHexString); +} +function addSlice(array) { + if (array.slice) { + return array; + } + array.slice = function () { + let args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + }; + return array; +} +export function isBytesLike(value) { + return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); +} +export function isBytes(value) { + if (value == null) { + return false; + } + if (value.constructor === Uint8Array) { + return true; + } + if (typeof (value) === "string") { + return false; + } + if (value.length == null) { + return false; + } + for (let i = 0; i < value.length; i++) { + let v = value[i]; + if (v < 0 || v >= 256 || (v % 1)) { + return false; + } + } + return true; +} +export function arrayify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger.checkSafeUint53(value, "invalid arrayify value"); + let result = []; + while (value) { + result.unshift(value & 0xff); + value /= 256; + } + if (result.length === 0) { + result.push(0); + } + return addSlice(new Uint8Array(result)); + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + value = value.toHexString(); + } + if (isHexString(value)) { + let hex = value.substring(2); + if (!options.allowOddLength && hex.length % 2) { + logger.throwArgumentError("hex data is odd-length", "value", value); + } + let result = []; + for (let i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + return addSlice(new Uint8Array(result)); + } + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + return logger.throwArgumentError("invalid arrayify value", "value", value); +} +export function concat(items) { + let objects = items.map(item => arrayify(item)); + let length = objects.reduce((accum, item) => (accum + item.length), 0); + let result = new Uint8Array(length); + objects.reduce((offset, object) => { + result.set(object, offset); + return offset + object.length; + }, 0); + return addSlice(result); +} +export function stripZeros(value) { + let result = arrayify(value); + if (result.length === 0) { + return result; + } + // Find the first non-zero entry + let start = 0; + while (start < result.length && result[start] === 0) { + start++; + } + // If we started with zeros, strip them + if (start) { + result = result.slice(start); + } + return result; +} +export function zeroPad(value, length) { + value = arrayify(value); + if (value.length > length) { + logger.throwArgumentError("value out of range", "value", arguments[0]); + } + let result = new Uint8Array(length); + result.set(value, length - value.length); + return addSlice(result); +} +export function isHexString(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (length && value.length !== 2 + 2 * length) { + return false; + } + return true; +} +const HexCharacters = "0123456789abcdef"; +export function hexlify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger.checkSafeUint53(value, "invalid hexlify value"); + let hex = ""; + while (value) { + hex = HexCharacters[value & 0x0f] + hex; + value = Math.floor(value / 16); + } + if (hex.length) { + if (hex.length % 2) { + hex = "0" + hex; + } + return "0x" + hex; + } + return "0x00"; + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + return value.toHexString(); + } + if (isHexString(value)) { + if (!options.allowOddLength && value.length % 2) { + logger.throwArgumentError("hex data is odd-length", "value", value); + } + return value.toLowerCase(); + } + if (isBytes(value)) { + let result = "0x"; + for (let i = 0; i < value.length; i++) { + let v = value[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; + } + return logger.throwArgumentError("invalid hexlify value", "value", value); +} +/* +function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { + if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { + return "0x0" + value.substring(2); + } + return value; +} +*/ +export function hexDataLength(data) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + return null; + } + return (data.length - 2) / 2; +} +export function hexDataSlice(data, offset, endOffset) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + logger.throwArgumentError("invalid hexData", "value", data); + } + offset = 2 + 2 * offset; + if (endOffset != null) { + return "0x" + data.substring(offset, 2 + 2 * endOffset); + } + return "0x" + data.substring(offset); +} +export function hexConcat(items) { + let result = "0x"; + items.forEach((item) => { + result += hexlify(item).substring(2); + }); + return result; +} +export function hexValue(value) { + let trimmed = hexStripZeros(hexlify(value, { allowOddLength: true })); + if (trimmed === "0x") { + return "0x0"; + } + return trimmed; +} +export function hexStripZeros(value) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + if (!isHexString(value)) { + logger.throwArgumentError("invalid hex string", "value", value); + } + value = value.substring(2); + let offset = 0; + while (offset < value.length && value[offset] === "0") { + offset++; + } + return "0x" + value.substring(offset); +} +export function hexZeroPad(value, length) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + else if (!isHexString(value)) { + logger.throwArgumentError("invalid hex string", "value", value); + } + if (value.length > 2 * length + 2) { + logger.throwArgumentError("value out of range", "value", arguments[1]); + } + while (value.length < 2 * length + 2) { + value = "0x0" + value.substring(2); + } + return value; +} +export function splitSignature(signature) { + let result = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0 + }; + if (isBytesLike(signature)) { + let bytes = arrayify(signature); + if (bytes.length !== 65) { + logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + } + // Get the r and s + result.r = hexlify(bytes.slice(0, 32)); + result.s = hexlify(bytes.slice(32, 64)); + // Reduce v to the canonical 27 or 28 + result.v = bytes[64]; + if (result.v !== 27 && result.v !== 28) { + result.v = 27 + (result.v % 2); + } + // Compute recoveryParam from v + result.recoveryParam = (result.v - 27); + // Compute _vs from recoveryParam and s + if (result.recoveryParam) { + bytes[32] |= 0x80; + } + result._vs = hexlify(bytes.slice(32, 64)); + } + else { + result.r = signature.r; + result.s = signature.s; + result.v = signature.v; + result.recoveryParam = signature.recoveryParam; + result._vs = signature._vs; + // Normalize v into a canonical 27 or 28 + if (result.v != null && !(result.v == 27 || result.v == 28)) { + result.v = 27 + (result.v % 2); + } + // Populate a missing v or recoveryParam if possible + if (result.recoveryParam == null && result.v != null) { + result.recoveryParam = 1 - (result.v % 2); + } + else if (result.recoveryParam != null && result.v == null) { + result.v = 27 + result.recoveryParam; + } + else if (result.recoveryParam != null && result.v != null) { + if (result.v !== 27 + result.recoveryParam) { + logger.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); + } + } + // Make sure r and s are padded properly + if (result.r != null) { + result.r = hexZeroPad(result.r, 32); + } + if (result.s != null) { + result.s = hexZeroPad(result.s, 32); + } + // If the _vs is available, use it to populate missing s, v and recoveryParam + // and verify non-missing s, v and recoveryParam + if (result._vs != null) { + result._vs = hexZeroPad(result._vs, 32); + if (result._vs.length > 66) { + logger.throwArgumentError("signature _vs overflow", "signature", signature); + } + let vs = arrayify(result._vs); + let recoveryParam = ((vs[0] >= 128) ? 1 : 0); + let v = 27 + result.recoveryParam; + // Use _vs to compute s + vs[0] &= 0x7f; + let s = hexlify(vs); + // Check _vs aggress with other parameters + if (result.s == null) { + result.s = s; + } + else if (result.s !== s) { + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (result.v == null) { + result.v = v; + } + else if (result.v !== v) { + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (recoveryParam == null) { + result.recoveryParam = recoveryParam; + } + else if (result.recoveryParam !== recoveryParam) { + logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + } + } + // After all populating, both v and recoveryParam are still missing... + if (result.v == null && result.recoveryParam == null) { + logger.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); + } + // Check for canonical v + if (result.v !== 27 && result.v !== 28) { + logger.throwArgumentError("signature v not canonical", "signature", signature); + } + // Check that r and s are in range + if (result.r.length > 66 || result.s.length > 66) { + logger.throwArgumentError("signature overflow r or s", "signature", signature); + } + if (result._vs == null) { + let vs = arrayify(result.s); + if (vs[0] >= 128) { + logger.throwArgumentError("signature s out of range", "signature", signature); + } + if (result.recoveryParam) { + vs[0] |= 0x80; + } + result._vs = hexlify(vs); + } + } + return result; +} +export function joinSignature(signature) { + signature = splitSignature(signature); + return hexlify(concat([ + signature.r, + signature.s, + (signature.recoveryParam ? "0x1c" : "0x1b") + ])); +} diff --git a/packages/bytes/lib/_version.d.ts b/packages/bytes/lib/_version.d.ts new file mode 100644 index 000000000..51cd78bfe --- /dev/null +++ b/packages/bytes/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "bytes/5.0.0-beta.128"; diff --git a/packages/bytes/_version.js b/packages/bytes/lib/_version.js similarity index 100% rename from packages/bytes/_version.js rename to packages/bytes/lib/_version.js diff --git a/packages/bytes/lib/index.d.ts b/packages/bytes/lib/index.d.ts new file mode 100644 index 000000000..ce6e4ea9b --- /dev/null +++ b/packages/bytes/lib/index.d.ts @@ -0,0 +1,39 @@ +export declare type Bytes = ArrayLike; +export declare type BytesLike = Bytes | string; +export declare type DataOptions = { + allowMissingPrefix?: boolean; + allowOddLength?: boolean; +}; +export interface Hexable { + toHexString(): string; +} +export declare type SignatureLike = { + r: string; + s?: string; + _vs?: string; + recoveryParam?: number; + v?: number; +} | BytesLike; +export interface Signature { + r: string; + s: string; + _vs: string; + recoveryParam: number; + v: number; +} +export declare function isBytesLike(value: any): value is BytesLike; +export declare function isBytes(value: any): value is Bytes; +export declare function arrayify(value: BytesLike | Hexable | number, options?: DataOptions): Uint8Array; +export declare function concat(items: Array): Uint8Array; +export declare function stripZeros(value: BytesLike): Uint8Array; +export declare function zeroPad(value: BytesLike, length: number): Uint8Array; +export declare function isHexString(value: any, length?: number): boolean; +export declare function hexlify(value: BytesLike | Hexable | number, options?: DataOptions): string; +export declare function hexDataLength(data: BytesLike): number; +export declare function hexDataSlice(data: BytesLike, offset: number, endOffset?: number): string; +export declare function hexConcat(items: Array): string; +export declare function hexValue(value: BytesLike | Hexable | number): string; +export declare function hexStripZeros(value: BytesLike): string; +export declare function hexZeroPad(value: BytesLike, length: number): string; +export declare function splitSignature(signature: SignatureLike): Signature; +export declare function joinSignature(signature: Signature): string; diff --git a/packages/bytes/index.js b/packages/bytes/lib/index.js similarity index 100% rename from packages/bytes/index.js rename to packages/bytes/lib/index.js diff --git a/packages/bytes/package.json b/packages/bytes/package.json index c742961e3..758e4f1a4 100644 --- a/packages/bytes/package.json +++ b/packages/bytes/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/bytes", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Bytes utility functions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "build": "tsc -p ./tsconfig.json", "auto-build": "npm run build -- -w", @@ -24,5 +24,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x793a4a0bb6c5a84b9dfc8e52a8627700bd85e00ede0a411db5ea25eae5b43cd1" + "module": "./lib.esm/index.js", + "tarballHash": "0x7092fb4f0431cc7edeabb25e101d0d73a378bbb842c38e48b8eb41031d97d2f2" } diff --git a/packages/bytes/tsconfig.json b/packages/bytes/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/bytes/tsconfig.json +++ b/packages/bytes/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/cli/.gitignore b/packages/cli/.gitignore index 13cc592f7..99ffa823b 100644 --- a/packages/cli/.gitignore +++ b/packages/cli/.gitignore @@ -1 +1,2 @@ -bin/*.ts +lib/bin/*.d.ts +lib.esm/bin/*.d.ts diff --git a/packages/cli/.npmignore b/packages/cli/.npmignore new file mode 100644 index 000000000..684f719ca --- /dev/null +++ b/packages/cli/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src.ts/ diff --git a/packages/cli/_version.d.ts b/packages/cli/lib.esm/_version.d.ts similarity index 100% rename from packages/cli/_version.d.ts rename to packages/cli/lib.esm/_version.d.ts diff --git a/packages/cli/lib.esm/_version.js b/packages/cli/lib.esm/_version.js new file mode 100644 index 000000000..8b04e3456 --- /dev/null +++ b/packages/cli/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "cli/5.0.0-beta.141"; diff --git a/packages/cli/lib.esm/bin/ethers-ens.js b/packages/cli/lib.esm/bin/ethers-ens.js new file mode 100644 index 000000000..f93a9ffad --- /dev/null +++ b/packages/cli/lib.esm/bin/ethers-ens.js @@ -0,0 +1,836 @@ +#!/usr/bin/env node +'use strict'; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import { ethers } from "ethers"; +import { Base58 } from "@ethersproject/basex"; +import { CLI, Plugin } from '../cli'; +import { version } from "../_version"; +const logger = new ethers.utils.Logger(version); +const ensAbi = [ + "function setOwner(bytes32 node, address owner) external @500000", + "function setSubnodeOwner(bytes32 node, bytes32 label, address owner) external @500000", + "function setResolver(bytes32 node, address resolver) external @500000", + "function owner(bytes32 node) external view returns (address)", + "function resolver(bytes32 node) external view returns (address)" +]; +const States = Object.freeze(["Open", "Auction", "Owned", "Forbidden", "Reveal", "NotAvailable"]); +const deedAbi = [ + "function owner() view returns (address)" +]; +const ethLegacyRegistrarAbi = [ + "function entries(bytes32 _hash) view returns (uint8 state, address owner, uint registrationDate, uint value, uint highestBid)", + "function transferRegistrars(bytes32 _hash) @500000", +]; +const ethControllerAbi = [ + "function rentPrice(string memory name, uint duration) view public returns(uint)", + "function available(string memory label) public view returns(bool)", + "function makeCommitment(string memory name, address owner, bytes32 secret) pure public returns(bytes32)", + "function commit(bytes32 commitment) public @500000", + "function register(string calldata name, address owner, uint duration, bytes32 secret) payable @500000", + "function renew(string calldata name, uint duration) payable @500000", +]; +const ethRegistrarAbi = [ + "function ownerOf(uint256 tokenId) view returns (address)", + "function reclaim(uint256 id, address owner) @500000", + "function safeTransferFrom(address from, address to, uint256 tokenId) @500000" +]; +const resolverAbi = [ + "function interfaceImplementer(bytes32 nodehash, bytes4 interfaceId) view returns (address)", + "function addr(bytes32 nodehash) view returns (address)", + "function setAddr(bytes32 nodehash, address addr) @500000", + "function text(bytes32 nodehash, string key) view returns (string)", + "function setText(bytes32 nodehash, string key, string value) @500000", + "function contenthash(bytes32 nodehash) view returns (bytes)", + "function setContenthash(bytes32 nodehash, bytes contenthash) @500000", +]; +//const InterfaceID_ERC721 = "0x6ccb2df4"; +const InterfaceID_Controller = "0x018fac06"; +const InterfaceID_Legacy = "0x7ba18ba1"; +/* + +const reverseRegistrarAbi = [ +]; +*/ +function listify(words) { + if (words.length === 1) { + return words[0]; + } + return words.slice(0, words.length - 1).join(", ") + " and " + words[words.length - 1]; +} +let cli = new CLI(); +class EnsPlugin extends Plugin { + constructor() { + super(); + ethers.utils.defineReadOnly(this, "_ethAddressCache", {}); + } + getEns() { + return new ethers.Contract(this.network.ensAddress, ensAbi, this.accounts[0] || this.provider); + } + getResolver(nodehash) { + return __awaiter(this, void 0, void 0, function* () { + if (!this._ethAddressCache[nodehash]) { + this._ethAddressCache[nodehash] = yield this.getEns().resolver(nodehash); + } + return new ethers.Contract(this._ethAddressCache[nodehash], resolverAbi, this.accounts[0] || this.provider); + }); + } + getEthInterfaceAddress(interfaceId) { + return __awaiter(this, void 0, void 0, function* () { + let ethNodehash = ethers.utils.namehash("eth"); + if (!this._ethAddressCache[interfaceId]) { + let resolver = yield this.getResolver(ethNodehash); + this._ethAddressCache[interfaceId] = yield resolver.interfaceImplementer(ethNodehash, interfaceId); + } + return this._ethAddressCache[interfaceId]; + }); + } + getEthController() { + return __awaiter(this, void 0, void 0, function* () { + let address = yield this.getEthInterfaceAddress(InterfaceID_Controller); + return new ethers.Contract(address, ethControllerAbi, this.accounts[0] || this.provider); + }); + } + getEthLegacyRegistrar() { + return __awaiter(this, void 0, void 0, function* () { + let address = yield this.getEthInterfaceAddress(InterfaceID_Legacy); + return new ethers.Contract(address, ethLegacyRegistrarAbi, this.accounts[0] || this.provider); + }); + } + getEthRegistrar() { + return __awaiter(this, void 0, void 0, function* () { + //let address = await this.getEthInterfaceAddress(InterfaceID_ERC721); + let address = yield this.getEns().owner(ethers.utils.namehash("eth")); + return new ethers.Contract(address, ethRegistrarAbi, this.accounts[0] || this.provider); + }); + } +} +class LookupPlugin extends EnsPlugin { + static getHelp() { + return { + name: "lookup [ NAME | ADDRESS [ ... ] ]", + help: "Lookup a name or address" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + this.names = args; + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + let ens = this.getEns(); + let controller = yield this.getEthController(); + let registrar = yield this.getEthRegistrar(); + let legacyRegistrar = yield this.getEthLegacyRegistrar(); + for (let i = 0; i < this.names.length; i++) { + let name = this.names[i]; + let nodehash = ethers.utils.namehash(name); + let details = { + Nodehash: nodehash + }; + let owner = yield ens.owner(nodehash); + let resolverAddress = null; + if (owner === ethers.constants.AddressZero) { + owner = null; + } + else { + details.Controller = owner; + details.Resolver = yield ens.resolver(nodehash).then((address) => { + if (address === ethers.constants.AddressZero) { + return "(not configured)"; + } + resolverAddress = address; + return address; + }); + } + let comps = name.split("."); + if (comps.length === 2 && comps[1] === "eth") { + details.Labelhash = ethers.utils.id(comps[0].toLowerCase()); // @TODO: nameprep + details.Available = yield controller.available(comps[0]); + if (!details.Available) { + try { + let ownerOf = yield registrar.ownerOf(details.Labelhash); + if (ownerOf !== ethers.constants.AddressZero) { + details.Registrant = ownerOf; + details.Registrar = "Permanent"; + } + } + catch (error) { + let entry = yield legacyRegistrar.entries(details.Labelhash); + let deed = new ethers.Contract(entry.owner, deedAbi, this.provider); + details.Registrant = yield deed.owner(); + details.Registrar = "Legacy"; + details["Deed Value"] = (ethers.utils.formatEther(entry.value) + " ether"); + details["Highest Bid"] = (ethers.utils.formatEther(entry.highestBid) + " ether"); + } + } + } + if (resolverAddress) { + let resolver = new ethers.Contract(resolverAddress, resolverAbi, this.provider); + details["Address"] = yield resolver.addr(nodehash); + let email = yield resolver.text(nodehash, "email").catch((error) => ("")); + if (email) { + details["E-mail"] = email; + } + let website = yield resolver.text(nodehash, "website").catch((error) => ("")); + if (website) { + details["Website"] = website; + } + let content = yield resolver.contenthash(nodehash).then((hash) => { + if (hash === "0x") { + return ""; + } + if (hash.substring(0, 10) === "0xe3010170" && ethers.utils.isHexString(hash, 38)) { + return Base58.encode(ethers.utils.hexDataSlice(hash, 4)) + " (IPFS)"; + } + return hash + " (unknown format)"; + }, (error) => ("")); + if (content) { + details["Content Hash"] = content; + } + } + let ordered = {}; + "Nodehash,Labelhash,Available,Registrant,Controller,Resolver,Address,Registrar,Deed Value,Highest Bid,E-mail,Website,Content Hash".split(",").forEach((key) => { + if (!details[key]) { + return; + } + ordered[key] = details[key]; + }); + for (let key in details) { + if (ordered[key]) { + continue; + } + ordered[key] = details[key]; + } + this.dump("Name: " + this.names[i], ordered); + } + }); + } +} +cli.addPlugin("lookup", LookupPlugin); +class AccountPlugin extends EnsPlugin { + static getHelp() { + return logger.throwError("subclasses must implemetn this", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "getHelp" + }); + } + _setValue(key, value) { + return __awaiter(this, void 0, void 0, function* () { + ethers.utils.defineReadOnly(this, key, value); + if (key === "name") { + yield this._setValue("nodehash", ethers.utils.namehash(value)); + } + }); + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + ethers.utils.defineReadOnly(this, "_wait", argParser.consumeFlag("wait")); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + let helpLine = ethers.utils.getStatic(this.constructor, "getHelp")().name; + let params = helpLine.split(" "); + let command = params[0]; + params = params.slice(1); + if (this.accounts.length !== 1) { + this.throwError(command + " requires an account"); + } + if (args.length !== params.length) { + this.throwError(command + " requires exactly " + listify(params)); + } + for (let i = 0; i < params.length; i++) { + yield this._setValue(params[i].toLowerCase(), args[i]); + } + }); + } +} +class ControllerPlugin extends AccountPlugin { + static getOptionHelp() { + return [ + { + name: "[ --duration DAYS ]", + help: "Register duration (default: 365 days)" + }, + { + name: "[ --salt SALT ]", + help: "SALT to blind the commit with" + }, + { + name: "[ --secret SECRET ]", + help: "Use id(SECRET) as the salt" + }, + { + name: "[ --owner OWNER ]", + help: "The target owner (default: current account)" + } + ]; + } + _setValue(key, value) { + const _super = Object.create(null, { + _setValue: { get: () => super._setValue } + }); + return __awaiter(this, void 0, void 0, function* () { + if (key === "name") { + let comps = value.split("."); + if (comps.length !== 2 || comps[1] !== "eth") { + this.throwError("Invalid NAME"); + } + yield _super._setValue.call(this, "label", comps[0]); + } + yield _super._setValue.call(this, key, value); + }); + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + this.salt = argParser.consumeOption("salt"); + let secret = argParser.consumeOption("secret"); + if (secret) { + if (this.salt) { + this.throwError("Cannot specify --salt with --secret"); + } + this.salt = ethers.utils.id(secret); + } + this.owner = argParser.consumeOption("owner"); + if (this.owner) { + this.owner = yield this.getAddress(this.owner); + } + else { + this.owner = yield this.accounts[0].getAddress(); + } + let duration = parseInt(argParser.consumeOption("duration") || "365"); + if (duration < 28) { + this.throwError("registration must be for a minimum length of 28 days"); + } + ethers.utils.defineReadOnly(this, "duration", duration * (60 * 60 * 24)); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (!this.salt) { + let signature = yield this.accounts[0].signMessage("commit-" + this.owner + "-" + this.name); + this.salt = ethers.utils.keccak256(signature); + } + }); + } +} +class CommitPlugin extends ControllerPlugin { + static getHelp() { + return { + name: "commit NAME", + help: "Submit a pre-commitment" + }; + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + let ethController = yield this.getEthController(); + let commitment = yield ethController.makeCommitment(this.label, this.owner, this.salt); + let fee = yield ethController.rentPrice(this.label, this.duration); + this.dump("Commit: " + this.name, { + Nodehash: this.nodehash, + Owner: this.owner, + Salt: this.salt, + Duration: (this.duration + " seconds (informational)"), + Fee: ethers.utils.formatEther(fee) + " (informational)", + Commitment: commitment + }); + yield ethController.commit(commitment); + }); + } +} +cli.addPlugin("commit", CommitPlugin); +class RevealPlugin extends ControllerPlugin { + static getHelp() { + return { + name: "reveal NAME", + help: "Reveal a previous pre-commitment" + }; + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + let ethController = yield this.getEthController(); + let fee = yield ethController.rentPrice(this.label, this.duration); + this.dump("Reveal: " + this.name, { + Nodehash: this.nodehash, + Owner: this.owner, + Salt: this.salt, + Duration: (this.duration + " seconds"), + Fee: ethers.utils.formatEther(fee), + }); + yield ethController.register(this.label, this.owner, this.duration, this.salt, { + value: fee.mul(11).div(10) + }); + }); + } +} +cli.addPlugin("reveal", RevealPlugin); +/* +class CommitRevealPlugin extends RevealPlugin { + waitBlocks: number; + + static getHelp(): Help { + return { + name: "commit-reveal LABEL", + help: "Commit, wait and reveal a name" + } + } + + static getOptionHelp(): Array { + let help = CommitPlugin.getOptionHelp().slice(); + + help.push({ + name: "[ --wait BLOCKS ]", + help: "Wait BLOCKS confirms (Default: 5)" + }) + + return help; + } + + async prepareOptions(argParser: ArgParser): Promise { + await super.prepareOptions(argParser); + + let waitBlocks = argParser.consumeOption("wait"); + try { + this.waitBlocks = parseInt(waitBlocks || "5"); + } catch(error) { + this.throwError("Invalid --wait BLOCKS") + } + } + + async run(): Promise { + await super.run(); + console.log(this); + } +} +cli.addPlugin("commit-reveal", CommitRevealPlugin); +*/ +class AddressAccountPlugin extends AccountPlugin { + static getOptionHelp() { + return [ + { + name: "[ --address ADDRESS ]", + help: "Specify another address" + } + ]; + } + getDefaultAddress() { + return this.accounts[0].getAddress(); + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + let address = argParser.consumeOption("address"); + if (!address) { + address = yield this.getDefaultAddress(); + } + this.address = address; + }); + } +} +class SetControllerPlugin extends AddressAccountPlugin { + static getHelp() { + return { + name: "set-controller NAME", + help: "Set the controller (default: current account)" + }; + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.getEns().setOwner(this.nodehash, this.address); + }); + } +} +cli.addPlugin("set-controller", SetControllerPlugin); +class SetSubnodePlugin extends AddressAccountPlugin { + static getHelp() { + return { + name: "set-subnode NAME", + help: "Set a subnode owner (default: current account)" + }; + } + _setValue(key, value) { + const _super = Object.create(null, { + _setValue: { get: () => super._setValue } + }); + return __awaiter(this, void 0, void 0, function* () { + if (key === "name") { + let comps = value.toLowerCase().split("."); + yield _super._setValue.call(this, "label", comps[0]); + yield _super._setValue.call(this, "node", comps.slice(1).join(".")); + } + yield _super._setValue.call(this, key, value); + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Set Subnode: " + this.name, { + Label: this.label, + Node: this.node + }); + yield this.getEns().setSubnodeOwner(ethers.utils.namehash(this.node), ethers.utils.id(this.label), this.address); + }); + } +} +cli.addPlugin("set-subnode", SetSubnodePlugin); +class SetResolverPlugin extends AddressAccountPlugin { + static getHelp() { + return { + name: "set-resolver NAME", + help: "Set the resolver (default: resolver.eth)" + }; + } + getDefaultAddress() { + return this.getAddress("resolver.eth"); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Set Resolver: " + this.name, { + Nodehash: this.nodehash, + Resolver: this.address + }); + yield this.getEns().setResolver(this.nodehash, this.address); + }); + } +} +cli.addPlugin("set-resolver", SetResolverPlugin); +class SetAddrPlugin extends AddressAccountPlugin { + static getHelp() { + return { + name: "set-addr NAME", + help: "Set the addr record (default: current account)" + }; + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Set Addr: " + this.name, { + Nodehash: this.nodehash, + Address: this.address + }); + let resolver = yield this.getResolver(this.nodehash); + yield resolver.setAddr(this.nodehash, this.address); + }); + } +} +cli.addPlugin("set-addr", SetAddrPlugin); +class TextAccountPlugin extends AccountPlugin { + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + let key = this.getKey(); + let value = this.getValue(); + this.dump("Set " + this.getHeader() + ": " + this.name, { + Nodehash: this.nodehash, + Key: key, + Value: value + }); + let resolver = yield this.getResolver(this.nodehash); + yield resolver.setText(this.nodehash, key, value); + }); + } +} +class SetTextPlugin extends TextAccountPlugin { + static getHelp() { + return { + name: "set-text NAME KEY VALUE", + help: "Set a text record" + }; + } + getHeader() { return "Test"; } + getKey() { return this.key; } + getValue() { return this.value; } +} +cli.addPlugin("set-text", SetTextPlugin); +class SetEmailPlugin extends TextAccountPlugin { + static getHelp() { + return { + name: "set-email NAME EMAIL", + help: "Set the email text record" + }; + } + getHeader() { return "E-mail"; } + getKey() { return "email"; } + getValue() { return this.email; } +} +cli.addPlugin("set-email", SetEmailPlugin); +class SetWebsitePlugin extends TextAccountPlugin { + static getHelp() { + return { + name: "set-website NAME URL", + help: "Set the website text record" + }; + } + getHeader() { return "Website"; } + getKey() { return "website"; } + getValue() { return this.url; } +} +cli.addPlugin("set-website", SetWebsitePlugin); +class SetContentPlugin extends AccountPlugin { + static getHelp() { + return { + name: "set-content NAME HASH", + help: "Set the IPFS Content Hash" + }; + } + _setValue(key, value) { + const _super = Object.create(null, { + _setValue: { get: () => super._setValue } + }); + return __awaiter(this, void 0, void 0, function* () { + if (key === "hash") { + let bytes = Base58.decode(value); + if (bytes.length !== 34 || bytes[0] !== 18 || bytes[1] !== 32) { + this.throwError("Unsupported IPFS hash"); + } + let multihash = ethers.utils.concat(["0xe3010170", bytes]); + yield _super._setValue.call(this, "multihash", ethers.utils.hexlify(multihash)); + } + yield _super._setValue.call(this, key, value); + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Set Content Hash: " + this.name, { + Nodehash: this.nodehash, + "Content Hash": this.hash + }); + let resolver = yield this.getResolver(this.nodehash); + yield resolver.setContenthash(this.nodehash, this.multihash); + }); + } +} +cli.addPlugin("set-content", SetContentPlugin); +class MigrateRegistrarPlugin extends AccountPlugin { + static getHelp() { + return { + name: "migrate-registrar NAME", + help: "Migrate from the Legacy to the Permanent Registrar" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs }, + _setValue: { get: () => super._setValue } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + // Only Top-Level names can be migrated + let comps = this.name.split("."); + if (comps.length !== 2 || comps[1] !== "eth") { + this.throwError("Not a top-level .eth name"); + } + yield _super._setValue.call(this, "label", comps[0]); + let ethLegacyRegistrar = yield this.getEthLegacyRegistrar(); + let entry = yield ethLegacyRegistrar.entries(ethers.utils.id(comps[0])); + // Only owned names can be migrated + if (States[entry.state] !== "Owned") { + this.throwError("Name not present in the Legacy registrar"); + } + let deed = new ethers.Contract(entry.owner, deedAbi, this.provider); + let owner = yield deed.owner(); + let address = yield this.accounts[0].getAddress(); + // Only the deed owner (registrant) may migrate a name + if (owner !== address) { + this.throwError("Only the registrant can migrate"); + } + yield _super._setValue.call(this, "deedValue", entry.value); + yield _super._setValue.call(this, "highestBid", entry.highestBid); + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Migrate Registrar: " + this.name, { + "Nodehash": this.nodehash, + "Highest Bid": (ethers.utils.formatEther(this.highestBid) + " ether"), + "Deed Value": (ethers.utils.formatEther(this.deedValue) + " ether"), + }); + let legacyRegistrar = yield this.getEthLegacyRegistrar(); + yield legacyRegistrar.transferRegistrars(ethers.utils.id(this.label)); + }); + } +} +cli.addPlugin("migrate-registrar", MigrateRegistrarPlugin); +class TransferPlugin extends AccountPlugin { + static getHelp() { + return { + name: "transfer NAME NEW_OWNER", + help: "Transfer registrant ownership" + }; + } + _setValue(key, value) { + const _super = Object.create(null, { + _setValue: { get: () => super._setValue } + }); + return __awaiter(this, void 0, void 0, function* () { + if (key === "new_owner") { + let address = yield this.getAddress(value); + yield _super._setValue.call(this, key, address); + } + else if (key === "name") { + let comps = value.split("."); + if (comps.length !== 2 || comps[1] !== "eth") { + this.throwError("Not a top-level .eth name"); + } + yield _super._setValue.call(this, "label", comps[0]); + yield _super._setValue.call(this, key, value); + } + else { + yield _super._setValue.call(this, key, value); + } + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Transfer: " + this.name, { + Nodehash: this.nodehash, + "New Owner": this.new_owner, + }); + let registrar = yield this.getEthRegistrar(); + yield registrar.safeTransferFrom(this.accounts[0].getAddress(), this.new_owner, ethers.utils.id(this.label)); + }); + } +} +cli.addPlugin("transfer", TransferPlugin); +class ReclaimPlugin extends AddressAccountPlugin { + static getHelp() { + return { + name: "reclaim NAME", + help: "Reset the controller by the registrant" + }; + } + _setValue(key, value) { + const _super = Object.create(null, { + _setValue: { get: () => super._setValue } + }); + return __awaiter(this, void 0, void 0, function* () { + if (key === "name") { + let comps = value.split("."); + if (comps.length !== 2 || comps[1] !== "eth") { + this.throwError("Not a top-level .eth name"); + } + let account = yield this.accounts[0].getAddress(); + let registrar = yield this.getEthRegistrar(); + let ownerOf = null; + try { + ownerOf = yield registrar.ownerOf(ethers.utils.id(comps[0])); + } + catch (error) { + this.throwError("Name not present in Permantent Registrar"); + } + if (account !== ownerOf) { + this.throwError("Only the registrant can call reclaim"); + } + yield _super._setValue.call(this, "label", comps[0]); + } + yield _super._setValue.call(this, key, value); + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + this.dump("Reclaim: " + this.name, { + Nodehash: this.nodehash, + "Address": this.address, + }); + let registrar = yield this.getEthRegistrar(); + yield registrar.reclaim(ethers.utils.id(this.label), this.address); + }); + } +} +cli.addPlugin("reclaim", ReclaimPlugin); +/** + * To Do: + * register NAME --registrar + * set-reverse NAME + * renew NAME --duration DAYS + * + * Done: + * migrate-registrar NAME + * transfer NAME OWNER + * set-subnode LABEL.NAME + * set-owner NAME OWNER + * set-resolver NAME RESOLVER + * set-addr NAME ADDRESS + * set-reverse-name ADDRESS NAME + * set-email NAME EMAIL + * set-webstie NAME WEBSITE + * set-text NAME KEY VALUE + * set-content NAME HASH + * reclaim NAME --address OWNER + */ +cli.run(process.argv.slice(2)); diff --git a/packages/cli/lib.esm/bin/ethers-ts.js b/packages/cli/lib.esm/bin/ethers-ts.js new file mode 100644 index 000000000..fb19bdbf7 --- /dev/null +++ b/packages/cli/lib.esm/bin/ethers-ts.js @@ -0,0 +1,151 @@ +#!/usr/bin/env node +'use strict'; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import fs from 'fs'; +import { join as pathJoin } from "path"; +import { ethers } from 'ethers'; +import { CLI, Plugin } from '../cli'; +import { header as Header, generate as generateTypeScript } from "../typescript"; +import { compile } from "../solc"; +function computeHash(content) { + let bareContent = content.replace(/\/\*\* Content Hash: 0x[0-9A-F]{64} \*\//i, '/** Content Hash: */'); + return ethers.utils.id(bareContent); +} +function checkHash(content) { + let match = content.match(/\/\*\* Content Hash: (0x[0-9A-F]{64}) \*\//i); + return (match && match[1] === computeHash(content)); +} +function addContentHash(content) { + let contentHash = computeHash("/** Content Hash: */\n" + content); + return "/** Content Hash: " + contentHash + " */\n" + content; +} +function save(path, content, force) { + if (fs.existsSync(path) && !force) { + let oldContent = fs.readFileSync(path).toString(); + if (!checkHash(oldContent)) { + return false; + } + } + fs.writeFileSync(path, content); + return true; +} +function walkFilenames(filenames) { + let result = []; + filenames.forEach((filename) => { + let stat = fs.statSync(filename); + if (stat.isDirectory()) { + walkFilenames(fs.readdirSync(filename).map((x) => pathJoin(filename, x))).forEach((filename) => { + result.push(filename); + }); + } + else if (stat.isFile()) { + result.push(filename); + } + }); + return result; +} +let cli = new CLI(null, { + account: false, + provider: false, + transaction: false +}); +class GeneratePlugin extends Plugin { + static getHelp() { + return { + name: "FILENAME [ ... ]", + help: "Generates a TypeScript file of all Contracts. May specify folders." + }; + } + static getOptionHelp() { + return [ + { + name: "--output FILENAME", + help: "Write the output to FILENAME (default: stdout)" + }, + { + name: "--force", + help: "Overwrite files if they already exist" + }, + { + name: "--no-optimize", + help: "Do not run the solc optimizer" + }, + { + name: "--no-bytecode", + help: "Do not include bytecode and Factory methods" + } + ]; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + this.output = argParser.consumeOption("output"); + this.force = argParser.consumeFlag("force"); + this.optimize = !argParser.consumeFlag("no-optimize"); + this.noBytecode = argParser.consumeFlag("no-bytecode"); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length === 0) { + this.throwError("generate requires at least one FILENAME"); + } + this.filenames = args; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let output = Header; + walkFilenames(this.filenames).forEach((filename) => { + if (!filename.match(/\.sol$/)) { + return; + } + let contracts = null; + let content = fs.readFileSync(filename).toString(); + try { + contracts = compile(content, { filename: filename, optimize: this.optimize }); + } + catch (error) { + console.log(error); + if (error.errors) { + error.errors.forEach((error) => { + console.log(error); + }); + } + throw new Error("errors during compilation"); + } + contracts.forEach((contract) => { + output += generateTypeScript(contract, (this.noBytecode ? null : contract.bytecode)); + output += "\n"; + }); + }); + output = addContentHash(output.trim()); + if (this.output) { + let success = save(this.output, output, this.force); + if (!success) { + return Promise.reject(new Error("File has been modified; use --force")); + } + } + else { + console.log(output); + } + return Promise.resolve(null); + }); + } +} +cli.setPlugin(GeneratePlugin); +cli.run(process.argv.slice(2)); diff --git a/packages/cli/lib.esm/bin/ethers.js b/packages/cli/lib.esm/bin/ethers.js new file mode 100644 index 000000000..4fe91a632 --- /dev/null +++ b/packages/cli/lib.esm/bin/ethers.js @@ -0,0 +1,844 @@ +#!/usr/bin/env node +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import fs from "fs"; +import REPL from "repl"; +import util from "util"; +import vm from "vm"; +import { ethers } from "ethers"; +import { CLI, dump, Plugin } from "../cli"; +import { getPassword, getProgressBar } from "../prompt"; +import { compile } from "../solc"; +function setupContext(context, plugin) { + context.provider = plugin.provider; + context.accounts = plugin.accounts; + if (!context.console) { + context.console = console; + } + if (!context.require) { + context.require = require; + } + if (!context.process) { + context.process = process; + } + context.ethers = ethers; + context.version = ethers.version; + context.Contract = ethers.Contract; + context.ContractFactory = ethers.ContractFactory; + context.Wallet = ethers.Wallet; + context.providers = ethers.providers; + context.utils = ethers.utils; + context.abiCoder = ethers.utils.defaultAbiCoder; + context.BN = ethers.BigNumber; + context.BigNumber = ethers.BigNumber; + context.FixedNumber = ethers.FixedNumber; + context.getAddress = ethers.utils.getAddress; + context.getContractAddress = ethers.utils.getContractAddress; + context.getIcapAddress = ethers.utils.getIcapAddress; + context.arrayify = ethers.utils.arrayify; + context.hexlify = ethers.utils.hexlify; + context.joinSignature = ethers.utils.joinSignature; + context.splitSignature = ethers.utils.splitSignature; + context.id = ethers.utils.id; + context.keccak256 = ethers.utils.keccak256; + context.namehash = ethers.utils.namehash; + context.sha256 = ethers.utils.sha256; + context.parseEther = ethers.utils.parseEther; + context.parseUnits = ethers.utils.parseUnits; + context.formatEther = ethers.utils.formatEther; + context.formatUnits = ethers.utils.formatUnits; + context.randomBytes = ethers.utils.randomBytes; + context.constants = ethers.constants; + context.parseTransaction = ethers.utils.parseTransaction; + context.serializeTransaction = ethers.utils.serializeTransaction; + context.toUtf8Bytes = ethers.utils.toUtf8Bytes; + context.toUtf8String = ethers.utils.toUtf8String; +} +const cli = new CLI("sandbox"); +class SandboxPlugin extends Plugin { + static getHelp() { + return { + name: "sandbox", + help: "Run a REPL VM environment with ethers" + }; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 0) { + this.throwUsageError("Unexpected argument - " + JSON.stringify(args[0])); + } + for (let i = 0; i < this.accounts.length; i++) { + yield this.accounts[i].unlock(); + } + }); + } + run() { + console.log("network: " + this.network.name + " (chainId: " + this.network.chainId + ")"); + let nextPromiseId = 0; + function promiseWriter(output) { + if (output instanceof Promise) { + repl.context._p = output; + let promiseId = nextPromiseId++; + output.then((result) => { + console.log(`\n`); + console.log(util.inspect(result)); + repl.context._r = result; + repl.displayPrompt(true); + }, (error) => { + console.log(`\n`); + console.log(util.inspect(error)); + repl.displayPrompt(true); + }); + return ``; + } + return util.inspect(output); + } + let repl = REPL.start({ + input: process.stdin, + output: process.stdout, + prompt: (this.provider ? this.network.name : "no-network") + "> ", + writer: promiseWriter + }); + setupContext(repl.context, this); + return new Promise((resolve) => { + repl.on("exit", function () { + console.log(""); + resolve(null); + }); + }); + } +} +cli.addPlugin("sandbox", SandboxPlugin); +class InitPlugin extends Plugin { + static getHelp() { + return { + name: "init FILENAME", + help: "Create a new JSON wallet" + }; + } + static getOptionHelp() { + return [ + { + name: "[ --force ]", + help: "Overwrite any existing files" + } + ]; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + this.force = argParser.consumeFlag("force"); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwUsageError("init requires FILENAME"); + } + this.filename = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + if (!this.force && fs.existsSync(this.filename)) { + this.throwError('File already exists (use --force to overwrite)'); + } + console.log("Creating a new JSON Wallet - " + this.filename); + console.log('Keep this password and file SAFE!! If lost or forgotten'); + console.log('it CANNOT be recovered, by ANYone, EVER.'); + let password = yield getPassword("Choose a password: "); + let confirm = yield getPassword("Confirm password: "); + if (password !== confirm) { + this.throwError("Passwords do not match"); + } + let wallet = ethers.Wallet.createRandom(); + let progressBar = yield getProgressBar("Encrypting"); + let json = yield wallet.encrypt(password, {}, progressBar); + try { + if (this.force) { + fs.writeFileSync(this.filename, json); + } + else { + fs.writeFileSync(this.filename, json, { flag: 'wx' }); + } + console.log('New account address: ' + wallet.address); + console.log('Saved: ' + this.filename); + } + catch (error) { + if (error.code === 'EEXIST') { + this.throwError('File already exists (use --force to overwrite)'); + } + this.throwError('Unknown Error: ' + error.message); + } + }); + } +} +cli.addPlugin("init", InitPlugin); +class FundPlugin extends Plugin { + static getHelp() { + return { + name: "fund TARGET", + help: "Fund TARGET with testnet ether" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (this.network.name !== "ropsten") { + this.throwError("Funding requires --network ropsten"); + } + if (args.length !== 1) { + this.throwUsageError("fund requires ADDRESS"); + } + this.toAddress = yield this.getAddress(args[0], "Cannot fund ZERO address", false); + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let url = "https:/" + "/api.ethers.io/api/v1/?action=fundAccount&address=" + this.toAddress.toLowerCase(); + return ethers.utils.fetchJson(url).then((data) => { + console.log("Transaction Hash: " + data.hash); + }); + }); + } +} +cli.addPlugin("fund", FundPlugin); +class InfoPlugin extends Plugin { + static getHelp() { + return { + name: "info [ TARGET ... ]", + help: "Dump info for accounts, addresses and ENS names" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + this.queries = []; + let runners = []; + this.accounts.forEach((account, index) => { + this.queries.push(`Account #${index}`); + runners.push(account.getAddress()); + }); + args.forEach((arg) => { + if (ethers.utils.isAddress(arg)) { + this.queries.push(`Address: ${arg}`); + } + else { + this.queries.push(`ENS Name: ${arg}`); + } + runners.push(this.provider.resolveName(arg)); + }); + this.addresses = yield Promise.all(runners); + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + for (let i = 0; i < this.addresses.length; i++) { + let address = this.addresses[i]; + let { balance, nonce, code, reverse } = yield ethers.utils.resolveProperties({ + balance: this.provider.getBalance(address), + nonce: this.provider.getTransactionCount(address), + code: this.provider.getCode(address), + reverse: this.provider.lookupAddress(address) + }); + let info = { + "Address": address, + "Balance": (ethers.utils.formatEther(balance) + " ether"), + "Transaction Count": nonce + }; + if (code != "0x") { + info["Code"] = code; + } + if (reverse) { + info["Reverse Lookup"] = reverse; + } + dump(this.queries[i], info); + } + }); + } +} +cli.addPlugin("info", InfoPlugin); +class SendPlugin extends Plugin { + static getHelp() { + return { + name: "send TARGET ETHER", + help: "Send ETHER ether to TARGET form accounts[0]" + }; + } + static getOptionHelp() { + return [ + { + name: "[ --allow-zero ]", + help: "Allow sending to the address zero" + }, + { + name: "[ --data DATA ]", + help: "Include data in the transaction" + } + ]; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + if (this.accounts.length !== 1) { + this.throwUsageError("send requires exacly one account"); + } + this.data = ethers.utils.hexlify(argParser.consumeOption("data") || "0x"); + this.allowZero = argParser.consumeFlag("allow-zero"); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 2) { + this.throwUsageError("send requires exactly ADDRESS and AMOUNT"); + } + this.toAddress = yield this.getAddress(args[0], "Cannot send to the zero address (use --allow-zero to override)", this.allowZero); + this.value = ethers.utils.parseEther(args[1]); + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + yield this.accounts[0].sendTransaction({ + to: this.toAddress, + data: this.data, + value: this.value + }); + ; + }); + } +} +cli.addPlugin("send", SendPlugin); +class SweepPlugin extends Plugin { + static getHelp() { + return { + name: "sweep TARGET", + help: "Send all ether from accounts[0] to TARGET" + }; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + if (this.accounts.length !== 1) { + this.throwUsageError("sweep requires exacly one account"); + } + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwUsageError("sweep requires exactly ADDRESS"); + } + this.toAddress = yield this.getAddress(args[0]); + ; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let { balance, gasPrice, code } = yield ethers.utils.resolveProperties({ + balance: this.provider.getBalance(this.accounts[0].getAddress()), + gasPrice: (this.gasPrice || this.provider.getGasPrice()), + code: this.provider.getCode(this.toAddress) + }); + if (code !== "0x") { + this.throwError("Cannot sweep to a contract address"); + } + let maxSpendable = balance.sub(gasPrice.mul(21000)); + if (maxSpendable.lte(0)) { + this.throwError("Insufficient funds to sweep"); + } + yield this.accounts[0].sendTransaction({ + to: this.toAddress, + gasLimit: 21000, + gasPrice: gasPrice, + value: maxSpendable + }); + }); + } +} +cli.addPlugin("sweep", SweepPlugin); +class SignMessagePlugin extends Plugin { + static getHelp() { + return { + name: "sign-message MESSAGE", + help: "Sign a MESSAGE with accounts[0]" + }; + } + static getOptionHelp() { + return [ + { + name: "[ --hex ]", + help: "The message content is hex encoded" + } + ]; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + if (this.accounts.length !== 1) { + this.throwError("sign-message requires exacly one account"); + } + this.hex = argParser.consumeFlag("hex"); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwError("send requires exactly MESSAGE"); + } + this.message = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + yield this.accounts[0].signMessage(this.message); + }); + } +} +cli.addPlugin("sign-message", SignMessagePlugin); +class EvalPlugin extends Plugin { + static getHelp() { + return { + name: "eval CODE", + help: "Run CODE in a VM with ethers" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwError("eval requires exactly CODE"); + } + this.code = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let contextObject = {}; + setupContext(contextObject, this); + let context = vm.createContext(contextObject); + let script = new vm.Script(this.code, { filename: "-" }); + let result = script.runInContext(context); + if (result instanceof Promise) { + result = yield result; + } + console.log(result); + }); + } +} +cli.addPlugin("eval", EvalPlugin); +class RunPlugin extends Plugin { + static getHelp() { + return { + name: "run FILENAME", + help: "Run FILENAME in a VM with ethers" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwError("run requires exactly FILENAME"); + } + this.filename = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let contextObject = {}; + setupContext(contextObject, this); + let context = vm.createContext(contextObject); + let script = new vm.Script(fs.readFileSync(this.filename).toString(), { filename: this.filename }); + let result = script.runInContext(context); + if (result instanceof Promise) { + result = yield result; + } + console.log(result); + }); + } +} +cli.addPlugin("run", RunPlugin); +class WaitPlugin extends Plugin { + static getHelp() { + return { + name: "wait HASH", + help: "Wait for a transaction HASH to be mined" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwError("wait requires exactly HASH"); + } + this.hash = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + console.log("Waiting for Transaction:", this.hash); + let receipt = yield this.provider.waitForTransaction(this.hash); + dump("Response:", { + "Block": receipt.blockNumber, + "Block Hash": receipt.blockHash, + "Status": (receipt.status ? "ok" : "failed") + }); + }); + } +} +cli.addPlugin("wait", WaitPlugin); +const WethAddress = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; +const WethAbi = [ + "function deposit() payable", + "function withdraw(uint wad)" +]; +class WrapEtherPlugin extends Plugin { + static getHelp() { + return { + name: "wrap-ether VALUE", + help: "Deposit VALUE into Wrapped Ether (WETH)" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (this.accounts.length !== 1) { + this.throwError("wrap-ether requires exactly one account"); + } + if (args.length !== 1) { + this.throwError("wrap-ether requires exactly VALUE"); + } + this.value = ethers.utils.parseEther(args[0]); + const address = yield this.accounts[0].getAddress(); + const balance = yield this.provider.getBalance(address); + if (balance.lt(this.value)) { + this.throwError("insufficient ether to wrap"); + } + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let address = yield this.accounts[0].getAddress(); + this.dump("Wrapping ether", { + "From": address, + "Value": ethers.utils.formatEther(this.value) + }); + let contract = new ethers.Contract(WethAddress, WethAbi, this.accounts[0]); + yield contract.deposit({ value: this.value }); + }); + } +} +cli.addPlugin("wrap-ether", WrapEtherPlugin); +class UnwrapEtherPlugin extends Plugin { + static getHelp() { + return { + name: "unwrap-ether VALUE", + help: "Withdraw VALUE from Wrapped Ether (WETH)" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (this.accounts.length !== 1) { + this.throwError("unwrap-ether requires exactly one account"); + } + if (args.length !== 1) { + this.throwError("unwrap-ether requires exactly VALUE"); + } + this.value = ethers.utils.parseEther(args[0]); + }); + } + run() { + const _super = Object.create(null, { + run: { get: () => super.run } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.run.call(this); + let address = yield this.accounts[0].getAddress(); + this.dump("Withdrawing Wrapped Ether", { + "To": address, + "Valiue": ethers.utils.formatEther(this.value) + }); + let contract = new ethers.Contract(WethAddress, WethAbi, this.accounts[0]); + yield contract.withdraw(this.value); + }); + } +} +cli.addPlugin("unwrap-ether", UnwrapEtherPlugin); +const Erc20Abi = [ + "function decimals() view returns (uint8)", + "function symbol() view returns (string)", + "function name() view returns (string)", + "function balanceOf(address) view returns (uint)", + "function transfer(address to, uint256 value)" +]; +const Erc20AltAbi = [ + "function symbol() view returns (bytes32)", + "function name() view returns (bytes32)", +]; +class SendTokenPlugin extends Plugin { + static getHelp() { + return { + name: "send-token TOKEN ADDRESS VALUE", + help: "Send VALUE tokens (at TOKEN) to ADDRESS" + }; + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 3) { + this.throwError("send-token requires exactly TOKEN, ADDRESS and VALUE"); + } + if (this.accounts.length !== 1) { + this.throwError("send-token requires exactly one account"); + } + let tokenAddress = yield this.getAddress(args[0]); + this.contract = new ethers.Contract(tokenAddress, Erc20Abi, this.accounts[0]); + this.decimals = yield this.contract.decimals(); + this.toAddress = yield this.getAddress(args[1]); + this.value = ethers.utils.parseUnits(args[2], this.decimals); + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + const info = { + "To": this.toAddress, + "Token Contract": this.contract.address, + "Value": ethers.utils.formatUnits(this.value, this.decimals) + }; + let namePromise = this.contract.name().then((name) => { + if (name === "") { + throw new Error("returned zero"); + } + info["Token Name"] = name; + }, (error) => { + let contract = new ethers.Contract(this.contract.address, Erc20AltAbi, this.contract.signer); + contract.name().then((name) => { + info["Token Name"] = ethers.utils.parseBytes32String(name); + }, (error) => { + throw error; + }); + }); + let symbolPromise = this.contract.symbol().then((symbol) => { + if (symbol === "") { + throw new Error("returned zero"); + } + info["Token Symbol"] = symbol; + }, (error) => { + let contract = new ethers.Contract(this.contract.address, Erc20AltAbi, this.contract.signer); + contract.symbol().then((symbol) => { + info["Token Symbol"] = ethers.utils.parseBytes32String(symbol); + }, (error) => { + throw error; + }); + }); + yield namePromise; + yield symbolPromise; + this.dump("Sending Tokens:", info); + yield this.contract.transfer(this.toAddress, this.value); + }); + } +} +cli.addPlugin("send-token", SendTokenPlugin); +class CompilePlugin extends Plugin { + static getHelp() { + return { + name: "compile FILENAME", + help: "Compiles a Solidity contract" + }; + } + static getOptionHelp() { + return [ + { + name: "[ --no-optimize ]", + help: "Do not optimize the compiled output" + }, + { + name: "[ --warnings ]", + help: "Error on any warning" + } + ]; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + this.noOptimize = argParser.consumeFlag("no-optimize"); + this.warnings = argParser.consumeFlag("warnings"); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwError("compile requires exactly FILENAME"); + } + this.filename = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let source = fs.readFileSync(this.filename).toString(); + let result = compile(source, { + filename: this.filename, + optimize: (!this.noOptimize) + }); + let output = {}; + result.forEach((contract, index) => { + output[contract.name] = { + bytecode: contract.bytecode, + runtime: contract.runtime, + interface: contract.interface.fragments.map((f) => f.format(ethers.utils.FormatTypes.full)) + }; + }); + console.log(JSON.stringify(output, null, 4)); + }); + } +} +cli.addPlugin("compile", CompilePlugin); +class DeployPlugin extends Plugin { + static getHelp() { + return { + name: "deploy FILENAME", + help: "Compile and deploy a Solidity contract" + }; + } + static getOptionHelp() { + return [ + { + name: "[ --no-optimize ]", + help: "Do not optimize the compiled output" + }, + { + name: "[ --contract NAME ]", + help: "Specify the contract to deploy" + } + ]; + } + prepareOptions(argParser) { + const _super = Object.create(null, { + prepareOptions: { get: () => super.prepareOptions } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareOptions.call(this, argParser); + if (this.accounts.length !== 1) { + this.throwError("deploy requires exactly one account"); + } + this.noOptimize = argParser.consumeFlag("no-optimize"); + this.contractName = argParser.consumeOption("contract"); + }); + } + prepareArgs(args) { + const _super = Object.create(null, { + prepareArgs: { get: () => super.prepareArgs } + }); + return __awaiter(this, void 0, void 0, function* () { + yield _super.prepareArgs.call(this, args); + if (args.length !== 1) { + this.throwError("deploy requires exactly FILENAME"); + } + this.filename = args[0]; + }); + } + run() { + return __awaiter(this, void 0, void 0, function* () { + let source = fs.readFileSync(this.filename).toString(); + let result = compile(source, { + filename: this.filename, + optimize: (!this.noOptimize) + }); + let codes = result.filter((c) => (c.bytecode !== "0x" && (this.contractName == null || this.contractName == c.name))); + if (codes.length > 1) { + this.throwError("Please specify a contract with --contract NAME"); + } + if (codes.length === 0) { + this.throwError("No contract found"); + } + let factory = new ethers.ContractFactory(codes[0].interface, codes[0].bytecode, this.accounts[0]); + let contract = yield factory.deploy(); + dump("Deployed:", { + Contract: codes[0].name, + Address: contract.address, + Bytecode: codes[0].bytecode, + Interface: codes[0].interface.fragments.map((f) => f.format(ethers.utils.FormatTypes.full)) + }); + }); + } +} +cli.addPlugin("deploy", DeployPlugin); +cli.run(process.argv.slice(2)); diff --git a/packages/cli/cli.d.ts b/packages/cli/lib.esm/cli.d.ts similarity index 100% rename from packages/cli/cli.d.ts rename to packages/cli/lib.esm/cli.d.ts diff --git a/packages/cli/lib.esm/cli.js b/packages/cli/lib.esm/cli.js new file mode 100644 index 000000000..d874295c6 --- /dev/null +++ b/packages/cli/lib.esm/cli.js @@ -0,0 +1,860 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +import fs from "fs"; +import { basename } from "path"; +import { ethers } from "ethers"; +import scrypt from "scrypt-js"; +import { getChoice, getPassword, getProgressBar } from "./prompt"; +import { version } from "./_version"; +const logger = new ethers.utils.Logger(version); +class UsageError extends Error { +} +///////////////////////////// +// Signer +/* +const signerStates = new WeakMap(); + +class SignerState { + signerFunc: () => Promise; + signer: ethers.Signer; + alwaysAllow: boolean; + + static get(wrapper: WrappedSigner): SignerState { + return signerStates.get(wrapper); + } +} +*/ +const signerFuncs = new WeakMap(); +const signers = new WeakMap(); +const alwaysAllow = new WeakMap(); +// Gets a signer or lazily request it if needed, possibly asking for a password +// to decrypt a JSON wallet +function getSigner(wrapper) { + return __awaiter(this, void 0, void 0, function* () { + if (!signers.has(wrapper)) { + let signerFunc = signerFuncs.get(wrapper); + let signer = yield signerFunc(); + signers.set(wrapper, signer); + } + return signers.get(wrapper); + }); +} +// Throws an error if the user does not allow the operation. If "y" is +// selected, all future operations of that type are automatically accepted +function isAllowed(wrapper, message) { + return __awaiter(this, void 0, void 0, function* () { + if (wrapper.plugin.yes) { + console.log(message + " (--yes => \"y\")"); + return true; + } + let allowed = alwaysAllow.get(wrapper) || {}; + if (allowed[message]) { + console.log(message + " (previous (a)ll => \"y\")"); + return true; + } + try { + let allow = yield getChoice(message, "yna", "n"); + if (allow === "a") { + allowed[message] = true; + alwaysAllow.set(wrapper, allowed); + } + else if (allow === "n") { + throw new Error("Cancelled."); + } + } + catch (error) { + throw new Error("Cancelled."); + } + return true; + }); +} +function repeat(chr, length) { + let result = chr; + while (result.length < length) { + result += result; + } + return result.substring(0, length); +} +// @TODO: Make dump recursable for objects +// Dumps key/value pairs in a nice format +export function dump(header, info) { + console.log(header); + let maxLength = Object.keys(info).reduce((maxLength, i) => Math.max(maxLength, i.length), 0); + for (let key in info) { + let value = info[key]; + if (Array.isArray(value)) { + console.log(" " + key + ":"); + value.forEach((value) => { + console.log(" " + value); + }); + } + else { + console.log(" " + key + ":" + repeat(" ", maxLength - key.length) + " " + info[key]); + } + } +} +// This wraps our signers to prevent the private keys and mnemonics from being exposed. +// It is also in charge of user-interaction, requesting permission before signing or +// sending. +class WrappedSigner extends ethers.Signer { + constructor(addressPromise, signerFunc, plugin) { + super(); + signerFuncs.set(this, signerFunc); + ethers.utils.defineReadOnly(this, "addressPromise", addressPromise); + ethers.utils.defineReadOnly(this, "provider", plugin.provider); + ethers.utils.defineReadOnly(this, "plugin", plugin); + } + connect(provider) { + throw new Error("unsupported for now..."); + //return new WrappedSigner(this.addressPromise, () => getSigner(this).then((s) => s.connect(provider)), provider); + } + getAddress() { + return __awaiter(this, void 0, void 0, function* () { + return this.addressPromise; + }); + } + signMessage(message) { + return __awaiter(this, void 0, void 0, function* () { + let signer = yield getSigner(this); + let info = {}; + if (typeof (message) === "string") { + info["Message"] = JSON.stringify(message); + info["Message (hex)"] = ethers.utils.hexlify(ethers.utils.toUtf8Bytes(message)); + } + else { + let bytes = ethers.utils.arrayify(message); + for (let i = 0; i < bytes.length; i++) { + let c = bytes[i]; + if (c < 32 || c > 126) { + bytes = null; + break; + } + } + if (bytes) { + info["Message"] = ethers.utils.toUtf8String(bytes); + } + info["Message (hex)"] = ethers.utils.hexlify(message); + } + dump("Message:", info); + yield isAllowed(this, "Sign Message?"); + let result = yield signer.signMessage(message); + let signature = ethers.utils.splitSignature(result); + dump("Signature", { + Flat: result, + r: signature.r, + s: signature.s, + vs: signature._vs, + v: signature.v, + recid: signature.recoveryParam, + }); + return result; + }); + } + populateTransaction(transactionRequest) { + return __awaiter(this, void 0, void 0, function* () { + transactionRequest = ethers.utils.shallowCopy(transactionRequest); + if (this.plugin.gasPrice != null) { + transactionRequest.gasPrice = this.plugin.gasPrice; + } + if (this.plugin.gasLimit != null) { + transactionRequest.gasLimit = this.plugin.gasLimit; + } + if (this.plugin.nonce != null) { + transactionRequest.nonce = this.plugin.nonce; + } + let signer = yield getSigner(this); + return signer.populateTransaction(transactionRequest); + }); + } + signTransaction(transactionRequest) { + return __awaiter(this, void 0, void 0, function* () { + let signer = yield getSigner(this); + let network = yield this.provider.getNetwork(); + let tx = yield ethers.utils.resolveProperties(transactionRequest); + let info = {}; + if (tx.to != null) { + info["To"] = tx.to; + } + if (tx.from != null) { + info["From"] = tx.from; + } + info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); + if (tx.nonce != null) { + info["None"] = tx.nonce; + } + info["Data"] = tx.data; + info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); + info["Gas Price"] = (ethers.utils.formatUnits(tx.gasPrice || 0, "gwei") + " gwei"), + info["Chain ID"] = (tx.chainId || 0); + info["Network"] = network.name; + dump("Transaction:", info); + yield isAllowed(this, "Sign Transaction?"); + let result = yield signer.signTransaction(transactionRequest); + let signature = ethers.utils.splitSignature(result); + dump("Signature:", { + Signature: result, + r: signature.r, + s: signature.s, + vs: signature._vs, + v: signature.v, + recid: signature.recoveryParam, + }); + return result; + }); + } + sendTransaction(transactionRequest) { + return __awaiter(this, void 0, void 0, function* () { + let signer = yield getSigner(this); + let network = yield this.provider.getNetwork(); + let tx = yield this.populateTransaction(transactionRequest); + tx = yield ethers.utils.resolveProperties(tx); + let info = {}; + if (tx.to != null) { + info["To"] = tx.to; + } + if (tx.from != null) { + info["From"] = tx.from; + } + info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); + if (tx.nonce != null) { + info["None"] = tx.nonce; + } + info["Data"] = tx.data; + info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); + info["Gas Price"] = (ethers.utils.formatUnits(tx.gasPrice || 0, "gwei") + " gwei"), + info["Chain ID"] = (tx.chainId || 0); + info["Network"] = network.name; + dump("Transaction:", info); + yield isAllowed(this, "Send Transaction?"); + let response = yield signer.sendTransaction(tx); + dump("Response:", { + "Hash": response.hash + }); + if (this.plugin.wait) { + try { + let receipt = yield response.wait(); + dump("Success:", { + "Block Number": receipt.blockNumber, + "Block Hash": receipt.blockHash, + "Gas Used": ethers.utils.commify(receipt.gasUsed.toString()), + "Fee": (ethers.utils.formatEther(receipt.gasUsed.mul(tx.gasPrice)) + " ether") + }); + } + catch (error) { + dump("Failed:", { + "Error": error.message + }); + } + } + return response; + }); + } + unlock() { + return __awaiter(this, void 0, void 0, function* () { + yield getSigner(this); + }); + } +} +class OfflineProvider extends ethers.providers.BaseProvider { + perform(method, params) { + if (method === "sendTransaction") { + console.log("Signed Transaction:"); + console.log(params.signedTransaction); + return Promise.resolve(ethers.utils.keccak256(params.signedTransaction)); + } + return super.perform(method, params); + } +} +///////////////////////////// +// Argument Parser +export class ArgParser { + constructor(args) { + ethers.utils.defineReadOnly(this, "_args", args); + ethers.utils.defineReadOnly(this, "_consumed", args.map((a) => false)); + } + _finalizeArgs() { + let args = []; + for (let i = 0; i < this._args.length; i++) { + if (this._consumed[i]) { + continue; + } + let arg = this._args[i]; + // Escaped args, add the rest as args + if (arg === "--") { + for (let j = i + 1; j < this._args.length; j++) { + args.push(this._args[j]); + } + break; + } + if (arg.substring(0, 2) === "--") { + throw new UsageError(`unexpected option ${arg}`); + } + args.push(arg); + } + return args; + } + _checkCommandIndex() { + for (let i = 0; i < this._args.length; i++) { + if (this._consumed[i]) { + continue; + } + return i; + } + return -1; + } + consumeFlag(name) { + let count = 0; + for (let i = 0; i < this._args.length; i++) { + let arg = this._args[i]; + if (arg === "--") { + break; + } + if (arg === ("--" + name)) { + count++; + this._consumed[i] = true; + } + } + if (count > 1) { + throw new UsageError("expected at most one --${name}"); + } + return (count === 1); + } + consumeMultiOptions(names) { + let result = []; + if (typeof (names) === "string") { + names = [names]; + } + for (let i = 0; i < this._args.length; i++) { + let arg = this._args[i]; + if (arg === "--") { + break; + } + if (arg.substring(0, 2) === "--") { + let name = arg.substring(2); + let index = names.indexOf(name); + if (index < 0) { + continue; + } + if (this._args.length === i) { + throw new UsageError("missing argument for --${name}"); + } + this._consumed[i] = true; + result.push({ name: name, value: this._args[++i] }); + this._consumed[i] = true; + } + } + return result; + } + consumeOptions(name) { + return this.consumeMultiOptions([name]).map((o) => o.value); + } + consumeOption(name) { + let options = this.consumeOptions(name); + if (options.length > 1) { + throw new UsageError(`expected at most one --${name}`); + } + return (options.length ? options[0] : null); + } +} +// Accepts: +// - "-" which indicates to read from the terminal using prompt (which can then be any of the below) +// - JSON Wallet filename (which will require a password to unlock) +// - raw private key +// - mnemonic +function loadAccount(arg, plugin, preventFile) { + return __awaiter(this, void 0, void 0, function* () { + // Secure entry; use prompt with mask + if (arg === "-") { + let content = yield getPassword("Private Key / Mnemonic:"); + return loadAccount(content, plugin, true); + } + // Raw private key + if (ethers.utils.isHexString(arg, 32)) { + let signer = new ethers.Wallet(arg, plugin.provider); + return Promise.resolve(new WrappedSigner(signer.getAddress(), () => Promise.resolve(signer), plugin)); + } + // Mnemonic + if (ethers.utils.isValidMnemonic(arg)) { + const mnemonic = arg; + let signerPromise = null; + if (plugin.mnemonicPassword) { + signerPromise = getPassword("Password (mnemonic): ").then((password) => { + let node = ethers.utils.HDNode.fromMnemonic(mnemonic, password).derivePath(ethers.utils.defaultPath); + return new ethers.Wallet(node.privateKey, plugin.provider); + }); + } + else if (plugin._xxxMnemonicPasswordHard) { + signerPromise = getPassword("Password (mnemonic; experimental - hard): ").then((password) => { + let passwordBytes = ethers.utils.toUtf8Bytes(password, ethers.utils.UnicodeNormalizationForm.NFKC); + let saltBytes = ethers.utils.arrayify(ethers.utils.HDNode.fromMnemonic(mnemonic).privateKey); + let progressBar = getProgressBar("Decrypting"); + return (new Promise((resolve, reject) => { + scrypt(passwordBytes, saltBytes, (1 << 20), 8, 1, 32, (error, progress, key) => { + if (error) { + reject(error); + } + else { + progressBar(progress); + if (key) { + let derivedPassword = ethers.utils.hexlify(key).substring(2); + let node = ethers.utils.HDNode.fromMnemonic(mnemonic, derivedPassword).derivePath(ethers.utils.defaultPath); + resolve(new ethers.Wallet(node.privateKey, plugin.provider)); + } + } + }); + })); + }); + } + else { + signerPromise = Promise.resolve(ethers.Wallet.fromMnemonic(arg).connect(plugin.provider)); + } + return Promise.resolve(new WrappedSigner(signerPromise.then((wallet) => wallet.getAddress()), () => signerPromise, plugin)); + } + // Check for a JSON wallet + try { + let content = fs.readFileSync(arg).toString(); + let address = ethers.utils.getJsonWalletAddress(content); + if (address) { + return Promise.resolve(new WrappedSigner(Promise.resolve(address), () => __awaiter(this, void 0, void 0, function* () { + let password = yield getPassword(`Password (${arg}): `); + let progressBar = getProgressBar("Decrypting"); + return ethers.Wallet.fromEncryptedJson(content, password, progressBar).then((wallet) => { + return wallet.connect(plugin.provider); + }); + }), plugin)); + } + else { + return loadAccount(content.trim(), plugin, true); + } + } + catch (error) { + if (error.message === "cancelled") { + throw new Error("Cancelled."); + } + else if (error.message === "wrong password") { + throw new Error("Incorrect password."); + } + } + throw new UsageError("unknown account option - [REDACTED]"); + return null; + }); +} +export class Plugin { + constructor() { + } + static getHelp() { + return null; + } + static getOptionHelp() { + return []; + } + prepareOptions(argParser) { + return __awaiter(this, void 0, void 0, function* () { + let runners = []; + this.wait = argParser.consumeFlag("wait"); + this.yes = argParser.consumeFlag("yes"); + ///////////////////// + // Provider + let network = (argParser.consumeOption("network") || "homestead"); + let providers = []; + let rpc = []; + argParser.consumeOptions("rpc").forEach((url) => { + let provider = new ethers.providers.JsonRpcProvider(url); + providers.push(provider); + rpc.push(provider); + }); + if (argParser.consumeFlag("alchemy")) { + providers.push(new ethers.providers.AlchemyProvider(network)); + } + if (argParser.consumeFlag("etherscan")) { + providers.push(new ethers.providers.EtherscanProvider(network)); + } + if (argParser.consumeFlag("infura")) { + providers.push(new ethers.providers.InfuraProvider(network)); + } + if (argParser.consumeFlag("nodesmith")) { + providers.push(new ethers.providers.NodesmithProvider(network)); + } + if (argParser.consumeFlag("offline")) { + providers.push(new OfflineProvider(network)); + } + if (providers.length === 1) { + ethers.utils.defineReadOnly(this, "provider", providers[0]); + } + else if (providers.length) { + ethers.utils.defineReadOnly(this, "provider", new ethers.providers.FallbackProvider(providers)); + } + else { + ethers.utils.defineReadOnly(this, "provider", ethers.getDefaultProvider(network)); + } + ///////////////////// + // Accounts + ethers.utils.defineReadOnly(this, "mnemonicPassword", argParser.consumeFlag("mnemonic-password")); + ethers.utils.defineReadOnly(this, "_xxxMnemonicPasswordHard", argParser.consumeFlag("xxx-mnemonic-password")); + let accounts = []; + let accountOptions = argParser.consumeMultiOptions(["account", "account-rpc", "account-void"]); + for (let i = 0; i < accountOptions.length; i++) { + let account = accountOptions[i]; + switch (account.name) { + case "account": + let wrappedSigner = yield loadAccount(account.value, this); + accounts.push(wrappedSigner); + break; + case "account-rpc": + if (rpc.length !== 1) { + this.throwUsageError("--account-rpc requires exactly one JSON-RPC provider"); + } + try { + let signer = null; + if (account.value.match(/^[0-9]+$/)) { + signer = rpc[0].getSigner(parseInt(account.value)); + } + else { + signer = rpc[0].getSigner(ethers.utils.getAddress(account.value)); + } + accounts.push(new WrappedSigner(signer.getAddress(), () => Promise.resolve(signer), this)); + } + catch (error) { + this.throwUsageError("invalid --account-rpc - " + account.value); + } + break; + case "account-void": { + let addressPromise = this.provider.resolveName(account.value); + let signerPromise = addressPromise.then((addr) => { + return new ethers.VoidSigner(addr, this.provider); + }); + accounts.push(new WrappedSigner(addressPromise, () => signerPromise, this)); + break; + } + } + } + ethers.utils.defineReadOnly(this, "accounts", Object.freeze(accounts)); + ///////////////////// + // Transaction Options + let gasPrice = argParser.consumeOption("gas-price"); + if (gasPrice) { + ethers.utils.defineReadOnly(this, "gasPrice", ethers.utils.parseUnits(gasPrice, "gwei")); + } + else { + ethers.utils.defineReadOnly(this, "gasPrice", null); + } + let gasLimit = argParser.consumeOption("gas-limit"); + if (gasLimit) { + ethers.utils.defineReadOnly(this, "gasLimit", ethers.BigNumber.from(gasLimit)); + } + else { + ethers.utils.defineReadOnly(this, "gasLimit", null); + } + let nonce = argParser.consumeOption("nonce"); + if (nonce) { + this.nonce = ethers.BigNumber.from(nonce).toNumber(); + } + // Now wait for all asynchronous options to load + runners.push(this.provider.getNetwork().then((network) => { + ethers.utils.defineReadOnly(this, "network", Object.freeze(network)); + }, (error) => { + ethers.utils.defineReadOnly(this, "network", Object.freeze({ + chainId: 0, + name: "no-network" + })); + })); + try { + yield Promise.all(runners); + } + catch (error) { + this.throwError(error); + } + }); + } + prepareArgs(args) { + return Promise.resolve(null); + } + run() { + return null; + } + getAddress(addressOrName, message, allowZero) { + try { + return Promise.resolve(ethers.utils.getAddress(addressOrName)); + } + catch (error) { } + return this.provider.resolveName(addressOrName).then((address) => { + if (address == null) { + this.throwError("ENS name not configured - " + addressOrName); + } + if (address === ethers.constants.AddressZero && !allowZero) { + this.throwError(message || "cannot use the zero address"); + } + return address; + }); + } + // Dumps formatted data + dump(header, info) { + dump(header, info); + } + // Throwing a UsageError causes the --help to be shown above + // the error.message + throwUsageError(message) { + throw new UsageError(message); + } + // Shows error.message + throwError(message) { + throw new Error(message); + } +} +class CheckPlugin extends Plugin { +} +export class CLI { + constructor(defaultCommand, options) { + ethers.utils.defineReadOnly(this, "options", { + account: true, + provider: true, + transaction: true, + version: version.split("/").pop(), + }); + if (options) { + ["account", "provider", "transaction"].forEach((key) => { + if (options[key] == null) { + return; + } + (this.options)[key] = !!(options[key]); + }); + ["version"].forEach((key) => { + if (options[key] == null) { + return; + } + (this.options)[key] = options[key]; + }); + } + Object.freeze(this.options); + ethers.utils.defineReadOnly(this, "defaultCommand", defaultCommand || null); + ethers.utils.defineReadOnly(this, "plugins", {}); + } + static getAppName() { + try { + return basename(process.mainModule.filename).split(".")[0]; + } + catch (error) { } + return "ethers"; + } + // @TODO: Better way to specify default; i.e. may not have args + addPlugin(command, plugin) { + if (this.standAlone) { + logger.throwError("only setPlugin or addPlugin may be used at once", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "addPlugin" + }); + } + else if (this.plugins[command]) { + logger.throwError("command already exists", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "addPlugin", + command: command + }); + } + ethers.utils.defineReadOnly(this.plugins, command, plugin); + } + setPlugin(plugin) { + if (Object.keys(this.plugins).length !== 0) { + logger.throwError("only setPlugin or addPlugin may be used at once", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "setPlugin" + }); + } + if (this.standAlone) { + logger.throwError("cannot setPlugin more than once", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "setPlugin" + }); + } + ethers.utils.defineReadOnly(this, "standAlone", plugin); + } + showUsage(message, status) { + // Limit: | | + console.log("Usage:"); + if (this.standAlone) { + let help = ethers.utils.getStatic(this.standAlone, "getHelp")(); + console.log(` ${CLI.getAppName()} ${help.name} [ OPTIONS ]`); + console.log(""); + let lines = []; + let optionHelp = ethers.utils.getStatic(this.standAlone, "getOptionHelp")(); + optionHelp.forEach((help) => { + lines.push(" " + help.name + repeat(" ", 28 - help.name.length) + help.help); + }); + if (lines.length) { + console.log("OPTIONS"); + lines.forEach((line) => { + console.log(line); + }); + console.log(""); + } + } + else { + if (this.defaultCommand) { + console.log(` ${CLI.getAppName()} [ COMMAND ] [ ARGS ] [ OPTIONS ]`); + console.log(""); + } + else { + console.log(` ${CLI.getAppName()} COMMAND [ ARGS ] [ OPTIONS ]`); + console.log(""); + } + let lines = []; + for (let cmd in this.plugins) { + let plugin = this.plugins[cmd]; + let help = ethers.utils.getStatic(plugin, "getHelp")(); + if (help == null) { + continue; + } + let helpLine = " " + help.name; + if (helpLine.length > 28) { + lines.push(helpLine); + lines.push(repeat(" ", 30) + help.help); + } + else { + helpLine += repeat(" ", 30 - helpLine.length); + lines.push(helpLine + help.help); + } + let optionHelp = ethers.utils.getStatic(plugin, "getOptionHelp")(); + optionHelp.forEach((help) => { + lines.push(" " + help.name + repeat(" ", 27 - help.name.length) + help.help); + }); + } + if (lines.length) { + if (this.defaultCommand) { + console.log(`COMMANDS (default: ${this.defaultCommand})`); + } + else { + console.log("COMMANDS"); + } + lines.forEach((line) => { + console.log(line); + }); + console.log(""); + } + } + if (this.options.account) { + console.log("ACCOUNT OPTIONS"); + console.log(" --account FILENAME Load from a file (JSON, RAW or mnemonic)"); + console.log(" --account RAW_KEY Use a private key (insecure *)"); + console.log(" --account 'MNEMONIC' Use a mnemonic (insecure *)"); + console.log(" --account - Use secure entry for a raw key or mnemonic"); + console.log(" --account-void ADDRESS Use an address as a void signer"); + console.log(" --account-void ENS_NAME Add the resolved address as a void signer"); + console.log(" --account-rpc ADDRESS Add the address from a JSON-RPC provider"); + console.log(" --account-rpc INDEX Add the index from a JSON-RPC provider"); + console.log(" --mnemonic-password Prompt for a password for mnemonics"); + console.log(" --xxx-mnemonic-password Prompt for a (experimental) hard password"); + console.log(""); + } + if (this.options.provider) { + console.log("PROVIDER OPTIONS (default: all + homestead)"); + console.log(" --alchemy Include Alchemy"); + console.log(" --etherscan Include Etherscan"); + console.log(" --infura Include INFURA"); + console.log(" --nodesmith Include nodesmith"); + console.log(" --rpc URL Include a custom JSON-RPC"); + console.log(" --offline Dump signed transactions (no send)"); + console.log(" --network NETWORK Network to connect to (default: homestead)"); + console.log(""); + } + if (this.options.transaction) { + console.log("TRANSACTION OPTIONS (default: query network)"); + console.log(" --gasPrice GWEI Default gas price for transactions(in wei)"); + console.log(" --gasLimit GAS Default gas limit for transactions"); + console.log(" --nonce NONCE Initial nonce for the first transaction"); + console.log(" --yes Always accept Siging and Sending"); + console.log(""); + } + console.log("OTHER OPTIONS"); + console.log(" --wait Wait until transactions are mined"); + console.log(" --debug Show stack traces for errors"); + console.log(" --help Show this usage and exit"); + console.log(" --version Show this version and exit"); + console.log(""); + console.log("(*) By including mnemonics or private keys on the command line they are"); + console.log(" possibly readable by other users on your system and may get stored in"); + console.log(" your bash history file. This is NOT recommended."); + console.log(""); + if (message) { + console.log(message); + console.log(""); + } + process.exit(status || 0); + throw new Error("never reached"); + } + run(args) { + return __awaiter(this, void 0, void 0, function* () { + args = args.slice(); + if (this.defaultCommand && !this.plugins[this.defaultCommand]) { + throw new Error("missing defaultCommand plugin"); + } + let command = null; + // We run a temporary argument parser to check for a command by processing standard options + { + let argParser = new ArgParser(args); + let plugin = new CheckPlugin(); + yield plugin.prepareOptions(argParser); + // These are not part of the plugin + ["debug", "help", "version"].forEach((key) => { + argParser.consumeFlag(key); + }); + // Find the first unconsumed argument + if (!this.standAlone) { + let commandIndex = argParser._checkCommandIndex(); + if (commandIndex === -1) { + command = this.defaultCommand; + } + else { + command = args[commandIndex]; + args.splice(commandIndex, 1); + } + } + } + // Reset the argument parser + let argParser = new ArgParser(args); + if (argParser.consumeFlag("version")) { + console.log(CLI.getAppName() + "/" + this.options.version); + return; + } + if (argParser.consumeFlag("help")) { + return this.showUsage(); + } + let debug = argParser.consumeFlag("debug"); + // Create Plug-in instance + let plugin = null; + if (this.standAlone) { + plugin = new this.standAlone; + } + else { + try { + plugin = new this.plugins[command](); + } + catch (error) { + if (command) { + this.showUsage("unknown command - " + command); + } + return this.showUsage("no command provided", 1); + } + } + try { + yield plugin.prepareOptions(argParser); + yield plugin.prepareArgs(argParser._finalizeArgs()); + yield plugin.run(); + } + catch (error) { + if (error instanceof UsageError) { + return this.showUsage(error.message, 1); + } + if (debug) { + console.log("----- ------"); + console.log(error); + console.log("----- -----"); + } + console.log("Error: " + error.message); + process.exit(2); + } + }); + } +} diff --git a/packages/cli/prompt.d.ts b/packages/cli/lib.esm/prompt.d.ts similarity index 100% rename from packages/cli/prompt.d.ts rename to packages/cli/lib.esm/prompt.d.ts diff --git a/packages/cli/lib.esm/prompt.js b/packages/cli/lib.esm/prompt.js new file mode 100644 index 000000000..a16287c71 --- /dev/null +++ b/packages/cli/lib.esm/prompt.js @@ -0,0 +1,125 @@ +"use strict"; +function repeat(chr, count) { + let result = ""; + while (result.length < count) { + result += chr; + } + return result; +} +function _getPrompt(prompt, options, callback) { + process.stdout.write(prompt); + let stdin = process.stdin; + stdin.resume(); + stdin.setRawMode(true); + stdin.resume(); + stdin.setEncoding('utf8'); + let message = ''; + let respond = (ctrlC, message) => { + process.stdout.write('\n'); + stdin.setRawMode(false); + stdin.pause(); + stdin.removeListener('data', handler); + callback(ctrlC, message); + }; + function handler(chr) { + chr = String(chr); + switch (chr) { + // Enter (ish) + case "\n": + case "\r": + case "\u0004": + if (options.choice) { + if (options.defaultChoice) { + respond(null, options.defaultChoice); + } + } + else { + respond(null, message); + } + break; + // Backspace + case "\u007f": + if (message.length > 0 && options.choice == null) { + message = message.substring(0, message.length - 1); + (process.stdout).clearLine(); + (process.stdout).cursorTo(0); + if (options.mask) { + process.stdout.write(prompt + repeat(options.mask, message.length)); + } + else { + process.stdout.write(prompt + message); + } + } + break; + // Ctrl-C + case "\u0003": + process.stdout.write('\n[ CTRL-C ]'); + respond(true, null); + break; + // Any other character + default: + if (options.choice) { + if (options.choice.indexOf(chr) >= 0) { + process.stdout.write(chr); + respond(null, chr); + } + } + else { + // More passsword characters + if (options.mask) { + process.stdout.write('*'); + } + else { + process.stdout.write(chr); + } + message += chr; + } + break; + } + } + stdin.on('data', handler); +} +function getPrompt(prompt, options) { + return new Promise((resolve, reject) => { + _getPrompt(prompt, options, (ctrlC, password) => { + if (ctrlC) { + return reject(new Error("cancelled")); + } + resolve(password); + }); + }); +} +export function getProgressBar(action) { + let lastProgress = -1; + return function (percent) { + let progress = Math.trunc(percent * 100); + if (progress == lastProgress) { + return; + } + lastProgress = progress; + process.stdin.setRawMode(false); + process.stdin.pause(); + (process.stdout).clearLine(); + (process.stdout).cursorTo(0); + process.stdout.write(action + "... " + progress + "%"); + if (percent === 1) { + process.stdout.write('\n'); + } + }; +} +export function getPassword(prompt) { + return getPrompt(prompt, { mask: "*" }); +} +export function getMessage(prompt) { + return getPrompt(prompt, {}); +} +// @TODO: Allow choices to be an array, [ "Yes", "No", "All" ] => "(y)es/ (N)o/ (a)ll" +export function getChoice(prompt, choices, defaultChoice) { + let choice = choices.toLowerCase().split(""); + if (defaultChoice) { + defaultChoice = defaultChoice.toLowerCase(); + } + let options = { choice: choice, defaultChoice: defaultChoice }; + let hint = choice.map((c) => ((c === defaultChoice) ? c.toUpperCase() : c)).join("/"); + return getPrompt((prompt + " (" + hint + ") "), options); +} diff --git a/packages/cli/solc.d.ts b/packages/cli/lib.esm/solc.d.ts similarity index 100% rename from packages/cli/solc.d.ts rename to packages/cli/lib.esm/solc.d.ts diff --git a/packages/cli/lib.esm/solc.js b/packages/cli/lib.esm/solc.js new file mode 100644 index 000000000..e444d7c21 --- /dev/null +++ b/packages/cli/lib.esm/solc.js @@ -0,0 +1,73 @@ +'use strict'; +import fs from "fs"; +import { dirname, resolve } from "path"; +import { ethers } from "ethers"; +let _solc = null; +function getSolc() { + if (!_solc) { + _solc = require("solc"); + } + return _solc; +} +; +export function compile(source, options) { + options = ethers.utils.shallowCopy(options || {}); + if (options.filename && !options.basedir) { + options.basedir = dirname(options.filename); + } + if (!options.filename) { + options.filename = "_contract.sol"; + } + if (!options.basedir) { + options.basedir = "."; + } + let sources = {}; + sources[options.filename] = { content: source }; + let input = { + language: "Solidity", + sources: sources, + settings: { + outputSelection: { + "*": { + "*": ["*"] + } + } + } + }; + if (options.optimize) { + input.settings.optimizer = { + enabled: true, + runs: 200 + }; + } + let findImport = (filename) => { + try { + return { + contents: fs.readFileSync(resolve(options.basedir, options.filename)).toString() + }; + } + catch (error) { + return { error: error.message }; + } + }; + let output = JSON.parse(getSolc().compile(JSON.stringify(input), findImport)); + let errors = (output.errors || []).filter((x) => (x.severity === "error" || options.throwWarnings)).map((x) => x.formattedMessage); + if (errors.length) { + let error = new Error("compilation error"); + error.errors = errors; + throw error; + } + let result = []; + for (let filename in output.contracts) { + for (let name in output.contracts[filename]) { + let contract = output.contracts[filename][name]; + result.push({ + name: name, + interface: new ethers.utils.Interface(contract.abi), + bytecode: "0x" + contract.evm.bytecode.object, + runtime: "0x" + contract.evm.deployedBytecode.object + }); + } + } + return result; +} diff --git a/packages/cli/typescript.d.ts b/packages/cli/lib.esm/typescript.d.ts similarity index 100% rename from packages/cli/typescript.d.ts rename to packages/cli/lib.esm/typescript.d.ts diff --git a/packages/cli/lib.esm/typescript.js b/packages/cli/lib.esm/typescript.js new file mode 100644 index 000000000..12247343d --- /dev/null +++ b/packages/cli/lib.esm/typescript.js @@ -0,0 +1,122 @@ +"use strict"; +import { ethers } from "ethers"; +function getType(param, flexible) { + if (param.type === "address" || param.type === "string") { + return "string"; + } + if (param.type === "bool") { + return "boolean"; + } + if (param.type.substring(0, 5) === "bytes") { + if (flexible) { + return "string | ethers.utils.BytesLike"; + } + return "string"; + } + let match = param.type.match(/^(u?int)([0-9]+)$/); + if (match) { + if (flexible) { + return "ethers.BigNumberish"; + } + if (parseInt(match[2]) < 53) { + return 'number'; + } + return 'ethers.BigNumber'; + } + if (param.type === "array") { + return "Array<" + getType(param.arrayChildren) + ">"; + } + if (param.type === "tuple") { + let struct = param.components.map((p, i) => `${p.name || "p_" + i}: ${getType(p, flexible)}`); + return "{ " + struct.join(", ") + " }"; + } + throw new Error("unknown type"); + return null; +} +export const header = "import { ethers } from \"ethers\";\n\n"; +export function generate(contract, bytecode) { + let lines = []; + lines.push("export class " + contract.name + " extends ethers.Contract {"); + lines.push(""); + lines.push(" constructor(addressOrName: string, providerOrSigner: ethers.Signer | ethers.providers.Provider) {"); + lines.push(" super(addressOrName, new.target.ABI(), providerOrSigner)"); + lines.push(" }"); + lines.push(""); + lines.push(` connect(providerOrSigner: ethers.Signer | ethers.providers.Provider): ${contract.name} {`); + lines.push(` return new (<{ new(...args: any[]): ${contract.name} }>(this.constructor))(this.address, providerOrSigner)`); + lines.push(" }"); + lines.push(""); + lines.push(` attach(addressOrName: string): ${contract.name} {`); + lines.push(` return new (<{ new(...args: any[]): ${contract.name} }>(this.constructor))(addressOrName, this.signer || this.provider)`); + lines.push(" }"); + for (let signature in contract.interface.functions) { + if (signature.indexOf('(') === -1) { + continue; + } + let fragment = contract.interface.functions[signature]; + console.log(fragment); + let output = "Promise"; + let overrides = "ethers.CallOverrides"; + if (fragment.constant == false) { + if (fragment.payable) { + overrides = "ethers.PayableOverrides"; + } + else { + overrides = "ethers.Overrides"; + } + } + else if (fragment.outputs.length > 0) { + if (fragment.outputs.length === 1) { + output = "Promise<" + getType(fragment.outputs[0]) + ">"; + } + else { + // If all output parameters are names, we can specify the struct + if (fragment.outputs.filter((o) => (!!o.name)).length === fragment.outputs.length) { + output = "Promise<{ " + fragment.outputs.map((o, i) => ((o.name || ("arg" + String(i))) + ": " + getType(o))).join(", ") + " }>"; + } + else { + // Otherwise, all we know is that it will be an Array + output = "Promise<{ Array }>"; + } + } + } + let inputs = []; + let passed = []; + fragment.inputs.forEach((input, index) => { + let name = (input.name || ("p_" + index)); + let type = getType(input, true); + inputs.push(name + ": " + type); + passed.push(name); + }); + inputs.push("_overrides?: " + overrides); + passed.push("_overrides"); + lines.push(""); + lines.push(` ${fragment.name}(${inputs.join(', ')}): ${output} {`); + lines.push(` return this.functions["${signature}"](${passed.join(", ")});`); + lines.push(" }"); + } + lines.push(""); + lines.push(" static factory(signer?: ethers.Signer): ethers.ContractFactory {"); + lines.push(" return new ethers.ContractFactory(" + contract.name + ".ABI(), " + contract.name + ".bytecode(), signer);"); + lines.push(" }"); + lines.push(""); + lines.push(" static bytecode(): string {"); + if (bytecode == null) { + lines.push(' return ethers.errors.throwError("no bytecode provided during generation", ethers.errors.UNSUPPORTED_OPERATION, { operation: "contract.bytecode" });'); + } + else { + lines.push(' return "' + bytecode + '";'); + } + lines.push(" }"); + lines.push(""); + lines.push(" static ABI(): Array {"); + lines.push(" return ["); + contract.interface.fragments.forEach((fragment) => { + lines.push(` "${fragment.format(ethers.utils.FormatTypes.full)}",`); + }); + lines.push(" ];"); + lines.push(" }"); + lines.push("}"); + let output = lines.join("\n") + "\n"; + return output; +} diff --git a/packages/cli/lib/_version.d.ts b/packages/cli/lib/_version.d.ts new file mode 100644 index 000000000..eb4b3a8de --- /dev/null +++ b/packages/cli/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "cli/5.0.0-beta.141"; diff --git a/packages/cli/_version.js b/packages/cli/lib/_version.js similarity index 100% rename from packages/cli/_version.js rename to packages/cli/lib/_version.js diff --git a/packages/cli/bin/ethers-ens.js b/packages/cli/lib/bin/ethers-ens.js old mode 100755 new mode 100644 similarity index 100% rename from packages/cli/bin/ethers-ens.js rename to packages/cli/lib/bin/ethers-ens.js diff --git a/packages/cli/bin/ethers-ts.js b/packages/cli/lib/bin/ethers-ts.js old mode 100755 new mode 100644 similarity index 100% rename from packages/cli/bin/ethers-ts.js rename to packages/cli/lib/bin/ethers-ts.js diff --git a/packages/cli/bin/ethers.js b/packages/cli/lib/bin/ethers.js old mode 100755 new mode 100644 similarity index 100% rename from packages/cli/bin/ethers.js rename to packages/cli/lib/bin/ethers.js diff --git a/packages/cli/lib/cli.d.ts b/packages/cli/lib/cli.d.ts new file mode 100644 index 000000000..6eb742876 --- /dev/null +++ b/packages/cli/lib/cli.d.ts @@ -0,0 +1,81 @@ +import { ethers } from "ethers"; +export declare function dump(header: string, info: any): void; +declare class WrappedSigner extends ethers.Signer { + readonly addressPromise: Promise; + readonly provider: ethers.providers.Provider; + readonly plugin: Plugin; + constructor(addressPromise: Promise, signerFunc: () => Promise, plugin: Plugin); + connect(provider?: ethers.providers.Provider): ethers.Signer; + getAddress(): Promise; + signMessage(message: string | ethers.utils.Bytes): Promise; + populateTransaction(transactionRequest: ethers.providers.TransactionRequest): Promise; + signTransaction(transactionRequest: ethers.providers.TransactionRequest): Promise; + sendTransaction(transactionRequest: ethers.providers.TransactionRequest): Promise; + unlock(): Promise; +} +export declare class ArgParser { + readonly _args: Array; + readonly _consumed: Array; + constructor(args: Array); + _finalizeArgs(): Array; + _checkCommandIndex(): number; + consumeFlag(name: string): boolean; + consumeMultiOptions(names: Array): Array<{ + name: string; + value: string; + }>; + consumeOptions(name: string): Array; + consumeOption(name: string): string; +} +export interface Help { + name: string; + help: string; +} +export interface PluginType { + new (...args: any[]): Plugin; + getHelp?: () => Help; + getOptionHelp?: () => Array; +} +export declare abstract class Plugin { + network: ethers.providers.Network; + provider: ethers.providers.Provider; + accounts: Array; + mnemonicPassword: boolean; + _xxxMnemonicPasswordHard: boolean; + gasLimit: ethers.BigNumber; + gasPrice: ethers.BigNumber; + nonce: number; + yes: boolean; + wait: boolean; + constructor(); + static getHelp(): Help; + static getOptionHelp(): Array; + prepareOptions(argParser: ArgParser): Promise; + prepareArgs(args: Array): Promise; + run(): Promise; + getAddress(addressOrName: string, message?: string, allowZero?: boolean): Promise; + dump(header: string, info: any): void; + throwUsageError(message?: string): never; + throwError(message: string): never; +} +export declare type Options = { + account?: boolean; + provider?: boolean; + transaction?: boolean; + version?: string; +}; +export declare class CLI { + readonly defaultCommand: string; + readonly plugins: { + [command: string]: PluginType; + }; + readonly standAlone: PluginType; + readonly options: Options; + constructor(defaultCommand?: string, options?: Options); + static getAppName(): string; + addPlugin(command: string, plugin: PluginType): void; + setPlugin(plugin: PluginType): void; + showUsage(message?: string, status?: number): never; + run(args: Array): Promise; +} +export {}; diff --git a/packages/cli/cli.js b/packages/cli/lib/cli.js similarity index 100% rename from packages/cli/cli.js rename to packages/cli/lib/cli.js diff --git a/packages/cli/lib/index.d.ts b/packages/cli/lib/index.d.ts new file mode 100644 index 000000000..bbd0b66a0 --- /dev/null +++ b/packages/cli/lib/index.d.ts @@ -0,0 +1,5 @@ +import * as cli from "./cli"; +import * as prompt from "./prompt"; +import * as solc from "./solc"; +import * as typescript from "./typescript"; +export { cli, prompt, solc, typescript, }; diff --git a/packages/cli/lib/index.js b/packages/cli/lib/index.js new file mode 100644 index 000000000..88992e6b6 --- /dev/null +++ b/packages/cli/lib/index.js @@ -0,0 +1,17 @@ +"use strict"; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var cli = __importStar(require("./cli")); +exports.cli = cli; +var prompt = __importStar(require("./prompt")); +exports.prompt = prompt; +var solc = __importStar(require("./solc")); +exports.solc = solc; +var typescript = __importStar(require("./typescript")); +exports.typescript = typescript; diff --git a/packages/cli/lib/prompt.d.ts b/packages/cli/lib/prompt.d.ts new file mode 100644 index 000000000..d9a14132b --- /dev/null +++ b/packages/cli/lib/prompt.d.ts @@ -0,0 +1,9 @@ +export declare type PromptOptions = { + choice?: Array; + defaultChoice?: string; + mask?: string; +}; +export declare function getProgressBar(action: string): (percent: number) => void; +export declare function getPassword(prompt: string): Promise; +export declare function getMessage(prompt: string): Promise; +export declare function getChoice(prompt: string, choices: string, defaultChoice?: string): Promise; diff --git a/packages/cli/prompt.js b/packages/cli/lib/prompt.js similarity index 100% rename from packages/cli/prompt.js rename to packages/cli/lib/prompt.js diff --git a/packages/cli/lib/solc.d.ts b/packages/cli/lib/solc.d.ts new file mode 100644 index 000000000..fc43b9a51 --- /dev/null +++ b/packages/cli/lib/solc.d.ts @@ -0,0 +1,14 @@ +import { ethers } from "ethers"; +export interface ContractCode { + interface: ethers.utils.Interface; + name: string; + bytecode?: string; + runtime?: string; +} +export declare type CompilerOptions = { + filename?: string; + basedir?: string; + optimize?: boolean; + throwWarnings?: boolean; +}; +export declare function compile(source: string, options?: CompilerOptions): Array; diff --git a/packages/cli/solc.js b/packages/cli/lib/solc.js similarity index 100% rename from packages/cli/solc.js rename to packages/cli/lib/solc.js diff --git a/packages/cli/lib/typescript.d.ts b/packages/cli/lib/typescript.d.ts new file mode 100644 index 000000000..f0aa5b8ff --- /dev/null +++ b/packages/cli/lib/typescript.d.ts @@ -0,0 +1,3 @@ +import { ContractCode } from "./solc"; +export declare const header = "import { ethers } from \"ethers\";\n\n"; +export declare function generate(contract: ContractCode, bytecode?: string): string; diff --git a/packages/cli/typescript.js b/packages/cli/lib/typescript.js similarity index 100% rename from packages/cli/typescript.js rename to packages/cli/lib/typescript.js diff --git a/packages/cli/package.json b/packages/cli/package.json index 492efe52c..2c52a22e0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,15 +1,15 @@ { "name": "@ethersproject/cli", - "version": "5.0.0-beta.141", + "version": "5.0.0-beta.142", "description": "Command-Line Interface scripts and releated utilities.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "exit 1" }, "bin": { - "ethers": "./bin/ethers.js", - "ethers-ens": "./bin/ethers-ens.js", - "ethers-ts": "./bin/ethers-ts.js" + "ethers": "./lib/bin/ethers.js", + "ethers-ens": "./lib/bin/ethers-ens.js", + "ethers-ts": "./lib/bin/ethers-ts.js" }, "dependencies": { "@types/node": "10.3.2", @@ -34,5 +34,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x9ca201d156724880ae19a0e253cc5521d32928d7629fd6d6e78c25064bdbca7b" + "module": "./lib.esm/index.js", + "tarballHash": "0xba8cdd7f8648de30fba61ce68e7592be382a490cb92217765fb926cdd99942b8" } diff --git a/packages/cli/src.ts/index.ts b/packages/cli/src.ts/index.ts new file mode 100644 index 000000000..5ba1e8368 --- /dev/null +++ b/packages/cli/src.ts/index.ts @@ -0,0 +1,13 @@ +"use strict"; + +import * as cli from "./cli"; +import * as prompt from "./prompt"; +import * as solc from "./solc"; +import * as typescript from "./typescript"; + +export { + cli, + prompt, + solc, + typescript, +}; diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index f551276d9..d48832e0c 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -2,13 +2,12 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./thirdparty.d.ts", - "./src.ts/*", - "./src.ts/bin/*" + "./thirdparty.d.ts", + "./src.ts/*", + "./src.ts/bin/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/constants/_version.d.ts b/packages/constants/lib.esm/_version.d.ts similarity index 100% rename from packages/constants/_version.d.ts rename to packages/constants/lib.esm/_version.d.ts diff --git a/packages/constants/lib.esm/_version.js b/packages/constants/lib.esm/_version.js new file mode 100644 index 000000000..8dd43ee6b --- /dev/null +++ b/packages/constants/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "constants/5.0.0-beta.127"; diff --git a/packages/constants/index.d.ts b/packages/constants/lib.esm/index.d.ts similarity index 100% rename from packages/constants/index.d.ts rename to packages/constants/lib.esm/index.d.ts diff --git a/packages/constants/lib.esm/index.js b/packages/constants/lib.esm/index.js new file mode 100644 index 000000000..0e28d3298 --- /dev/null +++ b/packages/constants/lib.esm/index.js @@ -0,0 +1,15 @@ +"use strict"; +import { BigNumber } from "@ethersproject/bignumber"; +const AddressZero = "0x0000000000000000000000000000000000000000"; +const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; +// NFKD (decomposed) +//const EtherSymbol = "\uD835\uDF63"; +// NFKC (composed) +const EtherSymbol = "\u039e"; +const NegativeOne = BigNumber.from(-1); +const Zero = BigNumber.from(0); +const One = BigNumber.from(1); +const Two = BigNumber.from(2); +const WeiPerEther = BigNumber.from("1000000000000000000"); +const MaxUint256 = BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); +export { AddressZero, HashZero, EtherSymbol, NegativeOne, Zero, One, Two, WeiPerEther, MaxUint256 }; diff --git a/packages/constants/lib/_version.d.ts b/packages/constants/lib/_version.d.ts new file mode 100644 index 000000000..d04a1c07c --- /dev/null +++ b/packages/constants/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "constants/5.0.0-beta.127"; diff --git a/packages/constants/_version.js b/packages/constants/lib/_version.js similarity index 100% rename from packages/constants/_version.js rename to packages/constants/lib/_version.js diff --git a/packages/constants/lib/index.d.ts b/packages/constants/lib/index.d.ts new file mode 100644 index 000000000..dbe822a82 --- /dev/null +++ b/packages/constants/lib/index.d.ts @@ -0,0 +1,11 @@ +import { BigNumber } from "@ethersproject/bignumber"; +declare const AddressZero = "0x0000000000000000000000000000000000000000"; +declare const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; +declare const EtherSymbol = "\u039E"; +declare const NegativeOne: BigNumber; +declare const Zero: BigNumber; +declare const One: BigNumber; +declare const Two: BigNumber; +declare const WeiPerEther: BigNumber; +declare const MaxUint256: BigNumber; +export { AddressZero, HashZero, EtherSymbol, NegativeOne, Zero, One, Two, WeiPerEther, MaxUint256 }; diff --git a/packages/constants/index.js b/packages/constants/lib/index.js similarity index 100% rename from packages/constants/index.js rename to packages/constants/lib/index.js diff --git a/packages/constants/package.json b/packages/constants/package.json index 9d614cbf8..1c77a794e 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/constants", - "version": "5.0.0-beta.127", + "version": "5.0.0-beta.128", "description": "Common Ethereum constants used for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -22,5 +22,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xf24dd45d26fff811147d6cff7199683bb090c6a182acc58e1007b82a14bf4ee1" + "module": "./lib.esm/index.js", + "tarballHash": "0x3ece9df573db39c560dac46836c5bc16d4c46a504991a726262f5f0ca8b1b2f1" } diff --git a/packages/constants/tsconfig.json b/packages/constants/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/constants/tsconfig.json +++ b/packages/constants/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/contracts/_version.d.ts b/packages/contracts/lib.esm/_version.d.ts similarity index 100% rename from packages/contracts/_version.d.ts rename to packages/contracts/lib.esm/_version.d.ts diff --git a/packages/contracts/lib.esm/_version.js b/packages/contracts/lib.esm/_version.js new file mode 100644 index 000000000..46c0fc670 --- /dev/null +++ b/packages/contracts/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "contracts/5.0.0-beta.136"; diff --git a/packages/contracts/index.d.ts b/packages/contracts/lib.esm/index.d.ts similarity index 100% rename from packages/contracts/index.d.ts rename to packages/contracts/lib.esm/index.d.ts diff --git a/packages/contracts/lib.esm/index.js b/packages/contracts/lib.esm/index.js new file mode 100644 index 000000000..8825caebc --- /dev/null +++ b/packages/contracts/lib.esm/index.js @@ -0,0 +1,703 @@ +"use strict"; +import { Indexed, Interface } from "@ethersproject/abi"; +import { Provider } from "@ethersproject/abstract-provider"; +import { Signer, VoidSigner } from "@ethersproject/abstract-signer"; +import { getContractAddress } from "@ethersproject/address"; +import { BigNumber } from "@ethersproject/bignumber"; +import { concat, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; +import { Zero } from "@ethersproject/constants"; +import { defineReadOnly, deepCopy, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +/////////////////////////////// +const allowedTransactionKeys = { + chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +// Recursively replaces ENS names with promises to resolve the name and resolves all properties +function resolveAddresses(signerOrProvider, value, paramType) { + if (Array.isArray(paramType)) { + return Promise.all(paramType.map((paramType, index) => { + return resolveAddresses(signerOrProvider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); + })); + } + if (paramType.type === "address") { + return signerOrProvider.resolveName(value); + } + if (paramType.type === "tuple") { + return resolveAddresses(signerOrProvider, value, paramType.components); + } + if (paramType.baseType === "array") { + if (!Array.isArray(value)) { + throw new Error("invalid value for array"); + } + return Promise.all(value.map((v) => resolveAddresses(signerOrProvider, v, paramType.arrayChildren))); + } + return Promise.resolve(value); +} +function runMethod(contract, functionName, options) { + let method = contract.interface.functions[functionName]; + return function (...params) { + let tx = {}; + let blockTag = null; + // If 1 extra parameter was passed in, it contains overrides + if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === "object") { + tx = shallowCopy(params.pop()); + if (tx.blockTag != null) { + blockTag = tx.blockTag; + } + delete tx.blockTag; + // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") + for (let key in tx) { + if (!allowedTransactionKeys[key]) { + logger.throwError(("unknown transaxction override - " + key), "overrides", tx); + } + } + } + logger.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); + // Check overrides make sense + ["data", "to"].forEach(function (key) { + if (tx[key] != null) { + logger.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + } + }); + // If the contract was just deployed, wait until it is minded + if (contract.deployTransaction != null) { + tx.to = contract._deployed(blockTag).then(() => { + return contract.addressPromise; + }); + } + else { + tx.to = contract.addressPromise; + } + return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then((params) => { + tx.data = contract.interface.encodeFunctionData(method, params); + if (method.constant || options.callStatic) { + // Call (constant functions) always cost 0 ether + if (options.estimate) { + return Promise.resolve(Zero); + } + if (!contract.provider && !contract.signer) { + logger.throwError("call (constant functions) require a provider or signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" }); + } + // Check overrides make sense + ["gasLimit", "gasPrice", "value"].forEach(function (key) { + if (tx[key] != null) { + throw new Error("call cannot override " + key); + } + }); + if (options.transaction) { + return resolveProperties(tx); + } + return (contract.signer || contract.provider).call(tx, blockTag).then((value) => { + try { + let result = contract.interface.decodeFunctionResult(method, value); + if (method.outputs.length === 1) { + result = result[0]; + } + return result; + } + catch (error) { + if (error.code === Logger.errors.CALL_EXCEPTION) { + error.address = contract.address; + error.args = params; + error.transaction = tx; + } + throw error; + } + }); + } + // Only computing the transaction estimate + if (options.estimate) { + if (!contract.provider && !contract.signer) { + logger.throwError("estimate require a provider or signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); + } + return (contract.signer || contract.provider).estimateGas(tx); + } + if (tx.gasLimit == null && method.gas != null) { + tx.gasLimit = BigNumber.from(method.gas).add(21000); + } + if (tx.value != null && !method.payable) { + logger.throwArgumentError("contract method is not payable", "sendTransaction:" + method.format(), tx); + } + if (options.transaction) { + return resolveProperties(tx); + } + if (!contract.signer) { + logger.throwError("sending a transaction require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); + } + return contract.signer.sendTransaction(tx).then((tx) => { + let wait = tx.wait.bind(tx); + tx.wait = (confirmations) => { + return wait(confirmations).then((receipt) => { + receipt.events = receipt.logs.map((log) => { + let event = deepCopy(log); + let parsed = contract.interface.parseLog(log); + if (parsed) { + event.values = parsed.values; + event.decode = (data, topics) => { + return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.event = parsed.name; + event.eventSignature = parsed.signature; + } + event.removeListener = () => { return contract.provider; }; + event.getBlock = () => { + return contract.provider.getBlock(receipt.blockHash); + }; + event.getTransaction = () => { + return contract.provider.getTransaction(receipt.transactionHash); + }; + event.getTransactionReceipt = () => { + return Promise.resolve(receipt); + }; + return event; + }); + return receipt; + }); + }; + return tx; + }); + }); + }; +} +function getEventTag(filter) { + if (filter.address && (filter.topics == null || filter.topics.length === 0)) { + return "*"; + } + return (filter.address || "*") + "@" + (filter.topics ? filter.topics.join(":") : ""); +} +class RunningEvent { + constructor(tag, filter) { + defineReadOnly(this, "tag", tag); + defineReadOnly(this, "filter", filter); + this._listeners = []; + } + addListener(listener, once) { + this._listeners.push({ listener: listener, once: once }); + } + removeListener(listener) { + let done = false; + this._listeners = this._listeners.filter((item) => { + if (done || item.listener !== listener) { + return true; + } + done = true; + return false; + }); + } + removeAllListeners() { + this._listeners = []; + } + listeners() { + return this._listeners.map((i) => i.listener); + } + listenerCount() { + return this._listeners.length; + } + run(args) { + let listenerCount = this.listenerCount(); + this._listeners = this._listeners.filter((item) => { + let argsCopy = args.slice(); + // Call the callback in the next event loop + setTimeout(() => { + item.listener.apply(this, argsCopy); + }, 0); + // Reschedule it if it not "once" + return !(item.once); + }); + return listenerCount; + } + prepareEvent(event) { + } +} +class ErrorRunningEvent extends RunningEvent { + constructor() { + super("error", null); + } +} +class FragmentRunningEvent extends RunningEvent { + constructor(address, contractInterface, fragment, topics) { + let filter = { + address: address + }; + let topic = contractInterface.getEventTopic(fragment); + if (topics) { + if (topic !== topics[0]) { + logger.throwArgumentError("topic mismatch", "topics", topics); + } + filter.topics = topics.slice(); + } + else { + filter.topics = [topic]; + } + super(getEventTag(filter), filter); + defineReadOnly(this, "address", address); + defineReadOnly(this, "interface", contractInterface); + defineReadOnly(this, "fragment", fragment); + } + prepareEvent(event) { + super.prepareEvent(event); + event.event = this.fragment.name; + event.eventSignature = this.fragment.format(); + event.decode = (data, topics) => { + return this.interface.decodeEventLog(this.fragment, data, topics); + }; + event.values = this.interface.decodeEventLog(this.fragment, event.data, event.topics); + } +} +class WildcardRunningEvent extends RunningEvent { + constructor(address, contractInterface) { + super("*", { address: address }); + defineReadOnly(this, "address", address); + defineReadOnly(this, "interface", contractInterface); + } + prepareEvent(event) { + super.prepareEvent(event); + let parsed = this.interface.parseLog(event); + if (parsed) { + event.event = parsed.name; + event.eventSignature = parsed.signature; + event.decode = (data, topics) => { + return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.values = parsed.values; + } + } +} +export class Contract { + constructor(addressOrName, contractInterface, signerOrProvider) { + logger.checkNew(new.target, Contract); + // @TODO: Maybe still check the addressOrName looks like a valid address or name? + //address = getAddress(address); + defineReadOnly(this, "interface", getStatic((new.target), "getInterface")(contractInterface)); + if (Signer.isSigner(signerOrProvider)) { + defineReadOnly(this, "provider", signerOrProvider.provider || null); + defineReadOnly(this, "signer", signerOrProvider); + } + else if (Provider.isProvider(signerOrProvider)) { + defineReadOnly(this, "provider", signerOrProvider); + defineReadOnly(this, "signer", null); + } + else { + logger.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); + } + defineReadOnly(this, "callStatic", {}); + defineReadOnly(this, "estimate", {}); + defineReadOnly(this, "functions", {}); + defineReadOnly(this, "populateTransaction", {}); + defineReadOnly(this, "filters", {}); + Object.keys(this.interface.events).forEach((eventName) => { + let event = this.interface.events[eventName]; + defineReadOnly(this.filters, eventName, (...args) => { + return { + address: this.address, + topics: this.interface.encodeFilterTopics(event, args) + }; + }); + }); + defineReadOnly(this, "_runningEvents", {}); + defineReadOnly(this, "_wrappedEmits", {}); + defineReadOnly(this, "address", addressOrName); + if (this.provider) { + defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then((address) => { + if (address == null) { + throw new Error("name not found"); + } + return address; + }).catch((error) => { + console.log("ERROR: Cannot find Contract - " + addressOrName); + throw error; + })); + } + else { + try { + defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); + } + catch (error) { + // Without a provider, we cannot use ENS names + logger.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); + } + } + Object.keys(this.interface.functions).forEach((name) => { + let run = runMethod(this, name, {}); + if (this[name] == null) { + defineReadOnly(this, name, run); + } + if (this.functions[name] == null) { + defineReadOnly(this.functions, name, run); + } + if (this.callStatic[name] == null) { + defineReadOnly(this.callStatic, name, runMethod(this, name, { callStatic: true })); + } + if (this.populateTransaction[name] == null) { + defineReadOnly(this.populateTransaction, name, runMethod(this, name, { transaction: true })); + } + if (this.estimate[name] == null) { + defineReadOnly(this.estimate, name, runMethod(this, name, { estimate: true })); + } + }); + } + static getContractAddress(transaction) { + return getContractAddress(transaction); + } + static getInterface(contractInterface) { + if (Interface.isInterface(contractInterface)) { + return contractInterface; + } + return new Interface(contractInterface); + } + // @TODO: Allow timeout? + deployed() { + return this._deployed(); + } + _deployed(blockTag) { + if (!this._deployedPromise) { + // If we were just deployed, we know the transaction we should occur in + if (this.deployTransaction) { + this._deployedPromise = this.deployTransaction.wait().then(() => { + return this; + }); + } + else { + // @TODO: Once we allow a timeout to be passed in, we will wait + // up to that many blocks for getCode + // Otherwise, poll for our code to be deployed + this._deployedPromise = this.provider.getCode(this.address, blockTag).then((code) => { + if (code === "0x") { + logger.throwError("contract not deployed", Logger.errors.UNSUPPORTED_OPERATION, { + contractAddress: this.address, + operation: "getDeployed" + }); + } + return this; + }); + } + } + return this._deployedPromise; + } + // @TODO: + // estimateFallback(overrides?: TransactionRequest): Promise + // @TODO: + // estimateDeploy(bytecode: string, ...args): Promise + fallback(overrides) { + if (!this.signer) { + logger.throwError("sending a transaction require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + } + let tx = shallowCopy(overrides || {}); + ["from", "to"].forEach(function (key) { + if (tx[key] == null) { + return; + } + logger.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + tx.to = this.addressPromise; + return this.deployed().then(() => { + return this.signer.sendTransaction(tx); + }); + } + // Reconnect to a different signer or provider + connect(signerOrProvider) { + if (typeof (signerOrProvider) === "string") { + signerOrProvider = new VoidSigner(signerOrProvider, this.provider); + } + let contract = new (this.constructor)(this.address, this.interface, signerOrProvider); + if (this.deployTransaction) { + defineReadOnly(contract, "deployTransaction", this.deployTransaction); + } + return contract; + } + // Re-attach to a different on-chain instance of this contract + attach(addressOrName) { + return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider); + } + static isIndexed(value) { + return Indexed.isIndexed(value); + } + _normalizeRunningEvent(runningEvent) { + // Already have an instance of this event running; we can re-use it + if (this._runningEvents[runningEvent.tag]) { + return this._runningEvents[runningEvent.tag]; + } + return runningEvent; + } + _getRunningEvent(eventName) { + if (typeof (eventName) === "string") { + // Listen for "error" events (if your contract has an error event, include + // the full signature to bypass this special event keyword) + if (eventName === "error") { + return this._normalizeRunningEvent(new ErrorRunningEvent()); + } + // Listen for any event + if (eventName === "*") { + return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); + } + let fragment = this.interface.getEvent(eventName); + if (!fragment) { + logger.throwArgumentError("unknown event - " + eventName, "eventName", eventName); + } + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); + } + let filter = { + address: this.address + }; + // Find the matching event in the ABI; if none, we still allow filtering + // since it may be a filter for an otherwise unknown event + if (eventName.topics) { + if (eventName.topics[0]) { + let fragment = this.interface.getEvent(eventName.topics[0]); + if (fragment) { + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); + } + } + filter.topics = eventName.topics; + } + return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter)); + } + _checkRunningEvents(runningEvent) { + if (runningEvent.listenerCount() === 0) { + delete this._runningEvents[runningEvent.tag]; + } + // If we have a poller for this, remove it + let emit = this._wrappedEmits[runningEvent.tag]; + if (emit) { + this.provider.off(runningEvent.filter, emit); + delete this._wrappedEmits[runningEvent.tag]; + } + } + _wrapEvent(runningEvent, log, listener) { + let event = deepCopy(log); + try { + runningEvent.prepareEvent(event); + } + catch (error) { + this.emit("error", error); + throw error; + } + event.removeListener = () => { + if (!listener) { + return; + } + runningEvent.removeListener(listener); + this._checkRunningEvents(runningEvent); + }; + event.getBlock = () => { return this.provider.getBlock(log.blockHash); }; + event.getTransaction = () => { return this.provider.getTransaction(log.transactionHash); }; + event.getTransactionReceipt = () => { return this.provider.getTransactionReceipt(log.transactionHash); }; + return event; + } + _addEventListener(runningEvent, listener, once) { + if (!this.provider) { + logger.throwError("events require a provider or a signer with a provider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); + } + runningEvent.addListener(listener, once); + // Track this running event and its listeners (may already be there; but no hard in updating) + this._runningEvents[runningEvent.tag] = runningEvent; + // If we are not polling the provider, start + if (!this._wrappedEmits[runningEvent.tag]) { + let wrappedEmit = (log) => { + let event = this._wrapEvent(runningEvent, log, listener); + let values = (event.values || []); + values.push(event); + this.emit(runningEvent.filter, ...values); + }; + this._wrappedEmits[runningEvent.tag] = wrappedEmit; + // Special events, like "error" do not have a filter + if (runningEvent.filter != null) { + this.provider.on(runningEvent.filter, wrappedEmit); + } + } + } + queryFilter(event, fromBlockOrBlockhash, toBlock) { + let runningEvent = this._getRunningEvent(event); + let filter = shallowCopy(runningEvent.filter); + if (typeof (fromBlockOrBlockhash) === "string" && isHexString(fromBlockOrBlockhash, 32)) { + if (toBlock != null) { + logger.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); + } + filter.blockhash = fromBlockOrBlockhash; + } + else { + filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0); + filter.toBlock = ((toBlock != null) ? toBlock : "latest"); + } + return this.provider.getLogs(filter).then((logs) => { + return logs.map((log) => this._wrapEvent(runningEvent, log, null)); + }); + } + on(event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, false); + return this; + } + once(event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, true); + return this; + } + emit(eventName, ...args) { + if (!this.provider) { + return false; + } + let runningEvent = this._getRunningEvent(eventName); + let result = (runningEvent.run(args) > 0); + // May have drained all the "once" events; check for living events + this._checkRunningEvents(runningEvent); + return result; + } + listenerCount(eventName) { + if (!this.provider) { + return 0; + } + return this._getRunningEvent(eventName).listenerCount(); + } + listeners(eventName) { + if (!this.provider) { + return []; + } + if (eventName == null) { + let result = []; + for (let tag in this._runningEvents) { + this._runningEvents[tag].listeners().forEach((listener) => { + result.push(listener); + }); + } + return result; + } + return this._getRunningEvent(eventName).listeners(); + } + removeAllListeners(eventName) { + if (!this.provider) { + return this; + } + if (eventName == null) { + for (let tag in this._runningEvents) { + let runningEvent = this._runningEvents[tag]; + runningEvent.removeAllListeners(); + this._checkRunningEvents(runningEvent); + } + return this; + } + // Delete any listeners + let runningEvent = this._getRunningEvent(eventName); + runningEvent.removeAllListeners(); + this._checkRunningEvents(runningEvent); + return this; + } + off(eventName, listener) { + if (!this.provider) { + return this; + } + let runningEvent = this._getRunningEvent(eventName); + runningEvent.removeListener(listener); + this._checkRunningEvents(runningEvent); + return this; + } + removeListener(eventName, listener) { + return this.off(eventName, listener); + } +} +export class ContractFactory { + constructor(contractInterface, bytecode, signer) { + let bytecodeHex = null; + if (typeof (bytecode) === "string") { + bytecodeHex = bytecode; + } + else if (isBytes(bytecode)) { + bytecodeHex = hexlify(bytecode); + } + else if (bytecode && typeof (bytecode.object) === "string") { + // Allow the bytecode object from the Solidity compiler + bytecodeHex = bytecode.object; + } + else { + // Crash in the next verification step + bytecodeHex = "!"; + } + // Make sure it is 0x prefixed + if (bytecodeHex.substring(0, 2) !== "0x") { + bytecodeHex = "0x" + bytecodeHex; + } + // Make sure the final result is valid bytecode + if (!isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { + logger.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + // If we have a signer, make sure it is valid + if (signer && !Signer.isSigner(signer)) { + logger.throwArgumentError("invalid signer", "signer", signer); + } + defineReadOnly(this, "bytecode", bytecodeHex); + defineReadOnly(this, "interface", getStatic((new.target), "getInterface")(contractInterface)); + defineReadOnly(this, "signer", signer || null); + } + getDeployTransaction(...args) { + let tx = {}; + // If we have 1 additional argument, we allow transaction overrides + if (args.length === this.interface.deploy.inputs.length + 1) { + tx = shallowCopy(args.pop()); + for (let key in tx) { + if (!allowedTransactionKeys[key]) { + throw new Error("unknown transaction override " + key); + } + } + } + // Do not allow these to be overridden in a deployment transaction + ["data", "from", "to"].forEach((key) => { + if (tx[key] == null) { + return; + } + logger.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + // Make sure the call matches the constructor signature + logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + // Set the data to the bytecode + the encoded constructor arguments + tx.data = hexlify(concat([ + this.bytecode, + this.interface.encodeDeploy(args) + ])); + return tx; + } + deploy(...args) { + return resolveAddresses(this.signer, args, this.interface.deploy.inputs).then((args) => { + // Get the deployment transaction (with optional overrides) + let tx = this.getDeployTransaction(...args); + // Send the deployment transaction + return this.signer.sendTransaction(tx).then((tx) => { + let address = (this.constructor).getContractAddress(tx); + let contract = (this.constructor).getContract(address, this.interface, this.signer); + defineReadOnly(contract, "deployTransaction", tx); + return contract; + }); + }); + } + attach(address) { + return (this.constructor).getContract(address, this.interface, this.signer); + } + connect(signer) { + return new (this.constructor)(this.interface, this.bytecode, signer); + } + static fromSolidity(compilerOutput, signer) { + if (compilerOutput == null) { + logger.throwError("missing compiler output", Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + } + if (typeof (compilerOutput) === "string") { + compilerOutput = JSON.parse(compilerOutput); + } + let abi = compilerOutput.abi; + let bytecode = null; + if (compilerOutput.bytecode) { + bytecode = compilerOutput.bytecode; + } + else if (compilerOutput.evm && compilerOutput.evm.bytecode) { + bytecode = compilerOutput.evm.bytecode; + } + return new this(abi, bytecode, signer); + } + static getInterface(contractInterface) { + return Contract.getInterface(contractInterface); + } + static getContractAddress(tx) { + return getContractAddress(tx); + } + static getContract(address, contractInterface, signer) { + return new Contract(address, contractInterface, signer); + } +} diff --git a/packages/contracts/lib/_version.d.ts b/packages/contracts/lib/_version.d.ts new file mode 100644 index 000000000..078d9ca46 --- /dev/null +++ b/packages/contracts/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "contracts/5.0.0-beta.136"; diff --git a/packages/contracts/_version.js b/packages/contracts/lib/_version.js similarity index 100% rename from packages/contracts/_version.js rename to packages/contracts/lib/_version.js diff --git a/packages/contracts/lib/index.d.ts b/packages/contracts/lib/index.d.ts new file mode 100644 index 000000000..d39301f2e --- /dev/null +++ b/packages/contracts/lib/index.d.ts @@ -0,0 +1,119 @@ +import { Fragment, Indexed, Interface, JsonFragment } from "@ethersproject/abi"; +import { Block, BlockTag, Listener, Log, Provider, TransactionReceipt, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { BytesLike } from "@ethersproject/bytes"; +import { UnsignedTransaction } from "@ethersproject/transactions"; +export interface Overrides { + gasLimit?: BigNumberish | Promise; + gasPrice?: BigNumberish | Promise; + nonce?: BigNumberish | Promise; +} +export interface PayableOverrides extends Overrides { + value?: BigNumberish | Promise; +} +export interface CallOverrides extends PayableOverrides { + blockTag?: BlockTag | Promise; + from?: string | Promise; +} +export declare type ContractFunction = (...params: Array) => Promise; +export declare type EventFilter = { + address?: string; + topics?: Array; +}; +export interface Event extends Log { + event?: string; + eventSignature?: string; + values?: Array; + decode?: (data: string, topics?: Array) => any; + removeListener: () => void; + getBlock: () => Promise; + getTransaction: () => Promise; + getTransactionReceipt: () => Promise; +} +export interface ContractReceipt extends TransactionReceipt { + events?: Array; +} +export interface ContractTransaction extends TransactionResponse { + wait(confirmations?: number): Promise; +} +interface Bucket { + [name: string]: T; +} +declare class RunningEvent { + readonly tag: string; + readonly filter: EventFilter; + private _listeners; + constructor(tag: string, filter: EventFilter); + addListener(listener: Listener, once: boolean): void; + removeListener(listener: Listener): void; + removeAllListeners(): void; + listeners(): Array; + listenerCount(): number; + run(args: Array): number; + prepareEvent(event: Event): void; +} +export declare type ContractInterface = string | Array | Interface; +export declare class Contract { + readonly address: string; + readonly interface: Interface; + readonly signer: Signer; + readonly provider: Provider; + readonly functions: Bucket; + readonly callStatic: Bucket; + readonly estimate: Bucket<(...params: Array) => Promise>; + readonly populateTransaction: Bucket<(...params: Array) => Promise>; + readonly filters: Bucket<(...params: Array) => EventFilter>; + readonly [name: string]: ContractFunction | any; + readonly addressPromise: Promise; + readonly deployTransaction: TransactionResponse; + private _deployedPromise; + private _runningEvents; + private _wrappedEmits; + constructor(addressOrName: string, contractInterface: ContractInterface, signerOrProvider: Signer | Provider); + static getContractAddress(transaction: { + from: string; + nonce: BigNumberish; + }): string; + static getInterface(contractInterface: ContractInterface): Interface; + deployed(): Promise; + _deployed(blockTag?: BlockTag): Promise; + fallback(overrides?: TransactionRequest): Promise; + connect(signerOrProvider: Signer | Provider | string): Contract; + attach(addressOrName: string): Contract; + static isIndexed(value: any): value is Indexed; + private _normalizeRunningEvent; + private _getRunningEvent; + _checkRunningEvents(runningEvent: RunningEvent): void; + private _wrapEvent; + private _addEventListener; + queryFilter(event: EventFilter, fromBlockOrBlockhash?: BlockTag | string, toBlock?: BlockTag): Promise>; + on(event: EventFilter | string, listener: Listener): this; + once(event: EventFilter | string, listener: Listener): this; + emit(eventName: EventFilter | string, ...args: Array): boolean; + listenerCount(eventName?: EventFilter | string): number; + listeners(eventName?: EventFilter | string): Array; + removeAllListeners(eventName?: EventFilter | string): this; + off(eventName: EventFilter | string, listener: Listener): this; + removeListener(eventName: EventFilter | string, listener: Listener): this; +} +export declare class ContractFactory { + readonly interface: Interface; + readonly bytecode: string; + readonly signer: Signer; + constructor(contractInterface: ContractInterface, bytecode: BytesLike | { + object: string; + }, signer?: Signer); + getDeployTransaction(...args: Array): UnsignedTransaction; + deploy(...args: Array): Promise; + attach(address: string): Contract; + connect(signer: Signer): ContractFactory; + static fromSolidity(compilerOutput: any, signer?: Signer): ContractFactory; + static getInterface(contractInterface: ContractInterface): Interface; + static getContractAddress(tx: { + from: string; + nonce: BytesLike | BigNumber | number; + }): string; + static getContract(address: string, contractInterface: ContractInterface, signer?: Signer): Contract; +} +export {}; diff --git a/packages/contracts/index.js b/packages/contracts/lib/index.js similarity index 100% rename from packages/contracts/index.js rename to packages/contracts/lib/index.js diff --git a/packages/contracts/package.json b/packages/contracts/package.json index f899f02f0..b9e5d0271 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/contracts", - "version": "5.0.0-beta.136", + "version": "5.0.0-beta.137", "description": "Contract abstraction meta-class for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -31,5 +31,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x28d79f65ed2ec24904f9c7e7d5960e8df2d4e85130b445e08979ad3103334d4b" + "module": "./lib.esm/index.js", + "tarballHash": "0x2b3d95a50f2ca8c9bfc0537b3ba0709961462384296311ea188b3b96e3f58b83" } diff --git a/packages/contracts/tsconfig.json b/packages/contracts/tsconfig.json index 969328db8..92930025f 100644 --- a/packages/contracts/tsconfig.json +++ b/packages/contracts/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts" + "./src.ts/*.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/errors/_version.d.ts b/packages/errors/lib.esm/_version.d.ts similarity index 100% rename from packages/errors/_version.d.ts rename to packages/errors/lib.esm/_version.d.ts diff --git a/packages/errors/lib.esm/_version.js b/packages/errors/lib.esm/_version.js new file mode 100644 index 000000000..326385a20 --- /dev/null +++ b/packages/errors/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "errors/5.0.0-beta.128"; diff --git a/packages/errors/index.d.ts b/packages/errors/lib.esm/index.d.ts similarity index 100% rename from packages/errors/index.d.ts rename to packages/errors/lib.esm/index.d.ts diff --git a/packages/errors/lib.esm/index.js b/packages/errors/lib.esm/index.js new file mode 100644 index 000000000..6e66cd029 --- /dev/null +++ b/packages/errors/lib.esm/index.js @@ -0,0 +1,245 @@ +"use strict"; +//import { version } from "./_version"; +const version = "@TODO"; +/////////////////// +// Generic Errors +// Unknown Error +export const UNKNOWN_ERROR = "UNKNOWN_ERROR"; +// Not Implemented +export const NOT_IMPLEMENTED = "NOT_IMPLEMENTED"; +// Unsupported Operation +// - operation +export const UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION"; +// Network Error (i.e. Ethereum Network, such as an invalid chain ID) +export const NETWORK_ERROR = "NETWORK_ERROR"; +// Some sort of bad response from the server +export const SERVER_ERROR = "SERVER_ERROR"; +// Timeout +export const TIMEOUT = "TIMEOUT"; +/////////////////// +// Operational Errors +// Buffer Overrun +export const BUFFER_OVERRUN = "BUFFER_OVERRUN"; +// Numeric Fault +// - operation: the operation being executed +// - fault: the reason this faulted +export const NUMERIC_FAULT = "NUMERIC_FAULT"; +/////////////////// +// Argument Errors +// Missing new operator to an object +// - name: The name of the class +export const MISSING_NEW = "MISSING_NEW"; +// Invalid argument (e.g. value is incompatible with type) to a function: +// - argument: The argument name that was invalid +// - value: The value of the argument +export const INVALID_ARGUMENT = "INVALID_ARGUMENT"; +// Missing argument to a function: +// - count: The number of arguments received +// - expectedCount: The number of arguments expected +export const MISSING_ARGUMENT = "MISSING_ARGUMENT"; +// Too many arguments +// - count: The number of arguments received +// - expectedCount: The number of arguments expected +export const UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT"; +/////////////////// +// Blockchain Errors +// Call exception +// - transaction: the transaction +// - address?: the contract address +// - args?: The arguments passed into the function +// - method?: The Solidity method signature +// - errorSignature?: The EIP848 error signature +// - errorArgs?: The EIP848 error parameters +// - reason: The reason (only for EIP848 "Error(string)") +export const CALL_EXCEPTION = "CALL_EXCEPTION"; +// Insufficien funds (< value + gasLimit * gasPrice) +// - transaction: the transaction attempted +export const INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS"; +// Nonce has already been used +// - transaction: the transaction attempted +export const NONCE_EXPIRED = "NONCE_EXPIRED"; +// The replacement fee for the transaction is too low +// - transaction: the transaction attempted +export const REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED"; +// The gas limit could not be estimated +// - transaction: the transaction passed to estimateGas +export const UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"; +//export const errors: { [ code: string ]: string } = { +//}; +/////////////////// +// Censorship +let _permanentCensorErrors = false; +let _censorErrors = false; +export function setCensorship(censorship, permanent) { + if (_permanentCensorErrors) { + throwError("error censorship permanent", UNSUPPORTED_OPERATION, { operation: "setCensorship" }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; +} +/////////////////// +// Errors +export function makeError(message, code, params) { + if (_censorErrors) { + return new Error("unknown error"); + } + if (!code) { + code = UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + let messageDetails = []; + Object.keys(params).forEach((key) => { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("version=" + version); + let reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + let error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; +} +// @TODO: Enum +export function throwError(message, code, params) { + throw makeError(message, code, params); +} +export function throwArgumentError(message, name, value) { + return throwError(message, INVALID_ARGUMENT, { + argument: name, + value: value + }); +} +/////////////////// +// Checking +export function checkArgumentCount(count, expectedCount, suffix) { + if (suffix) { + suffix = " " + suffix; + } + else { + suffix = ""; + } + if (count < expectedCount) { + throwError("missing argument" + suffix, MISSING_ARGUMENT, { count: count, expectedCount: expectedCount }); + } + if (count > expectedCount) { + throwError("too many arguments" + suffix, UNEXPECTED_ARGUMENT, { count: count, expectedCount: expectedCount }); + } +} +export function checkNew(target, kind) { + if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +/* +export function check(target: any: void { + if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +*/ +export function checkAbstract(target, kind) { + if (target === kind) { + throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +/* +export function checkTarget(target: any, kind: any): void { + if (target == null) { + throwError("missing new", MISSING_NEW, { name: kind.name }); + } +} +*/ +function _checkNormalize() { + try { + let missing = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { + try { + "test".normalize(form); + } + catch (error) { + missing.push(form); + } + }); + if (missing.length) { + throw new Error("missing " + missing.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; +} +let _normalizeError = _checkNormalize(); +export function checkNormalize() { + if (_normalizeError) { + throwError("platform missing String.prototype.normalize", UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } +} +export function checkSafeUint53(value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + throwError(message, NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + throwError(message, NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } +} +/////////////////// +// Logging +const LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; +let LogLevel = LogLevels["default"]; +export function setLogLevel(logLevel) { + let level = LogLevels[logLevel]; + if (level == null) { + warn("invliad log level - " + logLevel); + return; + } + LogLevel = level; +} +function log(logLevel, args) { + if (LogLevel > LogLevels[logLevel]) { + return; + } + console.log.apply(console, args); +} +export function warn(...args) { + log("warn", args); +} +export function info(...args) { + log("info", args); +} diff --git a/packages/errors/lib/_version.d.ts b/packages/errors/lib/_version.d.ts new file mode 100644 index 000000000..5284e3ff0 --- /dev/null +++ b/packages/errors/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "errors/5.0.0-beta.128"; diff --git a/packages/errors/_version.js b/packages/errors/lib/_version.js similarity index 100% rename from packages/errors/_version.js rename to packages/errors/lib/_version.js diff --git a/packages/errors/lib/index.d.ts b/packages/errors/lib/index.d.ts new file mode 100644 index 000000000..1890f1255 --- /dev/null +++ b/packages/errors/lib/index.d.ts @@ -0,0 +1,29 @@ +export declare const UNKNOWN_ERROR = "UNKNOWN_ERROR"; +export declare const NOT_IMPLEMENTED = "NOT_IMPLEMENTED"; +export declare const UNSUPPORTED_OPERATION = "UNSUPPORTED_OPERATION"; +export declare const NETWORK_ERROR = "NETWORK_ERROR"; +export declare const SERVER_ERROR = "SERVER_ERROR"; +export declare const TIMEOUT = "TIMEOUT"; +export declare const BUFFER_OVERRUN = "BUFFER_OVERRUN"; +export declare const NUMERIC_FAULT = "NUMERIC_FAULT"; +export declare const MISSING_NEW = "MISSING_NEW"; +export declare const INVALID_ARGUMENT = "INVALID_ARGUMENT"; +export declare const MISSING_ARGUMENT = "MISSING_ARGUMENT"; +export declare const UNEXPECTED_ARGUMENT = "UNEXPECTED_ARGUMENT"; +export declare const CALL_EXCEPTION = "CALL_EXCEPTION"; +export declare const INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS"; +export declare const NONCE_EXPIRED = "NONCE_EXPIRED"; +export declare const REPLACEMENT_UNDERPRICED = "REPLACEMENT_UNDERPRICED"; +export declare const UNPREDICTABLE_GAS_LIMIT = "UNPREDICTABLE_GAS_LIMIT"; +export declare function setCensorship(censorship: boolean, permanent?: boolean): void; +export declare function makeError(message: string, code: string, params: any): Error; +export declare function throwError(message: string, code: string, params: any): never; +export declare function throwArgumentError(message: string, name: string, value: any): never; +export declare function checkArgumentCount(count: number, expectedCount: number, suffix?: string): void; +export declare function checkNew(target: any, kind: any): void; +export declare function checkAbstract(target: any, kind: any): void; +export declare function checkNormalize(): void; +export declare function checkSafeUint53(value: number, message?: string): void; +export declare function setLogLevel(logLevel: string): void; +export declare function warn(...args: Array): void; +export declare function info(...args: Array): void; diff --git a/packages/errors/index.js b/packages/errors/lib/index.js similarity index 100% rename from packages/errors/index.js rename to packages/errors/lib/index.js diff --git a/packages/errors/package.json b/packages/errors/package.json index e73e85056..0a9026047 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/errors", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Error utility functions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -19,5 +19,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x53e437565080eff824d332689a72ee12b1794b71f15b783a2951378db03cb9ff" + "module": "./lib.esm/index.js", + "tarballHash": "0x38cdacb3663d11ec01cd55e8b13e4d77c8aa5b754dbaa9424bb4bb3de18071db" } diff --git a/packages/errors/tsconfig.json b/packages/errors/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/errors/tsconfig.json +++ b/packages/errors/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/ethers/dist/ethers.esm.js b/packages/ethers/dist/ethers.esm.js new file mode 100644 index 000000000..708d99563 --- /dev/null +++ b/packages/ethers/dist/ethers.esm.js @@ -0,0 +1,19283 @@ +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs'); +} + +function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +function getCjsExportFromNamespace (n) { + return n && n['default'] || n; +} + +var _nodeResolve_empty = {}; + +var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({ + 'default': _nodeResolve_empty +}); + +var require$$0 = getCjsExportFromNamespace(_nodeResolve_empty$1); + +var bn = createCommonjsModule(function (module) { +(function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + Buffer = require$$0.Buffer; + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + } + + if (base === 16) { + this._parseHex(number, start); + } else { + this._parseBase(number, base, start); + } + + if (number[0] === '-') { + this.negative = 1; + } + + this.strip(); + + if (endian !== 'le') return; + + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; + + function parseHex (str, start, end) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r <<= 4; + + // 'a' - 'f' + if (c >= 49 && c <= 54) { + r |= c - 49 + 0xa; + + // 'A' - 'F' + } else if (c >= 17 && c <= 22) { + r |= c - 17 + 0xa; + + // '0' - '9' + } else { + r |= c & 0xf; + } + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + // Scan 24-bit chunks and add them to the number + var off = 0; + for (i = number.length - 6, j = 0; i >= start; i -= 6) { + w = parseHex(number, i, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + if (i + 6 !== start) { + w = parseHex(number, start, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } + this.strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; + + // '0' - '9' + } else { + r += c; + } + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + BN.prototype.inspect = function inspect () { + return (this.red ? ''; + }; + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; + + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); + + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } + + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[i] = b; + } + + for (; i < reqLength; i++) { + res[i] = 0; + } + } + + return res; + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this.strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this.strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this.strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this.strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this.strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this.strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out.strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out.strip(); + } + + function jumboMulTo (self, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out.strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this.strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this.strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this.strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) < num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this.strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this.strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this.strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q.strip(); + } + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modn = function modn (num) { + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return acc; + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + return this.strip(); + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this.strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + r.strip(); + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; +})('object' === 'undefined' || module, commonjsGlobal); +}); +var bn_1 = bn.BN; + +const version = "logger/5.0.0-beta.129"; + +"use strict"; +let _permanentCensorErrors = false; +let _censorErrors = false; +const LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; +let LogLevel = LogLevels["default"]; +let _globalLogger = null; +function _checkNormalize() { + try { + let missing = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { + try { + if ("test".normalize(form) !== "test") { + throw new Error("bad normalize"); + } + ; + } + catch (error) { + missing.push(form); + } + }); + if (missing.length) { + throw new Error("missing " + missing.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; +} +let _normalizeError = _checkNormalize(); +class Logger { + constructor(version) { + Object.defineProperty(this, "version", { + enumerable: true, + value: version, + writable: false + }); + } + setLogLevel(logLevel) { + let level = LogLevels[logLevel]; + if (level == null) { + this.warn("invliad log level - " + logLevel); + return; + } + LogLevel = level; + } + _log(logLevel, args) { + if (LogLevel > LogLevels[logLevel]) { + return; + } + console.log.apply(console, args); + } + debug(...args) { + this._log(Logger.levels.DEBUG, args); + } + info(...args) { + this._log(Logger.levels.INFO, args); + } + warn(...args) { + this._log(Logger.levels.WARNING, args); + } + makeError(message, code, params) { + if (_censorErrors) { + return new Error("unknown error"); + } + if (!code) { + code = Logger.errors.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + let messageDetails = []; + Object.keys(params).forEach((key) => { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("version=" + this.version); + let reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + let error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; + } + throwError(message, code, params) { + throw this.makeError(message, code, params); + } + throwArgumentError(message, name, value) { + return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { + argument: name, + value: value + }); + } + checkNormalize(message) { + if (message == null) { + message = "platform missing String.prototype.normalize"; + } + if (_normalizeError) { + this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } + } + checkSafeUint53(value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } + } + checkArgumentCount(count, expectedCount, message) { + if (message) { + message = ": " + message; + } + else { + message = ""; + } + if (count < expectedCount) { + this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + if (count > expectedCount) { + this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + } + checkNew(target, kind) { + if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + } + checkAbstract(target, kind) { + if (target === kind) { + this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + } + static globalLogger() { + if (!_globalLogger) { + _globalLogger = new Logger(version); + } + return _globalLogger; + } + static setCensorship(censorship, permanent) { + if (_permanentCensorErrors) { + if (!censorship) { + return; + } + this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; + } +} +Logger.errors = { + /////////////////// + // Generic Errors + // Unknown Error + UNKNOWN_ERROR: "UNKNOWN_ERROR", + // Not Implemented + NOT_IMPLEMENTED: "NOT_IMPLEMENTED", + // Unsupported Operation + // - operation + UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION", + // Network Error (i.e. Ethereum Network, such as an invalid chain ID) + NETWORK_ERROR: "NETWORK_ERROR", + // Some sort of bad response from the server + SERVER_ERROR: "SERVER_ERROR", + // Timeout + TIMEOUT: "TIMEOUT", + /////////////////// + // Operational Errors + // Buffer Overrun + BUFFER_OVERRUN: "BUFFER_OVERRUN", + // Numeric Fault + // - operation: the operation being executed + // - fault: the reason this faulted + NUMERIC_FAULT: "NUMERIC_FAULT", + /////////////////// + // Argument Errors + // Missing new operator to an object + // - name: The name of the class + MISSING_NEW: "MISSING_NEW", + // Invalid argument (e.g. value is incompatible with type) to a function: + // - argument: The argument name that was invalid + // - value: The value of the argument + INVALID_ARGUMENT: "INVALID_ARGUMENT", + // Missing argument to a function: + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + MISSING_ARGUMENT: "MISSING_ARGUMENT", + // Too many arguments + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + UNEXPECTED_ARGUMENT: "UNEXPECTED_ARGUMENT", + /////////////////// + // Blockchain Errors + // Call exception + // - transaction: the transaction + // - address?: the contract address + // - args?: The arguments passed into the function + // - method?: The Solidity method signature + // - errorSignature?: The EIP848 error signature + // - errorArgs?: The EIP848 error parameters + // - reason: The reason (only for EIP848 "Error(string)") + CALL_EXCEPTION: "CALL_EXCEPTION", + // Insufficien funds (< value + gasLimit * gasPrice) + // - transaction: the transaction attempted + INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS", + // Nonce has already been used + // - transaction: the transaction attempted + NONCE_EXPIRED: "NONCE_EXPIRED", + // The replacement fee for the transaction is too low + // - transaction: the transaction attempted + REPLACEMENT_UNDERPRICED: "REPLACEMENT_UNDERPRICED", + // The gas limit could not be estimated + // - transaction: the transaction passed to estimateGas + UNPREDICTABLE_GAS_LIMIT: "UNPREDICTABLE_GAS_LIMIT", +}; +Logger.levels = { + DEBUG: "DEBUG", + INFO: "INFO", + WARNING: "WARNING", + ERROR: "ERROR", + OFF: "OFF" +}; + +var module = /*#__PURE__*/Object.freeze({ + Logger: Logger +}); + +const version$1 = "bytes/5.0.0-beta.129"; + +"use strict"; +const logger = new Logger(version$1); +/////////////////////////////// +function isHexable(value) { + return !!(value.toHexString); +} +function addSlice(array) { + if (array.slice) { + return array; + } + array.slice = function () { + let args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + }; + return array; +} +function isBytesLike(value) { + return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); +} +function isBytes(value) { + if (value == null) { + return false; + } + if (value.constructor === Uint8Array) { + return true; + } + if (typeof (value) === "string") { + return false; + } + if (value.length == null) { + return false; + } + for (let i = 0; i < value.length; i++) { + let v = value[i]; + if (v < 0 || v >= 256 || (v % 1)) { + return false; + } + } + return true; +} +function arrayify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger.checkSafeUint53(value, "invalid arrayify value"); + let result = []; + while (value) { + result.unshift(value & 0xff); + value /= 256; + } + if (result.length === 0) { + result.push(0); + } + return addSlice(new Uint8Array(result)); + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + value = value.toHexString(); + } + if (isHexString(value)) { + let hex = value.substring(2); + if (!options.allowOddLength && hex.length % 2) { + logger.throwArgumentError("hex data is odd-length", "value", value); + } + let result = []; + for (let i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + return addSlice(new Uint8Array(result)); + } + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + return logger.throwArgumentError("invalid arrayify value", "value", value); +} +function concat(items) { + let objects = items.map(item => arrayify(item)); + let length = objects.reduce((accum, item) => (accum + item.length), 0); + let result = new Uint8Array(length); + objects.reduce((offset, object) => { + result.set(object, offset); + return offset + object.length; + }, 0); + return addSlice(result); +} +function stripZeros(value) { + let result = arrayify(value); + if (result.length === 0) { + return result; + } + // Find the first non-zero entry + let start = 0; + while (start < result.length && result[start] === 0) { + start++; + } + // If we started with zeros, strip them + if (start) { + result = result.slice(start); + } + return result; +} +function zeroPad(value, length) { + value = arrayify(value); + if (value.length > length) { + logger.throwArgumentError("value out of range", "value", arguments[0]); + } + let result = new Uint8Array(length); + result.set(value, length - value.length); + return addSlice(result); +} +function isHexString(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (length && value.length !== 2 + 2 * length) { + return false; + } + return true; +} +const HexCharacters = "0123456789abcdef"; +function hexlify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger.checkSafeUint53(value, "invalid hexlify value"); + let hex = ""; + while (value) { + hex = HexCharacters[value & 0x0f] + hex; + value = Math.floor(value / 16); + } + if (hex.length) { + if (hex.length % 2) { + hex = "0" + hex; + } + return "0x" + hex; + } + return "0x00"; + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + return value.toHexString(); + } + if (isHexString(value)) { + if (!options.allowOddLength && value.length % 2) { + logger.throwArgumentError("hex data is odd-length", "value", value); + } + return value.toLowerCase(); + } + if (isBytes(value)) { + let result = "0x"; + for (let i = 0; i < value.length; i++) { + let v = value[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; + } + return logger.throwArgumentError("invalid hexlify value", "value", value); +} +/* +function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { + if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { + return "0x0" + value.substring(2); + } + return value; +} +*/ +function hexDataLength(data) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + return null; + } + return (data.length - 2) / 2; +} +function hexDataSlice(data, offset, endOffset) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + logger.throwArgumentError("invalid hexData", "value", data); + } + offset = 2 + 2 * offset; + if (endOffset != null) { + return "0x" + data.substring(offset, 2 + 2 * endOffset); + } + return "0x" + data.substring(offset); +} +function hexConcat(items) { + let result = "0x"; + items.forEach((item) => { + result += hexlify(item).substring(2); + }); + return result; +} +function hexValue(value) { + let trimmed = hexStripZeros(hexlify(value, { allowOddLength: true })); + if (trimmed === "0x") { + return "0x0"; + } + return trimmed; +} +function hexStripZeros(value) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + if (!isHexString(value)) { + logger.throwArgumentError("invalid hex string", "value", value); + } + value = value.substring(2); + let offset = 0; + while (offset < value.length && value[offset] === "0") { + offset++; + } + return "0x" + value.substring(offset); +} +function hexZeroPad(value, length) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + else if (!isHexString(value)) { + logger.throwArgumentError("invalid hex string", "value", value); + } + if (value.length > 2 * length + 2) { + logger.throwArgumentError("value out of range", "value", arguments[1]); + } + while (value.length < 2 * length + 2) { + value = "0x0" + value.substring(2); + } + return value; +} +function splitSignature(signature) { + let result = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0 + }; + if (isBytesLike(signature)) { + let bytes = arrayify(signature); + if (bytes.length !== 65) { + logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + } + // Get the r and s + result.r = hexlify(bytes.slice(0, 32)); + result.s = hexlify(bytes.slice(32, 64)); + // Reduce v to the canonical 27 or 28 + result.v = bytes[64]; + if (result.v !== 27 && result.v !== 28) { + result.v = 27 + (result.v % 2); + } + // Compute recoveryParam from v + result.recoveryParam = (result.v - 27); + // Compute _vs from recoveryParam and s + if (result.recoveryParam) { + bytes[32] |= 0x80; + } + result._vs = hexlify(bytes.slice(32, 64)); + } + else { + result.r = signature.r; + result.s = signature.s; + result.v = signature.v; + result.recoveryParam = signature.recoveryParam; + result._vs = signature._vs; + // Normalize v into a canonical 27 or 28 + if (result.v != null && !(result.v == 27 || result.v == 28)) { + result.v = 27 + (result.v % 2); + } + // Populate a missing v or recoveryParam if possible + if (result.recoveryParam == null && result.v != null) { + result.recoveryParam = 1 - (result.v % 2); + } + else if (result.recoveryParam != null && result.v == null) { + result.v = 27 + result.recoveryParam; + } + else if (result.recoveryParam != null && result.v != null) { + if (result.v !== 27 + result.recoveryParam) { + logger.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); + } + } + // Make sure r and s are padded properly + if (result.r != null) { + result.r = hexZeroPad(result.r, 32); + } + if (result.s != null) { + result.s = hexZeroPad(result.s, 32); + } + // If the _vs is available, use it to populate missing s, v and recoveryParam + // and verify non-missing s, v and recoveryParam + if (result._vs != null) { + result._vs = hexZeroPad(result._vs, 32); + if (result._vs.length > 66) { + logger.throwArgumentError("signature _vs overflow", "signature", signature); + } + let vs = arrayify(result._vs); + let recoveryParam = ((vs[0] >= 128) ? 1 : 0); + let v = 27 + result.recoveryParam; + // Use _vs to compute s + vs[0] &= 0x7f; + let s = hexlify(vs); + // Check _vs aggress with other parameters + if (result.s == null) { + result.s = s; + } + else if (result.s !== s) { + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (result.v == null) { + result.v = v; + } + else if (result.v !== v) { + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (recoveryParam == null) { + result.recoveryParam = recoveryParam; + } + else if (result.recoveryParam !== recoveryParam) { + logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + } + } + // After all populating, both v and recoveryParam are still missing... + if (result.v == null && result.recoveryParam == null) { + logger.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); + } + // Check for canonical v + if (result.v !== 27 && result.v !== 28) { + logger.throwArgumentError("signature v not canonical", "signature", signature); + } + // Check that r and s are in range + if (result.r.length > 66 || result.s.length > 66) { + logger.throwArgumentError("signature overflow r or s", "signature", signature); + } + if (result._vs == null) { + let vs = arrayify(result.s); + if (vs[0] >= 128) { + logger.throwArgumentError("signature s out of range", "signature", signature); + } + if (result.recoveryParam) { + vs[0] |= 0x80; + } + result._vs = hexlify(vs); + } + } + return result; +} +function joinSignature(signature) { + signature = splitSignature(signature); + return hexlify(concat([ + signature.r, + signature.s, + (signature.recoveryParam ? "0x1c" : "0x1b") + ])); +} + +var module$1 = /*#__PURE__*/Object.freeze({ + isBytesLike: isBytesLike, + isBytes: isBytes, + arrayify: arrayify, + concat: concat, + stripZeros: stripZeros, + zeroPad: zeroPad, + isHexString: isHexString, + hexlify: hexlify, + hexDataLength: hexDataLength, + hexDataSlice: hexDataSlice, + hexConcat: hexConcat, + hexValue: hexValue, + hexStripZeros: hexStripZeros, + hexZeroPad: hexZeroPad, + splitSignature: splitSignature, + joinSignature: joinSignature +}); + +const version$2 = "bignumber/5.0.0-beta.130"; + +"use strict"; +const logger$1 = new Logger(version$2); +const _constructorGuard = {}; +const MAX_SAFE = 0x1fffffffffffff; +function isBigNumberish(value) { + return (value != null) && (BigNumber.isBigNumber(value) || + (typeof (value) === "number" && (value % 1) === 0) || + (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || + isHexString(value) || + (typeof (value) === "bigint") || + isBytes(value)); +} +class BigNumber { + constructor(constructorGuard, hex) { + logger$1.checkNew(new.target, BigNumber); + if (constructorGuard !== _constructorGuard) { + logger$1.throwError("cannot call consturtor directly; use BigNumber.from", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); + } + this._hex = hex; + this._isBigNumber = true; + Object.freeze(this); + } + fromTwos(value) { + return toBigNumber(toBN(this).fromTwos(value)); + } + toTwos(value) { + return toBigNumber(toBN(this).toTwos(value)); + } + abs() { + if (this._hex[0] === "-") { + return BigNumber.from(this._hex.substring(1)); + } + return this; + } + add(other) { + return toBigNumber(toBN(this).add(toBN(other))); + } + sub(other) { + return toBigNumber(toBN(this).sub(toBN(other))); + } + div(other) { + let o = BigNumber.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + } + mul(other) { + return toBigNumber(toBN(this).mul(toBN(other))); + } + mod(other) { + return toBigNumber(toBN(this).mod(toBN(other))); + } + pow(other) { + return toBigNumber(toBN(this).pow(toBN(other))); + } + maskn(value) { + return toBigNumber(toBN(this).maskn(value)); + } + eq(other) { + return toBN(this).eq(toBN(other)); + } + lt(other) { + return toBN(this).lt(toBN(other)); + } + lte(other) { + return toBN(this).lte(toBN(other)); + } + gt(other) { + return toBN(this).gt(toBN(other)); + } + gte(other) { + return toBN(this).gte(toBN(other)); + } + isZero() { + return toBN(this).isZero(); + } + toNumber() { + try { + return toBN(this).toNumber(); + } + catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + } + toString() { + // Lots of people expect this, which we do not support, so check + if (arguments.length !== 0) { + logger$1.throwError("bigNumber.toString does not accept parameters", Logger.errors.UNEXPECTED_ARGUMENT, {}); + } + return toBN(this).toString(10); + } + toHexString() { + return this._hex; + } + static from(value) { + if (value instanceof BigNumber) { + return value; + } + if (typeof (value) === "string") { + if (value.match(/-?0x[0-9a-f]+/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new bn_1(value))); + } + return logger$1.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof (value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + return BigNumber.from(String(value)); + } + if (typeof (value) === "bigint") { + return BigNumber.from(value.toString()); + } + if (isBytes(value)) { + return BigNumber.from(hexlify(value)); + } + if (value._hex && isHexString(value._hex)) { + return BigNumber.from(value._hex); + } + if (value.toHexString) { + value = value.toHexString(); + if (typeof (value) === "string") { + return BigNumber.from(value); + } + } + return logger$1.throwArgumentError("invalid BigNumber value", "value", value); + } + static isBigNumber(value) { + return !!(value && value._isBigNumber); + } +} +// Normalize the hex string +function toHex(value) { + // For BN, call on the hex string + if (typeof (value) !== "string") { + return toHex(value.toString(16)); + } + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { + logger$1.throwArgumentError("invalid hex", "value", value); + } + // Call toHex on the positive component + value = toHex(value); + // Do not allow "-0x00" + if (value === "0x00") { + return value; + } + // Negate the value + return "-" + value; + } + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + // Normalize zero + if (value === "0x") { + return "0x00"; + } + // Make the string even length + if (value.length % 2) { + value = "0x0" + value.substring(2); + } + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + return value; +} +function toBigNumber(value) { + return BigNumber.from(toHex(value)); +} +function toBN(value) { + let hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new bn_1("-" + hex.substring(3), 16)); + } + return new bn_1(hex.substring(2), 16); +} +function throwFault(fault, operation, value) { + let params = { fault: fault, operation: operation }; + if (value != null) { + params.value = value; + } + return logger$1.throwError(fault, Logger.errors.NUMERIC_FAULT, params); +} + +"use strict"; +const logger$2 = new Logger(version$2); +const _constructorGuard$1 = {}; +const Zero = BigNumber.from(0); +const NegativeOne = BigNumber.from(-1); +function throwFault$1(message, fault, operation, value) { + let params = { fault: fault, operation: operation }; + if (value !== undefined) { + params.value = value; + } + return logger$2.throwError(message, Logger.errors.NUMERIC_FAULT, params); +} +// Constant to pull zeros from for multipliers +let zeros = "0"; +while (zeros.length < 256) { + zeros += zeros; +} +// Returns a string "1" followed by decimal "0"s +function getMultiplier(decimals) { + if (typeof (decimals) !== "number") { + try { + decimals = BigNumber.from(decimals).toNumber(); + } + catch (e) { } + } + if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + return logger$2.throwArgumentError("invalid decimal size", "decimals", decimals); +} +function formatFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + let multiplier = getMultiplier(decimals); + // Make sure wei is a big number (convert as necessary) + value = BigNumber.from(value); + let negative = value.lt(Zero); + if (negative) { + value = value.mul(NegativeOne); + } + let fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { + fraction = "0" + fraction; + } + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + let whole = value.div(multiplier).toString(); + value = whole + "." + fraction; + if (negative) { + value = "-" + value; + } + return value; +} +function parseFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + let multiplier = getMultiplier(decimals); + if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + logger$2.throwArgumentError("invalid decimal value", "value", value); + } + if (multiplier.length - 1 === 0) { + return BigNumber.from(value); + } + // Is it negative? + let negative = (value.substring(0, 1) === "-"); + if (negative) { + value = value.substring(1); + } + if (value === ".") { + logger$2.throwArgumentError("missing value", "value", value); + } + // Split it into a whole and fractional part + let comps = value.split("."); + if (comps.length > 2) { + logger$2.throwArgumentError("too many decimal points", "value", value); + } + let whole = comps[0], fraction = comps[1]; + if (!whole) { + whole = "0"; + } + if (!fraction) { + fraction = "0"; + } + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault$1("fractional component exceeds decimals", "underflow", "parseFixed"); + } + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { + fraction += "0"; + } + let wholeValue = BigNumber.from(whole); + let fractionValue = BigNumber.from(fraction); + let wei = (wholeValue.mul(multiplier)).add(fractionValue); + if (negative) { + wei = wei.mul(NegativeOne); + } + return wei; +} +class FixedFormat { + constructor(constructorGuard, signed, width, decimals) { + this.signed = signed; + this.width = width; + this.decimals = decimals; + this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + this._multiplier = getMultiplier(decimals); + Object.freeze(this); + } + static from(value) { + if (value instanceof FixedFormat) { + return value; + } + let signed = true; + let width = 128; + let decimals = 18; + if (typeof (value) === "string") { + if (value === "fixed") { + // defaults... + } + else if (value === "ufixed") { + signed = false; + } + else if (value != null) { + let match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + logger$2.throwArgumentError("invalid fixed format", "format", value); + } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + let check = (key, type, defaultValue) => { + if (value[key] == null) { + return defaultValue; + } + if (typeof (value[key]) !== type) { + logger$2.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + logger$2.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + logger$2.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat(_constructorGuard$1, signed, width, decimals); + } +} +class FixedNumber { + constructor(constructorGuard, hex, value, format) { + logger$2.checkNew(new.target, FixedNumber); + this.format = format; + this._hex = hex; + this._value = value; + this._isFixedNumber = true; + Object.freeze(this); + } + _checkFormat(other) { + if (this.format.name !== other.format.name) { + logger$2.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + } + addUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + } + subUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + } + mulUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + } + divUnsafe(other) { + this._checkFormat(other); + let a = parseFixed(this._value, this.format.decimals); + let b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + } + // @TODO: Support other rounding algorithms + round(decimals) { + if (decimals == null) { + decimals = 0; + } + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + logger$2.throwArgumentError("invalid decimal cound", "decimals", decimals); + } + // If we are already in range, we're done + let comps = this.toString().split("."); + if (comps[1].length <= decimals) { + return this; + } + // Bump the value up by the 0.00...0005 + let bump = "0." + zeros.substring(0, decimals) + "5"; + comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); + // Now it is safe to truncate + return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); + } + toString() { return this._value; } + toHexString(width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + logger$2.throwArgumentError("invalid byte width", "width", width); + } + let hex = BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return hexZeroPad(hex, width / 8); + } + toUnsafeFloat() { return parseFloat(this.toString()); } + toFormat(format) { + return FixedNumber.fromString(this._value, format); + } + static fromValue(value, decimals, format) { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && !isBigNumberish(decimals)) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); + } + static fromString(value, format) { + if (format == null) { + format = "fixed"; + } + let fixedFormat = FixedFormat.from(format); + let numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault$1("unsigned value cannot be negative", "overflow", "value", value); + } + let hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } + else { + hex = numeric.toHexString(); + hex = hexZeroPad(hex, fixedFormat.width / 8); + } + let decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard$1, hex, decimal, fixedFormat); + } + static fromBytes(value, format) { + if (format == null) { + format = "fixed"; + } + let fixedFormat = FixedFormat.from(format); + if (arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + let numeric = BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + let hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + let decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard$1, hex, decimal, fixedFormat); + } + static from(value, format) { + if (typeof (value) === "string") { + return FixedNumber.fromString(value, format); + } + if (isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + try { + return FixedNumber.fromValue(value, 0, format); + } + catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== Logger.errors.INVALID_ARGUMENT) { + throw error; + } + } + return logger$2.throwArgumentError("invalid FixedNumber value", "value", value); + } + static isFixedNumber(value) { + return !!(value && value._isFixedNumber); + } +} + +const version$3 = "properties/5.0.0-beta.131"; + +"use strict"; +const logger$3 = new Logger(version$3); +function defineReadOnly(object, name, value) { + Object.defineProperty(object, name, { + enumerable: true, + value: value, + writable: false, + }); +} +// Crawl up the constructor chain to find a static method +function getStatic(ctor, key) { + for (let i = 0; i < 32; i++) { + if (ctor[key]) { + return ctor[key]; + } + if (!ctor.prototype || typeof (ctor.prototype) !== "object") { + break; + } + ctor = Object.getPrototypeOf(ctor.prototype).constructor; + } + return null; +} +function resolveProperties(object) { + let promises = Object.keys(object).map((key) => { + let value = object[key]; + if (!(value instanceof Promise)) { + return Promise.resolve({ key: key, value: value }); + } + return value.then((value) => { + return { key: key, value: value }; + }); + }); + return Promise.all(promises).then((results) => { + let result = {}; + return results.reduce((accum, result) => { + accum[result.key] = result.value; + return accum; + }, result); + }); +} +function checkProperties(object, properties) { + if (!object || typeof (object) !== "object") { + logger$3.throwArgumentError("invalid object", "object", object); + } + Object.keys(object).forEach((key) => { + if (!properties[key]) { + logger$3.throwArgumentError("invalid object key - " + key, "transaction:" + key, object); + } + }); +} +function shallowCopy(object) { + let result = {}; + for (let key in object) { + result[key] = object[key]; + } + return result; +} +let opaque = { bigint: true, boolean: true, number: true, string: true }; +// Returns a new copy of object, such that no properties may be replaced. +// New properties may be added only to objects. +function deepCopy(object) { + // Opaque objects are not mutable, so safe to copy by assignment + if (object === undefined || object === null || opaque[typeof (object)]) { + return object; + } + // Arrays are mutable, so we need to create a copy + if (Array.isArray(object)) { + return Object.freeze(object.map((item) => deepCopy(item))); + } + if (typeof (object) === "object") { + // Immutable objects are safe to just use + if (Object.isFrozen(object)) { + return object; + } + let result = {}; + for (let key in object) { + let value = object[key]; + if (value === undefined) { + continue; + } + defineReadOnly(result, key, deepCopy(value)); + } + return result; + } + // The function type is also immutable, so safe to copy by assignment + if (typeof (object) === "function") { + return object; + } + throw new Error("Cannot deepCopy " + typeof (object)); +} +class Description { + constructor(info) { + for (let key in info) { + this[key] = deepCopy(info[key]); + } + Object.freeze(this); + } +} + +var module$2 = /*#__PURE__*/Object.freeze({ + defineReadOnly: defineReadOnly, + getStatic: getStatic, + resolveProperties: resolveProperties, + checkProperties: checkProperties, + shallowCopy: shallowCopy, + deepCopy: deepCopy, + Description: Description +}); + +const version$4 = "abi/5.0.0-beta.137"; + +"use strict"; +const logger$4 = new Logger(version$4); +; +const _constructorGuard$2 = {}; +let ModifiersBytes = { calldata: true, memory: true, storage: true }; +function checkModifier(type, name) { + if (type === "bytes" || type === "string") { + if (ModifiersBytes[name]) { + return true; + } + } + else if (type === "address") { + if (name === "payable") { + return true; + } + } + if (ModifiersBytes[name] || name === "payable") { + logger$4.throwArgumentError("invalid modifier", "name", name); + } + return false; +} +// @TODO: Make sure that children of an indexed tuple are marked with a null indexed +function parseParamType(param, allowIndexed) { + let originalParam = param; + function throwError(i) { + throw new Error("unexpected character '" + originalParam[i] + "' at position " + i + " in '" + originalParam + "'"); + } + param = param.replace(/\s/g, " "); + function newNode(parent) { + let node = { type: "", name: "", parent: parent, state: { allowType: true } }; + if (allowIndexed) { + node.indexed = false; + } + return node; + } + let parent = { type: "", name: "", state: { allowType: true } }; + let node = parent; + for (let i = 0; i < param.length; i++) { + let c = param[i]; + switch (c) { + case "(": + if (!node.state.allowParams) { + throwError(i); + } + node.state.allowType = false; + node.type = verifyType(node.type); + node.components = [newNode(node)]; + node = node.components[0]; + break; + case ")": + delete node.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + if (checkModifier(node.type, node.name)) { + node.name = ""; + } + node.type = verifyType(node.type); + let child = node; + node = node.parent; + if (!node) { + throwError(i); + } + delete child.parent; + node.state.allowParams = false; + node.state.allowName = true; + node.state.allowArray = true; + break; + case ",": + delete node.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + if (checkModifier(node.type, node.name)) { + node.name = ""; + } + node.type = verifyType(node.type); + let sibling = newNode(node.parent); + //{ type: "", name: "", parent: node.parent, state: { allowType: true } }; + node.parent.components.push(sibling); + delete node.parent; + node = sibling; + break; + // Hit a space... + case " ": + // If reading type, the type is done and may read a param or name + if (node.state.allowType) { + if (node.type !== "") { + node.type = verifyType(node.type); + delete node.state.allowType; + node.state.allowName = true; + node.state.allowParams = true; + } + } + // If reading name, the name is done + if (node.state.allowName) { + if (node.name !== "") { + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + if (node.indexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + else if (checkModifier(node.type, node.name)) { + node.name = ""; + } + else { + node.state.allowName = false; + } + } + } + break; + case "[": + if (!node.state.allowArray) { + throwError(i); + } + node.type += c; + node.state.allowArray = false; + node.state.allowName = false; + node.state.readArray = true; + break; + case "]": + if (!node.state.readArray) { + throwError(i); + } + node.type += c; + node.state.readArray = false; + node.state.allowArray = true; + node.state.allowName = true; + break; + default: + if (node.state.allowType) { + node.type += c; + node.state.allowParams = true; + node.state.allowArray = true; + } + else if (node.state.allowName) { + node.name += c; + delete node.state.allowArray; + } + else if (node.state.readArray) { + node.type += c; + } + else { + throwError(i); + } + } + } + if (node.parent) { + throw new Error("unexpected eof"); + } + delete parent.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(originalParam.length - 7); + } + if (node.indexed) { + throwError(originalParam.length - 7); + } + node.indexed = true; + node.name = ""; + } + else if (checkModifier(node.type, node.name)) { + node.name = ""; + } + parent.type = verifyType(parent.type); + return parent; +} +function populate(object, params) { + for (let key in params) { + defineReadOnly(object, key, params[key]); + } +} +const FormatTypes = Object.freeze({ + // Bare formatting, as is needed for computing a sighash of an event or function + sighash: "sighash", + // Human-Readable with Minimal spacing and without names (compact human-readable) + minimal: "minimal", + // Human-Readble with nice spacing, including all names + full: "full", + // JSON-format a la Solidity + json: "json" +}); +const paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); +class ParamType { + constructor(constructorGuard, params) { + if (constructorGuard !== _constructorGuard$2) { + throw new Error("use fromString"); + } + populate(this, params); + let match = this.type.match(paramTypeArray); + if (match) { + populate(this, { + arrayLength: parseInt(match[2] || "-1"), + arrayChildren: ParamType.fromObject({ + type: match[1], + components: this.components + }), + baseType: "array" + }); + } + else { + populate(this, { + arrayLength: null, + arrayChildren: null, + baseType: ((this.components != null) ? "tuple" : this.type) + }); + } + this._isParamType = true; + Object.freeze(this); + } + // Format the parameter fragment + // - sighash: "(uint256,address)" + // - minimal: "tuple(uint256,address) indexed" + // - full: "tuple(uint256 foo, addres bar) indexed baz" + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger$4.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + let result = { + type: ((this.baseType === "tuple") ? "tuple" : this.type), + name: (this.name || undefined) + }; + if (typeof (this.indexed) === "boolean") { + result.indexed = this.indexed; + } + if (this.components) { + result.components = this.components.map((comp) => JSON.parse(comp.format(format))); + } + return JSON.stringify(result); + } + let result = ""; + // Array + if (this.baseType === "array") { + result += this.arrayChildren.format(format); + result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; + } + else { + if (this.baseType === "tuple") { + if (format !== FormatTypes.sighash) { + result += this.type; + } + result += "(" + this.components.map((comp) => comp.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ")"; + } + else { + result += this.type; + } + } + if (format !== FormatTypes.sighash) { + if (this.indexed === true) { + result += " indexed"; + } + if (format === FormatTypes.full && this.name) { + result += " " + this.name; + } + } + return result; + } + static from(value, allowIndexed) { + if (typeof (value) === "string") { + return ParamType.fromString(value, allowIndexed); + } + return ParamType.fromObject(value); + } + static fromObject(value) { + if (ParamType.isParamType(value)) { + return value; + } + return new ParamType(_constructorGuard$2, { + name: (value.name || null), + type: verifyType(value.type), + indexed: ((value.indexed == null) ? null : !!value.indexed), + components: (value.components ? value.components.map(ParamType.fromObject) : null) + }); + } + static fromString(value, allowIndexed) { + function ParamTypify(node) { + return ParamType.fromObject({ + name: node.name, + type: node.type, + indexed: node.indexed, + components: node.components + }); + } + return ParamTypify(parseParamType(value, !!allowIndexed)); + } + static isParamType(value) { + return !!(value != null && value._isParamType); + } +} +; +function parseParams(value, allowIndex) { + return splitNesting(value).map((param) => ParamType.fromString(param, allowIndex)); +} +class Fragment { + constructor(constructorGuard, params) { + if (constructorGuard !== _constructorGuard$2) { + throw new Error("use a static from method"); + } + populate(this, params); + this._isFragment = true; + Object.freeze(this); + } + static from(value) { + if (Fragment.isFragment(value)) { + return value; + } + if (typeof (value) === "string") { + return Fragment.fromString(value); + } + return Fragment.fromObject(value); + } + static fromObject(value) { + if (Fragment.isFragment(value)) { + return value; + } + if (value.type === "function") { + return FunctionFragment.fromObject(value); + } + else if (value.type === "event") { + return EventFragment.fromObject(value); + } + else if (value.type === "constructor") { + return ConstructorFragment.fromObject(value); + } + else if (value.type === "fallback") { + // @TODO: + return null; + } + return logger$4.throwArgumentError("invalid fragment object", "value", value); + } + static fromString(value) { + // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space + value = value.replace(/\s/g, " "); + value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); + value = value.trim(); + if (value.split(" ")[0] === "event") { + return EventFragment.fromString(value.substring(5).trim()); + } + else if (value.split(" ")[0] === "function") { + return FunctionFragment.fromString(value.substring(8).trim()); + } + else if (value.split("(")[0].trim() === "constructor") { + return ConstructorFragment.fromString(value.trim()); + } + throw new Error("unknown fragment"); + } + static isFragment(value) { + return !!(value && value._isFragment); + } +} +class EventFragment extends Fragment { + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger$4.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + return JSON.stringify({ + type: "event", + anonymous: this.anonymous, + name: this.name, + inputs: this.inputs.map((input) => JSON.parse(input.format(format))) + }); + } + let result = ""; + if (format !== FormatTypes.sighash) { + result += "event "; + } + result += this.name + "(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") "; + if (format !== FormatTypes.sighash) { + if (this.anonymous) { + result += "anonymous "; + } + } + return result.trim(); + } + static from(value) { + if (typeof (value) === "string") { + return EventFragment.fromString(value); + } + return EventFragment.fromObject(value); + } + static fromObject(value) { + if (EventFragment.isEventFragment(value)) { + return value; + } + if (value.type !== "event") { + throw new Error("invalid event object - " + value.type); + } + return new EventFragment(_constructorGuard$2, { + name: verifyIdentifier(value.name), + anonymous: value.anonymous, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + type: "event" + }); + } + static fromString(value) { + let match = value.match(regexParen); + if (!match) { + throw new Error("invalid event: " + value); + } + let anonymous = false; + match[3].split(" ").forEach((modifier) => { + switch (modifier.trim()) { + case "anonymous": + anonymous = true; + break; + case "": + break; + default: + logger$4.warn("unknown modifier: " + modifier); + } + }); + return EventFragment.fromObject({ + name: match[1].trim(), + anonymous: anonymous, + inputs: parseParams(match[2], true), + type: "event" + }); + } + static isEventFragment(value) { + return (value && value._isFragment && value.type === "event"); + } +} +function parseGas(value, params) { + params.gas = null; + let comps = value.split("@"); + if (comps.length !== 1) { + if (comps.length > 2) { + throw new Error("invalid signature"); + } + if (!comps[1].match(/^[0-9]+$/)) { + throw new Error("invalid signature gas"); + } + params.gas = BigNumber.from(comps[1]); + return comps[0]; + } + return value; +} +function parseModifiers(value, params) { + params.constant = false; + params.payable = false; + params.stateMutability = "nonpayable"; + value.split(" ").forEach((modifier) => { + switch (modifier.trim()) { + case "constant": + params.constant = true; + break; + case "payable": + params.payable = true; + params.stateMutability = "payable"; + break; + case "pure": + params.constant = true; + params.stateMutability = "pure"; + break; + case "view": + params.constant = true; + params.stateMutability = "view"; + break; + case "external": + case "public": + case "": + break; + default: + console.log("unknown modifier: " + modifier); + } + }); +} +function verifyState(value) { + let result = { + constant: false, + payable: true, + stateMutability: "payable" + }; + if (value.stateMutability != null) { + result.stateMutability = value.stateMutability; + result.constant = (result.stateMutability === "view" || result.stateMutability === "pure"); + if (value.constant != null) { + if ((!!value.constant) !== result.constant) { + throw new Error("cannot have constant function with mutability " + result.stateMutability); + } + } + result.payable = (result.stateMutability === "payable"); + if (value.payable != null) { + if ((!!value.payable) !== result.payable) { + throw new Error("cannot have payable function with mutability " + result.stateMutability); + } + } + } + else if (value.payable != null) { + result.payable = !!value.payable; + result.stateMutability = (result.payable ? "payable" : "nonpayable"); + result.constant = !result.payable; + if (value.constant != null && (value.constant !== result.constant)) { + throw new Error("cannot have constant payable function"); + } + } + else if (value.constant != null) { + result.constant = !!value.constant; + result.payable = !result.constant; + result.stateMutability = (result.constant ? "view" : "payable"); + } + return result; +} +class ConstructorFragment extends Fragment { + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger$4.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + return JSON.stringify({ + type: "constructor", + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payble: this.payable, + gas: (this.gas ? this.gas.toNumber() : undefined), + inputs: this.inputs.map((input) => JSON.parse(input.format(format))) + }); + } + if (format === FormatTypes.sighash) { + logger$4.throwError("cannot format a constructor for sighash", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "format(sighash)" + }); + } + let result = "constructor(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") "; + if (this.stateMutability && this.stateMutability !== "nonpayable") { + result += this.stateMutability + " "; + } + return result.trim(); + } + static from(value) { + if (typeof (value) === "string") { + return ConstructorFragment.fromString(value); + } + return ConstructorFragment.fromObject(value); + } + static fromObject(value) { + if (ConstructorFragment.isConstructorFragment(value)) { + return value; + } + if (value.type !== "constructor") { + throw new Error("invalid constructor object - " + value.type); + } + let state = verifyState(value); + if (state.constant) { + throw new Error("constructor cannot be constant"); + } + return new ConstructorFragment(_constructorGuard$2, { + type: value.type, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + payable: state.payable, + gas: (value.gas ? BigNumber.from(value.gas) : null) + }); + } + static fromString(value) { + let params = { type: "constructor" }; + value = parseGas(value, params); + let parens = value.match(regexParen); + if (!parens) { + throw new Error("invalid constructor: " + value); + } + if (parens[1].trim() !== "constructor") { + throw new Error("invalid constructor"); + } + params.inputs = parseParams(parens[2].trim(), false); + parseModifiers(parens[3].trim(), params); + return ConstructorFragment.fromObject(params); + } + static isConstructorFragment(value) { + return (value && value._isFragment && value.type === "constructor"); + } +} +class FunctionFragment extends ConstructorFragment { + format(format) { + if (!format) { + format = FormatTypes.sighash; + } + if (!FormatTypes[format]) { + logger$4.throwArgumentError("invalid format type", "format", format); + } + if (format === FormatTypes.json) { + return JSON.stringify({ + type: "function", + name: this.name, + constant: this.constant, + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payble: this.payable, + gas: (this.gas ? this.gas.toNumber() : undefined), + inputs: this.inputs.map((input) => JSON.parse(input.format(format))), + ouputs: this.outputs.map((output) => JSON.parse(output.format(format))), + }); + } + let result = ""; + if (format !== FormatTypes.sighash) { + result += "function "; + } + result += this.name + "(" + this.inputs.map((input) => input.format(format)).join((format === FormatTypes.full) ? ", " : ",") + ") "; + if (format !== FormatTypes.sighash) { + if (this.stateMutability) { + if (this.stateMutability !== "nonpayable") { + result += (this.stateMutability + " "); + } + } + else if (this.constant) { + result += "view "; + } + if (this.outputs && this.outputs.length) { + result += "returns (" + this.outputs.map((output) => output.format(format)).join(", ") + ") "; + } + if (this.gas != null) { + result += "@" + this.gas.toString() + " "; + } + } + return result.trim(); + } + static from(value) { + if (typeof (value) === "string") { + return FunctionFragment.fromString(value); + } + return FunctionFragment.fromObject(value); + } + static fromObject(value) { + if (FunctionFragment.isFunctionFragment(value)) { + return value; + } + if (value.type !== "function") { + throw new Error("invalid function object - " + value.type); + } + let state = verifyState(value); + return new FunctionFragment(_constructorGuard$2, { + type: value.type, + name: verifyIdentifier(value.name), + constant: state.constant, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []), + payable: state.payable, + stateMutability: state.stateMutability, + gas: (value.gas ? BigNumber.from(value.gas) : null) + }); + } + static fromString(value) { + let params = { type: "function" }; + value = parseGas(value, params); + let comps = value.split(" returns "); + if (comps.length > 2) { + throw new Error("invalid function"); + } + let parens = comps[0].match(regexParen); + if (!parens) { + throw new Error("invalid signature"); + } + params.name = parens[1].trim(); + if (!params.name.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + params.name + "'"); + } + params.inputs = parseParams(parens[2], false); + parseModifiers(parens[3].trim(), params); + // We have outputs + if (comps.length > 1) { + let returns = comps[1].match(regexParen); + if (returns[1].trim() != "" || returns[3].trim() != "") { + throw new Error("unexpected tokens"); + } + params.outputs = parseParams(returns[2], false); + } + else { + params.outputs = []; + } + return FunctionFragment.fromObject(params); + } + static isFunctionFragment(value) { + return (value && value._isFragment && value.type === "function"); + } +} +//export class ErrorFragment extends Fragment { +//} +//export class StructFragment extends Fragment { +//} +function verifyType(type) { + // These need to be transformed to their full description + if (type.match(/^uint($|[^1-9])/)) { + type = "uint256" + type.substring(4); + } + else if (type.match(/^int($|[^1-9])/)) { + type = "int256" + type.substring(3); + } + // @TODO: more verification + return type; +} +const regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); +function verifyIdentifier(value) { + if (!value || !value.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + value + "'"); + } + return value; +} +const regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); +function splitNesting(value) { + value = value.trim(); + let result = []; + let accum = ""; + let depth = 0; + for (let offset = 0; offset < value.length; offset++) { + let c = value[offset]; + if (c === "," && depth === 0) { + result.push(accum); + accum = ""; + } + else { + accum += c; + if (c === "(") { + depth++; + } + else if (c === ")") { + depth--; + if (depth === -1) { + throw new Error("unbalanced parenthsis"); + } + } + } + } + if (accum) { + result.push(accum); + } + return result; +} + +"use strict"; +const logger$5 = new Logger(version$4); +class Coder { + constructor(name, type, localName, dynamic) { + this.name = name; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + _throwError(message, value) { + logger$5.throwArgumentError(message, this.localName, value); + } +} +class Writer { + constructor(wordSize) { + defineReadOnly(this, "wordSize", wordSize || 32); + this._data = arrayify([]); + this._padding = new Uint8Array(wordSize); + } + get data() { return hexlify(this._data); } + get length() { return this._data.length; } + _writeData(data) { + this._data = concat([this._data, data]); + return data.length; + } + // Arrayish items; padded on the right to wordSize + writeBytes(value) { + let bytes = arrayify(value); + if (bytes.length % this.wordSize) { + bytes = concat([bytes, this._padding.slice(bytes.length % this.wordSize)]); + } + return this._writeData(bytes); + } + _getValue(value) { + let bytes = arrayify(BigNumber.from(value)); + if (bytes.length > this.wordSize) { + logger$5.throwError("value out-of-bounds", Logger.errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes.length + }); + } + if (bytes.length % this.wordSize) { + bytes = concat([this._padding.slice(bytes.length % this.wordSize), bytes]); + } + return bytes; + } + // BigNumberish items; padded on the left to wordSize + writeValue(value) { + return this._writeData(this._getValue(value)); + } + writeUpdatableValue() { + let offset = this.length; + this.writeValue(0); + return (value) => { + this._data.set(this._getValue(value), offset); + }; + } +} +class Reader { + constructor(data, wordSize, coerceFunc) { + defineReadOnly(this, "_data", arrayify(data)); + defineReadOnly(this, "wordSize", wordSize || 32); + defineReadOnly(this, "_coerceFunc", coerceFunc); + this._offset = 0; + } + get data() { return hexlify(this._data); } + get consumed() { return this._offset; } + // The default Coerce function + static coerce(name, value) { + let match = name.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { + value = value.toNumber(); + } + return value; + } + coerce(name, value) { + if (this._coerceFunc) { + return this._coerceFunc(name, value); + } + return Reader.coerce(name, value); + } + _peekBytes(offset, length) { + let alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + logger$5.throwError("data out-of-bounds", Logger.errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); + } + return this._data.slice(this._offset, this._offset + alignedLength); + } + subReader(offset) { + return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); + } + readBytes(length) { + let bytes = this._peekBytes(0, length); + this._offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + } + readValue() { + return BigNumber.from(this.readBytes(this.wordSize)); + } +} + +var sha3 = createCommonjsModule(function (module) { +/** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.5.7 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2016 + * @license MIT + */ +/*jslint bitwise: true */ +(function () { + 'use strict'; + + var root = typeof window === 'object' ? window : {}; + var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = commonjsGlobal; + } + var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && 'object' === 'object' && module.exports; + var HEX_CHARS = '0123456789abcdef'.split(''); + var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; + var KECCAK_PADDING = [1, 256, 65536, 16777216]; + var PADDING = [6, 1536, 393216, 100663296]; + var SHIFT = [0, 8, 16, 24]; + var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; + var BITS = [224, 256, 384, 512]; + var SHAKE_BITS = [128, 256]; + var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array']; + + var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; + }; + + var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; + }; + + var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(bits, padding, type); + } + return method; + }; + + var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createShakeOutputMethod(bits, padding, type); + } + return method; + }; + + var algorithms = [ + {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod}, + {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod}, + {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod} + ]; + + var methods = {}, methodNames = []; + + for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name +'_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + } + } + + function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } + } + + Keccak.prototype.update = function (message) { + var notString = typeof message !== 'string'; + if (notString && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } + var length = message.length, blocks = this.blocks, byteCount = this.byteCount, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; + }; + + Keccak.prototype.finalize = function () { + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + }; + + Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + if (extraBytes > 0) { + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + } + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; + }; + + Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; + }; + + Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + + Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + if (extraBytes > 0) { + array[offset] = block & 0xFF; + } + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; + }; + + var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } + }; + + if (COMMON_JS) { + module.exports = methods; + } else { + for (var i = 0; i < methodNames.length; ++i) { + root[methodNames[i]] = methods[methodNames[i]]; + } + } +})(); +}); + +"use strict"; +function keccak256(data) { + return '0x' + sha3.keccak_256(arrayify(data)); +} + +"use strict"; +function arrayifyInteger(value) { + let result = []; + while (value) { + result.unshift(value & 0xff); + value >>= 8; + } + return result; +} +function unarrayifyInteger(data, offset, length) { + let result = 0; + for (let i = 0; i < length; i++) { + result = (result * 256) + data[offset + i]; + } + return result; +} +function _encode(object) { + if (Array.isArray(object)) { + let payload = []; + object.forEach(function (child) { + payload = payload.concat(_encode(child)); + }); + if (payload.length <= 55) { + payload.unshift(0xc0 + payload.length); + return payload; + } + let length = arrayifyInteger(payload.length); + length.unshift(0xf7 + length.length); + return length.concat(payload); + } + let data = Array.prototype.slice.call(arrayify(object)); + if (data.length === 1 && data[0] <= 0x7f) { + return data; + } + else if (data.length <= 55) { + data.unshift(0x80 + data.length); + return data; + } + let length = arrayifyInteger(data.length); + length.unshift(0xb7 + length.length); + return length.concat(data); +} +function encode(object) { + return hexlify(_encode(object)); +} +function _decodeChildren(data, offset, childOffset, length) { + let result = []; + while (childOffset < offset + 1 + length) { + let decoded = _decode(data, childOffset); + result.push(decoded.result); + childOffset += decoded.consumed; + if (childOffset > offset + 1 + length) { + throw new Error("invalid rlp"); + } + } + return { consumed: (1 + length), result: result }; +} +// returns { consumed: number, result: Object } +function _decode(data, offset) { + if (data.length === 0) { + throw new Error("invalid rlp data"); + } + // Array with extra length prefix + if (data[offset] >= 0xf8) { + let lengthLength = data[offset] - 0xf7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("too short"); + } + let length = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length > data.length) { + throw new Error("to short"); + } + return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length); + } + else if (data[offset] >= 0xc0) { + let length = data[offset] - 0xc0; + if (offset + 1 + length > data.length) { + throw new Error("invalid rlp data"); + } + return _decodeChildren(data, offset, offset + 1, length); + } + else if (data[offset] >= 0xb8) { + let lengthLength = data[offset] - 0xb7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("invalid rlp data"); + } + let length = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length > data.length) { + throw new Error("invalid rlp data"); + } + let result = hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length)); + return { consumed: (1 + lengthLength + length), result: result }; + } + else if (data[offset] >= 0x80) { + let length = data[offset] - 0x80; + if (offset + 1 + length > data.length) { + throw new Error("invlaid rlp data"); + } + let result = hexlify(data.slice(offset + 1, offset + 1 + length)); + return { consumed: (1 + length), result: result }; + } + return { consumed: 1, result: hexlify(data[offset]) }; +} +function decode(data) { + let bytes = arrayify(data); + let decoded = _decode(bytes, 0); + if (decoded.consumed !== bytes.length) { + throw new Error("invalid rlp data"); + } + return decoded.result; +} + +var index = /*#__PURE__*/Object.freeze({ + encode: encode, + decode: decode +}); + +const version$5 = "address/5.0.0-beta.128"; + +"use strict"; +const logger$6 = new Logger(version$5); +function getChecksumAddress(address) { + if (!isHexString(address, 20)) { + logger$6.throwArgumentError("invalid address", "address", address); + } + address = address.toLowerCase(); + let chars = address.substring(2).split(""); + let hashed = new Uint8Array(40); + for (let i = 0; i < 40; i++) { + hashed[i] = chars[i].charCodeAt(0); + } + hashed = arrayify(keccak256(hashed)); + for (let i = 0; i < 40; i += 2) { + if ((hashed[i >> 1] >> 4) >= 8) { + chars[i] = chars[i].toUpperCase(); + } + if ((hashed[i >> 1] & 0x0f) >= 8) { + chars[i + 1] = chars[i + 1].toUpperCase(); + } + } + return "0x" + chars.join(""); +} +// Shims for environments that are missing some required constants and functions +const MAX_SAFE_INTEGER = 0x1fffffffffffff; +function log10(x) { + if (Math.log10) { + return Math.log10(x); + } + return Math.log(x) / Math.LN10; +} +// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number +// Create lookup table +let ibanLookup = {}; +for (let i = 0; i < 10; i++) { + ibanLookup[String(i)] = String(i); +} +for (let i = 0; i < 26; i++) { + ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); +} +// How many decimal digits can we process? (for 64-bit float, this is 15) +let safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); +function ibanChecksum(address) { + address = address.toUpperCase(); + address = address.substring(4) + address.substring(0, 2) + "00"; + let expanded = ""; + address.split("").forEach(function (c) { + expanded += ibanLookup[c]; + }); + // Javascript can handle integers safely up to 15 (decimal) digits + while (expanded.length >= safeDigits) { + let block = expanded.substring(0, safeDigits); + expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); + } + let checksum = String(98 - (parseInt(expanded, 10) % 97)); + while (checksum.length < 2) { + checksum = "0" + checksum; + } + return checksum; +} +; +function getAddress(address) { + let result = null; + if (typeof (address) !== "string") { + logger$6.throwArgumentError("invalid address", "address", address); + } + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + // Missing the 0x prefix + if (address.substring(0, 2) !== "0x") { + address = "0x" + address; + } + result = getChecksumAddress(address); + // It is a checksummed address with a bad checksum + if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { + logger$6.throwArgumentError("bad address checksum", "address", address); + } + // Maybe ICAP? (we only support direct mode) + } + else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + // It is an ICAP address with a bad checksum + if (address.substring(2, 4) !== ibanChecksum(address)) { + logger$6.throwArgumentError("bad icap checksum", "address", address); + } + result = (new bn_1(address.substring(4), 36)).toString(16); + while (result.length < 40) { + result = "0" + result; + } + result = getChecksumAddress("0x" + result); + } + else { + logger$6.throwArgumentError("invalid address", "address", address); + } + return result; +} +function isAddress(address) { + try { + getAddress(address); + return true; + } + catch (error) { } + return false; +} +function getIcapAddress(address) { + let base36 = (new bn_1(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + while (base36.length < 30) { + base36 = "0" + base36; + } + return "XE" + ibanChecksum("XE00" + base36) + base36; +} +// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed +function getContractAddress(transaction) { + let from = null; + try { + from = getAddress(transaction.from); + } + catch (error) { + logger$6.throwArgumentError("missing from address", "transaction", transaction); + } + let nonce = stripZeros(arrayify(transaction.nonce)); + return getAddress(hexDataSlice(keccak256(encode([from, nonce])), 12)); +} + +"use strict"; +class AddressCoder extends Coder { + constructor(localName) { + super("address", "address", localName, false); + } + encode(writer, value) { + try { + getAddress(value); + } + catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + } + decode(reader) { + return getAddress(hexZeroPad(reader.readValue().toHexString(), 20)); + } +} + +"use strict"; +// Clones the functionality of an existing Coder, but without a localName +class AnonymousCoder extends Coder { + constructor(coder) { + super(coder.name, coder.type, undefined, coder.dynamic); + this.coder = coder; + } + encode(writer, value) { + return this.coder.encode(writer, value); + } + decode(reader) { + return this.coder.decode(reader); + } +} + +"use strict"; +const logger$7 = new Logger(version$4); +function pack(writer, coders, values) { + if (Array.isArray(values)) { + // do nothing + } + else if (values && typeof (values) === "object") { + let arrayValues = []; + coders.forEach(function (coder) { + arrayValues.push(values[coder.localName]); + }); + values = arrayValues; + } + else { + logger$7.throwArgumentError("invalid tuple value", "tuple", values); + } + if (coders.length !== values.length) { + logger$7.throwArgumentError("types/value length mismatch", "tuple", values); + } + let staticWriter = new Writer(writer.wordSize); + let dynamicWriter = new Writer(writer.wordSize); + let updateFuncs = []; + coders.forEach((coder, index) => { + let value = values[index]; + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + let dynamicOffset = dynamicWriter.length; + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + // Prepare to populate the correct offset once we are done + let updateFunc = staticWriter.writeUpdatableValue(); + updateFuncs.push((baseOffset) => { + updateFunc(baseOffset + dynamicOffset); + }); + } + else { + coder.encode(staticWriter, value); + } + }); + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach((func) => { func(staticWriter.length); }); + let length = writer.writeBytes(staticWriter.data); + length += writer.writeBytes(dynamicWriter.data); + return length; +} +function unpack(reader, coders) { + let values = []; + // A reader anchored to this base + let baseReader = reader.subReader(0); + // The amount of dynamic data read; to consume later to synchronize + let dynamicLength = 0; + coders.forEach((coder) => { + let value = null; + if (coder.dynamic) { + let offset = reader.readValue(); + let offsetReader = baseReader.subReader(offset.toNumber()); + value = coder.decode(offsetReader); + dynamicLength += offsetReader.consumed; + } + else { + value = coder.decode(reader); + } + if (value != undefined) { + values.push(value); + } + }); + // @TODO: get rid of this an see if it still works? + // Consume the dynamic components in the main reader + reader.readBytes(dynamicLength); + // Add any named parameters (i.e. tuples) + coders.forEach((coder, index) => { + let name = coder.localName; + if (!name) { + return; + } + if (name === "length") { + name = "_length"; + } + if (values[name] != null) { + return; + } + values[name] = values[index]; + }); + return values; +} +class ArrayCoder extends Coder { + constructor(coder, length, localName) { + const type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); + const dynamic = (length === -1 || coder.dynamic); + super("array", type, localName, dynamic); + this.coder = coder; + this.length = length; + } + encode(writer, value) { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + let count = this.length; + //let result = new Uint8Array(0); + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + logger$7.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); + let coders = []; + for (let i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + } + decode(reader) { + let count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + } + let coders = []; + for (let i = 0; i < count; i++) { + coders.push(new AnonymousCoder(this.coder)); + } + return reader.coerce(this.name, unpack(reader, coders)); + } +} + +"use strict"; +class BooleanCoder extends Coder { + constructor(localName) { + super("bool", "bool", localName, false); + } + encode(writer, value) { + return writer.writeValue(value ? 1 : 0); + } + decode(reader) { + return reader.coerce(this.type, !reader.readValue().isZero()); + } +} + +"use strict"; +class DynamicBytesCoder extends Coder { + constructor(type, localName) { + super(type, type, localName, true); + } + encode(writer, value) { + value = arrayify(value); + let length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + } + decode(reader) { + return reader.readBytes(reader.readValue().toNumber()); + } +} +class BytesCoder extends DynamicBytesCoder { + constructor(localName) { + super("bytes", localName); + } + decode(reader) { + return reader.coerce(this.name, hexlify(super.decode(reader))); + } +} + +"use strict"; +// @TODO: Merge this with bytes +class FixedBytesCoder extends Coder { + constructor(size, localName) { + let name = "bytes" + String(size); + super(name, name, localName, false); + this.size = size; + } + encode(writer, value) { + let data = arrayify(value); + if (data.length !== this.size) { + this._throwError("incorrect data length", value); + } + return writer.writeBytes(data); + } + decode(reader) { + return reader.coerce(this.name, hexlify(reader.readBytes(this.size))); + } +} + +"use strict"; +class NullCoder extends Coder { + constructor(localName) { + super("null", "", localName, false); + } + encode(writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes([]); + } + decode(reader) { + reader.readBytes(0); + return reader.coerce(this.name, null); + } +} + +"use strict"; +const AddressZero = "0x0000000000000000000000000000000000000000"; +const HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; +// NFKD (decomposed) +//const EtherSymbol = "\uD835\uDF63"; +// NFKC (composed) +const EtherSymbol = "\u039e"; +const NegativeOne$1 = BigNumber.from(-1); +const Zero$1 = BigNumber.from(0); +const One = BigNumber.from(1); +const Two = BigNumber.from(2); +const WeiPerEther = BigNumber.from("1000000000000000000"); +const MaxUint256 = BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + +var index$1 = /*#__PURE__*/Object.freeze({ + AddressZero: AddressZero, + HashZero: HashZero, + EtherSymbol: EtherSymbol, + NegativeOne: NegativeOne$1, + Zero: Zero$1, + One: One, + Two: Two, + WeiPerEther: WeiPerEther, + MaxUint256: MaxUint256 +}); + +"use strict"; +class NumberCoder extends Coder { + constructor(size, signed, localName) { + const name = ((signed ? "int" : "uint") + (size * 8)); + super(name, name, localName, false); + this.size = size; + this.signed = signed; + } + encode(writer, value) { + let v = BigNumber.from(value); + // Check bounds are safe for encoding + let maxUintValue = MaxUint256.maskn(writer.wordSize * 8); + if (this.signed) { + let bounds = maxUintValue.maskn(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(One).mul(NegativeOne$1))) { + this._throwError("value out-of-bounds", value); + } + } + else if (v.lt(Zero$1) || v.gt(maxUintValue.maskn(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + v = v.toTwos(this.size * 8).maskn(this.size * 8); + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + return writer.writeValue(v); + } + decode(reader) { + let value = reader.readValue().maskn(this.size * 8); + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + return reader.coerce(this.name, value); + } +} + +const version$6 = "strings/5.0.0-beta.130"; + +"use strict"; +const logger$8 = new Logger(version$6); +/////////////////////////////// +var UnicodeNormalizationForm; +(function (UnicodeNormalizationForm) { + UnicodeNormalizationForm["current"] = ""; + UnicodeNormalizationForm["NFC"] = "NFC"; + UnicodeNormalizationForm["NFD"] = "NFD"; + UnicodeNormalizationForm["NFKC"] = "NFKC"; + UnicodeNormalizationForm["NFKD"] = "NFKD"; +})(UnicodeNormalizationForm || (UnicodeNormalizationForm = {})); +; +// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 +function getUtf8CodePoints(bytes, ignoreErrors) { + bytes = arrayify(bytes); + let result = []; + let i = 0; + // Invalid bytes are ignored + while (i < bytes.length) { + let c = bytes[i++]; + // 0xxx xxxx + if (c >> 7 === 0) { + result.push(c); + continue; + } + // Multibyte; how many bytes left for this character? + let extraLength = null; + let overlongMask = null; + // 110x xxxx 10xx xxxx + if ((c & 0xe0) === 0xc0) { + extraLength = 1; + overlongMask = 0x7f; + // 1110 xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf0) === 0xe0) { + extraLength = 2; + overlongMask = 0x7ff; + // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf8) === 0xf0) { + extraLength = 3; + overlongMask = 0xffff; + } + else { + if (!ignoreErrors) { + if ((c & 0xc0) === 0x80) { + throw new Error("invalid utf8 byte sequence; unexpected continuation byte"); + } + throw new Error("invalid utf8 byte sequence; invalid prefix"); + } + continue; + } + // Do we have enough bytes in our data? + if (i + extraLength > bytes.length) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; too short"); + } + // If there is an invalid unprocessed byte, skip continuation bytes + for (; i < bytes.length; i++) { + if (bytes[i] >> 6 !== 0x02) { + break; + } + } + continue; + } + // Remove the length prefix from the char + let res = c & ((1 << (8 - extraLength - 1)) - 1); + for (let j = 0; j < extraLength; j++) { + let nextChar = bytes[i]; + // Invalid continuation byte + if ((nextChar & 0xc0) != 0x80) { + res = null; + break; + } + ; + res = (res << 6) | (nextChar & 0x3f); + i++; + } + if (res === null) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; invalid continuation byte"); + } + continue; + } + // Check for overlong seuences (more bytes than needed) + if (res <= overlongMask) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; overlong"); + } + continue; + } + // Maximum code point + if (res > 0x10ffff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; out-of-range"); + } + continue; + } + // Reserved for UTF-16 surrogate halves + if (res >= 0xd800 && res <= 0xdfff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; utf-16 surrogate"); + } + continue; + } + result.push(res); + } + return result; +} +// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) { + if (form != UnicodeNormalizationForm.current) { + logger$8.checkNormalize(); + str = str.normalize(form); + } + let result = []; + for (let i = 0; i < str.length; i++) { + let c = str.charCodeAt(i); + if (c < 0x80) { + result.push(c); + } + else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + } + else if ((c & 0xfc00) == 0xd800) { + i++; + let c2 = str.charCodeAt(i); + if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { + throw new Error("invalid utf-8 string"); + } + // Surrogate Pair + c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((c >> 18) | 0xf0); + result.push(((c >> 12) & 0x3f) | 0x80); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + return arrayify(result); +} +; +function escapeChar(value) { + let hex = ("0000" + value.toString(16)); + return "\\u" + hex.substring(hex.length - 4); +} +function _toEscapedUtf8String(bytes, ignoreErrors) { + return '"' + getUtf8CodePoints(bytes, ignoreErrors).map((codePoint) => { + if (codePoint < 256) { + switch (codePoint) { + case 8: return "\\b"; + case 9: return "\\t"; + case 10: return "\\n"; + case 13: return "\\r"; + case 34: return "\\\""; + case 92: return "\\\\"; + } + if (codePoint >= 32 && codePoint < 127) { + return String.fromCharCode(codePoint); + } + } + if (codePoint <= 0xffff) { + return escapeChar(codePoint); + } + codePoint -= 0x10000; + return escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) + escapeChar((codePoint & 0x3ff) + 0xdc00); + }).join("") + '"'; +} +function _toUtf8String(codePoints) { + return codePoints.map((codePoint) => { + if (codePoint <= 0xffff) { + return String.fromCharCode(codePoint); + } + codePoint -= 0x10000; + return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00)); + }).join(""); +} +function toUtf8String(bytes, ignoreErrors) { + return _toUtf8String(getUtf8CodePoints(bytes, ignoreErrors)); +} +function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) { + return getUtf8CodePoints(toUtf8Bytes(str, form)); +} + +"use strict"; +function formatBytes32String(text) { + // Get the bytes + let bytes = toUtf8Bytes(text); + // Check we have room for null-termination + if (bytes.length > 31) { + throw new Error("bytes32 string must be less than 32 bytes"); + } + // Zero-pad (implicitly null-terminates) + return hexlify(concat([bytes, HashZero]).slice(0, 32)); +} +function parseBytes32String(bytes) { + let data = arrayify(bytes); + // Must be 32 bytes with a null-termination + if (data.length !== 32) { + throw new Error("invalid bytes32 - not 32 bytes long"); + } + if (data[31] !== 0) { + throw new Error("invalid bytes32 string - no null terminator"); + } + // Find the null termination + let length = 31; + while (data[length - 1] === 0) { + length--; + } + // Determine the string value + return toUtf8String(data.slice(0, length)); +} + +"use strict"; +function bytes2(data) { + if ((data.length % 4) !== 0) { + throw new Error("bad data"); + } + let result = []; + for (let i = 0; i < data.length; i += 4) { + result.push(parseInt(data.substring(i, i + 4), 16)); + } + return result; +} +function createTable(data, func) { + if (!func) { + func = function (value) { return [parseInt(value, 16)]; }; + } + let lo = 0; + let result = {}; + data.split(",").forEach((pair) => { + let comps = pair.split(":"); + lo += parseInt(comps[0], 16); + result[lo] = func(comps[1]); + }); + return result; +} +function createRangeTable(data) { + let hi = 0; + return data.split(",").map((v) => { + let comps = v.split("-"); + if (comps.length === 1) { + comps[1] = "0"; + } + else if (comps[1] === "") { + comps[1] = "1"; + } + let lo = hi + parseInt(comps[0], 16); + hi = parseInt(comps[1], 16); + return { l: lo, h: hi }; + }); +} +function matchMap(value, ranges) { + let lo = 0; + for (let i = 0; i < ranges.length; i++) { + let range = ranges[i]; + lo += range.l; + if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) { + if (range.e && range.e.indexOf(value - lo) !== -1) { + continue; + } + return range; + } + } + return null; +} +const Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); +// @TODO: Make this relative... +const Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((v) => parseInt(v, 16)); +const Table_B_2_ranges = [ + { h: 25, s: 32, l: 65 }, + { h: 30, s: 32, e: [23], l: 127 }, + { h: 54, s: 1, e: [48], l: 64, d: 2 }, + { h: 14, s: 1, l: 57, d: 2 }, + { h: 44, s: 1, l: 17, d: 2 }, + { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 }, + { h: 16, s: 1, l: 68, d: 2 }, + { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 }, + { h: 26, s: 32, e: [17], l: 435 }, + { h: 22, s: 1, l: 71, d: 2 }, + { h: 15, s: 80, l: 40 }, + { h: 31, s: 32, l: 16 }, + { h: 32, s: 1, l: 80, d: 2 }, + { h: 52, s: 1, l: 42, d: 2 }, + { h: 12, s: 1, l: 55, d: 2 }, + { h: 40, s: 1, e: [38], l: 15, d: 2 }, + { h: 14, s: 1, l: 48, d: 2 }, + { h: 37, s: 48, l: 49 }, + { h: 148, s: 1, l: 6351, d: 2 }, + { h: 88, s: 1, l: 160, d: 2 }, + { h: 15, s: 16, l: 704 }, + { h: 25, s: 26, l: 854 }, + { h: 25, s: 32, l: 55915 }, + { h: 37, s: 40, l: 1247 }, + { h: 25, s: -119711, l: 53248 }, + { h: 25, s: -119763, l: 52 }, + { h: 25, s: -119815, l: 52 }, + { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 }, + { h: 25, s: -119919, l: 52 }, + { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 }, + { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 }, + { h: 25, s: -120075, l: 52 }, + { h: 25, s: -120127, l: 52 }, + { h: 25, s: -120179, l: 52 }, + { h: 25, s: -120231, l: 52 }, + { h: 25, s: -120283, l: 52 }, + { h: 25, s: -120335, l: 52 }, + { h: 24, s: -119543, e: [17], l: 56 }, + { h: 24, s: -119601, e: [17], l: 58 }, + { h: 24, s: -119659, e: [17], l: 58 }, + { h: 24, s: -119717, e: [17], l: 58 }, + { h: 24, s: -119775, e: [17], l: 58 } +]; +const Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); +const Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); +const Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); +const Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function flatten(values) { + return values.reduce((accum, value) => { + value.forEach((value) => { accum.push(value); }); + return accum; + }, []); +} +function _nameprepTableA1(codepoint) { + return !!matchMap(codepoint, Table_A_1_ranges); +} +function _nameprepTableB2(codepoint) { + let range = matchMap(codepoint, Table_B_2_ranges); + if (range) { + return [codepoint + range.s]; + } + let codes = Table_B_2_lut_abs[codepoint]; + if (codes) { + return codes; + } + let shift = Table_B_2_lut_rel[codepoint]; + if (shift) { + return [codepoint + shift[0]]; + } + let complex = Table_B_2_complex[codepoint]; + if (complex) { + return complex; + } + return null; +} +function _nameprepTableC(codepoint) { + return !!matchMap(codepoint, Table_C_ranges); +} +function nameprep(value) { + // This allows platforms with incomplete normalize to bypass + // it for very basic names which the built-in toLowerCase + // will certainly handle correctly + if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) { + return value.toLowerCase(); + } + // Get the code points (keeping the current normalization) + let codes = toUtf8CodePoints(value); + codes = flatten(codes.map((code) => { + // Substitute Table B.1 (Maps to Nothing) + if (Table_B_1_flags.indexOf(code) >= 0) { + return []; + } + if (code >= 0xfe00 && code <= 0xfe0f) { + return []; + } + // Substitute Table B.2 (Case Folding) + let codesTableB2 = _nameprepTableB2(code); + if (codesTableB2) { + return codesTableB2; + } + // No Substitution + return [code]; + })); + // Normalize using form KC + codes = toUtf8CodePoints(_toUtf8String(codes), UnicodeNormalizationForm.NFKC); + // Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9 + codes.forEach((code) => { + if (_nameprepTableC(code)) { + throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); + } + }); + // Prohibit Unassigned Code Points (Table A.1) + codes.forEach((code) => { + if (_nameprepTableA1(code)) { + throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); + } + }); + // IDNA extras + let name = _toUtf8String(codes); + // IDNA: 4.2.3.1 + if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { + throw new Error("invalid hyphen"); + } + // IDNA: 4.2.4 + if (name.length > 63) { + throw new Error("too long"); + } + return name; +} + +"use strict"; + +"use strict"; +class StringCoder extends DynamicBytesCoder { + constructor(localName) { + super("string", localName); + } + encode(writer, value) { + return super.encode(writer, toUtf8Bytes(value)); + } + decode(reader) { + return toUtf8String(super.decode(reader)); + } +} + +"use strict"; +class TupleCoder extends Coder { + constructor(coders, localName) { + let dynamic = false; + let types = []; + coders.forEach((coder) => { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + let type = ("tuple(" + types.join(",") + ")"); + super("tuple", type, localName, dynamic); + this.coders = coders; + } + encode(writer, value) { + return pack(writer, this.coders, value); + } + decode(reader) { + return reader.coerce(this.name, unpack(reader, this.coders)); + } +} + +"use strict"; +const logger$9 = new Logger(version$4); +const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); +const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); +class AbiCoder { + constructor(coerceFunc) { + logger$9.checkNew(new.target, AbiCoder); + defineReadOnly(this, "coerceFunc", coerceFunc || null); + } + _getCoder(param) { + switch (param.baseType) { + case "address": + return new AddressCoder(param.name); + case "bool": + return new BooleanCoder(param.name); + case "string": + return new StringCoder(param.name); + case "bytes": + return new BytesCoder(param.name); + case "array": + return new ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); + case "tuple": + return new TupleCoder((param.components || []).map((component) => { + return this._getCoder(component); + }), param.name); + case "": + return new NullCoder(param.name); + } + // u?int[0-9]* + let match = param.type.match(paramTypeNumber); + if (match) { + let size = parseInt(match[2] || "256"); + if (size === 0 || size > 256 || (size % 8) !== 0) { + logger$9.throwArgumentError("invalid " + match[1] + " bit length", "param", param); + } + return new NumberCoder(size / 8, (match[1] === "int"), param.name); + } + // bytes[0-9]+ + match = param.type.match(paramTypeBytes); + if (match) { + let size = parseInt(match[1]); + if (size === 0 || size > 32) { + logger$9.throwArgumentError("invalid bytes length", "param", param); + } + return new FixedBytesCoder(size, param.name); + } + return logger$9.throwError("invalid type", "type", param.type); + } + _getWordSize() { return 32; } + _getReader(data) { + return new Reader(data, this._getWordSize(), this.coerceFunc); + } + _getWriter() { + return new Writer(this._getWordSize()); + } + encode(types, values) { + if (types.length !== values.length) { + logger$9.throwError("types/values length mismatch", Logger.errors.INVALID_ARGUMENT, { + count: { types: types.length, values: values.length }, + value: { types: types, values: values } + }); + } + let coders = types.map((type) => this._getCoder(ParamType.from(type))); + let coder = (new TupleCoder(coders, "_")); + let writer = this._getWriter(); + coder.encode(writer, values); + return writer.data; + } + decode(types, data) { + let coders = types.map((type) => this._getCoder(ParamType.from(type))); + let coder = new TupleCoder(coders, "_"); + return coder.decode(this._getReader(arrayify(data))); + } +} +const defaultAbiCoder = new AbiCoder(); + +const version$7 = "hash/5.0.0-beta.128"; + +"use strict"; +const logger$a = new Logger(version$7); +/////////////////////////////// +const Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); +const Partition = new RegExp("^((.*)\\.)?([^.]+)$"); +function isValidName(name) { + try { + let comps = name.split("."); + for (let i = 0; i < comps.length; i++) { + if (nameprep(comps[i]).length === 0) { + throw new Error("empty"); + } + } + return true; + } + catch (error) { } + return false; +} +function namehash(name) { + if (typeof (name) !== "string") { + logger$a.throwArgumentError("invalid address - " + String(name), "name", name); + } + let result = Zeros; + while (name.length) { + let partition = name.match(Partition); + let label = toUtf8Bytes(nameprep(partition[3])); + result = keccak256(concat([result, keccak256(label)])); + name = partition[2] || ""; + } + return hexlify(result); +} +function id(text) { + return keccak256(toUtf8Bytes(text)); +} +const messagePrefix = "\x19Ethereum Signed Message:\n"; +function hashMessage(message) { + if (typeof (message) === "string") { + message = toUtf8Bytes(message); + } + return keccak256(concat([ + toUtf8Bytes(messagePrefix), + toUtf8Bytes(String(message.length)), + message + ])); +} + +var module$3 = /*#__PURE__*/Object.freeze({ + isValidName: isValidName, + namehash: namehash, + id: id, + messagePrefix: messagePrefix, + hashMessage: hashMessage +}); + +"use strict"; +const logger$b = new Logger(version$4); +class LogDescription extends Description { +} +class TransactionDescription extends Description { +} +class Indexed extends Description { + static isIndexed(value) { + return !!(value && value._isIndexed); + } +} +class Result { +} +class Interface { + constructor(fragments) { + logger$b.checkNew(new.target, Interface); + let abi = []; + if (typeof (fragments) === "string") { + abi = JSON.parse(fragments); + } + else { + abi = fragments; + } + defineReadOnly(this, "fragments", abi.map((fragment) => { + return Fragment.from(fragment); + }).filter((fragment) => (fragment != null))); + defineReadOnly(this, "_abiCoder", getStatic((new.target), "getAbiCoder")()); + defineReadOnly(this, "functions", {}); + defineReadOnly(this, "errors", {}); + defineReadOnly(this, "events", {}); + defineReadOnly(this, "structs", {}); + // Add all fragments by their signature + this.fragments.forEach((fragment) => { + let bucket = null; + switch (fragment.type) { + case "constructor": + if (this.deploy) { + logger$b.warn("duplicate definition - constructor"); + return; + } + defineReadOnly(this, "deploy", fragment); + return; + case "function": + bucket = this.functions; + break; + case "event": + bucket = this.events; + break; + default: + return; + } + let signature = fragment.format(); + if (bucket[signature]) { + logger$b.warn("duplicate definition - " + signature); + return; + } + bucket[signature] = fragment; + }); + // Add any fragments with a unique name by its name (sans signature parameters) + [this.events, this.functions].forEach((bucket) => { + let count = getNameCount(bucket); + Object.keys(bucket).forEach((signature) => { + let fragment = bucket[signature]; + if (count[fragment.name] !== 1) { + logger$b.warn("duplicate definition - " + fragment.name); + return; + } + bucket[fragment.name] = fragment; + }); + }); + // If we do not have a constructor use the default "constructor() payable" + if (!this.deploy) { + defineReadOnly(this, "deploy", ConstructorFragment.from({ type: "constructor" })); + } + defineReadOnly(this, "_isInterface", true); + } + static getAbiCoder() { + return defaultAbiCoder; + } + static getAddress(address) { + return getAddress(address); + } + _sighashify(functionFragment) { + return hexDataSlice(id(functionFragment.format()), 0, 4); + } + _topicify(eventFragment) { + return id(eventFragment.format()); + } + getFunction(nameOrSignatureOrSighash) { + if (isHexString(nameOrSignatureOrSighash)) { + return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + return (this.functions[nameOrSignatureOrSighash.trim()] || null); + } + // Normlize the signature and lookup the function + return this.functions[FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + } + getEvent(nameOrSignatureOrTopic) { + if (isHexString(nameOrSignatureOrTopic)) { + return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrTopic.indexOf("(") === -1) { + return this.events[nameOrSignatureOrTopic]; + } + return this.events[EventFragment.fromString(nameOrSignatureOrTopic).format()]; + } + getSighash(functionFragment) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return this._sighashify(functionFragment); + } + getEventTopic(eventFragment) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + return this._topicify(eventFragment); + } + _encodeParams(params, values) { + return this._abiCoder.encode(params, values); + } + encodeDeploy(values) { + return this._encodeParams(this.deploy.inputs, values || []); + } + encodeFunctionData(functionFragment, values) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return hexlify(concat([ + this.getSighash(functionFragment), + this._encodeParams(functionFragment.inputs, values || []) + ])); + } + decodeFunctionResult(functionFragment, data) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + let bytes = arrayify(data); + let reason = null; + let errorSignature = null; + switch (bytes.length % this._abiCoder._getWordSize()) { + case 0: + try { + return this._abiCoder.decode(functionFragment.outputs, bytes); + } + catch (error) { } + break; + case 4: + if (hexlify(bytes.slice(0, 4)) === "0x08c379a0") { + errorSignature = "Error(string)"; + reason = this._abiCoder.decode(["string"], bytes.slice(4)); + } + break; + } + return logger$b.throwError("call revert exception", Logger.errors.CALL_EXCEPTION, { + method: functionFragment.format(), + errorSignature: errorSignature, + errorArgs: [reason], + reason: reason + }); + } + encodeFilterTopics(eventFragment, values) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (values.length > eventFragment.inputs.length) { + logger$b.throwError("too many arguments for " + eventFragment.format(), Logger.errors.UNEXPECTED_ARGUMENT, { + argument: "values", + value: values + }); + } + let topics = []; + if (!eventFragment.anonymous) { + topics.push(this.getEventTopic(eventFragment)); + } + values.forEach((value, index) => { + let param = eventFragment.inputs[index]; + if (!param.indexed) { + if (value != null) { + logger$b.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + } + return; + } + if (value == null) { + topics.push(null); + } + else if (param.type === "string") { + topics.push(id(value)); + } + else if (param.type === "bytes") { + topics.push(keccak256(hexlify(value))); + } + else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { + logger$b.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + } + else { + // Check addresses are valid + if (param.type === "address") { + this._abiCoder.encode(["address"], [value]); + } + topics.push(hexZeroPad(hexlify(value), 32)); + } + }); + // Trim off trailing nulls + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + return topics; + } + decodeEventLog(eventFragment, data, topics) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (topics != null && !eventFragment.anonymous) { + let topicHash = this.getEventTopic(eventFragment); + if (!isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { + logger$b.throwError("fragment/topic mismatch", Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); + } + topics = topics.slice(1); + } + let indexed = []; + let nonIndexed = []; + let dynamic = []; + eventFragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(ParamType.fromObject({ type: "bytes32", name: param.name })); + dynamic.push(true); + } + else { + indexed.push(param); + dynamic.push(false); + } + } + else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + let resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, concat(topics)) : null; + let resultNonIndexed = this._abiCoder.decode(nonIndexed, data); + let result = []; + let nonIndexedIndex = 0, indexedIndex = 0; + eventFragment.inputs.forEach((param, index) => { + if (param.indexed) { + if (resultIndexed == null) { + result[index] = new Indexed({ _isIndexed: true, hash: null }); + } + else if (dynamic[index]) { + result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); + } + else { + result[index] = resultIndexed[indexedIndex++]; + } + } + else { + result[index] = resultNonIndexed[nonIndexedIndex++]; + } + //if (param.name && result[param.name] == null) { result[param.name] = result[index]; } + }); + return result; + } + parseTransaction(tx) { + let fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); + if (!fragment) { + return null; + } + return new TransactionDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), + functionFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment), + value: BigNumber.from(tx.value || "0"), + }); + } + parseLog(log) { + let fragment = this.getEvent(log.topics[0]); + if (!fragment || fragment.anonymous) { + return null; + } + // @TODO: If anonymous, and the only method, and the input count matches, should we parse? + return new LogDescription({ + eventFragment: fragment, + name: fragment.name, + signature: fragment.format(), + topic: this.getEventTopic(fragment), + values: this.decodeEventLog(fragment, log.data, log.topics) + }); + } + /* + static from(value: Array | string | Interface) { + if (Interface.isInterface(value)) { + return value; + } + if (typeof(value) === "string") { + return new Interface(JSON.parse(value)); + } + return new Interface(value); + } + */ + static isInterface(value) { + return !!(value && value._isInterface); + } +} +function getFragment(hash, calcFunc, items) { + for (let signature in items) { + if (signature.indexOf("(") === -1) { + continue; + } + let fragment = items[signature]; + if (calcFunc(fragment) === hash) { + return fragment; + } + } + return null; +} +function getNameCount(fragments) { + let unique = {}; + // Count each name + for (let signature in fragments) { + let name = fragments[signature].name; + if (!unique[name]) { + unique[name] = 0; + } + unique[name]++; + } + return unique; +} + +"use strict"; + +const version$8 = "abstract-provider/5.0.0-beta.131"; + +"use strict"; +const logger$c = new Logger(version$8); +; +; +//export type CallTransactionable = { +// call(transaction: TransactionRequest): Promise; +//}; +class ForkEvent extends Description { + static isForkEvent(value) { + return !!(value && value._isForkEvent); + } +} +class BlockForkEvent extends ForkEvent { + constructor(blockhash, expiry) { + if (!isHexString(blockhash, 32)) { + logger$c.throwArgumentError("invalid blockhash", "blockhash", blockhash); + } + super({ + _isForkEvent: true, + _isBlockForkEvent: true, + expiry: (expiry || 0), + blockHash: blockhash + }); + } +} +class TransactionForkEvent extends ForkEvent { + constructor(hash, expiry) { + if (!isHexString(hash, 32)) { + logger$c.throwArgumentError("invalid transaction hash", "hash", hash); + } + super({ + _isForkEvent: true, + _isTransactionForkEvent: true, + expiry: (expiry || 0), + hash: hash + }); + } +} +class TransactionOrderForkEvent extends ForkEvent { + constructor(beforeHash, afterHash, expiry) { + if (!isHexString(beforeHash, 32)) { + logger$c.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + } + if (!isHexString(afterHash, 32)) { + logger$c.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + } + super({ + _isForkEvent: true, + _isTransactionOrderForkEvent: true, + expiry: (expiry || 0), + beforeHash: beforeHash, + afterHash: afterHash + }); + } +} +/////////////////////////////// +// Exported Abstracts +class Provider { + // Alias for "on" + addListener(eventName, listener) { + return this.on(eventName, listener); + } + // Alias for "off" + removeListener(eventName, listener) { + return this.off(eventName, listener); + } + constructor() { + logger$c.checkAbstract(new.target, Provider); + defineReadOnly(this, "_isProvider", true); + } + static isProvider(value) { + return !!(value && value._isProvider); + } +} + +const version$9 = "abstract-signer/5.0.0-beta.132"; + +"use strict"; +const logger$d = new Logger(version$9); +const allowedTransactionKeys = [ + "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" +]; +// Sub-Class Notes: +// - A Signer MUST always make sure, that if present, the "from" field +// matches the Signer, before sending or signing a transaction +// - A Signer SHOULD always wrap private information (such as a private +// key or mnemonic) in a function, so that console.log does not leak +// the data +class Signer { + /////////////////// + // Sub-classes MUST call super + constructor() { + logger$d.checkAbstract(new.target, Signer); + defineReadOnly(this, "_isSigner", true); + } + /////////////////// + // Sub-classes MAY override these + getBalance(blockTag) { + this._checkProvider("getBalance"); + return this.provider.getBalance(this.getAddress(), blockTag); + } + getTransactionCount(blockTag) { + this._checkProvider("getTransactionCount"); + return this.provider.getTransactionCount(this.getAddress(), blockTag); + } + // Populates "from" if unspecified, and estimates the gas for the transation + estimateGas(transaction) { + this._checkProvider("estimateGas"); + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + return this.provider.estimateGas(tx); + }); + } + // Populates "from" if unspecified, and calls with the transation + call(transaction, blockTag) { + this._checkProvider("call"); + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + return this.provider.call(tx); + }); + } + // Populates all fields in a transaction, signs it and sends it to the network + sendTransaction(transaction) { + this._checkProvider("sendTransaction"); + return this.populateTransaction(transaction).then((tx) => { + return this.signTransaction(tx).then((signedTx) => { + return this.provider.sendTransaction(signedTx); + }); + }); + } + getChainId() { + this._checkProvider("getChainId"); + return this.provider.getNetwork().then((network) => network.chainId); + } + getGasPrice() { + this._checkProvider("getGasPrice"); + return this.provider.getGasPrice(); + } + resolveName(name) { + this._checkProvider("resolveName"); + return this.provider.resolveName(name); + } + // Checks a transaction does not contain invalid keys and if + // no "from" is provided, populates it. + // - does NOT require a provider + // - adds "from" is not present + // - returns a COPY (safe to mutate the result) + // By default called from: (overriding these prevents it) + // - call + // - estimateGas + // - populateTransaction (and therefor sendTransaction) + checkTransaction(transaction) { + for (let key in transaction) { + if (allowedTransactionKeys.indexOf(key) === -1) { + logger$d.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + } + } + let tx = shallowCopy(transaction); + if (tx.from == null) { + tx.from = this.getAddress(); + } + return tx; + } + // Populates ALL keys for a transaction and checks that "from" matches + // this Signer. Should be used by sendTransaction but NOT by signTransaction. + // By default called from: (overriding these prevents it) + // - sendTransaction + populateTransaction(transaction) { + return resolveProperties(this.checkTransaction(transaction)).then((tx) => { + if (tx.to != null) { + tx.to = Promise.resolve(tx.to).then((to) => this.resolveName(to)); + } + if (tx.gasPrice == null) { + tx.gasPrice = this.getGasPrice(); + } + if (tx.nonce == null) { + tx.nonce = this.getTransactionCount("pending"); + } + // Make sure any provided address matches this signer + if (tx.from == null) { + tx.from = this.getAddress(); + } + else { + tx.from = Promise.all([ + this.getAddress(), + this.provider.resolveName(tx.from) + ]).then((results) => { + if (results[0] !== results[1]) { + logger$d.throwArgumentError("from address mismatch", "transaction", transaction); + } + return results[0]; + }); + } + if (tx.gasLimit == null) { + tx.gasLimit = this.estimateGas(tx).catch((error) => { + logger$d.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", Logger.errors.UNPREDICTABLE_GAS_LIMIT, { + tx: tx + }); + }); + } + if (tx.chainId == null) { + tx.chainId = this.getChainId(); + } + return resolveProperties(tx); + }); + } + /////////////////// + // Sub-classes SHOULD leave these alone + _checkProvider(operation) { + if (!this.provider) { + logger$d.throwError("missing provider", Logger.errors.UNSUPPORTED_OPERATION, { + operation: (operation || "_checkProvider") + }); + } + } + static isSigner(value) { + return !!(value && value._isSigner); + } +} +class VoidSigner extends Signer { + constructor(address, provider) { + logger$d.checkNew(new.target, VoidSigner); + super(); + defineReadOnly(this, "address", address); + defineReadOnly(this, "provider", provider || null); + } + getAddress() { + return Promise.resolve(this.address); + } + _fail(message, operation) { + return Promise.resolve().then(() => { + logger$d.throwError(message, Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); + }); + } + signMessage(message) { + return this._fail("VoidSigner cannot sign messages", "signMessage"); + } + signTransaction(transaction) { + return this._fail("VoidSigner cannot sign transactions", "signTransaction"); + } + connect(provider) { + return new VoidSigner(this.address, provider); + } +} + +const version$a = "contracts/5.0.0-beta.137"; + +"use strict"; +const logger$e = new Logger(version$a); +/////////////////////////////// +const allowedTransactionKeys$1 = { + chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +// Recursively replaces ENS names with promises to resolve the name and resolves all properties +function resolveAddresses(signerOrProvider, value, paramType) { + if (Array.isArray(paramType)) { + return Promise.all(paramType.map((paramType, index) => { + return resolveAddresses(signerOrProvider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); + })); + } + if (paramType.type === "address") { + return signerOrProvider.resolveName(value); + } + if (paramType.type === "tuple") { + return resolveAddresses(signerOrProvider, value, paramType.components); + } + if (paramType.baseType === "array") { + if (!Array.isArray(value)) { + throw new Error("invalid value for array"); + } + return Promise.all(value.map((v) => resolveAddresses(signerOrProvider, v, paramType.arrayChildren))); + } + return Promise.resolve(value); +} +function runMethod(contract, functionName, options) { + let method = contract.interface.functions[functionName]; + return function (...params) { + let tx = {}; + let blockTag = null; + // If 1 extra parameter was passed in, it contains overrides + if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === "object") { + tx = shallowCopy(params.pop()); + if (tx.blockTag != null) { + blockTag = tx.blockTag; + } + delete tx.blockTag; + // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") + for (let key in tx) { + if (!allowedTransactionKeys$1[key]) { + logger$e.throwError(("unknown transaxction override - " + key), "overrides", tx); + } + } + } + logger$e.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); + // Check overrides make sense + ["data", "to"].forEach(function (key) { + if (tx[key] != null) { + logger$e.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + } + }); + // If the contract was just deployed, wait until it is minded + if (contract.deployTransaction != null) { + tx.to = contract._deployed(blockTag).then(() => { + return contract.addressPromise; + }); + } + else { + tx.to = contract.addressPromise; + } + return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then((params) => { + tx.data = contract.interface.encodeFunctionData(method, params); + if (method.constant || options.callStatic) { + // Call (constant functions) always cost 0 ether + if (options.estimate) { + return Promise.resolve(Zero$1); + } + if (!contract.provider && !contract.signer) { + logger$e.throwError("call (constant functions) require a provider or signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" }); + } + // Check overrides make sense + ["gasLimit", "gasPrice", "value"].forEach(function (key) { + if (tx[key] != null) { + throw new Error("call cannot override " + key); + } + }); + if (options.transaction) { + return resolveProperties(tx); + } + return (contract.signer || contract.provider).call(tx, blockTag).then((value) => { + try { + let result = contract.interface.decodeFunctionResult(method, value); + if (method.outputs.length === 1) { + result = result[0]; + } + return result; + } + catch (error) { + if (error.code === Logger.errors.CALL_EXCEPTION) { + error.address = contract.address; + error.args = params; + error.transaction = tx; + } + throw error; + } + }); + } + // Only computing the transaction estimate + if (options.estimate) { + if (!contract.provider && !contract.signer) { + logger$e.throwError("estimate require a provider or signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); + } + return (contract.signer || contract.provider).estimateGas(tx); + } + if (tx.gasLimit == null && method.gas != null) { + tx.gasLimit = BigNumber.from(method.gas).add(21000); + } + if (tx.value != null && !method.payable) { + logger$e.throwArgumentError("contract method is not payable", "sendTransaction:" + method.format(), tx); + } + if (options.transaction) { + return resolveProperties(tx); + } + if (!contract.signer) { + logger$e.throwError("sending a transaction require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); + } + return contract.signer.sendTransaction(tx).then((tx) => { + let wait = tx.wait.bind(tx); + tx.wait = (confirmations) => { + return wait(confirmations).then((receipt) => { + receipt.events = receipt.logs.map((log) => { + let event = deepCopy(log); + let parsed = contract.interface.parseLog(log); + if (parsed) { + event.values = parsed.values; + event.decode = (data, topics) => { + return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.event = parsed.name; + event.eventSignature = parsed.signature; + } + event.removeListener = () => { return contract.provider; }; + event.getBlock = () => { + return contract.provider.getBlock(receipt.blockHash); + }; + event.getTransaction = () => { + return contract.provider.getTransaction(receipt.transactionHash); + }; + event.getTransactionReceipt = () => { + return Promise.resolve(receipt); + }; + return event; + }); + return receipt; + }); + }; + return tx; + }); + }); + }; +} +function getEventTag(filter) { + if (filter.address && (filter.topics == null || filter.topics.length === 0)) { + return "*"; + } + return (filter.address || "*") + "@" + (filter.topics ? filter.topics.join(":") : ""); +} +class RunningEvent { + constructor(tag, filter) { + defineReadOnly(this, "tag", tag); + defineReadOnly(this, "filter", filter); + this._listeners = []; + } + addListener(listener, once) { + this._listeners.push({ listener: listener, once: once }); + } + removeListener(listener) { + let done = false; + this._listeners = this._listeners.filter((item) => { + if (done || item.listener !== listener) { + return true; + } + done = true; + return false; + }); + } + removeAllListeners() { + this._listeners = []; + } + listeners() { + return this._listeners.map((i) => i.listener); + } + listenerCount() { + return this._listeners.length; + } + run(args) { + let listenerCount = this.listenerCount(); + this._listeners = this._listeners.filter((item) => { + let argsCopy = args.slice(); + // Call the callback in the next event loop + setTimeout(() => { + item.listener.apply(this, argsCopy); + }, 0); + // Reschedule it if it not "once" + return !(item.once); + }); + return listenerCount; + } + prepareEvent(event) { + } +} +class ErrorRunningEvent extends RunningEvent { + constructor() { + super("error", null); + } +} +class FragmentRunningEvent extends RunningEvent { + constructor(address, contractInterface, fragment, topics) { + let filter = { + address: address + }; + let topic = contractInterface.getEventTopic(fragment); + if (topics) { + if (topic !== topics[0]) { + logger$e.throwArgumentError("topic mismatch", "topics", topics); + } + filter.topics = topics.slice(); + } + else { + filter.topics = [topic]; + } + super(getEventTag(filter), filter); + defineReadOnly(this, "address", address); + defineReadOnly(this, "interface", contractInterface); + defineReadOnly(this, "fragment", fragment); + } + prepareEvent(event) { + super.prepareEvent(event); + event.event = this.fragment.name; + event.eventSignature = this.fragment.format(); + event.decode = (data, topics) => { + return this.interface.decodeEventLog(this.fragment, data, topics); + }; + event.values = this.interface.decodeEventLog(this.fragment, event.data, event.topics); + } +} +class WildcardRunningEvent extends RunningEvent { + constructor(address, contractInterface) { + super("*", { address: address }); + defineReadOnly(this, "address", address); + defineReadOnly(this, "interface", contractInterface); + } + prepareEvent(event) { + super.prepareEvent(event); + let parsed = this.interface.parseLog(event); + if (parsed) { + event.event = parsed.name; + event.eventSignature = parsed.signature; + event.decode = (data, topics) => { + return this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.values = parsed.values; + } + } +} +class Contract { + constructor(addressOrName, contractInterface, signerOrProvider) { + logger$e.checkNew(new.target, Contract); + // @TODO: Maybe still check the addressOrName looks like a valid address or name? + //address = getAddress(address); + defineReadOnly(this, "interface", getStatic((new.target), "getInterface")(contractInterface)); + if (Signer.isSigner(signerOrProvider)) { + defineReadOnly(this, "provider", signerOrProvider.provider || null); + defineReadOnly(this, "signer", signerOrProvider); + } + else if (Provider.isProvider(signerOrProvider)) { + defineReadOnly(this, "provider", signerOrProvider); + defineReadOnly(this, "signer", null); + } + else { + logger$e.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); + } + defineReadOnly(this, "callStatic", {}); + defineReadOnly(this, "estimate", {}); + defineReadOnly(this, "functions", {}); + defineReadOnly(this, "populateTransaction", {}); + defineReadOnly(this, "filters", {}); + Object.keys(this.interface.events).forEach((eventName) => { + let event = this.interface.events[eventName]; + defineReadOnly(this.filters, eventName, (...args) => { + return { + address: this.address, + topics: this.interface.encodeFilterTopics(event, args) + }; + }); + }); + defineReadOnly(this, "_runningEvents", {}); + defineReadOnly(this, "_wrappedEmits", {}); + defineReadOnly(this, "address", addressOrName); + if (this.provider) { + defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then((address) => { + if (address == null) { + throw new Error("name not found"); + } + return address; + }).catch((error) => { + console.log("ERROR: Cannot find Contract - " + addressOrName); + throw error; + })); + } + else { + try { + defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); + } + catch (error) { + // Without a provider, we cannot use ENS names + logger$e.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); + } + } + Object.keys(this.interface.functions).forEach((name) => { + let run = runMethod(this, name, {}); + if (this[name] == null) { + defineReadOnly(this, name, run); + } + if (this.functions[name] == null) { + defineReadOnly(this.functions, name, run); + } + if (this.callStatic[name] == null) { + defineReadOnly(this.callStatic, name, runMethod(this, name, { callStatic: true })); + } + if (this.populateTransaction[name] == null) { + defineReadOnly(this.populateTransaction, name, runMethod(this, name, { transaction: true })); + } + if (this.estimate[name] == null) { + defineReadOnly(this.estimate, name, runMethod(this, name, { estimate: true })); + } + }); + } + static getContractAddress(transaction) { + return getContractAddress(transaction); + } + static getInterface(contractInterface) { + if (Interface.isInterface(contractInterface)) { + return contractInterface; + } + return new Interface(contractInterface); + } + // @TODO: Allow timeout? + deployed() { + return this._deployed(); + } + _deployed(blockTag) { + if (!this._deployedPromise) { + // If we were just deployed, we know the transaction we should occur in + if (this.deployTransaction) { + this._deployedPromise = this.deployTransaction.wait().then(() => { + return this; + }); + } + else { + // @TODO: Once we allow a timeout to be passed in, we will wait + // up to that many blocks for getCode + // Otherwise, poll for our code to be deployed + this._deployedPromise = this.provider.getCode(this.address, blockTag).then((code) => { + if (code === "0x") { + logger$e.throwError("contract not deployed", Logger.errors.UNSUPPORTED_OPERATION, { + contractAddress: this.address, + operation: "getDeployed" + }); + } + return this; + }); + } + } + return this._deployedPromise; + } + // @TODO: + // estimateFallback(overrides?: TransactionRequest): Promise + // @TODO: + // estimateDeploy(bytecode: string, ...args): Promise + fallback(overrides) { + if (!this.signer) { + logger$e.throwError("sending a transaction require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + } + let tx = shallowCopy(overrides || {}); + ["from", "to"].forEach(function (key) { + if (tx[key] == null) { + return; + } + logger$e.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + tx.to = this.addressPromise; + return this.deployed().then(() => { + return this.signer.sendTransaction(tx); + }); + } + // Reconnect to a different signer or provider + connect(signerOrProvider) { + if (typeof (signerOrProvider) === "string") { + signerOrProvider = new VoidSigner(signerOrProvider, this.provider); + } + let contract = new (this.constructor)(this.address, this.interface, signerOrProvider); + if (this.deployTransaction) { + defineReadOnly(contract, "deployTransaction", this.deployTransaction); + } + return contract; + } + // Re-attach to a different on-chain instance of this contract + attach(addressOrName) { + return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider); + } + static isIndexed(value) { + return Indexed.isIndexed(value); + } + _normalizeRunningEvent(runningEvent) { + // Already have an instance of this event running; we can re-use it + if (this._runningEvents[runningEvent.tag]) { + return this._runningEvents[runningEvent.tag]; + } + return runningEvent; + } + _getRunningEvent(eventName) { + if (typeof (eventName) === "string") { + // Listen for "error" events (if your contract has an error event, include + // the full signature to bypass this special event keyword) + if (eventName === "error") { + return this._normalizeRunningEvent(new ErrorRunningEvent()); + } + // Listen for any event + if (eventName === "*") { + return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); + } + let fragment = this.interface.getEvent(eventName); + if (!fragment) { + logger$e.throwArgumentError("unknown event - " + eventName, "eventName", eventName); + } + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); + } + let filter = { + address: this.address + }; + // Find the matching event in the ABI; if none, we still allow filtering + // since it may be a filter for an otherwise unknown event + if (eventName.topics) { + if (eventName.topics[0]) { + let fragment = this.interface.getEvent(eventName.topics[0]); + if (fragment) { + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); + } + } + filter.topics = eventName.topics; + } + return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter)); + } + _checkRunningEvents(runningEvent) { + if (runningEvent.listenerCount() === 0) { + delete this._runningEvents[runningEvent.tag]; + } + // If we have a poller for this, remove it + let emit = this._wrappedEmits[runningEvent.tag]; + if (emit) { + this.provider.off(runningEvent.filter, emit); + delete this._wrappedEmits[runningEvent.tag]; + } + } + _wrapEvent(runningEvent, log, listener) { + let event = deepCopy(log); + try { + runningEvent.prepareEvent(event); + } + catch (error) { + this.emit("error", error); + throw error; + } + event.removeListener = () => { + if (!listener) { + return; + } + runningEvent.removeListener(listener); + this._checkRunningEvents(runningEvent); + }; + event.getBlock = () => { return this.provider.getBlock(log.blockHash); }; + event.getTransaction = () => { return this.provider.getTransaction(log.transactionHash); }; + event.getTransactionReceipt = () => { return this.provider.getTransactionReceipt(log.transactionHash); }; + return event; + } + _addEventListener(runningEvent, listener, once) { + if (!this.provider) { + logger$e.throwError("events require a provider or a signer with a provider", Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); + } + runningEvent.addListener(listener, once); + // Track this running event and its listeners (may already be there; but no hard in updating) + this._runningEvents[runningEvent.tag] = runningEvent; + // If we are not polling the provider, start + if (!this._wrappedEmits[runningEvent.tag]) { + let wrappedEmit = (log) => { + let event = this._wrapEvent(runningEvent, log, listener); + let values = (event.values || []); + values.push(event); + this.emit(runningEvent.filter, ...values); + }; + this._wrappedEmits[runningEvent.tag] = wrappedEmit; + // Special events, like "error" do not have a filter + if (runningEvent.filter != null) { + this.provider.on(runningEvent.filter, wrappedEmit); + } + } + } + queryFilter(event, fromBlockOrBlockhash, toBlock) { + let runningEvent = this._getRunningEvent(event); + let filter = shallowCopy(runningEvent.filter); + if (typeof (fromBlockOrBlockhash) === "string" && isHexString(fromBlockOrBlockhash, 32)) { + if (toBlock != null) { + logger$e.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); + } + filter.blockhash = fromBlockOrBlockhash; + } + else { + filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0); + filter.toBlock = ((toBlock != null) ? toBlock : "latest"); + } + return this.provider.getLogs(filter).then((logs) => { + return logs.map((log) => this._wrapEvent(runningEvent, log, null)); + }); + } + on(event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, false); + return this; + } + once(event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, true); + return this; + } + emit(eventName, ...args) { + if (!this.provider) { + return false; + } + let runningEvent = this._getRunningEvent(eventName); + let result = (runningEvent.run(args) > 0); + // May have drained all the "once" events; check for living events + this._checkRunningEvents(runningEvent); + return result; + } + listenerCount(eventName) { + if (!this.provider) { + return 0; + } + return this._getRunningEvent(eventName).listenerCount(); + } + listeners(eventName) { + if (!this.provider) { + return []; + } + if (eventName == null) { + let result = []; + for (let tag in this._runningEvents) { + this._runningEvents[tag].listeners().forEach((listener) => { + result.push(listener); + }); + } + return result; + } + return this._getRunningEvent(eventName).listeners(); + } + removeAllListeners(eventName) { + if (!this.provider) { + return this; + } + if (eventName == null) { + for (let tag in this._runningEvents) { + let runningEvent = this._runningEvents[tag]; + runningEvent.removeAllListeners(); + this._checkRunningEvents(runningEvent); + } + return this; + } + // Delete any listeners + let runningEvent = this._getRunningEvent(eventName); + runningEvent.removeAllListeners(); + this._checkRunningEvents(runningEvent); + return this; + } + off(eventName, listener) { + if (!this.provider) { + return this; + } + let runningEvent = this._getRunningEvent(eventName); + runningEvent.removeListener(listener); + this._checkRunningEvents(runningEvent); + return this; + } + removeListener(eventName, listener) { + return this.off(eventName, listener); + } +} +class ContractFactory { + constructor(contractInterface, bytecode, signer) { + let bytecodeHex = null; + if (typeof (bytecode) === "string") { + bytecodeHex = bytecode; + } + else if (isBytes(bytecode)) { + bytecodeHex = hexlify(bytecode); + } + else if (bytecode && typeof (bytecode.object) === "string") { + // Allow the bytecode object from the Solidity compiler + bytecodeHex = bytecode.object; + } + else { + // Crash in the next verification step + bytecodeHex = "!"; + } + // Make sure it is 0x prefixed + if (bytecodeHex.substring(0, 2) !== "0x") { + bytecodeHex = "0x" + bytecodeHex; + } + // Make sure the final result is valid bytecode + if (!isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { + logger$e.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + // If we have a signer, make sure it is valid + if (signer && !Signer.isSigner(signer)) { + logger$e.throwArgumentError("invalid signer", "signer", signer); + } + defineReadOnly(this, "bytecode", bytecodeHex); + defineReadOnly(this, "interface", getStatic((new.target), "getInterface")(contractInterface)); + defineReadOnly(this, "signer", signer || null); + } + getDeployTransaction(...args) { + let tx = {}; + // If we have 1 additional argument, we allow transaction overrides + if (args.length === this.interface.deploy.inputs.length + 1) { + tx = shallowCopy(args.pop()); + for (let key in tx) { + if (!allowedTransactionKeys$1[key]) { + throw new Error("unknown transaction override " + key); + } + } + } + // Do not allow these to be overridden in a deployment transaction + ["data", "from", "to"].forEach((key) => { + if (tx[key] == null) { + return; + } + logger$e.throwError("cannot override " + key, Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + // Make sure the call matches the constructor signature + logger$e.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + // Set the data to the bytecode + the encoded constructor arguments + tx.data = hexlify(concat([ + this.bytecode, + this.interface.encodeDeploy(args) + ])); + return tx; + } + deploy(...args) { + return resolveAddresses(this.signer, args, this.interface.deploy.inputs).then((args) => { + // Get the deployment transaction (with optional overrides) + let tx = this.getDeployTransaction(...args); + // Send the deployment transaction + return this.signer.sendTransaction(tx).then((tx) => { + let address = (this.constructor).getContractAddress(tx); + let contract = (this.constructor).getContract(address, this.interface, this.signer); + defineReadOnly(contract, "deployTransaction", tx); + return contract; + }); + }); + } + attach(address) { + return (this.constructor).getContract(address, this.interface, this.signer); + } + connect(signer) { + return new (this.constructor)(this.interface, this.bytecode, signer); + } + static fromSolidity(compilerOutput, signer) { + if (compilerOutput == null) { + logger$e.throwError("missing compiler output", Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + } + if (typeof (compilerOutput) === "string") { + compilerOutput = JSON.parse(compilerOutput); + } + let abi = compilerOutput.abi; + let bytecode = null; + if (compilerOutput.bytecode) { + bytecode = compilerOutput.bytecode; + } + else if (compilerOutput.evm && compilerOutput.evm.bytecode) { + bytecode = compilerOutput.evm.bytecode; + } + return new this(abi, bytecode, signer); + } + static getInterface(contractInterface) { + return Contract.getInterface(contractInterface); + } + static getContractAddress(tx) { + return getContractAddress(tx); + } + static getContract(address, contractInterface, signer) { + return new Contract(address, contractInterface, signer); + } +} + +/** + * var basex = require("base-x"); + * + * This implementation is heavily based on base-x. The main reason to + * deviate was to prevent the dependency of Buffer. + * + * Contributors: + * + * base-x encoding + * Forked from https://github.com/cryptocoinjs/bs58 + * Originally written by Mike Hearn for BitcoinJ + * Copyright (c) 2011 Google Inc + * Ported to JavaScript by Stefan Thomas + * Merged Buffer refactorings from base58-native by Stephen Pair + * Copyright (c) 2013 BitPay Inc + * + * The MIT License (MIT) + * + * Copyright base-x contributors (c) 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ +class BaseX { + constructor(alphabet) { + defineReadOnly(this, "alphabet", alphabet); + defineReadOnly(this, "base", alphabet.length); + defineReadOnly(this, "_alphabetMap", {}); + defineReadOnly(this, "_leader", alphabet.charAt(0)); + // pre-compute lookup table + for (let i = 0; i < alphabet.length; i++) { + this._alphabetMap[alphabet.charAt(i)] = i; + } + } + encode(value) { + let source = arrayify(value); + if (source.length === 0) { + return ""; + } + let digits = [0]; + for (let i = 0; i < source.length; ++i) { + let carry = source[i]; + for (let j = 0; j < digits.length; ++j) { + carry += digits[j] << 8; + digits[j] = carry % this.base; + carry = (carry / this.base) | 0; + } + while (carry > 0) { + digits.push(carry % this.base); + carry = (carry / this.base) | 0; + } + } + let string = ""; + // deal with leading zeros + for (let k = 0; source[k] === 0 && k < source.length - 1; ++k) { + string += this._leader; + } + // convert digits to a string + for (let q = digits.length - 1; q >= 0; --q) { + string += this.alphabet[digits[q]]; + } + return string; + } + decode(value) { + if (typeof (value) !== "string") { + throw new TypeError("Expected String"); + } + let bytes = []; + if (value.length === 0) { + return new Uint8Array(bytes); + } + bytes.push(0); + for (let i = 0; i < value.length; i++) { + let byte = this._alphabetMap[value[i]]; + if (byte === undefined) { + throw new Error("Non-base" + this.base + " character"); + } + let carry = byte; + for (let j = 0; j < bytes.length; ++j) { + carry += bytes[j] * this.base; + bytes[j] = carry & 0xff; + carry >>= 8; + } + while (carry > 0) { + bytes.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (let k = 0; value[k] === this._leader && k < value.length - 1; ++k) { + bytes.push(0); + } + return arrayify(new Uint8Array(bytes.reverse())); + } +} +const Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); +const Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); +//console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) +//console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) + +var minimalisticAssert = assert; + +function assert(val, msg) { + if (!val) + throw new Error(msg || 'Assertion failed'); +} + +assert.equal = function assertEqual(l, r, msg) { + if (l != r) + throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); +}; + +var inherits_browser = createCommonjsModule(function (module) { +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; +} +}); + +'use strict'; + + + + +var inherits_1 = inherits_browser; + +function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === 'string') { + if (!enc) { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } else if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } + } else { + for (i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + } + return res; +} +var toArray_1 = toArray; + +function toHex$1(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; +} +var toHex_1 = toHex$1; + +function htonl(w) { + var res = (w >>> 24) | + ((w >>> 8) & 0xff00) | + ((w << 8) & 0xff0000) | + ((w & 0xff) << 24); + return res >>> 0; +} +var htonl_1 = htonl; + +function toHex32(msg, endian) { + var res = ''; + for (var i = 0; i < msg.length; i++) { + var w = msg[i]; + if (endian === 'little') + w = htonl(w); + res += zero8(w.toString(16)); + } + return res; +} +var toHex32_1 = toHex32; + +function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; +} +var zero2_1 = zero2; + +function zero8(word) { + if (word.length === 7) + return '0' + word; + else if (word.length === 6) + return '00' + word; + else if (word.length === 5) + return '000' + word; + else if (word.length === 4) + return '0000' + word; + else if (word.length === 3) + return '00000' + word; + else if (word.length === 2) + return '000000' + word; + else if (word.length === 1) + return '0000000' + word; + else + return word; +} +var zero8_1 = zero8; + +function join32(msg, start, end, endian) { + var len = end - start; + minimalisticAssert(len % 4 === 0); + var res = new Array(len / 4); + for (var i = 0, k = start; i < res.length; i++, k += 4) { + var w; + if (endian === 'big') + w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; + else + w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; + res[i] = w >>> 0; + } + return res; +} +var join32_1 = join32; + +function split32(msg, endian) { + var res = new Array(msg.length * 4); + for (var i = 0, k = 0; i < msg.length; i++, k += 4) { + var m = msg[i]; + if (endian === 'big') { + res[k] = m >>> 24; + res[k + 1] = (m >>> 16) & 0xff; + res[k + 2] = (m >>> 8) & 0xff; + res[k + 3] = m & 0xff; + } else { + res[k + 3] = m >>> 24; + res[k + 2] = (m >>> 16) & 0xff; + res[k + 1] = (m >>> 8) & 0xff; + res[k] = m & 0xff; + } + } + return res; +} +var split32_1 = split32; + +function rotr32(w, b) { + return (w >>> b) | (w << (32 - b)); +} +var rotr32_1 = rotr32; + +function rotl32(w, b) { + return (w << b) | (w >>> (32 - b)); +} +var rotl32_1 = rotl32; + +function sum32(a, b) { + return (a + b) >>> 0; +} +var sum32_1 = sum32; + +function sum32_3(a, b, c) { + return (a + b + c) >>> 0; +} +var sum32_3_1 = sum32_3; + +function sum32_4(a, b, c, d) { + return (a + b + c + d) >>> 0; +} +var sum32_4_1 = sum32_4; + +function sum32_5(a, b, c, d, e) { + return (a + b + c + d + e) >>> 0; +} +var sum32_5_1 = sum32_5; + +function sum64(buf, pos, ah, al) { + var bh = buf[pos]; + var bl = buf[pos + 1]; + + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + buf[pos] = hi >>> 0; + buf[pos + 1] = lo; +} +var sum64_1 = sum64; + +function sum64_hi(ah, al, bh, bl) { + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + return hi >>> 0; +} +var sum64_hi_1 = sum64_hi; + +function sum64_lo(ah, al, bh, bl) { + var lo = al + bl; + return lo >>> 0; +} +var sum64_lo_1 = sum64_lo; + +function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + + var hi = ah + bh + ch + dh + carry; + return hi >>> 0; +} +var sum64_4_hi_1 = sum64_4_hi; + +function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { + var lo = al + bl + cl + dl; + return lo >>> 0; +} +var sum64_4_lo_1 = sum64_4_lo; + +function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + lo = (lo + el) >>> 0; + carry += lo < el ? 1 : 0; + + var hi = ah + bh + ch + dh + eh + carry; + return hi >>> 0; +} +var sum64_5_hi_1 = sum64_5_hi; + +function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var lo = al + bl + cl + dl + el; + + return lo >>> 0; +} +var sum64_5_lo_1 = sum64_5_lo; + +function rotr64_hi(ah, al, num) { + var r = (al << (32 - num)) | (ah >>> num); + return r >>> 0; +} +var rotr64_hi_1 = rotr64_hi; + +function rotr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; +} +var rotr64_lo_1 = rotr64_lo; + +function shr64_hi(ah, al, num) { + return ah >>> num; +} +var shr64_hi_1 = shr64_hi; + +function shr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; +} +var shr64_lo_1 = shr64_lo; + +var utils = { + inherits: inherits_1, + toArray: toArray_1, + toHex: toHex_1, + htonl: htonl_1, + toHex32: toHex32_1, + zero2: zero2_1, + zero8: zero8_1, + join32: join32_1, + split32: split32_1, + rotr32: rotr32_1, + rotl32: rotl32_1, + sum32: sum32_1, + sum32_3: sum32_3_1, + sum32_4: sum32_4_1, + sum32_5: sum32_5_1, + sum64: sum64_1, + sum64_hi: sum64_hi_1, + sum64_lo: sum64_lo_1, + sum64_4_hi: sum64_4_hi_1, + sum64_4_lo: sum64_4_lo_1, + sum64_5_hi: sum64_5_hi_1, + sum64_5_lo: sum64_5_lo_1, + rotr64_hi: rotr64_hi_1, + rotr64_lo: rotr64_lo_1, + shr64_hi: shr64_hi_1, + shr64_lo: shr64_lo_1 +}; + +'use strict'; + + + + +function BlockHash() { + this.pending = null; + this.pendingTotal = 0; + this.blockSize = this.constructor.blockSize; + this.outSize = this.constructor.outSize; + this.hmacStrength = this.constructor.hmacStrength; + this.padLength = this.constructor.padLength / 8; + this.endian = 'big'; + + this._delta8 = this.blockSize / 8; + this._delta32 = this.blockSize / 32; +} +var BlockHash_1 = BlockHash; + +BlockHash.prototype.update = function update(msg, enc) { + // Convert message to array, pad it, and join into 32bit blocks + msg = utils.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + + // Enough data, try updating + if (this.pending.length >= this._delta8) { + msg = this.pending; + + // Process pending data in blocks + var r = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r, msg.length); + if (this.pending.length === 0) + this.pending = null; + + msg = utils.join32(msg, 0, msg.length - r, this.endian); + for (var i = 0; i < msg.length; i += this._delta32) + this._update(msg, i, i + this._delta32); + } + + return this; +}; + +BlockHash.prototype.digest = function digest(enc) { + this.update(this._pad()); + minimalisticAssert(this.pending === null); + + return this._digest(enc); +}; + +BlockHash.prototype._pad = function pad() { + var len = this.pendingTotal; + var bytes = this._delta8; + var k = bytes - ((len + this.padLength) % bytes); + var res = new Array(k + this.padLength); + res[0] = 0x80; + for (var i = 1; i < k; i++) + res[i] = 0; + + // Append length + len <<= 3; + if (this.endian === 'big') { + for (var t = 8; t < this.padLength; t++) + res[i++] = 0; + + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = (len >>> 24) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = len & 0xff; + } else { + res[i++] = len & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 24) & 0xff; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + + for (t = 8; t < this.padLength; t++) + res[i++] = 0; + } + + return res; +}; + +var common = { + BlockHash: BlockHash_1 +}; + +var _1 = {}; + +var _224 = {}; + +'use strict'; + + +var rotr32$1 = utils.rotr32; + +function ft_1(s, x, y, z) { + if (s === 0) + return ch32(x, y, z); + if (s === 1 || s === 3) + return p32(x, y, z); + if (s === 2) + return maj32(x, y, z); +} +var ft_1_1 = ft_1; + +function ch32(x, y, z) { + return (x & y) ^ ((~x) & z); +} +var ch32_1 = ch32; + +function maj32(x, y, z) { + return (x & y) ^ (x & z) ^ (y & z); +} +var maj32_1 = maj32; + +function p32(x, y, z) { + return x ^ y ^ z; +} +var p32_1 = p32; + +function s0_256(x) { + return rotr32$1(x, 2) ^ rotr32$1(x, 13) ^ rotr32$1(x, 22); +} +var s0_256_1 = s0_256; + +function s1_256(x) { + return rotr32$1(x, 6) ^ rotr32$1(x, 11) ^ rotr32$1(x, 25); +} +var s1_256_1 = s1_256; + +function g0_256(x) { + return rotr32$1(x, 7) ^ rotr32$1(x, 18) ^ (x >>> 3); +} +var g0_256_1 = g0_256; + +function g1_256(x) { + return rotr32$1(x, 17) ^ rotr32$1(x, 19) ^ (x >>> 10); +} +var g1_256_1 = g1_256; + +var common$1 = { + ft_1: ft_1_1, + ch32: ch32_1, + maj32: maj32_1, + p32: p32_1, + s0_256: s0_256_1, + s1_256: s1_256_1, + g0_256: g0_256_1, + g1_256: g1_256_1 +}; + +'use strict'; + + + + + + +var sum32$1 = utils.sum32; +var sum32_4$1 = utils.sum32_4; +var sum32_5$1 = utils.sum32_5; +var ch32$1 = common$1.ch32; +var maj32$1 = common$1.maj32; +var s0_256$1 = common$1.s0_256; +var s1_256$1 = common$1.s1_256; +var g0_256$1 = common$1.g0_256; +var g1_256$1 = common$1.g1_256; + +var BlockHash$1 = common.BlockHash; + +var sha256_K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 +]; + +function SHA256() { + if (!(this instanceof SHA256)) + return new SHA256(); + + BlockHash$1.call(this); + this.h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ]; + this.k = sha256_K; + this.W = new Array(64); +} +utils.inherits(SHA256, BlockHash$1); +var _256 = SHA256; + +SHA256.blockSize = 512; +SHA256.outSize = 256; +SHA256.hmacStrength = 192; +SHA256.padLength = 64; + +SHA256.prototype._update = function _update(msg, start) { + var W = this.W; + + for (var i = 0; i < 16; i++) + W[i] = msg[start + i]; + for (; i < W.length; i++) + W[i] = sum32_4$1(g1_256$1(W[i - 2]), W[i - 7], g0_256$1(W[i - 15]), W[i - 16]); + + var a = this.h[0]; + var b = this.h[1]; + var c = this.h[2]; + var d = this.h[3]; + var e = this.h[4]; + var f = this.h[5]; + var g = this.h[6]; + var h = this.h[7]; + + minimalisticAssert(this.k.length === W.length); + for (i = 0; i < W.length; i++) { + var T1 = sum32_5$1(h, s1_256$1(e), ch32$1(e, f, g), this.k[i], W[i]); + var T2 = sum32$1(s0_256$1(a), maj32$1(a, b, c)); + h = g; + g = f; + f = e; + e = sum32$1(d, T1); + d = c; + c = b; + b = a; + a = sum32$1(T1, T2); + } + + this.h[0] = sum32$1(this.h[0], a); + this.h[1] = sum32$1(this.h[1], b); + this.h[2] = sum32$1(this.h[2], c); + this.h[3] = sum32$1(this.h[3], d); + this.h[4] = sum32$1(this.h[4], e); + this.h[5] = sum32$1(this.h[5], f); + this.h[6] = sum32$1(this.h[6], g); + this.h[7] = sum32$1(this.h[7], h); +}; + +SHA256.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +var _384 = {}; + +'use strict'; + + + + + +var rotr64_hi$1 = utils.rotr64_hi; +var rotr64_lo$1 = utils.rotr64_lo; +var shr64_hi$1 = utils.shr64_hi; +var shr64_lo$1 = utils.shr64_lo; +var sum64$1 = utils.sum64; +var sum64_hi$1 = utils.sum64_hi; +var sum64_lo$1 = utils.sum64_lo; +var sum64_4_hi$1 = utils.sum64_4_hi; +var sum64_4_lo$1 = utils.sum64_4_lo; +var sum64_5_hi$1 = utils.sum64_5_hi; +var sum64_5_lo$1 = utils.sum64_5_lo; + +var BlockHash$2 = common.BlockHash; + +var sha512_K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 +]; + +function SHA512() { + if (!(this instanceof SHA512)) + return new SHA512(); + + BlockHash$2.call(this); + this.h = [ + 0x6a09e667, 0xf3bcc908, + 0xbb67ae85, 0x84caa73b, + 0x3c6ef372, 0xfe94f82b, + 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, + 0x9b05688c, 0x2b3e6c1f, + 0x1f83d9ab, 0xfb41bd6b, + 0x5be0cd19, 0x137e2179 ]; + this.k = sha512_K; + this.W = new Array(160); +} +utils.inherits(SHA512, BlockHash$2); +var _512 = SHA512; + +SHA512.blockSize = 1024; +SHA512.outSize = 512; +SHA512.hmacStrength = 192; +SHA512.padLength = 128; + +SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { + var W = this.W; + + // 32 x 32bit words + for (var i = 0; i < 32; i++) + W[i] = msg[start + i]; + for (; i < W.length; i += 2) { + var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 + var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); + var c1_hi = W[i - 14]; // i - 7 + var c1_lo = W[i - 13]; + var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 + var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); + var c3_hi = W[i - 32]; // i - 16 + var c3_lo = W[i - 31]; + + W[i] = sum64_4_hi$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + W[i + 1] = sum64_4_lo$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + } +}; + +SHA512.prototype._update = function _update(msg, start) { + this._prepareBlock(msg, start); + + var W = this.W; + + var ah = this.h[0]; + var al = this.h[1]; + var bh = this.h[2]; + var bl = this.h[3]; + var ch = this.h[4]; + var cl = this.h[5]; + var dh = this.h[6]; + var dl = this.h[7]; + var eh = this.h[8]; + var el = this.h[9]; + var fh = this.h[10]; + var fl = this.h[11]; + var gh = this.h[12]; + var gl = this.h[13]; + var hh = this.h[14]; + var hl = this.h[15]; + + minimalisticAssert(this.k.length === W.length); + for (var i = 0; i < W.length; i += 2) { + var c0_hi = hh; + var c0_lo = hl; + var c1_hi = s1_512_hi(eh, el); + var c1_lo = s1_512_lo(eh, el); + var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); + var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); + var c3_hi = this.k[i]; + var c3_lo = this.k[i + 1]; + var c4_hi = W[i]; + var c4_lo = W[i + 1]; + + var T1_hi = sum64_5_hi$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + var T1_lo = sum64_5_lo$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + + c0_hi = s0_512_hi(ah, al); + c0_lo = s0_512_lo(ah, al); + c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); + c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); + + var T2_hi = sum64_hi$1(c0_hi, c0_lo, c1_hi, c1_lo); + var T2_lo = sum64_lo$1(c0_hi, c0_lo, c1_hi, c1_lo); + + hh = gh; + hl = gl; + + gh = fh; + gl = fl; + + fh = eh; + fl = el; + + eh = sum64_hi$1(dh, dl, T1_hi, T1_lo); + el = sum64_lo$1(dl, dl, T1_hi, T1_lo); + + dh = ch; + dl = cl; + + ch = bh; + cl = bl; + + bh = ah; + bl = al; + + ah = sum64_hi$1(T1_hi, T1_lo, T2_hi, T2_lo); + al = sum64_lo$1(T1_hi, T1_lo, T2_hi, T2_lo); + } + + sum64$1(this.h, 0, ah, al); + sum64$1(this.h, 2, bh, bl); + sum64$1(this.h, 4, ch, cl); + sum64$1(this.h, 6, dh, dl); + sum64$1(this.h, 8, eh, el); + sum64$1(this.h, 10, fh, fl); + sum64$1(this.h, 12, gh, gl); + sum64$1(this.h, 14, hh, hl); +}; + +SHA512.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); +}; + +function ch64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ ((~xh) & zh); + if (r < 0) + r += 0x100000000; + return r; +} + +function ch64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ ((~xl) & zl); + if (r < 0) + r += 0x100000000; + return r; +} + +function maj64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); + if (r < 0) + r += 0x100000000; + return r; +} + +function maj64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); + if (r < 0) + r += 0x100000000; + return r; +} + +function s0_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 28); + var c1_hi = rotr64_hi$1(xl, xh, 2); // 34 + var c2_hi = rotr64_hi$1(xl, xh, 7); // 39 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function s0_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 28); + var c1_lo = rotr64_lo$1(xl, xh, 2); // 34 + var c2_lo = rotr64_lo$1(xl, xh, 7); // 39 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function s1_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 14); + var c1_hi = rotr64_hi$1(xh, xl, 18); + var c2_hi = rotr64_hi$1(xl, xh, 9); // 41 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function s1_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 14); + var c1_lo = rotr64_lo$1(xh, xl, 18); + var c2_lo = rotr64_lo$1(xl, xh, 9); // 41 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function g0_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 1); + var c1_hi = rotr64_hi$1(xh, xl, 8); + var c2_hi = shr64_hi$1(xh, xl, 7); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function g0_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 1); + var c1_lo = rotr64_lo$1(xh, xl, 8); + var c2_lo = shr64_lo$1(xh, xl, 7); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +function g1_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 19); + var c1_hi = rotr64_hi$1(xl, xh, 29); // 61 + var c2_hi = shr64_hi$1(xh, xl, 6); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; +} + +function g1_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 19); + var c1_lo = rotr64_lo$1(xl, xh, 29); // 61 + var c2_lo = shr64_lo$1(xh, xl, 6); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; +} + +'use strict'; + +var sha1 = _1; +var sha224 = _224; +var sha256 = _256; +var sha384 = _384; +var sha512 = _512; + +var sha = { + sha1: sha1, + sha224: sha224, + sha256: sha256, + sha384: sha384, + sha512: sha512 +}; + +'use strict'; + + + + +var rotl32$1 = utils.rotl32; +var sum32$2 = utils.sum32; +var sum32_3$1 = utils.sum32_3; +var sum32_4$2 = utils.sum32_4; +var BlockHash$3 = common.BlockHash; + +function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + + BlockHash$3.call(this); + + this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; + this.endian = 'little'; +} +utils.inherits(RIPEMD160, BlockHash$3); +var ripemd160 = RIPEMD160; + +RIPEMD160.blockSize = 512; +RIPEMD160.outSize = 160; +RIPEMD160.hmacStrength = 192; +RIPEMD160.padLength = 64; + +RIPEMD160.prototype._update = function update(msg, start) { + var A = this.h[0]; + var B = this.h[1]; + var C = this.h[2]; + var D = this.h[3]; + var E = this.h[4]; + var Ah = A; + var Bh = B; + var Ch = C; + var Dh = D; + var Eh = E; + for (var j = 0; j < 80; j++) { + var T = sum32$2( + rotl32$1( + sum32_4$2(A, f(j, B, C, D), msg[r[j] + start], K(j)), + s[j]), + E); + A = E; + E = D; + D = rotl32$1(C, 10); + C = B; + B = T; + T = sum32$2( + rotl32$1( + sum32_4$2(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), + sh[j]), + Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32$1(Ch, 10); + Ch = Bh; + Bh = T; + } + T = sum32_3$1(this.h[1], C, Dh); + this.h[1] = sum32_3$1(this.h[2], D, Eh); + this.h[2] = sum32_3$1(this.h[3], E, Ah); + this.h[3] = sum32_3$1(this.h[4], A, Bh); + this.h[4] = sum32_3$1(this.h[0], B, Ch); + this.h[0] = T; +}; + +RIPEMD160.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'little'); + else + return utils.split32(this.h, 'little'); +}; + +function f(j, x, y, z) { + if (j <= 15) + return x ^ y ^ z; + else if (j <= 31) + return (x & y) | ((~x) & z); + else if (j <= 47) + return (x | (~y)) ^ z; + else if (j <= 63) + return (x & z) | (y & (~z)); + else + return x ^ (y | (~z)); +} + +function K(j) { + if (j <= 15) + return 0x00000000; + else if (j <= 31) + return 0x5a827999; + else if (j <= 47) + return 0x6ed9eba1; + else if (j <= 63) + return 0x8f1bbcdc; + else + return 0xa953fd4e; +} + +function Kh(j) { + if (j <= 15) + return 0x50a28be6; + else if (j <= 31) + return 0x5c4dd124; + else if (j <= 47) + return 0x6d703ef3; + else if (j <= 63) + return 0x7a6d76e9; + else + return 0x00000000; +} + +var r = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 +]; + +var rh = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 +]; + +var s = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 +]; + +var sh = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 +]; + +var ripemd = { + ripemd160: ripemd160 +}; + +'use strict'; + + + + +function Hmac(hash, key, enc) { + if (!(this instanceof Hmac)) + return new Hmac(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + + this._init(utils.toArray(key, enc)); +} +var hmac = Hmac; + +Hmac.prototype._init = function init(key) { + // Shorten key, if needed + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + minimalisticAssert(key.length <= this.blockSize); + + // Add padding to key + for (var i = key.length; i < this.blockSize; i++) + key.push(0); + + for (i = 0; i < key.length; i++) + key[i] ^= 0x36; + this.inner = new this.Hash().update(key); + + // 0x36 ^ 0x5c = 0x6a + for (i = 0; i < key.length; i++) + key[i] ^= 0x6a; + this.outer = new this.Hash().update(key); +}; + +Hmac.prototype.update = function update(msg, enc) { + this.inner.update(msg, enc); + return this; +}; + +Hmac.prototype.digest = function digest(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); +}; + +var hash_1 = createCommonjsModule(function (module, exports) { +var hash = exports; + +hash.utils = utils; +hash.common = common; +hash.sha = sha; +hash.ripemd = ripemd; +hash.hmac = hmac; + +// Proxy hash functions to the main object +hash.sha1 = hash.sha.sha1; +hash.sha256 = hash.sha.sha256; +hash.sha224 = hash.sha.sha224; +hash.sha384 = hash.sha.sha384; +hash.sha512 = hash.sha.sha512; +hash.ripemd160 = hash.ripemd.ripemd160; +}); + +var _version = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.version = "sha2/5.0.0-beta.129"; +}); + +var _version$1 = unwrapExports(_version); +var _version_1 = _version.version; + +var browser = createCommonjsModule(function (module$2, exports) { +"use strict"; +var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +var hash = __importStar(hash_1); + + + +var logger = new module.Logger(_version.version); +var SupportedAlgorithms; +(function (SupportedAlgorithms) { + SupportedAlgorithms["sha256"] = "sha256"; + SupportedAlgorithms["sha512"] = "sha512"; +})(SupportedAlgorithms = exports.SupportedAlgorithms || (exports.SupportedAlgorithms = {})); +; +function ripemd160(data) { + return "0x" + (hash.ripemd160().update(module$1.arrayify(data)).digest("hex")); +} +exports.ripemd160 = ripemd160; +function sha256(data) { + return "0x" + (hash.sha256().update(module$1.arrayify(data)).digest("hex")); +} +exports.sha256 = sha256; +function sha512(data) { + return "0x" + (hash.sha512().update(module$1.arrayify(data)).digest("hex")); +} +exports.sha512 = sha512; +function computeHmac(algorithm, key, data) { + if (!SupportedAlgorithms[algorithm]) { + logger.throwError("unsupported algorithm " + algorithm, module.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "hmac", + algorithm: algorithm + }); + } + return "0x" + hash.hmac(hash[algorithm], module$1.arrayify(key)).update(module$1.arrayify(data)).digest("hex"); +} +exports.computeHmac = computeHmac; +}); + +var browser$1 = unwrapExports(browser); +var browser_1 = browser.SupportedAlgorithms; +var browser_2 = browser.ripemd160; +var browser_3 = browser.sha256; +var browser_4 = browser.sha512; +var browser_5 = browser.computeHmac; + +var browser$2 = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + +function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { + password = module$1.arrayify(password); + salt = module$1.arrayify(salt); + var hLen; + var l = 1; + var DK = new Uint8Array(keylen); + var block1 = new Uint8Array(salt.length + 4); + block1.set(salt); + //salt.copy(block1, 0, 0, salt.length) + var r; + var T; + for (var i = 1; i <= l; i++) { + //block1.writeUInt32BE(i, salt.length) + block1[salt.length] = (i >> 24) & 0xff; + block1[salt.length + 1] = (i >> 16) & 0xff; + block1[salt.length + 2] = (i >> 8) & 0xff; + block1[salt.length + 3] = i & 0xff; + //let U = createHmac(password).update(block1).digest(); + var U = module$1.arrayify(browser.computeHmac(hashAlgorithm, password, block1)); + if (!hLen) { + hLen = U.length; + T = new Uint8Array(hLen); + l = Math.ceil(keylen / hLen); + r = keylen - (l - 1) * hLen; + } + //U.copy(T, 0, 0, hLen) + T.set(U); + for (var j = 1; j < iterations; j++) { + //U = createHmac(password).update(U).digest(); + U = module$1.arrayify(browser.computeHmac(hashAlgorithm, password, U)); + for (var k = 0; k < hLen; k++) + T[k] ^= U[k]; + } + var destPos = (i - 1) * hLen; + var len = (i === l ? r : hLen); + //T.copy(DK, destPos, 0, len) + DK.set(module$1.arrayify(T).slice(0, len), destPos); + } + return module$1.hexlify(DK); +} +exports.pbkdf2 = pbkdf2; +}); + +var browser$3 = unwrapExports(browser$2); +var browser_1$1 = browser$2.pbkdf2; + +var version$b = "6.5.0"; +var _package = { + version: version$b +}; + +var _package$1 = /*#__PURE__*/Object.freeze({ + version: version$b, + 'default': _package +}); + +var utils_1 = createCommonjsModule(function (module, exports) { +'use strict'; + +var utils = exports; + +function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== 'string') { + for (var i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + return res; + } + if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (var i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } else { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } + return res; +} +utils.toArray = toArray; + +function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; +} +utils.zero2 = zero2; + +function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; +} +utils.toHex = toHex; + +utils.encode = function encode(arr, enc) { + if (enc === 'hex') + return toHex(arr); + else + return arr; +}; +}); + +var utils_1$1 = createCommonjsModule(function (module, exports) { +'use strict'; + +var utils = exports; + + + + +utils.assert = minimalisticAssert; +utils.toArray = utils_1.toArray; +utils.zero2 = utils_1.zero2; +utils.toHex = utils_1.toHex; +utils.encode = utils_1.encode; + +// Represent num in a w-NAF form +function getNAF(num, w) { + var naf = []; + var ws = 1 << (w + 1); + var k = num.clone(); + while (k.cmpn(1) >= 0) { + var z; + if (k.isOdd()) { + var mod = k.andln(ws - 1); + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } + naf.push(z); + + // Optimization, shift by word if possible + var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; + for (var i = 1; i < shift; i++) + naf.push(0); + k.iushrn(shift); + } + + return naf; +} +utils.getNAF = getNAF; + +// Represent k1, k2 in a Joint Sparse Form +function getJSF(k1, k2) { + var jsf = [ + [], + [] + ]; + + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + var m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + var m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); + + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } + + return jsf; +} +utils.getJSF = getJSF; + +function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; +} +utils.cachedProperty = cachedProperty; + +function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; +} +utils.parseBytes = parseBytes; + +function intFromLE(bytes) { + return new bn(bytes, 'hex', 'le'); +} +utils.intFromLE = intFromLE; +}); + +var brorand = function(length) { var result = new Uint8Array(length); (commonjsGlobal.crypto || commonjsGlobal.msCrypto).getRandomValues(result); return result; }; + +'use strict'; + + + +var getNAF = utils_1$1.getNAF; +var getJSF = utils_1$1.getJSF; +var assert$1 = utils_1$1.assert; + +function BaseCurve(type, conf) { + this.type = type; + this.p = new bn(conf.p, 16); + + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? bn.red(conf.prime) : bn.mont(this.p); + + // Useful for many curves + this.zero = new bn(0).toRed(this.red); + this.one = new bn(1).toRed(this.red); + this.two = new bn(2).toRed(this.red); + + // Curve configuration, optional + this.n = conf.n && new bn(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } +} +var base = BaseCurve; + +BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); +}; + +BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert$1(p.precomputed); + var doubles = p._getDoubles(); + + var naf = getNAF(k, 1); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + for (var j = 0; j < naf.length; j += doubles.step) { + var nafW = 0; + for (var k = j + doubles.step - 1; k >= j; k--) + nafW = (nafW << 1) + naf[k]; + repr.push(nafW); + } + + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (var j = 0; j < repr.length; j++) { + var nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); + } + return a.toP(); +}; + +BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; + + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; + + // Get NAF form + var naf = getNAF(k, w); + + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var k = 0; i >= 0 && naf[i] === 0; i--) + k++; + if (i >= 0) + k++; + acc = acc.dblp(k); + + if (i < 0) + break; + var z = naf[i]; + assert$1(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } + } + return p.type === 'affine' ? acc.toP() : acc; +}; + +BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + for (var i = 0; i < len; i++) { + var p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; + } + + // Comb small window NAFs + for (var i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a]); + naf[b] = getNAF(coeffs[b], wndWidth[b]); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } + + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b] /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); + } else { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3 /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (var j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (var i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (var j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; + } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) + break; + + for (var j = 0; j < len; j++) { + var z = tmp[j]; + var p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (var i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); +}; + +function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; +} +BaseCurve.BasePoint = BasePoint; + +BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); +}; + +BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); +}; + +BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils_1$1.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert$1(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert$1(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); + } + throw new Error('Unknown point format'); +}; + +BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); +}; + +BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; +}; + +BasePoint.prototype.encode = function encode(enc, compact) { + return utils_1$1.encode(this._encode(compact), enc); +}; + +BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; +}; + +BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); +}; + +BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step, + points: doubles + }; +}; + +BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res + }; +}; + +BasePoint.prototype._getBeta = function _getBeta() { + return null; +}; + +BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; +}; + +'use strict'; + + + + + + +var assert$2 = utils_1$1.assert; + +function ShortCurve(conf) { + base.call(this, 'short', conf); + + this.a = new bn(conf.a, 16).toRed(this.red); + this.b = new bn(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); +} +inherits_browser(ShortCurve, base); +var short_1 = ShortCurve; + +ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new bn(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new bn(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert$2(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new bn(vec.a, 16), + b: new bn(vec.b, 16) + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + + return { + beta: beta, + lambda: lambda, + basis: basis + }; +}; + +ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : bn.mont(num); + var tinv = new bn(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + + var s = new bn(3).toRed(red).redNeg().redSqrt().redMul(tinv); + + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; +}; + +ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new bn(1); + var y1 = new bn(0); + var x2 = new bn(0); + var y2 = new bn(1); + + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; + + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); + + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; + + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; + + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } + + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } + + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 } + ]; +}; + +ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; + + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); + + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); + + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; +}; + +ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new bn(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); +}; + +ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; + + var x = point.x; + var y = point.y; + + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; +}; + +ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); + + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } + + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); + + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; +}; + +function Point(curve, x, y, isRed) { + base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new bn(x, 16); + this.y = new bn(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } +} +inherits_browser(Point, base.BasePoint); + +ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); +}; + +ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); +}; + +Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul) + } + }; + } + return beta; +}; + +Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + } ]; +}; + +Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } + + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)) + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)) + } + }; + return res; +}; + +Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +Point.prototype.isInfinity = function isInfinity() { + return this.inf; +}; + +Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; + + // P + O = P + if (p.inf) + return this; + + // P + P = 2P + if (this.eq(p)) + return this.dbl(); + + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); + + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); + + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.dbl = function dbl() { + if (this.inf) + return this; + + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + + var a = this.curve.a; + + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); + + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); +}; + +Point.prototype.getX = function getX() { + return this.x.fromRed(); +}; + +Point.prototype.getY = function getY() { + return this.y.fromRed(); +}; + +Point.prototype.mul = function mul(k) { + k = new bn(k, 16); + + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); + else + return this.curve._wnafMul(this, k); +}; + +Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); +}; + +Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); +}; + +Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); +}; + +Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate) + } + }; + } + return res; +}; + +Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; +}; + +function JPoint(curve, x, y, z) { + base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new bn(0); + } else { + this.x = new bn(x, 16); + this.y = new bn(y, 16); + this.z = new bn(z, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + + this.zOne = this.z === this.curve.one; +} +inherits_browser(JPoint, base.BasePoint); + +ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); +}; + +JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + + return this.curve.point(ax, ay); +}; + +JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); +}; + +JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) + return this; + + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); + + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (var i = 0; i < pow; i++) + r = r.dbl(); + return r; + } + + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; + + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + // Reuse results + var jyd = jy.redAdd(jy); + for (var i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); + + jx = nx; + jz = nz; + jyd = dny; + } + + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); +}; + +JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); +}; + +JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; + + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + + return this.curve.jpoint(nx, ny, nz); +}; + +JPoint.prototype.mul = function mul(k, kbase) { + k = new bn(k, kbase); + + return this.curve._wnafMul(this, k); +}; + +JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); + + if (this === p) + return true; + + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; + + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; +}; + +JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } +}; + +JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; +}; + +JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; +}; + +var mont = {}; + +var edwards = {}; + +var curve_1 = createCommonjsModule(function (module, exports) { +'use strict'; + +var curve = exports; + +curve.base = base; +curve.short = short_1; +curve.mont = mont; +curve.edwards = edwards; +}); + +var secp256k1 = undefined; + +var curves_1 = createCommonjsModule(function (module, exports) { +'use strict'; + +var curves = exports; + + + + + +var assert = utils_1$1.assert; + +function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve_1.short(options); + else if (options.type === 'edwards') + this.curve = new curve_1.edwards(options); + else + this.curve = new curve_1.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); +} +curves.PresetCurve = PresetCurve; + +function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve + }); + return curve; + } + }); +} + +defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash_1.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' + ] +}); + +defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash_1.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' + ] +}); + +defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash_1.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' + ] +}); + +defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash_1.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' + ] +}); + +defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash_1.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650' + ] +}); + +defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash_1.sha256, + gRed: false, + g: [ + '9' + ] +}); + +defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash_1.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', + + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658' + ] +}); + +var pre; +try { + pre = secp256k1; +} catch (e) { + pre = undefined; +} + +defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash_1.sha256, + + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3' + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15' + } + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre + ] +}); +}); + +'use strict'; + + + + + +function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + + this._reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + + var entropy = utils_1.toArray(options.entropy, options.entropyEnc || 'hex'); + var nonce = utils_1.toArray(options.nonce, options.nonceEnc || 'hex'); + var pers = utils_1.toArray(options.pers, options.persEnc || 'hex'); + minimalisticAssert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + this._init(entropy, nonce, pers); +} +var hmacDrbg = HmacDRBG; + +HmacDRBG.prototype._init = function init(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i = 0; i < this.V.length; i++) { + this.K[i] = 0x00; + this.V[i] = 0x01; + } + + this._update(seed); + this._reseed = 1; + this.reseedInterval = 0x1000000000000; // 2^48 +}; + +HmacDRBG.prototype._hmac = function hmac() { + return new hash_1.hmac(this.hash, this.K); +}; + +HmacDRBG.prototype._update = function update(seed) { + var kmac = this._hmac() + .update(this.V) + .update([ 0x00 ]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + + this.K = this._hmac() + .update(this.V) + .update([ 0x01 ]) + .update(seed) + .digest(); + this.V = this._hmac().update(this.V).digest(); +}; + +HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { + // Optional entropy enc + if (typeof entropyEnc !== 'string') { + addEnc = add; + add = entropyEnc; + entropyEnc = null; + } + + entropy = utils_1.toArray(entropy, entropyEnc); + add = utils_1.toArray(add, addEnc); + + minimalisticAssert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + + this._update(entropy.concat(add || [])); + this._reseed = 1; +}; + +HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { + if (this._reseed > this.reseedInterval) + throw new Error('Reseed is required'); + + // Optional encoding + if (typeof enc !== 'string') { + addEnc = add; + add = enc; + enc = null; + } + + // Optional additional data + if (add) { + add = utils_1.toArray(add, addEnc || 'hex'); + this._update(add); + } + + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + + var res = temp.slice(0, len); + this._update(add); + this._reseed++; + return utils_1.encode(res, enc); +}; + +'use strict'; + + + +var assert$3 = utils_1$1.assert; + +function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); +} +var key = KeyPair; + +KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + + return new KeyPair(ec, { + pub: pub, + pubEnc: enc + }); +}; + +KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + + return new KeyPair(ec, { + priv: priv, + privEnc: enc + }); +}; + +KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); + + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; + + return { result: true, reason: null }; +}; + +KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); +}; + +KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; +}; + +KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new bn(key, enc || 16); + + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); +}; + +KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert$3(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert$3(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); +}; + +// ECDH +KeyPair.prototype.derive = function derive(pub) { + return pub.mul(this.priv).getX(); +}; + +// ECDSA +KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); +}; + +KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); +}; + +KeyPair.prototype.inspect = function inspect() { + return ''; +}; + +'use strict'; + + + + +var assert$4 = utils_1$1.assert; + +function Signature(options, enc) { + if (options instanceof Signature) + return options; + + if (this._importDER(options, enc)) + return; + + assert$4(options.r && options.s, 'Signature without r or s'); + this.r = new bn(options.r, 16); + this.s = new bn(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; +} +var signature = Signature; + +function Position() { + this.place = 0; +} + +function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + } + p.place = off; + return val; +} + +function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; + } + if (i === 0) { + return buf; + } + return buf.slice(i); +} + +Signature.prototype._importDER = function _importDER(data, enc) { + data = utils_1$1.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0 && (r[1] & 0x80)) { + r = r.slice(1); + } + if (s[0] === 0 && (s[1] & 0x80)) { + s = s.slice(1); + } + + this.r = new bn(r); + this.s = new bn(s); + this.recoveryParam = null; + + return true; +}; + +function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); +} + +Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); + + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); + + r = rmPadding(r); + s = rmPadding(s); + + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils_1$1.encode(res, enc); +}; + +'use strict'; + + + + + + +var assert$5 = utils_1$1.assert; + + + + +function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert$5(curves_1.hasOwnProperty(options), 'Unknown curve ' + options); + + options = curves_1[options]; + } + + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves_1.PresetCurve) + options = { curve: options }; + + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; +} +var ec = EC; + +EC.prototype.keyPair = function keyPair(options) { + return new key(this, options); +}; + +EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return key.fromPrivate(this, priv, enc); +}; + +EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return key.fromPublic(this, pub, enc); +}; + +EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + + // Instantiate Hmac_DRBG + var drbg = new hmacDrbg({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || brorand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray() + }); + + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new bn(2)); + do { + var priv = new bn(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; + + priv.iaddn(1); + return this.keyFromPrivate(priv); + } while (true); +}; + +EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; +}; + +EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; + + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new bn(msg, 16)); + + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); + + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); + + // Instantiate Hmac_DRBG + var drbg = new hmacDrbg({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8' + }); + + // Number of bytes to generate + var ns1 = this.n.sub(new bn(1)); + + for (var iter = 0; true; iter++) { + var k = options.k ? + options.k(iter) : + new bn(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; + + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; + + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; + + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; + + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); + + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } + + return new signature({ r: r, s: s, recoveryParam: recoveryParam }); + } +}; + +EC.prototype.verify = function verify(msg, signature$1, key, enc) { + msg = this._truncateToN(new bn(msg, 16)); + key = this.keyFromPublic(key, enc); + signature$1 = new signature(signature$1, 'hex'); + + // Perform primitive values validation + var r = signature$1.r; + var s = signature$1.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; + + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + + if (!this.curve._maxwellTrick) { + var p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + return p.getX().umod(this.n).cmp(r) === 0; + } + + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K + + var p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); +}; + +EC.prototype.recoverPubKey = function(msg, signature$1, j, enc) { + assert$5((3 & j) === j, 'The recovery param is more than two bits'); + signature$1 = new signature(signature$1, enc); + + var n = this.n; + var e = new bn(msg); + var r = signature$1.r; + var s = signature$1.s; + + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); + + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); + + var rInv = signature$1.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); + + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); +}; + +EC.prototype.getKeyRecoveryParam = function(e, signature$1, Q, enc) { + signature$1 = new signature(signature$1, enc); + if (signature$1.recoveryParam !== null) + return signature$1.recoveryParam; + + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature$1, i); + } catch (e) { + continue; + } + + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); +}; + +var eddsa = {}; + +var require$$0$1 = getCjsExportFromNamespace(_package$1); + +var elliptic_1 = createCommonjsModule(function (module, exports) { +'use strict'; + +var elliptic = exports; + +elliptic.version = require$$0$1.version; +elliptic.utils = utils_1$1; +elliptic.rand = brorand; +elliptic.curve = curve_1; +elliptic.curves = curves_1; + +// Protocols +elliptic.ec = ec; +elliptic.eddsa = eddsa; +}); +var elliptic_2 = elliptic_1.ec; + +const version$c = "signing-key/5.0.0-beta.129"; + +"use strict"; +const logger$f = new Logger(version$c); +let _curve = null; +function getCurve() { + if (!_curve) { + _curve = new elliptic_2("secp256k1"); + } + return _curve; +} +class SigningKey { + constructor(privateKey) { + defineReadOnly(this, "curve", "secp256k1"); + defineReadOnly(this, "privateKey", hexlify(privateKey)); + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + defineReadOnly(this, "_isSigningKey", true); + } + _addPoint(other) { + let p0 = getCurve().keyFromPublic(arrayify(this.publicKey)); + let p1 = getCurve().keyFromPublic(arrayify(other)); + return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); + } + signDigest(digest) { + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + let signature = keyPair.sign(arrayify(digest), { canonical: true }); + return splitSignature({ + recoveryParam: signature.recoveryParam, + r: hexZeroPad("0x" + signature.r.toString(16), 32), + s: hexZeroPad("0x" + signature.s.toString(16), 32), + }); + } + computeSharedSecret(otherKey) { + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + let otherKeyPair = getCurve().keyFromPublic(arrayify(computePublicKey(otherKey))); + return hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + } + static isSigningKey(value) { + return !!(value && value._isSigningKey); + } +} +function recoverPublicKey(digest, signature) { + let sig = splitSignature(signature); + let rs = { r: arrayify(sig.r), s: arrayify(sig.s) }; + return "0x" + getCurve().recoverPubKey(arrayify(digest), rs, sig.recoveryParam).encode("hex", false); +} +function computePublicKey(key, compressed) { + let bytes = arrayify(key); + if (bytes.length === 32) { + let signingKey = new SigningKey(bytes); + if (compressed) { + return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); + } + return signingKey.publicKey; + } + else if (bytes.length === 33) { + if (compressed) { + return hexlify(bytes); + } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); + } + else if (bytes.length === 65) { + if (!compressed) { + return hexlify(bytes); + } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); + } + return logger$f.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} + +const version$d = "transactions/5.0.0-beta.128"; + +"use strict"; +const logger$g = new Logger(version$d); +/////////////////////////////// +function handleAddress(value) { + if (value === "0x") { + return null; + } + return getAddress(value); +} +function handleNumber(value) { + if (value === "0x") { + return Zero$1; + } + return BigNumber.from(value); +} +const transactionFields = [ + { name: "nonce", maxLength: 32 }, + { name: "gasPrice", maxLength: 32 }, + { name: "gasLimit", maxLength: 32 }, + { name: "to", length: 20 }, + { name: "value", maxLength: 32 }, + { name: "data" }, +]; +const allowedTransactionKeys$2 = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +function computeAddress(key) { + let publicKey = computePublicKey(key); + return getAddress(hexDataSlice(keccak256(hexDataSlice(publicKey, 1)), 12)); +} +function recoverAddress(digest, signature) { + return computeAddress(recoverPublicKey(arrayify(digest), signature)); +} +function serialize(transaction, signature) { + checkProperties(transaction, allowedTransactionKeys$2); + let raw = []; + transactionFields.forEach(function (fieldInfo) { + let value = transaction[fieldInfo.name] || ([]); + value = arrayify(hexlify(value)); + // Fixed-width field + if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { + logger$g.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + } + // Variable-width (with a maximum) + if (fieldInfo.maxLength) { + value = stripZeros(value); + if (value.length > fieldInfo.maxLength) { + logger$g.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + } + } + raw.push(hexlify(value)); + }); + if (transaction.chainId != null && transaction.chainId !== 0) { + raw.push(hexlify(transaction.chainId)); + raw.push("0x"); + raw.push("0x"); + } + let unsignedTransaction = encode(raw); + // Requesting an unsigned transation + if (!signature) { + return unsignedTransaction; + } + // The splitSignature will ensure the transaction has a recoveryParam in the + // case that the signTransaction function only adds a v. + let sig = splitSignature(signature); + // We pushed a chainId and null r, s on for hashing only; remove those + let v = 27 + sig.recoveryParam; + if (raw.length === 9) { + raw.pop(); + raw.pop(); + raw.pop(); + v += transaction.chainId * 2 + 8; + } + raw.push(hexlify(v)); + raw.push(stripZeros(arrayify(sig.r))); + raw.push(stripZeros(arrayify(sig.s))); + return encode(raw); +} +function parse(rawTransaction) { + let transaction = decode(rawTransaction); + if (transaction.length !== 9 && transaction.length !== 6) { + logger$g.throwArgumentError("invalid raw transaction", "rawTransactin", rawTransaction); + } + let tx = { + nonce: handleNumber(transaction[0]).toNumber(), + gasPrice: handleNumber(transaction[1]), + gasLimit: handleNumber(transaction[2]), + to: handleAddress(transaction[3]), + value: handleNumber(transaction[4]), + data: transaction[5], + chainId: 0 + }; + // Legacy unsigned transaction + if (transaction.length === 6) { + return tx; + } + try { + tx.v = BigNumber.from(transaction[6]).toNumber(); + } + catch (error) { + console.log(error); + return tx; + } + tx.r = hexZeroPad(transaction[7], 32); + tx.s = hexZeroPad(transaction[8], 32); + if (BigNumber.from(tx.r).isZero() && BigNumber.from(tx.s).isZero()) { + // EIP-155 unsigned transaction + tx.chainId = tx.v; + tx.v = 0; + } + else { + // Signed Tranasaction + tx.chainId = Math.floor((tx.v - 35) / 2); + if (tx.chainId < 0) { + tx.chainId = 0; + } + let recoveryParam = tx.v - 27; + let raw = transaction.slice(0, 6); + if (tx.chainId !== 0) { + raw.push(hexlify(tx.chainId)); + raw.push("0x"); + raw.push("0x"); + recoveryParam -= tx.chainId * 2 + 8; + } + let digest = keccak256(encode(raw)); + try { + tx.from = recoverAddress(digest, { r: hexlify(tx.r), s: hexlify(tx.s), recoveryParam: recoveryParam }); + } + catch (error) { + console.log(error); + } + tx.hash = keccak256(rawTransaction); + } + return tx; +} + +var _version$2 = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.version = "wordlists/5.0.0-beta.128"; +}); + +var _version$3 = unwrapExports(_version$2); +var _version_1$1 = _version$2.version; + +var wordlist = createCommonjsModule(function (module$1, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// This gets overriddenby gulp during bip39-XX +var exportWordlist = false; + + + + +var logger = new module.Logger(_version$2.version); +function check(wordlist) { + var words = []; + for (var i = 0; i < 2048; i++) { + var word = wordlist.getWord(i); + if (i !== wordlist.getWordIndex(word)) { + return "0x"; + } + words.push(word); + } + return module$3.id(words.join("\n") + "\n"); +} +exports.check = check; +var Wordlist = /** @class */ (function () { + function Wordlist(locale) { + var _newTarget = this.constructor; + logger.checkAbstract(_newTarget, Wordlist); + module$2.defineReadOnly(this, "locale", locale); + } + // Subclasses may override this + Wordlist.prototype.split = function (mnemonic) { + return mnemonic.toLowerCase().split(/ +/g); + }; + // Subclasses may override this + Wordlist.prototype.join = function (words) { + return words.join(" "); + }; + return Wordlist; +}()); +exports.Wordlist = Wordlist; +function register(lang, name) { + if (!name) { + name = lang.locale; + } + if (exportWordlist) { + var g = commonjsGlobal; + if (!(g.wordlists)) { + module$2.defineReadOnly(g, "wordlists", {}); + } + if (!g.wordlists[name]) { + module$2.defineReadOnly(g.wordlists, name, lang); + } + if (g.ethers && g.ethers.wordlists) { + if (!g.ethers.wordlists[name]) { + module$2.defineReadOnly(g.ethers.wordlists, name, lang); + } + } + } +} +exports.register = register; +}); + +var wordlist$1 = unwrapExports(wordlist); +var wordlist_1 = wordlist.check; +var wordlist_2 = wordlist.Wordlist; +var wordlist_3 = wordlist.register; + +var langEn_1 = createCommonjsModule(function (module, exports) { +"use strict"; +var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +Object.defineProperty(exports, "__esModule", { value: true }); + +var words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo"; +var wordlist$1 = null; +function loadWords(lang) { + if (wordlist$1 != null) { + return; + } + wordlist$1 = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); + if (wordlist.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") { + wordlist$1 = null; + throw new Error("BIP39 Wordlist for en (English) FAILED"); + } +} +var LangEn = /** @class */ (function (_super) { + __extends(LangEn, _super); + function LangEn() { + return _super.call(this, "en") || this; + } + LangEn.prototype.getWord = function (index) { + loadWords(this); + return wordlist$1[index]; + }; + LangEn.prototype.getWordIndex = function (word) { + loadWords(this); + return wordlist$1.indexOf(word); + }; + return LangEn; +}(wordlist.Wordlist)); +var langEn = new LangEn(); +exports.langEn = langEn; +wordlist.register(langEn); +}); + +var langEn = unwrapExports(langEn_1); +var langEn_2 = langEn_1.langEn; + +var browser$4 = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// Wordlists +// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md + +exports.Wordlist = wordlist.Wordlist; + +var wordlists = { en: langEn_1.langEn }; +exports.wordlists = wordlists; +}); + +var browser$5 = unwrapExports(browser$4); +var browser_1$2 = browser$4.Wordlist; +var browser_2$1 = browser$4.wordlists; + +const version$e = "hdnode/5.0.0-beta.130"; + +"use strict"; +const logger$h = new Logger(version$e); +const N = BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); +// "Bitcoin seed" +const MasterSecret = toUtf8Bytes("Bitcoin seed"); +const HardenedBit = 0x80000000; +// Returns a byte with the MSB bits set +function getUpperMask(bits) { + return ((1 << bits) - 1) << (8 - bits); +} +// Returns a byte with the LSB bits set +function getLowerMask(bits) { + return (1 << bits) - 1; +} +function bytes32(value) { + return hexZeroPad(hexlify(value), 32); +} +function base58check(data) { + let checksum = hexDataSlice(browser_3(browser_3(data)), 0, 4); + return Base58.encode(concat([data, checksum])); +} +const _constructorGuard$3 = {}; +const defaultPath = "m/44'/60'/0'/0/0"; +class HDNode { + /** + * This constructor should not be called directly. + * + * Please use: + * - fromMnemonic + * - fromSeed + */ + constructor(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) { + logger$h.checkNew(new.target, HDNode); + if (constructorGuard !== _constructorGuard$3) { + throw new Error("HDNode constructor cannot be called directly"); + } + if (privateKey) { + let signingKey = new SigningKey(privateKey); + defineReadOnly(this, "privateKey", signingKey.privateKey); + defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); + } + else { + defineReadOnly(this, "privateKey", null); + defineReadOnly(this, "publicKey", hexlify(publicKey)); + } + defineReadOnly(this, "parentFingerprint", parentFingerprint); + defineReadOnly(this, "fingerprint", hexDataSlice(browser_2(browser_3(this.publicKey)), 0, 4)); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + defineReadOnly(this, "chainCode", chainCode); + defineReadOnly(this, "index", index); + defineReadOnly(this, "depth", depth); + defineReadOnly(this, "mnemonic", mnemonic); + defineReadOnly(this, "path", path); + } + get extendedKey() { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current senitment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + if (this.depth >= 256) { + throw new Error("Depth too large!"); + } + return base58check(concat([ + ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"), + hexlify(this.depth), + this.parentFingerprint, + hexZeroPad(hexlify(this.index), 4), + this.chainCode, + ((this.privateKey != null) ? concat(["0x00", this.privateKey]) : this.publicKey), + ])); + } + neuter() { + return new HDNode(_constructorGuard$3, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, null, this.path); + } + _derive(index) { + if (index > 0xffffffff) { + throw new Error("invalid index - " + String(index)); + } + // Base path + let path = this.path; + if (path) { + path += "/" + (index & ~HardenedBit); + } + let data = new Uint8Array(37); + if (index & HardenedBit) { + if (!this.privateKey) { + throw new Error("cannot derive child of neutered node"); + } + // Data = 0x00 || ser_256(k_par) + data.set(arrayify(this.privateKey), 1); + // Hardened path + if (path) { + path += "'"; + } + } + else { + // Data = ser_p(point(k_par)) + data.set(arrayify(this.publicKey)); + } + // Data += ser_32(i) + for (let i = 24; i >= 0; i -= 8) { + data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); + } + let I = arrayify(browser_5(browser_1.sha512, this.chainCode, data)); + let IL = I.slice(0, 32); + let IR = I.slice(32); + // The private key + let ki = null; + // The public key + let Ki = null; + if (this.privateKey) { + ki = bytes32(BigNumber.from(IL).add(this.privateKey).mod(N)); + } + else { + let ek = new SigningKey(hexlify(IL)); + Ki = ek._addPoint(this.publicKey); + } + return new HDNode(_constructorGuard$3, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); + } + derivePath(path) { + let components = path.split("/"); + if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) { + throw new Error("invalid path - " + path); + } + if (components[0] === "m") { + components.shift(); + } + let result = this; + for (let i = 0; i < components.length; i++) { + let component = components[i]; + if (component.match(/^[0-9]+'$/)) { + let index = parseInt(component.substring(0, component.length - 1)); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(HardenedBit + index); + } + else if (component.match(/^[0-9]+$/)) { + let index = parseInt(component); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(index); + } + else { + throw new Error("invlaid path component - " + component); + } + } + return result; + } + static _fromSeed(seed, mnemonic) { + let seedArray = arrayify(seed); + if (seedArray.length < 16 || seedArray.length > 64) { + throw new Error("invalid seed"); + } + let I = arrayify(browser_5(browser_1.sha512, MasterSecret, seedArray)); + return new HDNode(_constructorGuard$3, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); + } + static fromMnemonic(mnemonic, password, wordlist) { + // Normalize the case and spacing in the mnemonic (throws if the mnemonic is invalid) + mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist); + return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), mnemonic); + } + static fromSeed(seed) { + return HDNode._fromSeed(seed, null); + } + static fromExtendedKey(extendedKey) { + let bytes = Base58.decode(extendedKey); + if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { + logger$h.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); + } + let depth = bytes[4]; + let parentFingerprint = hexlify(bytes.slice(5, 9)); + let index = parseInt(hexlify(bytes.slice(9, 13)).substring(2), 16); + let chainCode = hexlify(bytes.slice(13, 45)); + let key = bytes.slice(45, 78); + switch (hexlify(bytes.slice(0, 4))) { + // Public Key + case "0x0488b21e": + case "0x043587cf": + return new HDNode(_constructorGuard$3, null, hexlify(key), parentFingerprint, chainCode, index, depth, null, null); + // Private Key + case "0x0488ade4": + case "0x04358394 ": + if (key[0] !== 0) { + break; + } + return new HDNode(_constructorGuard$3, hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); + } + return logger$h.throwError("invalid extended key", "extendedKey", "[REDACTED]"); + } +} +function mnemonicToSeed(mnemonic, password) { + if (!password) { + password = ""; + } + let salt = toUtf8Bytes("mnemonic" + password, UnicodeNormalizationForm.NFKD); + return browser_1$1(toUtf8Bytes(mnemonic, UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); +} +function mnemonicToEntropy(mnemonic, wordlist) { + if (!wordlist) { + wordlist = browser_2$1["en"]; + } + logger$h.checkNormalize(); + let words = wordlist.split(mnemonic); + if ((words.length % 3) !== 0) { + throw new Error("invalid mnemonic"); + } + let entropy = arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); + let offset = 0; + for (let i = 0; i < words.length; i++) { + let index = wordlist.getWordIndex(words[i].normalize("NFKD")); + if (index === -1) { + throw new Error("invalid mnemonic"); + } + for (let bit = 0; bit < 11; bit++) { + if (index & (1 << (10 - bit))) { + entropy[offset >> 3] |= (1 << (7 - (offset % 8))); + } + offset++; + } + } + let entropyBits = 32 * words.length / 3; + let checksumBits = words.length / 3; + let checksumMask = getUpperMask(checksumBits); + let checksum = arrayify(browser_3(entropy.slice(0, entropyBits / 8)))[0]; + checksum &= checksumMask; + if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { + throw new Error("invalid checksum"); + } + return hexlify(entropy.slice(0, entropyBits / 8)); +} +function entropyToMnemonic(entropy, wordlist) { + entropy = arrayify(entropy); + if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { + throw new Error("invalid entropy"); + } + let indices = [0]; + let remainingBits = 11; + for (let i = 0; i < entropy.length; i++) { + // Consume the whole byte (with still more to go) + if (remainingBits > 8) { + indices[indices.length - 1] <<= 8; + indices[indices.length - 1] |= entropy[i]; + remainingBits -= 8; + // This byte will complete an 11-bit index + } + else { + indices[indices.length - 1] <<= remainingBits; + indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); + // Start the next word + indices.push(entropy[i] & getLowerMask(8 - remainingBits)); + remainingBits += 3; + } + } + // Compute the checksum bits + let checksum = arrayify(browser_3(entropy))[0]; + let checksumBits = entropy.length / 4; + checksum &= getUpperMask(checksumBits); + // Shift the checksum into the word indices + indices[indices.length - 1] <<= checksumBits; + indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); + if (!wordlist) { + wordlist = browser_2$1["en"]; + } + return wordlist.join(indices.map((index) => wordlist.getWord(index))); +} +function isValidMnemonic(mnemonic, wordlist) { + try { + mnemonicToEntropy(mnemonic, wordlist); + return true; + } + catch (error) { } + return false; +} + +var _version$4 = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.version = "random/5.0.0-beta.128"; +}); + +var _version$5 = unwrapExports(_version$4); +var _version_1$2 = _version$4.version; + +var shuffle = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function shuffled(array) { + array = array.slice(); + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + return array; +} +exports.shuffled = shuffled; +}); + +var shuffle$1 = unwrapExports(shuffle); +var shuffle_1 = shuffle.shuffled; + +var browser$6 = createCommonjsModule(function (module$2, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + + +var logger = new module.Logger(_version$4.version); + +exports.shuffled = shuffle.shuffled; +var crypto = commonjsGlobal.crypto || commonjsGlobal.msCrypto; +if (!crypto || !crypto.getRandomValues) { + logger.warn("WARNING: Missing strong random number source"); + crypto = { + getRandomValues: function (buffer) { + return logger.throwError("no secure random source avaialble", module.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "crypto.getRandomValues" + }); + } + }; +} +function randomBytes(length) { + if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { + logger.throwArgumentError("invalid length", "length", length); + } + var result = new Uint8Array(length); + crypto.getRandomValues(result); + return module$1.arrayify(result); +} +exports.randomBytes = randomBytes; +; +}); + +var browser$7 = unwrapExports(browser$6); +var browser_1$3 = browser$6.shuffled; +var browser_2$2 = browser$6.randomBytes; + +var aesJs = createCommonjsModule(function (module, exports) { +"use strict"; + +(function(root) { + + function checkInt(value) { + return (parseInt(value) === value); + } + + function checkInts(arrayish) { + if (!checkInt(arrayish.length)) { return false; } + + for (var i = 0; i < arrayish.length; i++) { + if (!checkInt(arrayish[i]) || arrayish[i] < 0 || arrayish[i] > 255) { + return false; + } + } + + return true; + } + + function coerceArray(arg, copy) { + + // ArrayBuffer view + if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === 'Uint8Array') { + + if (copy) { + if (arg.slice) { + arg = arg.slice(); + } else { + arg = Array.prototype.slice.call(arg); + } + } + + return arg; + } + + // It's an array; check it is a valid representation of a byte + if (Array.isArray(arg)) { + if (!checkInts(arg)) { + throw new Error('Array contains invalid value: ' + arg); + } + + return new Uint8Array(arg); + } + + // Something else, but behaves like an array (maybe a Buffer? Arguments?) + if (checkInt(arg.length) && checkInts(arg)) { + return new Uint8Array(arg); + } + + throw new Error('unsupported array-like object'); + } + + function createArray(length) { + return new Uint8Array(length); + } + + function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { + if (sourceStart != null || sourceEnd != null) { + if (sourceArray.slice) { + sourceArray = sourceArray.slice(sourceStart, sourceEnd); + } else { + sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); + } + } + targetArray.set(sourceArray, targetStart); + } + + + + var convertUtf8 = (function() { + function toBytes(text) { + var result = [], i = 0; + text = encodeURI(text); + while (i < text.length) { + var c = text.charCodeAt(i++); + + // if it is a % sign, encode the following 2 bytes as a hex value + if (c === 37) { + result.push(parseInt(text.substr(i, 2), 16)); + i += 2; + + // otherwise, just the actual byte + } else { + result.push(c); + } + } + + return coerceArray(result); + } + + function fromBytes(bytes) { + var result = [], i = 0; + + while (i < bytes.length) { + var c = bytes[i]; + + if (c < 128) { + result.push(String.fromCharCode(c)); + i++; + } else if (c > 191 && c < 224) { + result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f))); + i += 2; + } else { + result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f))); + i += 3; + } + } + + return result.join(''); + } + + return { + toBytes: toBytes, + fromBytes: fromBytes, + } + })(); + + var convertHex = (function() { + function toBytes(text) { + var result = []; + for (var i = 0; i < text.length; i += 2) { + result.push(parseInt(text.substr(i, 2), 16)); + } + + return result; + } + + // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html + var Hex = '0123456789abcdef'; + + function fromBytes(bytes) { + var result = []; + for (var i = 0; i < bytes.length; i++) { + var v = bytes[i]; + result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]); + } + return result.join(''); + } + + return { + toBytes: toBytes, + fromBytes: fromBytes, + } + })(); + + + // Number of rounds by keysize + var numberOfRounds = {16: 10, 24: 12, 32: 14}; + + // Round constant words + var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91]; + + // S-box and Inverse S-box (S is for Substitution) + var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]; + + // Transformations for encryption + var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a]; + var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616]; + var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16]; + var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c]; + + // Transformations for decryption + var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742]; + var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857]; + var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8]; + var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0]; + + // Transformations for decryption key expansion + var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]; + var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697]; + var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46]; + var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d]; + + function convertToInt32(bytes) { + var result = []; + for (var i = 0; i < bytes.length; i += 4) { + result.push( + (bytes[i ] << 24) | + (bytes[i + 1] << 16) | + (bytes[i + 2] << 8) | + bytes[i + 3] + ); + } + return result; + } + + var AES = function(key) { + if (!(this instanceof AES)) { + throw Error('AES must be instanitated with `new`'); + } + + Object.defineProperty(this, 'key', { + value: coerceArray(key, true) + }); + + this._prepare(); + }; + + + AES.prototype._prepare = function() { + + var rounds = numberOfRounds[this.key.length]; + if (rounds == null) { + throw new Error('invalid key size (must be 16, 24 or 32 bytes)'); + } + + // encryption round keys + this._Ke = []; + + // decryption round keys + this._Kd = []; + + for (var i = 0; i <= rounds; i++) { + this._Ke.push([0, 0, 0, 0]); + this._Kd.push([0, 0, 0, 0]); + } + + var roundKeyCount = (rounds + 1) * 4; + var KC = this.key.length / 4; + + // convert the key into ints + var tk = convertToInt32(this.key); + + // copy values into round key arrays + var index; + for (var i = 0; i < KC; i++) { + index = i >> 2; + this._Ke[index][i % 4] = tk[i]; + this._Kd[rounds - index][i % 4] = tk[i]; + } + + // key expansion (fips-197 section 5.2) + var rconpointer = 0; + var t = KC, tt; + while (t < roundKeyCount) { + tt = tk[KC - 1]; + tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^ + (S[(tt >> 8) & 0xFF] << 16) ^ + (S[ tt & 0xFF] << 8) ^ + S[(tt >> 24) & 0xFF] ^ + (rcon[rconpointer] << 24)); + rconpointer += 1; + + // key expansion (for non-256 bit) + if (KC != 8) { + for (var i = 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + + // key expansion for 256-bit keys is "slightly different" (fips-197) + } else { + for (var i = 1; i < (KC / 2); i++) { + tk[i] ^= tk[i - 1]; + } + tt = tk[(KC / 2) - 1]; + + tk[KC / 2] ^= (S[ tt & 0xFF] ^ + (S[(tt >> 8) & 0xFF] << 8) ^ + (S[(tt >> 16) & 0xFF] << 16) ^ + (S[(tt >> 24) & 0xFF] << 24)); + + for (var i = (KC / 2) + 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + } + + // copy values into round key arrays + var i = 0, r, c; + while (i < KC && t < roundKeyCount) { + r = t >> 2; + c = t % 4; + this._Ke[r][c] = tk[i]; + this._Kd[rounds - r][c] = tk[i++]; + t++; + } + } + + // inverse-cipher-ify the decryption round key (fips-197 section 5.3) + for (var r = 1; r < rounds; r++) { + for (var c = 0; c < 4; c++) { + tt = this._Kd[r][c]; + this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^ + U2[(tt >> 16) & 0xFF] ^ + U3[(tt >> 8) & 0xFF] ^ + U4[ tt & 0xFF]); + } + } + }; + + AES.prototype.encrypt = function(plaintext) { + if (plaintext.length != 16) { + throw new Error('invalid plaintext size (must be 16 bytes)'); + } + + var rounds = this._Ke.length - 1; + var a = [0, 0, 0, 0]; + + // convert plaintext to (ints ^ key) + var t = convertToInt32(plaintext); + for (var i = 0; i < 4; i++) { + t[i] ^= this._Ke[0][i]; + } + + // apply round transforms + for (var r = 1; r < rounds; r++) { + for (var i = 0; i < 4; i++) { + a[i] = (T1[(t[ i ] >> 24) & 0xff] ^ + T2[(t[(i + 1) % 4] >> 16) & 0xff] ^ + T3[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T4[ t[(i + 3) % 4] & 0xff] ^ + this._Ke[r][i]); + } + t = a.slice(); + } + + // the last round is special + var result = createArray(16), tt; + for (var i = 0; i < 4; i++) { + tt = this._Ke[rounds][i]; + result[4 * i ] = (S[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (S[ t[(i + 3) % 4] & 0xff] ^ tt ) & 0xff; + } + + return result; + }; + + AES.prototype.decrypt = function(ciphertext) { + if (ciphertext.length != 16) { + throw new Error('invalid ciphertext size (must be 16 bytes)'); + } + + var rounds = this._Kd.length - 1; + var a = [0, 0, 0, 0]; + + // convert plaintext to (ints ^ key) + var t = convertToInt32(ciphertext); + for (var i = 0; i < 4; i++) { + t[i] ^= this._Kd[0][i]; + } + + // apply round transforms + for (var r = 1; r < rounds; r++) { + for (var i = 0; i < 4; i++) { + a[i] = (T5[(t[ i ] >> 24) & 0xff] ^ + T6[(t[(i + 3) % 4] >> 16) & 0xff] ^ + T7[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T8[ t[(i + 1) % 4] & 0xff] ^ + this._Kd[r][i]); + } + t = a.slice(); + } + + // the last round is special + var result = createArray(16), tt; + for (var i = 0; i < 4; i++) { + tt = this._Kd[rounds][i]; + result[4 * i ] = (Si[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (Si[ t[(i + 1) % 4] & 0xff] ^ tt ) & 0xff; + } + + return result; + }; + + + /** + * Mode Of Operation - Electonic Codebook (ECB) + */ + var ModeOfOperationECB = function(key) { + if (!(this instanceof ModeOfOperationECB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Electronic Code Block"; + this.name = "ecb"; + + this._aes = new AES(key); + }; + + ModeOfOperationECB.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + + if ((plaintext.length % 16) !== 0) { + throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); + } + + var ciphertext = createArray(plaintext.length); + var block = createArray(16); + + for (var i = 0; i < plaintext.length; i += 16) { + copyArray(plaintext, block, 0, i, i + 16); + block = this._aes.encrypt(block); + copyArray(block, ciphertext, i); + } + + return ciphertext; + }; + + ModeOfOperationECB.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + + if ((ciphertext.length % 16) !== 0) { + throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); + } + + var plaintext = createArray(ciphertext.length); + var block = createArray(16); + + for (var i = 0; i < ciphertext.length; i += 16) { + copyArray(ciphertext, block, 0, i, i + 16); + block = this._aes.decrypt(block); + copyArray(block, plaintext, i); + } + + return plaintext; + }; + + + /** + * Mode Of Operation - Cipher Block Chaining (CBC) + */ + var ModeOfOperationCBC = function(key, iv) { + if (!(this instanceof ModeOfOperationCBC)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Cipher Block Chaining"; + this.name = "cbc"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 bytes)'); + } + + this._lastCipherblock = coerceArray(iv, true); + + this._aes = new AES(key); + }; + + ModeOfOperationCBC.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + + if ((plaintext.length % 16) !== 0) { + throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); + } + + var ciphertext = createArray(plaintext.length); + var block = createArray(16); + + for (var i = 0; i < plaintext.length; i += 16) { + copyArray(plaintext, block, 0, i, i + 16); + + for (var j = 0; j < 16; j++) { + block[j] ^= this._lastCipherblock[j]; + } + + this._lastCipherblock = this._aes.encrypt(block); + copyArray(this._lastCipherblock, ciphertext, i); + } + + return ciphertext; + }; + + ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + + if ((ciphertext.length % 16) !== 0) { + throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); + } + + var plaintext = createArray(ciphertext.length); + var block = createArray(16); + + for (var i = 0; i < ciphertext.length; i += 16) { + copyArray(ciphertext, block, 0, i, i + 16); + block = this._aes.decrypt(block); + + for (var j = 0; j < 16; j++) { + plaintext[i + j] = block[j] ^ this._lastCipherblock[j]; + } + + copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16); + } + + return plaintext; + }; + + + /** + * Mode Of Operation - Cipher Feedback (CFB) + */ + var ModeOfOperationCFB = function(key, iv, segmentSize) { + if (!(this instanceof ModeOfOperationCFB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Cipher Feedback"; + this.name = "cfb"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 size)'); + } + + if (!segmentSize) { segmentSize = 1; } + + this.segmentSize = segmentSize; + + this._shiftRegister = coerceArray(iv, true); + + this._aes = new AES(key); + }; + + ModeOfOperationCFB.prototype.encrypt = function(plaintext) { + if ((plaintext.length % this.segmentSize) != 0) { + throw new Error('invalid plaintext size (must be segmentSize bytes)'); + } + + var encrypted = coerceArray(plaintext, true); + + var xorSegment; + for (var i = 0; i < encrypted.length; i += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + for (var j = 0; j < this.segmentSize; j++) { + encrypted[i + j] ^= xorSegment[j]; + } + + // Shift the register + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); + } + + return encrypted; + }; + + ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { + if ((ciphertext.length % this.segmentSize) != 0) { + throw new Error('invalid ciphertext size (must be segmentSize bytes)'); + } + + var plaintext = coerceArray(ciphertext, true); + + var xorSegment; + for (var i = 0; i < plaintext.length; i += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + + for (var j = 0; j < this.segmentSize; j++) { + plaintext[i + j] ^= xorSegment[j]; + } + + // Shift the register + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); + } + + return plaintext; + }; + + /** + * Mode Of Operation - Output Feedback (OFB) + */ + var ModeOfOperationOFB = function(key, iv) { + if (!(this instanceof ModeOfOperationOFB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Output Feedback"; + this.name = "ofb"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 bytes)'); + } + + this._lastPrecipher = coerceArray(iv, true); + this._lastPrecipherIndex = 16; + + this._aes = new AES(key); + }; + + ModeOfOperationOFB.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + + for (var i = 0; i < encrypted.length; i++) { + if (this._lastPrecipherIndex === 16) { + this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); + this._lastPrecipherIndex = 0; + } + encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++]; + } + + return encrypted; + }; + + // Decryption is symetric + ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; + + + /** + * Counter object for CTR common mode of operation + */ + var Counter = function(initialValue) { + if (!(this instanceof Counter)) { + throw Error('Counter must be instanitated with `new`'); + } + + // We allow 0, but anything false-ish uses the default 1 + if (initialValue !== 0 && !initialValue) { initialValue = 1; } + + if (typeof(initialValue) === 'number') { + this._counter = createArray(16); + this.setValue(initialValue); + + } else { + this.setBytes(initialValue); + } + }; + + Counter.prototype.setValue = function(value) { + if (typeof(value) !== 'number' || parseInt(value) != value) { + throw new Error('invalid counter value (must be an integer)'); + } + + for (var index = 15; index >= 0; --index) { + this._counter[index] = value % 256; + value = value >> 8; + } + }; + + Counter.prototype.setBytes = function(bytes) { + bytes = coerceArray(bytes, true); + + if (bytes.length != 16) { + throw new Error('invalid counter bytes size (must be 16 bytes)'); + } + + this._counter = bytes; + }; + + Counter.prototype.increment = function() { + for (var i = 15; i >= 0; i--) { + if (this._counter[i] === 255) { + this._counter[i] = 0; + } else { + this._counter[i]++; + break; + } + } + }; + + + /** + * Mode Of Operation - Counter (CTR) + */ + var ModeOfOperationCTR = function(key, counter) { + if (!(this instanceof ModeOfOperationCTR)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Counter"; + this.name = "ctr"; + + if (!(counter instanceof Counter)) { + counter = new Counter(counter); + } + + this._counter = counter; + + this._remainingCounter = null; + this._remainingCounterIndex = 16; + + this._aes = new AES(key); + }; + + ModeOfOperationCTR.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + + for (var i = 0; i < encrypted.length; i++) { + if (this._remainingCounterIndex === 16) { + this._remainingCounter = this._aes.encrypt(this._counter._counter); + this._remainingCounterIndex = 0; + this._counter.increment(); + } + encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++]; + } + + return encrypted; + }; + + // Decryption is symetric + ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; + + + /////////////////////// + // Padding + + // See:https://tools.ietf.org/html/rfc2315 + function pkcs7pad(data) { + data = coerceArray(data, true); + var padder = 16 - (data.length % 16); + var result = createArray(data.length + padder); + copyArray(data, result); + for (var i = data.length; i < result.length; i++) { + result[i] = padder; + } + return result; + } + + function pkcs7strip(data) { + data = coerceArray(data, true); + if (data.length < 16) { throw new Error('PKCS#7 invalid length'); } + + var padder = data[data.length - 1]; + if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); } + + var length = data.length - padder; + for (var i = 0; i < padder; i++) { + if (data[length + i] !== padder) { + throw new Error('PKCS#7 invalid padding byte'); + } + } + + var result = createArray(length); + copyArray(data, result, 0, 0, length); + return result; + } + + /////////////////////// + // Exporting + + + // The block cipher + var aesjs = { + AES: AES, + Counter: Counter, + + ModeOfOperation: { + ecb: ModeOfOperationECB, + cbc: ModeOfOperationCBC, + cfb: ModeOfOperationCFB, + ofb: ModeOfOperationOFB, + ctr: ModeOfOperationCTR + }, + + utils: { + hex: convertHex, + utf8: convertUtf8 + }, + + padding: { + pkcs7: { + pad: pkcs7pad, + strip: pkcs7strip + } + }, + + _arrayTest: { + coerceArray: coerceArray, + createArray: createArray, + copyArray: copyArray, + } + }; + + + // node.js + if ('object' !== 'undefined') { + module.exports = aesjs; + + // RequireJS/AMD + // http://www.requirejs.org/docs/api.html + // https://github.com/amdjs/amdjs-api/wiki/AMD + } else if (typeof(undefined) === 'function' && undefined.amd) { + undefined(aesjs); + + // Web Browsers + } else { + + // If there was an existing library at "aesjs" make sure it's still available + if (root.aesjs) { + aesjs._aesjs = root.aesjs; + } + + root.aesjs = aesjs; + } + + +})(commonjsGlobal); +}); + +const version$f = "json-wallets/5.0.0-beta.129"; + +"use strict"; +/* +export class Account extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + +// static isAccount(value: any): value is Account { +// return Description._isType(value); +// } +} +//defineReadOnly(Account, "name", "Account"); +*/ +function looseArrayify(hexString) { + if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') { + hexString = '0x' + hexString; + } + return arrayify(hexString); +} +function zpad(value, length) { + value = String(value); + while (value.length < length) { + value = '0' + value; + } + return value; +} +function getPassword(password) { + if (typeof (password) === 'string') { + return toUtf8Bytes(password, UnicodeNormalizationForm.NFKC); + } + return arrayify(password); +} +function searchPath(object, path) { + let currentChild = object; + let comps = path.toLowerCase().split('/'); + for (let i = 0; i < comps.length; i++) { + // Search for a child object with a case-insensitive matching key + let matchingChild = null; + for (let key in currentChild) { + if (key.toLowerCase() === comps[i]) { + matchingChild = currentChild[key]; + break; + } + } + // Didn't find one. :'( + if (matchingChild === null) { + return null; + } + // Now check this child... + currentChild = matchingChild; + } + return currentChild; +} + +"use strict"; +const logger$i = new Logger(version$f); +class CrowdsaleAccount extends Description { + isCrowdsaleAccount(value) { + return !!(value && value._isCrowdsaleAccount); + } +} +// See: https://github.com/ethereum/pyethsaletool +function decrypt(json, password) { + let data = JSON.parse(json); + password = getPassword(password); + // Ethereum Address + let ethaddr = getAddress(searchPath(data, "ethaddr")); + // Encrypted Seed + let encseed = looseArrayify(searchPath(data, "encseed")); + if (!encseed || (encseed.length % 16) !== 0) { + logger$i.throwArgumentError("invalid encseed", "json", json); + } + let key = arrayify(browser_1$1(password, password, 2000, 32, "sha256")).slice(0, 16); + let iv = encseed.slice(0, 16); + let encryptedSeed = encseed.slice(16); + // Decrypt the seed + let aesCbc = new aesJs.ModeOfOperation.cbc(key, iv); + let seed = arrayify(aesCbc.decrypt(encryptedSeed)); + seed = aesJs.padding.pkcs7.strip(seed); + // This wallet format is weird... Convert the binary encoded hex to a string. + let seedHex = ""; + for (let i = 0; i < seed.length; i++) { + seedHex += String.fromCharCode(seed[i]); + } + let seedHexBytes = toUtf8Bytes(seedHex); + let privateKey = keccak256(seedHexBytes); + return new CrowdsaleAccount({ + _isCrowdsaleAccount: true, + address: ethaddr, + privateKey: privateKey + }); +} + +"use strict"; +function isCrowdsaleWallet(json) { + let data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + return (data.encseed && data.ethaddr); +} +function isKeystoreWallet(json) { + let data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { + return false; + } + // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff + return true; +} +//export function isJsonWallet(json: string): boolean { +// return (isSecretStorageWallet(json) || isCrowdsaleWallet(json)); +//} +function getJsonWalletAddress(json) { + if (isCrowdsaleWallet(json)) { + try { + return getAddress(JSON.parse(json).ethaddr); + } + catch (error) { + return null; + } + } + if (isKeystoreWallet(json)) { + try { + return getAddress(JSON.parse(json).address); + } + catch (error) { + return null; + } + } + return null; +} + +var scrypt = createCommonjsModule(function (module, exports) { +"use strict"; + +(function(root) { + var MAX_VALUE = 0x7fffffff; + + // The SHA256 and PBKDF2 implementation are from scrypt-async-js: + // See: https://github.com/dchest/scrypt-async-js + function SHA256(m) { + var K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, + 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, + 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, + 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, + 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, + 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, + 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, + 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, + 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + ]; + + var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a; + var h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19; + var w = new Array(64); + + function blocks(p) { + var off = 0, len = p.length; + while (len >= 64) { + var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, u, i, j, t1, t2; + + for (i = 0; i < 16; i++) { + j = off + i*4; + w[i] = ((p[j] & 0xff)<<24) | ((p[j+1] & 0xff)<<16) | + ((p[j+2] & 0xff)<<8) | (p[j+3] & 0xff); + } + + for (i = 16; i < 64; i++) { + u = w[i-2]; + t1 = ((u>>>17) | (u<<(32-17))) ^ ((u>>>19) | (u<<(32-19))) ^ (u>>>10); + + u = w[i-15]; + t2 = ((u>>>7) | (u<<(32-7))) ^ ((u>>>18) | (u<<(32-18))) ^ (u>>>3); + + w[i] = (((t1 + w[i-7]) | 0) + ((t2 + w[i-16]) | 0)) | 0; + } + + for (i = 0; i < 64; i++) { + t1 = ((((((e>>>6) | (e<<(32-6))) ^ ((e>>>11) | (e<<(32-11))) ^ + ((e>>>25) | (e<<(32-25)))) + ((e & f) ^ (~e & g))) | 0) + + ((h + ((K[i] + w[i]) | 0)) | 0)) | 0; + + t2 = ((((a>>>2) | (a<<(32-2))) ^ ((a>>>13) | (a<<(32-13))) ^ + ((a>>>22) | (a<<(32-22)))) + ((a & b) ^ (a & c) ^ (b & c))) | 0; + + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } + + h0 = (h0 + a) | 0; + h1 = (h1 + b) | 0; + h2 = (h2 + c) | 0; + h3 = (h3 + d) | 0; + h4 = (h4 + e) | 0; + h5 = (h5 + f) | 0; + h6 = (h6 + g) | 0; + h7 = (h7 + h) | 0; + + off += 64; + len -= 64; + } + } + + blocks(m); + + var i, bytesLeft = m.length % 64, + bitLenHi = (m.length / 0x20000000) | 0, + bitLenLo = m.length << 3, + numZeros = (bytesLeft < 56) ? 56 : 120, + p = m.slice(m.length - bytesLeft, m.length); + + p.push(0x80); + for (i = bytesLeft + 1; i < numZeros; i++) { p.push(0); } + p.push((bitLenHi>>>24) & 0xff); + p.push((bitLenHi>>>16) & 0xff); + p.push((bitLenHi>>>8) & 0xff); + p.push((bitLenHi>>>0) & 0xff); + p.push((bitLenLo>>>24) & 0xff); + p.push((bitLenLo>>>16) & 0xff); + p.push((bitLenLo>>>8) & 0xff); + p.push((bitLenLo>>>0) & 0xff); + + blocks(p); + + return [ + (h0>>>24) & 0xff, (h0>>>16) & 0xff, (h0>>>8) & 0xff, (h0>>>0) & 0xff, + (h1>>>24) & 0xff, (h1>>>16) & 0xff, (h1>>>8) & 0xff, (h1>>>0) & 0xff, + (h2>>>24) & 0xff, (h2>>>16) & 0xff, (h2>>>8) & 0xff, (h2>>>0) & 0xff, + (h3>>>24) & 0xff, (h3>>>16) & 0xff, (h3>>>8) & 0xff, (h3>>>0) & 0xff, + (h4>>>24) & 0xff, (h4>>>16) & 0xff, (h4>>>8) & 0xff, (h4>>>0) & 0xff, + (h5>>>24) & 0xff, (h5>>>16) & 0xff, (h5>>>8) & 0xff, (h5>>>0) & 0xff, + (h6>>>24) & 0xff, (h6>>>16) & 0xff, (h6>>>8) & 0xff, (h6>>>0) & 0xff, + (h7>>>24) & 0xff, (h7>>>16) & 0xff, (h7>>>8) & 0xff, (h7>>>0) & 0xff + ]; + } + + function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) { + // compress password if it's longer than hash block length + password = password.length <= 64 ? password : SHA256(password); + + var i; + var innerLen = 64 + salt.length + 4; + var inner = new Array(innerLen); + var outerKey = new Array(64); + var dk = []; + + // inner = (password ^ ipad) || salt || counter + for (i = 0; i < 64; i++) inner[i] = 0x36; + for (i = 0; i < password.length; i++) inner[i] ^= password[i]; + for (i = 0; i < salt.length; i++) inner[64+i] = salt[i]; + for (i = innerLen - 4; i < innerLen; i++) inner[i] = 0; + + // outerKey = password ^ opad + for (i = 0; i < 64; i++) outerKey[i] = 0x5c; + for (i = 0; i < password.length; i++) outerKey[i] ^= password[i]; + + // increments counter inside inner + function incrementCounter() { + for (var i = innerLen-1; i >= innerLen-4; i--) { + inner[i]++; + if (inner[i] <= 0xff) return; + inner[i] = 0; + } + } + + // output blocks = SHA256(outerKey || SHA256(inner)) ... + while (dkLen >= 32) { + incrementCounter(); + dk = dk.concat(SHA256(outerKey.concat(SHA256(inner)))); + dkLen -= 32; + } + if (dkLen > 0) { + incrementCounter(); + dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen)); + } + + return dk; + } + + // The following is an adaptation of scryptsy + // See: https://www.npmjs.com/package/scryptsy + function blockmix_salsa8(BY, Yi, r, x, _X) { + var i; + + arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16); + for (i = 0; i < 2 * r; i++) { + blockxor(BY, i * 16, _X, 16); + salsa20_8(_X, x); + arraycopy(_X, 0, BY, Yi + (i * 16), 16); + } + + for (i = 0; i < r; i++) { + arraycopy(BY, Yi + (i * 2) * 16, BY, (i * 16), 16); + } + + for (i = 0; i < r; i++) { + arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16); + } + } + + function R(a, b) { + return (a << b) | (a >>> (32 - b)); + } + + function salsa20_8(B, x) { + arraycopy(B, 0, x, 0, 16); + + for (var i = 8; i > 0; i -= 2) { + x[ 4] ^= R(x[ 0] + x[12], 7); + x[ 8] ^= R(x[ 4] + x[ 0], 9); + x[12] ^= R(x[ 8] + x[ 4], 13); + x[ 0] ^= R(x[12] + x[ 8], 18); + x[ 9] ^= R(x[ 5] + x[ 1], 7); + x[13] ^= R(x[ 9] + x[ 5], 9); + x[ 1] ^= R(x[13] + x[ 9], 13); + x[ 5] ^= R(x[ 1] + x[13], 18); + x[14] ^= R(x[10] + x[ 6], 7); + x[ 2] ^= R(x[14] + x[10], 9); + x[ 6] ^= R(x[ 2] + x[14], 13); + x[10] ^= R(x[ 6] + x[ 2], 18); + x[ 3] ^= R(x[15] + x[11], 7); + x[ 7] ^= R(x[ 3] + x[15], 9); + x[11] ^= R(x[ 7] + x[ 3], 13); + x[15] ^= R(x[11] + x[ 7], 18); + x[ 1] ^= R(x[ 0] + x[ 3], 7); + x[ 2] ^= R(x[ 1] + x[ 0], 9); + x[ 3] ^= R(x[ 2] + x[ 1], 13); + x[ 0] ^= R(x[ 3] + x[ 2], 18); + x[ 6] ^= R(x[ 5] + x[ 4], 7); + x[ 7] ^= R(x[ 6] + x[ 5], 9); + x[ 4] ^= R(x[ 7] + x[ 6], 13); + x[ 5] ^= R(x[ 4] + x[ 7], 18); + x[11] ^= R(x[10] + x[ 9], 7); + x[ 8] ^= R(x[11] + x[10], 9); + x[ 9] ^= R(x[ 8] + x[11], 13); + x[10] ^= R(x[ 9] + x[ 8], 18); + x[12] ^= R(x[15] + x[14], 7); + x[13] ^= R(x[12] + x[15], 9); + x[14] ^= R(x[13] + x[12], 13); + x[15] ^= R(x[14] + x[13], 18); + } + + for (i = 0; i < 16; ++i) { + B[i] += x[i]; + } + } + + // naive approach... going back to loop unrolling may yield additional performance + function blockxor(S, Si, D, len) { + for (var i = 0; i < len; i++) { + D[i] ^= S[Si + i]; + } + } + + function arraycopy(src, srcPos, dest, destPos, length) { + while (length--) { + dest[destPos++] = src[srcPos++]; + } + } + + function checkBufferish(o) { + if (!o || typeof(o.length) !== 'number') { + return false; + } + for (var i = 0; i < o.length; i++) { + if (typeof(o[i]) !== 'number') { return false; } + + var v = parseInt(o[i]); + if (v != o[i] || v < 0 || v >= 256) { + return false; + } + } + return true; + } + + function ensureInteger(value, name) { + var intValue = parseInt(value); + if (value != intValue) { throw new Error('invalid ' + name); } + return intValue; + } + + // N = Cpu cost, r = Memory cost, p = parallelization cost + // callback(error, progress, key) + function scrypt(password, salt, N, r, p, dkLen, callback) { + + if (!callback) { throw new Error('missing callback'); } + + N = ensureInteger(N, 'N'); + r = ensureInteger(r, 'r'); + p = ensureInteger(p, 'p'); + + dkLen = ensureInteger(dkLen, 'dkLen'); + + if (N === 0 || (N & (N - 1)) !== 0) { throw new Error('N must be power of 2'); } + + if (N > MAX_VALUE / 128 / r) { throw new Error('N too large'); } + if (r > MAX_VALUE / 128 / p) { throw new Error('r too large'); } + + if (!checkBufferish(password)) { + throw new Error('password must be an array or buffer'); + } + password = Array.prototype.slice.call(password); + + if (!checkBufferish(salt)) { + throw new Error('salt must be an array or buffer'); + } + salt = Array.prototype.slice.call(salt); + + var b = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r); + var B = new Uint32Array(p * 32 * r); + for (var i = 0; i < B.length; i++) { + var j = i * 4; + B[i] = ((b[j + 3] & 0xff) << 24) | + ((b[j + 2] & 0xff) << 16) | + ((b[j + 1] & 0xff) << 8) | + ((b[j + 0] & 0xff) << 0); + } + + var XY = new Uint32Array(64 * r); + var V = new Uint32Array(32 * r * N); + + var Yi = 32 * r; + + // scratch space + var x = new Uint32Array(16); // salsa20_8 + var _X = new Uint32Array(16); // blockmix_salsa8 + + var totalOps = p * N * 2; + var currentOp = 0; + var lastPercent10 = null; + + // Set this to true to abandon the scrypt on the next step + var stop = false; + + // State information + var state = 0; + var i0 = 0, i1; + var Bi; + + // How many blockmix_salsa8 can we do per step? + var limit = parseInt(1000 / r); + + // Trick from scrypt-async; if there is a setImmediate shim in place, use it + var nextTick = (typeof(setImmediate) !== 'undefined') ? setImmediate : setTimeout; + + // This is really all I changed; making scryptsy a state machine so we occasionally + // stop and give other evnts on the evnt loop a chance to run. ~RicMoo + var incrementalSMix = function() { + if (stop) { + return callback(new Error('cancelled'), currentOp / totalOps); + } + + switch (state) { + case 0: + // for (var i = 0; i < p; i++)... + Bi = i0 * 32 * r; + + arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1 + + state = 1; // Move to ROMix 2 + i1 = 0; + + // Fall through + + case 1: + + // Run up to 1000 steps of the first inner smix loop + var steps = N - i1; + if (steps > limit) { steps = limit; } + for (var i = 0; i < steps; i++) { // ROMix - 2 + arraycopy(XY, 0, V, (i1 + i) * Yi, Yi); // ROMix - 3 + blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 4 + } + + // for (var i = 0; i < N; i++) + i1 += steps; + currentOp += steps; + + // Call the callback with the progress (optionally stopping us) + var percent10 = parseInt(1000 * currentOp / totalOps); + if (percent10 !== lastPercent10) { + stop = callback(null, currentOp / totalOps); + if (stop) { break; } + lastPercent10 = percent10; + } + + if (i1 < N) { + break; + } + + i1 = 0; // Move to ROMix 6 + state = 2; + + // Fall through + + case 2: + + // Run up to 1000 steps of the second inner smix loop + var steps = N - i1; + if (steps > limit) { steps = limit; } + for (var i = 0; i < steps; i++) { // ROMix - 6 + var offset = (2 * r - 1) * 16; // ROMix - 7 + var j = XY[offset] & (N - 1); + blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner) + blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer) + } + + // for (var i = 0; i < N; i++)... + i1 += steps; + currentOp += steps; + + // Call the callback with the progress (optionally stopping us) + var percent10 = parseInt(1000 * currentOp / totalOps); + if (percent10 !== lastPercent10) { + stop = callback(null, currentOp / totalOps); + if (stop) { break; } + lastPercent10 = percent10; + } + + if (i1 < N) { + break; + } + + arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10 + + // for (var i = 0; i < p; i++)... + i0++; + if (i0 < p) { + state = 0; + break; + } + + b = []; + for (var i = 0; i < B.length; i++) { + b.push((B[i] >> 0) & 0xff); + b.push((B[i] >> 8) & 0xff); + b.push((B[i] >> 16) & 0xff); + b.push((B[i] >> 24) & 0xff); + } + + var derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b, dkLen); + + // Done; don't break (which would reschedule) + return callback(null, 1.0, derivedKey); + } + + // Schedule the next steps + nextTick(incrementalSMix); + }; + + // Bootstrap the incremental smix + incrementalSMix(); + } + + // node.js + if ('object' !== 'undefined') { + module.exports = scrypt; + + // RequireJS/AMD + // http://www.requirejs.org/docs/api.html + // https://github.com/amdjs/amdjs-api/wiki/AMD + } else if (typeof(undefined) === 'function' && undefined.amd) { + undefined(scrypt); + + // Web Browsers + } else if (root) { + + // If there was an existing library "scrypt", make sure it is still available + if (root.scrypt) { + root._scrypt = root.scrypt; + } + + root.scrypt = scrypt; + } + +})(commonjsGlobal); +}); + +var rng; + +if (commonjsGlobal.crypto && crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // Moderately fast, high quality + var _rnds8 = new Uint8Array(16); + rng = function whatwgRNG() { + crypto.getRandomValues(_rnds8); + return _rnds8; + }; +} + +if (!rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) r = Math.random() * 0x100000000; + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; +} + +var rngBrowser = rng; + +// uuid.js +// +// Copyright (c) 2010-2012 Robert Kieffer +// MIT License - http://opensource.org/licenses/mit-license.php + +// Unique ID creation requires a high quality random # generator. We feature +// detect to determine the best RNG source, normalizing to a function that +// returns 128-bits of randomness, since that's what's usually required + + +// Maps for number <-> hex string conversion +var _byteToHex = []; +var _hexToByte = {}; +for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; +} + +// **`parse()` - Parse a UUID into it's component bytes** +function parse$1(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; +} + +// **`unparse()` - Convert UUID byte array (ala parse()) into a string** +function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; +} + +// **`v1()` - Generate time-based UUID** +// +// Inspired by https://github.com/LiosK/UUID.js +// and http://docs.python.org/library/uuid.html + +// random #'s we need to init node and clockseq +var _seedBytes = rngBrowser(); + +// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) +var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] +]; + +// Per 4.2.2, randomize (14 bit) clockseq +var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + +// Previous uuid creation time +var _lastMSecs = 0, _lastNSecs = 0; + +// See https://github.com/broofa/node-uuid for API details +function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); +} + +// **`v4()` - Generate random UUID** + +// See https://github.com/broofa/node-uuid for API details +function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new Array(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || rngBrowser)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); +} + +// Export public API +var uuid = v4; +uuid.v1 = v1; +uuid.v4 = v4; +uuid.parse = parse$1; +uuid.unparse = unparse; + +var uuid_1 = uuid; + +"use strict"; +// Exported Types +class KeystoreAccount extends Description { + isKeystoreAccount(value) { + return !!(value && value._isKeystoreAccount); + } +} +function decrypt$1(json, password, progressCallback) { + let data = JSON.parse(json); + let passwordBytes = getPassword(password); + let decrypt = function (key, ciphertext) { + let cipher = searchPath(data, "crypto/cipher"); + if (cipher === "aes-128-ctr") { + let iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv")); + let counter = new aesJs.Counter(iv); + let aesCtr = new aesJs.ModeOfOperation.ctr(key, counter); + return arrayify(aesCtr.decrypt(ciphertext)); + } + return null; + }; + let computeMAC = function (derivedHalf, ciphertext) { + return keccak256(concat([derivedHalf, ciphertext])); + }; + let getAccount = function (key, reject) { + let ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext")); + let computedMAC = hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); + if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) { + reject(new Error("invalid password")); + return null; + } + let privateKey = decrypt(key.slice(0, 16), ciphertext); + let mnemonicKey = key.slice(32, 64); + if (!privateKey) { + reject(new Error("unsupported cipher")); + return null; + } + let address = computeAddress(privateKey); + if (data.address) { + let check = data.address.toLowerCase(); + if (check.substring(0, 2) !== "0x") { + check = "0x" + check; + } + try { + if (getAddress(check) !== address) { + reject(new Error("address mismatch")); + return null; + } + } + catch (e) { } + } + let account = { + _isKeystoreAccount: true, + address: address, + privateKey: hexlify(privateKey) + }; + // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase + if (searchPath(data, "x-ethers/version") === "0.1") { + let mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext")); + let mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter")); + let mnemonicCounter = new aesJs.Counter(mnemonicIv); + let mnemonicAesCtr = new aesJs.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + let path = searchPath(data, "x-ethers/path") || defaultPath; + let entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); + let mnemonic = entropyToMnemonic(entropy); + let node = HDNode.fromMnemonic(mnemonic).derivePath(path); + if (node.privateKey != account.privateKey) { + reject(new Error("mnemonic mismatch")); + return null; + } + account.mnemonic = node.mnemonic; + account.path = node.path; + } + return new KeystoreAccount(account); + }; + return new Promise(function (resolve, reject) { + let kdf = searchPath(data, "crypto/kdf"); + if (kdf && typeof (kdf) === "string") { + if (kdf.toLowerCase() === "scrypt") { + let salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); + let N = parseInt(searchPath(data, "crypto/kdfparams/n")); + let r = parseInt(searchPath(data, "crypto/kdfparams/r")); + let p = parseInt(searchPath(data, "crypto/kdfparams/p")); + if (!N || !r || !p) { + reject(new Error("unsupported key-derivation function parameters")); + return; + } + // Make sure N is a power of 2 + if ((N & (N - 1)) !== 0) { + reject(new Error("unsupported key-derivation function parameter value for N")); + return; + } + let dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + if (progressCallback) { + progressCallback(0); + } + scrypt(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = arrayify(key); + let account = getAccount(key, reject); + if (!account) { + return; + } + if (progressCallback) { + progressCallback(1); + } + resolve(account); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + } + else if (kdf.toLowerCase() === "pbkdf2") { + let salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); + let prfFunc = null; + let prf = searchPath(data, "crypto/kdfparams/prf"); + if (prf === "hmac-sha256") { + prfFunc = "sha256"; + } + else if (prf === "hmac-sha512") { + prfFunc = "sha512"; + } + else { + reject(new Error("unsupported prf")); + return; + } + let c = parseInt(searchPath(data, "crypto/kdfparams/c")); + let dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + let key = arrayify(browser_1$1(passwordBytes, salt, c, dkLen, prfFunc)); + let account = getAccount(key, reject); + if (!account) { + return; + } + resolve(account); + } + else { + reject(new Error("unsupported key-derivation function")); + } + } + else { + reject(new Error("unsupported key-derivation function")); + } + }); +} +function encrypt(account, password, options, progressCallback) { + try { + if (getAddress(account.address) !== computeAddress(account.privateKey)) { + throw new Error("address/privateKey mismatch"); + } + if (account.mnemonic != null) { + let node = HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || defaultPath); + if (node.privateKey != account.privateKey) { + throw new Error("mnemonic mismatch"); + } + } + else if (account.path != null) { + throw new Error("cannot specify path without mnemonic"); + } + } + catch (e) { + return Promise.reject(e); + } + // the options are optional, so adjust the call as needed + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (!options) { + options = {}; + } + let privateKey = arrayify(account.privateKey); + let passwordBytes = getPassword(password); + let entropy = null; + let path = account.path; + if (account.mnemonic) { + entropy = arrayify(mnemonicToEntropy(account.mnemonic)); + if (!path) { + path = defaultPath; + } + } + let client = options.client; + if (!client) { + client = "ethers.js"; + } + // Check/generate the salt + let salt = null; + if (options.salt) { + salt = arrayify(options.salt); + } + else { + salt = browser_2$2(32); + ; + } + // Override initialization vector + let iv = null; + if (options.iv) { + iv = arrayify(options.iv); + if (iv.length !== 16) { + throw new Error("invalid iv"); + } + } + else { + iv = browser_2$2(16); + } + // Override the uuid + let uuidRandom = null; + if (options.uuid) { + uuidRandom = arrayify(options.uuid); + if (uuidRandom.length !== 16) { + throw new Error("invalid uuid"); + } + } + else { + uuidRandom = browser_2$2(16); + } + // Override the scrypt password-based key derivation function parameters + let N = (1 << 17), r = 8, p = 1; + if (options.scrypt) { + if (options.scrypt.N) { + N = options.scrypt.N; + } + if (options.scrypt.r) { + r = options.scrypt.r; + } + if (options.scrypt.p) { + p = options.scrypt.p; + } + } + return new Promise(function (resolve, reject) { + if (progressCallback) { + progressCallback(0); + } + // We take 64 bytes: + // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) + // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) + scrypt(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = arrayify(key); + // This will be used to encrypt the wallet (as per Web3 secret storage) + let derivedKey = key.slice(0, 16); + let macPrefix = key.slice(16, 32); + // This will be used to encrypt the mnemonic phrase (if any) + let mnemonicKey = key.slice(32, 64); + // Encrypt the private key + let counter = new aesJs.Counter(iv); + let aesCtr = new aesJs.ModeOfOperation.ctr(derivedKey, counter); + let ciphertext = arrayify(aesCtr.encrypt(privateKey)); + // Compute the message authentication code, used to check the password + let mac = keccak256(concat([macPrefix, ciphertext])); + // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition + let data = { + address: account.address.substring(2).toLowerCase(), + id: uuid_1.v4({ random: uuidRandom }), + version: 3, + Crypto: { + cipher: "aes-128-ctr", + cipherparams: { + iv: hexlify(iv).substring(2), + }, + ciphertext: hexlify(ciphertext).substring(2), + kdf: "scrypt", + kdfparams: { + salt: hexlify(salt).substring(2), + n: N, + dklen: 32, + p: p, + r: r + }, + mac: mac.substring(2) + } + }; + // If we have a mnemonic, encrypt it into the JSON wallet + if (entropy) { + let mnemonicIv = browser_2$2(16); + let mnemonicCounter = new aesJs.Counter(mnemonicIv); + let mnemonicAesCtr = new aesJs.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + let mnemonicCiphertext = arrayify(mnemonicAesCtr.encrypt(entropy)); + let now = new Date(); + let timestamp = (now.getUTCFullYear() + "-" + + zpad(now.getUTCMonth() + 1, 2) + "-" + + zpad(now.getUTCDate(), 2) + "T" + + zpad(now.getUTCHours(), 2) + "-" + + zpad(now.getUTCMinutes(), 2) + "-" + + zpad(now.getUTCSeconds(), 2) + ".0Z"); + data["x-ethers"] = { + client: client, + gethFilename: ("UTC--" + timestamp + "--" + data.address), + mnemonicCounter: hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2), + path: path, + version: "0.1" + }; + } + if (progressCallback) { + progressCallback(1); + } + resolve(JSON.stringify(data)); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + }); +} + +"use strict"; +function decryptJsonWallet(json, password, progressCallback) { + if (isCrowdsaleWallet(json)) { + if (progressCallback) { + progressCallback(0); + } + let account = decrypt(json, password); + if (progressCallback) { + progressCallback(1); + } + return Promise.resolve(account); + } + if (isKeystoreWallet(json)) { + return decrypt$1(json, password, progressCallback); + } + return Promise.reject(new Error("invalid JSON wallet")); +} + +const version$g = "wallet/5.0.0-beta.130"; + +"use strict"; +const logger$j = new Logger(version$g); +function isAccount(value) { + return (value != null && isHexString(value.privateKey, 32) && value.address != null); +} +class Wallet extends Signer { + constructor(privateKey, provider) { + logger$j.checkNew(new.target, Wallet); + super(); + if (isAccount(privateKey)) { + let signingKey = new SigningKey(privateKey.privateKey); + defineReadOnly(this, "_signingKey", () => signingKey); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + if (this.address !== getAddress(privateKey.address)) { + logger$j.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); + } + if (privateKey.mnemonic != null) { + let mnemonic = privateKey.mnemonic; + let path = privateKey.path || defaultPath; + defineReadOnly(this, "_mnemonic", () => mnemonic); + defineReadOnly(this, "path", privateKey.path); + let node = HDNode.fromMnemonic(mnemonic).derivePath(path); + if (computeAddress(node.privateKey) !== this.address) { + logger$j.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); + } + } + else { + defineReadOnly(this, "_mnemonic", () => null); + defineReadOnly(this, "path", null); + } + } + else { + if (SigningKey.isSigningKey(privateKey)) { + if (privateKey.curve !== "secp256k1") { + logger$j.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); + } + defineReadOnly(this, "_signingKey", () => privateKey); + } + else { + let signingKey = new SigningKey(privateKey); + defineReadOnly(this, "_signingKey", () => signingKey); + } + defineReadOnly(this, "_mnemonic", () => null); + defineReadOnly(this, "path", null); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + } + if (provider && !Provider.isProvider(provider)) { + logger$j.throwArgumentError("invalid provider", "provider", provider); + } + defineReadOnly(this, "provider", provider || null); + } + get mnemonic() { return this._mnemonic(); } + get privateKey() { return this._signingKey().privateKey; } + get publicKey() { return this._signingKey().publicKey; } + getAddress() { + return Promise.resolve(this.address); + } + connect(provider) { + return new Wallet(this, provider); + } + signTransaction(transaction) { + return resolveProperties(transaction).then((tx) => { + if (tx.from != null) { + if (getAddress(tx.from) !== this.address) { + throw new Error("transaction from address mismatch"); + } + delete tx.from; + } + let signature = this._signingKey().signDigest(keccak256(serialize(tx))); + return serialize(tx, signature); + }); + } + signMessage(message) { + return Promise.resolve(joinSignature(this._signingKey().signDigest(hashMessage(message)))); + } + encrypt(password, options, progressCallback) { + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (progressCallback && typeof (progressCallback) !== "function") { + throw new Error("invalid callback"); + } + if (!options) { + options = {}; + } + return encrypt(this, password, options, progressCallback); + } + /** + * Static methods to create Wallet instances. + */ + static createRandom(options) { + let entropy = browser_2$2(16); + if (!options) { + options = {}; + } + if (options.extraEntropy) { + entropy = arrayify(hexDataSlice(keccak256(concat([entropy, options.extraEntropy])), 0, 16)); + } + let mnemonic = entropyToMnemonic(entropy, options.locale); + return Wallet.fromMnemonic(mnemonic, options.path, options.locale); + } + static fromEncryptedJson(json, password, progressCallback) { + return decryptJsonWallet(json, password, progressCallback).then((account) => { + return new Wallet(account); + }); + } + static fromMnemonic(mnemonic, path, wordlist) { + if (!path) { + path = defaultPath; + } + return new Wallet(HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); + } +} +function verifyMessage(message, signature) { + return recoverAddress(hashMessage(message), signature); +} + +const version$h = "networks/5.0.0-beta.129"; + +"use strict"; +const logger$k = new Logger(version$h); +function ethDefaultProvider(network) { + return function (providers, options) { + if (options == null) { + options = {}; + } + let providerList = []; + if (providers.InfuraProvider) { + try { + providerList.push(new providers.InfuraProvider(network, options.infura)); + } + catch (error) { } + } + if (providers.EtherscanProvider) { + try { + providerList.push(new providers.EtherscanProvider(network, options.etherscan)); + } + catch (error) { } + } + if (providers.NodesmithProvider) { + try { + providerList.push(new providers.NodesmithProvider(network, options.nodesmith)); + } + catch (error) { } + } + if (providers.AlchemyProvider) { + try { + providerList.push(new providers.AlchemyProvider(network, options.alchemy)); + } + catch (error) { } + } + if (providers.CloudflareProvider) { + try { + providerList.push(new providers.CloudflareProvider(network)); + } + catch (error) { } + } + if (providerList.length === 0) { + return null; + } + if (providers.FallbackProvider) { + return new providers.FallbackProvider(providerList); + ; + } + return providerList[0]; + }; +} +function etcDefaultProvider(url, network) { + return function (providers, options) { + if (providers.JsonRpcProvider) { + return new providers.JsonRpcProvider(url, network); + } + return null; + }; +} +const homestead = { + chainId: 1, + ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b", + name: "homestead", + _defaultProvider: ethDefaultProvider("homestead") +}; +const ropsten = { + chainId: 3, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "ropsten", + _defaultProvider: ethDefaultProvider("ropsten") +}; +const networks = { + unspecified: { + chainId: 0, + name: "unspecified" + }, + homestead: homestead, + mainnet: homestead, + morden: { + chainId: 2, + name: "morden" + }, + ropsten: ropsten, + testnet: ropsten, + rinkeby: { + chainId: 4, + ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A", + name: "rinkeby", + _defaultProvider: ethDefaultProvider("rinkeby") + }, + kovan: { + chainId: 42, + name: "kovan", + _defaultProvider: ethDefaultProvider("kovan") + }, + goerli: { + chainId: 5, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "goerli", + _defaultProvider: ethDefaultProvider("goerli") + }, + classic: { + chainId: 61, + name: "classic", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io", "classic") + }, + classicTestnet: { + chainId: 62, + name: "classicTestnet", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io/morden", "classicTestnet") + } +}; +/** + * getNetwork + * + * Converts a named common networks or chain ID (network ID) to a Network + * and verifies a network is a valid Network.. + */ +function getNetwork(network) { + // No network (null) + if (network == null) { + return null; + } + if (typeof (network) === "number") { + for (let name in networks) { + let standard = networks[name]; + if (standard.chainId === network) { + return { + name: standard.name, + chainId: standard.chainId, + ensAddress: (standard.ensAddress || null), + _defaultProvider: (standard._defaultProvider || null) + }; + } + } + return { + chainId: network, + name: "unknown" + }; + } + if (typeof (network) === "string") { + let standard = networks[network]; + if (standard == null) { + return null; + } + return { + name: standard.name, + chainId: standard.chainId, + ensAddress: standard.ensAddress, + _defaultProvider: (standard._defaultProvider || null) + }; + } + let standard = networks[network.name]; + // Not a standard network; check that it is a valid network in general + if (!standard) { + if (typeof (network.chainId) !== "number") { + logger$k.throwArgumentError("invalid network chainId", "network", network); + } + return network; + } + // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) + if (network.chainId !== 0 && network.chainId !== standard.chainId) { + logger$k.throwArgumentError("network chainId mismatch", "network", network); + } + // Standard Network (allow overriding the ENS address) + return { + name: network.name, + chainId: standard.chainId, + ensAddress: (network.ensAddress || standard.ensAddress || null), + _defaultProvider: (network._defaultProvider || standard._defaultProvider || null) + }; +} + +var browserPonyfill = createCommonjsModule(function (module, exports) { +var __self__ = (function (root) { +function F() { +this.fetch = false; +this.DOMException = root.DOMException; +} +F.prototype = root; +return new F(); +})(typeof self !== 'undefined' ? self : commonjsGlobal); +(function(self) { + +var irrelevant = (function (exports) { + var support = { + searchParams: 'URLSearchParams' in self, + iterable: 'Symbol' in self && 'iterator' in Symbol, + blob: + 'FileReader' in self && + 'Blob' in self && + (function() { + try { + new Blob(); + return true + } catch (e) { + return false + } + })(), + formData: 'FormData' in self, + arrayBuffer: 'ArrayBuffer' in self + }; + + function isDataView(obj) { + return obj && DataView.prototype.isPrototypeOf(obj) + } + + if (support.arrayBuffer) { + var viewClasses = [ + '[object Int8Array]', + '[object Uint8Array]', + '[object Uint8ClampedArray]', + '[object Int16Array]', + '[object Uint16Array]', + '[object Int32Array]', + '[object Uint32Array]', + '[object Float32Array]', + '[object Float64Array]' + ]; + + var isArrayBufferView = + ArrayBuffer.isView || + function(obj) { + return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 + }; + } + + function normalizeName(name) { + if (typeof name !== 'string') { + name = String(name); + } + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { + throw new TypeError('Invalid character in header field name') + } + return name.toLowerCase() + } + + function normalizeValue(value) { + if (typeof value !== 'string') { + value = String(value); + } + return value + } + + // Build a destructive iterator for the value list + function iteratorFor(items) { + var iterator = { + next: function() { + var value = items.shift(); + return {done: value === undefined, value: value} + } + }; + + if (support.iterable) { + iterator[Symbol.iterator] = function() { + return iterator + }; + } + + return iterator + } + + function Headers(headers) { + this.map = {}; + + if (headers instanceof Headers) { + headers.forEach(function(value, name) { + this.append(name, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function(header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function(name) { + this.append(name, headers[name]); + }, this); + } + } + + Headers.prototype.append = function(name, value) { + name = normalizeName(name); + value = normalizeValue(value); + var oldValue = this.map[name]; + this.map[name] = oldValue ? oldValue + ', ' + value : value; + }; + + Headers.prototype['delete'] = function(name) { + delete this.map[normalizeName(name)]; + }; + + Headers.prototype.get = function(name) { + name = normalizeName(name); + return this.has(name) ? this.map[name] : null + }; + + Headers.prototype.has = function(name) { + return this.map.hasOwnProperty(normalizeName(name)) + }; + + Headers.prototype.set = function(name, value) { + this.map[normalizeName(name)] = normalizeValue(value); + }; + + Headers.prototype.forEach = function(callback, thisArg) { + for (var name in this.map) { + if (this.map.hasOwnProperty(name)) { + callback.call(thisArg, this.map[name], name, this); + } + } + }; + + Headers.prototype.keys = function() { + var items = []; + this.forEach(function(value, name) { + items.push(name); + }); + return iteratorFor(items) + }; + + Headers.prototype.values = function() { + var items = []; + this.forEach(function(value) { + items.push(value); + }); + return iteratorFor(items) + }; + + Headers.prototype.entries = function() { + var items = []; + this.forEach(function(value, name) { + items.push([name, value]); + }); + return iteratorFor(items) + }; + + if (support.iterable) { + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; + } + + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError('Already read')) + } + body.bodyUsed = true; + } + + function fileReaderReady(reader) { + return new Promise(function(resolve, reject) { + reader.onload = function() { + resolve(reader.result); + }; + reader.onerror = function() { + reject(reader.error); + }; + }) + } + + function readBlobAsArrayBuffer(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsArrayBuffer(blob); + return promise + } + + function readBlobAsText(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsText(blob); + return promise + } + + function readArrayBufferAsText(buf) { + var view = new Uint8Array(buf); + var chars = new Array(view.length); + + for (var i = 0; i < view.length; i++) { + chars[i] = String.fromCharCode(view[i]); + } + return chars.join('') + } + + function bufferClone(buf) { + if (buf.slice) { + return buf.slice(0) + } else { + var view = new Uint8Array(buf.byteLength); + view.set(new Uint8Array(buf)); + return view.buffer + } + } + + function Body() { + this.bodyUsed = false; + + this._initBody = function(body) { + this._bodyInit = body; + if (!body) { + this._bodyText = ''; + } else if (typeof body === 'string') { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); + // IE 10-11 can't handle a DataView body. + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } + + if (!this.headers.get('content-type')) { + if (typeof body === 'string') { + this.headers.set('content-type', 'text/plain;charset=UTF-8'); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set('content-type', this._bodyBlob.type); + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + } + } + }; + + if (support.blob) { + this.blob = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as blob') + } else { + return Promise.resolve(new Blob([this._bodyText])) + } + }; + + this.arrayBuffer = function() { + if (this._bodyArrayBuffer) { + return consumed(this) || Promise.resolve(this._bodyArrayBuffer) + } else { + return this.blob().then(readBlobAsArrayBuffer) + } + }; + } + + this.text = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as text') + } else { + return Promise.resolve(this._bodyText) + } + }; + + if (support.formData) { + this.formData = function() { + return this.text().then(decode) + }; + } + + this.json = function() { + return this.text().then(JSON.parse) + }; + + return this + } + + // HTTP methods whose capitalization should be normalized + var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; + + function normalizeMethod(method) { + var upcased = method.toUpperCase(); + return methods.indexOf(upcased) > -1 ? upcased : method + } + + function Request(input, options) { + options = options || {}; + var body = options.body; + + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError('Already read') + } + this.url = input.url; + this.credentials = input.credentials; + if (!options.headers) { + this.headers = new Headers(input.headers); + } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } + + this.credentials = options.credentials || this.credentials || 'same-origin'; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } + this.method = normalizeMethod(options.method || this.method || 'GET'); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; + + if ((this.method === 'GET' || this.method === 'HEAD') && body) { + throw new TypeError('Body not allowed for GET or HEAD requests') + } + this._initBody(body); + } + + Request.prototype.clone = function() { + return new Request(this, {body: this._bodyInit}) + }; + + function decode(body) { + var form = new FormData(); + body + .trim() + .split('&') + .forEach(function(bytes) { + if (bytes) { + var split = bytes.split('='); + var name = split.shift().replace(/\+/g, ' '); + var value = split.join('=').replace(/\+/g, ' '); + form.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + return form + } + + function parseHeaders(rawHeaders) { + var headers = new Headers(); + // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space + // https://tools.ietf.org/html/rfc7230#section-3.2 + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); + preProcessedHeaders.split(/\r?\n/).forEach(function(line) { + var parts = line.split(':'); + var key = parts.shift().trim(); + if (key) { + var value = parts.join(':').trim(); + headers.append(key, value); + } + }); + return headers + } + + Body.call(Request.prototype); + + function Response(bodyInit, options) { + if (!options) { + options = {}; + } + + this.type = 'default'; + this.status = options.status === undefined ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = 'statusText' in options ? options.statusText : 'OK'; + this.headers = new Headers(options.headers); + this.url = options.url || ''; + this._initBody(bodyInit); + } + + Body.call(Response.prototype); + + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }) + }; + + Response.error = function() { + var response = new Response(null, {status: 0, statusText: ''}); + response.type = 'error'; + return response + }; + + var redirectStatuses = [301, 302, 303, 307, 308]; + + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code') + } + + return new Response(null, {status: status, headers: {location: url}}) + }; + + exports.DOMException = self.DOMException; + try { + new exports.DOMException(); + } catch (err) { + exports.DOMException = function(message, name) { + this.message = message; + this.name = name; + var error = Error(message); + this.stack = error.stack; + }; + exports.DOMException.prototype = Object.create(Error.prototype); + exports.DOMException.prototype.constructor = exports.DOMException; + } + + function fetch(input, init) { + return new Promise(function(resolve, reject) { + var request = new Request(input, init); + + if (request.signal && request.signal.aborted) { + return reject(new exports.DOMException('Aborted', 'AbortError')) + } + + var xhr = new XMLHttpRequest(); + + function abortXhr() { + xhr.abort(); + } + + xhr.onload = function() { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || '') + }; + options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); + var body = 'response' in xhr ? xhr.response : xhr.responseText; + resolve(new Response(body, options)); + }; + + xhr.onerror = function() { + reject(new TypeError('Network request failed')); + }; + + xhr.ontimeout = function() { + reject(new TypeError('Network request failed')); + }; + + xhr.onabort = function() { + reject(new exports.DOMException('Aborted', 'AbortError')); + }; + + xhr.open(request.method, request.url, true); + + if (request.credentials === 'include') { + xhr.withCredentials = true; + } else if (request.credentials === 'omit') { + xhr.withCredentials = false; + } + + if ('responseType' in xhr && support.blob) { + xhr.responseType = 'blob'; + } + + request.headers.forEach(function(value, name) { + xhr.setRequestHeader(name, value); + }); + + if (request.signal) { + request.signal.addEventListener('abort', abortXhr); + + xhr.onreadystatechange = function() { + // DONE (success or failure) + if (xhr.readyState === 4) { + request.signal.removeEventListener('abort', abortXhr); + } + }; + } + + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); + }) + } + + fetch.polyfill = true; + + if (!self.fetch) { + self.fetch = fetch; + self.Headers = Headers; + self.Request = Request; + self.Response = Response; + } + + exports.Headers = Headers; + exports.Request = Request; + exports.Response = Response; + exports.fetch = fetch; + + return exports; + +}({})); +})(__self__); +delete __self__.fetch.polyfill; +exports = __self__.fetch; // To enable: import fetch from 'cross-fetch' +exports.default = __self__.fetch; // For TypeScript consumers without esModuleInterop. +exports.fetch = __self__.fetch; // To enable: import {fetch} from 'cross-fetch' +exports.Headers = __self__.Headers; +exports.Request = __self__.Request; +exports.Response = __self__.Response; +module.exports = exports; +}); +var browserPonyfill_1 = browserPonyfill.fetch; +var browserPonyfill_2 = browserPonyfill.Headers; +var browserPonyfill_3 = browserPonyfill.Request; +var browserPonyfill_4 = browserPonyfill.Response; + +var browser$8 = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + +function decode(textData) { + textData = atob(textData); + var data = []; + for (var i = 0; i < textData.length; i++) { + data.push(textData.charCodeAt(i)); + } + return module$1.arrayify(data); +} +exports.decode = decode; +function encode(data) { + data = module$1.arrayify(data); + var textData = ""; + for (var i = 0; i < data.length; i++) { + textData += String.fromCharCode(data[i]); + } + return btoa(textData); +} +exports.encode = encode; +}); + +var browser$9 = unwrapExports(browser$8); +var browser_1$4 = browser$8.decode; +var browser_2$3 = browser$8.encode; + +var browser$a = /*#__PURE__*/Object.freeze({ + 'default': browser$9, + __moduleExports: browser$8, + decode: browser_1$4, + encode: browser_2$3 +}); + +const version$i = "web/5.0.0-beta.129"; + +"use strict"; +const logger$l = new Logger(version$i); +function fetchJson(connection, json, processFunc) { + let headers = {}; + let url = null; + // @TODO: Allow ConnectionInfo to override some of these values + let options = { + method: "GET", + mode: "cors", + cache: "no-cache", + credentials: "same-origin", + redirect: "follow", + referrer: "client", + }; + let timeout = 2 * 60 * 1000; + if (typeof (connection) === "string") { + url = connection; + } + else if (typeof (connection) === "object") { + if (connection == null || connection.url == null) { + logger$l.throwArgumentError("missing URL", "connection.url", connection); + } + url = connection.url; + if (typeof (connection.timeout) === "number" && connection.timeout > 0) { + timeout = connection.timeout; + } + if (connection.headers) { + for (let key in connection.headers) { + headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) }; + } + } + if (connection.user != null && connection.password != null) { + if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) { + logger$l.throwError("basic authentication requires a secure https url", Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" }); + } + let authorization = connection.user + ":" + connection.password; + headers["authorization"] = { + key: "Authorization", + value: "Basic " + browser_2$3(toUtf8Bytes(authorization)) + }; + } + } + return new Promise(function (resolve, reject) { + let timer = null; + if (timeout) { + timer = setTimeout(() => { + if (timer == null) { + return; + } + timer = null; + reject(logger$l.makeError("timeout", Logger.errors.TIMEOUT, { timeout: timeout })); + }, timeout); + } + let cancelTimeout = () => { + if (timer == null) { + return; + } + clearTimeout(timer); + timer = null; + }; + if (json) { + options.method = "POST"; + options.body = json; + headers["content-type"] = { key: "Content-Type", value: "application/json" }; + } + let flatHeaders = {}; + Object.keys(headers).forEach((key) => { + let header = headers[key]; + flatHeaders[header.key] = header.value; + }); + options.headers = flatHeaders; + return browserPonyfill(url, options).then((response) => { + return response.text().then((body) => { + if (!response.ok) { + logger$l.throwError("bad response", Logger.errors.SERVER_ERROR, { + status: response.status, + body: body, + type: response.type, + url: response.url + }); + } + return body; + }); + }).then((text) => { + let json = null; + try { + json = JSON.parse(text); + } + catch (error) { + logger$l.throwError("invalid JSON", Logger.errors.SERVER_ERROR, { + body: text, + error: error, + url: url + }); + } + if (processFunc) { + try { + json = processFunc(json); + } + catch (error) { + logger$l.throwError("processing response error", Logger.errors.SERVER_ERROR, { + body: json, + error: error + }); + } + } + return json; + }, (error) => { + throw error; + }).then((result) => { + cancelTimeout(); + resolve(result); + }, (error) => { + cancelTimeout(); + reject(error); + }); + }); +} +function poll(func, options) { + if (!options) { + options = {}; + } + options = shallowCopy(options); + if (options.floor == null) { + options.floor = 0; + } + if (options.ceiling == null) { + options.ceiling = 10000; + } + if (options.interval == null) { + options.interval = 250; + } + return new Promise(function (resolve, reject) { + let timer = null; + let done = false; + // Returns true if cancel was successful. Unsuccessful cancel means we're already done. + let cancel = () => { + if (done) { + return false; + } + done = true; + if (timer) { + clearTimeout(timer); + } + return true; + }; + if (options.timeout) { + timer = setTimeout(() => { + if (cancel()) { + reject(new Error("timeout")); + } + }, options.timeout); + } + let retryLimit = options.retryLimit; + let attempt = 0; + function check() { + return func().then(function (result) { + // If we have a result, or are allowed null then we're done + if (result !== undefined) { + if (cancel()) { + resolve(result); + } + } + else if (options.onceBlock) { + options.onceBlock.once("block", check); + // Otherwise, exponential back-off (up to 10s) our next request + } + else if (!done) { + attempt++; + if (attempt > retryLimit) { + if (cancel()) { + reject(new Error("retry limit reached")); + } + return; + } + let timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); + if (timeout < options.floor) { + timeout = options.floor; + } + if (timeout > options.ceiling) { + timeout = options.ceiling; + } + setTimeout(check, timeout); + } + return null; + }, function (error) { + if (cancel()) { + reject(error); + } + }); + } + check(); + }); +} + +const version$j = "providers/5.0.0-beta.141"; + +"use strict"; +const logger$m = new Logger(version$j); +class Formatter { + constructor() { + logger$m.checkNew(new.target, Formatter); + this.formats = this.getDefaultFormats(); + } + getDefaultFormats() { + let formats = ({}); + let address = this.address.bind(this); + let bigNumber = this.bigNumber.bind(this); + let blockTag = this.blockTag.bind(this); + let data = this.data.bind(this); + let hash = this.hash.bind(this); + let hex = this.hex.bind(this); + let number = this.number.bind(this); + let strictData = (v) => { return this.data(v, true); }; + formats.transaction = { + hash: hash, + blockHash: Formatter.allowNull(hash, null), + blockNumber: Formatter.allowNull(number, null), + transactionIndex: Formatter.allowNull(number, null), + confirmations: Formatter.allowNull(number, null), + from: address, + gasPrice: bigNumber, + gasLimit: bigNumber, + to: Formatter.allowNull(address, null), + value: bigNumber, + nonce: number, + data: data, + r: Formatter.allowNull(this.uint256), + s: Formatter.allowNull(this.uint256), + v: Formatter.allowNull(number), + creates: Formatter.allowNull(address, null), + raw: Formatter.allowNull(data), + }; + formats.transactionRequest = { + from: Formatter.allowNull(address), + nonce: Formatter.allowNull(number), + gasLimit: Formatter.allowNull(bigNumber), + gasPrice: Formatter.allowNull(bigNumber), + to: Formatter.allowNull(address), + value: Formatter.allowNull(bigNumber), + data: Formatter.allowNull(strictData), + }; + formats.receiptLog = { + transactionLogIndex: Formatter.allowNull(number), + transactionIndex: number, + blockNumber: number, + transactionHash: hash, + address: address, + topics: Formatter.arrayOf(hash), + data: data, + logIndex: number, + blockHash: hash, + }; + formats.receipt = { + to: Formatter.allowNull(this.address), + from: Formatter.allowNull(this.address), + contractAddress: Formatter.allowNull(address, null), + transactionIndex: number, + root: Formatter.allowNull(hash), + gasUsed: bigNumber, + logsBloom: Formatter.allowNull(data), + blockHash: hash, + transactionHash: hash, + logs: Formatter.arrayOf(this.receiptLog.bind(this)), + blockNumber: number, + confirmations: Formatter.allowNull(number, null), + cumulativeGasUsed: bigNumber, + status: Formatter.allowNull(number) + }; + formats.block = { + hash: hash, + parentHash: hash, + number: number, + timestamp: number, + nonce: Formatter.allowNull(hex), + difficulty: this.difficulty.bind(this), + gasLimit: bigNumber, + gasUsed: bigNumber, + miner: address, + extraData: data, + transactions: Formatter.allowNull(Formatter.arrayOf(hash)), + }; + formats.blockWithTransactions = shallowCopy(formats.block); + formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); + formats.filter = { + fromBlock: Formatter.allowNull(blockTag, undefined), + toBlock: Formatter.allowNull(blockTag, undefined), + blockHash: Formatter.allowNull(hash, undefined), + address: Formatter.allowNull(address, undefined), + topics: Formatter.allowNull(this.topics.bind(this), undefined), + }; + formats.filterLog = { + blockNumber: Formatter.allowNull(number), + blockHash: Formatter.allowNull(hash), + transactionIndex: number, + removed: Formatter.allowNull(this.boolean.bind(this)), + address: address, + data: Formatter.allowFalsish(data, "0x"), + topics: Formatter.arrayOf(hash), + transactionHash: hash, + logIndex: number, + }; + return formats; + } + // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number + // Strict! Used on input. + number(number) { + return BigNumber.from(number).toNumber(); + } + // Strict! Used on input. + bigNumber(value) { + return BigNumber.from(value); + } + // Requires a boolean, "true" or "false"; returns a boolean + boolean(value) { + if (typeof (value) === "boolean") { + return value; + } + if (typeof (value) === "string") { + value = value.toLowerCase(); + if (value === "true") { + return true; + } + if (value === "false") { + return false; + } + } + throw new Error("invaid boolean - " + value); + } + hex(value, strict) { + if (typeof (value) === "string") { + if (!strict && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexString(value)) { + return value.toLowerCase(); + } + } + return logger$m.throwArgumentError("invalid hash", "value", value); + } + data(value, strict) { + let result = this.hex(value, strict); + if ((result.length % 2) !== 0) { + throw new Error("invalid data; odd-length - " + value); + } + return result; + } + // Requires an address + // Strict! Used on input. + address(value) { + return getAddress(value); + } + callAddress(value) { + if (!isHexString(value, 32)) { + return null; + } + let address = getAddress(hexDataSlice(value, 12)); + return (address === AddressZero) ? null : address; + } + contractAddress(value) { + return getContractAddress(value); + } + // Strict! Used on input. + blockTag(blockTag) { + if (blockTag == null) { + return "latest"; + } + if (blockTag === "earliest") { + return "0x0"; + } + if (blockTag === "latest" || blockTag === "pending") { + return blockTag; + } + if (typeof (blockTag) === "number" || isHexString(blockTag)) { + return hexValue(blockTag); + } + throw new Error("invalid blockTag"); + } + // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. + hash(value, strict) { + let result = this.hex(value, strict); + if (hexDataLength(result) !== 32) { + return logger$m.throwArgumentError("invalid hash", "value", value); + } + return result; + } + // Returns the difficulty as a number, or if too large (i.e. PoA network) null + difficulty(value) { + let v = BigNumber.from(value); + try { + return v.toNumber(); + } + catch (error) { } + return null; + } + uint256(value) { + if (!isHexString(value)) { + throw new Error("invalid uint256"); + } + return hexZeroPad(value, 32); + } + _block(value, format) { + if (value.author != null && value.miner == null) { + value.miner = value.author; + } + return Formatter.check(format, value); + } + block(value) { + return this._block(value, this.formats.block); + } + blockWithTransactions(value) { + return this._block(value, this.formats.blockWithTransactions); + } + // Strict! Used on input. + transactionRequest(value) { + return Formatter.check(this.formats.transactionRequest, value); + } + transactionResponse(transaction) { + // Rename gas to gasLimit + if (transaction.gas != null && transaction.gasLimit == null) { + transaction.gasLimit = transaction.gas; + } + // Some clients (TestRPC) do strange things like return 0x0 for the + // 0 address; correct this to be a real address + if (transaction.to && BigNumber.from(transaction.to).isZero()) { + transaction.to = "0x0000000000000000000000000000000000000000"; + } + // Rename input to data + if (transaction.input != null && transaction.data == null) { + transaction.data = transaction.input; + } + // If to and creates are empty, populate the creates from the transaction + if (transaction.to == null && transaction.creates == null) { + transaction.creates = this.contractAddress(transaction); + } + // @TODO: use transaction.serialize? Have to add support for including v, r, and s... + /* + if (!transaction.raw) { + + // Very loose providers (e.g. TestRPC) do not provide a signature or raw + if (transaction.v && transaction.r && transaction.s) { + let raw = [ + stripZeros(hexlify(transaction.nonce)), + stripZeros(hexlify(transaction.gasPrice)), + stripZeros(hexlify(transaction.gasLimit)), + (transaction.to || "0x"), + stripZeros(hexlify(transaction.value || "0x")), + hexlify(transaction.data || "0x"), + stripZeros(hexlify(transaction.v || "0x")), + stripZeros(hexlify(transaction.r)), + stripZeros(hexlify(transaction.s)), + ]; + + transaction.raw = rlpEncode(raw); + } + } + */ + let result = Formatter.check(this.formats.transaction, transaction); + let networkId = transaction.networkId; + // geth-etc returns chainId + if (transaction.chainId != null && networkId == null && result.v == null) { + networkId = transaction.chainId; + } + if (isHexString(networkId)) { + networkId = BigNumber.from(networkId).toNumber(); + } + if (typeof (networkId) !== "number" && result.v != null) { + networkId = (result.v - 35) / 2; + if (networkId < 0) { + networkId = 0; + } + networkId = parseInt(networkId); + } + if (typeof (networkId) !== "number") { + networkId = 0; + } + result.networkId = networkId; + // 0x0000... should actually be null + if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { + result.blockHash = null; + } + return result; + } + transaction(value) { + return parse(value); + } + receiptLog(value) { + return Formatter.check(this.formats.receiptLog, value); + } + receipt(value) { + //let status = transactionReceipt.status; + //let root = transactionReceipt.root; + let result = Formatter.check(this.formats.receipt, value); + result.logs.forEach((entry, index) => { + if (entry.transactionLogIndex == null) { + entry.transactionLogIndex = index; + } + }); + if (value.status != null) { + result.byzantium = true; + } + return result; + } + topics(value) { + if (Array.isArray(value)) { + return value.map((v) => this.topics(v)); + } + else if (value != null) { + return this.hash(value, true); + } + return null; + } + filter(value) { + return Formatter.check(this.formats.filter, value); + } + filterLog(value) { + return Formatter.check(this.formats.filterLog, value); + } + static check(format, object) { + let result = {}; + for (let key in format) { + try { + let value = format[key](object[key]); + if (value !== undefined) { + result[key] = value; + } + } + catch (error) { + error.checkKey = key; + error.checkValue = object[key]; + throw error; + } + } + return result; + } + // if value is null-ish, nullValue is returned + static allowNull(format, nullValue) { + return (function (value) { + if (value == null) { + return nullValue; + } + return format(value); + }); + } + // If value is false-ish, replaceValue is returned + static allowFalsish(format, replaceValue) { + return (function (value) { + if (!value) { + return replaceValue; + } + return format(value); + }); + } + // Requires an Array satisfying check + static arrayOf(format) { + return (function (array) { + if (!Array.isArray(array)) { + throw new Error("not an array"); + } + let result = []; + array.forEach(function (value) { + result.push(format(value)); + }); + return result; + }); + } +} + +"use strict"; +const logger$n = new Logger(version$j); +////////////////////////////// +// Event Serializeing +function checkTopic(topic) { + if (topic == null) { + return "null"; + } + if (hexDataLength(topic) !== 32) { + logger$n.throwArgumentError("invalid topic", "topic", topic); + } + return topic.toLowerCase(); +} +function serializeTopics(topics) { + // Remove trailing null AND-topics; they are redundant + topics = topics.slice(); + while (topics[topics.length - 1] == null) { + topics.pop(); + } + return topics.map((topic) => { + if (Array.isArray(topic)) { + // Only track unique OR-topics + let unique = {}; + topic.forEach((topic) => { + unique[checkTopic(topic)] = true; + }); + // The order of OR-topics does not matter + let sorted = Object.keys(unique); + sorted.sort(); + return sorted.join("|"); + } + else { + return checkTopic(topic); + } + }).join("&"); +} +function deserializeTopics(data) { + return data.split(/&/g).map((topic) => { + return topic.split("|").map((topic) => { + return ((topic === "null") ? null : topic); + }); + }); +} +function getEventTag$1(eventName) { + if (typeof (eventName) === "string") { + eventName = eventName.toLowerCase(); + if (hexDataLength(eventName) === 32) { + return "tx:" + eventName; + } + if (eventName.indexOf(":") === -1) { + return eventName; + } + } + else if (Array.isArray(eventName)) { + return "filter:*:" + serializeTopics(eventName); + } + else if (ForkEvent.isForkEvent(eventName)) { + logger$n.warn("not implemented"); + throw new Error("not implemented"); + } + else if (eventName && typeof (eventName) === "object") { + return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); + } + throw new Error("invalid event - " + eventName); +} +////////////////////////////// +// Helper Object +function getTime() { + return (new Date()).getTime(); +} +////////////////////////////// +// Provider Object +/** + * EventType + * - "block" + * - "pending" + * - "error" + * - filter + * - topics array + * - transaction hash + */ +class Event { + constructor(tag, listener, once) { + defineReadOnly(this, "tag", tag); + defineReadOnly(this, "listener", listener); + defineReadOnly(this, "once", once); + } + pollable() { + return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); + } +} +let defaultFormatter = null; +let nextPollId = 1; +class BaseProvider extends Provider { + constructor(network) { + logger$n.checkNew(new.target, Provider); + super(); + this.formatter = new.target.getFormatter(); + if (network instanceof Promise) { + defineReadOnly(this, "ready", network.then((network) => { + defineReadOnly(this, "_network", network); + return network; + })); + // Squash any "unhandled promise" errors; that do not need to be handled + this.ready.catch((error) => { }); + } + else { + let knownNetwork = getStatic((new.target), "getNetwork")(network); + if (knownNetwork) { + defineReadOnly(this, "_network", knownNetwork); + defineReadOnly(this, "ready", Promise.resolve(this._network)); + } + else { + logger$n.throwArgumentError("invalid network", "network", network); + } + } + this._lastBlockNumber = -2; + // Events being listened to + this._events = []; + this._pollingInterval = 4000; + this._emitted = { block: -2 }; + this._fastQueryDate = 0; + } + static getFormatter() { + if (defaultFormatter == null) { + defaultFormatter = new Formatter(); + } + return defaultFormatter; + } + static getNetwork(network) { + return getNetwork((network == null) ? "homestead" : network); + } + poll() { + let pollId = nextPollId++; + this.emit("willPoll", pollId); + // Track all running promises, so we can trigger a post-poll once they are complete + let runners = []; + this.getBlockNumber().then((blockNumber) => { + this._setFastBlockNumber(blockNumber); + // If the block has not changed, meh. + if (blockNumber === this._lastBlockNumber) { + return; + } + // First polling cycle, trigger a "block" events + if (this._emitted.block === -2) { + this._emitted.block = blockNumber - 1; + } + // Notify all listener for each block that has passed + for (let i = this._emitted.block + 1; i <= blockNumber; i++) { + this.emit("block", i); + } + // The emitted block was updated, check for obsolete events + if (this._emitted.block !== blockNumber) { + this._emitted.block = blockNumber; + Object.keys(this._emitted).forEach((key) => { + // The block event does not expire + if (key === "block") { + return; + } + // The block we were at when we emitted this event + let eventBlockNumber = this._emitted[key]; + // We cannot garbage collect pending transactions or blocks here + // They should be garbage collected by the Provider when setting + // "pending" events + if (eventBlockNumber === "pending") { + return; + } + // Evict any transaction hashes or block hashes over 12 blocks + // old, since they should not return null anyways + if (blockNumber - eventBlockNumber > 12) { + delete this._emitted[key]; + } + }); + } + // First polling cycle + if (this._lastBlockNumber === -2) { + this._lastBlockNumber = blockNumber - 1; + } + // Find all transaction hashes we are waiting on + this._events.forEach((event) => { + let comps = event.tag.split(":"); + switch (comps[0]) { + case "tx": { + let hash = comps[1]; + let runner = this.getTransactionReceipt(hash).then((receipt) => { + if (!receipt || receipt.blockNumber == null) { + return null; + } + this._emitted["t:" + hash] = receipt.blockNumber; + this.emit(hash, receipt); + return null; + }).catch((error) => { this.emit("error", error); }); + runners.push(runner); + break; + } + case "filter": { + let topics = deserializeTopics(comps[2]); + let filter = { + address: comps[1], + fromBlock: this._lastBlockNumber + 1, + toBlock: blockNumber, + topics: topics + }; + if (!filter.address) { + delete filter.address; + } + let runner = this.getLogs(filter).then((logs) => { + if (logs.length === 0) { + return; + } + logs.forEach((log) => { + this._emitted["b:" + log.blockHash] = log.blockNumber; + this._emitted["t:" + log.transactionHash] = log.blockNumber; + this.emit(filter, log); + }); + return null; + }).catch((error) => { this.emit("error", error); }); + runners.push(runner); + break; + } + } + }); + this._lastBlockNumber = blockNumber; + return null; + }).catch((error) => { }); + Promise.all(runners).then(() => { + this.emit("didPoll", pollId); + }); + } + resetEventsBlock(blockNumber) { + this._lastBlockNumber = blockNumber - 1; + if (this.polling) { + this.poll(); + } + } + get network() { + return this._network; + } + getNetwork() { + return this.ready; + } + get blockNumber() { + return this._fastBlockNumber; + } + get polling() { + return (this._poller != null); + } + set polling(value) { + setTimeout(() => { + if (value && !this._poller) { + this._poller = setInterval(this.poll.bind(this), this.pollingInterval); + } + else if (!value && this._poller) { + clearInterval(this._poller); + this._poller = null; + } + }, 0); + } + get pollingInterval() { + return this._pollingInterval; + } + set pollingInterval(value) { + if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) { + throw new Error("invalid polling interval"); + } + this._pollingInterval = value; + if (this._poller) { + clearInterval(this._poller); + this._poller = setInterval(() => { this.poll(); }, this._pollingInterval); + } + } + _getFastBlockNumber() { + let now = getTime(); + // Stale block number, request a newer value + if ((now - this._fastQueryDate) > 2 * this._pollingInterval) { + this._fastQueryDate = now; + this._fastBlockNumberPromise = this.getBlockNumber().then((blockNumber) => { + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + } + return this._fastBlockNumber; + }); + } + return this._fastBlockNumberPromise; + } + _setFastBlockNumber(blockNumber) { + // Older block, maybe a stale request + if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { + return; + } + // Update the time we updated the blocknumber + this._fastQueryDate = getTime(); + // Newer block number, use it + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + this._fastBlockNumberPromise = Promise.resolve(blockNumber); + } + } + // @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event; + // this will be used once we move to the WebSocket or other alternatives to polling + waitForTransaction(transactionHash, confirmations) { + if (confirmations == null) { + confirmations = 1; + } + if (confirmations === 0) { + return this.getTransactionReceipt(transactionHash); + } + return new Promise((resolve) => { + let handler = (receipt) => { + if (receipt.confirmations < confirmations) { + return; + } + this.removeListener(transactionHash, handler); + resolve(receipt); + }; + this.on(transactionHash, handler); + }); + } + _runPerform(method, params) { + return this.ready.then(() => { + // Execute all the functions now that we are "ready" + Object.keys(params).forEach((key) => { + params[key] = params[key](); + }); + return resolveProperties(params).then((params) => { + return this.perform(method, params); + }); + }); + } + getBlockNumber() { + return this._runPerform("getBlockNumber", {}).then((result) => { + let value = parseInt(result); + if (value != result) { + throw new Error("invalid response - getBlockNumber"); + } + this._setFastBlockNumber(value); + return value; + }); + } + getGasPrice() { + return this._runPerform("getGasPrice", {}).then((result) => { + return BigNumber.from(result); + }); + } + getBalance(addressOrName, blockTag) { + return this._runPerform("getBalance", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return BigNumber.from(result); + }); + } + getTransactionCount(addressOrName, blockTag) { + return this._runPerform("getTransactionCount", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return BigNumber.from(result).toNumber(); + }); + } + getCode(addressOrName, blockTag) { + return this._runPerform("getCode", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return hexlify(result); + }); + } + getStorageAt(addressOrName, position, blockTag) { + return this._runPerform("getStorageAt", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag), + position: () => Promise.resolve(position).then((p) => hexValue(p)) + }).then((result) => { + return hexlify(result); + }); + } + // This should be called by any subclass wrapping a TransactionResponse + _wrapTransaction(tx, hash) { + if (hash != null && hexDataLength(hash) !== 32) { + throw new Error("invalid response - sendTransaction"); + } + let result = tx; + // Check the hash we expect is the same as the hash the server reported + if (hash != null && tx.hash !== hash) { + logger$n.throwError("Transaction hash mismatch from Provider.sendTransaction.", Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + } + // @TODO: (confirmations? number, timeout? number) + result.wait = (confirmations) => { + // We know this transaction *must* exist (whether it gets mined is + // another story), so setting an emitted value forces us to + // wait even if the node returns null for the receipt + if (confirmations !== 0) { + this._emitted["t:" + tx.hash] = "pending"; + } + return this.waitForTransaction(tx.hash, confirmations).then((receipt) => { + if (receipt == null && confirmations === 0) { + return null; + } + // No longer pending, allow the polling loop to garbage collect this + this._emitted["t:" + tx.hash] = receipt.blockNumber; + if (receipt.status === 0) { + logger$n.throwError("transaction failed", Logger.errors.CALL_EXCEPTION, { + transactionHash: tx.hash, + transaction: tx, + receipt: receipt + }); + } + return receipt; + }); + }; + return result; + } + sendTransaction(signedTransaction) { + return this._runPerform("sendTransaction", { + signedTransaction: () => Promise.resolve(signedTransaction).then(t => hexlify(t)) + }).then((result) => { + return this._wrapTransaction(this.formatter.transaction(signedTransaction), result); + }, (error) => { + error.transaction = this.formatter.transaction(signedTransaction); + if (error.transaction.hash) { + error.transactionHash = error.transaction.hash; + } + throw error; + }); + } + _getTransactionRequest(transaction) { + return Promise.resolve(transaction).then((t) => { + let tx = {}; + ["from", "to"].forEach((key) => { + if (t[key] == null) { + return; + } + tx[key] = Promise.resolve(t[key]).then(a => (a ? this._getAddress(a) : null)); + }); + ["data", "gasLimit", "gasPrice", "value"].forEach((key) => { + if (t[key] == null) { + return; + } + tx[key] = t[key]; + }); + return resolveProperties(tx).then((t) => this.formatter.transactionRequest(t)); + }); + } + _getFilter(filter) { + return Promise.resolve(filter).then((f) => { + let filter = {}; + if (f.address != null) { + filter.address = this._getAddress(f.address); + } + if (f.topics) { + filter.topics = f.topics; + } + if (f.blockHash != null) { + filter.blockHash = f.blockHash; + } + ["fromBlock", "toBlock"].forEach((key) => { + if (f[key] == null) { + return; + } + filter[key] = this._getBlockTag(f[key]); + }); + return resolveProperties(filter).then((f) => this.formatter.filter(f)); + }); + } + call(transaction, blockTag) { + return this._runPerform("call", { + transaction: () => this._getTransactionRequest(transaction), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return hexlify(result); + }); + } + estimateGas(transaction) { + return this._runPerform("estimateGas", { + transaction: () => this._getTransactionRequest(transaction) + }).then((result) => { + return BigNumber.from(result); + }); + } + _getAddress(addressOrName) { + return this.resolveName(addressOrName).then((address) => { + if (address == null) { + logger$n.throwError("ENS name not configured", Logger.errors.UNSUPPORTED_OPERATION, { + operation: `resolveName(${JSON.stringify(addressOrName)})` + }); + } + return address; + }); + } + _getBlock(blockHashOrBlockTag, includeTransactions) { + return this.ready.then(() => { + return this._getBlockTag(blockHashOrBlockTag).then((blockHashOrBlockTag) => { + let params = { + includeTransactions: !!includeTransactions + }; + // Exactly one of blockHash or blockTag will be set + let blockHash = null; + let blockTag = null; + // If blockTag is a number (not "latest", etc), this is the block number + let blockNumber = -128; + if (isHexString(blockHashOrBlockTag, 32)) { + params.blockHash = blockHashOrBlockTag; + } + else { + try { + params.blockTag = this.formatter.blockTag(blockHashOrBlockTag); + if (isHexString(params.blockTag)) { + blockNumber = parseInt(params.blockTag.substring(2), 16); + } + } + catch (error) { + logger$n.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + } + } + return poll(() => { + return this.perform("getBlock", params).then((block) => { + // Block was not found + if (block == null) { + // For blockhashes, if we didn't say it existed, that blockhash may + // not exist. If we did see it though, perhaps from a log, we know + // it exists, and this node is just not caught up yet. + if (blockHash) { + if (this._emitted["b:" + blockHash] == null) { + return null; + } + } + // For block tags, if we are asking for a future block, we return null + if (blockTag) { + if (blockNumber > this._emitted.block) { + return null; + } + } + // Retry on the next block + return undefined; + } + // Add transactions + if (includeTransactions) { + return this.formatter.blockWithTransactions(block); + } + return this.formatter.block(block); + }); + }, { onceBlock: this }); + }); + }); + } + getBlock(blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, false)); + } + getBlockWithTransactions(blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, true)); + } + getTransaction(transactionHash) { + return this.ready.then(() => { + return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => { + let params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return poll(() => { + return this.perform("getTransaction", params).then((result) => { + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + let tx = this.formatter.transactionResponse(result); + if (tx.blockNumber == null) { + tx.confirmations = 0; + } + else if (tx.confirmations == null) { + return this._getFastBlockNumber().then((blockNumber) => { + // Add the confirmations using the fast block number (pessimistic) + let confirmations = (blockNumber - tx.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + tx.confirmations = confirmations; + return this._wrapTransaction(tx); + }); + } + return this._wrapTransaction(tx); + }); + }, { onceBlock: this }); + }); + }); + } + getTransactionReceipt(transactionHash) { + return this.ready.then(() => { + return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => { + let params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return poll(() => { + return this.perform("getTransactionReceipt", params).then((result) => { + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + // "geth-etc" returns receipts before they are ready + if (result.blockHash == null) { + return undefined; + } + let receipt = this.formatter.receipt(result); + if (receipt.blockNumber == null) { + receipt.confirmations = 0; + } + else if (receipt.confirmations == null) { + return this._getFastBlockNumber().then((blockNumber) => { + // Add the confirmations using the fast block number (pessimistic) + let confirmations = (blockNumber - receipt.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + receipt.confirmations = confirmations; + return receipt; + }); + } + return receipt; + }); + }, { onceBlock: this }); + }); + }); + } + getLogs(filter) { + return this._runPerform("getLogs", { + filter: () => this._getFilter(filter) + }).then((result) => { + return Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(result); + }); + } + getEtherPrice() { + return this._runPerform("getEtherPrice", {}).then((result) => { + return result; + }); + } + _getBlockTag(blockTag) { + if (blockTag instanceof Promise) { + return blockTag.then((b) => this._getBlockTag(b)); + } + if (typeof (blockTag) === "number" && blockTag < 0) { + if (blockTag % 1) { + logger$n.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + } + return this._getFastBlockNumber().then((bn) => { + bn += blockTag; + if (bn < 0) { + bn = 0; + } + return this.formatter.blockTag(bn); + }); + } + return Promise.resolve(this.formatter.blockTag(blockTag)); + } + _getResolver(name) { + // Get the resolver from the blockchain + return this.getNetwork().then((network) => { + // No ENS... + if (!network.ensAddress) { + logger$n.throwError("network does support ENS", Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); + } + // keccak256("resolver(bytes32)") + let data = "0x0178b8bf" + namehash(name).substring(2); + let transaction = { to: network.ensAddress, data: data }; + return this.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + }); + } + resolveName(name) { + // If it is a promise, resolve it then recurse + if (name instanceof Promise) { + return name.then((addressOrName) => this.resolveName(addressOrName)); + } + // If it is already an address, nothing to resolve + try { + return Promise.resolve(this.formatter.address(name)); + } + catch (error) { } + // Get the addr from the resovler + return this._getResolver(name).then((resolverAddress) => { + if (!resolverAddress) { + return null; + } + // keccak256("addr(bytes32)") + let data = "0x3b3b57de" + namehash(name).substring(2); + let transaction = { to: resolverAddress, data: data }; + return this.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + }); + } + lookupAddress(address) { + if (address instanceof Promise) { + return address.then((address) => this.lookupAddress(address)); + } + address = this.formatter.address(address); + let name = address.substring(2) + ".addr.reverse"; + return this._getResolver(name).then((resolverAddress) => { + if (!resolverAddress) { + return null; + } + // keccak("name(bytes32)") + let data = "0x691f3431" + namehash(name).substring(2); + return this.call({ to: resolverAddress, data: data }).then((data) => { + let bytes = arrayify(data); + // Strip off the dynamic string pointer (0x20) + if (bytes.length < 32 || !BigNumber.from(bytes.slice(0, 32)).eq(32)) { + return null; + } + bytes = bytes.slice(32); + if (bytes.length < 32) { + return null; + } + let length = BigNumber.from(bytes.slice(0, 32)).toNumber(); + bytes = bytes.slice(32); + if (length > bytes.length) { + return null; + } + let name = toUtf8String(bytes.slice(0, length)); + // Make sure the reverse record matches the foward record + return this.resolveName(name).then((addr) => { + if (addr != address) { + return null; + } + return name; + }); + }); + }); + } + perform(method, params) { + return logger$n.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); + } + _startPending() { + console.log("WARNING: this provider does not support pending events"); + } + _stopPending() { + } + // Returns true if there are events that still require polling + _checkPolling() { + this.polling = (this._events.filter((e) => e.pollable()).length > 0); + } + _addEventListener(eventName, listener, once) { + this._events.push(new Event(getEventTag$1(eventName), listener, once)); + if (eventName === "pending") { + this._startPending(); + } + // Do we still now have any events that require polling? + this._checkPolling(); + return this; + } + on(eventName, listener) { + return this._addEventListener(eventName, listener, false); + } + once(eventName, listener) { + return this._addEventListener(eventName, listener, true); + } + emit(eventName, ...args) { + let result = false; + let eventTag = getEventTag$1(eventName); + this._events = this._events.filter((event) => { + if (event.tag !== eventTag) { + return true; + } + setTimeout(() => { + event.listener.apply(this, args); + }, 0); + result = true; + return !(event.once); + }); + // Do we still have any events that require polling? ("once" events remove themselves) + this._checkPolling(); + return result; + } + listenerCount(eventName) { + if (!eventName) { + return this._events.length; + } + let eventTag = getEventTag$1(eventName); + return this._events.filter((event) => { + return (event.tag === eventTag); + }).length; + } + listeners(eventName) { + if (eventName == null) { + return this._events.map((event) => event.listener); + } + let eventTag = getEventTag$1(eventName); + return this._events + .filter((event) => (event.tag === eventTag)) + .map((event) => event.listener); + } + off(eventName, listener) { + if (listener == null) { + return this.removeAllListeners(eventName); + } + let found = false; + let eventTag = getEventTag$1(eventName); + this._events = this._events.filter((event) => { + if (event.tag !== eventTag || event.listener != listener) { + return true; + } + if (found) { + return true; + } + found = true; + return false; + }); + if (eventName === "pending" && this.listenerCount("pending") === 0) { + this._stopPending(); + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + } + removeAllListeners(eventName) { + if (eventName == null) { + this._events = []; + this._stopPending(); + } + else { + let eventTag = getEventTag$1(eventName); + this._events = this._events.filter((event) => { + return (event.tag !== eventTag); + }); + if (eventName === "pending") { + this._stopPending(); + } + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + } +} + +"use strict"; +const logger$o = new Logger(version$j); +function timer(timeout) { + return new Promise(function (resolve) { + setTimeout(function () { + resolve(); + }, timeout); + }); +} +function getResult(payload) { + if (payload.error) { + // @TODO: not any + let error = new Error(payload.error.message); + error.code = payload.error.code; + error.data = payload.error.data; + throw error; + } + return payload.result; +} +function getLowerCase(value) { + if (value) { + return value.toLowerCase(); + } + return value; +} +const _constructorGuard$4 = {}; +class JsonRpcSigner extends Signer { + constructor(constructorGuard, provider, addressOrIndex) { + logger$o.checkNew(new.target, JsonRpcSigner); + super(); + if (constructorGuard !== _constructorGuard$4) { + throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); + } + defineReadOnly(this, "provider", provider); + if (addressOrIndex == null) { + addressOrIndex = 0; + } + if (typeof (addressOrIndex) === "string") { + defineReadOnly(this, "_address", this.provider.formatter.address(addressOrIndex)); + defineReadOnly(this, "_index", null); + } + else if (typeof (addressOrIndex) === "number") { + defineReadOnly(this, "_index", addressOrIndex); + defineReadOnly(this, "_address", null); + } + else { + logger$o.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); + } + } + connect(provider) { + return logger$o.throwError("cannot alter JSON-RPC Signer connection", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "connect" + }); + } + connectUnchecked() { + return new UncheckedJsonRpcSigner(_constructorGuard$4, this.provider, this._address || this._index); + } + getAddress() { + if (this._address) { + return Promise.resolve(this._address); + } + return this.provider.send("eth_accounts", []).then((accounts) => { + if (accounts.length <= this._index) { + logger$o.throwError("unknown account #" + this._index, Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getAddress" + }); + } + return this.provider.formatter.address(accounts[this._index]); + }); + } + sendUncheckedTransaction(transaction) { + transaction = shallowCopy(transaction); + let fromAddress = this.getAddress().then((address) => { + if (address) { + address = address.toLowerCase(); + } + return address; + }); + // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user + // wishes to use this, it is easy to specify explicitly, otherwise + // we look it up for them. + if (transaction.gasLimit == null) { + let estimate = shallowCopy(transaction); + estimate.from = fromAddress; + transaction.gasLimit = this.provider.estimateGas(estimate); + } + return Promise.all([ + resolveProperties(transaction), + fromAddress + ]).then((results) => { + let tx = results[0]; + let hexTx = this.provider.constructor.hexlifyTransaction(tx); + hexTx.from = results[1]; + return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => { + return hash; + }, (error) => { + if (error.responseText) { + // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) + if (error.responseText.indexOf("insufficient funds") >= 0) { + logger$o.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, { + transaction: tx + }); + } + if (error.responseText.indexOf("nonce too low") >= 0) { + logger$o.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, { + transaction: tx + }); + } + if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { + logger$o.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, { + transaction: tx + }); + } + } + throw error; + }); + }); + } + signTransaction(transaction) { + return logger$o.throwError("signing transactions is unsupported", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "signTransaction" + }); + } + sendTransaction(transaction) { + return this.sendUncheckedTransaction(transaction).then((hash) => { + return poll(() => { + return this.provider.getTransaction(hash).then((tx) => { + if (tx === null) { + return undefined; + } + return this.provider._wrapTransaction(tx, hash); + }); + }, { onceBlock: this.provider }).catch((error) => { + error.transactionHash = hash; + throw error; + }); + }); + } + signMessage(message) { + let data = ((typeof (message) === "string") ? toUtf8Bytes(message) : message); + return this.getAddress().then((address) => { + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + return this.provider.send("eth_sign", [address.toLowerCase(), hexlify(data)]); + }); + } + unlock(password) { + let provider = this.provider; + return this.getAddress().then(function (address) { + return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]); + }); + } +} +class UncheckedJsonRpcSigner extends JsonRpcSigner { + sendTransaction(transaction) { + return this.sendUncheckedTransaction(transaction).then((hash) => { + return { + hash: hash, + nonce: null, + gasLimit: null, + gasPrice: null, + data: null, + value: null, + chainId: null, + confirmations: 0, + from: null, + wait: (confirmations) => { return this.provider.waitForTransaction(hash, confirmations); } + }; + }); + } +} +const allowedTransactionKeys$3 = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +class JsonRpcProvider extends BaseProvider { + constructor(url, network) { + logger$o.checkNew(new.target, JsonRpcProvider); + // One parameter, but it is a network name, so swap it with the URL + if (typeof (url) === "string") { + if (network === null && getNetwork(url)) { + network = url; + url = null; + } + } + if (network) { + // The network has been specified explicitly, we can use it + super(network); + } + else { + // The network is unknown, query the JSON-RPC for it + let ready = new Promise((resolve, reject) => { + setTimeout(() => { + this.send("eth_chainId", []).then((result) => { + resolve(getNetwork(BigNumber.from(result).toNumber())); + }).catch((error) => { + this.send("net_version", []).then((result) => { + resolve(getNetwork(BigNumber.from(result).toNumber())); + }).catch((error) => { + reject(logger$o.makeError("could not detect network", Logger.errors.NETWORK_ERROR)); + }); + }); + }); + }); + super(ready); + } + // Default URL + if (!url) { + url = "http:/" + "/localhost:8545"; + } + if (typeof (url) === "string") { + this.connection = { + url: url + }; + } + else { + this.connection = url; + } + this._nextId = 42; + } + getSigner(addressOrIndex) { + return new JsonRpcSigner(_constructorGuard$4, this, addressOrIndex); + } + getUncheckedSigner(addressOrIndex) { + return this.getSigner(addressOrIndex).connectUnchecked(); + } + listAccounts() { + return this.send("eth_accounts", []).then((accounts) => { + return accounts.map((a) => this.formatter.address(a)); + }); + } + send(method, params) { + let request = { + method: method, + params: params, + id: (this._nextId++), + jsonrpc: "2.0" + }; + this.emit("debug", { + action: "request", + request: deepCopy(request), + provider: this + }); + return fetchJson(this.connection, JSON.stringify(request), getResult).then((result) => { + this.emit("debug", { + action: "response", + request: request, + response: result, + provider: this + }); + return result; + }); + } + perform(method, params) { + switch (method) { + case "getBlockNumber": + return this.send("eth_blockNumber", []); + case "getGasPrice": + return this.send("eth_gasPrice", []); + case "getBalance": + return this.send("eth_getBalance", [getLowerCase(params.address), params.blockTag]); + case "getTransactionCount": + return this.send("eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]); + case "getCode": + return this.send("eth_getCode", [getLowerCase(params.address), params.blockTag]); + case "getStorageAt": + return this.send("eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]); + case "sendTransaction": + return this.send("eth_sendRawTransaction", [params.signedTransaction]).catch((error) => { + if (error.responseText) { + // "insufficient funds for gas * price + value" + if (error.responseText.indexOf("insufficient funds") > 0) { + logger$o.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {}); + } + // "nonce too low" + if (error.responseText.indexOf("nonce too low") > 0) { + logger$o.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {}); + } + // "replacement transaction underpriced" + if (error.responseText.indexOf("replacement transaction underpriced") > 0) { + logger$o.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + return this.send("eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]); + } + else if (params.blockHash) { + return this.send("eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]); + } + return logger$o.throwArgumentError("invalid block tag or block hash", "params", params); + case "getTransaction": + return this.send("eth_getTransactionByHash", [params.transactionHash]); + case "getTransactionReceipt": + return this.send("eth_getTransactionReceipt", [params.transactionHash]); + case "call": + return this.send("eth_call", [this.constructor.hexlifyTransaction(params.transaction, { from: true }), params.blockTag]); + case "estimateGas": + return this.send("eth_estimateGas", [this.constructor.hexlifyTransaction(params.transaction, { from: true })]); + case "getLogs": + if (params.filter && params.filter.address != null) { + params.filter.address = getLowerCase(params.filter.address); + } + return this.send("eth_getLogs", [params.filter]); + default: + break; + } + return logger$o.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); + } + _startPending() { + if (this._pendingFilter != null) { + return; + } + let self = this; + let pendingFilter = this.send("eth_newPendingTransactionFilter", []); + this._pendingFilter = pendingFilter; + pendingFilter.then(function (filterId) { + function poll() { + self.send("eth_getFilterChanges", [filterId]).then(function (hashes) { + if (self._pendingFilter != pendingFilter) { + return null; + } + let seq = Promise.resolve(); + hashes.forEach(function (hash) { + // @TODO: This should be garbage collected at some point... How? When? + self._emitted["t:" + hash.toLowerCase()] = "pending"; + seq = seq.then(function () { + return self.getTransaction(hash).then(function (tx) { + self.emit("pending", tx); + return null; + }); + }); + }); + return seq.then(function () { + return timer(1000); + }); + }).then(function () { + if (self._pendingFilter != pendingFilter) { + self.send("eth_uninstallFilter", [filterId]); + return; + } + setTimeout(function () { poll(); }, 0); + return null; + }).catch((error) => { }); + } + poll(); + return filterId; + }).catch((error) => { }); + } + _stopPending() { + this._pendingFilter = null; + } + // Convert an ethers.js transaction into a JSON-RPC transaction + // - gasLimit => gas + // - All values hexlified + // - All numeric values zero-striped + // NOTE: This allows a TransactionRequest, but all values should be resolved + // before this is called + static hexlifyTransaction(transaction, allowExtra) { + // Check only allowed properties are given + let allowed = shallowCopy(allowedTransactionKeys$3); + if (allowExtra) { + for (let key in allowExtra) { + if (allowExtra[key]) { + allowed[key] = true; + } + } + } + checkProperties(transaction, allowed); + let result = {}; + // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. + ["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + let value = hexValue(transaction[key]); + if (key === "gasLimit") { + key = "gas"; + } + result[key] = value; + }); + ["from", "to", "data"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + result[key] = hexlify(transaction[key]); + }); + return result; + } +} + +"use strict"; +const logger$p = new Logger(version$j); +class UrlJsonRpcProvider extends JsonRpcProvider { + constructor(network, apiKey) { + logger$p.checkAbstract(new.target, UrlJsonRpcProvider); + // Normalize the Network and API Key + network = getStatic((new.target), "getNetwork")(network); + apiKey = getStatic((new.target), "getApiKey")(apiKey); + let url = getStatic((new.target), "getUrl")(network, apiKey); + super(url, network); + defineReadOnly(this, "apiKey", apiKey); + } + _startPending() { + logger$p.warn("WARNING: API provider does not support pending filters"); + } + getSigner(address) { + logger$p.throwError("API provider does not support signing", Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); + return null; + } + listAccounts() { + return Promise.resolve([]); + } + static getNetwork(network) { + return getNetwork((network == null) ? "homestead" : network); + } + // Return a defaultApiKey if null, otherwise validate the API key + static getApiKey(apiKey) { + return apiKey; + } + // Returns the url for the given network and API key + static getUrl(network, apiKey) { + return logger$p.throwError("not implemented; sub-classes must override getUrl", Logger.errors.NOT_IMPLEMENTED, { + operation: "getUrl" + }); + } +} + +"use strict"; +const logger$q = new Logger(version$j); +// This key was provided to ethers.js by Alchemy to be used by the +// default provider, but it is recommended that for your own +// production environments, that you acquire your own API key at: +// https://dashboard.alchemyapi.io +const defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"; +class AlchemyProvider extends UrlJsonRpcProvider { + static getApiKey(apiKey) { + if (apiKey == null) { + return defaultApiKey; + } + return apiKey; + } + static getUrl(network, apiKey) { + let host = null; + switch (network.name) { + case "homestead": + host = "eth-mainnet.alchemyapi.io/jsonrpc/"; + break; + case "ropsten": + host = "eth-ropsten.alchemyapi.io/jsonrpc/"; + break; + case "rinkeby": + host = "eth-rinkeby.alchemyapi.io/jsonrpc/"; + break; + case "kovan": + host = "eth-kovan.alchemyapi.io/jsonrpc/"; + break; + default: + logger$q.throwArgumentError("unsupported network", "network", arguments[0]); + } + return ("https:/" + "/" + host + apiKey); + } +} + +"use strict"; +const logger$r = new Logger(version$j); +class CloudflareProvider extends UrlJsonRpcProvider { + static getUrl(network, apiKey) { + if (apiKey != null) { + logger$r.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); + } + let host = null; + switch (network.name) { + case "homestead": + host = "https://cloudflare-eth.com/"; + break; + default: + logger$r.throwArgumentError("unsupported network", "network", arguments[0]); + } + return host; + } +} + +"use strict"; +const logger$s = new Logger(version$j); +// The transaction has already been sanitized by the calls in Provider +function getTransactionString(transaction) { + let result = []; + for (let key in transaction) { + if (transaction[key] == null) { + continue; + } + let value = hexlify(transaction[key]); + if ({ gasLimit: true, gasPrice: true, nonce: true, value: true }[key]) { + value = hexValue(value); + } + result.push(key + "=" + value); + } + return result.join("&"); +} +function getResult$1(result) { + // getLogs, getHistory have weird success responses + if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) { + return result.result; + } + if (result.status != 1 || result.message != "OK") { + // @TODO: not any + let error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + return result.result; +} +function getJsonResult(result) { + if (result.jsonrpc != "2.0") { + // @TODO: not any + let error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + if (result.error) { + // @TODO: not any + let error = new Error(result.error.message || "unknown error"); + if (result.error.code) { + error.code = result.error.code; + } + if (result.error.data) { + error.data = result.error.data; + } + throw error; + } + return result.result; +} +// The blockTag was normalized as a string by the Provider pre-perform operations +function checkLogTag(blockTag) { + if (blockTag === "pending") { + throw new Error("pending not supported"); + } + if (blockTag === "latest") { + return blockTag; + } + return parseInt(blockTag.substring(2), 16); +} +class EtherscanProvider extends BaseProvider { + constructor(network, apiKey) { + logger$s.checkNew(new.target, EtherscanProvider); + super(network); + let name = "invalid"; + if (this.network) { + name = this.network.name; + } + let baseUrl = null; + switch (name) { + case "homestead": + baseUrl = "https://api.etherscan.io"; + break; + case "ropsten": + baseUrl = "https://api-ropsten.etherscan.io"; + break; + case "rinkeby": + baseUrl = "https://api-rinkeby.etherscan.io"; + break; + case "kovan": + baseUrl = "https://api-kovan.etherscan.io"; + break; + case "goerli": + baseUrl = "https://api-goerli.etherscan.io"; + break; + default: + throw new Error("unsupported network"); + } + defineReadOnly(this, "baseUrl", baseUrl); + defineReadOnly(this, "apiKey", apiKey); + } + perform(method, params) { + let url = this.baseUrl; + let apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + let get = (url, procFunc) => { + this.emit("debug", { + action: "request", + request: url, + provider: this + }); + return fetchJson(url, null, procFunc || getJsonResult).then((result) => { + this.emit("debug", { + action: "response", + request: url, + response: deepCopy(result), + provider: this + }); + return result; + }); + }; + switch (method) { + case "getBlockNumber": + url += "/api?module=proxy&action=eth_blockNumber" + apiKey; + return get(url); + case "getGasPrice": + url += "/api?module=proxy&action=eth_gasPrice" + apiKey; + return get(url); + case "getBalance": + // Returns base-10 result + url += "/api?module=account&action=balance&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getResult$1); + case "getTransactionCount": + url += "/api?module=proxy&action=eth_getTransactionCount&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url); + case "getCode": + url += "/api?module=proxy&action=eth_getCode&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "getStorageAt": + url += "/api?module=proxy&action=eth_getStorageAt&address=" + params.address; + url += "&position=" + params.position; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "sendTransaction": + url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; + url += apiKey; + return get(url).catch((error) => { + if (error.responseText) { + // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" + if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { + logger$s.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {}); + } + // "Transaction with the same hash was already imported." + if (error.responseText.indexOf("same hash was already imported") >= 0) { + logger$s.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {}); + } + // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." + if (error.responseText.indexOf("another transaction with same nonce") >= 0) { + logger$s.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + url += "/api?module=proxy&action=eth_getBlockByNumber&tag=" + params.blockTag; + if (params.includeTransactions) { + url += "&boolean=true"; + } + else { + url += "&boolean=false"; + } + url += apiKey; + return get(url); + } + throw new Error("getBlock by blockHash not implmeneted"); + case "getTransaction": + url += "/api?module=proxy&action=eth_getTransactionByHash&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "getTransactionReceipt": + url += "/api?module=proxy&action=eth_getTransactionReceipt&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "call": { + let transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_call" + transaction; + //url += "&tag=" + params.blockTag + apiKey; + if (params.blockTag !== "latest") { + throw new Error("EtherscanProvider does not support blockTag for call"); + } + url += apiKey; + return get(url); + } + case "estimateGas": { + let transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_estimateGas&" + transaction; + url += apiKey; + return get(url); + } + case "getLogs": + url += "/api?module=logs&action=getLogs"; + try { + if (params.filter.fromBlock) { + url += "&fromBlock=" + checkLogTag(params.filter.fromBlock); + } + if (params.filter.toBlock) { + url += "&toBlock=" + checkLogTag(params.filter.toBlock); + } + if (params.filter.address) { + url += "&address=" + params.filter.address; + } + // @TODO: We can handle slightly more complicated logs using the logs API + if (params.filter.topics && params.filter.topics.length > 0) { + if (params.filter.topics.length > 1) { + throw new Error("unsupported topic format"); + } + let topic0 = params.filter.topics[0]; + if (typeof (topic0) !== "string" || topic0.length !== 66) { + throw new Error("unsupported topic0 format"); + } + url += "&topic0=" + topic0; + } + } + catch (error) { + return Promise.reject(error); + } + url += apiKey; + let self = this; + return get(url, getResult$1).then(function (logs) { + let txs = {}; + let seq = Promise.resolve(); + logs.forEach(function (log) { + seq = seq.then(function () { + if (log.blockHash != null) { + return null; + } + log.blockHash = txs[log.transactionHash]; + if (log.blockHash == null) { + return self.getTransaction(log.transactionHash).then(function (tx) { + txs[log.transactionHash] = tx.blockHash; + log.blockHash = tx.blockHash; + return null; + }); + } + return null; + }); + }); + return seq.then(function () { + return logs; + }); + }); + case "getEtherPrice": + if (this.network.name !== "homestead") { + return Promise.resolve(0.0); + } + url += "/api?module=stats&action=ethprice"; + url += apiKey; + return get(url, getResult$1).then(function (result) { + return parseFloat(result.ethusd); + }); + default: + break; + } + return super.perform(method, params); + } + // @TODO: Allow startBlock and endBlock to be Promises + getHistory(addressOrName, startBlock, endBlock) { + let url = this.baseUrl; + let apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + if (startBlock == null) { + startBlock = 0; + } + if (endBlock == null) { + endBlock = 99999999; + } + return this.resolveName(addressOrName).then((address) => { + url += "/api?module=account&action=txlist&address=" + address; + url += "&startblock=" + startBlock; + url += "&endblock=" + endBlock; + url += "&sort=asc" + apiKey; + this.emit("debug", { + action: "request", + request: url, + provider: this + }); + return fetchJson(url, null, getResult$1).then((result) => { + this.emit("debug", { + action: "response", + request: url, + response: deepCopy(result), + provider: this + }); + let output = []; + result.forEach((tx) => { + ["contractAddress", "to"].forEach(function (key) { + if (tx[key] == "") { + delete tx[key]; + } + }); + if (tx.creates == null && tx.contractAddress != null) { + tx.creates = tx.contractAddress; + } + let item = this.formatter.transactionResponse(tx); + if (tx.timeStamp) { + item.timestamp = parseInt(tx.timeStamp); + } + output.push(item); + }); + return output; + }); + }); + } +} + +"use strict"; +const logger$t = new Logger(version$j); +function now() { return (new Date()).getTime(); } +// Returns: +// - true is all networks match +// - false if any network is null +// - throws if any 2 networks do not match +function checkNetworks(networks) { + let result = true; + let check = null; + networks.forEach((network) => { + // Null + if (network == null) { + result = false; + return; + } + // Have nothing to compre to yet + if (check == null) { + check = network; + return; + } + // Matches! + if (check.name === network.name && + check.chainId === network.chainId && + ((check.ensAddress === network.ensAddress) || + (check.ensAddress == null && network.ensAddress == null))) { + return; + } + logger$t.throwArgumentError("provider mismatch", "networks", networks); + }); + return result; +} +function serialize$1(result) { + if (Array.isArray(result)) { + return JSON.stringify(result.map((r) => serialize$1(r))); + } + else if (result === null) { + return "null"; + } + else if (typeof (result) === "object") { + let keys = Object.keys(result); + keys.sort(); + return "{" + keys.map((key) => { + let value = result[key]; + if (typeof (value) === "function") { + value = "function{}"; + } + else { + value = serialize$1(value); + } + return JSON.stringify(key) + "=" + serialize$1(value); + }).join(",") + "}"; + } + return JSON.stringify(result); +} +let nextRid = 1; +class FallbackProvider extends BaseProvider { + constructor(providers, quorum, weights) { + logger$t.checkNew(new.target, FallbackProvider); + if (providers.length === 0) { + logger$t.throwArgumentError("missing providers", "providers", providers); + } + if (weights != null && weights.length !== providers.length) { + logger$t.throwArgumentError("too many weights", "weights", weights); + } + else if (!weights) { + weights = providers.map((p) => 1); + } + else { + weights.forEach((w) => { + if (w % 1 || w > 512 || w < 1) { + logger$t.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); + } + }); + } + let total = weights.reduce((accum, w) => (accum + w)); + if (quorum == null) { + quorum = total / 2; + } + else { + if (quorum > total) { + logger$t.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + } + } + // All networks are ready, we can know the network for certain + let ready = checkNetworks(providers.map((p) => p.network)); + if (ready) { + super(providers[0].network); + } + else { + // The network won't be known until all child providers know + let ready = Promise.all(providers.map((p) => p.getNetwork())).then((networks) => { + if (!checkNetworks(networks)) { + logger$t.throwError("getNetwork returned null", Logger.errors.UNKNOWN_ERROR); + } + return networks[0]; + }); + super(ready); + } + // Preserve a copy, so we do not get mutated + defineReadOnly(this, "providers", Object.freeze(providers.slice())); + defineReadOnly(this, "quorum", quorum); + defineReadOnly(this, "weights", Object.freeze(weights.slice())); + } + static doPerform(provider, method, params) { + switch (method) { + case "getBlockNumber": + case "getGasPrice": + case "getEtherPrice": + return provider[method](); + case "getBalance": + case "getTransactionCount": + case "getCode": + return provider[method](params.address, params.blockTag || "latest"); + case "getStorageAt": + return provider.getStorageAt(params.address, params.position, params.blockTag || "latest"); + case "sendTransaction": + return provider.sendTransaction(params.signedTransaction).then((result) => { + return result.hash; + }); + case "getBlock": + return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash); + case "call": + case "estimateGas": + return provider[method](params.transaction); + case "getTransaction": + case "getTransactionReceipt": + return provider[method](params.transactionHash); + case "getLogs": + return provider.getLogs(params.filter); + } + return logger$t.throwError("unknown method error", Logger.errors.UNKNOWN_ERROR, { + method: method, + params: params + }); + } + perform(method, params) { + let T0 = now(); + let runners = (browser_1$3(this.providers)).map((provider, i) => { + let weight = this.weights[i]; + let rid = nextRid++; + return { + run: () => { + let t0 = now(); + let start = t0 - T0; + this.emit("debug", { + action: "request", + rid: rid, + backend: { weight, start, provider }, + request: { method: method, params: deepCopy(params) }, + provider: this + }); + return FallbackProvider.doPerform(provider, method, params).then((result) => { + let duration = now() - t0; + this.emit("debug", { + action: "response", + rid: rid, + backend: { weight, start, duration, provider }, + request: { method: method, params: deepCopy(params) }, + response: deepCopy(result) + }); + return { weight: weight, result: result }; + }, (error) => { + let duration = now() - t0; + this.emit("debug", { + action: "response", + rid: rid, + backend: { weight, start, duration, provider }, + request: { method: method, params: deepCopy(params) }, + error: error + }); + return { weight: weight, error: error }; + }); + }, + weight: weight + }; + }); + // Broadcast transactions to all backends, any that succeed is good enough + if (method === "sendTransaction") { + return Promise.all(runners.map((r) => r.run())).then((results) => { + for (let i = 0; i < results.length; i++) { + let result = results[i]; + if (result.result) { + return result.result; + } + } + return Promise.reject(results[0].error); + }); + } + // Otherwise query backends (randomly) until we have a quorum agreement + // on the correct result + return new Promise((resolve, reject) => { + let firstError = null; + // How much weight is inflight + let inflightWeight = 0; + // All results, indexed by the serialized response. + let results = {}; + let next = () => { + if (runners.length === 0) { + return; + } + let runner = runners.shift(); + inflightWeight += runner.weight; + runner.run().then((result) => { + if (results === null) { + return; + } + inflightWeight -= runner.weight; + if (result.error) { + if (firstError == null) { + firstError = result.error; + } + } + else { + let unique = serialize$1(result.result); + if (results[unique] == null) { + results[unique] = []; + } + results[unique].push(result); + // Do any results meet our quroum? + for (let u in results) { + let weight = results[u].reduce((accum, r) => (accum + r.weight), 0); + if (weight >= this.quorum) { + let result = results[u][0].result; + this.emit("debug", "quorum", -1, { weight, result }); + resolve(result); + results = null; + return; + } + } + } + // Out of options; give up + if (runners.length === 0 && inflightWeight === 0) { + // @TODO: this might need some more thinking... Maybe only if half + // of the results contain non-error? + if (method === "getGasPrice") { + const values = []; + Object.keys(results).forEach((key) => { + results[key].forEach((result) => { + if (!result.result) { + return; + } + values.push(result.result); + }); + }); + values.sort((a, b) => { + if (a.lt(b)) { + return -1; + } + if (a.gt(b)) { + return 1; + } + return 0; + }); + let index = parseInt(String(values.length / 2)); + if (values.length % 2) { + resolve(values[index]); + return; + } + resolve(values[index - 1].add(values[index]).div(2)); + return; + } + if (firstError === null) { + firstError = logger$t.makeError("failed to meet quorum", Logger.errors.SERVER_ERROR, { + results: Object.keys(results).map((u) => { + return { + method: method, + params: params, + result: u, + weight: results[u].reduce((accum, r) => (accum + r.weight), 0) + }; + }) + }); + } + reject(firstError); + return; + } + // Queue up the next round + setTimeout(next, 0); + }); + // Fire off requests until we could possibly meet quorum + if (inflightWeight < this.quorum) { + setTimeout(next, 0); + return; + } + }; + // bootstrap firing requests + next(); + }); + } +} + +"use strict"; +var browserNet = {}; + +"use strict"; +const logger$u = new Logger(version$j); +class IpcProvider extends JsonRpcProvider { + constructor(path, network) { + logger$u.checkNew(new.target, IpcProvider); + if (path == null) { + logger$u.throwError("missing path", Logger.errors.MISSING_ARGUMENT, { arg: "path" }); + } + super("ipc://" + path, network); + defineReadOnly(this, "path", path); + } + // @TODO: Create a connection to the IPC path and use filters instead of polling for block + send(method, params) { + // This method is very simple right now. We create a new socket + // connection each time, which may be slower, but the main + // advantage we are aiming for now is security. This simplifies + // multiplexing requests (since we do not need to multiplex). + let payload = JSON.stringify({ + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }); + return new Promise((resolve, reject) => { + let response = Buffer.alloc(0); + let stream = browserNet.connect(this.path); + stream.on("data", (data) => { + response = Buffer.concat([response, data]); + }); + stream.on("end", () => { + try { + resolve(JSON.parse(response.toString()).result); + // @TODO: Better pull apart the error + stream.destroy(); + } + catch (error) { + reject(error); + stream.destroy(); + } + }); + stream.on("error", (error) => { + reject(error); + stream.destroy(); + }); + stream.write(payload); + stream.end(); + }); + } +} + +"use strict"; +const logger$v = new Logger(version$j); +const defaultProjectId = "84842078b09946638c03157f83405213"; +class InfuraProvider extends UrlJsonRpcProvider { + get projectId() { return this.apiKey; } + static getApiKey(apiKey) { + if (apiKey == null) { + return defaultProjectId; + } + return apiKey; + } + static getUrl(network, apiKey) { + let host = null; + switch (network.name) { + case "homestead": + host = "mainnet.infura.io"; + break; + case "ropsten": + host = "ropsten.infura.io"; + break; + case "rinkeby": + host = "rinkeby.infura.io"; + break; + case "kovan": + host = "kovan.infura.io"; + break; + case "goerli": + host = "goerli.infura.io"; + break; + default: + logger$v.throwError("unsupported network", Logger.errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + return "https:/" + "/" + host + "/v3/" + apiKey; + } +} + +"use strict"; +const logger$w = new Logger(version$j); +// Special API key provided by Nodesmith for ethers.js +const defaultApiKey$1 = "ETHERS_JS_SHARED"; +class NodesmithProvider extends UrlJsonRpcProvider { + static getApiKey(apiKey) { + return apiKey || defaultApiKey$1; + } + static getUrl(network, apiKey) { + let host = null; + switch (network.name) { + case "homestead": + host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; + break; + case "ropsten": + host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; + break; + case "rinkeby": + host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; + break; + case "goerli": + host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; + break; + case "kovan": + host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; + break; + default: + logger$w.throwArgumentError("unsupported network", "network", arguments[0]); + } + return (host + "?apiKey=" + apiKey); + } +} + +"use strict"; +const logger$x = new Logger(version$j); +/* +@TODO +utils.defineProperty(Web3Signer, "onchange", { + +}); + +*/ +class Web3Provider extends JsonRpcProvider { + constructor(web3Provider, network) { + logger$x.checkNew(new.target, Web3Provider); + // HTTP has a host; IPC has a path. + super(web3Provider.host || web3Provider.path || "", network); + if (web3Provider) { + if (web3Provider.sendAsync) { + this._sendAsync = web3Provider.sendAsync.bind(web3Provider); + } + else if (web3Provider.send) { + this._sendAsync = web3Provider.send.bind(web3Provider); + } + } + if (!web3Provider || !this._sendAsync) { + logger$x.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); + } + defineReadOnly(this, "_web3Provider", web3Provider); + } + send(method, params) { + // Metamask complains about eth_sign (and on some versions hangs) + if (method == "eth_sign" && this._web3Provider.isMetaMask) { + // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + method = "personal_sign"; + params = [params[1], params[0]]; + } + return new Promise((resolve, reject) => { + let request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + this._sendAsync(request, function (error, result) { + if (error) { + reject(error); + return; + } + if (result.error) { + // @TODO: not any + let error = new Error(result.error.message); + error.code = result.error.code; + error.data = result.error.data; + reject(error); + return; + } + resolve(result.result); + }); + }); + } +} + +"use strict"; + +var providers = /*#__PURE__*/Object.freeze({ + Provider: Provider, + BaseProvider: BaseProvider, + FallbackProvider: FallbackProvider, + AlchemyProvider: AlchemyProvider, + CloudflareProvider: CloudflareProvider, + EtherscanProvider: EtherscanProvider, + InfuraProvider: InfuraProvider, + JsonRpcProvider: JsonRpcProvider, + NodesmithProvider: NodesmithProvider, + Web3Provider: Web3Provider, + IpcProvider: IpcProvider, + JsonRpcSigner: JsonRpcSigner, + getNetwork: getNetwork, + Formatter: Formatter +}); + +"use strict"; +const regexBytes = new RegExp("^bytes([0-9]+)$"); +const regexNumber = new RegExp("^(u?int)([0-9]*)$"); +const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); +const Zeros$1 = "0000000000000000000000000000000000000000000000000000000000000000"; +function _pack(type, value, isArray) { + switch (type) { + case "address": + if (isArray) { + return zeroPad(value, 32); + } + return arrayify(value); + case "string": + return toUtf8Bytes(value); + case "bytes": + return arrayify(value); + case "bool": + value = (value ? "0x01" : "0x00"); + if (isArray) { + return zeroPad(value, 32); + } + return arrayify(value); + } + let match = type.match(regexNumber); + if (match) { + //let signed = (match[1] === "int") + let size = parseInt(match[2] || "256"); + if ((size % 8 != 0) || size === 0 || size > 256) { + throw new Error("invalid number type - " + type); + } + if (isArray) { + size = 256; + } + value = BigNumber.from(value).toTwos(size); + return zeroPad(value, size / 8); + } + match = type.match(regexBytes); + if (match) { + let size = parseInt(match[1]); + if (String(size) != match[1] || size === 0 || size > 32) { + throw new Error("invalid number type - " + type); + } + if (arrayify(value).byteLength !== size) { + throw new Error("invalid value for " + type); + } + if (isArray) { + return arrayify((value + Zeros$1).substring(0, 66)); + } + return value; + } + match = type.match(regexArray); + if (match && Array.isArray(value)) { + let baseType = match[1]; + let count = parseInt(match[2] || String(value.length)); + if (count != value.length) { + throw new Error("invalid value for " + type); + } + let result = []; + value.forEach(function (value) { + result.push(_pack(baseType, value, true)); + }); + return concat(result); + } + throw new Error("unknown type - " + type); +} +// @TODO: Array Enum +function pack$1(types, values) { + if (types.length != values.length) { + throw new Error("type/value count mismatch"); + } + let tight = []; + types.forEach(function (type, index) { + tight.push(_pack(type, values[index])); + }); + return hexlify(concat(tight)); +} +function keccak256$1(types, values) { + return keccak256(pack$1(types, values)); +} +function sha256$1(types, values) { + return browser_3(pack$1(types, values)); +} + +var _version$6 = createCommonjsModule(function (module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.version = "bignumber/5.0.0-beta.130"; +}); + +var _version$7 = unwrapExports(_version$6); +var _version_1$3 = _version$6.version; + +var bignumber = createCommonjsModule(function (module$2, exports) { +"use strict"; +var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +/** + * BigNumber + * + * A wrapper around the BN.js object. We use the BN.js library + * because it is used by elliptic, so it is required regardles. + * + */ +var BN = __importStar(bn); + + + +var logger = new module.Logger(_version$6.version); +var _constructorGuard = {}; +var MAX_SAFE = 0x1fffffffffffff; +function isBigNumberish(value) { + return (value != null) && (BigNumber.isBigNumber(value) || + (typeof (value) === "number" && (value % 1) === 0) || + (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || + module$1.isHexString(value) || + (typeof (value) === "bigint") || + module$1.isBytes(value)); +} +exports.isBigNumberish = isBigNumberish; +var BigNumber = /** @class */ (function () { + function BigNumber(constructorGuard, hex) { + var _newTarget = this.constructor; + logger.checkNew(_newTarget, BigNumber); + if (constructorGuard !== _constructorGuard) { + logger.throwError("cannot call consturtor directly; use BigNumber.from", module.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); + } + this._hex = hex; + this._isBigNumber = true; + Object.freeze(this); + } + BigNumber.prototype.fromTwos = function (value) { + return toBigNumber(toBN(this).fromTwos(value)); + }; + BigNumber.prototype.toTwos = function (value) { + return toBigNumber(toBN(this).toTwos(value)); + }; + BigNumber.prototype.abs = function () { + if (this._hex[0] === "-") { + return BigNumber.from(this._hex.substring(1)); + } + return this; + }; + BigNumber.prototype.add = function (other) { + return toBigNumber(toBN(this).add(toBN(other))); + }; + BigNumber.prototype.sub = function (other) { + return toBigNumber(toBN(this).sub(toBN(other))); + }; + BigNumber.prototype.div = function (other) { + var o = BigNumber.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + }; + BigNumber.prototype.mul = function (other) { + return toBigNumber(toBN(this).mul(toBN(other))); + }; + BigNumber.prototype.mod = function (other) { + return toBigNumber(toBN(this).mod(toBN(other))); + }; + BigNumber.prototype.pow = function (other) { + return toBigNumber(toBN(this).pow(toBN(other))); + }; + BigNumber.prototype.maskn = function (value) { + return toBigNumber(toBN(this).maskn(value)); + }; + BigNumber.prototype.eq = function (other) { + return toBN(this).eq(toBN(other)); + }; + BigNumber.prototype.lt = function (other) { + return toBN(this).lt(toBN(other)); + }; + BigNumber.prototype.lte = function (other) { + return toBN(this).lte(toBN(other)); + }; + BigNumber.prototype.gt = function (other) { + return toBN(this).gt(toBN(other)); + }; + BigNumber.prototype.gte = function (other) { + return toBN(this).gte(toBN(other)); + }; + BigNumber.prototype.isZero = function () { + return toBN(this).isZero(); + }; + BigNumber.prototype.toNumber = function () { + try { + return toBN(this).toNumber(); + } + catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + }; + BigNumber.prototype.toString = function () { + // Lots of people expect this, which we do not support, so check + if (arguments.length !== 0) { + logger.throwError("bigNumber.toString does not accept parameters", module.Logger.errors.UNEXPECTED_ARGUMENT, {}); + } + return toBN(this).toString(10); + }; + BigNumber.prototype.toHexString = function () { + return this._hex; + }; + BigNumber.from = function (value) { + if (value instanceof BigNumber) { + return value; + } + if (typeof (value) === "string") { + if (value.match(/-?0x[0-9a-f]+/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + } + return logger.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof (value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + return BigNumber.from(String(value)); + } + if (typeof (value) === "bigint") { + return BigNumber.from(value.toString()); + } + if (module$1.isBytes(value)) { + return BigNumber.from(module$1.hexlify(value)); + } + if (value._hex && module$1.isHexString(value._hex)) { + return BigNumber.from(value._hex); + } + if (value.toHexString) { + value = value.toHexString(); + if (typeof (value) === "string") { + return BigNumber.from(value); + } + } + return logger.throwArgumentError("invalid BigNumber value", "value", value); + }; + BigNumber.isBigNumber = function (value) { + return !!(value && value._isBigNumber); + }; + return BigNumber; +}()); +exports.BigNumber = BigNumber; +// Normalize the hex string +function toHex(value) { + // For BN, call on the hex string + if (typeof (value) !== "string") { + return toHex(value.toString(16)); + } + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { + logger.throwArgumentError("invalid hex", "value", value); + } + // Call toHex on the positive component + value = toHex(value); + // Do not allow "-0x00" + if (value === "0x00") { + return value; + } + // Negate the value + return "-" + value; + } + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + // Normalize zero + if (value === "0x") { + return "0x00"; + } + // Make the string even length + if (value.length % 2) { + value = "0x0" + value.substring(2); + } + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + return value; +} +function toBigNumber(value) { + return BigNumber.from(toHex(value)); +} +function toBN(value) { + var hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new BN.BN("-" + hex.substring(3), 16)); + } + return new BN.BN(hex.substring(2), 16); +} +function throwFault(fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value != null) { + params.value = value; + } + return logger.throwError(fault, module.Logger.errors.NUMERIC_FAULT, params); +} +}); + +var bignumber$1 = unwrapExports(bignumber); +var bignumber_1 = bignumber.isBigNumberish; +var bignumber_2 = bignumber.BigNumber; + +var fixednumber = createCommonjsModule(function (module$2, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); + + + +var logger = new module.Logger(_version$6.version); + +var _constructorGuard = {}; +var Zero = bignumber.BigNumber.from(0); +var NegativeOne = bignumber.BigNumber.from(-1); +function throwFault(message, fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value !== undefined) { + params.value = value; + } + return logger.throwError(message, module.Logger.errors.NUMERIC_FAULT, params); +} +// Constant to pull zeros from for multipliers +var zeros = "0"; +while (zeros.length < 256) { + zeros += zeros; +} +// Returns a string "1" followed by decimal "0"s +function getMultiplier(decimals) { + if (typeof (decimals) !== "number") { + try { + decimals = bignumber.BigNumber.from(decimals).toNumber(); + } + catch (e) { } + } + if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + return logger.throwArgumentError("invalid decimal size", "decimals", decimals); +} +function formatFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + // Make sure wei is a big number (convert as necessary) + value = bignumber.BigNumber.from(value); + var negative = value.lt(Zero); + if (negative) { + value = value.mul(NegativeOne); + } + var fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { + fraction = "0" + fraction; + } + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + var whole = value.div(multiplier).toString(); + value = whole + "." + fraction; + if (negative) { + value = "-" + value; + } + return value; +} +exports.formatFixed = formatFixed; +function parseFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + logger.throwArgumentError("invalid decimal value", "value", value); + } + if (multiplier.length - 1 === 0) { + return bignumber.BigNumber.from(value); + } + // Is it negative? + var negative = (value.substring(0, 1) === "-"); + if (negative) { + value = value.substring(1); + } + if (value === ".") { + logger.throwArgumentError("missing value", "value", value); + } + // Split it into a whole and fractional part + var comps = value.split("."); + if (comps.length > 2) { + logger.throwArgumentError("too many decimal points", "value", value); + } + var whole = comps[0], fraction = comps[1]; + if (!whole) { + whole = "0"; + } + if (!fraction) { + fraction = "0"; + } + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); + } + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { + fraction += "0"; + } + var wholeValue = bignumber.BigNumber.from(whole); + var fractionValue = bignumber.BigNumber.from(fraction); + var wei = (wholeValue.mul(multiplier)).add(fractionValue); + if (negative) { + wei = wei.mul(NegativeOne); + } + return wei; +} +exports.parseFixed = parseFixed; +var FixedFormat = /** @class */ (function () { + function FixedFormat(constructorGuard, signed, width, decimals) { + this.signed = signed; + this.width = width; + this.decimals = decimals; + this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + this._multiplier = getMultiplier(decimals); + Object.freeze(this); + } + FixedFormat.from = function (value) { + if (value instanceof FixedFormat) { + return value; + } + var signed = true; + var width = 128; + var decimals = 18; + if (typeof (value) === "string") { + if (value === "fixed") { + // defaults... + } + else if (value === "ufixed") { + signed = false; + } + else if (value != null) { + var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + logger.throwArgumentError("invalid fixed format", "format", value); + } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + var check = function (key, type, defaultValue) { + if (value[key] == null) { + return defaultValue; + } + if (typeof (value[key]) !== type) { + logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat(_constructorGuard, signed, width, decimals); + }; + return FixedFormat; +}()); +exports.FixedFormat = FixedFormat; +var FixedNumber = /** @class */ (function () { + function FixedNumber(constructorGuard, hex, value, format) { + var _newTarget = this.constructor; + logger.checkNew(_newTarget, FixedNumber); + this.format = format; + this._hex = hex; + this._value = value; + this._isFixedNumber = true; + Object.freeze(this); + } + FixedNumber.prototype._checkFormat = function (other) { + if (this.format.name !== other.format.name) { + logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + }; + FixedNumber.prototype.addUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.subUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.mulUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + }; + FixedNumber.prototype.divUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + }; + // @TODO: Support other rounding algorithms + FixedNumber.prototype.round = function (decimals) { + if (decimals == null) { + decimals = 0; + } + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + logger.throwArgumentError("invalid decimal cound", "decimals", decimals); + } + // If we are already in range, we're done + var comps = this.toString().split("."); + if (comps[1].length <= decimals) { + return this; + } + // Bump the value up by the 0.00...0005 + var bump = "0." + zeros.substring(0, decimals) + "5"; + comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); + // Now it is safe to truncate + return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); + }; + FixedNumber.prototype.toString = function () { return this._value; }; + FixedNumber.prototype.toHexString = function (width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + logger.throwArgumentError("invalid byte width", "width", width); + } + var hex = bignumber.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return module$1.hexZeroPad(hex, width / 8); + }; + FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; + FixedNumber.prototype.toFormat = function (format) { + return FixedNumber.fromString(this._value, format); + }; + FixedNumber.fromValue = function (value, decimals, format) { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && !bignumber.isBigNumberish(decimals)) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); + }; + FixedNumber.fromString = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + var numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + var hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } + else { + hex = numeric.toHexString(); + hex = module$1.hexZeroPad(hex, fixedFormat.width / 8); + } + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.fromBytes = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + if (module$1.arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + var numeric = bignumber.BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.from = function (value, format) { + if (typeof (value) === "string") { + return FixedNumber.fromString(value, format); + } + if (module$1.isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + try { + return FixedNumber.fromValue(value, 0, format); + } + catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== module.Logger.errors.INVALID_ARGUMENT) { + throw error; + } + } + return logger.throwArgumentError("invalid FixedNumber value", "value", value); + }; + FixedNumber.isFixedNumber = function (value) { + return !!(value && value._isFixedNumber); + }; + return FixedNumber; +}()); +exports.FixedNumber = FixedNumber; +}); + +var fixednumber$1 = unwrapExports(fixednumber); +var fixednumber_1 = fixednumber.formatFixed; +var fixednumber_2 = fixednumber.parseFixed; +var fixednumber_3 = fixednumber.FixedFormat; +var fixednumber_4 = fixednumber.FixedNumber; + +const version$k = "units/5.0.0-beta.127"; + +"use strict"; +const logger$y = new Logger(version$k); +const names = [ + "wei", + "kwei", + "mwei", + "gwei", + "szabo", + "finney", + "ether", +]; +// Some environments have issues with RegEx that contain back-tracking, so we cannot +// use them. +function commify(value) { + let comps = String(value).split("."); + if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { + logger$y.throwArgumentError("invalid value", "value", value); + } + // Make sure we have at least one whole digit (0 if none) + let whole = comps[0]; + let negative = ""; + if (whole.substring(0, 1) === "-") { + negative = "-"; + whole = whole.substring(1); + } + // Make sure we have at least 1 whole digit with no leading zeros + while (whole.substring(0, 1) === "0") { + whole = whole.substring(1); + } + if (whole === "") { + whole = "0"; + } + let suffix = ""; + if (comps.length === 2) { + suffix = "." + (comps[1] || "0"); + } + let formatted = []; + while (whole.length) { + if (whole.length <= 3) { + formatted.unshift(whole); + break; + } + else { + let index = whole.length - 3; + formatted.unshift(whole.substring(index)); + whole = whole.substring(0, index); + } + } + return negative + formatted.join(",") + suffix; +} +function formatUnits(value, unitName) { + if (typeof (unitName) === "string") { + let index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return fixednumber_1(value, (unitName != null) ? unitName : 18); +} +function parseUnits(value, unitName) { + if (typeof (unitName) === "string") { + let index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return fixednumber_2(value, (unitName != null) ? unitName : 18); +} +function formatEther(wei) { + return formatUnits(wei, 18); +} +function parseEther(ether) { + return parseUnits(ether, 18); +} + +"use strict"; + +var utils$1 = /*#__PURE__*/Object.freeze({ + AbiCoder: AbiCoder, + defaultAbiCoder: defaultAbiCoder, + Fragment: Fragment, + EventFragment: EventFragment, + FunctionFragment: FunctionFragment, + ParamType: ParamType, + FormatTypes: FormatTypes, + Logger: Logger, + RLP: index, + fetchJson: fetchJson, + poll: poll, + checkProperties: checkProperties, + deepCopy: deepCopy, + defineReadOnly: defineReadOnly, + getStatic: getStatic, + resolveProperties: resolveProperties, + shallowCopy: shallowCopy, + arrayify: arrayify, + concat: concat, + stripZeros: stripZeros, + zeroPad: zeroPad, + defaultPath: defaultPath, + HDNode: HDNode, + SigningKey: SigningKey, + Interface: Interface, + base64: browser$a, + hexlify: hexlify, + isHexString: isHexString, + hexStripZeros: hexStripZeros, + hexValue: hexValue, + hexZeroPad: hexZeroPad, + hexDataLength: hexDataLength, + hexDataSlice: hexDataSlice, + nameprep: nameprep, + _toEscapedUtf8String: _toEscapedUtf8String, + toUtf8Bytes: toUtf8Bytes, + toUtf8CodePoints: toUtf8CodePoints, + toUtf8String: toUtf8String, + formatBytes32String: formatBytes32String, + parseBytes32String: parseBytes32String, + hashMessage: hashMessage, + namehash: namehash, + isValidName: isValidName, + id: id, + getAddress: getAddress, + getIcapAddress: getIcapAddress, + getContractAddress: getContractAddress, + isAddress: isAddress, + formatEther: formatEther, + parseEther: parseEther, + formatUnits: formatUnits, + parseUnits: parseUnits, + commify: commify, + keccak256: keccak256, + sha256: browser_3, + randomBytes: browser_2$2, + solidityPack: pack$1, + solidityKeccak256: keccak256$1, + soliditySha256: sha256$1, + splitSignature: splitSignature, + joinSignature: joinSignature, + parseTransaction: parse, + serializeTransaction: serialize, + getJsonWalletAddress: getJsonWalletAddress, + computeAddress: computeAddress, + recoverAddress: recoverAddress, + computePublicKey: computePublicKey, + recoverPublicKey: recoverPublicKey, + verifyMessage: verifyMessage, + mnemonicToEntropy: mnemonicToEntropy, + entropyToMnemonic: entropyToMnemonic, + isValidMnemonic: isValidMnemonic, + mnemonicToSeed: mnemonicToSeed, + SupportedAlgorithms: browser_1, + get UnicodeNormalizationForm () { return UnicodeNormalizationForm; }, + Indexed: Indexed +}); + +"use strict"; +const platform = "node"; + +const version$l = "ethers/5.0.0-beta.156"; + +"use strict"; +const errors = Logger.errors; +const logger$z = new Logger(version$l); +//////////////////////// +// Helper Functions +function getDefaultProvider(network, options) { + if (network == null) { + network = "homestead"; + } + let n = getNetwork(network); + if (!n || !n._defaultProvider) { + logger$z.throwError("unsupported getDefaultProvider network", Logger.errors.NETWORK_ERROR, { + operation: "getDefaultProvider", + network: network + }); + } + return n._defaultProvider(providers, options); +} + +var ethers = /*#__PURE__*/Object.freeze({ + version: version$l, + Signer: Signer, + Wallet: Wallet, + VoidSigner: VoidSigner, + getDefaultProvider: getDefaultProvider, + providers: providers, + Contract: Contract, + ContractFactory: ContractFactory, + BigNumber: BigNumber, + FixedNumber: FixedNumber, + constants: index$1, + errors: errors, + logger: logger$z, + utils: utils$1, + wordlists: browser_2$1, + platform: platform, + Wordlist: browser_1$2 +}); + +"use strict"; + +window.ethers = ethers; + +export { BigNumber, Contract, ContractFactory, FixedNumber, Signer, VoidSigner, Wallet, browser_1$2 as Wordlist, index$1 as constants, errors, ethers, getDefaultProvider, logger$z as logger, platform, providers, utils$1 as utils, version$l as version, browser_2$1 as wordlists }; diff --git a/packages/ethers/dist/ethers.esm.min.js b/packages/ethers/dist/ethers.esm.min.js new file mode 100644 index 000000000..e01b66811 --- /dev/null +++ b/packages/ethers/dist/ethers.esm.min.js @@ -0,0 +1 @@ +var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),o=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,h=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var h=1;h>>26,f=67108863&u,c=Math.min(h,e.length-1),d=Math.max(0,h-t.length+1);d<=c;d++){var p=h-d|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[h]=0|f,u=0|l}return 0!==u?r.words[h]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:h[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return r(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,u="le"===e,h=new t(o),l=this.clone();if(u){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),h[a]=s;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],v=8191&g,y=g>>>13,b=0|s[3],w=8191&b,_=b>>>13,E=0|s[4],S=8191&E,A=E>>>13,M=0|s[5],k=8191&M,x=M>>>13,P=0|s[6],N=8191&P,T=P>>>13,I=0|s[7],R=8191&I,B=I>>>13,C=0|s[8],O=8191&C,F=C>>>13,L=0|s[9],D=8191&L,U=L>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(h+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;h=((o=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,o=Math.imul(m,H);var vt=(h+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;h=((o=o+Math.imul(c,G)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,j),i=(i=Math.imul(v,H))+Math.imul(y,j)|0,o=Math.imul(y,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,G)|0;var yt=(h+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;h=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(_,j)|0,o=Math.imul(_,H),n=n+Math.imul(v,K)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var bt=(h+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;h=((o=o+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,H))+Math.imul(A,j)|0,o=Math.imul(A,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var wt=(h+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;h=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(x,j)|0,o=Math.imul(x,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,X)|0,i=(i=i+Math.imul(v,$)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,tt)|0;var _t=(h+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;h=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(N,j),i=(i=Math.imul(N,H))+Math.imul(T,j)|0,o=Math.imul(T,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var Et=(h+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;h=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(B,j)|0,o=Math.imul(B,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,G)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var St=(h+(n=n+Math.imul(f,ut)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(c,ut)|0))<<13)|0;h=((o=o+Math.imul(c,ht)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,o=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(B,K)|0,o=o+Math.imul(B,G)|0,n=n+Math.imul(N,V)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,$)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ht)|0;var At=(h+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;h=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,j),i=(i=Math.imul(D,H))+Math.imul(U,j)|0,o=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,o=o+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(B,V)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(N,X)|0,i=(i=i+Math.imul(N,$)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ht)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ht)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,o=o+Math.imul(m,ct)|0;var Mt=(h+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;h=((o=o+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,G))+Math.imul(U,K)|0,o=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(B,X)|0,o=o+Math.imul(B,$)|0,n=n+Math.imul(N,Y)|0,i=(i=i+Math.imul(N,tt)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ht)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ht)|0,n=n+Math.imul(v,ft)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(y,ft)|0,o=o+Math.imul(y,ct)|0;var kt=(h+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,V),i=(i=Math.imul(D,J))+Math.imul(U,V)|0,o=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(N,rt)|0,i=(i=i+Math.imul(N,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ht)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ht)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ft)|0,o=o+Math.imul(_,ct)|0;var xt=(h+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;h=((o=o+Math.imul(y,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,X),i=(i=Math.imul(D,$))+Math.imul(U,X)|0,o=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(N,ot)|0,i=(i=i+Math.imul(N,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(k,ut)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ht)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Pt=(h+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;h=((o=o+Math.imul(_,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,Y),i=(i=Math.imul(D,tt))+Math.imul(U,Y)|0,o=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(N,ut)|0,i=(i=i+Math.imul(N,ht)|0)+Math.imul(T,ut)|0,o=o+Math.imul(T,ht)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(x,ft)|0,o=o+Math.imul(x,ct)|0;var Nt=(h+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,mt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((o=o+Math.imul(A,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(O,ot)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(R,ut)|0,i=(i=i+Math.imul(R,ht)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ht)|0,n=n+Math.imul(N,ft)|0,i=(i=i+Math.imul(N,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var Tt=(h+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(x,pt)|0))<<13)|0;h=((o=o+Math.imul(x,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(O,ut)|0,i=(i=i+Math.imul(O,ht)|0)+Math.imul(F,ut)|0,o=o+Math.imul(F,ht)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(B,ft)|0,o=o+Math.imul(B,ct)|0;var It=(h+(n=n+Math.imul(N,pt)|0)|0)+((8191&(i=(i=i+Math.imul(N,mt)|0)+Math.imul(T,pt)|0))<<13)|0;h=((o=o+Math.imul(T,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,ut),i=(i=Math.imul(D,ht))+Math.imul(U,ut)|0,o=Math.imul(U,ht),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var Rt=(h+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(B,pt)|0))<<13)|0;h=((o=o+Math.imul(B,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ft),i=(i=Math.imul(D,ct))+Math.imul(U,ft)|0,o=Math.imul(U,ct);var Bt=(h+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;h=((o=o+Math.imul(F,mt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863;var Ct=(h+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,mt))+Math.imul(U,pt)|0))<<13)|0;return h=((o=Math.imul(U,mt))+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,u[0]=gt,u[1]=vt,u[2]=yt,u[3]=bt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=At,u[9]=Mt,u[10]=kt,u[11]=xt,u[12]=Pt,u[13]=Nt,u[14]=Tt,u[15]=It,u[16]=Rt,u[17]=Bt,u[18]=Ct,0!==h&&(u[19]=h,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,h=0;h=0&&(0!==l||h>=i);h--){var f=0|this.words[h];this.words[h]=l<<26-o|f>>>o,l=f&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var h=0;h=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},o.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(f)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),s.isub(u)):(n.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:n.iushln(h)}},o.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new E(t)},o.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(y,v),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,h).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var h=e.words[n],l=u-1;l>=0;l--){var f=h>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},n(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),s=o.BN;const a="logger/5.0.0-beta.129";let u=!1,h=!1;const l={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=l.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=l[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>l[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(h)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach(function(t){o[t]=r[t]}),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(u){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}h=!!t,u=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.129");function v(t){return!!t.toHexString}function y(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return y(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function _(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),y(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),v(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;t_(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),y(n)}function S(t){let e=_(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),y(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function x(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),v(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function P(t){if("string"!=typeof t)t=x(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function N(t,e,r){return"string"!=typeof t?t=x(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function T(t){let e=I(x(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=x(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function B(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=_(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=x(r.slice(0,32)),e.s=x(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=x(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=_(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let o=x(r);null==e.s?e.s=o:e.s!==o&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=_(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=x(r)}}return e}function C(t){return x(E([(t=B(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:_,concat:E,stripZeros:S,zeroPad:A,isHexString:M,hexlify:x,hexDataLength:P,hexDataSlice:N,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=x(t).substring(2)}),e},hexValue:T,hexStripZeros:I,hexZeroPad:R,splitSignature:B,joinSignature:C});const F=new p("bignumber/5.0.0-beta.130"),L={},D=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==L&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(L,z(t)):t.match(/^-?[0-9]+$/)?new U(L,z(new s(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=D||t<=-D)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(x(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new s("-"+e.substring(3),16):new s(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.130"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let o=i[0],s=i[1];for(o||(o="0"),s||(s="0"),s.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");s.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let o=$(n,r.decimals);return new tt(G,i,o,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(_(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),o=$(n,r.decimals);return new tt(G,i,o,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.131");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function ot(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function st(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ut(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ut(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ut(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class ht{constructor(t){for(let e in t)this[e]=ut(t[e]);Object.freeze(this)}}var lt=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:ot,shallowCopy:st,deepCopy:ut,Description:ht});const ft="abi/5.0.0-beta.137",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const vt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),yt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(yt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==vt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===vt.full?", ":",")+")"):e+=this.type,t!==vt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===vt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:Pt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;rbt.fromString(t,e))}class _t{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return _t.isFragment(t)?t:"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){return _t.isFragment(t)?t:"function"===t.type?xt.fromObject(t):"event"===t.type?Et.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return Et.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return xt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class Et extends _t{format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==vt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===vt.full?", ":",")+") ",t!==vt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){if(Et.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new Et(dt,{name:Tt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),Et.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function St(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function At(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends _t{format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===vt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===vt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=St(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),At(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class xt extends kt{format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==vt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===vt.full?", ":",")+") ",t!==vt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?xt.fromString(t):xt.fromObject(t)}static fromObject(t){if(xt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new xt(dt,{type:t.type,name:Tt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=St(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Nt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),At(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return xt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function Pt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Nt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Tt(t){if(!t||!t.match(Nt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Bt{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Ct{constructor(t){rt(this,"wordSize",t||32),this._data=_([]),this._padding=new Uint8Array(t)}get data(){return x(this._data)}get length(){return this._data.length}_writeData(t){return this._data=E([this._data,t]),t.length}writeBytes(t){let e=_(t);return e.length%this.wordSize&&(e=E([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=_(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=E([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",_(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return x(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],h=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},l=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=h(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,s=this.blocks,a=this.byteCount,u=this.blockCount,h=0,l=this.s;h>2]|=t[h]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(s[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=s[u],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(_(r),s=0)}return o&&(t=r[s],o>0&&(u+=i[t>>4&15]+i[15&t]),o>1&&(u+=i[t>>12&15]+i[t>>8&15]),o>2&&(u+=i[t>>20&15]+i[t>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(t);s>8&255,u[t+2]=e>>16&255,u[t+3]=e>>24&255;a%r==0&&_(n)}return o&&(t=a<<2,e=n[s],o>0&&(u[t]=255&e),o>1&&(u[t+1]=e>>8&255),o>2&&(u[t+2]=e>>16&255)),u};var _=function(t){var e,r,n,i,o,a,u,h,l,f,c,d,p,m,g,v,y,b,w,_,E,S,A,M,k,x,P,N,T,I,R,B,C,O,F,L,D,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,ot,st,at,ut,ht,lt;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],u=t[3]^t[13]^t[23]^t[33]^t[43],h=t[4]^t[14]^t[24]^t[34]^t[44],l=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|u>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(u<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(h<<1|l>>>31),r=o^(l<<1|h>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=u^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=h^(d<<1|p>>>31),r=l^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=c^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,N=t[20]<<3|t[21]>>>29,T=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ut=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,v=t[13]<<12|t[12]>>>20,y=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,lt=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,L=t[14]<<6|t[15]>>>26,D=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,B=t[45]<<29|t[44]>>>3,C=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,E=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,P=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,S=t[48]<<14|t[49]>>>18,A=t[49]<<14|t[48]>>>18,t[0]=m^~v&b,t[1]=g^~y&w,t[10]=M^~x&N,t[11]=k^~P&T,t[20]=O^~L&U,t[21]=F^~D&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=v^~b&_,t[3]=y^~w&E,t[12]=x^~N&I,t[13]=P^~T&R,t[22]=L^~U&j,t[23]=D^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~ot&at,t[43]=it^~st&ut,t[4]=b^~_&S,t[5]=w^~E&A,t[14]=N^~I&B,t[15]=T^~R&C,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=ot^~at&ht,t[45]=st^~ut<,t[6]=_^~S&m,t[7]=E^~A&g,t[16]=I^~B&M,t[17]=R^~C&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~ht&et,t[47]=ut^~lt&rt,t[8]=S^~m&v,t[9]=A^~g&y,t[18]=B^~M&x,t[19]=C^~k&P,t[28]=q^~O&L,t[29]=K^~F&D,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=ht^~et&nt,t[49]=lt^~rt&it,t[0]^=s[n],t[1]^=s[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:x(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:x(t.slice(e+1,e+1+r))}}return{consumed:1,result:x(t[e])}}function qt(t){let e=_(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.128");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=_(Lt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new s(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(N(Lt(zt([e,S(_(t.nonce))])),12))}class Yt extends Bt{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Bt{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Ct(t.wordSize),i=new Ct(t.wordSize),o=[];e.forEach((t,e)=>{let s=r[e];if(t.dynamic){let e=i.length;t.encode(i,s);let r=n.writeUpdatableValue();o.push(t=>{r(t+e)})}else t.encode(n,s)}),o.forEach(t=>{t(n.length)});let s=t.writeBytes(n.data);return s+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let o=null;if(e.dynamic){let r=t.readValue(),s=n.subReader(r.toNumber());o=e.decode(s),i+=s.consumed}else o=e.decode(t);null!=o&&r.push(o)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Bt{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,s=65535}if(n+o>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-o-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Se(t,e=_e.current){e!=_e.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return _(r)}function Ae(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(Ee(t,e))}function xe(t,e=_e.current){return Ee(Se(t,e))}function Pe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Ne(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Te(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(_e||(_e={}));const Ie=Ne("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Be=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Ce=Pe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=Pe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=Pe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Te(t,Be);if(e)return[t+e.s];let r=Ce[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=xe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),_e.NFKC)).forEach(t=>{if(function(t){return!!Te(t,Le)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Te(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends se{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Se(e))}decode(t){return ke(super.decode(t))}}class ze extends Bt{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new oe(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new he(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new ue(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Ct(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(_(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.128"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;t_t.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return N($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?sr(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[xt.fromString(t).format()]}getEvent(t){return M(t)?sr(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[Et.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),x(E([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=_(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===x(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Lt(x(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(x(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))});let s=null!=r?this._abiCoder.decode(n,E(r)):null,a=this._abiCoder.decode(i,e),u=[],h=0,l=0;return t.inputs.forEach((t,e)=>{t.indexed?null==s?u[e]=new ir({_isIndexed:!0,hash:null}):o[e]?u[e]=new ir({_isIndexed:!0,hash:s[l++]}):u[e]=s[l++]:u[e]=a[h++]}),u}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function sr(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.131");class ur extends ht{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class hr{addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}constructor(){ar.checkAbstract(new.target,hr),rt(this,"_isProvider",!0)}static isProvider(t){return!(!t||!t._isProvider)}}const lr=new p("abstract-signer/5.0.0-beta.132"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){lr.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&lr.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=st(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&lr.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{lr.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||lr.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){lr.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{lr.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.137"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function vr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},o=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=st(e.pop())).blockTag&&(o=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(o).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,o).then(r=>{try{let o=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(o=o[0]),o}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ut(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function yr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class _r extends br{constructor(t,e,r,n){let i={address:t},o=e.getEventTopic(r);n?(o!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(yr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class Er extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Sr{constructor(t,e,r){if(pr.checkNew(new.target,Sr),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):hr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=vr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,vr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,vr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,vr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return or.isInterface(t)?t:new or(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=st(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new Er(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new _r(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new _r(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(yr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ut(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=st(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Ar{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?x(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=st(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=x(E([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Sr.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Sr(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Br={inherits:Nr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,o,s,a){var u=0,h=e;return u+=(h=h+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},sum64_5_hi:function(t,e,r,n,i,o,s,a,u,h){var l=0,f=e;return l+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,o,s,a,u,h){return e+n+o+a+h>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Cr(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Cr;Cr.prototype.update=function(t,e){if(t=Br.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Br.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(t){return Lr(t,17)^Lr(t,19)^t>>>10}},Hr=Br.sum32,qr=Br.sum32_4,Kr=Br.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Br.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),xr(t.length<=this.blockSize);for(var e=t.length;e>24&255,l[e.length+1]=f>>16&255,l[e.length+2]=f>>8&255,l[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,l));o||(o=c.length,a=new Uint8Array(o),s=n-((u=Math.ceil(n/o))-1)*o),a.set(c);for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),oi=r(function(t,e){var r=e;r.assert=xr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,u=1;u0||e.cmpn(-i)>0;){var o,s,a,u=t.andln(3)+n&3,h=e.andln(3)+i&3;if(3===u&&(u=-1),3===h&&(h=-1),0==(1&u))o=0;else o=3!==(a=t.andln(7)+n&7)&&5!==a||2!==h?u:-u;if(r[0].push(o),0==(1&h))s=0;else s=3!==(a=e.andln(7)+i&7)&&5!==a||2!==u?h:-h;r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new o(t,"hex","le")}}),si=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=oi.getNAF,ui=oi.getJSF,hi=oi.assert;function li(t,e){this.type=t,this.p=new o(e.p,16),this.red=e.prime?o.red(e.prime):o.mont(this.p),this.zero=new o(0).toRed(this.red),this.one=new o(1).toRed(this.red),this.two=new o(2).toRed(this.red),this.n=e.n&&new o(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=li;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}li.prototype.point=function(){throw new Error("Not implemented")},li.prototype.validate=function(){throw new Error("Not implemented")},li.prototype._fixedNafMul=function(t,e){hi(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=s;e--)a=(a<<1)+n[e];o.push(a)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(s=0;s=0;a--){for(e=0;a>=0&&0===o[a];a--)e++;if(a>=0&&e++,s=s.dblp(e),a<0)break;var u=o[a];hi(0!==u),s="affine"===t.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===t.type?s.toP():s},li.prototype._wnafMulAdd=function(t,e,r,n,i){for(var o=this._wnafT1,s=this._wnafT2,a=this._wnafT3,u=0,h=0;h=1;h-=2){var f=h-1,c=h;if(1===o[f]&&1===o[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=ui(r[f],r[c]);u=Math.max(m[0].length,u),a[f]=new Array(u),a[c]=new Array(u);for(var g=0;g=0;h--){for(var _=0;h>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),h<0)break;for(g=0;g0?S=s[g][A-1>>1]:A<0&&(S=s[g][-A-1>>1].neg()),b="affine"===S.type?b.mixedAdd(S):b.add(S))}}for(h=0;h=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),h=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(h).neg()}},pi.prototype.pointFromX=function(t,e){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new o(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Nr(vi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new vi(this,t,e,r)},vi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},vi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},vi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),f=n.redMul(h),c=u.redSqr().redIAdd(l).redISub(f).redISub(f),d=u.redMul(f.redISub(c)).redISub(o.redMul(l)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},vi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),h=u.redMul(s),l=r.redMul(u),f=a.redSqr().redIAdd(h).redISub(l).redISub(l),c=a.redMul(l.redISub(f)).redISub(i.redMul(h)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},vi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},vi.prototype.inspect=function(){return this.isInfinity()?"":""},vi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var yi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=yi,r.edwards=bi}),_i=r(function(t,e){var r,n=e,i=oi.assert;function o(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Ei(t){if(!(this instanceof Ei))return new Ei(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");xr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Si=Ei;Ei.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Ei.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var xi=oi.assert;function Pi(t,e){if(t instanceof Pi)return t;this._importDER(t,e)||(xi(t.r&&t.s,"Signature without r or s"),this.r=new o(t.r,16),this.s=new o(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ni=Pi;function Ti(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=e.place;o>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Pi.prototype._importDER=function(t,e){t=oi.toArray(t,e);var r=new Ti;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var s=Ii(t,r);if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new o(i),this.s=new o(a),this.recoveryParam=null,!0},Pi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Bi(n,e.length),(n=n.concat(e)).push(2),Bi(n,r.length);var i=n.concat(r),o=[48];return Bi(o,i.length),o=o.concat(i),oi.encode(o,t)};var Ci=oi.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Ci(_i.hasOwnProperty(t),"Unknown curve "+t),t=_i[t]),t instanceof _i.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Si({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||si(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new o(2));;){var i=new o(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new o(t,16));for(var i=this.n.byteLength(),s=e.getPrivate().toArray("be",i),a=t.toArray("be",i),u=new Si({hash:this.hash,entropy:s,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new o(1)),l=0;;l++){var f=n.k?n.k(l):new o(u.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(h)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ni({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new o(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ni(e,"hex")).r,s=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),h=u.mul(t).umod(this.n),l=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,r.getPublic(),l)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(h,r.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Ci((3&r)===r,"The recovery param is more than two bits"),e=new Ni(e,n);var i=this.n,s=new o(t),a=e.r,u=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var f=e.r.invm(i),c=i.sub(s).mul(f).umod(i),d=u.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ni(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Li={},Di=n(ni),Ui=r(function(t,e){var r=e;r.version=Di.version,r.utils=oi,r.rand=si,r.curve=wi,r.curves=_i,r.ec=Fi,r.eddsa=Li}).ec;const zi=new p("signing-key/5.0.0-beta.129");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",x(t));let e=Hi().keyFromPrivate(_(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(_(this.publicKey)),r=Hi().keyFromPublic(_(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(_(this.privateKey)).sign(_(t),{canonical:!0});return B({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(_(this.privateKey)),r=Hi().keyFromPublic(_(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=B(e),n={r:_(r.r),s:_(r.s)};return"0x"+Hi().recoverPubKey(_(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=_(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?x(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):x(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.128");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(N(Lt(N(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(_(t),e))}function Qi(t,e){ot(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=_(x(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=S(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(x(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(x(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=B(e),o=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),o+=2*t.chainId+8),r.push(x(o)),r.push(S(_(i.r))),r.push(S(_(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(x(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let o=Lt(zt(i));try{r.from=$i(o,{r:x(r.r),s:x(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Lt(t)}return r}var to=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.128"}),eo=(e(to),to.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(to.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var o=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),lt.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||lt.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||lt.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||lt.defineReadOnly(i.ethers.wordlists,r,e))}}})),ro=(e(eo),eo.check,eo.Wordlist,eo.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",s=null;function a(t){if(null==s&&(s=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==eo.check(t)))throw s=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),s[t]},e.prototype.getWordIndex=function(t){return a(this),s.indexOf(t)},e}(eo.Wordlist));r.langEn=u,eo.register(u)})),no=(e(ro),ro.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=eo.Wordlist;var r={en:ro.langEn};e.wordlists=r})),io=(e(no),no.Wordlist),oo=no.wordlists;const so=new p("hdnode/5.0.0-beta.130"),ao=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),uo=Se("Bitcoin seed"),ho=2147483648;function lo(t){return(1<=256)throw new Error("Depth too large!");return co(E([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",x(this.depth),this.parentFingerprint,R(x(this.index),4),this.chainCode,null!=this.privateKey?E(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new go(po,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~ho));let r=new Uint8Array(37);if(t&ho){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(_(this.privateKey),1),e&&(e+="'")}else r.set(_(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=_(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),o=n.slice(32),s=null,a=null;if(this.privateKey)s=fo(U.from(i).add(this.privateKey).mod(ao));else{a=new qi(x(i))._addPoint(this.publicKey)}return new go(po,s,a,this.fingerprint,fo(o),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=ho)throw new Error("invalid path index - "+n);r=r._derive(ho+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invlaid path component - "+n);{let t=parseInt(n);if(t>=ho)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=_(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=_(Yn(Xn.sha512,uo,r));return new go(po,fo(n.slice(0,32)),null,"0x00000000",fo(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=bo(yo(t,r),r),go._fromSeed(vo(t,e),t)}static fromSeed(t){return go._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&co(e.slice(0,78))===t||so.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=x(e.slice(5,9)),i=parseInt(x(e.slice(9,13)).substring(2),16),o=x(e.slice(13,45)),s=e.slice(45,78);switch(x(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new go(po,null,x(s),n,o,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==s[0])break;return new go(po,x(s.slice(1)),null,n,o,i,r,null,null)}return so.throwError("invalid extended key","extendedKey","[REDACTED]")}}function vo(t,e){e||(e="");let r=Se("mnemonic"+e,_e.NFKD);return ei(Se(t,_e.NFKD),r,2048,64,"sha512")}function yo(t,e){e||(e=oo.en),so.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=_(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let o=32*r.length/3,s=lo(r.length/3),a=_(Qn(n.slice(0,o/8)))[0];if((a&=s)!==(n[n.length-1]&s))throw new Error("invalid checksum");return x(n.slice(0,o/8))}function bo(t,e){if((t=_(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=_(Qn(t))[0],o=t.length/4;return i&=lo(o),r[r.length-1]<<=o,r[r.length-1]|=i>>8-o,e||(e=oo.en),e.join(r.map(t=>e.getWord(t)))}var wo=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.128"}),_o=(e(wo),wo.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),Eo=(e(_o),_o.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(wo.version);r.shuffled=_o.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),So=(e(Eo),Eo.shuffled),Ao=Eo.randomBytes,Mo=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function o(t){return new Uint8Array(t)}function s(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,u={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},h=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),l={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],v=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],y=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],S=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=o[e],this._Kd[t-r][e%4]=o[e];for(var s,a=0,u=i;u>16&255]<<24^c[s>>8&255]<<16^c[255&s]<<8^c[s>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[s>>16&255]<<16^c[s>>24&255]<<24;for(e=i/2+1;e>2,d=u%4,this._Ke[h][d]=o[e],this._Kd[t-h][d]=o[e++],u++}for(var h=1;h>24&255]^S[s>>16&255]^A[s>>8&255]^M[255&s]},x.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var s=1;s>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^v[255&n[(i+3)%4]]^this._Ke[s][i];n=r.slice()}var a,u=o(16);for(i=0;i<4;i++)a=this._Ke[e][i],u[4*i]=255&(c[n[i]>>24&255]^a>>24),u[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),u[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return u},x.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var s=1;s>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[s][i];n=r.slice()}var a,u=o(16);for(i=0;i<4;i++)a=this._Kd[e][i],u[4*i]=255&(d[n[i]>>24&255]^a>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return u};var P=function(t){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new x(t)};P.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=o(t.length),r=o(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var B=function(t,e){if(!(this instanceof B))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new x(t)};B.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,v,y=r,b=n,w=i,_=o,E=s,S=a,A=u,M=h;for(p=0;p<16;p++)m=f+4*p,l[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=l[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,v=((d=l[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,l[p]=(g+l[p-7]|0)+(v+l[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&S^~E&A)|0)+(M+(e[p]+l[p]|0)|0)|0,v=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&b^y&w^b&w)|0,M=A,A=S,S=E,E=_+g|0,_=w,w=b,b=y,y=g+v|0;r=r+y|0,n=n+b|0,i=i+w|0,o=o+_|0,s=s+E|0,a=a+S|0,u=u+A|0,h=h+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,v=t.slice(t.length-d,t.length);for(v.push(128),c=d+1;c>>24&255),v.push(p>>>16&255),v.push(p>>>8&255),v.push(p>>>0&255),v.push(m>>>24&255),v.push(m>>>16&255),v.push(m>>>8&255),v.push(m>>>0&255),f(v),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var o=64+e.length+4,s=new Array(o),a=new Array(64),u=[];for(i=0;i<64;i++)s[i]=54;for(i=0;i=o-4;t--){if(s[t]++,s[t]<=255)return;s[t]=0}}for(;r>=32;)h(),u=u.concat(n(a.concat(n(s)))),r-=32;return r>0&&(h(),u=u.concat(n(a.concat(n(s))).slice(0,r))),u}function o(t,e,r,n,i){var o;for(h(t,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(t,16*o,i,16),a(i,n),h(i,0,t,e+16*o,16);for(o=0;o>>32-e}function a(t,e){h(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=s(e[0]+e[12],7),e[8]^=s(e[4]+e[0],9),e[12]^=s(e[8]+e[4],13),e[0]^=s(e[12]+e[8],18),e[9]^=s(e[5]+e[1],7),e[13]^=s(e[9]+e[5],9),e[1]^=s(e[13]+e[9],13),e[5]^=s(e[1]+e[13],18),e[14]^=s(e[10]+e[6],7),e[2]^=s(e[14]+e[10],9),e[6]^=s(e[2]+e[14],13),e[10]^=s(e[6]+e[2],18),e[3]^=s(e[15]+e[11],7),e[7]^=s(e[3]+e[15],9),e[11]^=s(e[7]+e[3],13),e[15]^=s(e[11]+e[7],18),e[1]^=s(e[0]+e[3],7),e[2]^=s(e[1]+e[0],9),e[3]^=s(e[2]+e[1],13),e[0]^=s(e[3]+e[2],18),e[6]^=s(e[5]+e[4],7),e[7]^=s(e[6]+e[5],9),e[4]^=s(e[7]+e[6],13),e[5]^=s(e[4]+e[7],18),e[11]^=s(e[10]+e[9],7),e[8]^=s(e[11]+e[10],9),e[9]^=s(e[8]+e[11],13),e[10]^=s(e[9]+e[8],18),e[12]^=s(e[15]+e[14],7),e[13]^=s(e[12]+e[15],9),e[14]^=s(e[13]+e[12],13),e[15]^=s(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function u(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,s,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),s=f(s,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/s)throw new Error("N too large");if(s>r/128/a)throw new Error("r too large");if(!l(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!l(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*s),m=new Uint32Array(32*a*s),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(B)};B()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Fo=new Uint8Array(16);Co=function(){return crypto.getRandomValues(Fo),Fo}}if(!Co){var Lo=new Array(16);Co=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Lo[e]=t>>>((3&e)<<3)&255;return Lo}}for(var Do=Co,Uo=[],zo={},jo=0;jo<256;jo++)Uo[jo]=(jo+256).toString(16).substr(1),zo[Uo[jo]]=jo;function Ho(t,e){var r=e||0,n=Uo;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var qo=Do(),Ko=[1|qo[0],qo[1],qo[2],qo[3],qo[4],qo[5]],Go=16383&(qo[6]<<8|qo[7]),Wo=0,Vo=0;function Jo(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Do)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var o=0;o<16;o++)e[n+o]=i[o];return e||Ho(i)}var Zo=Jo;Zo.v1=function(t,e,r){var n=e&&r||0,i=e||[],o=void 0!==(t=t||{}).clockseq?t.clockseq:Go,s=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Vo+1,u=s-Wo+(a-Vo)/1e4;if(u<0&&void 0===t.clockseq&&(o=o+1&16383),(u<0||s>Wo)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Wo=s,Vo=a,Go=o;var h=(1e4*(268435455&(s+=122192928e5))+a)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=255&h;var l=s/4294967296*1e4&268435455;i[n++]=l>>>8&255,i[n++]=255&l,i[n++]=l>>>24&15|16,i[n++]=l>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var f=t.node||Ko,c=0;c<6;c++)i[n+c]=f[c];return e||Ho(i)},Zo.v4=Jo,Zo.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=zo[t])});i<16;)e[n+i++]=0;return e},Zo.unparse=Ho;var Xo=Zo;class $o extends ht{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function Qo(t,e,r){let n=JSON.parse(t),i=Po(e),o=function(t,e){let r=ko(No(n,"crypto/ciphertext"));if(x(function(t,e){return Lt(E([t,e]))}(t.slice(16,32),r)).substring(2)!==No(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===No(n,"crypto/cipher")){let r=ko(No(n,"crypto/cipherparams/iv")),i=new Mo.Counter(r);return _(new Mo.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),o=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let s=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==s)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:s,privateKey:x(i)};if("0.1"===No(n,"x-ethers/version")){let t=ko(No(n,"x-ethers/mnemonicCiphertext")),r=ko(No(n,"x-ethers/mnemonicCounter")),i=new Mo.Counter(r),s=new Mo.ModeOfOperation.ctr(o,i),u=No(n,"x-ethers/path")||mo,h=bo(_(s.decrypt(t))),l=go.fromMnemonic(h).derivePath(u);if(l.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=l.mnemonic,a.path=l.path}return new $o(a)};return new Promise(function(t,e){let s=No(n,"crypto/kdf");if(s&&"string"==typeof s)if("scrypt"===s.toLowerCase()){let s=ko(No(n,"crypto/kdfparams/salt")),a=parseInt(No(n,"crypto/kdfparams/n")),u=parseInt(No(n,"crypto/kdfparams/r")),h=parseInt(No(n,"crypto/kdfparams/p"));if(!a||!u||!h)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(No(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Oo(i,s,a,u,h,64,function(n,i,s){if(n)n.progress=i,e(n);else if(s){s=_(s);let n=o(s,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===s.toLowerCase()){let r=ko(No(n,"crypto/kdfparams/salt")),s=null,a=No(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)s="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));s="sha512"}let u=parseInt(No(n,"crypto/kdfparams/c")),h=parseInt(No(n,"crypto/kdfparams/dklen"));if(32!==h)return void e(new Error("unsupported key-derivation derived-key length"));let l=_(ei(i,r,u,h,s)),f=o(l,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Yo(t,e,r){if(Ro(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=Po(e);let n=$t(No(r,"ethaddr")),i=ko(No(r,"encseed"));i&&i.length%16==0||To.throwArgumentError("invalid encseed","json",t);let o=_(ei(e,e,2e3,32,"sha256")).slice(0,16),s=i.slice(0,16),a=i.slice(16),u=_(new Mo.ModeOfOperation.cbc(o,s).decrypt(a));u=Mo.padding.pkcs7.strip(u);let h="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&ts.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||mo;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(go.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&ts.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&ts.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!hr.isProvider(e)&&ts.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new es(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Lt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(C(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(go.fromMnemonic(t.mnemonic).derivePath(t.path||mo).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=_(t.privateKey),o=Po(e),s=null,a=t.path;t.mnemonic&&(s=_(yo(t.mnemonic)),a||(a=mo));let u=r.client;u||(u="ethers.js");let h=null;h=r.salt?_(r.salt):Ao(32);let l=null;if(r.iv){if(16!==(l=_(r.iv)).length)throw new Error("invalid iv")}else l=Ao(16);let f=null;if(r.uuid){if(16!==(f=_(r.uuid)).length)throw new Error("invalid uuid")}else f=Ao(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Oo(o,h,c,d,p,64,function(o,m,g){if(o)o.progress=m,r(o);else if(g){let r=(g=_(g)).slice(0,16),o=g.slice(16,32),m=g.slice(32,64),v=new Mo.Counter(l),y=_(new Mo.ModeOfOperation.ctr(r,v).encrypt(i)),b=Lt(E([o,y])),w={address:t.address.substring(2).toLowerCase(),id:Xo.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:x(l).substring(2)},ciphertext:x(y).substring(2),kdf:"scrypt",kdfparams:{salt:x(h).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(s){let t=Ao(16),e=new Mo.Counter(t),r=_(new Mo.ModeOfOperation.ctr(m,e).encrypt(s)),n=new Date,i=n.getUTCFullYear()+"-"+xo(n.getUTCMonth()+1,2)+"-"+xo(n.getUTCDate(),2)+"T"+xo(n.getUTCHours(),2)+"-"+xo(n.getUTCMinutes(),2)+"-"+xo(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:u,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:x(t).substring(2),mnemonicCiphertext:x(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=Ao(16);t||(t={}),t.extraEntropy&&(e=_(N(Lt(E([e,t.extraEntropy])),0,16)));let r=bo(e,t.locale);return es.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Yo(t,e,r).then(t=>new es(t))}static fromMnemonic(t,e,r){return e||(e=mo),new es(go.fromMnemonic(t,null,r).derivePath(e))}}const rs=new p("networks/5.0.0-beta.129");function ns(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function is(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const os={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ns("homestead")},ss={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ns("ropsten")},as={unspecified:{chainId:0,name:"unspecified"},homestead:os,mainnet:os,morden:{chainId:2,name:"morden"},ropsten:ss,testnet:ss,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ns("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ns("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ns("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:is("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:is("https://web3.gastracker.io/morden","classicTestnet")}};function us(t){if(null==t)return null;if("number"==typeof t){for(let e in as){let r=as[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=as[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=as[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&rs.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&rs.throwArgumentError("invalid network chainId","network",t),t)}var hs=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=h(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var y=[301,302,303,307,308];v.redirect=function(t,e){if(-1===y.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,o){var s=new m(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new v(n,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",h)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=u,t.Request=m,t.Response=v),e.Headers=u,e.Request=m,e.Response=v,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),ls=(hs.fetch,hs.Headers,hs.Request,hs.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(s=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&ms.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+ds(Se(e))}}}return new Promise(function(t,a){let u=null;s&&(u=setTimeout(()=>{null!=u&&(u=null,a(ms.makeError("timeout",p.errors.TIMEOUT,{timeout:s})))},s));let h=()=>{null!=u&&(clearTimeout(u),u=null)};e&&(o.method="POST",o.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let l={};return Object.keys(n).forEach(t=>{let e=n[t];l[e.key]=e.value}),o.headers=l,hs(i,o).then(t=>t.text().then(e=>(t.ok||ms.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){ms.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){ms.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{h(),t(e)},t=>{h(),a(t)})})}function vs(t,e){return e||(e={}),null==(e=st(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,o=!1,s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{s()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,u=0;!function i(){return t().then(function(t){if(void 0!==t)s()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!o){if(++u>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,u)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){s()&&n(t)})}()})}const ys="providers/5.0.0-beta.141",bs=new p(ys);class ws{constructor(){bs.checkNew(new.target,ws),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:o,blockHash:ws.allowNull(o,null),blockNumber:ws.allowNull(a,null),transactionIndex:ws.allowNull(a,null),confirmations:ws.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:ws.allowNull(e,null),value:r,nonce:a,data:i,r:ws.allowNull(this.uint256),s:ws.allowNull(this.uint256),v:ws.allowNull(a),creates:ws.allowNull(e,null),raw:ws.allowNull(i)},t.transactionRequest={from:ws.allowNull(e),nonce:ws.allowNull(a),gasLimit:ws.allowNull(r),gasPrice:ws.allowNull(r),to:ws.allowNull(e),value:ws.allowNull(r),data:ws.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:ws.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:o,address:e,topics:ws.arrayOf(o),data:i,logIndex:a,blockHash:o},t.receipt={to:ws.allowNull(this.address),from:ws.allowNull(this.address),contractAddress:ws.allowNull(e,null),transactionIndex:a,root:ws.allowNull(o),gasUsed:r,logsBloom:ws.allowNull(i),blockHash:o,transactionHash:o,logs:ws.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ws.allowNull(a,null),cumulativeGasUsed:r,status:ws.allowNull(a)},t.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ws.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:ws.allowNull(ws.arrayOf(o))},t.blockWithTransactions=st(t.block),t.blockWithTransactions.transactions=ws.allowNull(ws.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:ws.allowNull(n,void 0),toBlock:ws.allowNull(n,void 0),blockHash:ws.allowNull(o,void 0),address:ws.allowNull(e,void 0),topics:ws.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:ws.allowNull(a),blockHash:ws.allowNull(o),transactionIndex:a,removed:ws.allowNull(this.boolean.bind(this)),address:e,data:ws.allowFalsish(i,"0x"),topics:ws.arrayOf(o),transactionHash:o,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bs.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(N(t,12));return e===le?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return T(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==P(r)?bs.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),ws.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return ws.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=ws.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return ws.check(this.formats.receiptLog,t)}receipt(t){let e=ws.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return ws.check(this.formats.filter,t)}filterLog(t){return ws.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const _s=new p(ys);function Es(t){return null==t?"null":(32!==P(t)&&_s.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function Ss(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[Es(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return Es(t)}).join("&")}function As(t){if("string"==typeof t){if(32===P(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+Ss(t);if(ur.isForkEvent(t))throw _s.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+Ss(t.topics||[])}throw new Error("invalid event - "+t)}function Ms(){return(new Date).getTime()}class ks{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let xs=null,Ps=1;class Ns extends hr{constructor(t){if(_s.checkNew(new.target,hr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):_s.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==xs&&(xs=new ws),xs}static getNetwork(t){return us(null==t?"homestead":t)}poll(){let t=Ps++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let o=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(o);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Ms();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>x(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>T(t))}).then(t=>x(t))}_wrapTransaction(t,e){if(null!=e&&32!==P(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&_s.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&_s.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>x(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>x(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&_s.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){_s.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return vs(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return vs(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return vs(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>ws.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&_s.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||_s.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=_(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return _s.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ks(As(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=As(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=As(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=As(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=As(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=As(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const Ts=new p(ys);function Is(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Rs(t){return t?t.toLowerCase():t}const Bs={};class Cs extends cr{constructor(t,e,r){if(Ts.checkNew(new.target,Cs),super(),t!==Bs)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):Ts.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Ts.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Os(Bs,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Ts.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=st(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=st(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&Ts.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&Ts.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&Ts.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return Ts.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>vs(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Se(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),x(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Os extends Cs{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fs={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Ls extends Ns{constructor(t,e){if(Ts.checkNew(new.target,Ls),"string"==typeof t&&null===e&&us(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(us(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(us(U.from(e).toNumber()))}).catch(t=>{e(Ts.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Cs(Bs,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ut(r),provider:this}),gs(this.connection,JSON.stringify(r),Is).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Rs(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Rs(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Rs(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Rs(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&Ts.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&Ts.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&Ts.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):Ts.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Rs(e.filter.address)),this.send("eth_getLogs",[e.filter])}return Ts.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=st(Fs);if(e)for(let t in e)e[t]&&(r[t]=!0);ot(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=T(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=x(t[e]))}),n}}const Ds=new p(ys);class Us extends Ls{constructor(t,e){Ds.checkAbstract(new.target,Us),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Ds.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Ds.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return us(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Ds.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zs=new p(ys),js="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Hs=new p(ys);const qs=new p(ys);function Ks(t){let e=[];for(let r in t){if(null==t[r])continue;let n=x(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=T(n)),e.push(r+"="+n)}return e.join("&")}function Gs(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Ws(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vs(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Js extends Ns{constructor(t,e){qs.checkNew(new.target,Js),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),gs(t,null,e||Ws).then(e=>(this.emit("debug",{action:"response",request:t,response:ut(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Gs);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Ws);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Ws);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qs.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qs.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qs.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ks(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ks(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vs(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vs(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let o=this;return i(r+=n,Gs).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?o.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Gs).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),gs(n,null,Gs).then(t=>{this.emit("debug",{action:"response",request:n,response:ut(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zs=new p(ys);function Xs(){return(new Date).getTime()}function $s(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zs.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qs=1;class Ys extends Ns{constructor(t,e,r){Zs.checkNew(new.target,Ys),0===t.length&&Zs.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zs.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zs.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zs.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$s(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($s(t)||Zs.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zs.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xs(),n=So(this.providers).map((n,i)=>{let o=this.weights[i],s=Qs++;return{run:()=>{let i=Xs(),a=i-r;return this.emit("debug",{action:"request",rid:s,backend:{weight:o,start:a,provider:n},request:{method:t,params:ut(e)},provider:this}),Ys.doPerform(n,t,e).then(r=>{let u=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:u,provider:n},request:{method:t,params:ut(e)},response:ut(r)}),{weight:o,result:r}},r=>{let u=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:u,provider:n},request:{method:t,params:ut(e)},error:r}),{weight:o,error:r}})},weight:o}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let o=null,s=0,a={},u=()=>{if(0===n.length)return;let h=n.shift();s+=h.weight,h.run().then(l=>{if(null!==a){if(s-=h.weight,l.error)null==o&&(o=l.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(l.result);null==a[t]&&(a[t]=[]),a[t].push(l);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===s){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===o&&(o=Zs.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(o)}setTimeout(u,0)}}),s{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(ys),ia="84842078b09946638c03157f83405213";const oa=new p(ys),sa="ETHERS_JS_SHARED";const aa=new p(ys);class ua extends Ls{constructor(t,e){aa.checkNew(new.target,ua),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var ha=Object.freeze({Provider:hr,BaseProvider:Ns,FallbackProvider:Ys,AlchemyProvider:class extends Us{static getApiKey(t){return null==t?js:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zs.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Us{static getUrl(t,e){null!=e&&Hs.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Hs.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Js,InfuraProvider:class extends Us{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Ls,NodesmithProvider:class extends Us{static getApiKey(t){return t||sa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:oa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ua,IpcProvider:ra,JsonRpcSigner:Cs,getNetwork:us,Formatter:ws});const la=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?A(r,32):_(r);case"string":return Se(r);case"bytes":return _(r);case"bool":return r=r?"0x01":"0x00",n?A(r,32):_(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),A(r=U.from(r).toTwos(t),t/8)}if(i=e.match(la)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(_(r).byteLength!==t)throw new Error("invalid value for "+e);return n?_((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let o=[];return r.forEach(function(e){o.push(t(n,e,!0))}),E(o)}throw new Error("unknown type - "+e)}(t,e[n]))}),x(E(r))}var ma=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="bignumber/5.0.0-beta.130"}),ga=(e(ma),ma.version,r(function(e,r){var n=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(r,"__esModule",{value:!0});var i=n(o),s=new m.Logger(ma.version),a={};r.isBigNumberish=function(t){return null!=t&&(u.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||O.isHexString(t)||"bigint"==typeof t||O.isBytes(t))};var u=function(){function t(e,r){var n=this.constructor;s.checkNew(n,t),e!==a&&s.throwError("cannot call consturtor directly; use BigNumber.from",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return t.prototype.fromTwos=function(t){return l(f(this).fromTwos(t))},t.prototype.toTwos=function(t){return l(f(this).toTwos(t))},t.prototype.abs=function(){return"-"===this._hex[0]?t.from(this._hex.substring(1)):this},t.prototype.add=function(t){return l(f(this).add(f(t)))},t.prototype.sub=function(t){return l(f(this).sub(f(t)))},t.prototype.div=function(e){return t.from(e).isZero()&&c("division by zero","div"),l(f(this).div(f(e)))},t.prototype.mul=function(t){return l(f(this).mul(f(t)))},t.prototype.mod=function(t){return l(f(this).mod(f(t)))},t.prototype.pow=function(t){return l(f(this).pow(f(t)))},t.prototype.maskn=function(t){return l(f(this).maskn(t))},t.prototype.eq=function(t){return f(this).eq(f(t))},t.prototype.lt=function(t){return f(this).lt(f(t))},t.prototype.lte=function(t){return f(this).lte(f(t))},t.prototype.gt=function(t){return f(this).gt(f(t))},t.prototype.gte=function(t){return f(this).gte(f(t))},t.prototype.isZero=function(){return f(this).isZero()},t.prototype.toNumber=function(){try{return f(this).toNumber()}catch(t){c("overflow","toNumber",this.toString())}return null},t.prototype.toString=function(){return 0!==arguments.length&&s.throwError("bigNumber.toString does not accept parameters",m.Logger.errors.UNEXPECTED_ARGUMENT,{}),f(this).toString(10)},t.prototype.toHexString=function(){return this._hex},t.from=function(e){return e instanceof t?e:"string"==typeof e?e.match(/-?0x[0-9a-f]+/i)?new t(a,h(e)):e.match(/^-?[0-9]+$/)?new t(a,h(new i.BN(e))):s.throwArgumentError("invalid BigNumber string","value",e):"number"==typeof e?(e%1&&c("underflow","BigNumber.from",e),(e>=9007199254740991||e<=-9007199254740991)&&c("overflow","BigNumber.from",e),t.from(String(e))):"bigint"==typeof e?t.from(e.toString()):O.isBytes(e)?t.from(O.hexlify(e)):e._hex&&O.isHexString(e._hex)?t.from(e._hex):e.toHexString&&"string"==typeof(e=e.toHexString())?t.from(e):s.throwArgumentError("invalid BigNumber value","value",e)},t.isBigNumber=function(t){return!(!t||!t._isBigNumber)},t}();function h(t){if("string"!=typeof t)return h(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&s.throwArgumentError("invalid hex","value",t),"0x00"===(t=h(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function l(t){return u.from(h(t))}function f(t){var e=u.from(t).toHexString();return"-"===e[0]?new i.BN("-"+e.substring(3),16):new i.BN(e.substring(2),16)}function c(t,e,r){var n={fault:t,operation:e};return null!=r&&(n.value=r),s.throwError(t,m.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),va=(e(ga),ga.isBigNumberish,ga.BigNumber,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=new m.Logger(ma.version),n={},i=ga.BigNumber.from(0),o=ga.BigNumber.from(-1);function s(t,e,n,i){var o={fault:e,operation:n};return void 0!==i&&(o.value=i),r.throwError(t,m.Logger.errors.NUMERIC_FAULT,o)}for(var a="0";a.length<256;)a+=a;function u(t){if("number"!=typeof t)try{t=ga.BigNumber.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+a.substring(0,t):r.throwArgumentError("invalid decimal size","decimals",t)}function h(t,e){null==e&&(e=0);var r=u(e),n=(t=ga.BigNumber.from(t)).lt(i);n&&(t=t.mul(o));for(var s=t.mod(r).toString();s.length2&&r.throwArgumentError("too many decimal points","value",t);var h=a[0],l=a[1];for(h||(h="0"),l||(l="0"),l.length>n.length-1&&s("fractional component exceeds decimals","underflow","parseFixed");l.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",s),new t(n,i,o,s)},t}();e.FixedFormat=f;var c=function(){function t(e,n,i,o){var s=this.constructor;r.checkNew(s,t),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return t.prototype._checkFormat=function(t){this.format.name!==t.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)},t.prototype.addUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.add(n),this.format.decimals,this.format)},t.prototype.subUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.sub(n),this.format.decimals,this.format)},t.prototype.mulUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},t.prototype.divUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},t.prototype.round=function(e){null==e&&(e=0),(e<0||e>80||e%1)&&r.throwArgumentError("invalid decimal cound","decimals",e);var n=this.toString().split(".");if(n[1].length<=e)return this;var i="0."+a.substring(0,e)+"5";return n=this.addUnsafe(t.fromString(i,this.format))._value.split("."),t.fromString(n[0]+"."+n[1].substring(0,e))},t.prototype.toString=function(){return this._value},t.prototype.toHexString=function(t){if(null==t)return this._hex;t%8&&r.throwArgumentError("invalid byte width","width",t);var e=ga.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return O.hexZeroPad(e,t/8)},t.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},t.prototype.toFormat=function(e){return t.fromString(this._value,e)},t.fromValue=function(e,r,n){return null!=n||null==r||ga.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),t.fromString(h(e,r),f.from(n))},t.fromString=function(e,r){null==r&&(r="fixed");var o=f.from(r),a=l(e,o.decimals);!o.signed&&a.lt(i)&&s("unsigned value cannot be negative","overflow","value",e);var u=null;o.signed?u=a.toTwos(o.width).toHexString():(u=a.toHexString(),u=O.hexZeroPad(u,o.width/8));var c=h(a,o.decimals);return new t(n,u,c,o)},t.fromBytes=function(e,r){null==r&&(r="fixed");var i=f.from(r);if(O.arrayify(e).length>i.width/8)throw new Error("overflow");var o=ga.BigNumber.from(e);i.signed&&(o=o.fromTwos(i.width));var s=o.toTwos((i.signed?0:1)+i.width).toHexString(),a=h(o,i.decimals);return new t(n,s,a,i)},t.from=function(e,n){if("string"==typeof e)return t.fromString(e,n);if(O.isBytes(e))return t.fromBytes(e,n);try{return t.fromValue(e,0,n)}catch(t){if(t.code!==m.Logger.errors.INVALID_ARGUMENT)throw t}return r.throwArgumentError("invalid FixedNumber value","value",e)},t.isFixedNumber=function(t){return!(!t||!t._isFixedNumber)},t}();e.FixedNumber=c})),ya=(e(va),va.formatFixed),ba=va.parseFixed;va.FixedFormat,va.FixedNumber;const wa=new p("units/5.0.0-beta.127"),_a=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Ea(t,e){if("string"==typeof e){let t=_a.indexOf(e);-1!==t&&(e=3*t)}return ya(t,null!=e?e:18)}function Sa(t,e){if("string"==typeof e){let t=_a.indexOf(e);-1!==t&&(e=3*t)}return ba(t,null!=e?e:18)}var Aa=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:_t,EventFragment:Et,FunctionFragment:xt,ParamType:bt,FormatTypes:vt,Logger:p,RLP:Kt,fetchJson:gs,poll:vs,checkProperties:ot,deepCopy:ut,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:st,arrayify:_,concat:E,stripZeros:S,zeroPad:A,defaultPath:mo,HDNode:go,SigningKey:qi,Interface:or,base64:ps,hexlify:x,isHexString:M,hexStripZeros:I,hexValue:T,hexZeroPad:R,hexDataLength:P,hexDataSlice:N,nameprep:De,_toEscapedUtf8String:function(t,e){return'"'+Ee(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Ae(t):Ae(55296+((t-=65536)>>10&1023))+Ae(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Se,toUtf8CodePoints:xe,toUtf8String:ke,formatBytes32String:function(t){let e=Se(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return x(E([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=_(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new s($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return Ea(t,18)},parseEther:function(t){return Sa(t,18)},formatUnits:Ea,parseUnits:Sa,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&wa.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let o=[];for(;r.length;){if(r.length<=3){o.unshift(r);break}{let t=r.length-3;o.unshift(r.substring(t)),r=r.substring(0,t)}}return n+o.join(",")+i},keccak256:Lt,sha256:Qn,randomBytes:Ao,solidityPack:pa,solidityKeccak256:function(t,e){return Lt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:B,joinSignature:C,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Ro(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Bo(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:yo,entropyToMnemonic:bo,isValidMnemonic:function(t,e){try{return yo(t,e),!0}catch(t){}return!1},mnemonicToSeed:vo,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return _e},Indexed:ir});const Ma="node",ka="ethers/5.0.0-beta.156",xa=p.errors,Pa=new p(ka);function Na(t,e){null==t&&(t="homestead");let r=us(t);return r&&r._defaultProvider||Pa.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(ha,e)}var Ta=Object.freeze({version:ka,Signer:cr,Wallet:es,VoidSigner:dr,getDefaultProvider:Na,providers:ha,Contract:Sr,ContractFactory:Ar,BigNumber:U,FixedNumber:tt,constants:ye,errors:xa,logger:Pa,utils:Aa,wordlists:oo,platform:"node",Wordlist:io});window.ethers=Ta;export{U as BigNumber,Sr as Contract,Ar as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,es as Wallet,io as Wordlist,ye as constants,xa as errors,Ta as ethers,Na as getDefaultProvider,Pa as logger,Ma as platform,ha as providers,Aa as utils,ka as version,oo as wordlists}; diff --git a/packages/ethers/dist/ethers.umd.js b/packages/ethers/dist/ethers.umd.js new file mode 100644 index 000000000..cdd8b5d31 --- /dev/null +++ b/packages/ethers/dist/ethers.umd.js @@ -0,0 +1,20648 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = global || self, factory(global.ethers = {})); +}(this, function (exports) { 'use strict'; + + var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + + function commonjsRequire () { + throw new Error('Dynamic requires are not currently supported by rollup-plugin-commonjs'); + } + + function unwrapExports (x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; + } + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + function getCjsExportFromNamespace (n) { + return n && n['default'] || n; + } + + var _nodeResolve_empty = {}; + + var _nodeResolve_empty$1 = /*#__PURE__*/Object.freeze({ + 'default': _nodeResolve_empty + }); + + var require$$0 = getCjsExportFromNamespace(_nodeResolve_empty$1); + + var bn = createCommonjsModule(function (module) { + (function (module, exports) { + 'use strict'; + + // Utils + function assert (val, msg) { + if (!val) throw new Error(msg || 'Assertion failed'); + } + + // Could use `inherits` module, but don't want to move from single file + // architecture yet. + function inherits (ctor, superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + + // BN + + function BN (number, base, endian) { + if (BN.isBN(number)) { + return number; + } + + this.negative = 0; + this.words = null; + this.length = 0; + + // Reduction context + this.red = null; + + if (number !== null) { + if (base === 'le' || base === 'be') { + endian = base; + base = 10; + } + + this._init(number || 0, base || 10, endian || 'be'); + } + } + if (typeof module === 'object') { + module.exports = BN; + } else { + exports.BN = BN; + } + + BN.BN = BN; + BN.wordSize = 26; + + var Buffer; + try { + Buffer = require$$0.Buffer; + } catch (e) { + } + + BN.isBN = function isBN (num) { + if (num instanceof BN) { + return true; + } + + return num !== null && typeof num === 'object' && + num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); + }; + + BN.max = function max (left, right) { + if (left.cmp(right) > 0) return left; + return right; + }; + + BN.min = function min (left, right) { + if (left.cmp(right) < 0) return left; + return right; + }; + + BN.prototype._init = function init (number, base, endian) { + if (typeof number === 'number') { + return this._initNumber(number, base, endian); + } + + if (typeof number === 'object') { + return this._initArray(number, base, endian); + } + + if (base === 'hex') { + base = 16; + } + assert(base === (base | 0) && base >= 2 && base <= 36); + + number = number.toString().replace(/\s+/g, ''); + var start = 0; + if (number[0] === '-') { + start++; + } + + if (base === 16) { + this._parseHex(number, start); + } else { + this._parseBase(number, base, start); + } + + if (number[0] === '-') { + this.negative = 1; + } + + this.strip(); + + if (endian !== 'le') return; + + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initNumber = function _initNumber (number, base, endian) { + if (number < 0) { + this.negative = 1; + number = -number; + } + if (number < 0x4000000) { + this.words = [ number & 0x3ffffff ]; + this.length = 1; + } else if (number < 0x10000000000000) { + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff + ]; + this.length = 2; + } else { + assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) + this.words = [ + number & 0x3ffffff, + (number / 0x4000000) & 0x3ffffff, + 1 + ]; + this.length = 3; + } + + if (endian !== 'le') return; + + // Reverse the bytes + this._initArray(this.toArray(), base, endian); + }; + + BN.prototype._initArray = function _initArray (number, base, endian) { + // Perhaps a Uint8Array + assert(typeof number.length === 'number'); + if (number.length <= 0) { + this.words = [ 0 ]; + this.length = 1; + return this; + } + + this.length = Math.ceil(number.length / 3); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + var off = 0; + if (endian === 'be') { + for (i = number.length - 1, j = 0; i >= 0; i -= 3) { + w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } else if (endian === 'le') { + for (i = 0, j = 0; i < number.length; i += 3) { + w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + } + return this.strip(); + }; + + function parseHex (str, start, end) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r <<= 4; + + // 'a' - 'f' + if (c >= 49 && c <= 54) { + r |= c - 49 + 0xa; + + // 'A' - 'F' + } else if (c >= 17 && c <= 22) { + r |= c - 17 + 0xa; + + // '0' - '9' + } else { + r |= c & 0xf; + } + } + return r; + } + + BN.prototype._parseHex = function _parseHex (number, start) { + // Create possibly bigger array to ensure that it fits the number + this.length = Math.ceil((number.length - start) / 6); + this.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + this.words[i] = 0; + } + + var j, w; + // Scan 24-bit chunks and add them to the number + var off = 0; + for (i = number.length - 6, j = 0; i >= start; i -= 6) { + w = parseHex(number, i, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + off += 24; + if (off >= 26) { + off -= 26; + j++; + } + } + if (i + 6 !== start) { + w = parseHex(number, start, i + 6); + this.words[j] |= (w << off) & 0x3ffffff; + this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; + } + this.strip(); + }; + + function parseBase (str, start, end, mul) { + var r = 0; + var len = Math.min(str.length, end); + for (var i = start; i < len; i++) { + var c = str.charCodeAt(i) - 48; + + r *= mul; + + // 'a' + if (c >= 49) { + r += c - 49 + 0xa; + + // 'A' + } else if (c >= 17) { + r += c - 17 + 0xa; + + // '0' - '9' + } else { + r += c; + } + } + return r; + } + + BN.prototype._parseBase = function _parseBase (number, base, start) { + // Initialize as zero + this.words = [ 0 ]; + this.length = 1; + + // Find length of limb in base + for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { + limbLen++; + } + limbLen--; + limbPow = (limbPow / base) | 0; + + var total = number.length - start; + var mod = total % limbLen; + var end = Math.min(total, total - mod) + start; + + var word = 0; + for (var i = start; i < end; i += limbLen) { + word = parseBase(number, i, i + limbLen, base); + + this.imuln(limbPow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + + if (mod !== 0) { + var pow = 1; + word = parseBase(number, i, number.length, base); + + for (i = 0; i < mod; i++) { + pow *= base; + } + + this.imuln(pow); + if (this.words[0] + word < 0x4000000) { + this.words[0] += word; + } else { + this._iaddn(word); + } + } + }; + + BN.prototype.copy = function copy (dest) { + dest.words = new Array(this.length); + for (var i = 0; i < this.length; i++) { + dest.words[i] = this.words[i]; + } + dest.length = this.length; + dest.negative = this.negative; + dest.red = this.red; + }; + + BN.prototype.clone = function clone () { + var r = new BN(null); + this.copy(r); + return r; + }; + + BN.prototype._expand = function _expand (size) { + while (this.length < size) { + this.words[this.length++] = 0; + } + return this; + }; + + // Remove leading `0` from `this` + BN.prototype.strip = function strip () { + while (this.length > 1 && this.words[this.length - 1] === 0) { + this.length--; + } + return this._normSign(); + }; + + BN.prototype._normSign = function _normSign () { + // -0 = 0 + if (this.length === 1 && this.words[0] === 0) { + this.negative = 0; + } + return this; + }; + + BN.prototype.inspect = function inspect () { + return (this.red ? ''; + }; + + /* + + var zeros = []; + var groupSizes = []; + var groupBases = []; + + var s = ''; + var i = -1; + while (++i < BN.wordSize) { + zeros[i] = s; + s += '0'; + } + groupSizes[0] = 0; + groupSizes[1] = 0; + groupBases[0] = 0; + groupBases[1] = 0; + var base = 2 - 1; + while (++base < 36 + 1) { + var groupSize = 0; + var groupBase = 1; + while (groupBase < (1 << BN.wordSize) / base) { + groupBase *= base; + groupSize += 1; + } + groupSizes[base] = groupSize; + groupBases[base] = groupBase; + } + + */ + + var zeros = [ + '', + '0', + '00', + '000', + '0000', + '00000', + '000000', + '0000000', + '00000000', + '000000000', + '0000000000', + '00000000000', + '000000000000', + '0000000000000', + '00000000000000', + '000000000000000', + '0000000000000000', + '00000000000000000', + '000000000000000000', + '0000000000000000000', + '00000000000000000000', + '000000000000000000000', + '0000000000000000000000', + '00000000000000000000000', + '000000000000000000000000', + '0000000000000000000000000' + ]; + + var groupSizes = [ + 0, 0, + 25, 16, 12, 11, 10, 9, 8, + 8, 7, 7, 7, 7, 6, 6, + 6, 6, 6, 6, 6, 5, 5, + 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5 + ]; + + var groupBases = [ + 0, 0, + 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, + 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, + 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, + 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, + 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 + ]; + + BN.prototype.toString = function toString (base, padding) { + base = base || 10; + padding = padding | 0 || 1; + + var out; + if (base === 16 || base === 'hex') { + out = ''; + var off = 0; + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = this.words[i]; + var word = (((w << off) | carry) & 0xffffff).toString(16); + carry = (w >>> (24 - off)) & 0xffffff; + if (carry !== 0 || i !== this.length - 1) { + out = zeros[6 - word.length] + word + out; + } else { + out = word + out; + } + off += 2; + if (off >= 26) { + off -= 26; + i--; + } + } + if (carry !== 0) { + out = carry.toString(16) + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + if (base === (base | 0) && base >= 2 && base <= 36) { + // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); + var groupSize = groupSizes[base]; + // var groupBase = Math.pow(base, groupSize); + var groupBase = groupBases[base]; + out = ''; + var c = this.clone(); + c.negative = 0; + while (!c.isZero()) { + var r = c.modn(groupBase).toString(base); + c = c.idivn(groupBase); + + if (!c.isZero()) { + out = zeros[groupSize - r.length] + r + out; + } else { + out = r + out; + } + } + if (this.isZero()) { + out = '0' + out; + } + while (out.length % padding !== 0) { + out = '0' + out; + } + if (this.negative !== 0) { + out = '-' + out; + } + return out; + } + + assert(false, 'Base should be between 2 and 36'); + }; + + BN.prototype.toNumber = function toNumber () { + var ret = this.words[0]; + if (this.length === 2) { + ret += this.words[1] * 0x4000000; + } else if (this.length === 3 && this.words[2] === 0x01) { + // NOTE: at this stage it is known that the top bit is set + ret += 0x10000000000000 + (this.words[1] * 0x4000000); + } else if (this.length > 2) { + assert(false, 'Number can only safely store up to 53 bits'); + } + return (this.negative !== 0) ? -ret : ret; + }; + + BN.prototype.toJSON = function toJSON () { + return this.toString(16); + }; + + BN.prototype.toBuffer = function toBuffer (endian, length) { + assert(typeof Buffer !== 'undefined'); + return this.toArrayLike(Buffer, endian, length); + }; + + BN.prototype.toArray = function toArray (endian, length) { + return this.toArrayLike(Array, endian, length); + }; + + BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { + var byteLength = this.byteLength(); + var reqLength = length || Math.max(1, byteLength); + assert(byteLength <= reqLength, 'byte array longer than desired length'); + assert(reqLength > 0, 'Requested array length <= 0'); + + this.strip(); + var littleEndian = endian === 'le'; + var res = new ArrayType(reqLength); + + var b, i; + var q = this.clone(); + if (!littleEndian) { + // Assume big-endian + for (i = 0; i < reqLength - byteLength; i++) { + res[i] = 0; + } + + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[reqLength - i - 1] = b; + } + } else { + for (i = 0; !q.isZero(); i++) { + b = q.andln(0xff); + q.iushrn(8); + + res[i] = b; + } + + for (; i < reqLength; i++) { + res[i] = 0; + } + } + + return res; + }; + + if (Math.clz32) { + BN.prototype._countBits = function _countBits (w) { + return 32 - Math.clz32(w); + }; + } else { + BN.prototype._countBits = function _countBits (w) { + var t = w; + var r = 0; + if (t >= 0x1000) { + r += 13; + t >>>= 13; + } + if (t >= 0x40) { + r += 7; + t >>>= 7; + } + if (t >= 0x8) { + r += 4; + t >>>= 4; + } + if (t >= 0x02) { + r += 2; + t >>>= 2; + } + return r + t; + }; + } + + BN.prototype._zeroBits = function _zeroBits (w) { + // Short-cut + if (w === 0) return 26; + + var t = w; + var r = 0; + if ((t & 0x1fff) === 0) { + r += 13; + t >>>= 13; + } + if ((t & 0x7f) === 0) { + r += 7; + t >>>= 7; + } + if ((t & 0xf) === 0) { + r += 4; + t >>>= 4; + } + if ((t & 0x3) === 0) { + r += 2; + t >>>= 2; + } + if ((t & 0x1) === 0) { + r++; + } + return r; + }; + + // Return number of used bits in a BN + BN.prototype.bitLength = function bitLength () { + var w = this.words[this.length - 1]; + var hi = this._countBits(w); + return (this.length - 1) * 26 + hi; + }; + + function toBitArray (num) { + var w = new Array(num.bitLength()); + + for (var bit = 0; bit < w.length; bit++) { + var off = (bit / 26) | 0; + var wbit = bit % 26; + + w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; + } + + return w; + } + + // Number of trailing zero bits + BN.prototype.zeroBits = function zeroBits () { + if (this.isZero()) return 0; + + var r = 0; + for (var i = 0; i < this.length; i++) { + var b = this._zeroBits(this.words[i]); + r += b; + if (b !== 26) break; + } + return r; + }; + + BN.prototype.byteLength = function byteLength () { + return Math.ceil(this.bitLength() / 8); + }; + + BN.prototype.toTwos = function toTwos (width) { + if (this.negative !== 0) { + return this.abs().inotn(width).iaddn(1); + } + return this.clone(); + }; + + BN.prototype.fromTwos = function fromTwos (width) { + if (this.testn(width - 1)) { + return this.notn(width).iaddn(1).ineg(); + } + return this.clone(); + }; + + BN.prototype.isNeg = function isNeg () { + return this.negative !== 0; + }; + + // Return negative clone of `this` + BN.prototype.neg = function neg () { + return this.clone().ineg(); + }; + + BN.prototype.ineg = function ineg () { + if (!this.isZero()) { + this.negative ^= 1; + } + + return this; + }; + + // Or `num` with `this` in-place + BN.prototype.iuor = function iuor (num) { + while (this.length < num.length) { + this.words[this.length++] = 0; + } + + for (var i = 0; i < num.length; i++) { + this.words[i] = this.words[i] | num.words[i]; + } + + return this.strip(); + }; + + BN.prototype.ior = function ior (num) { + assert((this.negative | num.negative) === 0); + return this.iuor(num); + }; + + // Or `num` with `this` + BN.prototype.or = function or (num) { + if (this.length > num.length) return this.clone().ior(num); + return num.clone().ior(this); + }; + + BN.prototype.uor = function uor (num) { + if (this.length > num.length) return this.clone().iuor(num); + return num.clone().iuor(this); + }; + + // And `num` with `this` in-place + BN.prototype.iuand = function iuand (num) { + // b = min-length(num, this) + var b; + if (this.length > num.length) { + b = num; + } else { + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = this.words[i] & num.words[i]; + } + + this.length = b.length; + + return this.strip(); + }; + + BN.prototype.iand = function iand (num) { + assert((this.negative | num.negative) === 0); + return this.iuand(num); + }; + + // And `num` with `this` + BN.prototype.and = function and (num) { + if (this.length > num.length) return this.clone().iand(num); + return num.clone().iand(this); + }; + + BN.prototype.uand = function uand (num) { + if (this.length > num.length) return this.clone().iuand(num); + return num.clone().iuand(this); + }; + + // Xor `num` with `this` in-place + BN.prototype.iuxor = function iuxor (num) { + // a.length > b.length + var a; + var b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + for (var i = 0; i < b.length; i++) { + this.words[i] = a.words[i] ^ b.words[i]; + } + + if (this !== a) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = a.length; + + return this.strip(); + }; + + BN.prototype.ixor = function ixor (num) { + assert((this.negative | num.negative) === 0); + return this.iuxor(num); + }; + + // Xor `num` with `this` + BN.prototype.xor = function xor (num) { + if (this.length > num.length) return this.clone().ixor(num); + return num.clone().ixor(this); + }; + + BN.prototype.uxor = function uxor (num) { + if (this.length > num.length) return this.clone().iuxor(num); + return num.clone().iuxor(this); + }; + + // Not ``this`` with ``width`` bitwidth + BN.prototype.inotn = function inotn (width) { + assert(typeof width === 'number' && width >= 0); + + var bytesNeeded = Math.ceil(width / 26) | 0; + var bitsLeft = width % 26; + + // Extend the buffer with leading zeroes + this._expand(bytesNeeded); + + if (bitsLeft > 0) { + bytesNeeded--; + } + + // Handle complete words + for (var i = 0; i < bytesNeeded; i++) { + this.words[i] = ~this.words[i] & 0x3ffffff; + } + + // Handle the residue + if (bitsLeft > 0) { + this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); + } + + // And remove leading zeroes + return this.strip(); + }; + + BN.prototype.notn = function notn (width) { + return this.clone().inotn(width); + }; + + // Set `bit` of `this` + BN.prototype.setn = function setn (bit, val) { + assert(typeof bit === 'number' && bit >= 0); + + var off = (bit / 26) | 0; + var wbit = bit % 26; + + this._expand(off + 1); + + if (val) { + this.words[off] = this.words[off] | (1 << wbit); + } else { + this.words[off] = this.words[off] & ~(1 << wbit); + } + + return this.strip(); + }; + + // Add `num` to `this` in-place + BN.prototype.iadd = function iadd (num) { + var r; + + // negative + positive + if (this.negative !== 0 && num.negative === 0) { + this.negative = 0; + r = this.isub(num); + this.negative ^= 1; + return this._normSign(); + + // positive + negative + } else if (this.negative === 0 && num.negative !== 0) { + num.negative = 0; + r = this.isub(num); + num.negative = 1; + return r._normSign(); + } + + // a.length > b.length + var a, b; + if (this.length > num.length) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) + (b.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + this.words[i] = r & 0x3ffffff; + carry = r >>> 26; + } + + this.length = a.length; + if (carry !== 0) { + this.words[this.length] = carry; + this.length++; + // Copy the rest of the words + } else if (a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + return this; + }; + + // Add `num` to `this` + BN.prototype.add = function add (num) { + var res; + if (num.negative !== 0 && this.negative === 0) { + num.negative = 0; + res = this.sub(num); + num.negative ^= 1; + return res; + } else if (num.negative === 0 && this.negative !== 0) { + this.negative = 0; + res = num.sub(this); + this.negative = 1; + return res; + } + + if (this.length > num.length) return this.clone().iadd(num); + + return num.clone().iadd(this); + }; + + // Subtract `num` from `this` in-place + BN.prototype.isub = function isub (num) { + // this - (-num) = this + num + if (num.negative !== 0) { + num.negative = 0; + var r = this.iadd(num); + num.negative = 1; + return r._normSign(); + + // -this - num = -(this + num) + } else if (this.negative !== 0) { + this.negative = 0; + this.iadd(num); + this.negative = 1; + return this._normSign(); + } + + // At this point both numbers are positive + var cmp = this.cmp(num); + + // Optimization - zeroify + if (cmp === 0) { + this.negative = 0; + this.length = 1; + this.words[0] = 0; + return this; + } + + // a > b + var a, b; + if (cmp > 0) { + a = this; + b = num; + } else { + a = num; + b = this; + } + + var carry = 0; + for (var i = 0; i < b.length; i++) { + r = (a.words[i] | 0) - (b.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + for (; carry !== 0 && i < a.length; i++) { + r = (a.words[i] | 0) + carry; + carry = r >> 26; + this.words[i] = r & 0x3ffffff; + } + + // Copy rest of the words + if (carry === 0 && i < a.length && a !== this) { + for (; i < a.length; i++) { + this.words[i] = a.words[i]; + } + } + + this.length = Math.max(this.length, i); + + if (a !== this) { + this.negative = 1; + } + + return this.strip(); + }; + + // Subtract `num` from `this` + BN.prototype.sub = function sub (num) { + return this.clone().isub(num); + }; + + function smallMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + var len = (self.length + num.length) | 0; + out.length = len; + len = (len - 1) | 0; + + // Peel one iteration (compiler can't do it, because of code complexity) + var a = self.words[0] | 0; + var b = num.words[0] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + var carry = (r / 0x4000000) | 0; + out.words[0] = lo; + + for (var k = 1; k < len; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = carry >>> 26; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = (k - j) | 0; + a = self.words[i] | 0; + b = num.words[j] | 0; + r = a * b + rword; + ncarry += (r / 0x4000000) | 0; + rword = r & 0x3ffffff; + } + out.words[k] = rword | 0; + carry = ncarry | 0; + } + if (carry !== 0) { + out.words[k] = carry | 0; + } else { + out.length--; + } + + return out.strip(); + } + + // TODO(indutny): it may be reasonable to omit it for users who don't need + // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit + // multiplication (like elliptic secp256k1). + var comb10MulTo = function comb10MulTo (self, num, out) { + var a = self.words; + var b = num.words; + var o = out.words; + var c = 0; + var lo; + var mid; + var hi; + var a0 = a[0] | 0; + var al0 = a0 & 0x1fff; + var ah0 = a0 >>> 13; + var a1 = a[1] | 0; + var al1 = a1 & 0x1fff; + var ah1 = a1 >>> 13; + var a2 = a[2] | 0; + var al2 = a2 & 0x1fff; + var ah2 = a2 >>> 13; + var a3 = a[3] | 0; + var al3 = a3 & 0x1fff; + var ah3 = a3 >>> 13; + var a4 = a[4] | 0; + var al4 = a4 & 0x1fff; + var ah4 = a4 >>> 13; + var a5 = a[5] | 0; + var al5 = a5 & 0x1fff; + var ah5 = a5 >>> 13; + var a6 = a[6] | 0; + var al6 = a6 & 0x1fff; + var ah6 = a6 >>> 13; + var a7 = a[7] | 0; + var al7 = a7 & 0x1fff; + var ah7 = a7 >>> 13; + var a8 = a[8] | 0; + var al8 = a8 & 0x1fff; + var ah8 = a8 >>> 13; + var a9 = a[9] | 0; + var al9 = a9 & 0x1fff; + var ah9 = a9 >>> 13; + var b0 = b[0] | 0; + var bl0 = b0 & 0x1fff; + var bh0 = b0 >>> 13; + var b1 = b[1] | 0; + var bl1 = b1 & 0x1fff; + var bh1 = b1 >>> 13; + var b2 = b[2] | 0; + var bl2 = b2 & 0x1fff; + var bh2 = b2 >>> 13; + var b3 = b[3] | 0; + var bl3 = b3 & 0x1fff; + var bh3 = b3 >>> 13; + var b4 = b[4] | 0; + var bl4 = b4 & 0x1fff; + var bh4 = b4 >>> 13; + var b5 = b[5] | 0; + var bl5 = b5 & 0x1fff; + var bh5 = b5 >>> 13; + var b6 = b[6] | 0; + var bl6 = b6 & 0x1fff; + var bh6 = b6 >>> 13; + var b7 = b[7] | 0; + var bl7 = b7 & 0x1fff; + var bh7 = b7 >>> 13; + var b8 = b[8] | 0; + var bl8 = b8 & 0x1fff; + var bh8 = b8 >>> 13; + var b9 = b[9] | 0; + var bl9 = b9 & 0x1fff; + var bh9 = b9 >>> 13; + + out.negative = self.negative ^ num.negative; + out.length = 19; + /* k = 0 */ + lo = Math.imul(al0, bl0); + mid = Math.imul(al0, bh0); + mid = (mid + Math.imul(ah0, bl0)) | 0; + hi = Math.imul(ah0, bh0); + var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; + w0 &= 0x3ffffff; + /* k = 1 */ + lo = Math.imul(al1, bl0); + mid = Math.imul(al1, bh0); + mid = (mid + Math.imul(ah1, bl0)) | 0; + hi = Math.imul(ah1, bh0); + lo = (lo + Math.imul(al0, bl1)) | 0; + mid = (mid + Math.imul(al0, bh1)) | 0; + mid = (mid + Math.imul(ah0, bl1)) | 0; + hi = (hi + Math.imul(ah0, bh1)) | 0; + var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; + w1 &= 0x3ffffff; + /* k = 2 */ + lo = Math.imul(al2, bl0); + mid = Math.imul(al2, bh0); + mid = (mid + Math.imul(ah2, bl0)) | 0; + hi = Math.imul(ah2, bh0); + lo = (lo + Math.imul(al1, bl1)) | 0; + mid = (mid + Math.imul(al1, bh1)) | 0; + mid = (mid + Math.imul(ah1, bl1)) | 0; + hi = (hi + Math.imul(ah1, bh1)) | 0; + lo = (lo + Math.imul(al0, bl2)) | 0; + mid = (mid + Math.imul(al0, bh2)) | 0; + mid = (mid + Math.imul(ah0, bl2)) | 0; + hi = (hi + Math.imul(ah0, bh2)) | 0; + var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; + w2 &= 0x3ffffff; + /* k = 3 */ + lo = Math.imul(al3, bl0); + mid = Math.imul(al3, bh0); + mid = (mid + Math.imul(ah3, bl0)) | 0; + hi = Math.imul(ah3, bh0); + lo = (lo + Math.imul(al2, bl1)) | 0; + mid = (mid + Math.imul(al2, bh1)) | 0; + mid = (mid + Math.imul(ah2, bl1)) | 0; + hi = (hi + Math.imul(ah2, bh1)) | 0; + lo = (lo + Math.imul(al1, bl2)) | 0; + mid = (mid + Math.imul(al1, bh2)) | 0; + mid = (mid + Math.imul(ah1, bl2)) | 0; + hi = (hi + Math.imul(ah1, bh2)) | 0; + lo = (lo + Math.imul(al0, bl3)) | 0; + mid = (mid + Math.imul(al0, bh3)) | 0; + mid = (mid + Math.imul(ah0, bl3)) | 0; + hi = (hi + Math.imul(ah0, bh3)) | 0; + var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; + w3 &= 0x3ffffff; + /* k = 4 */ + lo = Math.imul(al4, bl0); + mid = Math.imul(al4, bh0); + mid = (mid + Math.imul(ah4, bl0)) | 0; + hi = Math.imul(ah4, bh0); + lo = (lo + Math.imul(al3, bl1)) | 0; + mid = (mid + Math.imul(al3, bh1)) | 0; + mid = (mid + Math.imul(ah3, bl1)) | 0; + hi = (hi + Math.imul(ah3, bh1)) | 0; + lo = (lo + Math.imul(al2, bl2)) | 0; + mid = (mid + Math.imul(al2, bh2)) | 0; + mid = (mid + Math.imul(ah2, bl2)) | 0; + hi = (hi + Math.imul(ah2, bh2)) | 0; + lo = (lo + Math.imul(al1, bl3)) | 0; + mid = (mid + Math.imul(al1, bh3)) | 0; + mid = (mid + Math.imul(ah1, bl3)) | 0; + hi = (hi + Math.imul(ah1, bh3)) | 0; + lo = (lo + Math.imul(al0, bl4)) | 0; + mid = (mid + Math.imul(al0, bh4)) | 0; + mid = (mid + Math.imul(ah0, bl4)) | 0; + hi = (hi + Math.imul(ah0, bh4)) | 0; + var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; + w4 &= 0x3ffffff; + /* k = 5 */ + lo = Math.imul(al5, bl0); + mid = Math.imul(al5, bh0); + mid = (mid + Math.imul(ah5, bl0)) | 0; + hi = Math.imul(ah5, bh0); + lo = (lo + Math.imul(al4, bl1)) | 0; + mid = (mid + Math.imul(al4, bh1)) | 0; + mid = (mid + Math.imul(ah4, bl1)) | 0; + hi = (hi + Math.imul(ah4, bh1)) | 0; + lo = (lo + Math.imul(al3, bl2)) | 0; + mid = (mid + Math.imul(al3, bh2)) | 0; + mid = (mid + Math.imul(ah3, bl2)) | 0; + hi = (hi + Math.imul(ah3, bh2)) | 0; + lo = (lo + Math.imul(al2, bl3)) | 0; + mid = (mid + Math.imul(al2, bh3)) | 0; + mid = (mid + Math.imul(ah2, bl3)) | 0; + hi = (hi + Math.imul(ah2, bh3)) | 0; + lo = (lo + Math.imul(al1, bl4)) | 0; + mid = (mid + Math.imul(al1, bh4)) | 0; + mid = (mid + Math.imul(ah1, bl4)) | 0; + hi = (hi + Math.imul(ah1, bh4)) | 0; + lo = (lo + Math.imul(al0, bl5)) | 0; + mid = (mid + Math.imul(al0, bh5)) | 0; + mid = (mid + Math.imul(ah0, bl5)) | 0; + hi = (hi + Math.imul(ah0, bh5)) | 0; + var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; + w5 &= 0x3ffffff; + /* k = 6 */ + lo = Math.imul(al6, bl0); + mid = Math.imul(al6, bh0); + mid = (mid + Math.imul(ah6, bl0)) | 0; + hi = Math.imul(ah6, bh0); + lo = (lo + Math.imul(al5, bl1)) | 0; + mid = (mid + Math.imul(al5, bh1)) | 0; + mid = (mid + Math.imul(ah5, bl1)) | 0; + hi = (hi + Math.imul(ah5, bh1)) | 0; + lo = (lo + Math.imul(al4, bl2)) | 0; + mid = (mid + Math.imul(al4, bh2)) | 0; + mid = (mid + Math.imul(ah4, bl2)) | 0; + hi = (hi + Math.imul(ah4, bh2)) | 0; + lo = (lo + Math.imul(al3, bl3)) | 0; + mid = (mid + Math.imul(al3, bh3)) | 0; + mid = (mid + Math.imul(ah3, bl3)) | 0; + hi = (hi + Math.imul(ah3, bh3)) | 0; + lo = (lo + Math.imul(al2, bl4)) | 0; + mid = (mid + Math.imul(al2, bh4)) | 0; + mid = (mid + Math.imul(ah2, bl4)) | 0; + hi = (hi + Math.imul(ah2, bh4)) | 0; + lo = (lo + Math.imul(al1, bl5)) | 0; + mid = (mid + Math.imul(al1, bh5)) | 0; + mid = (mid + Math.imul(ah1, bl5)) | 0; + hi = (hi + Math.imul(ah1, bh5)) | 0; + lo = (lo + Math.imul(al0, bl6)) | 0; + mid = (mid + Math.imul(al0, bh6)) | 0; + mid = (mid + Math.imul(ah0, bl6)) | 0; + hi = (hi + Math.imul(ah0, bh6)) | 0; + var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; + w6 &= 0x3ffffff; + /* k = 7 */ + lo = Math.imul(al7, bl0); + mid = Math.imul(al7, bh0); + mid = (mid + Math.imul(ah7, bl0)) | 0; + hi = Math.imul(ah7, bh0); + lo = (lo + Math.imul(al6, bl1)) | 0; + mid = (mid + Math.imul(al6, bh1)) | 0; + mid = (mid + Math.imul(ah6, bl1)) | 0; + hi = (hi + Math.imul(ah6, bh1)) | 0; + lo = (lo + Math.imul(al5, bl2)) | 0; + mid = (mid + Math.imul(al5, bh2)) | 0; + mid = (mid + Math.imul(ah5, bl2)) | 0; + hi = (hi + Math.imul(ah5, bh2)) | 0; + lo = (lo + Math.imul(al4, bl3)) | 0; + mid = (mid + Math.imul(al4, bh3)) | 0; + mid = (mid + Math.imul(ah4, bl3)) | 0; + hi = (hi + Math.imul(ah4, bh3)) | 0; + lo = (lo + Math.imul(al3, bl4)) | 0; + mid = (mid + Math.imul(al3, bh4)) | 0; + mid = (mid + Math.imul(ah3, bl4)) | 0; + hi = (hi + Math.imul(ah3, bh4)) | 0; + lo = (lo + Math.imul(al2, bl5)) | 0; + mid = (mid + Math.imul(al2, bh5)) | 0; + mid = (mid + Math.imul(ah2, bl5)) | 0; + hi = (hi + Math.imul(ah2, bh5)) | 0; + lo = (lo + Math.imul(al1, bl6)) | 0; + mid = (mid + Math.imul(al1, bh6)) | 0; + mid = (mid + Math.imul(ah1, bl6)) | 0; + hi = (hi + Math.imul(ah1, bh6)) | 0; + lo = (lo + Math.imul(al0, bl7)) | 0; + mid = (mid + Math.imul(al0, bh7)) | 0; + mid = (mid + Math.imul(ah0, bl7)) | 0; + hi = (hi + Math.imul(ah0, bh7)) | 0; + var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; + w7 &= 0x3ffffff; + /* k = 8 */ + lo = Math.imul(al8, bl0); + mid = Math.imul(al8, bh0); + mid = (mid + Math.imul(ah8, bl0)) | 0; + hi = Math.imul(ah8, bh0); + lo = (lo + Math.imul(al7, bl1)) | 0; + mid = (mid + Math.imul(al7, bh1)) | 0; + mid = (mid + Math.imul(ah7, bl1)) | 0; + hi = (hi + Math.imul(ah7, bh1)) | 0; + lo = (lo + Math.imul(al6, bl2)) | 0; + mid = (mid + Math.imul(al6, bh2)) | 0; + mid = (mid + Math.imul(ah6, bl2)) | 0; + hi = (hi + Math.imul(ah6, bh2)) | 0; + lo = (lo + Math.imul(al5, bl3)) | 0; + mid = (mid + Math.imul(al5, bh3)) | 0; + mid = (mid + Math.imul(ah5, bl3)) | 0; + hi = (hi + Math.imul(ah5, bh3)) | 0; + lo = (lo + Math.imul(al4, bl4)) | 0; + mid = (mid + Math.imul(al4, bh4)) | 0; + mid = (mid + Math.imul(ah4, bl4)) | 0; + hi = (hi + Math.imul(ah4, bh4)) | 0; + lo = (lo + Math.imul(al3, bl5)) | 0; + mid = (mid + Math.imul(al3, bh5)) | 0; + mid = (mid + Math.imul(ah3, bl5)) | 0; + hi = (hi + Math.imul(ah3, bh5)) | 0; + lo = (lo + Math.imul(al2, bl6)) | 0; + mid = (mid + Math.imul(al2, bh6)) | 0; + mid = (mid + Math.imul(ah2, bl6)) | 0; + hi = (hi + Math.imul(ah2, bh6)) | 0; + lo = (lo + Math.imul(al1, bl7)) | 0; + mid = (mid + Math.imul(al1, bh7)) | 0; + mid = (mid + Math.imul(ah1, bl7)) | 0; + hi = (hi + Math.imul(ah1, bh7)) | 0; + lo = (lo + Math.imul(al0, bl8)) | 0; + mid = (mid + Math.imul(al0, bh8)) | 0; + mid = (mid + Math.imul(ah0, bl8)) | 0; + hi = (hi + Math.imul(ah0, bh8)) | 0; + var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; + w8 &= 0x3ffffff; + /* k = 9 */ + lo = Math.imul(al9, bl0); + mid = Math.imul(al9, bh0); + mid = (mid + Math.imul(ah9, bl0)) | 0; + hi = Math.imul(ah9, bh0); + lo = (lo + Math.imul(al8, bl1)) | 0; + mid = (mid + Math.imul(al8, bh1)) | 0; + mid = (mid + Math.imul(ah8, bl1)) | 0; + hi = (hi + Math.imul(ah8, bh1)) | 0; + lo = (lo + Math.imul(al7, bl2)) | 0; + mid = (mid + Math.imul(al7, bh2)) | 0; + mid = (mid + Math.imul(ah7, bl2)) | 0; + hi = (hi + Math.imul(ah7, bh2)) | 0; + lo = (lo + Math.imul(al6, bl3)) | 0; + mid = (mid + Math.imul(al6, bh3)) | 0; + mid = (mid + Math.imul(ah6, bl3)) | 0; + hi = (hi + Math.imul(ah6, bh3)) | 0; + lo = (lo + Math.imul(al5, bl4)) | 0; + mid = (mid + Math.imul(al5, bh4)) | 0; + mid = (mid + Math.imul(ah5, bl4)) | 0; + hi = (hi + Math.imul(ah5, bh4)) | 0; + lo = (lo + Math.imul(al4, bl5)) | 0; + mid = (mid + Math.imul(al4, bh5)) | 0; + mid = (mid + Math.imul(ah4, bl5)) | 0; + hi = (hi + Math.imul(ah4, bh5)) | 0; + lo = (lo + Math.imul(al3, bl6)) | 0; + mid = (mid + Math.imul(al3, bh6)) | 0; + mid = (mid + Math.imul(ah3, bl6)) | 0; + hi = (hi + Math.imul(ah3, bh6)) | 0; + lo = (lo + Math.imul(al2, bl7)) | 0; + mid = (mid + Math.imul(al2, bh7)) | 0; + mid = (mid + Math.imul(ah2, bl7)) | 0; + hi = (hi + Math.imul(ah2, bh7)) | 0; + lo = (lo + Math.imul(al1, bl8)) | 0; + mid = (mid + Math.imul(al1, bh8)) | 0; + mid = (mid + Math.imul(ah1, bl8)) | 0; + hi = (hi + Math.imul(ah1, bh8)) | 0; + lo = (lo + Math.imul(al0, bl9)) | 0; + mid = (mid + Math.imul(al0, bh9)) | 0; + mid = (mid + Math.imul(ah0, bl9)) | 0; + hi = (hi + Math.imul(ah0, bh9)) | 0; + var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; + w9 &= 0x3ffffff; + /* k = 10 */ + lo = Math.imul(al9, bl1); + mid = Math.imul(al9, bh1); + mid = (mid + Math.imul(ah9, bl1)) | 0; + hi = Math.imul(ah9, bh1); + lo = (lo + Math.imul(al8, bl2)) | 0; + mid = (mid + Math.imul(al8, bh2)) | 0; + mid = (mid + Math.imul(ah8, bl2)) | 0; + hi = (hi + Math.imul(ah8, bh2)) | 0; + lo = (lo + Math.imul(al7, bl3)) | 0; + mid = (mid + Math.imul(al7, bh3)) | 0; + mid = (mid + Math.imul(ah7, bl3)) | 0; + hi = (hi + Math.imul(ah7, bh3)) | 0; + lo = (lo + Math.imul(al6, bl4)) | 0; + mid = (mid + Math.imul(al6, bh4)) | 0; + mid = (mid + Math.imul(ah6, bl4)) | 0; + hi = (hi + Math.imul(ah6, bh4)) | 0; + lo = (lo + Math.imul(al5, bl5)) | 0; + mid = (mid + Math.imul(al5, bh5)) | 0; + mid = (mid + Math.imul(ah5, bl5)) | 0; + hi = (hi + Math.imul(ah5, bh5)) | 0; + lo = (lo + Math.imul(al4, bl6)) | 0; + mid = (mid + Math.imul(al4, bh6)) | 0; + mid = (mid + Math.imul(ah4, bl6)) | 0; + hi = (hi + Math.imul(ah4, bh6)) | 0; + lo = (lo + Math.imul(al3, bl7)) | 0; + mid = (mid + Math.imul(al3, bh7)) | 0; + mid = (mid + Math.imul(ah3, bl7)) | 0; + hi = (hi + Math.imul(ah3, bh7)) | 0; + lo = (lo + Math.imul(al2, bl8)) | 0; + mid = (mid + Math.imul(al2, bh8)) | 0; + mid = (mid + Math.imul(ah2, bl8)) | 0; + hi = (hi + Math.imul(ah2, bh8)) | 0; + lo = (lo + Math.imul(al1, bl9)) | 0; + mid = (mid + Math.imul(al1, bh9)) | 0; + mid = (mid + Math.imul(ah1, bl9)) | 0; + hi = (hi + Math.imul(ah1, bh9)) | 0; + var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; + w10 &= 0x3ffffff; + /* k = 11 */ + lo = Math.imul(al9, bl2); + mid = Math.imul(al9, bh2); + mid = (mid + Math.imul(ah9, bl2)) | 0; + hi = Math.imul(ah9, bh2); + lo = (lo + Math.imul(al8, bl3)) | 0; + mid = (mid + Math.imul(al8, bh3)) | 0; + mid = (mid + Math.imul(ah8, bl3)) | 0; + hi = (hi + Math.imul(ah8, bh3)) | 0; + lo = (lo + Math.imul(al7, bl4)) | 0; + mid = (mid + Math.imul(al7, bh4)) | 0; + mid = (mid + Math.imul(ah7, bl4)) | 0; + hi = (hi + Math.imul(ah7, bh4)) | 0; + lo = (lo + Math.imul(al6, bl5)) | 0; + mid = (mid + Math.imul(al6, bh5)) | 0; + mid = (mid + Math.imul(ah6, bl5)) | 0; + hi = (hi + Math.imul(ah6, bh5)) | 0; + lo = (lo + Math.imul(al5, bl6)) | 0; + mid = (mid + Math.imul(al5, bh6)) | 0; + mid = (mid + Math.imul(ah5, bl6)) | 0; + hi = (hi + Math.imul(ah5, bh6)) | 0; + lo = (lo + Math.imul(al4, bl7)) | 0; + mid = (mid + Math.imul(al4, bh7)) | 0; + mid = (mid + Math.imul(ah4, bl7)) | 0; + hi = (hi + Math.imul(ah4, bh7)) | 0; + lo = (lo + Math.imul(al3, bl8)) | 0; + mid = (mid + Math.imul(al3, bh8)) | 0; + mid = (mid + Math.imul(ah3, bl8)) | 0; + hi = (hi + Math.imul(ah3, bh8)) | 0; + lo = (lo + Math.imul(al2, bl9)) | 0; + mid = (mid + Math.imul(al2, bh9)) | 0; + mid = (mid + Math.imul(ah2, bl9)) | 0; + hi = (hi + Math.imul(ah2, bh9)) | 0; + var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; + w11 &= 0x3ffffff; + /* k = 12 */ + lo = Math.imul(al9, bl3); + mid = Math.imul(al9, bh3); + mid = (mid + Math.imul(ah9, bl3)) | 0; + hi = Math.imul(ah9, bh3); + lo = (lo + Math.imul(al8, bl4)) | 0; + mid = (mid + Math.imul(al8, bh4)) | 0; + mid = (mid + Math.imul(ah8, bl4)) | 0; + hi = (hi + Math.imul(ah8, bh4)) | 0; + lo = (lo + Math.imul(al7, bl5)) | 0; + mid = (mid + Math.imul(al7, bh5)) | 0; + mid = (mid + Math.imul(ah7, bl5)) | 0; + hi = (hi + Math.imul(ah7, bh5)) | 0; + lo = (lo + Math.imul(al6, bl6)) | 0; + mid = (mid + Math.imul(al6, bh6)) | 0; + mid = (mid + Math.imul(ah6, bl6)) | 0; + hi = (hi + Math.imul(ah6, bh6)) | 0; + lo = (lo + Math.imul(al5, bl7)) | 0; + mid = (mid + Math.imul(al5, bh7)) | 0; + mid = (mid + Math.imul(ah5, bl7)) | 0; + hi = (hi + Math.imul(ah5, bh7)) | 0; + lo = (lo + Math.imul(al4, bl8)) | 0; + mid = (mid + Math.imul(al4, bh8)) | 0; + mid = (mid + Math.imul(ah4, bl8)) | 0; + hi = (hi + Math.imul(ah4, bh8)) | 0; + lo = (lo + Math.imul(al3, bl9)) | 0; + mid = (mid + Math.imul(al3, bh9)) | 0; + mid = (mid + Math.imul(ah3, bl9)) | 0; + hi = (hi + Math.imul(ah3, bh9)) | 0; + var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; + w12 &= 0x3ffffff; + /* k = 13 */ + lo = Math.imul(al9, bl4); + mid = Math.imul(al9, bh4); + mid = (mid + Math.imul(ah9, bl4)) | 0; + hi = Math.imul(ah9, bh4); + lo = (lo + Math.imul(al8, bl5)) | 0; + mid = (mid + Math.imul(al8, bh5)) | 0; + mid = (mid + Math.imul(ah8, bl5)) | 0; + hi = (hi + Math.imul(ah8, bh5)) | 0; + lo = (lo + Math.imul(al7, bl6)) | 0; + mid = (mid + Math.imul(al7, bh6)) | 0; + mid = (mid + Math.imul(ah7, bl6)) | 0; + hi = (hi + Math.imul(ah7, bh6)) | 0; + lo = (lo + Math.imul(al6, bl7)) | 0; + mid = (mid + Math.imul(al6, bh7)) | 0; + mid = (mid + Math.imul(ah6, bl7)) | 0; + hi = (hi + Math.imul(ah6, bh7)) | 0; + lo = (lo + Math.imul(al5, bl8)) | 0; + mid = (mid + Math.imul(al5, bh8)) | 0; + mid = (mid + Math.imul(ah5, bl8)) | 0; + hi = (hi + Math.imul(ah5, bh8)) | 0; + lo = (lo + Math.imul(al4, bl9)) | 0; + mid = (mid + Math.imul(al4, bh9)) | 0; + mid = (mid + Math.imul(ah4, bl9)) | 0; + hi = (hi + Math.imul(ah4, bh9)) | 0; + var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; + w13 &= 0x3ffffff; + /* k = 14 */ + lo = Math.imul(al9, bl5); + mid = Math.imul(al9, bh5); + mid = (mid + Math.imul(ah9, bl5)) | 0; + hi = Math.imul(ah9, bh5); + lo = (lo + Math.imul(al8, bl6)) | 0; + mid = (mid + Math.imul(al8, bh6)) | 0; + mid = (mid + Math.imul(ah8, bl6)) | 0; + hi = (hi + Math.imul(ah8, bh6)) | 0; + lo = (lo + Math.imul(al7, bl7)) | 0; + mid = (mid + Math.imul(al7, bh7)) | 0; + mid = (mid + Math.imul(ah7, bl7)) | 0; + hi = (hi + Math.imul(ah7, bh7)) | 0; + lo = (lo + Math.imul(al6, bl8)) | 0; + mid = (mid + Math.imul(al6, bh8)) | 0; + mid = (mid + Math.imul(ah6, bl8)) | 0; + hi = (hi + Math.imul(ah6, bh8)) | 0; + lo = (lo + Math.imul(al5, bl9)) | 0; + mid = (mid + Math.imul(al5, bh9)) | 0; + mid = (mid + Math.imul(ah5, bl9)) | 0; + hi = (hi + Math.imul(ah5, bh9)) | 0; + var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; + w14 &= 0x3ffffff; + /* k = 15 */ + lo = Math.imul(al9, bl6); + mid = Math.imul(al9, bh6); + mid = (mid + Math.imul(ah9, bl6)) | 0; + hi = Math.imul(ah9, bh6); + lo = (lo + Math.imul(al8, bl7)) | 0; + mid = (mid + Math.imul(al8, bh7)) | 0; + mid = (mid + Math.imul(ah8, bl7)) | 0; + hi = (hi + Math.imul(ah8, bh7)) | 0; + lo = (lo + Math.imul(al7, bl8)) | 0; + mid = (mid + Math.imul(al7, bh8)) | 0; + mid = (mid + Math.imul(ah7, bl8)) | 0; + hi = (hi + Math.imul(ah7, bh8)) | 0; + lo = (lo + Math.imul(al6, bl9)) | 0; + mid = (mid + Math.imul(al6, bh9)) | 0; + mid = (mid + Math.imul(ah6, bl9)) | 0; + hi = (hi + Math.imul(ah6, bh9)) | 0; + var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; + w15 &= 0x3ffffff; + /* k = 16 */ + lo = Math.imul(al9, bl7); + mid = Math.imul(al9, bh7); + mid = (mid + Math.imul(ah9, bl7)) | 0; + hi = Math.imul(ah9, bh7); + lo = (lo + Math.imul(al8, bl8)) | 0; + mid = (mid + Math.imul(al8, bh8)) | 0; + mid = (mid + Math.imul(ah8, bl8)) | 0; + hi = (hi + Math.imul(ah8, bh8)) | 0; + lo = (lo + Math.imul(al7, bl9)) | 0; + mid = (mid + Math.imul(al7, bh9)) | 0; + mid = (mid + Math.imul(ah7, bl9)) | 0; + hi = (hi + Math.imul(ah7, bh9)) | 0; + var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; + w16 &= 0x3ffffff; + /* k = 17 */ + lo = Math.imul(al9, bl8); + mid = Math.imul(al9, bh8); + mid = (mid + Math.imul(ah9, bl8)) | 0; + hi = Math.imul(ah9, bh8); + lo = (lo + Math.imul(al8, bl9)) | 0; + mid = (mid + Math.imul(al8, bh9)) | 0; + mid = (mid + Math.imul(ah8, bl9)) | 0; + hi = (hi + Math.imul(ah8, bh9)) | 0; + var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; + w17 &= 0x3ffffff; + /* k = 18 */ + lo = Math.imul(al9, bl9); + mid = Math.imul(al9, bh9); + mid = (mid + Math.imul(ah9, bl9)) | 0; + hi = Math.imul(ah9, bh9); + var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; + c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; + w18 &= 0x3ffffff; + o[0] = w0; + o[1] = w1; + o[2] = w2; + o[3] = w3; + o[4] = w4; + o[5] = w5; + o[6] = w6; + o[7] = w7; + o[8] = w8; + o[9] = w9; + o[10] = w10; + o[11] = w11; + o[12] = w12; + o[13] = w13; + o[14] = w14; + o[15] = w15; + o[16] = w16; + o[17] = w17; + o[18] = w18; + if (c !== 0) { + o[19] = c; + out.length++; + } + return out; + }; + + // Polyfill comb + if (!Math.imul) { + comb10MulTo = smallMulTo; + } + + function bigMulTo (self, num, out) { + out.negative = num.negative ^ self.negative; + out.length = self.length + num.length; + + var carry = 0; + var hncarry = 0; + for (var k = 0; k < out.length - 1; k++) { + // Sum all words with the same `i + j = k` and accumulate `ncarry`, + // note that ncarry could be >= 0x3ffffff + var ncarry = hncarry; + hncarry = 0; + var rword = carry & 0x3ffffff; + var maxJ = Math.min(k, num.length - 1); + for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { + var i = k - j; + var a = self.words[i] | 0; + var b = num.words[j] | 0; + var r = a * b; + + var lo = r & 0x3ffffff; + ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; + lo = (lo + rword) | 0; + rword = lo & 0x3ffffff; + ncarry = (ncarry + (lo >>> 26)) | 0; + + hncarry += ncarry >>> 26; + ncarry &= 0x3ffffff; + } + out.words[k] = rword; + carry = ncarry; + ncarry = hncarry; + } + if (carry !== 0) { + out.words[k] = carry; + } else { + out.length--; + } + + return out.strip(); + } + + function jumboMulTo (self, num, out) { + var fftm = new FFTM(); + return fftm.mulp(self, num, out); + } + + BN.prototype.mulTo = function mulTo (num, out) { + var res; + var len = this.length + num.length; + if (this.length === 10 && num.length === 10) { + res = comb10MulTo(this, num, out); + } else if (len < 63) { + res = smallMulTo(this, num, out); + } else if (len < 1024) { + res = bigMulTo(this, num, out); + } else { + res = jumboMulTo(this, num, out); + } + + return res; + }; + + // Cooley-Tukey algorithm for FFT + // slightly revisited to rely on looping instead of recursion + + function FFTM (x, y) { + this.x = x; + this.y = y; + } + + FFTM.prototype.makeRBT = function makeRBT (N) { + var t = new Array(N); + var l = BN.prototype._countBits(N) - 1; + for (var i = 0; i < N; i++) { + t[i] = this.revBin(i, l, N); + } + + return t; + }; + + // Returns binary-reversed representation of `x` + FFTM.prototype.revBin = function revBin (x, l, N) { + if (x === 0 || x === N - 1) return x; + + var rb = 0; + for (var i = 0; i < l; i++) { + rb |= (x & 1) << (l - i - 1); + x >>= 1; + } + + return rb; + }; + + // Performs "tweedling" phase, therefore 'emulating' + // behaviour of the recursive algorithm + FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { + for (var i = 0; i < N; i++) { + rtws[i] = rws[rbt[i]]; + itws[i] = iws[rbt[i]]; + } + }; + + FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { + this.permute(rbt, rws, iws, rtws, itws, N); + + for (var s = 1; s < N; s <<= 1) { + var l = s << 1; + + var rtwdf = Math.cos(2 * Math.PI / l); + var itwdf = Math.sin(2 * Math.PI / l); + + for (var p = 0; p < N; p += l) { + var rtwdf_ = rtwdf; + var itwdf_ = itwdf; + + for (var j = 0; j < s; j++) { + var re = rtws[p + j]; + var ie = itws[p + j]; + + var ro = rtws[p + j + s]; + var io = itws[p + j + s]; + + var rx = rtwdf_ * ro - itwdf_ * io; + + io = rtwdf_ * io + itwdf_ * ro; + ro = rx; + + rtws[p + j] = re + ro; + itws[p + j] = ie + io; + + rtws[p + j + s] = re - ro; + itws[p + j + s] = ie - io; + + /* jshint maxdepth : false */ + if (j !== l) { + rx = rtwdf * rtwdf_ - itwdf * itwdf_; + + itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; + rtwdf_ = rx; + } + } + } + } + }; + + FFTM.prototype.guessLen13b = function guessLen13b (n, m) { + var N = Math.max(m, n) | 1; + var odd = N & 1; + var i = 0; + for (N = N / 2 | 0; N; N = N >>> 1) { + i++; + } + + return 1 << i + 1 + odd; + }; + + FFTM.prototype.conjugate = function conjugate (rws, iws, N) { + if (N <= 1) return; + + for (var i = 0; i < N / 2; i++) { + var t = rws[i]; + + rws[i] = rws[N - i - 1]; + rws[N - i - 1] = t; + + t = iws[i]; + + iws[i] = -iws[N - i - 1]; + iws[N - i - 1] = -t; + } + }; + + FFTM.prototype.normalize13b = function normalize13b (ws, N) { + var carry = 0; + for (var i = 0; i < N / 2; i++) { + var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + + Math.round(ws[2 * i] / N) + + carry; + + ws[i] = w & 0x3ffffff; + + if (w < 0x4000000) { + carry = 0; + } else { + carry = w / 0x4000000 | 0; + } + } + + return ws; + }; + + FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { + var carry = 0; + for (var i = 0; i < len; i++) { + carry = carry + (ws[i] | 0); + + rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; + rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; + } + + // Pad with zeroes + for (i = 2 * len; i < N; ++i) { + rws[i] = 0; + } + + assert(carry === 0); + assert((carry & ~0x1fff) === 0); + }; + + FFTM.prototype.stub = function stub (N) { + var ph = new Array(N); + for (var i = 0; i < N; i++) { + ph[i] = 0; + } + + return ph; + }; + + FFTM.prototype.mulp = function mulp (x, y, out) { + var N = 2 * this.guessLen13b(x.length, y.length); + + var rbt = this.makeRBT(N); + + var _ = this.stub(N); + + var rws = new Array(N); + var rwst = new Array(N); + var iwst = new Array(N); + + var nrws = new Array(N); + var nrwst = new Array(N); + var niwst = new Array(N); + + var rmws = out.words; + rmws.length = N; + + this.convert13b(x.words, x.length, rws, N); + this.convert13b(y.words, y.length, nrws, N); + + this.transform(rws, _, rwst, iwst, N, rbt); + this.transform(nrws, _, nrwst, niwst, N, rbt); + + for (var i = 0; i < N; i++) { + var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; + iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; + rwst[i] = rx; + } + + this.conjugate(rwst, iwst, N); + this.transform(rwst, iwst, rmws, _, N, rbt); + this.conjugate(rmws, _, N); + this.normalize13b(rmws, N); + + out.negative = x.negative ^ y.negative; + out.length = x.length + y.length; + return out.strip(); + }; + + // Multiply `this` by `num` + BN.prototype.mul = function mul (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return this.mulTo(num, out); + }; + + // Multiply employing FFT + BN.prototype.mulf = function mulf (num) { + var out = new BN(null); + out.words = new Array(this.length + num.length); + return jumboMulTo(this, num, out); + }; + + // In-place Multiplication + BN.prototype.imul = function imul (num) { + return this.clone().mulTo(num, this); + }; + + BN.prototype.imuln = function imuln (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + + // Carry + var carry = 0; + for (var i = 0; i < this.length; i++) { + var w = (this.words[i] | 0) * num; + var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); + carry >>= 26; + carry += (w / 0x4000000) | 0; + // NOTE: lo is 27bit maximum + carry += lo >>> 26; + this.words[i] = lo & 0x3ffffff; + } + + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + + return this; + }; + + BN.prototype.muln = function muln (num) { + return this.clone().imuln(num); + }; + + // `this` * `this` + BN.prototype.sqr = function sqr () { + return this.mul(this); + }; + + // `this` * `this` in-place + BN.prototype.isqr = function isqr () { + return this.imul(this.clone()); + }; + + // Math.pow(`this`, `num`) + BN.prototype.pow = function pow (num) { + var w = toBitArray(num); + if (w.length === 0) return new BN(1); + + // Skip leading zeroes + var res = this; + for (var i = 0; i < w.length; i++, res = res.sqr()) { + if (w[i] !== 0) break; + } + + if (++i < w.length) { + for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { + if (w[i] === 0) continue; + + res = res.mul(q); + } + } + + return res; + }; + + // Shift-left in-place + BN.prototype.iushln = function iushln (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); + var i; + + if (r !== 0) { + var carry = 0; + + for (i = 0; i < this.length; i++) { + var newCarry = this.words[i] & carryMask; + var c = ((this.words[i] | 0) - newCarry) << r; + this.words[i] = c | carry; + carry = newCarry >>> (26 - r); + } + + if (carry) { + this.words[i] = carry; + this.length++; + } + } + + if (s !== 0) { + for (i = this.length - 1; i >= 0; i--) { + this.words[i + s] = this.words[i]; + } + + for (i = 0; i < s; i++) { + this.words[i] = 0; + } + + this.length += s; + } + + return this.strip(); + }; + + BN.prototype.ishln = function ishln (bits) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushln(bits); + }; + + // Shift-right in-place + // NOTE: `hint` is a lowest bit before trailing zeroes + // NOTE: if `extended` is present - it will be filled with destroyed bits + BN.prototype.iushrn = function iushrn (bits, hint, extended) { + assert(typeof bits === 'number' && bits >= 0); + var h; + if (hint) { + h = (hint - (hint % 26)) / 26; + } else { + h = 0; + } + + var r = bits % 26; + var s = Math.min((bits - r) / 26, this.length); + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + var maskedWords = extended; + + h -= s; + h = Math.max(0, h); + + // Extended mode, copy masked part + if (maskedWords) { + for (var i = 0; i < s; i++) { + maskedWords.words[i] = this.words[i]; + } + maskedWords.length = s; + } + + if (s === 0) { + // No-op, we should not move anything at all + } else if (this.length > s) { + this.length -= s; + for (i = 0; i < this.length; i++) { + this.words[i] = this.words[i + s]; + } + } else { + this.words[0] = 0; + this.length = 1; + } + + var carry = 0; + for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { + var word = this.words[i] | 0; + this.words[i] = (carry << (26 - r)) | (word >>> r); + carry = word & mask; + } + + // Push carried bits as a mask + if (maskedWords && carry !== 0) { + maskedWords.words[maskedWords.length++] = carry; + } + + if (this.length === 0) { + this.words[0] = 0; + this.length = 1; + } + + return this.strip(); + }; + + BN.prototype.ishrn = function ishrn (bits, hint, extended) { + // TODO(indutny): implement me + assert(this.negative === 0); + return this.iushrn(bits, hint, extended); + }; + + // Shift-left + BN.prototype.shln = function shln (bits) { + return this.clone().ishln(bits); + }; + + BN.prototype.ushln = function ushln (bits) { + return this.clone().iushln(bits); + }; + + // Shift-right + BN.prototype.shrn = function shrn (bits) { + return this.clone().ishrn(bits); + }; + + BN.prototype.ushrn = function ushrn (bits) { + return this.clone().iushrn(bits); + }; + + // Test if n bit is set + BN.prototype.testn = function testn (bit) { + assert(typeof bit === 'number' && bit >= 0); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) return false; + + // Check bit and return + var w = this.words[s]; + + return !!(w & q); + }; + + // Return only lowers bits of number (in-place) + BN.prototype.imaskn = function imaskn (bits) { + assert(typeof bits === 'number' && bits >= 0); + var r = bits % 26; + var s = (bits - r) / 26; + + assert(this.negative === 0, 'imaskn works only with positive numbers'); + + if (this.length <= s) { + return this; + } + + if (r !== 0) { + s++; + } + this.length = Math.min(s, this.length); + + if (r !== 0) { + var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); + this.words[this.length - 1] &= mask; + } + + return this.strip(); + }; + + // Return only lowers bits of number + BN.prototype.maskn = function maskn (bits) { + return this.clone().imaskn(bits); + }; + + // Add plain number `num` to `this` + BN.prototype.iaddn = function iaddn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.isubn(-num); + + // Possible sign change + if (this.negative !== 0) { + if (this.length === 1 && (this.words[0] | 0) < num) { + this.words[0] = num - (this.words[0] | 0); + this.negative = 0; + return this; + } + + this.negative = 0; + this.isubn(num); + this.negative = 1; + return this; + } + + // Add without checks + return this._iaddn(num); + }; + + BN.prototype._iaddn = function _iaddn (num) { + this.words[0] += num; + + // Carry + for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { + this.words[i] -= 0x4000000; + if (i === this.length - 1) { + this.words[i + 1] = 1; + } else { + this.words[i + 1]++; + } + } + this.length = Math.max(this.length, i + 1); + + return this; + }; + + // Subtract plain number `num` from `this` + BN.prototype.isubn = function isubn (num) { + assert(typeof num === 'number'); + assert(num < 0x4000000); + if (num < 0) return this.iaddn(-num); + + if (this.negative !== 0) { + this.negative = 0; + this.iaddn(num); + this.negative = 1; + return this; + } + + this.words[0] -= num; + + if (this.length === 1 && this.words[0] < 0) { + this.words[0] = -this.words[0]; + this.negative = 1; + } else { + // Carry + for (var i = 0; i < this.length && this.words[i] < 0; i++) { + this.words[i] += 0x4000000; + this.words[i + 1] -= 1; + } + } + + return this.strip(); + }; + + BN.prototype.addn = function addn (num) { + return this.clone().iaddn(num); + }; + + BN.prototype.subn = function subn (num) { + return this.clone().isubn(num); + }; + + BN.prototype.iabs = function iabs () { + this.negative = 0; + + return this; + }; + + BN.prototype.abs = function abs () { + return this.clone().iabs(); + }; + + BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { + var len = num.length + shift; + var i; + + this._expand(len); + + var w; + var carry = 0; + for (i = 0; i < num.length; i++) { + w = (this.words[i + shift] | 0) + carry; + var right = (num.words[i] | 0) * mul; + w -= right & 0x3ffffff; + carry = (w >> 26) - ((right / 0x4000000) | 0); + this.words[i + shift] = w & 0x3ffffff; + } + for (; i < this.length - shift; i++) { + w = (this.words[i + shift] | 0) + carry; + carry = w >> 26; + this.words[i + shift] = w & 0x3ffffff; + } + + if (carry === 0) return this.strip(); + + // Subtraction overflow + assert(carry === -1); + carry = 0; + for (i = 0; i < this.length; i++) { + w = -(this.words[i] | 0) + carry; + carry = w >> 26; + this.words[i] = w & 0x3ffffff; + } + this.negative = 1; + + return this.strip(); + }; + + BN.prototype._wordDiv = function _wordDiv (num, mode) { + var shift = this.length - num.length; + + var a = this.clone(); + var b = num; + + // Normalize + var bhi = b.words[b.length - 1] | 0; + var bhiBits = this._countBits(bhi); + shift = 26 - bhiBits; + if (shift !== 0) { + b = b.ushln(shift); + a.iushln(shift); + bhi = b.words[b.length - 1] | 0; + } + + // Initialize quotient + var m = a.length - b.length; + var q; + + if (mode !== 'mod') { + q = new BN(null); + q.length = m + 1; + q.words = new Array(q.length); + for (var i = 0; i < q.length; i++) { + q.words[i] = 0; + } + } + + var diff = a.clone()._ishlnsubmul(b, 1, m); + if (diff.negative === 0) { + a = diff; + if (q) { + q.words[m] = 1; + } + } + + for (var j = m - 1; j >= 0; j--) { + var qj = (a.words[b.length + j] | 0) * 0x4000000 + + (a.words[b.length + j - 1] | 0); + + // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max + // (0x7ffffff) + qj = Math.min((qj / bhi) | 0, 0x3ffffff); + + a._ishlnsubmul(b, qj, j); + while (a.negative !== 0) { + qj--; + a.negative = 0; + a._ishlnsubmul(b, 1, j); + if (!a.isZero()) { + a.negative ^= 1; + } + } + if (q) { + q.words[j] = qj; + } + } + if (q) { + q.strip(); + } + a.strip(); + + // Denormalize + if (mode !== 'div' && shift !== 0) { + a.iushrn(shift); + } + + return { + div: q || null, + mod: a + }; + }; + + // NOTE: 1) `mode` can be set to `mod` to request mod only, + // to `div` to request div only, or be absent to + // request both div & mod + // 2) `positive` is true if unsigned mod is requested + BN.prototype.divmod = function divmod (num, mode, positive) { + assert(!num.isZero()); + + if (this.isZero()) { + return { + div: new BN(0), + mod: new BN(0) + }; + } + + var div, mod, res; + if (this.negative !== 0 && num.negative === 0) { + res = this.neg().divmod(num, mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.iadd(num); + } + } + + return { + div: div, + mod: mod + }; + } + + if (this.negative === 0 && num.negative !== 0) { + res = this.divmod(num.neg(), mode); + + if (mode !== 'mod') { + div = res.div.neg(); + } + + return { + div: div, + mod: res.mod + }; + } + + if ((this.negative & num.negative) !== 0) { + res = this.neg().divmod(num.neg(), mode); + + if (mode !== 'div') { + mod = res.mod.neg(); + if (positive && mod.negative !== 0) { + mod.isub(num); + } + } + + return { + div: res.div, + mod: mod + }; + } + + // Both numbers are positive at this point + + // Strip both numbers to approximate shift value + if (num.length > this.length || this.cmp(num) < 0) { + return { + div: new BN(0), + mod: this + }; + } + + // Very short reduction + if (num.length === 1) { + if (mode === 'div') { + return { + div: this.divn(num.words[0]), + mod: null + }; + } + + if (mode === 'mod') { + return { + div: null, + mod: new BN(this.modn(num.words[0])) + }; + } + + return { + div: this.divn(num.words[0]), + mod: new BN(this.modn(num.words[0])) + }; + } + + return this._wordDiv(num, mode); + }; + + // Find `this` / `num` + BN.prototype.div = function div (num) { + return this.divmod(num, 'div', false).div; + }; + + // Find `this` % `num` + BN.prototype.mod = function mod (num) { + return this.divmod(num, 'mod', false).mod; + }; + + BN.prototype.umod = function umod (num) { + return this.divmod(num, 'mod', true).mod; + }; + + // Find Round(`this` / `num`) + BN.prototype.divRound = function divRound (num) { + var dm = this.divmod(num); + + // Fast case - exact division + if (dm.mod.isZero()) return dm.div; + + var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; + + var half = num.ushrn(1); + var r2 = num.andln(1); + var cmp = mod.cmp(half); + + // Round down + if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; + + // Round up + return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); + }; + + BN.prototype.modn = function modn (num) { + assert(num <= 0x3ffffff); + var p = (1 << 26) % num; + + var acc = 0; + for (var i = this.length - 1; i >= 0; i--) { + acc = (p * acc + (this.words[i] | 0)) % num; + } + + return acc; + }; + + // In-place division by number + BN.prototype.idivn = function idivn (num) { + assert(num <= 0x3ffffff); + + var carry = 0; + for (var i = this.length - 1; i >= 0; i--) { + var w = (this.words[i] | 0) + carry * 0x4000000; + this.words[i] = (w / num) | 0; + carry = w % num; + } + + return this.strip(); + }; + + BN.prototype.divn = function divn (num) { + return this.clone().idivn(num); + }; + + BN.prototype.egcd = function egcd (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var x = this; + var y = p.clone(); + + if (x.negative !== 0) { + x = x.umod(p); + } else { + x = x.clone(); + } + + // A * x + B * y = x + var A = new BN(1); + var B = new BN(0); + + // C * x + D * y = y + var C = new BN(0); + var D = new BN(1); + + var g = 0; + + while (x.isEven() && y.isEven()) { + x.iushrn(1); + y.iushrn(1); + ++g; + } + + var yp = y.clone(); + var xp = x.clone(); + + while (!x.isZero()) { + for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + x.iushrn(i); + while (i-- > 0) { + if (A.isOdd() || B.isOdd()) { + A.iadd(yp); + B.isub(xp); + } + + A.iushrn(1); + B.iushrn(1); + } + } + + for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + y.iushrn(j); + while (j-- > 0) { + if (C.isOdd() || D.isOdd()) { + C.iadd(yp); + D.isub(xp); + } + + C.iushrn(1); + D.iushrn(1); + } + } + + if (x.cmp(y) >= 0) { + x.isub(y); + A.isub(C); + B.isub(D); + } else { + y.isub(x); + C.isub(A); + D.isub(B); + } + } + + return { + a: C, + b: D, + gcd: y.iushln(g) + }; + }; + + // This is reduced incarnation of the binary EEA + // above, designated to invert members of the + // _prime_ fields F(p) at a maximal speed + BN.prototype._invmp = function _invmp (p) { + assert(p.negative === 0); + assert(!p.isZero()); + + var a = this; + var b = p.clone(); + + if (a.negative !== 0) { + a = a.umod(p); + } else { + a = a.clone(); + } + + var x1 = new BN(1); + var x2 = new BN(0); + + var delta = b.clone(); + + while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { + for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); + if (i > 0) { + a.iushrn(i); + while (i-- > 0) { + if (x1.isOdd()) { + x1.iadd(delta); + } + + x1.iushrn(1); + } + } + + for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); + if (j > 0) { + b.iushrn(j); + while (j-- > 0) { + if (x2.isOdd()) { + x2.iadd(delta); + } + + x2.iushrn(1); + } + } + + if (a.cmp(b) >= 0) { + a.isub(b); + x1.isub(x2); + } else { + b.isub(a); + x2.isub(x1); + } + } + + var res; + if (a.cmpn(1) === 0) { + res = x1; + } else { + res = x2; + } + + if (res.cmpn(0) < 0) { + res.iadd(p); + } + + return res; + }; + + BN.prototype.gcd = function gcd (num) { + if (this.isZero()) return num.abs(); + if (num.isZero()) return this.abs(); + + var a = this.clone(); + var b = num.clone(); + a.negative = 0; + b.negative = 0; + + // Remove common factor of two + for (var shift = 0; a.isEven() && b.isEven(); shift++) { + a.iushrn(1); + b.iushrn(1); + } + + do { + while (a.isEven()) { + a.iushrn(1); + } + while (b.isEven()) { + b.iushrn(1); + } + + var r = a.cmp(b); + if (r < 0) { + // Swap `a` and `b` to make `a` always bigger than `b` + var t = a; + a = b; + b = t; + } else if (r === 0 || b.cmpn(1) === 0) { + break; + } + + a.isub(b); + } while (true); + + return b.iushln(shift); + }; + + // Invert number in the field F(num) + BN.prototype.invm = function invm (num) { + return this.egcd(num).a.umod(num); + }; + + BN.prototype.isEven = function isEven () { + return (this.words[0] & 1) === 0; + }; + + BN.prototype.isOdd = function isOdd () { + return (this.words[0] & 1) === 1; + }; + + // And first word and num + BN.prototype.andln = function andln (num) { + return this.words[0] & num; + }; + + // Increment at the bit position in-line + BN.prototype.bincn = function bincn (bit) { + assert(typeof bit === 'number'); + var r = bit % 26; + var s = (bit - r) / 26; + var q = 1 << r; + + // Fast case: bit is much higher than all existing words + if (this.length <= s) { + this._expand(s + 1); + this.words[s] |= q; + return this; + } + + // Add bit and propagate, if needed + var carry = q; + for (var i = s; carry !== 0 && i < this.length; i++) { + var w = this.words[i] | 0; + w += carry; + carry = w >>> 26; + w &= 0x3ffffff; + this.words[i] = w; + } + if (carry !== 0) { + this.words[i] = carry; + this.length++; + } + return this; + }; + + BN.prototype.isZero = function isZero () { + return this.length === 1 && this.words[0] === 0; + }; + + BN.prototype.cmpn = function cmpn (num) { + var negative = num < 0; + + if (this.negative !== 0 && !negative) return -1; + if (this.negative === 0 && negative) return 1; + + this.strip(); + + var res; + if (this.length > 1) { + res = 1; + } else { + if (negative) { + num = -num; + } + + assert(num <= 0x3ffffff, 'Number is too big'); + + var w = this.words[0] | 0; + res = w === num ? 0 : w < num ? -1 : 1; + } + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Compare two numbers and return: + // 1 - if `this` > `num` + // 0 - if `this` == `num` + // -1 - if `this` < `num` + BN.prototype.cmp = function cmp (num) { + if (this.negative !== 0 && num.negative === 0) return -1; + if (this.negative === 0 && num.negative !== 0) return 1; + + var res = this.ucmp(num); + if (this.negative !== 0) return -res | 0; + return res; + }; + + // Unsigned comparison + BN.prototype.ucmp = function ucmp (num) { + // At this point both numbers have the same sign + if (this.length > num.length) return 1; + if (this.length < num.length) return -1; + + var res = 0; + for (var i = this.length - 1; i >= 0; i--) { + var a = this.words[i] | 0; + var b = num.words[i] | 0; + + if (a === b) continue; + if (a < b) { + res = -1; + } else if (a > b) { + res = 1; + } + break; + } + return res; + }; + + BN.prototype.gtn = function gtn (num) { + return this.cmpn(num) === 1; + }; + + BN.prototype.gt = function gt (num) { + return this.cmp(num) === 1; + }; + + BN.prototype.gten = function gten (num) { + return this.cmpn(num) >= 0; + }; + + BN.prototype.gte = function gte (num) { + return this.cmp(num) >= 0; + }; + + BN.prototype.ltn = function ltn (num) { + return this.cmpn(num) === -1; + }; + + BN.prototype.lt = function lt (num) { + return this.cmp(num) === -1; + }; + + BN.prototype.lten = function lten (num) { + return this.cmpn(num) <= 0; + }; + + BN.prototype.lte = function lte (num) { + return this.cmp(num) <= 0; + }; + + BN.prototype.eqn = function eqn (num) { + return this.cmpn(num) === 0; + }; + + BN.prototype.eq = function eq (num) { + return this.cmp(num) === 0; + }; + + // + // A reduce context, could be using montgomery or something better, depending + // on the `m` itself. + // + BN.red = function red (num) { + return new Red(num); + }; + + BN.prototype.toRed = function toRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + assert(this.negative === 0, 'red works only with positives'); + return ctx.convertTo(this)._forceRed(ctx); + }; + + BN.prototype.fromRed = function fromRed () { + assert(this.red, 'fromRed works only with numbers in reduction context'); + return this.red.convertFrom(this); + }; + + BN.prototype._forceRed = function _forceRed (ctx) { + this.red = ctx; + return this; + }; + + BN.prototype.forceRed = function forceRed (ctx) { + assert(!this.red, 'Already a number in reduction context'); + return this._forceRed(ctx); + }; + + BN.prototype.redAdd = function redAdd (num) { + assert(this.red, 'redAdd works only with red numbers'); + return this.red.add(this, num); + }; + + BN.prototype.redIAdd = function redIAdd (num) { + assert(this.red, 'redIAdd works only with red numbers'); + return this.red.iadd(this, num); + }; + + BN.prototype.redSub = function redSub (num) { + assert(this.red, 'redSub works only with red numbers'); + return this.red.sub(this, num); + }; + + BN.prototype.redISub = function redISub (num) { + assert(this.red, 'redISub works only with red numbers'); + return this.red.isub(this, num); + }; + + BN.prototype.redShl = function redShl (num) { + assert(this.red, 'redShl works only with red numbers'); + return this.red.shl(this, num); + }; + + BN.prototype.redMul = function redMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.mul(this, num); + }; + + BN.prototype.redIMul = function redIMul (num) { + assert(this.red, 'redMul works only with red numbers'); + this.red._verify2(this, num); + return this.red.imul(this, num); + }; + + BN.prototype.redSqr = function redSqr () { + assert(this.red, 'redSqr works only with red numbers'); + this.red._verify1(this); + return this.red.sqr(this); + }; + + BN.prototype.redISqr = function redISqr () { + assert(this.red, 'redISqr works only with red numbers'); + this.red._verify1(this); + return this.red.isqr(this); + }; + + // Square root over p + BN.prototype.redSqrt = function redSqrt () { + assert(this.red, 'redSqrt works only with red numbers'); + this.red._verify1(this); + return this.red.sqrt(this); + }; + + BN.prototype.redInvm = function redInvm () { + assert(this.red, 'redInvm works only with red numbers'); + this.red._verify1(this); + return this.red.invm(this); + }; + + // Return negative clone of `this` % `red modulo` + BN.prototype.redNeg = function redNeg () { + assert(this.red, 'redNeg works only with red numbers'); + this.red._verify1(this); + return this.red.neg(this); + }; + + BN.prototype.redPow = function redPow (num) { + assert(this.red && !num.red, 'redPow(normalNum)'); + this.red._verify1(this); + return this.red.pow(this, num); + }; + + // Prime numbers with efficient reduction + var primes = { + k256: null, + p224: null, + p192: null, + p25519: null + }; + + // Pseudo-Mersenne prime + function MPrime (name, p) { + // P = 2 ^ N - K + this.name = name; + this.p = new BN(p, 16); + this.n = this.p.bitLength(); + this.k = new BN(1).iushln(this.n).isub(this.p); + + this.tmp = this._tmp(); + } + + MPrime.prototype._tmp = function _tmp () { + var tmp = new BN(null); + tmp.words = new Array(Math.ceil(this.n / 13)); + return tmp; + }; + + MPrime.prototype.ireduce = function ireduce (num) { + // Assumes that `num` is less than `P^2` + // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) + var r = num; + var rlen; + + do { + this.split(r, this.tmp); + r = this.imulK(r); + r = r.iadd(this.tmp); + rlen = r.bitLength(); + } while (rlen > this.n); + + var cmp = rlen < this.n ? -1 : r.ucmp(this.p); + if (cmp === 0) { + r.words[0] = 0; + r.length = 1; + } else if (cmp > 0) { + r.isub(this.p); + } else { + r.strip(); + } + + return r; + }; + + MPrime.prototype.split = function split (input, out) { + input.iushrn(this.n, 0, out); + }; + + MPrime.prototype.imulK = function imulK (num) { + return num.imul(this.k); + }; + + function K256 () { + MPrime.call( + this, + 'k256', + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); + } + inherits(K256, MPrime); + + K256.prototype.split = function split (input, output) { + // 256 = 9 * 26 + 22 + var mask = 0x3fffff; + + var outLen = Math.min(input.length, 9); + for (var i = 0; i < outLen; i++) { + output.words[i] = input.words[i]; + } + output.length = outLen; + + if (input.length <= 9) { + input.words[0] = 0; + input.length = 1; + return; + } + + // Shift by 9 limbs + var prev = input.words[9]; + output.words[output.length++] = prev & mask; + + for (i = 10; i < input.length; i++) { + var next = input.words[i] | 0; + input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); + prev = next; + } + prev >>>= 22; + input.words[i - 10] = prev; + if (prev === 0 && input.length > 10) { + input.length -= 10; + } else { + input.length -= 9; + } + }; + + K256.prototype.imulK = function imulK (num) { + // K = 0x1000003d1 = [ 0x40, 0x3d1 ] + num.words[num.length] = 0; + num.words[num.length + 1] = 0; + num.length += 2; + + // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 + var lo = 0; + for (var i = 0; i < num.length; i++) { + var w = num.words[i] | 0; + lo += w * 0x3d1; + num.words[i] = lo & 0x3ffffff; + lo = w * 0x40 + ((lo / 0x4000000) | 0); + } + + // Fast length reduction + if (num.words[num.length - 1] === 0) { + num.length--; + if (num.words[num.length - 1] === 0) { + num.length--; + } + } + return num; + }; + + function P224 () { + MPrime.call( + this, + 'p224', + 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); + } + inherits(P224, MPrime); + + function P192 () { + MPrime.call( + this, + 'p192', + 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); + } + inherits(P192, MPrime); + + function P25519 () { + // 2 ^ 255 - 19 + MPrime.call( + this, + '25519', + '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); + } + inherits(P25519, MPrime); + + P25519.prototype.imulK = function imulK (num) { + // K = 0x13 + var carry = 0; + for (var i = 0; i < num.length; i++) { + var hi = (num.words[i] | 0) * 0x13 + carry; + var lo = hi & 0x3ffffff; + hi >>>= 26; + + num.words[i] = lo; + carry = hi; + } + if (carry !== 0) { + num.words[num.length++] = carry; + } + return num; + }; + + // Exported mostly for testing purposes, use plain name instead + BN._prime = function prime (name) { + // Cached version of prime + if (primes[name]) return primes[name]; + + var prime; + if (name === 'k256') { + prime = new K256(); + } else if (name === 'p224') { + prime = new P224(); + } else if (name === 'p192') { + prime = new P192(); + } else if (name === 'p25519') { + prime = new P25519(); + } else { + throw new Error('Unknown prime ' + name); + } + primes[name] = prime; + + return prime; + }; + + // + // Base reduction engine + // + function Red (m) { + if (typeof m === 'string') { + var prime = BN._prime(m); + this.m = prime.p; + this.prime = prime; + } else { + assert(m.gtn(1), 'modulus must be greater than 1'); + this.m = m; + this.prime = null; + } + } + + Red.prototype._verify1 = function _verify1 (a) { + assert(a.negative === 0, 'red works only with positives'); + assert(a.red, 'red works only with red numbers'); + }; + + Red.prototype._verify2 = function _verify2 (a, b) { + assert((a.negative | b.negative) === 0, 'red works only with positives'); + assert(a.red && a.red === b.red, + 'red works only with red numbers'); + }; + + Red.prototype.imod = function imod (a) { + if (this.prime) return this.prime.ireduce(a)._forceRed(this); + return a.umod(this.m)._forceRed(this); + }; + + Red.prototype.neg = function neg (a) { + if (a.isZero()) { + return a.clone(); + } + + return this.m.sub(a)._forceRed(this); + }; + + Red.prototype.add = function add (a, b) { + this._verify2(a, b); + + var res = a.add(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.iadd = function iadd (a, b) { + this._verify2(a, b); + + var res = a.iadd(b); + if (res.cmp(this.m) >= 0) { + res.isub(this.m); + } + return res; + }; + + Red.prototype.sub = function sub (a, b) { + this._verify2(a, b); + + var res = a.sub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res._forceRed(this); + }; + + Red.prototype.isub = function isub (a, b) { + this._verify2(a, b); + + var res = a.isub(b); + if (res.cmpn(0) < 0) { + res.iadd(this.m); + } + return res; + }; + + Red.prototype.shl = function shl (a, num) { + this._verify1(a); + return this.imod(a.ushln(num)); + }; + + Red.prototype.imul = function imul (a, b) { + this._verify2(a, b); + return this.imod(a.imul(b)); + }; + + Red.prototype.mul = function mul (a, b) { + this._verify2(a, b); + return this.imod(a.mul(b)); + }; + + Red.prototype.isqr = function isqr (a) { + return this.imul(a, a.clone()); + }; + + Red.prototype.sqr = function sqr (a) { + return this.mul(a, a); + }; + + Red.prototype.sqrt = function sqrt (a) { + if (a.isZero()) return a.clone(); + + var mod3 = this.m.andln(3); + assert(mod3 % 2 === 1); + + // Fast case + if (mod3 === 3) { + var pow = this.m.add(new BN(1)).iushrn(2); + return this.pow(a, pow); + } + + // Tonelli-Shanks algorithm (Totally unoptimized and slow) + // + // Find Q and S, that Q * 2 ^ S = (P - 1) + var q = this.m.subn(1); + var s = 0; + while (!q.isZero() && q.andln(1) === 0) { + s++; + q.iushrn(1); + } + assert(!q.isZero()); + + var one = new BN(1).toRed(this); + var nOne = one.redNeg(); + + // Find quadratic non-residue + // NOTE: Max is such because of generalized Riemann hypothesis. + var lpow = this.m.subn(1).iushrn(1); + var z = this.m.bitLength(); + z = new BN(2 * z * z).toRed(this); + + while (this.pow(z, lpow).cmp(nOne) !== 0) { + z.redIAdd(nOne); + } + + var c = this.pow(z, q); + var r = this.pow(a, q.addn(1).iushrn(1)); + var t = this.pow(a, q); + var m = s; + while (t.cmp(one) !== 0) { + var tmp = t; + for (var i = 0; tmp.cmp(one) !== 0; i++) { + tmp = tmp.redSqr(); + } + assert(i < m); + var b = this.pow(c, new BN(1).iushln(m - i - 1)); + + r = r.redMul(b); + c = b.redSqr(); + t = t.redMul(c); + m = i; + } + + return r; + }; + + Red.prototype.invm = function invm (a) { + var inv = a._invmp(this.m); + if (inv.negative !== 0) { + inv.negative = 0; + return this.imod(inv).redNeg(); + } else { + return this.imod(inv); + } + }; + + Red.prototype.pow = function pow (a, num) { + if (num.isZero()) return new BN(1).toRed(this); + if (num.cmpn(1) === 0) return a.clone(); + + var windowSize = 4; + var wnd = new Array(1 << windowSize); + wnd[0] = new BN(1).toRed(this); + wnd[1] = a; + for (var i = 2; i < wnd.length; i++) { + wnd[i] = this.mul(wnd[i - 1], a); + } + + var res = wnd[0]; + var current = 0; + var currentLen = 0; + var start = num.bitLength() % 26; + if (start === 0) { + start = 26; + } + + for (i = num.length - 1; i >= 0; i--) { + var word = num.words[i]; + for (var j = start - 1; j >= 0; j--) { + var bit = (word >> j) & 1; + if (res !== wnd[0]) { + res = this.sqr(res); + } + + if (bit === 0 && current === 0) { + currentLen = 0; + continue; + } + + current <<= 1; + current |= bit; + currentLen++; + if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; + + res = this.mul(res, wnd[current]); + currentLen = 0; + current = 0; + } + start = 26; + } + + return res; + }; + + Red.prototype.convertTo = function convertTo (num) { + var r = num.umod(this.m); + + return r === num ? r.clone() : r; + }; + + Red.prototype.convertFrom = function convertFrom (num) { + var res = num.clone(); + res.red = null; + return res; + }; + + // + // Montgomery method engine + // + + BN.mont = function mont (num) { + return new Mont(num); + }; + + function Mont (m) { + Red.call(this, m); + + this.shift = this.m.bitLength(); + if (this.shift % 26 !== 0) { + this.shift += 26 - (this.shift % 26); + } + + this.r = new BN(1).iushln(this.shift); + this.r2 = this.imod(this.r.sqr()); + this.rinv = this.r._invmp(this.m); + + this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); + this.minv = this.minv.umod(this.r); + this.minv = this.r.sub(this.minv); + } + inherits(Mont, Red); + + Mont.prototype.convertTo = function convertTo (num) { + return this.imod(num.ushln(this.shift)); + }; + + Mont.prototype.convertFrom = function convertFrom (num) { + var r = this.imod(num.mul(this.rinv)); + r.red = null; + return r; + }; + + Mont.prototype.imul = function imul (a, b) { + if (a.isZero() || b.isZero()) { + a.words[0] = 0; + a.length = 1; + return a; + } + + var t = a.imul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.mul = function mul (a, b) { + if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); + + var t = a.mul(b); + var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); + var u = t.isub(c).iushrn(this.shift); + var res = u; + if (u.cmp(this.m) >= 0) { + res = u.isub(this.m); + } else if (u.cmpn(0) < 0) { + res = u.iadd(this.m); + } + + return res._forceRed(this); + }; + + Mont.prototype.invm = function invm (a) { + // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R + var res = this.imod(a._invmp(this.m).mul(this.r2)); + return res._forceRed(this); + }; + })('object' === 'undefined' || module, commonjsGlobal); + }); + var bn_1 = bn.BN; + + var _version = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "logger/5.0.0-beta.129"; + }); + + var _version$1 = unwrapExports(_version); + var _version_1 = _version.version; + + var logger = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + var _permanentCensorErrors = false; + var _censorErrors = false; + var LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; + var LogLevel = LogLevels["default"]; + + var _globalLogger = null; + function _checkNormalize() { + try { + var missing_1 = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) { + try { + if ("test".normalize(form) !== "test") { + throw new Error("bad normalize"); + } + ; + } + catch (error) { + missing_1.push(form); + } + }); + if (missing_1.length) { + throw new Error("missing " + missing_1.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; + } + var _normalizeError = _checkNormalize(); + var Logger = /** @class */ (function () { + function Logger(version) { + Object.defineProperty(this, "version", { + enumerable: true, + value: version, + writable: false + }); + } + Logger.prototype.setLogLevel = function (logLevel) { + var level = LogLevels[logLevel]; + if (level == null) { + this.warn("invliad log level - " + logLevel); + return; + } + LogLevel = level; + }; + Logger.prototype._log = function (logLevel, args) { + if (LogLevel > LogLevels[logLevel]) { + return; + } + console.log.apply(console, args); + }; + Logger.prototype.debug = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger.levels.DEBUG, args); + }; + Logger.prototype.info = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger.levels.INFO, args); + }; + Logger.prototype.warn = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + this._log(Logger.levels.WARNING, args); + }; + Logger.prototype.makeError = function (message, code, params) { + if (_censorErrors) { + return new Error("unknown error"); + } + if (!code) { + code = Logger.errors.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + var messageDetails = []; + Object.keys(params).forEach(function (key) { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("version=" + this.version); + var reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + var error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; + }; + Logger.prototype.throwError = function (message, code, params) { + throw this.makeError(message, code, params); + }; + Logger.prototype.throwArgumentError = function (message, name, value) { + return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { + argument: name, + value: value + }); + }; + Logger.prototype.checkNormalize = function (message) { + if (message == null) { + message = "platform missing String.prototype.normalize"; + } + if (_normalizeError) { + this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } + }; + Logger.prototype.checkSafeUint53 = function (value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } + }; + Logger.prototype.checkArgumentCount = function (count, expectedCount, message) { + if (message) { + message = ": " + message; + } + else { + message = ""; + } + if (count < expectedCount) { + this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + if (count > expectedCount) { + this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + }; + Logger.prototype.checkNew = function (target, kind) { + if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + }; + Logger.prototype.checkAbstract = function (target, kind) { + if (target === kind) { + this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + }; + Logger.globalLogger = function () { + if (!_globalLogger) { + _globalLogger = new Logger(_version.version); + } + return _globalLogger; + }; + Logger.setCensorship = function (censorship, permanent) { + if (_permanentCensorErrors) { + if (!censorship) { + return; + } + this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; + }; + Logger.errors = { + /////////////////// + // Generic Errors + // Unknown Error + UNKNOWN_ERROR: "UNKNOWN_ERROR", + // Not Implemented + NOT_IMPLEMENTED: "NOT_IMPLEMENTED", + // Unsupported Operation + // - operation + UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION", + // Network Error (i.e. Ethereum Network, such as an invalid chain ID) + NETWORK_ERROR: "NETWORK_ERROR", + // Some sort of bad response from the server + SERVER_ERROR: "SERVER_ERROR", + // Timeout + TIMEOUT: "TIMEOUT", + /////////////////// + // Operational Errors + // Buffer Overrun + BUFFER_OVERRUN: "BUFFER_OVERRUN", + // Numeric Fault + // - operation: the operation being executed + // - fault: the reason this faulted + NUMERIC_FAULT: "NUMERIC_FAULT", + /////////////////// + // Argument Errors + // Missing new operator to an object + // - name: The name of the class + MISSING_NEW: "MISSING_NEW", + // Invalid argument (e.g. value is incompatible with type) to a function: + // - argument: The argument name that was invalid + // - value: The value of the argument + INVALID_ARGUMENT: "INVALID_ARGUMENT", + // Missing argument to a function: + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + MISSING_ARGUMENT: "MISSING_ARGUMENT", + // Too many arguments + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + UNEXPECTED_ARGUMENT: "UNEXPECTED_ARGUMENT", + /////////////////// + // Blockchain Errors + // Call exception + // - transaction: the transaction + // - address?: the contract address + // - args?: The arguments passed into the function + // - method?: The Solidity method signature + // - errorSignature?: The EIP848 error signature + // - errorArgs?: The EIP848 error parameters + // - reason: The reason (only for EIP848 "Error(string)") + CALL_EXCEPTION: "CALL_EXCEPTION", + // Insufficien funds (< value + gasLimit * gasPrice) + // - transaction: the transaction attempted + INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS", + // Nonce has already been used + // - transaction: the transaction attempted + NONCE_EXPIRED: "NONCE_EXPIRED", + // The replacement fee for the transaction is too low + // - transaction: the transaction attempted + REPLACEMENT_UNDERPRICED: "REPLACEMENT_UNDERPRICED", + // The gas limit could not be estimated + // - transaction: the transaction passed to estimateGas + UNPREDICTABLE_GAS_LIMIT: "UNPREDICTABLE_GAS_LIMIT", + }; + Logger.levels = { + DEBUG: "DEBUG", + INFO: "INFO", + WARNING: "WARNING", + ERROR: "ERROR", + OFF: "OFF" + }; + return Logger; + }()); + exports.Logger = Logger; + }); + + var index = unwrapExports(logger); + var logger_1 = logger.Logger; + + var _version$2 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "bytes/5.0.0-beta.129"; + }); + + var _version$3 = unwrapExports(_version$2); + var _version_1$1 = _version$2.version; + + var bytes = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + var logger$1 = new logger.Logger(_version$2.version); + /////////////////////////////// + function isHexable(value) { + return !!(value.toHexString); + } + function addSlice(array) { + if (array.slice) { + return array; + } + array.slice = function () { + var args = Array.prototype.slice.call(arguments); + return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); + }; + return array; + } + function isBytesLike(value) { + return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); + } + exports.isBytesLike = isBytesLike; + function isBytes(value) { + if (value == null) { + return false; + } + if (value.constructor === Uint8Array) { + return true; + } + if (typeof (value) === "string") { + return false; + } + if (value.length == null) { + return false; + } + for (var i = 0; i < value.length; i++) { + var v = value[i]; + if (v < 0 || v >= 256 || (v % 1)) { + return false; + } + } + return true; + } + exports.isBytes = isBytes; + function arrayify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger$1.checkSafeUint53(value, "invalid arrayify value"); + var result = []; + while (value) { + result.unshift(value & 0xff); + value /= 256; + } + if (result.length === 0) { + result.push(0); + } + return addSlice(new Uint8Array(result)); + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + value = value.toHexString(); + } + if (isHexString(value)) { + var hex = value.substring(2); + if (!options.allowOddLength && hex.length % 2) { + logger$1.throwArgumentError("hex data is odd-length", "value", value); + } + var result = []; + for (var i = 0; i < hex.length; i += 2) { + result.push(parseInt(hex.substring(i, i + 2), 16)); + } + return addSlice(new Uint8Array(result)); + } + if (isBytes(value)) { + return addSlice(new Uint8Array(value)); + } + return logger$1.throwArgumentError("invalid arrayify value", "value", value); + } + exports.arrayify = arrayify; + function concat(items) { + var objects = items.map(function (item) { return arrayify(item); }); + var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0); + var result = new Uint8Array(length); + objects.reduce(function (offset, object) { + result.set(object, offset); + return offset + object.length; + }, 0); + return addSlice(result); + } + exports.concat = concat; + function stripZeros(value) { + var result = arrayify(value); + if (result.length === 0) { + return result; + } + // Find the first non-zero entry + var start = 0; + while (start < result.length && result[start] === 0) { + start++; + } + // If we started with zeros, strip them + if (start) { + result = result.slice(start); + } + return result; + } + exports.stripZeros = stripZeros; + function zeroPad(value, length) { + value = arrayify(value); + if (value.length > length) { + logger$1.throwArgumentError("value out of range", "value", arguments[0]); + } + var result = new Uint8Array(length); + result.set(value, length - value.length); + return addSlice(result); + } + exports.zeroPad = zeroPad; + function isHexString(value, length) { + if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { + return false; + } + if (length && value.length !== 2 + 2 * length) { + return false; + } + return true; + } + exports.isHexString = isHexString; + var HexCharacters = "0123456789abcdef"; + function hexlify(value, options) { + if (!options) { + options = {}; + } + if (typeof (value) === "number") { + logger$1.checkSafeUint53(value, "invalid hexlify value"); + var hex = ""; + while (value) { + hex = HexCharacters[value & 0x0f] + hex; + value = Math.floor(value / 16); + } + if (hex.length) { + if (hex.length % 2) { + hex = "0" + hex; + } + return "0x" + hex; + } + return "0x00"; + } + if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexable(value)) { + return value.toHexString(); + } + if (isHexString(value)) { + if (!options.allowOddLength && value.length % 2) { + logger$1.throwArgumentError("hex data is odd-length", "value", value); + } + return value.toLowerCase(); + } + if (isBytes(value)) { + var result = "0x"; + for (var i = 0; i < value.length; i++) { + var v = value[i]; + result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; + } + return result; + } + return logger$1.throwArgumentError("invalid hexlify value", "value", value); + } + exports.hexlify = hexlify; + /* + function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { + if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { + return "0x0" + value.substring(2); + } + return value; + } + */ + function hexDataLength(data) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + return null; + } + return (data.length - 2) / 2; + } + exports.hexDataLength = hexDataLength; + function hexDataSlice(data, offset, endOffset) { + if (typeof (data) !== "string") { + data = hexlify(data); + } + else if (!isHexString(data) || (data.length % 2)) { + logger$1.throwArgumentError("invalid hexData", "value", data); + } + offset = 2 + 2 * offset; + if (endOffset != null) { + return "0x" + data.substring(offset, 2 + 2 * endOffset); + } + return "0x" + data.substring(offset); + } + exports.hexDataSlice = hexDataSlice; + function hexConcat(items) { + var result = "0x"; + items.forEach(function (item) { + result += hexlify(item).substring(2); + }); + return result; + } + exports.hexConcat = hexConcat; + function hexValue(value) { + var trimmed = hexStripZeros(hexlify(value, { allowOddLength: true })); + if (trimmed === "0x") { + return "0x0"; + } + return trimmed; + } + exports.hexValue = hexValue; + function hexStripZeros(value) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + if (!isHexString(value)) { + logger$1.throwArgumentError("invalid hex string", "value", value); + } + value = value.substring(2); + var offset = 0; + while (offset < value.length && value[offset] === "0") { + offset++; + } + return "0x" + value.substring(offset); + } + exports.hexStripZeros = hexStripZeros; + function hexZeroPad(value, length) { + if (typeof (value) !== "string") { + value = hexlify(value); + } + else if (!isHexString(value)) { + logger$1.throwArgumentError("invalid hex string", "value", value); + } + if (value.length > 2 * length + 2) { + logger$1.throwArgumentError("value out of range", "value", arguments[1]); + } + while (value.length < 2 * length + 2) { + value = "0x0" + value.substring(2); + } + return value; + } + exports.hexZeroPad = hexZeroPad; + function splitSignature(signature) { + var result = { + r: "0x", + s: "0x", + _vs: "0x", + recoveryParam: 0, + v: 0 + }; + if (isBytesLike(signature)) { + var bytes = arrayify(signature); + if (bytes.length !== 65) { + logger$1.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + } + // Get the r and s + result.r = hexlify(bytes.slice(0, 32)); + result.s = hexlify(bytes.slice(32, 64)); + // Reduce v to the canonical 27 or 28 + result.v = bytes[64]; + if (result.v !== 27 && result.v !== 28) { + result.v = 27 + (result.v % 2); + } + // Compute recoveryParam from v + result.recoveryParam = (result.v - 27); + // Compute _vs from recoveryParam and s + if (result.recoveryParam) { + bytes[32] |= 0x80; + } + result._vs = hexlify(bytes.slice(32, 64)); + } + else { + result.r = signature.r; + result.s = signature.s; + result.v = signature.v; + result.recoveryParam = signature.recoveryParam; + result._vs = signature._vs; + // Normalize v into a canonical 27 or 28 + if (result.v != null && !(result.v == 27 || result.v == 28)) { + result.v = 27 + (result.v % 2); + } + // Populate a missing v or recoveryParam if possible + if (result.recoveryParam == null && result.v != null) { + result.recoveryParam = 1 - (result.v % 2); + } + else if (result.recoveryParam != null && result.v == null) { + result.v = 27 + result.recoveryParam; + } + else if (result.recoveryParam != null && result.v != null) { + if (result.v !== 27 + result.recoveryParam) { + logger$1.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); + } + } + // Make sure r and s are padded properly + if (result.r != null) { + result.r = hexZeroPad(result.r, 32); + } + if (result.s != null) { + result.s = hexZeroPad(result.s, 32); + } + // If the _vs is available, use it to populate missing s, v and recoveryParam + // and verify non-missing s, v and recoveryParam + if (result._vs != null) { + result._vs = hexZeroPad(result._vs, 32); + if (result._vs.length > 66) { + logger$1.throwArgumentError("signature _vs overflow", "signature", signature); + } + var vs = arrayify(result._vs); + var recoveryParam = ((vs[0] >= 128) ? 1 : 0); + var v = 27 + result.recoveryParam; + // Use _vs to compute s + vs[0] &= 0x7f; + var s = hexlify(vs); + // Check _vs aggress with other parameters + if (result.s == null) { + result.s = s; + } + else if (result.s !== s) { + logger$1.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (result.v == null) { + result.v = v; + } + else if (result.v !== v) { + logger$1.throwArgumentError("signature v mismatch _vs", "signature", signature); + } + if (recoveryParam == null) { + result.recoveryParam = recoveryParam; + } + else if (result.recoveryParam !== recoveryParam) { + logger$1.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + } + } + // After all populating, both v and recoveryParam are still missing... + if (result.v == null && result.recoveryParam == null) { + logger$1.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); + } + // Check for canonical v + if (result.v !== 27 && result.v !== 28) { + logger$1.throwArgumentError("signature v not canonical", "signature", signature); + } + // Check that r and s are in range + if (result.r.length > 66 || result.s.length > 66) { + logger$1.throwArgumentError("signature overflow r or s", "signature", signature); + } + if (result._vs == null) { + var vs = arrayify(result.s); + if (vs[0] >= 128) { + logger$1.throwArgumentError("signature s out of range", "signature", signature); + } + if (result.recoveryParam) { + vs[0] |= 0x80; + } + result._vs = hexlify(vs); + } + } + return result; + } + exports.splitSignature = splitSignature; + function joinSignature(signature) { + signature = splitSignature(signature); + return hexlify(concat([ + signature.r, + signature.s, + (signature.recoveryParam ? "0x1c" : "0x1b") + ])); + } + exports.joinSignature = joinSignature; + }); + + var index$1 = unwrapExports(bytes); + var bytes_1 = bytes.isBytesLike; + var bytes_2 = bytes.isBytes; + var bytes_3 = bytes.arrayify; + var bytes_4 = bytes.concat; + var bytes_5 = bytes.stripZeros; + var bytes_6 = bytes.zeroPad; + var bytes_7 = bytes.isHexString; + var bytes_8 = bytes.hexlify; + var bytes_9 = bytes.hexDataLength; + var bytes_10 = bytes.hexDataSlice; + var bytes_11 = bytes.hexConcat; + var bytes_12 = bytes.hexValue; + var bytes_13 = bytes.hexStripZeros; + var bytes_14 = bytes.hexZeroPad; + var bytes_15 = bytes.splitSignature; + var bytes_16 = bytes.joinSignature; + + var _version$4 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "bignumber/5.0.0-beta.130"; + }); + + var _version$5 = unwrapExports(_version$4); + var _version_1$2 = _version$4.version; + + var bignumber = createCommonjsModule(function (module, exports) { + "use strict"; + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + /** + * BigNumber + * + * A wrapper around the BN.js object. We use the BN.js library + * because it is used by elliptic, so it is required regardles. + * + */ + var BN = __importStar(bn); + + + + var logger$1 = new logger.Logger(_version$4.version); + var _constructorGuard = {}; + var MAX_SAFE = 0x1fffffffffffff; + function isBigNumberish(value) { + return (value != null) && (BigNumber.isBigNumber(value) || + (typeof (value) === "number" && (value % 1) === 0) || + (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || + bytes.isHexString(value) || + (typeof (value) === "bigint") || + bytes.isBytes(value)); + } + exports.isBigNumberish = isBigNumberish; + var BigNumber = /** @class */ (function () { + function BigNumber(constructorGuard, hex) { + var _newTarget = this.constructor; + logger$1.checkNew(_newTarget, BigNumber); + if (constructorGuard !== _constructorGuard) { + logger$1.throwError("cannot call consturtor directly; use BigNumber.from", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "new (BigNumber)" + }); + } + this._hex = hex; + this._isBigNumber = true; + Object.freeze(this); + } + BigNumber.prototype.fromTwos = function (value) { + return toBigNumber(toBN(this).fromTwos(value)); + }; + BigNumber.prototype.toTwos = function (value) { + return toBigNumber(toBN(this).toTwos(value)); + }; + BigNumber.prototype.abs = function () { + if (this._hex[0] === "-") { + return BigNumber.from(this._hex.substring(1)); + } + return this; + }; + BigNumber.prototype.add = function (other) { + return toBigNumber(toBN(this).add(toBN(other))); + }; + BigNumber.prototype.sub = function (other) { + return toBigNumber(toBN(this).sub(toBN(other))); + }; + BigNumber.prototype.div = function (other) { + var o = BigNumber.from(other); + if (o.isZero()) { + throwFault("division by zero", "div"); + } + return toBigNumber(toBN(this).div(toBN(other))); + }; + BigNumber.prototype.mul = function (other) { + return toBigNumber(toBN(this).mul(toBN(other))); + }; + BigNumber.prototype.mod = function (other) { + return toBigNumber(toBN(this).mod(toBN(other))); + }; + BigNumber.prototype.pow = function (other) { + return toBigNumber(toBN(this).pow(toBN(other))); + }; + BigNumber.prototype.maskn = function (value) { + return toBigNumber(toBN(this).maskn(value)); + }; + BigNumber.prototype.eq = function (other) { + return toBN(this).eq(toBN(other)); + }; + BigNumber.prototype.lt = function (other) { + return toBN(this).lt(toBN(other)); + }; + BigNumber.prototype.lte = function (other) { + return toBN(this).lte(toBN(other)); + }; + BigNumber.prototype.gt = function (other) { + return toBN(this).gt(toBN(other)); + }; + BigNumber.prototype.gte = function (other) { + return toBN(this).gte(toBN(other)); + }; + BigNumber.prototype.isZero = function () { + return toBN(this).isZero(); + }; + BigNumber.prototype.toNumber = function () { + try { + return toBN(this).toNumber(); + } + catch (error) { + throwFault("overflow", "toNumber", this.toString()); + } + return null; + }; + BigNumber.prototype.toString = function () { + // Lots of people expect this, which we do not support, so check + if (arguments.length !== 0) { + logger$1.throwError("bigNumber.toString does not accept parameters", logger.Logger.errors.UNEXPECTED_ARGUMENT, {}); + } + return toBN(this).toString(10); + }; + BigNumber.prototype.toHexString = function () { + return this._hex; + }; + BigNumber.from = function (value) { + if (value instanceof BigNumber) { + return value; + } + if (typeof (value) === "string") { + if (value.match(/-?0x[0-9a-f]+/i)) { + return new BigNumber(_constructorGuard, toHex(value)); + } + if (value.match(/^-?[0-9]+$/)) { + return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + } + return logger$1.throwArgumentError("invalid BigNumber string", "value", value); + } + if (typeof (value) === "number") { + if (value % 1) { + throwFault("underflow", "BigNumber.from", value); + } + if (value >= MAX_SAFE || value <= -MAX_SAFE) { + throwFault("overflow", "BigNumber.from", value); + } + return BigNumber.from(String(value)); + } + if (typeof (value) === "bigint") { + return BigNumber.from(value.toString()); + } + if (bytes.isBytes(value)) { + return BigNumber.from(bytes.hexlify(value)); + } + if (value._hex && bytes.isHexString(value._hex)) { + return BigNumber.from(value._hex); + } + if (value.toHexString) { + value = value.toHexString(); + if (typeof (value) === "string") { + return BigNumber.from(value); + } + } + return logger$1.throwArgumentError("invalid BigNumber value", "value", value); + }; + BigNumber.isBigNumber = function (value) { + return !!(value && value._isBigNumber); + }; + return BigNumber; + }()); + exports.BigNumber = BigNumber; + // Normalize the hex string + function toHex(value) { + // For BN, call on the hex string + if (typeof (value) !== "string") { + return toHex(value.toString(16)); + } + // If negative, prepend the negative sign to the normalized positive value + if (value[0] === "-") { + // Strip off the negative sign + value = value.substring(1); + // Cannot have mulitple negative signs (e.g. "--0x04") + if (value[0] === "-") { + logger$1.throwArgumentError("invalid hex", "value", value); + } + // Call toHex on the positive component + value = toHex(value); + // Do not allow "-0x00" + if (value === "0x00") { + return value; + } + // Negate the value + return "-" + value; + } + // Add a "0x" prefix if missing + if (value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + // Normalize zero + if (value === "0x") { + return "0x00"; + } + // Make the string even length + if (value.length % 2) { + value = "0x0" + value.substring(2); + } + // Trim to smallest even-length string + while (value.length > 4 && value.substring(0, 4) === "0x00") { + value = "0x" + value.substring(4); + } + return value; + } + function toBigNumber(value) { + return BigNumber.from(toHex(value)); + } + function toBN(value) { + var hex = BigNumber.from(value).toHexString(); + if (hex[0] === "-") { + return (new BN.BN("-" + hex.substring(3), 16)); + } + return new BN.BN(hex.substring(2), 16); + } + function throwFault(fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value != null) { + params.value = value; + } + return logger$1.throwError(fault, logger.Logger.errors.NUMERIC_FAULT, params); + } + }); + + var bignumber$1 = unwrapExports(bignumber); + var bignumber_1 = bignumber.isBigNumberish; + var bignumber_2 = bignumber.BigNumber; + + var fixednumber = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$4.version); + + var _constructorGuard = {}; + var Zero = bignumber.BigNumber.from(0); + var NegativeOne = bignumber.BigNumber.from(-1); + function throwFault(message, fault, operation, value) { + var params = { fault: fault, operation: operation }; + if (value !== undefined) { + params.value = value; + } + return logger$1.throwError(message, logger.Logger.errors.NUMERIC_FAULT, params); + } + // Constant to pull zeros from for multipliers + var zeros = "0"; + while (zeros.length < 256) { + zeros += zeros; + } + // Returns a string "1" followed by decimal "0"s + function getMultiplier(decimals) { + if (typeof (decimals) !== "number") { + try { + decimals = bignumber.BigNumber.from(decimals).toNumber(); + } + catch (e) { } + } + if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { + return ("1" + zeros.substring(0, decimals)); + } + return logger$1.throwArgumentError("invalid decimal size", "decimals", decimals); + } + function formatFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + // Make sure wei is a big number (convert as necessary) + value = bignumber.BigNumber.from(value); + var negative = value.lt(Zero); + if (negative) { + value = value.mul(NegativeOne); + } + var fraction = value.mod(multiplier).toString(); + while (fraction.length < multiplier.length - 1) { + fraction = "0" + fraction; + } + // Strip training 0 + fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; + var whole = value.div(multiplier).toString(); + value = whole + "." + fraction; + if (negative) { + value = "-" + value; + } + return value; + } + exports.formatFixed = formatFixed; + function parseFixed(value, decimals) { + if (decimals == null) { + decimals = 0; + } + var multiplier = getMultiplier(decimals); + if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { + logger$1.throwArgumentError("invalid decimal value", "value", value); + } + if (multiplier.length - 1 === 0) { + return bignumber.BigNumber.from(value); + } + // Is it negative? + var negative = (value.substring(0, 1) === "-"); + if (negative) { + value = value.substring(1); + } + if (value === ".") { + logger$1.throwArgumentError("missing value", "value", value); + } + // Split it into a whole and fractional part + var comps = value.split("."); + if (comps.length > 2) { + logger$1.throwArgumentError("too many decimal points", "value", value); + } + var whole = comps[0], fraction = comps[1]; + if (!whole) { + whole = "0"; + } + if (!fraction) { + fraction = "0"; + } + // Prevent underflow + if (fraction.length > multiplier.length - 1) { + throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); + } + // Fully pad the string with zeros to get to wei + while (fraction.length < multiplier.length - 1) { + fraction += "0"; + } + var wholeValue = bignumber.BigNumber.from(whole); + var fractionValue = bignumber.BigNumber.from(fraction); + var wei = (wholeValue.mul(multiplier)).add(fractionValue); + if (negative) { + wei = wei.mul(NegativeOne); + } + return wei; + } + exports.parseFixed = parseFixed; + var FixedFormat = /** @class */ (function () { + function FixedFormat(constructorGuard, signed, width, decimals) { + this.signed = signed; + this.width = width; + this.decimals = decimals; + this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); + this._multiplier = getMultiplier(decimals); + Object.freeze(this); + } + FixedFormat.from = function (value) { + if (value instanceof FixedFormat) { + return value; + } + var signed = true; + var width = 128; + var decimals = 18; + if (typeof (value) === "string") { + if (value === "fixed") { + // defaults... + } + else if (value === "ufixed") { + signed = false; + } + else if (value != null) { + var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); + if (!match) { + logger$1.throwArgumentError("invalid fixed format", "format", value); + } + signed = (match[1] !== "u"); + width = parseInt(match[2]); + decimals = parseInt(match[3]); + } + } + else if (value) { + var check = function (key, type, defaultValue) { + if (value[key] == null) { + return defaultValue; + } + if (typeof (value[key]) !== type) { + logger$1.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + } + return value[key]; + }; + signed = check("signed", "boolean", signed); + width = check("width", "number", width); + decimals = check("decimals", "number", decimals); + } + if (width % 8) { + logger$1.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + } + if (decimals > 80) { + logger$1.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + } + return new FixedFormat(_constructorGuard, signed, width, decimals); + }; + return FixedFormat; + }()); + exports.FixedFormat = FixedFormat; + var FixedNumber = /** @class */ (function () { + function FixedNumber(constructorGuard, hex, value, format) { + var _newTarget = this.constructor; + logger$1.checkNew(_newTarget, FixedNumber); + this.format = format; + this._hex = hex; + this._value = value; + this._isFixedNumber = true; + Object.freeze(this); + } + FixedNumber.prototype._checkFormat = function (other) { + if (this.format.name !== other.format.name) { + logger$1.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + } + }; + FixedNumber.prototype.addUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.subUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); + }; + FixedNumber.prototype.mulUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); + }; + FixedNumber.prototype.divUnsafe = function (other) { + this._checkFormat(other); + var a = parseFixed(this._value, this.format.decimals); + var b = parseFixed(other._value, other.format.decimals); + return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); + }; + // @TODO: Support other rounding algorithms + FixedNumber.prototype.round = function (decimals) { + if (decimals == null) { + decimals = 0; + } + if (decimals < 0 || decimals > 80 || (decimals % 1)) { + logger$1.throwArgumentError("invalid decimal cound", "decimals", decimals); + } + // If we are already in range, we're done + var comps = this.toString().split("."); + if (comps[1].length <= decimals) { + return this; + } + // Bump the value up by the 0.00...0005 + var bump = "0." + zeros.substring(0, decimals) + "5"; + comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); + // Now it is safe to truncate + return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); + }; + FixedNumber.prototype.toString = function () { return this._value; }; + FixedNumber.prototype.toHexString = function (width) { + if (width == null) { + return this._hex; + } + if (width % 8) { + logger$1.throwArgumentError("invalid byte width", "width", width); + } + var hex = bignumber.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); + return bytes.hexZeroPad(hex, width / 8); + }; + FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; + FixedNumber.prototype.toFormat = function (format) { + return FixedNumber.fromString(this._value, format); + }; + FixedNumber.fromValue = function (value, decimals, format) { + // If decimals looks more like a format, and there is no format, shift the parameters + if (format == null && decimals != null && !bignumber.isBigNumberish(decimals)) { + format = decimals; + decimals = null; + } + if (decimals == null) { + decimals = 0; + } + if (format == null) { + format = "fixed"; + } + return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); + }; + FixedNumber.fromString = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + var numeric = parseFixed(value, fixedFormat.decimals); + if (!fixedFormat.signed && numeric.lt(Zero)) { + throwFault("unsigned value cannot be negative", "overflow", "value", value); + } + var hex = null; + if (fixedFormat.signed) { + hex = numeric.toTwos(fixedFormat.width).toHexString(); + } + else { + hex = numeric.toHexString(); + hex = bytes.hexZeroPad(hex, fixedFormat.width / 8); + } + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.fromBytes = function (value, format) { + if (format == null) { + format = "fixed"; + } + var fixedFormat = FixedFormat.from(format); + if (bytes.arrayify(value).length > fixedFormat.width / 8) { + throw new Error("overflow"); + } + var numeric = bignumber.BigNumber.from(value); + if (fixedFormat.signed) { + numeric = numeric.fromTwos(fixedFormat.width); + } + var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); + var decimal = formatFixed(numeric, fixedFormat.decimals); + return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); + }; + FixedNumber.from = function (value, format) { + if (typeof (value) === "string") { + return FixedNumber.fromString(value, format); + } + if (bytes.isBytes(value)) { + return FixedNumber.fromBytes(value, format); + } + try { + return FixedNumber.fromValue(value, 0, format); + } + catch (error) { + // Allow NUMERIC_FAULT to bubble up + if (error.code !== logger.Logger.errors.INVALID_ARGUMENT) { + throw error; + } + } + return logger$1.throwArgumentError("invalid FixedNumber value", "value", value); + }; + FixedNumber.isFixedNumber = function (value) { + return !!(value && value._isFixedNumber); + }; + return FixedNumber; + }()); + exports.FixedNumber = FixedNumber; + }); + + var fixednumber$1 = unwrapExports(fixednumber); + var fixednumber_1 = fixednumber.formatFixed; + var fixednumber_2 = fixednumber.parseFixed; + var fixednumber_3 = fixednumber.FixedFormat; + var fixednumber_4 = fixednumber.FixedNumber; + + var bignumber$2 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.BigNumber = bignumber.BigNumber; + + exports.FixedNumber = fixednumber.FixedNumber; + }); + + var index$2 = unwrapExports(bignumber$2); + var bignumber_2$1 = bignumber$2.BigNumber; + var bignumber_3 = bignumber$2.FixedNumber; + + var _version$6 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "properties/5.0.0-beta.131"; + }); + + var _version$7 = unwrapExports(_version$6); + var _version_1$3 = _version$6.version; + + var properties = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + var logger$1 = new logger.Logger(_version$6.version); + function defineReadOnly(object, name, value) { + Object.defineProperty(object, name, { + enumerable: true, + value: value, + writable: false, + }); + } + exports.defineReadOnly = defineReadOnly; + // Crawl up the constructor chain to find a static method + function getStatic(ctor, key) { + for (var i = 0; i < 32; i++) { + if (ctor[key]) { + return ctor[key]; + } + if (!ctor.prototype || typeof (ctor.prototype) !== "object") { + break; + } + ctor = Object.getPrototypeOf(ctor.prototype).constructor; + } + return null; + } + exports.getStatic = getStatic; + function resolveProperties(object) { + var promises = Object.keys(object).map(function (key) { + var value = object[key]; + if (!(value instanceof Promise)) { + return Promise.resolve({ key: key, value: value }); + } + return value.then(function (value) { + return { key: key, value: value }; + }); + }); + return Promise.all(promises).then(function (results) { + var result = {}; + return results.reduce(function (accum, result) { + accum[result.key] = result.value; + return accum; + }, result); + }); + } + exports.resolveProperties = resolveProperties; + function checkProperties(object, properties) { + if (!object || typeof (object) !== "object") { + logger$1.throwArgumentError("invalid object", "object", object); + } + Object.keys(object).forEach(function (key) { + if (!properties[key]) { + logger$1.throwArgumentError("invalid object key - " + key, "transaction:" + key, object); + } + }); + } + exports.checkProperties = checkProperties; + function shallowCopy(object) { + var result = {}; + for (var key in object) { + result[key] = object[key]; + } + return result; + } + exports.shallowCopy = shallowCopy; + var opaque = { bigint: true, boolean: true, number: true, string: true }; + // Returns a new copy of object, such that no properties may be replaced. + // New properties may be added only to objects. + function deepCopy(object) { + // Opaque objects are not mutable, so safe to copy by assignment + if (object === undefined || object === null || opaque[typeof (object)]) { + return object; + } + // Arrays are mutable, so we need to create a copy + if (Array.isArray(object)) { + return Object.freeze(object.map(function (item) { return deepCopy(item); })); + } + if (typeof (object) === "object") { + // Immutable objects are safe to just use + if (Object.isFrozen(object)) { + return object; + } + var result = {}; + for (var key in object) { + var value = object[key]; + if (value === undefined) { + continue; + } + defineReadOnly(result, key, deepCopy(value)); + } + return result; + } + // The function type is also immutable, so safe to copy by assignment + if (typeof (object) === "function") { + return object; + } + throw new Error("Cannot deepCopy " + typeof (object)); + } + exports.deepCopy = deepCopy; + var Description = /** @class */ (function () { + function Description(info) { + for (var key in info) { + this[key] = deepCopy(info[key]); + } + Object.freeze(this); + } + return Description; + }()); + exports.Description = Description; + }); + + var index$3 = unwrapExports(properties); + var properties_1 = properties.defineReadOnly; + var properties_2 = properties.getStatic; + var properties_3 = properties.resolveProperties; + var properties_4 = properties.checkProperties; + var properties_5 = properties.shallowCopy; + var properties_6 = properties.deepCopy; + var properties_7 = properties.Description; + + var _version$8 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "abi/5.0.0-beta.137"; + }); + + var _version$9 = unwrapExports(_version$8); + var _version_1$4 = _version$8.version; + + var fragments = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + var logger$1 = new logger.Logger(_version$8.version); + ; + var _constructorGuard = {}; + var ModifiersBytes = { calldata: true, memory: true, storage: true }; + function checkModifier(type, name) { + if (type === "bytes" || type === "string") { + if (ModifiersBytes[name]) { + return true; + } + } + else if (type === "address") { + if (name === "payable") { + return true; + } + } + if (ModifiersBytes[name] || name === "payable") { + logger$1.throwArgumentError("invalid modifier", "name", name); + } + return false; + } + // @TODO: Make sure that children of an indexed tuple are marked with a null indexed + function parseParamType(param, allowIndexed) { + var originalParam = param; + function throwError(i) { + throw new Error("unexpected character '" + originalParam[i] + "' at position " + i + " in '" + originalParam + "'"); + } + param = param.replace(/\s/g, " "); + function newNode(parent) { + var node = { type: "", name: "", parent: parent, state: { allowType: true } }; + if (allowIndexed) { + node.indexed = false; + } + return node; + } + var parent = { type: "", name: "", state: { allowType: true } }; + var node = parent; + for (var i = 0; i < param.length; i++) { + var c = param[i]; + switch (c) { + case "(": + if (!node.state.allowParams) { + throwError(i); + } + node.state.allowType = false; + node.type = verifyType(node.type); + node.components = [newNode(node)]; + node = node.components[0]; + break; + case ")": + delete node.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + if (checkModifier(node.type, node.name)) { + node.name = ""; + } + node.type = verifyType(node.type); + var child = node; + node = node.parent; + if (!node) { + throwError(i); + } + delete child.parent; + node.state.allowParams = false; + node.state.allowName = true; + node.state.allowArray = true; + break; + case ",": + delete node.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + if (checkModifier(node.type, node.name)) { + node.name = ""; + } + node.type = verifyType(node.type); + var sibling = newNode(node.parent); + //{ type: "", name: "", parent: node.parent, state: { allowType: true } }; + node.parent.components.push(sibling); + delete node.parent; + node = sibling; + break; + // Hit a space... + case " ": + // If reading type, the type is done and may read a param or name + if (node.state.allowType) { + if (node.type !== "") { + node.type = verifyType(node.type); + delete node.state.allowType; + node.state.allowName = true; + node.state.allowParams = true; + } + } + // If reading name, the name is done + if (node.state.allowName) { + if (node.name !== "") { + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(i); + } + if (node.indexed) { + throwError(i); + } + node.indexed = true; + node.name = ""; + } + else if (checkModifier(node.type, node.name)) { + node.name = ""; + } + else { + node.state.allowName = false; + } + } + } + break; + case "[": + if (!node.state.allowArray) { + throwError(i); + } + node.type += c; + node.state.allowArray = false; + node.state.allowName = false; + node.state.readArray = true; + break; + case "]": + if (!node.state.readArray) { + throwError(i); + } + node.type += c; + node.state.readArray = false; + node.state.allowArray = true; + node.state.allowName = true; + break; + default: + if (node.state.allowType) { + node.type += c; + node.state.allowParams = true; + node.state.allowArray = true; + } + else if (node.state.allowName) { + node.name += c; + delete node.state.allowArray; + } + else if (node.state.readArray) { + node.type += c; + } + else { + throwError(i); + } + } + } + if (node.parent) { + throw new Error("unexpected eof"); + } + delete parent.state; + if (node.name === "indexed") { + if (!allowIndexed) { + throwError(originalParam.length - 7); + } + if (node.indexed) { + throwError(originalParam.length - 7); + } + node.indexed = true; + node.name = ""; + } + else if (checkModifier(node.type, node.name)) { + node.name = ""; + } + parent.type = verifyType(parent.type); + return parent; + } + function populate(object, params) { + for (var key in params) { + properties.defineReadOnly(object, key, params[key]); + } + } + exports.FormatTypes = Object.freeze({ + // Bare formatting, as is needed for computing a sighash of an event or function + sighash: "sighash", + // Human-Readable with Minimal spacing and without names (compact human-readable) + minimal: "minimal", + // Human-Readble with nice spacing, including all names + full: "full", + // JSON-format a la Solidity + json: "json" + }); + var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); + var ParamType = /** @class */ (function () { + function ParamType(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + throw new Error("use fromString"); + } + populate(this, params); + var match = this.type.match(paramTypeArray); + if (match) { + populate(this, { + arrayLength: parseInt(match[2] || "-1"), + arrayChildren: ParamType.fromObject({ + type: match[1], + components: this.components + }), + baseType: "array" + }); + } + else { + populate(this, { + arrayLength: null, + arrayChildren: null, + baseType: ((this.components != null) ? "tuple" : this.type) + }); + } + this._isParamType = true; + Object.freeze(this); + } + // Format the parameter fragment + // - sighash: "(uint256,address)" + // - minimal: "tuple(uint256,address) indexed" + // - full: "tuple(uint256 foo, addres bar) indexed baz" + ParamType.prototype.format = function (format) { + if (!format) { + format = exports.FormatTypes.sighash; + } + if (!exports.FormatTypes[format]) { + logger$1.throwArgumentError("invalid format type", "format", format); + } + if (format === exports.FormatTypes.json) { + var result_1 = { + type: ((this.baseType === "tuple") ? "tuple" : this.type), + name: (this.name || undefined) + }; + if (typeof (this.indexed) === "boolean") { + result_1.indexed = this.indexed; + } + if (this.components) { + result_1.components = this.components.map(function (comp) { return JSON.parse(comp.format(format)); }); + } + return JSON.stringify(result_1); + } + var result = ""; + // Array + if (this.baseType === "array") { + result += this.arrayChildren.format(format); + result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; + } + else { + if (this.baseType === "tuple") { + if (format !== exports.FormatTypes.sighash) { + result += this.type; + } + result += "(" + this.components.map(function (comp) { return comp.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ")"; + } + else { + result += this.type; + } + } + if (format !== exports.FormatTypes.sighash) { + if (this.indexed === true) { + result += " indexed"; + } + if (format === exports.FormatTypes.full && this.name) { + result += " " + this.name; + } + } + return result; + }; + ParamType.from = function (value, allowIndexed) { + if (typeof (value) === "string") { + return ParamType.fromString(value, allowIndexed); + } + return ParamType.fromObject(value); + }; + ParamType.fromObject = function (value) { + if (ParamType.isParamType(value)) { + return value; + } + return new ParamType(_constructorGuard, { + name: (value.name || null), + type: verifyType(value.type), + indexed: ((value.indexed == null) ? null : !!value.indexed), + components: (value.components ? value.components.map(ParamType.fromObject) : null) + }); + }; + ParamType.fromString = function (value, allowIndexed) { + function ParamTypify(node) { + return ParamType.fromObject({ + name: node.name, + type: node.type, + indexed: node.indexed, + components: node.components + }); + } + return ParamTypify(parseParamType(value, !!allowIndexed)); + }; + ParamType.isParamType = function (value) { + return !!(value != null && value._isParamType); + }; + return ParamType; + }()); + exports.ParamType = ParamType; + ; + function parseParams(value, allowIndex) { + return splitNesting(value).map(function (param) { return ParamType.fromString(param, allowIndex); }); + } + var Fragment = /** @class */ (function () { + function Fragment(constructorGuard, params) { + if (constructorGuard !== _constructorGuard) { + throw new Error("use a static from method"); + } + populate(this, params); + this._isFragment = true; + Object.freeze(this); + } + Fragment.from = function (value) { + if (Fragment.isFragment(value)) { + return value; + } + if (typeof (value) === "string") { + return Fragment.fromString(value); + } + return Fragment.fromObject(value); + }; + Fragment.fromObject = function (value) { + if (Fragment.isFragment(value)) { + return value; + } + if (value.type === "function") { + return FunctionFragment.fromObject(value); + } + else if (value.type === "event") { + return EventFragment.fromObject(value); + } + else if (value.type === "constructor") { + return ConstructorFragment.fromObject(value); + } + else if (value.type === "fallback") { + // @TODO: + return null; + } + return logger$1.throwArgumentError("invalid fragment object", "value", value); + }; + Fragment.fromString = function (value) { + // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space + value = value.replace(/\s/g, " "); + value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); + value = value.trim(); + if (value.split(" ")[0] === "event") { + return EventFragment.fromString(value.substring(5).trim()); + } + else if (value.split(" ")[0] === "function") { + return FunctionFragment.fromString(value.substring(8).trim()); + } + else if (value.split("(")[0].trim() === "constructor") { + return ConstructorFragment.fromString(value.trim()); + } + throw new Error("unknown fragment"); + }; + Fragment.isFragment = function (value) { + return !!(value && value._isFragment); + }; + return Fragment; + }()); + exports.Fragment = Fragment; + var EventFragment = /** @class */ (function (_super) { + __extends(EventFragment, _super); + function EventFragment() { + return _super !== null && _super.apply(this, arguments) || this; + } + EventFragment.prototype.format = function (format) { + if (!format) { + format = exports.FormatTypes.sighash; + } + if (!exports.FormatTypes[format]) { + logger$1.throwArgumentError("invalid format type", "format", format); + } + if (format === exports.FormatTypes.json) { + return JSON.stringify({ + type: "event", + anonymous: this.anonymous, + name: this.name, + inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }) + }); + } + var result = ""; + if (format !== exports.FormatTypes.sighash) { + result += "event "; + } + result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") "; + if (format !== exports.FormatTypes.sighash) { + if (this.anonymous) { + result += "anonymous "; + } + } + return result.trim(); + }; + EventFragment.from = function (value) { + if (typeof (value) === "string") { + return EventFragment.fromString(value); + } + return EventFragment.fromObject(value); + }; + EventFragment.fromObject = function (value) { + if (EventFragment.isEventFragment(value)) { + return value; + } + if (value.type !== "event") { + throw new Error("invalid event object - " + value.type); + } + return new EventFragment(_constructorGuard, { + name: verifyIdentifier(value.name), + anonymous: value.anonymous, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + type: "event" + }); + }; + EventFragment.fromString = function (value) { + var match = value.match(regexParen); + if (!match) { + throw new Error("invalid event: " + value); + } + var anonymous = false; + match[3].split(" ").forEach(function (modifier) { + switch (modifier.trim()) { + case "anonymous": + anonymous = true; + break; + case "": + break; + default: + logger$1.warn("unknown modifier: " + modifier); + } + }); + return EventFragment.fromObject({ + name: match[1].trim(), + anonymous: anonymous, + inputs: parseParams(match[2], true), + type: "event" + }); + }; + EventFragment.isEventFragment = function (value) { + return (value && value._isFragment && value.type === "event"); + }; + return EventFragment; + }(Fragment)); + exports.EventFragment = EventFragment; + function parseGas(value, params) { + params.gas = null; + var comps = value.split("@"); + if (comps.length !== 1) { + if (comps.length > 2) { + throw new Error("invalid signature"); + } + if (!comps[1].match(/^[0-9]+$/)) { + throw new Error("invalid signature gas"); + } + params.gas = bignumber$2.BigNumber.from(comps[1]); + return comps[0]; + } + return value; + } + function parseModifiers(value, params) { + params.constant = false; + params.payable = false; + params.stateMutability = "nonpayable"; + value.split(" ").forEach(function (modifier) { + switch (modifier.trim()) { + case "constant": + params.constant = true; + break; + case "payable": + params.payable = true; + params.stateMutability = "payable"; + break; + case "pure": + params.constant = true; + params.stateMutability = "pure"; + break; + case "view": + params.constant = true; + params.stateMutability = "view"; + break; + case "external": + case "public": + case "": + break; + default: + console.log("unknown modifier: " + modifier); + } + }); + } + function verifyState(value) { + var result = { + constant: false, + payable: true, + stateMutability: "payable" + }; + if (value.stateMutability != null) { + result.stateMutability = value.stateMutability; + result.constant = (result.stateMutability === "view" || result.stateMutability === "pure"); + if (value.constant != null) { + if ((!!value.constant) !== result.constant) { + throw new Error("cannot have constant function with mutability " + result.stateMutability); + } + } + result.payable = (result.stateMutability === "payable"); + if (value.payable != null) { + if ((!!value.payable) !== result.payable) { + throw new Error("cannot have payable function with mutability " + result.stateMutability); + } + } + } + else if (value.payable != null) { + result.payable = !!value.payable; + result.stateMutability = (result.payable ? "payable" : "nonpayable"); + result.constant = !result.payable; + if (value.constant != null && (value.constant !== result.constant)) { + throw new Error("cannot have constant payable function"); + } + } + else if (value.constant != null) { + result.constant = !!value.constant; + result.payable = !result.constant; + result.stateMutability = (result.constant ? "view" : "payable"); + } + return result; + } + var ConstructorFragment = /** @class */ (function (_super) { + __extends(ConstructorFragment, _super); + function ConstructorFragment() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConstructorFragment.prototype.format = function (format) { + if (!format) { + format = exports.FormatTypes.sighash; + } + if (!exports.FormatTypes[format]) { + logger$1.throwArgumentError("invalid format type", "format", format); + } + if (format === exports.FormatTypes.json) { + return JSON.stringify({ + type: "constructor", + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payble: this.payable, + gas: (this.gas ? this.gas.toNumber() : undefined), + inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }) + }); + } + if (format === exports.FormatTypes.sighash) { + logger$1.throwError("cannot format a constructor for sighash", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "format(sighash)" + }); + } + var result = "constructor(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") "; + if (this.stateMutability && this.stateMutability !== "nonpayable") { + result += this.stateMutability + " "; + } + return result.trim(); + }; + ConstructorFragment.from = function (value) { + if (typeof (value) === "string") { + return ConstructorFragment.fromString(value); + } + return ConstructorFragment.fromObject(value); + }; + ConstructorFragment.fromObject = function (value) { + if (ConstructorFragment.isConstructorFragment(value)) { + return value; + } + if (value.type !== "constructor") { + throw new Error("invalid constructor object - " + value.type); + } + var state = verifyState(value); + if (state.constant) { + throw new Error("constructor cannot be constant"); + } + return new ConstructorFragment(_constructorGuard, { + type: value.type, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + payable: state.payable, + gas: (value.gas ? bignumber$2.BigNumber.from(value.gas) : null) + }); + }; + ConstructorFragment.fromString = function (value) { + var params = { type: "constructor" }; + value = parseGas(value, params); + var parens = value.match(regexParen); + if (!parens) { + throw new Error("invalid constructor: " + value); + } + if (parens[1].trim() !== "constructor") { + throw new Error("invalid constructor"); + } + params.inputs = parseParams(parens[2].trim(), false); + parseModifiers(parens[3].trim(), params); + return ConstructorFragment.fromObject(params); + }; + ConstructorFragment.isConstructorFragment = function (value) { + return (value && value._isFragment && value.type === "constructor"); + }; + return ConstructorFragment; + }(Fragment)); + exports.ConstructorFragment = ConstructorFragment; + var FunctionFragment = /** @class */ (function (_super) { + __extends(FunctionFragment, _super); + function FunctionFragment() { + return _super !== null && _super.apply(this, arguments) || this; + } + FunctionFragment.prototype.format = function (format) { + if (!format) { + format = exports.FormatTypes.sighash; + } + if (!exports.FormatTypes[format]) { + logger$1.throwArgumentError("invalid format type", "format", format); + } + if (format === exports.FormatTypes.json) { + return JSON.stringify({ + type: "function", + name: this.name, + constant: this.constant, + stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), + payble: this.payable, + gas: (this.gas ? this.gas.toNumber() : undefined), + inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }), + ouputs: this.outputs.map(function (output) { return JSON.parse(output.format(format)); }), + }); + } + var result = ""; + if (format !== exports.FormatTypes.sighash) { + result += "function "; + } + result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") "; + if (format !== exports.FormatTypes.sighash) { + if (this.stateMutability) { + if (this.stateMutability !== "nonpayable") { + result += (this.stateMutability + " "); + } + } + else if (this.constant) { + result += "view "; + } + if (this.outputs && this.outputs.length) { + result += "returns (" + this.outputs.map(function (output) { return output.format(format); }).join(", ") + ") "; + } + if (this.gas != null) { + result += "@" + this.gas.toString() + " "; + } + } + return result.trim(); + }; + FunctionFragment.from = function (value) { + if (typeof (value) === "string") { + return FunctionFragment.fromString(value); + } + return FunctionFragment.fromObject(value); + }; + FunctionFragment.fromObject = function (value) { + if (FunctionFragment.isFunctionFragment(value)) { + return value; + } + if (value.type !== "function") { + throw new Error("invalid function object - " + value.type); + } + var state = verifyState(value); + return new FunctionFragment(_constructorGuard, { + type: value.type, + name: verifyIdentifier(value.name), + constant: state.constant, + inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), + outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []), + payable: state.payable, + stateMutability: state.stateMutability, + gas: (value.gas ? bignumber$2.BigNumber.from(value.gas) : null) + }); + }; + FunctionFragment.fromString = function (value) { + var params = { type: "function" }; + value = parseGas(value, params); + var comps = value.split(" returns "); + if (comps.length > 2) { + throw new Error("invalid function"); + } + var parens = comps[0].match(regexParen); + if (!parens) { + throw new Error("invalid signature"); + } + params.name = parens[1].trim(); + if (!params.name.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + params.name + "'"); + } + params.inputs = parseParams(parens[2], false); + parseModifiers(parens[3].trim(), params); + // We have outputs + if (comps.length > 1) { + var returns = comps[1].match(regexParen); + if (returns[1].trim() != "" || returns[3].trim() != "") { + throw new Error("unexpected tokens"); + } + params.outputs = parseParams(returns[2], false); + } + else { + params.outputs = []; + } + return FunctionFragment.fromObject(params); + }; + FunctionFragment.isFunctionFragment = function (value) { + return (value && value._isFragment && value.type === "function"); + }; + return FunctionFragment; + }(ConstructorFragment)); + exports.FunctionFragment = FunctionFragment; + //export class ErrorFragment extends Fragment { + //} + //export class StructFragment extends Fragment { + //} + function verifyType(type) { + // These need to be transformed to their full description + if (type.match(/^uint($|[^1-9])/)) { + type = "uint256" + type.substring(4); + } + else if (type.match(/^int($|[^1-9])/)) { + type = "int256" + type.substring(3); + } + // @TODO: more verification + return type; + } + var regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); + function verifyIdentifier(value) { + if (!value || !value.match(regexIdentifier)) { + throw new Error("invalid identifier: '" + value + "'"); + } + return value; + } + var regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); + function splitNesting(value) { + value = value.trim(); + var result = []; + var accum = ""; + var depth = 0; + for (var offset = 0; offset < value.length; offset++) { + var c = value[offset]; + if (c === "," && depth === 0) { + result.push(accum); + accum = ""; + } + else { + accum += c; + if (c === "(") { + depth++; + } + else if (c === ")") { + depth--; + if (depth === -1) { + throw new Error("unbalanced parenthsis"); + } + } + } + } + if (accum) { + result.push(accum); + } + return result; + } + }); + + var fragments$1 = unwrapExports(fragments); + var fragments_1 = fragments.FormatTypes; + var fragments_2 = fragments.ParamType; + var fragments_3 = fragments.Fragment; + var fragments_4 = fragments.EventFragment; + var fragments_5 = fragments.ConstructorFragment; + var fragments_6 = fragments.FunctionFragment; + + var abstractCoder = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + var logger$1 = new logger.Logger(_version$8.version); + var Coder = /** @class */ (function () { + function Coder(name, type, localName, dynamic) { + this.name = name; + this.type = type; + this.localName = localName; + this.dynamic = dynamic; + } + Coder.prototype._throwError = function (message, value) { + logger$1.throwArgumentError(message, this.localName, value); + }; + return Coder; + }()); + exports.Coder = Coder; + var Writer = /** @class */ (function () { + function Writer(wordSize) { + properties.defineReadOnly(this, "wordSize", wordSize || 32); + this._data = bytes.arrayify([]); + this._padding = new Uint8Array(wordSize); + } + Object.defineProperty(Writer.prototype, "data", { + get: function () { return bytes.hexlify(this._data); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Writer.prototype, "length", { + get: function () { return this._data.length; }, + enumerable: true, + configurable: true + }); + Writer.prototype._writeData = function (data) { + this._data = bytes.concat([this._data, data]); + return data.length; + }; + // Arrayish items; padded on the right to wordSize + Writer.prototype.writeBytes = function (value) { + var bytes$1 = bytes.arrayify(value); + if (bytes$1.length % this.wordSize) { + bytes$1 = bytes.concat([bytes$1, this._padding.slice(bytes$1.length % this.wordSize)]); + } + return this._writeData(bytes$1); + }; + Writer.prototype._getValue = function (value) { + var bytes$1 = bytes.arrayify(bignumber$2.BigNumber.from(value)); + if (bytes$1.length > this.wordSize) { + logger$1.throwError("value out-of-bounds", logger.Logger.errors.BUFFER_OVERRUN, { + length: this.wordSize, + offset: bytes$1.length + }); + } + if (bytes$1.length % this.wordSize) { + bytes$1 = bytes.concat([this._padding.slice(bytes$1.length % this.wordSize), bytes$1]); + } + return bytes$1; + }; + // BigNumberish items; padded on the left to wordSize + Writer.prototype.writeValue = function (value) { + return this._writeData(this._getValue(value)); + }; + Writer.prototype.writeUpdatableValue = function () { + var _this = this; + var offset = this.length; + this.writeValue(0); + return function (value) { + _this._data.set(_this._getValue(value), offset); + }; + }; + return Writer; + }()); + exports.Writer = Writer; + var Reader = /** @class */ (function () { + function Reader(data, wordSize, coerceFunc) { + properties.defineReadOnly(this, "_data", bytes.arrayify(data)); + properties.defineReadOnly(this, "wordSize", wordSize || 32); + properties.defineReadOnly(this, "_coerceFunc", coerceFunc); + this._offset = 0; + } + Object.defineProperty(Reader.prototype, "data", { + get: function () { return bytes.hexlify(this._data); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Reader.prototype, "consumed", { + get: function () { return this._offset; }, + enumerable: true, + configurable: true + }); + // The default Coerce function + Reader.coerce = function (name, value) { + var match = name.match("^u?int([0-9]+)$"); + if (match && parseInt(match[1]) <= 48) { + value = value.toNumber(); + } + return value; + }; + Reader.prototype.coerce = function (name, value) { + if (this._coerceFunc) { + return this._coerceFunc(name, value); + } + return Reader.coerce(name, value); + }; + Reader.prototype._peekBytes = function (offset, length) { + var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; + if (this._offset + alignedLength > this._data.length) { + logger$1.throwError("data out-of-bounds", logger.Logger.errors.BUFFER_OVERRUN, { + length: this._data.length, + offset: this._offset + alignedLength + }); + } + return this._data.slice(this._offset, this._offset + alignedLength); + }; + Reader.prototype.subReader = function (offset) { + return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); + }; + Reader.prototype.readBytes = function (length) { + var bytes = this._peekBytes(0, length); + this._offset += bytes.length; + // @TODO: Make sure the length..end bytes are all 0? + return bytes.slice(0, length); + }; + Reader.prototype.readValue = function () { + return bignumber$2.BigNumber.from(this.readBytes(this.wordSize)); + }; + return Reader; + }()); + exports.Reader = Reader; + }); + + var abstractCoder$1 = unwrapExports(abstractCoder); + var abstractCoder_1 = abstractCoder.Coder; + var abstractCoder_2 = abstractCoder.Writer; + var abstractCoder_3 = abstractCoder.Reader; + + var sha3 = createCommonjsModule(function (module) { + /** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.5.7 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2016 + * @license MIT + */ + /*jslint bitwise: true */ + (function () { + 'use strict'; + + var root = typeof window === 'object' ? window : {}; + var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; + if (NODE_JS) { + root = commonjsGlobal; + } + var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && 'object' === 'object' && module.exports; + var HEX_CHARS = '0123456789abcdef'.split(''); + var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; + var KECCAK_PADDING = [1, 256, 65536, 16777216]; + var PADDING = [6, 1536, 393216, 100663296]; + var SHIFT = [0, 8, 16, 24]; + var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, + 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, + 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, + 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, + 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; + var BITS = [224, 256, 384, 512]; + var SHAKE_BITS = [128, 256]; + var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array']; + + var createOutputMethod = function (bits, padding, outputType) { + return function (message) { + return new Keccak(bits, padding, bits).update(message)[outputType](); + }; + }; + + var createShakeOutputMethod = function (bits, padding, outputType) { + return function (message, outputBits) { + return new Keccak(bits, padding, outputBits).update(message)[outputType](); + }; + }; + + var createMethod = function (bits, padding) { + var method = createOutputMethod(bits, padding, 'hex'); + method.create = function () { + return new Keccak(bits, padding, bits); + }; + method.update = function (message) { + return method.create().update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createOutputMethod(bits, padding, type); + } + return method; + }; + + var createShakeMethod = function (bits, padding) { + var method = createShakeOutputMethod(bits, padding, 'hex'); + method.create = function (outputBits) { + return new Keccak(bits, padding, outputBits); + }; + method.update = function (message, outputBits) { + return method.create(outputBits).update(message); + }; + for (var i = 0; i < OUTPUT_TYPES.length; ++i) { + var type = OUTPUT_TYPES[i]; + method[type] = createShakeOutputMethod(bits, padding, type); + } + return method; + }; + + var algorithms = [ + {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod}, + {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod}, + {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod} + ]; + + var methods = {}, methodNames = []; + + for (var i = 0; i < algorithms.length; ++i) { + var algorithm = algorithms[i]; + var bits = algorithm.bits; + for (var j = 0; j < bits.length; ++j) { + var methodName = algorithm.name +'_' + bits[j]; + methodNames.push(methodName); + methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); + } + } + + function Keccak(bits, padding, outputBits) { + this.blocks = []; + this.s = []; + this.padding = padding; + this.outputBits = outputBits; + this.reset = true; + this.block = 0; + this.start = 0; + this.blockCount = (1600 - (bits << 1)) >> 5; + this.byteCount = this.blockCount << 2; + this.outputBlocks = outputBits >> 5; + this.extraBytes = (outputBits & 31) >> 3; + + for (var i = 0; i < 50; ++i) { + this.s[i] = 0; + } + } + + Keccak.prototype.update = function (message) { + var notString = typeof message !== 'string'; + if (notString && message.constructor === ArrayBuffer) { + message = new Uint8Array(message); + } + var length = message.length, blocks = this.blocks, byteCount = this.byteCount, + blockCount = this.blockCount, index = 0, s = this.s, i, code; + + while (index < length) { + if (this.reset) { + this.reset = false; + blocks[0] = this.block; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + if (notString) { + for (i = this.start; index < length && i < byteCount; ++index) { + blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; + } + } else { + for (i = this.start; index < length && i < byteCount; ++index) { + code = message.charCodeAt(index); + if (code < 0x80) { + blocks[i >> 2] |= code << SHIFT[i++ & 3]; + } else if (code < 0x800) { + blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else if (code < 0xd800 || code >= 0xe000) { + blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } else { + code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); + blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; + blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; + } + } + } + this.lastByteIndex = i; + if (i >= byteCount) { + this.start = i - byteCount; + this.block = blocks[blockCount]; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + this.reset = true; + } else { + this.start = i; + } + } + return this; + }; + + Keccak.prototype.finalize = function () { + var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; + blocks[i >> 2] |= this.padding[i & 3]; + if (this.lastByteIndex === this.byteCount) { + blocks[0] = blocks[blockCount]; + for (i = 1; i < blockCount + 1; ++i) { + blocks[i] = 0; + } + } + blocks[blockCount - 1] |= 0x80000000; + for (i = 0; i < blockCount; ++i) { + s[i] ^= blocks[i]; + } + f(s); + }; + + Keccak.prototype.toString = Keccak.prototype.hex = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var hex = '', block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + block = s[i]; + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + + HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + + HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + + HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; + } + if (j % blockCount === 0) { + f(s); + i = 0; + } + } + if (extraBytes) { + block = s[i]; + if (extraBytes > 0) { + hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; + } + if (extraBytes > 1) { + hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; + } + if (extraBytes > 2) { + hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; + } + } + return hex; + }; + + Keccak.prototype.arrayBuffer = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var bytes = this.outputBits >> 3; + var buffer; + if (extraBytes) { + buffer = new ArrayBuffer((outputBlocks + 1) << 2); + } else { + buffer = new ArrayBuffer(bytes); + } + var array = new Uint32Array(buffer); + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + array[j] = s[i]; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + array[i] = s[i]; + buffer = buffer.slice(0, bytes); + } + return buffer; + }; + + Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; + + Keccak.prototype.digest = Keccak.prototype.array = function () { + this.finalize(); + + var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, + extraBytes = this.extraBytes, i = 0, j = 0; + var array = [], offset, block; + while (j < outputBlocks) { + for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { + offset = j << 2; + block = s[i]; + array[offset] = block & 0xFF; + array[offset + 1] = (block >> 8) & 0xFF; + array[offset + 2] = (block >> 16) & 0xFF; + array[offset + 3] = (block >> 24) & 0xFF; + } + if (j % blockCount === 0) { + f(s); + } + } + if (extraBytes) { + offset = j << 2; + block = s[i]; + if (extraBytes > 0) { + array[offset] = block & 0xFF; + } + if (extraBytes > 1) { + array[offset + 1] = (block >> 8) & 0xFF; + } + if (extraBytes > 2) { + array[offset + 2] = (block >> 16) & 0xFF; + } + } + return array; + }; + + var f = function (s) { + var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, + b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, + b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, + b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; + for (n = 0; n < 48; n += 2) { + c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; + c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; + c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; + c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; + c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; + c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; + c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; + c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; + c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; + c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; + + h = c8 ^ ((c2 << 1) | (c3 >>> 31)); + l = c9 ^ ((c3 << 1) | (c2 >>> 31)); + s[0] ^= h; + s[1] ^= l; + s[10] ^= h; + s[11] ^= l; + s[20] ^= h; + s[21] ^= l; + s[30] ^= h; + s[31] ^= l; + s[40] ^= h; + s[41] ^= l; + h = c0 ^ ((c4 << 1) | (c5 >>> 31)); + l = c1 ^ ((c5 << 1) | (c4 >>> 31)); + s[2] ^= h; + s[3] ^= l; + s[12] ^= h; + s[13] ^= l; + s[22] ^= h; + s[23] ^= l; + s[32] ^= h; + s[33] ^= l; + s[42] ^= h; + s[43] ^= l; + h = c2 ^ ((c6 << 1) | (c7 >>> 31)); + l = c3 ^ ((c7 << 1) | (c6 >>> 31)); + s[4] ^= h; + s[5] ^= l; + s[14] ^= h; + s[15] ^= l; + s[24] ^= h; + s[25] ^= l; + s[34] ^= h; + s[35] ^= l; + s[44] ^= h; + s[45] ^= l; + h = c4 ^ ((c8 << 1) | (c9 >>> 31)); + l = c5 ^ ((c9 << 1) | (c8 >>> 31)); + s[6] ^= h; + s[7] ^= l; + s[16] ^= h; + s[17] ^= l; + s[26] ^= h; + s[27] ^= l; + s[36] ^= h; + s[37] ^= l; + s[46] ^= h; + s[47] ^= l; + h = c6 ^ ((c0 << 1) | (c1 >>> 31)); + l = c7 ^ ((c1 << 1) | (c0 >>> 31)); + s[8] ^= h; + s[9] ^= l; + s[18] ^= h; + s[19] ^= l; + s[28] ^= h; + s[29] ^= l; + s[38] ^= h; + s[39] ^= l; + s[48] ^= h; + s[49] ^= l; + + b0 = s[0]; + b1 = s[1]; + b32 = (s[11] << 4) | (s[10] >>> 28); + b33 = (s[10] << 4) | (s[11] >>> 28); + b14 = (s[20] << 3) | (s[21] >>> 29); + b15 = (s[21] << 3) | (s[20] >>> 29); + b46 = (s[31] << 9) | (s[30] >>> 23); + b47 = (s[30] << 9) | (s[31] >>> 23); + b28 = (s[40] << 18) | (s[41] >>> 14); + b29 = (s[41] << 18) | (s[40] >>> 14); + b20 = (s[2] << 1) | (s[3] >>> 31); + b21 = (s[3] << 1) | (s[2] >>> 31); + b2 = (s[13] << 12) | (s[12] >>> 20); + b3 = (s[12] << 12) | (s[13] >>> 20); + b34 = (s[22] << 10) | (s[23] >>> 22); + b35 = (s[23] << 10) | (s[22] >>> 22); + b16 = (s[33] << 13) | (s[32] >>> 19); + b17 = (s[32] << 13) | (s[33] >>> 19); + b48 = (s[42] << 2) | (s[43] >>> 30); + b49 = (s[43] << 2) | (s[42] >>> 30); + b40 = (s[5] << 30) | (s[4] >>> 2); + b41 = (s[4] << 30) | (s[5] >>> 2); + b22 = (s[14] << 6) | (s[15] >>> 26); + b23 = (s[15] << 6) | (s[14] >>> 26); + b4 = (s[25] << 11) | (s[24] >>> 21); + b5 = (s[24] << 11) | (s[25] >>> 21); + b36 = (s[34] << 15) | (s[35] >>> 17); + b37 = (s[35] << 15) | (s[34] >>> 17); + b18 = (s[45] << 29) | (s[44] >>> 3); + b19 = (s[44] << 29) | (s[45] >>> 3); + b10 = (s[6] << 28) | (s[7] >>> 4); + b11 = (s[7] << 28) | (s[6] >>> 4); + b42 = (s[17] << 23) | (s[16] >>> 9); + b43 = (s[16] << 23) | (s[17] >>> 9); + b24 = (s[26] << 25) | (s[27] >>> 7); + b25 = (s[27] << 25) | (s[26] >>> 7); + b6 = (s[36] << 21) | (s[37] >>> 11); + b7 = (s[37] << 21) | (s[36] >>> 11); + b38 = (s[47] << 24) | (s[46] >>> 8); + b39 = (s[46] << 24) | (s[47] >>> 8); + b30 = (s[8] << 27) | (s[9] >>> 5); + b31 = (s[9] << 27) | (s[8] >>> 5); + b12 = (s[18] << 20) | (s[19] >>> 12); + b13 = (s[19] << 20) | (s[18] >>> 12); + b44 = (s[29] << 7) | (s[28] >>> 25); + b45 = (s[28] << 7) | (s[29] >>> 25); + b26 = (s[38] << 8) | (s[39] >>> 24); + b27 = (s[39] << 8) | (s[38] >>> 24); + b8 = (s[48] << 14) | (s[49] >>> 18); + b9 = (s[49] << 14) | (s[48] >>> 18); + + s[0] = b0 ^ (~b2 & b4); + s[1] = b1 ^ (~b3 & b5); + s[10] = b10 ^ (~b12 & b14); + s[11] = b11 ^ (~b13 & b15); + s[20] = b20 ^ (~b22 & b24); + s[21] = b21 ^ (~b23 & b25); + s[30] = b30 ^ (~b32 & b34); + s[31] = b31 ^ (~b33 & b35); + s[40] = b40 ^ (~b42 & b44); + s[41] = b41 ^ (~b43 & b45); + s[2] = b2 ^ (~b4 & b6); + s[3] = b3 ^ (~b5 & b7); + s[12] = b12 ^ (~b14 & b16); + s[13] = b13 ^ (~b15 & b17); + s[22] = b22 ^ (~b24 & b26); + s[23] = b23 ^ (~b25 & b27); + s[32] = b32 ^ (~b34 & b36); + s[33] = b33 ^ (~b35 & b37); + s[42] = b42 ^ (~b44 & b46); + s[43] = b43 ^ (~b45 & b47); + s[4] = b4 ^ (~b6 & b8); + s[5] = b5 ^ (~b7 & b9); + s[14] = b14 ^ (~b16 & b18); + s[15] = b15 ^ (~b17 & b19); + s[24] = b24 ^ (~b26 & b28); + s[25] = b25 ^ (~b27 & b29); + s[34] = b34 ^ (~b36 & b38); + s[35] = b35 ^ (~b37 & b39); + s[44] = b44 ^ (~b46 & b48); + s[45] = b45 ^ (~b47 & b49); + s[6] = b6 ^ (~b8 & b0); + s[7] = b7 ^ (~b9 & b1); + s[16] = b16 ^ (~b18 & b10); + s[17] = b17 ^ (~b19 & b11); + s[26] = b26 ^ (~b28 & b20); + s[27] = b27 ^ (~b29 & b21); + s[36] = b36 ^ (~b38 & b30); + s[37] = b37 ^ (~b39 & b31); + s[46] = b46 ^ (~b48 & b40); + s[47] = b47 ^ (~b49 & b41); + s[8] = b8 ^ (~b0 & b2); + s[9] = b9 ^ (~b1 & b3); + s[18] = b18 ^ (~b10 & b12); + s[19] = b19 ^ (~b11 & b13); + s[28] = b28 ^ (~b20 & b22); + s[29] = b29 ^ (~b21 & b23); + s[38] = b38 ^ (~b30 & b32); + s[39] = b39 ^ (~b31 & b33); + s[48] = b48 ^ (~b40 & b42); + s[49] = b49 ^ (~b41 & b43); + + s[0] ^= RC[n]; + s[1] ^= RC[n + 1]; + } + }; + + if (COMMON_JS) { + module.exports = methods; + } else { + for (var i = 0; i < methodNames.length; ++i) { + root[methodNames[i]] = methods[methodNames[i]]; + } + } + })(); + }); + + var keccak256_1 = createCommonjsModule(function (module, exports) { + "use strict"; + var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var js_sha3_1 = __importDefault(sha3); + + function keccak256(data) { + return '0x' + js_sha3_1.default.keccak_256(bytes.arrayify(data)); + } + exports.keccak256 = keccak256; + }); + + var index$4 = unwrapExports(keccak256_1); + var keccak256_2 = keccak256_1.keccak256; + + var rlp = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + //See: https://github.com/ethereum/wiki/wiki/RLP + + function arrayifyInteger(value) { + var result = []; + while (value) { + result.unshift(value & 0xff); + value >>= 8; + } + return result; + } + function unarrayifyInteger(data, offset, length) { + var result = 0; + for (var i = 0; i < length; i++) { + result = (result * 256) + data[offset + i]; + } + return result; + } + function _encode(object) { + if (Array.isArray(object)) { + var payload_1 = []; + object.forEach(function (child) { + payload_1 = payload_1.concat(_encode(child)); + }); + if (payload_1.length <= 55) { + payload_1.unshift(0xc0 + payload_1.length); + return payload_1; + } + var length_1 = arrayifyInteger(payload_1.length); + length_1.unshift(0xf7 + length_1.length); + return length_1.concat(payload_1); + } + var data = Array.prototype.slice.call(bytes.arrayify(object)); + if (data.length === 1 && data[0] <= 0x7f) { + return data; + } + else if (data.length <= 55) { + data.unshift(0x80 + data.length); + return data; + } + var length = arrayifyInteger(data.length); + length.unshift(0xb7 + length.length); + return length.concat(data); + } + function encode(object) { + return bytes.hexlify(_encode(object)); + } + exports.encode = encode; + function _decodeChildren(data, offset, childOffset, length) { + var result = []; + while (childOffset < offset + 1 + length) { + var decoded = _decode(data, childOffset); + result.push(decoded.result); + childOffset += decoded.consumed; + if (childOffset > offset + 1 + length) { + throw new Error("invalid rlp"); + } + } + return { consumed: (1 + length), result: result }; + } + // returns { consumed: number, result: Object } + function _decode(data, offset) { + if (data.length === 0) { + throw new Error("invalid rlp data"); + } + // Array with extra length prefix + if (data[offset] >= 0xf8) { + var lengthLength = data[offset] - 0xf7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("too short"); + } + var length_2 = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length_2 > data.length) { + throw new Error("to short"); + } + return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length_2); + } + else if (data[offset] >= 0xc0) { + var length_3 = data[offset] - 0xc0; + if (offset + 1 + length_3 > data.length) { + throw new Error("invalid rlp data"); + } + return _decodeChildren(data, offset, offset + 1, length_3); + } + else if (data[offset] >= 0xb8) { + var lengthLength = data[offset] - 0xb7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("invalid rlp data"); + } + var length_4 = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length_4 > data.length) { + throw new Error("invalid rlp data"); + } + var result = bytes.hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4)); + return { consumed: (1 + lengthLength + length_4), result: result }; + } + else if (data[offset] >= 0x80) { + var length_5 = data[offset] - 0x80; + if (offset + 1 + length_5 > data.length) { + throw new Error("invlaid rlp data"); + } + var result = bytes.hexlify(data.slice(offset + 1, offset + 1 + length_5)); + return { consumed: (1 + length_5), result: result }; + } + return { consumed: 1, result: bytes.hexlify(data[offset]) }; + } + function decode(data) { + var bytes$1 = bytes.arrayify(data); + var decoded = _decode(bytes$1, 0); + if (decoded.consumed !== bytes$1.length) { + throw new Error("invalid rlp data"); + } + return decoded.result; + } + exports.decode = decode; + }); + + var index$5 = unwrapExports(rlp); + var rlp_1 = rlp.encode; + var rlp_2 = rlp.decode; + + var _version$a = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "address/5.0.0-beta.128"; + }); + + var _version$b = unwrapExports(_version$a); + var _version_1$5 = _version$a.version; + + var address = createCommonjsModule(function (module, exports) { + "use strict"; + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + // We use this for base 36 maths + var BN = __importStar(bn); + + + + + + var logger$1 = new logger.Logger(_version$a.version); + function getChecksumAddress(address) { + if (!bytes.isHexString(address, 20)) { + logger$1.throwArgumentError("invalid address", "address", address); + } + address = address.toLowerCase(); + var chars = address.substring(2).split(""); + var hashed = new Uint8Array(40); + for (var i = 0; i < 40; i++) { + hashed[i] = chars[i].charCodeAt(0); + } + hashed = bytes.arrayify(keccak256_1.keccak256(hashed)); + for (var i = 0; i < 40; i += 2) { + if ((hashed[i >> 1] >> 4) >= 8) { + chars[i] = chars[i].toUpperCase(); + } + if ((hashed[i >> 1] & 0x0f) >= 8) { + chars[i + 1] = chars[i + 1].toUpperCase(); + } + } + return "0x" + chars.join(""); + } + // Shims for environments that are missing some required constants and functions + var MAX_SAFE_INTEGER = 0x1fffffffffffff; + function log10(x) { + if (Math.log10) { + return Math.log10(x); + } + return Math.log(x) / Math.LN10; + } + // See: https://en.wikipedia.org/wiki/International_Bank_Account_Number + // Create lookup table + var ibanLookup = {}; + for (var i = 0; i < 10; i++) { + ibanLookup[String(i)] = String(i); + } + for (var i = 0; i < 26; i++) { + ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); + } + // How many decimal digits can we process? (for 64-bit float, this is 15) + var safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); + function ibanChecksum(address) { + address = address.toUpperCase(); + address = address.substring(4) + address.substring(0, 2) + "00"; + var expanded = ""; + address.split("").forEach(function (c) { + expanded += ibanLookup[c]; + }); + // Javascript can handle integers safely up to 15 (decimal) digits + while (expanded.length >= safeDigits) { + var block = expanded.substring(0, safeDigits); + expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); + } + var checksum = String(98 - (parseInt(expanded, 10) % 97)); + while (checksum.length < 2) { + checksum = "0" + checksum; + } + return checksum; + } + ; + function getAddress(address) { + var result = null; + if (typeof (address) !== "string") { + logger$1.throwArgumentError("invalid address", "address", address); + } + if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { + // Missing the 0x prefix + if (address.substring(0, 2) !== "0x") { + address = "0x" + address; + } + result = getChecksumAddress(address); + // It is a checksummed address with a bad checksum + if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { + logger$1.throwArgumentError("bad address checksum", "address", address); + } + // Maybe ICAP? (we only support direct mode) + } + else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { + // It is an ICAP address with a bad checksum + if (address.substring(2, 4) !== ibanChecksum(address)) { + logger$1.throwArgumentError("bad icap checksum", "address", address); + } + result = (new BN.BN(address.substring(4), 36)).toString(16); + while (result.length < 40) { + result = "0" + result; + } + result = getChecksumAddress("0x" + result); + } + else { + logger$1.throwArgumentError("invalid address", "address", address); + } + return result; + } + exports.getAddress = getAddress; + function isAddress(address) { + try { + getAddress(address); + return true; + } + catch (error) { } + return false; + } + exports.isAddress = isAddress; + function getIcapAddress(address) { + var base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + while (base36.length < 30) { + base36 = "0" + base36; + } + return "XE" + ibanChecksum("XE00" + base36) + base36; + } + exports.getIcapAddress = getIcapAddress; + // http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed + function getContractAddress(transaction) { + var from = null; + try { + from = getAddress(transaction.from); + } + catch (error) { + logger$1.throwArgumentError("missing from address", "transaction", transaction); + } + var nonce = bytes.stripZeros(bytes.arrayify(transaction.nonce)); + return getAddress(bytes.hexDataSlice(keccak256_1.keccak256(rlp.encode([from, nonce])), 12)); + } + exports.getContractAddress = getContractAddress; + }); + + var index$6 = unwrapExports(address); + var address_1 = address.getAddress; + var address_2 = address.isAddress; + var address_3 = address.getIcapAddress; + var address_4 = address.getContractAddress; + + var address$1 = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var AddressCoder = /** @class */ (function (_super) { + __extends(AddressCoder, _super); + function AddressCoder(localName) { + return _super.call(this, "address", "address", localName, false) || this; + } + AddressCoder.prototype.encode = function (writer, value) { + try { + address.getAddress(value); + } + catch (error) { + this._throwError(error.message, value); + } + return writer.writeValue(value); + }; + AddressCoder.prototype.decode = function (reader) { + return address.getAddress(bytes.hexZeroPad(reader.readValue().toHexString(), 20)); + }; + return AddressCoder; + }(abstractCoder.Coder)); + exports.AddressCoder = AddressCoder; + }); + + var address$2 = unwrapExports(address$1); + var address_2$1 = address$1.AddressCoder; + + var anonymous = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + // Clones the functionality of an existing Coder, but without a localName + var AnonymousCoder = /** @class */ (function (_super) { + __extends(AnonymousCoder, _super); + function AnonymousCoder(coder) { + var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this; + _this.coder = coder; + return _this; + } + AnonymousCoder.prototype.encode = function (writer, value) { + return this.coder.encode(writer, value); + }; + AnonymousCoder.prototype.decode = function (reader) { + return this.coder.decode(reader); + }; + return AnonymousCoder; + }(abstractCoder.Coder)); + exports.AnonymousCoder = AnonymousCoder; + }); + + var anonymous$1 = unwrapExports(anonymous); + var anonymous_1 = anonymous.AnonymousCoder; + + var array = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + var logger$1 = new logger.Logger(_version$8.version); + + + function pack(writer, coders, values) { + if (Array.isArray(values)) { + // do nothing + } + else if (values && typeof (values) === "object") { + var arrayValues_1 = []; + coders.forEach(function (coder) { + arrayValues_1.push(values[coder.localName]); + }); + values = arrayValues_1; + } + else { + logger$1.throwArgumentError("invalid tuple value", "tuple", values); + } + if (coders.length !== values.length) { + logger$1.throwArgumentError("types/value length mismatch", "tuple", values); + } + var staticWriter = new abstractCoder.Writer(writer.wordSize); + var dynamicWriter = new abstractCoder.Writer(writer.wordSize); + var updateFuncs = []; + coders.forEach(function (coder, index) { + var value = values[index]; + if (coder.dynamic) { + // Get current dynamic offset (for the future pointer) + var dynamicOffset_1 = dynamicWriter.length; + // Encode the dynamic value into the dynamicWriter + coder.encode(dynamicWriter, value); + // Prepare to populate the correct offset once we are done + var updateFunc_1 = staticWriter.writeUpdatableValue(); + updateFuncs.push(function (baseOffset) { + updateFunc_1(baseOffset + dynamicOffset_1); + }); + } + else { + coder.encode(staticWriter, value); + } + }); + // Backfill all the dynamic offsets, now that we know the static length + updateFuncs.forEach(function (func) { func(staticWriter.length); }); + var length = writer.writeBytes(staticWriter.data); + length += writer.writeBytes(dynamicWriter.data); + return length; + } + exports.pack = pack; + function unpack(reader, coders) { + var values = []; + // A reader anchored to this base + var baseReader = reader.subReader(0); + // The amount of dynamic data read; to consume later to synchronize + var dynamicLength = 0; + coders.forEach(function (coder) { + var value = null; + if (coder.dynamic) { + var offset = reader.readValue(); + var offsetReader = baseReader.subReader(offset.toNumber()); + value = coder.decode(offsetReader); + dynamicLength += offsetReader.consumed; + } + else { + value = coder.decode(reader); + } + if (value != undefined) { + values.push(value); + } + }); + // @TODO: get rid of this an see if it still works? + // Consume the dynamic components in the main reader + reader.readBytes(dynamicLength); + // Add any named parameters (i.e. tuples) + coders.forEach(function (coder, index) { + var name = coder.localName; + if (!name) { + return; + } + if (name === "length") { + name = "_length"; + } + if (values[name] != null) { + return; + } + values[name] = values[index]; + }); + return values; + } + exports.unpack = unpack; + var ArrayCoder = /** @class */ (function (_super) { + __extends(ArrayCoder, _super); + function ArrayCoder(coder, length, localName) { + var _this = this; + var type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); + var dynamic = (length === -1 || coder.dynamic); + _this = _super.call(this, "array", type, localName, dynamic) || this; + _this.coder = coder; + _this.length = length; + return _this; + } + ArrayCoder.prototype.encode = function (writer, value) { + if (!Array.isArray(value)) { + this._throwError("expected array value", value); + } + var count = this.length; + //let result = new Uint8Array(0); + if (count === -1) { + count = value.length; + writer.writeValue(value.length); + } + logger$1.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); + var coders = []; + for (var i = 0; i < value.length; i++) { + coders.push(this.coder); + } + return pack(writer, coders, value); + }; + ArrayCoder.prototype.decode = function (reader) { + var count = this.length; + if (count === -1) { + count = reader.readValue().toNumber(); + } + var coders = []; + for (var i = 0; i < count; i++) { + coders.push(new anonymous.AnonymousCoder(this.coder)); + } + return reader.coerce(this.name, unpack(reader, coders)); + }; + return ArrayCoder; + }(abstractCoder.Coder)); + exports.ArrayCoder = ArrayCoder; + }); + + var array$1 = unwrapExports(array); + var array_1 = array.pack; + var array_2 = array.unpack; + var array_3 = array.ArrayCoder; + + var boolean_1 = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + var BooleanCoder = /** @class */ (function (_super) { + __extends(BooleanCoder, _super); + function BooleanCoder(localName) { + return _super.call(this, "bool", "bool", localName, false) || this; + } + BooleanCoder.prototype.encode = function (writer, value) { + return writer.writeValue(value ? 1 : 0); + }; + BooleanCoder.prototype.decode = function (reader) { + return reader.coerce(this.type, !reader.readValue().isZero()); + }; + return BooleanCoder; + }(abstractCoder.Coder)); + exports.BooleanCoder = BooleanCoder; + }); + + var boolean = unwrapExports(boolean_1); + var boolean_2 = boolean_1.BooleanCoder; + + var bytes$1 = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + var DynamicBytesCoder = /** @class */ (function (_super) { + __extends(DynamicBytesCoder, _super); + function DynamicBytesCoder(type, localName) { + return _super.call(this, type, type, localName, true) || this; + } + DynamicBytesCoder.prototype.encode = function (writer, value) { + value = bytes.arrayify(value); + var length = writer.writeValue(value.length); + length += writer.writeBytes(value); + return length; + }; + DynamicBytesCoder.prototype.decode = function (reader) { + return reader.readBytes(reader.readValue().toNumber()); + }; + return DynamicBytesCoder; + }(abstractCoder.Coder)); + exports.DynamicBytesCoder = DynamicBytesCoder; + var BytesCoder = /** @class */ (function (_super) { + __extends(BytesCoder, _super); + function BytesCoder(localName) { + return _super.call(this, "bytes", localName) || this; + } + BytesCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, bytes.hexlify(_super.prototype.decode.call(this, reader))); + }; + return BytesCoder; + }(DynamicBytesCoder)); + exports.BytesCoder = BytesCoder; + }); + + var bytes$2 = unwrapExports(bytes$1); + var bytes_2$1 = bytes$1.DynamicBytesCoder; + var bytes_3$1 = bytes$1.BytesCoder; + + var fixedBytes = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + // @TODO: Merge this with bytes + var FixedBytesCoder = /** @class */ (function (_super) { + __extends(FixedBytesCoder, _super); + function FixedBytesCoder(size, localName) { + var _this = this; + var name = "bytes" + String(size); + _this = _super.call(this, name, name, localName, false) || this; + _this.size = size; + return _this; + } + FixedBytesCoder.prototype.encode = function (writer, value) { + var data = bytes.arrayify(value); + if (data.length !== this.size) { + this._throwError("incorrect data length", value); + } + return writer.writeBytes(data); + }; + FixedBytesCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, bytes.hexlify(reader.readBytes(this.size))); + }; + return FixedBytesCoder; + }(abstractCoder.Coder)); + exports.FixedBytesCoder = FixedBytesCoder; + }); + + var fixedBytes$1 = unwrapExports(fixedBytes); + var fixedBytes_1 = fixedBytes.FixedBytesCoder; + + var _null = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + var NullCoder = /** @class */ (function (_super) { + __extends(NullCoder, _super); + function NullCoder(localName) { + return _super.call(this, "null", "", localName, false) || this; + } + NullCoder.prototype.encode = function (writer, value) { + if (value != null) { + this._throwError("not null", value); + } + return writer.writeBytes([]); + }; + NullCoder.prototype.decode = function (reader) { + reader.readBytes(0); + return reader.coerce(this.name, null); + }; + return NullCoder; + }(abstractCoder.Coder)); + exports.NullCoder = NullCoder; + }); + + var _null$1 = unwrapExports(_null); + var _null_1 = _null.NullCoder; + + var constants = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + var AddressZero = "0x0000000000000000000000000000000000000000"; + exports.AddressZero = AddressZero; + var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; + exports.HashZero = HashZero; + // NFKD (decomposed) + //const EtherSymbol = "\uD835\uDF63"; + // NFKC (composed) + var EtherSymbol = "\u039e"; + exports.EtherSymbol = EtherSymbol; + var NegativeOne = bignumber$2.BigNumber.from(-1); + exports.NegativeOne = NegativeOne; + var Zero = bignumber$2.BigNumber.from(0); + exports.Zero = Zero; + var One = bignumber$2.BigNumber.from(1); + exports.One = One; + var Two = bignumber$2.BigNumber.from(2); + exports.Two = Two; + var WeiPerEther = bignumber$2.BigNumber.from("1000000000000000000"); + exports.WeiPerEther = WeiPerEther; + var MaxUint256 = bignumber$2.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + exports.MaxUint256 = MaxUint256; + }); + + var index$7 = unwrapExports(constants); + var constants_1 = constants.AddressZero; + var constants_2 = constants.HashZero; + var constants_3 = constants.EtherSymbol; + var constants_4 = constants.NegativeOne; + var constants_5 = constants.Zero; + var constants_6 = constants.One; + var constants_7 = constants.Two; + var constants_8 = constants.WeiPerEther; + var constants_9 = constants.MaxUint256; + + var number = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var NumberCoder = /** @class */ (function (_super) { + __extends(NumberCoder, _super); + function NumberCoder(size, signed, localName) { + var _this = this; + var name = ((signed ? "int" : "uint") + (size * 8)); + _this = _super.call(this, name, name, localName, false) || this; + _this.size = size; + _this.signed = signed; + return _this; + } + NumberCoder.prototype.encode = function (writer, value) { + var v = bignumber$2.BigNumber.from(value); + // Check bounds are safe for encoding + var maxUintValue = constants.MaxUint256.maskn(writer.wordSize * 8); + if (this.signed) { + var bounds = maxUintValue.maskn(this.size * 8 - 1); + if (v.gt(bounds) || v.lt(bounds.add(constants.One).mul(constants.NegativeOne))) { + this._throwError("value out-of-bounds", value); + } + } + else if (v.lt(constants.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { + this._throwError("value out-of-bounds", value); + } + v = v.toTwos(this.size * 8).maskn(this.size * 8); + if (this.signed) { + v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); + } + return writer.writeValue(v); + }; + NumberCoder.prototype.decode = function (reader) { + var value = reader.readValue().maskn(this.size * 8); + if (this.signed) { + value = value.fromTwos(this.size * 8); + } + return reader.coerce(this.name, value); + }; + return NumberCoder; + }(abstractCoder.Coder)); + exports.NumberCoder = NumberCoder; + }); + + var number$1 = unwrapExports(number); + var number_1 = number.NumberCoder; + + var _version$c = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "strings/5.0.0-beta.130"; + }); + + var _version$d = unwrapExports(_version$c); + var _version_1$6 = _version$c.version; + + var utf8 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$c.version); + /////////////////////////////// + var UnicodeNormalizationForm; + (function (UnicodeNormalizationForm) { + UnicodeNormalizationForm["current"] = ""; + UnicodeNormalizationForm["NFC"] = "NFC"; + UnicodeNormalizationForm["NFD"] = "NFD"; + UnicodeNormalizationForm["NFKC"] = "NFKC"; + UnicodeNormalizationForm["NFKD"] = "NFKD"; + })(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {})); + ; + // http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 + function getUtf8CodePoints(bytes$1, ignoreErrors) { + bytes$1 = bytes.arrayify(bytes$1); + var result = []; + var i = 0; + // Invalid bytes are ignored + while (i < bytes$1.length) { + var c = bytes$1[i++]; + // 0xxx xxxx + if (c >> 7 === 0) { + result.push(c); + continue; + } + // Multibyte; how many bytes left for this character? + var extraLength = null; + var overlongMask = null; + // 110x xxxx 10xx xxxx + if ((c & 0xe0) === 0xc0) { + extraLength = 1; + overlongMask = 0x7f; + // 1110 xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf0) === 0xe0) { + extraLength = 2; + overlongMask = 0x7ff; + // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf8) === 0xf0) { + extraLength = 3; + overlongMask = 0xffff; + } + else { + if (!ignoreErrors) { + if ((c & 0xc0) === 0x80) { + throw new Error("invalid utf8 byte sequence; unexpected continuation byte"); + } + throw new Error("invalid utf8 byte sequence; invalid prefix"); + } + continue; + } + // Do we have enough bytes in our data? + if (i + extraLength > bytes$1.length) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; too short"); + } + // If there is an invalid unprocessed byte, skip continuation bytes + for (; i < bytes$1.length; i++) { + if (bytes$1[i] >> 6 !== 0x02) { + break; + } + } + continue; + } + // Remove the length prefix from the char + var res = c & ((1 << (8 - extraLength - 1)) - 1); + for (var j = 0; j < extraLength; j++) { + var nextChar = bytes$1[i]; + // Invalid continuation byte + if ((nextChar & 0xc0) != 0x80) { + res = null; + break; + } + ; + res = (res << 6) | (nextChar & 0x3f); + i++; + } + if (res === null) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; invalid continuation byte"); + } + continue; + } + // Check for overlong seuences (more bytes than needed) + if (res <= overlongMask) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; overlong"); + } + continue; + } + // Maximum code point + if (res > 0x10ffff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; out-of-range"); + } + continue; + } + // Reserved for UTF-16 surrogate halves + if (res >= 0xd800 && res <= 0xdfff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; utf-16 surrogate"); + } + continue; + } + result.push(res); + } + return result; + } + // http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array + function toUtf8Bytes(str, form) { + if (form === void 0) { form = UnicodeNormalizationForm.current; } + if (form != UnicodeNormalizationForm.current) { + logger$1.checkNormalize(); + str = str.normalize(form); + } + var result = []; + for (var i = 0; i < str.length; i++) { + var c = str.charCodeAt(i); + if (c < 0x80) { + result.push(c); + } + else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + } + else if ((c & 0xfc00) == 0xd800) { + i++; + var c2 = str.charCodeAt(i); + if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { + throw new Error("invalid utf-8 string"); + } + // Surrogate Pair + c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((c >> 18) | 0xf0); + result.push(((c >> 12) & 0x3f) | 0x80); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + return bytes.arrayify(result); + } + exports.toUtf8Bytes = toUtf8Bytes; + ; + function escapeChar(value) { + var hex = ("0000" + value.toString(16)); + return "\\u" + hex.substring(hex.length - 4); + } + function _toEscapedUtf8String(bytes, ignoreErrors) { + return '"' + getUtf8CodePoints(bytes, ignoreErrors).map(function (codePoint) { + if (codePoint < 256) { + switch (codePoint) { + case 8: return "\\b"; + case 9: return "\\t"; + case 10: return "\\n"; + case 13: return "\\r"; + case 34: return "\\\""; + case 92: return "\\\\"; + } + if (codePoint >= 32 && codePoint < 127) { + return String.fromCharCode(codePoint); + } + } + if (codePoint <= 0xffff) { + return escapeChar(codePoint); + } + codePoint -= 0x10000; + return escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) + escapeChar((codePoint & 0x3ff) + 0xdc00); + }).join("") + '"'; + } + exports._toEscapedUtf8String = _toEscapedUtf8String; + function _toUtf8String(codePoints) { + return codePoints.map(function (codePoint) { + if (codePoint <= 0xffff) { + return String.fromCharCode(codePoint); + } + codePoint -= 0x10000; + return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00)); + }).join(""); + } + exports._toUtf8String = _toUtf8String; + function toUtf8String(bytes, ignoreErrors) { + return _toUtf8String(getUtf8CodePoints(bytes, ignoreErrors)); + } + exports.toUtf8String = toUtf8String; + function toUtf8CodePoints(str, form) { + if (form === void 0) { form = UnicodeNormalizationForm.current; } + return getUtf8CodePoints(toUtf8Bytes(str, form)); + } + exports.toUtf8CodePoints = toUtf8CodePoints; + }); + + var utf8$1 = unwrapExports(utf8); + var utf8_1 = utf8.UnicodeNormalizationForm; + var utf8_2 = utf8.toUtf8Bytes; + var utf8_3 = utf8._toEscapedUtf8String; + var utf8_4 = utf8._toUtf8String; + var utf8_5 = utf8.toUtf8String; + var utf8_6 = utf8.toUtf8CodePoints; + + var bytes32 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + function formatBytes32String(text) { + // Get the bytes + var bytes$1 = utf8.toUtf8Bytes(text); + // Check we have room for null-termination + if (bytes$1.length > 31) { + throw new Error("bytes32 string must be less than 32 bytes"); + } + // Zero-pad (implicitly null-terminates) + return bytes.hexlify(bytes.concat([bytes$1, constants.HashZero]).slice(0, 32)); + } + exports.formatBytes32String = formatBytes32String; + function parseBytes32String(bytes$1) { + var data = bytes.arrayify(bytes$1); + // Must be 32 bytes with a null-termination + if (data.length !== 32) { + throw new Error("invalid bytes32 - not 32 bytes long"); + } + if (data[31] !== 0) { + throw new Error("invalid bytes32 string - no null terminator"); + } + // Find the null termination + var length = 31; + while (data[length - 1] === 0) { + length--; + } + // Determine the string value + return utf8.toUtf8String(data.slice(0, length)); + } + exports.parseBytes32String = parseBytes32String; + }); + + var bytes32$1 = unwrapExports(bytes32); + var bytes32_1 = bytes32.formatBytes32String; + var bytes32_2 = bytes32.parseBytes32String; + + var idna = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + function bytes2(data) { + if ((data.length % 4) !== 0) { + throw new Error("bad data"); + } + var result = []; + for (var i = 0; i < data.length; i += 4) { + result.push(parseInt(data.substring(i, i + 4), 16)); + } + return result; + } + function createTable(data, func) { + if (!func) { + func = function (value) { return [parseInt(value, 16)]; }; + } + var lo = 0; + var result = {}; + data.split(",").forEach(function (pair) { + var comps = pair.split(":"); + lo += parseInt(comps[0], 16); + result[lo] = func(comps[1]); + }); + return result; + } + function createRangeTable(data) { + var hi = 0; + return data.split(",").map(function (v) { + var comps = v.split("-"); + if (comps.length === 1) { + comps[1] = "0"; + } + else if (comps[1] === "") { + comps[1] = "1"; + } + var lo = hi + parseInt(comps[0], 16); + hi = parseInt(comps[1], 16); + return { l: lo, h: hi }; + }); + } + function matchMap(value, ranges) { + var lo = 0; + for (var i = 0; i < ranges.length; i++) { + var range = ranges[i]; + lo += range.l; + if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) { + if (range.e && range.e.indexOf(value - lo) !== -1) { + continue; + } + return range; + } + } + return null; + } + var Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); + // @TODO: Make this relative... + var Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function (v) { return parseInt(v, 16); }); + var Table_B_2_ranges = [ + { h: 25, s: 32, l: 65 }, + { h: 30, s: 32, e: [23], l: 127 }, + { h: 54, s: 1, e: [48], l: 64, d: 2 }, + { h: 14, s: 1, l: 57, d: 2 }, + { h: 44, s: 1, l: 17, d: 2 }, + { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 }, + { h: 16, s: 1, l: 68, d: 2 }, + { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 }, + { h: 26, s: 32, e: [17], l: 435 }, + { h: 22, s: 1, l: 71, d: 2 }, + { h: 15, s: 80, l: 40 }, + { h: 31, s: 32, l: 16 }, + { h: 32, s: 1, l: 80, d: 2 }, + { h: 52, s: 1, l: 42, d: 2 }, + { h: 12, s: 1, l: 55, d: 2 }, + { h: 40, s: 1, e: [38], l: 15, d: 2 }, + { h: 14, s: 1, l: 48, d: 2 }, + { h: 37, s: 48, l: 49 }, + { h: 148, s: 1, l: 6351, d: 2 }, + { h: 88, s: 1, l: 160, d: 2 }, + { h: 15, s: 16, l: 704 }, + { h: 25, s: 26, l: 854 }, + { h: 25, s: 32, l: 55915 }, + { h: 37, s: 40, l: 1247 }, + { h: 25, s: -119711, l: 53248 }, + { h: 25, s: -119763, l: 52 }, + { h: 25, s: -119815, l: 52 }, + { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 }, + { h: 25, s: -119919, l: 52 }, + { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 }, + { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 }, + { h: 25, s: -120075, l: 52 }, + { h: 25, s: -120127, l: 52 }, + { h: 25, s: -120179, l: 52 }, + { h: 25, s: -120231, l: 52 }, + { h: 25, s: -120283, l: 52 }, + { h: 25, s: -120335, l: 52 }, + { h: 24, s: -119543, e: [17], l: 56 }, + { h: 24, s: -119601, e: [17], l: 58 }, + { h: 24, s: -119659, e: [17], l: 58 }, + { h: 24, s: -119717, e: [17], l: 58 }, + { h: 24, s: -119775, e: [17], l: 58 } + ]; + var Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); + var Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); + var Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); + var Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); + function flatten(values) { + return values.reduce(function (accum, value) { + value.forEach(function (value) { accum.push(value); }); + return accum; + }, []); + } + function _nameprepTableA1(codepoint) { + return !!matchMap(codepoint, Table_A_1_ranges); + } + exports._nameprepTableA1 = _nameprepTableA1; + function _nameprepTableB2(codepoint) { + var range = matchMap(codepoint, Table_B_2_ranges); + if (range) { + return [codepoint + range.s]; + } + var codes = Table_B_2_lut_abs[codepoint]; + if (codes) { + return codes; + } + var shift = Table_B_2_lut_rel[codepoint]; + if (shift) { + return [codepoint + shift[0]]; + } + var complex = Table_B_2_complex[codepoint]; + if (complex) { + return complex; + } + return null; + } + exports._nameprepTableB2 = _nameprepTableB2; + function _nameprepTableC(codepoint) { + return !!matchMap(codepoint, Table_C_ranges); + } + exports._nameprepTableC = _nameprepTableC; + function nameprep(value) { + // This allows platforms with incomplete normalize to bypass + // it for very basic names which the built-in toLowerCase + // will certainly handle correctly + if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) { + return value.toLowerCase(); + } + // Get the code points (keeping the current normalization) + var codes = utf8.toUtf8CodePoints(value); + codes = flatten(codes.map(function (code) { + // Substitute Table B.1 (Maps to Nothing) + if (Table_B_1_flags.indexOf(code) >= 0) { + return []; + } + if (code >= 0xfe00 && code <= 0xfe0f) { + return []; + } + // Substitute Table B.2 (Case Folding) + var codesTableB2 = _nameprepTableB2(code); + if (codesTableB2) { + return codesTableB2; + } + // No Substitution + return [code]; + })); + // Normalize using form KC + codes = utf8.toUtf8CodePoints(utf8._toUtf8String(codes), utf8.UnicodeNormalizationForm.NFKC); + // Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9 + codes.forEach(function (code) { + if (_nameprepTableC(code)) { + throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); + } + }); + // Prohibit Unassigned Code Points (Table A.1) + codes.forEach(function (code) { + if (_nameprepTableA1(code)) { + throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); + } + }); + // IDNA extras + var name = utf8._toUtf8String(codes); + // IDNA: 4.2.3.1 + if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { + throw new Error("invalid hyphen"); + } + // IDNA: 4.2.4 + if (name.length > 63) { + throw new Error("too long"); + } + return name; + } + exports.nameprep = nameprep; + }); + + var idna$1 = unwrapExports(idna); + var idna_1 = idna._nameprepTableA1; + var idna_2 = idna._nameprepTableB2; + var idna_3 = idna._nameprepTableC; + var idna_4 = idna.nameprep; + + var strings = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.formatBytes32String = bytes32.formatBytes32String; + exports.parseBytes32String = bytes32.parseBytes32String; + + exports.nameprep = idna.nameprep; + + exports._toEscapedUtf8String = utf8._toEscapedUtf8String; + exports.toUtf8Bytes = utf8.toUtf8Bytes; + exports.toUtf8CodePoints = utf8.toUtf8CodePoints; + exports.toUtf8String = utf8.toUtf8String; + exports.UnicodeNormalizationForm = utf8.UnicodeNormalizationForm; + }); + + var index$8 = unwrapExports(strings); + var strings_1 = strings.formatBytes32String; + var strings_2 = strings.parseBytes32String; + var strings_3 = strings.nameprep; + var strings_4 = strings._toEscapedUtf8String; + var strings_5 = strings.toUtf8Bytes; + var strings_6 = strings.toUtf8CodePoints; + var strings_7 = strings.toUtf8String; + var strings_8 = strings.UnicodeNormalizationForm; + + var string = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + var StringCoder = /** @class */ (function (_super) { + __extends(StringCoder, _super); + function StringCoder(localName) { + return _super.call(this, "string", localName) || this; + } + StringCoder.prototype.encode = function (writer, value) { + return _super.prototype.encode.call(this, writer, strings.toUtf8Bytes(value)); + }; + StringCoder.prototype.decode = function (reader) { + return strings.toUtf8String(_super.prototype.decode.call(this, reader)); + }; + return StringCoder; + }(bytes$1.DynamicBytesCoder)); + exports.StringCoder = StringCoder; + }); + + var string$1 = unwrapExports(string); + var string_1 = string.StringCoder; + + var tuple = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + var TupleCoder = /** @class */ (function (_super) { + __extends(TupleCoder, _super); + function TupleCoder(coders, localName) { + var _this = this; + var dynamic = false; + var types = []; + coders.forEach(function (coder) { + if (coder.dynamic) { + dynamic = true; + } + types.push(coder.type); + }); + var type = ("tuple(" + types.join(",") + ")"); + _this = _super.call(this, "tuple", type, localName, dynamic) || this; + _this.coders = coders; + return _this; + } + TupleCoder.prototype.encode = function (writer, value) { + return array.pack(writer, this.coders, value); + }; + TupleCoder.prototype.decode = function (reader) { + return reader.coerce(this.name, array.unpack(reader, this.coders)); + }; + return TupleCoder; + }(abstractCoder.Coder)); + exports.TupleCoder = TupleCoder; + }); + + var tuple$1 = unwrapExports(tuple); + var tuple_1 = tuple.TupleCoder; + + var abiCoder = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + // See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI + + + + + var logger$1 = new logger.Logger(_version$8.version); + + + + + + + + + + + + var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); + var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); + var AbiCoder = /** @class */ (function () { + function AbiCoder(coerceFunc) { + var _newTarget = this.constructor; + logger$1.checkNew(_newTarget, AbiCoder); + properties.defineReadOnly(this, "coerceFunc", coerceFunc || null); + } + AbiCoder.prototype._getCoder = function (param) { + var _this = this; + switch (param.baseType) { + case "address": + return new address$1.AddressCoder(param.name); + case "bool": + return new boolean_1.BooleanCoder(param.name); + case "string": + return new string.StringCoder(param.name); + case "bytes": + return new bytes$1.BytesCoder(param.name); + case "array": + return new array.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); + case "tuple": + return new tuple.TupleCoder((param.components || []).map(function (component) { + return _this._getCoder(component); + }), param.name); + case "": + return new _null.NullCoder(param.name); + } + // u?int[0-9]* + var match = param.type.match(paramTypeNumber); + if (match) { + var size = parseInt(match[2] || "256"); + if (size === 0 || size > 256 || (size % 8) !== 0) { + logger$1.throwArgumentError("invalid " + match[1] + " bit length", "param", param); + } + return new number.NumberCoder(size / 8, (match[1] === "int"), param.name); + } + // bytes[0-9]+ + match = param.type.match(paramTypeBytes); + if (match) { + var size = parseInt(match[1]); + if (size === 0 || size > 32) { + logger$1.throwArgumentError("invalid bytes length", "param", param); + } + return new fixedBytes.FixedBytesCoder(size, param.name); + } + return logger$1.throwError("invalid type", "type", param.type); + }; + AbiCoder.prototype._getWordSize = function () { return 32; }; + AbiCoder.prototype._getReader = function (data) { + return new abstractCoder.Reader(data, this._getWordSize(), this.coerceFunc); + }; + AbiCoder.prototype._getWriter = function () { + return new abstractCoder.Writer(this._getWordSize()); + }; + AbiCoder.prototype.encode = function (types, values) { + var _this = this; + if (types.length !== values.length) { + logger$1.throwError("types/values length mismatch", logger.Logger.errors.INVALID_ARGUMENT, { + count: { types: types.length, values: values.length }, + value: { types: types, values: values } + }); + } + var coders = types.map(function (type) { return _this._getCoder(fragments.ParamType.from(type)); }); + var coder = (new tuple.TupleCoder(coders, "_")); + var writer = this._getWriter(); + coder.encode(writer, values); + return writer.data; + }; + AbiCoder.prototype.decode = function (types, data) { + var _this = this; + var coders = types.map(function (type) { return _this._getCoder(fragments.ParamType.from(type)); }); + var coder = new tuple.TupleCoder(coders, "_"); + return coder.decode(this._getReader(bytes.arrayify(data))); + }; + return AbiCoder; + }()); + exports.AbiCoder = AbiCoder; + exports.defaultAbiCoder = new AbiCoder(); + }); + + var abiCoder$1 = unwrapExports(abiCoder); + var abiCoder_1 = abiCoder.AbiCoder; + var abiCoder_2 = abiCoder.defaultAbiCoder; + + var _version$e = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "hash/5.0.0-beta.128"; + }); + + var _version$f = unwrapExports(_version$e); + var _version_1$7 = _version$e.version; + + var hash = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + var logger$1 = new logger.Logger(_version$e.version); + /////////////////////////////// + var Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + var Partition = new RegExp("^((.*)\\.)?([^.]+)$"); + function isValidName(name) { + try { + var comps = name.split("."); + for (var i = 0; i < comps.length; i++) { + if (strings.nameprep(comps[i]).length === 0) { + throw new Error("empty"); + } + } + return true; + } + catch (error) { } + return false; + } + exports.isValidName = isValidName; + function namehash(name) { + if (typeof (name) !== "string") { + logger$1.throwArgumentError("invalid address - " + String(name), "name", name); + } + var result = Zeros; + while (name.length) { + var partition = name.match(Partition); + var label = strings.toUtf8Bytes(strings.nameprep(partition[3])); + result = keccak256_1.keccak256(bytes.concat([result, keccak256_1.keccak256(label)])); + name = partition[2] || ""; + } + return bytes.hexlify(result); + } + exports.namehash = namehash; + function id(text) { + return keccak256_1.keccak256(strings.toUtf8Bytes(text)); + } + exports.id = id; + exports.messagePrefix = "\x19Ethereum Signed Message:\n"; + function hashMessage(message) { + if (typeof (message) === "string") { + message = strings.toUtf8Bytes(message); + } + return keccak256_1.keccak256(bytes.concat([ + strings.toUtf8Bytes(exports.messagePrefix), + strings.toUtf8Bytes(String(message.length)), + message + ])); + } + exports.hashMessage = hashMessage; + }); + + var index$9 = unwrapExports(hash); + var hash_1 = hash.isValidName; + var hash_2 = hash.namehash; + var hash_3 = hash.id; + var hash_4 = hash.messagePrefix; + var hash_5 = hash.hashMessage; + + var _interface = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + + + var logger$1 = new logger.Logger(_version$8.version); + var LogDescription = /** @class */ (function (_super) { + __extends(LogDescription, _super); + function LogDescription() { + return _super !== null && _super.apply(this, arguments) || this; + } + return LogDescription; + }(properties.Description)); + exports.LogDescription = LogDescription; + var TransactionDescription = /** @class */ (function (_super) { + __extends(TransactionDescription, _super); + function TransactionDescription() { + return _super !== null && _super.apply(this, arguments) || this; + } + return TransactionDescription; + }(properties.Description)); + exports.TransactionDescription = TransactionDescription; + var Indexed = /** @class */ (function (_super) { + __extends(Indexed, _super); + function Indexed() { + return _super !== null && _super.apply(this, arguments) || this; + } + Indexed.isIndexed = function (value) { + return !!(value && value._isIndexed); + }; + return Indexed; + }(properties.Description)); + exports.Indexed = Indexed; + var Result = /** @class */ (function () { + function Result() { + } + return Result; + }()); + exports.Result = Result; + var Interface = /** @class */ (function () { + function Interface(fragments$1) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, Interface); + var abi = []; + if (typeof (fragments$1) === "string") { + abi = JSON.parse(fragments$1); + } + else { + abi = fragments$1; + } + properties.defineReadOnly(this, "fragments", abi.map(function (fragment) { + return fragments.Fragment.from(fragment); + }).filter(function (fragment) { return (fragment != null); })); + properties.defineReadOnly(this, "_abiCoder", properties.getStatic((_newTarget), "getAbiCoder")()); + properties.defineReadOnly(this, "functions", {}); + properties.defineReadOnly(this, "errors", {}); + properties.defineReadOnly(this, "events", {}); + properties.defineReadOnly(this, "structs", {}); + // Add all fragments by their signature + this.fragments.forEach(function (fragment) { + var bucket = null; + switch (fragment.type) { + case "constructor": + if (_this.deploy) { + logger$1.warn("duplicate definition - constructor"); + return; + } + properties.defineReadOnly(_this, "deploy", fragment); + return; + case "function": + bucket = _this.functions; + break; + case "event": + bucket = _this.events; + break; + default: + return; + } + var signature = fragment.format(); + if (bucket[signature]) { + logger$1.warn("duplicate definition - " + signature); + return; + } + bucket[signature] = fragment; + }); + // Add any fragments with a unique name by its name (sans signature parameters) + [this.events, this.functions].forEach(function (bucket) { + var count = getNameCount(bucket); + Object.keys(bucket).forEach(function (signature) { + var fragment = bucket[signature]; + if (count[fragment.name] !== 1) { + logger$1.warn("duplicate definition - " + fragment.name); + return; + } + bucket[fragment.name] = fragment; + }); + }); + // If we do not have a constructor use the default "constructor() payable" + if (!this.deploy) { + properties.defineReadOnly(this, "deploy", fragments.ConstructorFragment.from({ type: "constructor" })); + } + properties.defineReadOnly(this, "_isInterface", true); + } + Interface.getAbiCoder = function () { + return abiCoder.defaultAbiCoder; + }; + Interface.getAddress = function (address$1) { + return address.getAddress(address$1); + }; + Interface.prototype._sighashify = function (functionFragment) { + return bytes.hexDataSlice(hash.id(functionFragment.format()), 0, 4); + }; + Interface.prototype._topicify = function (eventFragment) { + return hash.id(eventFragment.format()); + }; + Interface.prototype.getFunction = function (nameOrSignatureOrSighash) { + if (bytes.isHexString(nameOrSignatureOrSighash)) { + return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrSighash.indexOf("(") === -1) { + return (this.functions[nameOrSignatureOrSighash.trim()] || null); + } + // Normlize the signature and lookup the function + return this.functions[fragments.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; + }; + Interface.prototype.getEvent = function (nameOrSignatureOrTopic) { + if (bytes.isHexString(nameOrSignatureOrTopic)) { + return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); + } + // It is a bare name, look up the function (will return null if ambiguous) + if (nameOrSignatureOrTopic.indexOf("(") === -1) { + return this.events[nameOrSignatureOrTopic]; + } + return this.events[fragments.EventFragment.fromString(nameOrSignatureOrTopic).format()]; + }; + Interface.prototype.getSighash = function (functionFragment) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return this._sighashify(functionFragment); + }; + Interface.prototype.getEventTopic = function (eventFragment) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + return this._topicify(eventFragment); + }; + Interface.prototype._encodeParams = function (params, values) { + return this._abiCoder.encode(params, values); + }; + Interface.prototype.encodeDeploy = function (values) { + return this._encodeParams(this.deploy.inputs, values || []); + }; + Interface.prototype.encodeFunctionData = function (functionFragment, values) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + return bytes.hexlify(bytes.concat([ + this.getSighash(functionFragment), + this._encodeParams(functionFragment.inputs, values || []) + ])); + }; + Interface.prototype.decodeFunctionResult = function (functionFragment, data) { + if (typeof (functionFragment) === "string") { + functionFragment = this.getFunction(functionFragment); + } + var bytes$1 = bytes.arrayify(data); + var reason = null; + var errorSignature = null; + switch (bytes$1.length % this._abiCoder._getWordSize()) { + case 0: + try { + return this._abiCoder.decode(functionFragment.outputs, bytes$1); + } + catch (error) { } + break; + case 4: + if (bytes.hexlify(bytes$1.slice(0, 4)) === "0x08c379a0") { + errorSignature = "Error(string)"; + reason = this._abiCoder.decode(["string"], bytes$1.slice(4)); + } + break; + } + return logger$1.throwError("call revert exception", logger.Logger.errors.CALL_EXCEPTION, { + method: functionFragment.format(), + errorSignature: errorSignature, + errorArgs: [reason], + reason: reason + }); + }; + Interface.prototype.encodeFilterTopics = function (eventFragment, values) { + var _this = this; + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (values.length > eventFragment.inputs.length) { + logger$1.throwError("too many arguments for " + eventFragment.format(), logger.Logger.errors.UNEXPECTED_ARGUMENT, { + argument: "values", + value: values + }); + } + var topics = []; + if (!eventFragment.anonymous) { + topics.push(this.getEventTopic(eventFragment)); + } + values.forEach(function (value, index) { + var param = eventFragment.inputs[index]; + if (!param.indexed) { + if (value != null) { + logger$1.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + } + return; + } + if (value == null) { + topics.push(null); + } + else if (param.type === "string") { + topics.push(hash.id(value)); + } + else if (param.type === "bytes") { + topics.push(keccak256_1.keccak256(bytes.hexlify(value))); + } + else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { + logger$1.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + } + else { + // Check addresses are valid + if (param.type === "address") { + _this._abiCoder.encode(["address"], [value]); + } + topics.push(bytes.hexZeroPad(bytes.hexlify(value), 32)); + } + }); + // Trim off trailing nulls + while (topics.length && topics[topics.length - 1] === null) { + topics.pop(); + } + return topics; + }; + Interface.prototype.decodeEventLog = function (eventFragment, data, topics) { + if (typeof (eventFragment) === "string") { + eventFragment = this.getEvent(eventFragment); + } + if (topics != null && !eventFragment.anonymous) { + var topicHash = this.getEventTopic(eventFragment); + if (!bytes.isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { + logger$1.throwError("fragment/topic mismatch", logger.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); + } + topics = topics.slice(1); + } + var indexed = []; + var nonIndexed = []; + var dynamic = []; + eventFragment.inputs.forEach(function (param, index) { + if (param.indexed) { + if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { + indexed.push(fragments.ParamType.fromObject({ type: "bytes32", name: param.name })); + dynamic.push(true); + } + else { + indexed.push(param); + dynamic.push(false); + } + } + else { + nonIndexed.push(param); + dynamic.push(false); + } + }); + var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, bytes.concat(topics)) : null; + var resultNonIndexed = this._abiCoder.decode(nonIndexed, data); + var result = []; + var nonIndexedIndex = 0, indexedIndex = 0; + eventFragment.inputs.forEach(function (param, index) { + if (param.indexed) { + if (resultIndexed == null) { + result[index] = new Indexed({ _isIndexed: true, hash: null }); + } + else if (dynamic[index]) { + result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); + } + else { + result[index] = resultIndexed[indexedIndex++]; + } + } + else { + result[index] = resultNonIndexed[nonIndexedIndex++]; + } + //if (param.name && result[param.name] == null) { result[param.name] = result[index]; } + }); + return result; + }; + Interface.prototype.parseTransaction = function (tx) { + var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); + if (!fragment) { + return null; + } + return new TransactionDescription({ + args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), + functionFragment: fragment, + name: fragment.name, + signature: fragment.format(), + sighash: this.getSighash(fragment), + value: bignumber$2.BigNumber.from(tx.value || "0"), + }); + }; + Interface.prototype.parseLog = function (log) { + var fragment = this.getEvent(log.topics[0]); + if (!fragment || fragment.anonymous) { + return null; + } + // @TODO: If anonymous, and the only method, and the input count matches, should we parse? + return new LogDescription({ + eventFragment: fragment, + name: fragment.name, + signature: fragment.format(), + topic: this.getEventTopic(fragment), + values: this.decodeEventLog(fragment, log.data, log.topics) + }); + }; + /* + static from(value: Array | string | Interface) { + if (Interface.isInterface(value)) { + return value; + } + if (typeof(value) === "string") { + return new Interface(JSON.parse(value)); + } + return new Interface(value); + } + */ + Interface.isInterface = function (value) { + return !!(value && value._isInterface); + }; + return Interface; + }()); + exports.Interface = Interface; + function getFragment(hash, calcFunc, items) { + for (var signature in items) { + if (signature.indexOf("(") === -1) { + continue; + } + var fragment = items[signature]; + if (calcFunc(fragment) === hash) { + return fragment; + } + } + return null; + } + function getNameCount(fragments) { + var unique = {}; + // Count each name + for (var signature in fragments) { + var name_1 = fragments[signature].name; + if (!unique[name_1]) { + unique[name_1] = 0; + } + unique[name_1]++; + } + return unique; + } + }); + + var _interface$1 = unwrapExports(_interface); + var _interface_1 = _interface.LogDescription; + var _interface_2 = _interface.TransactionDescription; + var _interface_3 = _interface.Indexed; + var _interface_4 = _interface.Result; + var _interface_5 = _interface.Interface; + + var abi = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.ConstructorFragment = fragments.ConstructorFragment; + exports.EventFragment = fragments.EventFragment; + exports.FormatTypes = fragments.FormatTypes; + exports.Fragment = fragments.Fragment; + exports.FunctionFragment = fragments.FunctionFragment; + exports.ParamType = fragments.ParamType; + + exports.AbiCoder = abiCoder.AbiCoder; + exports.defaultAbiCoder = abiCoder.defaultAbiCoder; + + exports.Indexed = _interface.Indexed; + exports.Interface = _interface.Interface; + }); + + var index$a = unwrapExports(abi); + var abi_1 = abi.ConstructorFragment; + var abi_2 = abi.EventFragment; + var abi_3 = abi.FormatTypes; + var abi_4 = abi.Fragment; + var abi_5 = abi.FunctionFragment; + var abi_6 = abi.ParamType; + var abi_7 = abi.AbiCoder; + var abi_8 = abi.defaultAbiCoder; + var abi_9 = abi.Indexed; + var abi_10 = abi.Interface; + + var _version$g = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "abstract-provider/5.0.0-beta.131"; + }); + + var _version$h = unwrapExports(_version$g); + var _version_1$8 = _version$g.version; + + var abstractProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + var logger$1 = new logger.Logger(_version$g.version); + ; + ; + //export type CallTransactionable = { + // call(transaction: TransactionRequest): Promise; + //}; + var ForkEvent = /** @class */ (function (_super) { + __extends(ForkEvent, _super); + function ForkEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + ForkEvent.isForkEvent = function (value) { + return !!(value && value._isForkEvent); + }; + return ForkEvent; + }(properties.Description)); + exports.ForkEvent = ForkEvent; + var BlockForkEvent = /** @class */ (function (_super) { + __extends(BlockForkEvent, _super); + function BlockForkEvent(blockhash, expiry) { + var _this = this; + if (!bytes.isHexString(blockhash, 32)) { + logger$1.throwArgumentError("invalid blockhash", "blockhash", blockhash); + } + _this = _super.call(this, { + _isForkEvent: true, + _isBlockForkEvent: true, + expiry: (expiry || 0), + blockHash: blockhash + }) || this; + return _this; + } + return BlockForkEvent; + }(ForkEvent)); + exports.BlockForkEvent = BlockForkEvent; + var TransactionForkEvent = /** @class */ (function (_super) { + __extends(TransactionForkEvent, _super); + function TransactionForkEvent(hash, expiry) { + var _this = this; + if (!bytes.isHexString(hash, 32)) { + logger$1.throwArgumentError("invalid transaction hash", "hash", hash); + } + _this = _super.call(this, { + _isForkEvent: true, + _isTransactionForkEvent: true, + expiry: (expiry || 0), + hash: hash + }) || this; + return _this; + } + return TransactionForkEvent; + }(ForkEvent)); + exports.TransactionForkEvent = TransactionForkEvent; + var TransactionOrderForkEvent = /** @class */ (function (_super) { + __extends(TransactionOrderForkEvent, _super); + function TransactionOrderForkEvent(beforeHash, afterHash, expiry) { + var _this = this; + if (!bytes.isHexString(beforeHash, 32)) { + logger$1.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + } + if (!bytes.isHexString(afterHash, 32)) { + logger$1.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + } + _this = _super.call(this, { + _isForkEvent: true, + _isTransactionOrderForkEvent: true, + expiry: (expiry || 0), + beforeHash: beforeHash, + afterHash: afterHash + }) || this; + return _this; + } + return TransactionOrderForkEvent; + }(ForkEvent)); + exports.TransactionOrderForkEvent = TransactionOrderForkEvent; + /////////////////////////////// + // Exported Abstracts + var Provider = /** @class */ (function () { + function Provider() { + var _newTarget = this.constructor; + logger$1.checkAbstract(_newTarget, Provider); + properties.defineReadOnly(this, "_isProvider", true); + } + // Alias for "on" + Provider.prototype.addListener = function (eventName, listener) { + return this.on(eventName, listener); + }; + // Alias for "off" + Provider.prototype.removeListener = function (eventName, listener) { + return this.off(eventName, listener); + }; + Provider.isProvider = function (value) { + return !!(value && value._isProvider); + }; + return Provider; + }()); + exports.Provider = Provider; + }); + + var index$b = unwrapExports(abstractProvider); + var abstractProvider_1 = abstractProvider.ForkEvent; + var abstractProvider_2 = abstractProvider.BlockForkEvent; + var abstractProvider_3 = abstractProvider.TransactionForkEvent; + var abstractProvider_4 = abstractProvider.TransactionOrderForkEvent; + var abstractProvider_5 = abstractProvider.Provider; + + var _version$i = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "abstract-signer/5.0.0-beta.132"; + }); + + var _version$j = unwrapExports(_version$i); + var _version_1$9 = _version$i.version; + + var abstractSigner = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$i.version); + var allowedTransactionKeys = [ + "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" + ]; + // Sub-Class Notes: + // - A Signer MUST always make sure, that if present, the "from" field + // matches the Signer, before sending or signing a transaction + // - A Signer SHOULD always wrap private information (such as a private + // key or mnemonic) in a function, so that console.log does not leak + // the data + var Signer = /** @class */ (function () { + /////////////////// + // Sub-classes MUST call super + function Signer() { + var _newTarget = this.constructor; + logger$1.checkAbstract(_newTarget, Signer); + properties.defineReadOnly(this, "_isSigner", true); + } + /////////////////// + // Sub-classes MAY override these + Signer.prototype.getBalance = function (blockTag) { + this._checkProvider("getBalance"); + return this.provider.getBalance(this.getAddress(), blockTag); + }; + Signer.prototype.getTransactionCount = function (blockTag) { + this._checkProvider("getTransactionCount"); + return this.provider.getTransactionCount(this.getAddress(), blockTag); + }; + // Populates "from" if unspecified, and estimates the gas for the transation + Signer.prototype.estimateGas = function (transaction) { + var _this = this; + this._checkProvider("estimateGas"); + return properties.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return _this.provider.estimateGas(tx); + }); + }; + // Populates "from" if unspecified, and calls with the transation + Signer.prototype.call = function (transaction, blockTag) { + var _this = this; + this._checkProvider("call"); + return properties.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return _this.provider.call(tx); + }); + }; + // Populates all fields in a transaction, signs it and sends it to the network + Signer.prototype.sendTransaction = function (transaction) { + var _this = this; + this._checkProvider("sendTransaction"); + return this.populateTransaction(transaction).then(function (tx) { + return _this.signTransaction(tx).then(function (signedTx) { + return _this.provider.sendTransaction(signedTx); + }); + }); + }; + Signer.prototype.getChainId = function () { + this._checkProvider("getChainId"); + return this.provider.getNetwork().then(function (network) { return network.chainId; }); + }; + Signer.prototype.getGasPrice = function () { + this._checkProvider("getGasPrice"); + return this.provider.getGasPrice(); + }; + Signer.prototype.resolveName = function (name) { + this._checkProvider("resolveName"); + return this.provider.resolveName(name); + }; + // Checks a transaction does not contain invalid keys and if + // no "from" is provided, populates it. + // - does NOT require a provider + // - adds "from" is not present + // - returns a COPY (safe to mutate the result) + // By default called from: (overriding these prevents it) + // - call + // - estimateGas + // - populateTransaction (and therefor sendTransaction) + Signer.prototype.checkTransaction = function (transaction) { + for (var key in transaction) { + if (allowedTransactionKeys.indexOf(key) === -1) { + logger$1.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + } + } + var tx = properties.shallowCopy(transaction); + if (tx.from == null) { + tx.from = this.getAddress(); + } + return tx; + }; + // Populates ALL keys for a transaction and checks that "from" matches + // this Signer. Should be used by sendTransaction but NOT by signTransaction. + // By default called from: (overriding these prevents it) + // - sendTransaction + Signer.prototype.populateTransaction = function (transaction) { + var _this = this; + return properties.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + if (tx.to != null) { + tx.to = Promise.resolve(tx.to).then(function (to) { return _this.resolveName(to); }); + } + if (tx.gasPrice == null) { + tx.gasPrice = _this.getGasPrice(); + } + if (tx.nonce == null) { + tx.nonce = _this.getTransactionCount("pending"); + } + // Make sure any provided address matches this signer + if (tx.from == null) { + tx.from = _this.getAddress(); + } + else { + tx.from = Promise.all([ + _this.getAddress(), + _this.provider.resolveName(tx.from) + ]).then(function (results) { + if (results[0] !== results[1]) { + logger$1.throwArgumentError("from address mismatch", "transaction", transaction); + } + return results[0]; + }); + } + if (tx.gasLimit == null) { + tx.gasLimit = _this.estimateGas(tx).catch(function (error) { + logger$1.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { + tx: tx + }); + }); + } + if (tx.chainId == null) { + tx.chainId = _this.getChainId(); + } + return properties.resolveProperties(tx); + }); + }; + /////////////////// + // Sub-classes SHOULD leave these alone + Signer.prototype._checkProvider = function (operation) { + if (!this.provider) { + logger$1.throwError("missing provider", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: (operation || "_checkProvider") + }); + } + }; + Signer.isSigner = function (value) { + return !!(value && value._isSigner); + }; + return Signer; + }()); + exports.Signer = Signer; + var VoidSigner = /** @class */ (function (_super) { + __extends(VoidSigner, _super); + function VoidSigner(address, provider) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, VoidSigner); + _this = _super.call(this) || this; + properties.defineReadOnly(_this, "address", address); + properties.defineReadOnly(_this, "provider", provider || null); + return _this; + } + VoidSigner.prototype.getAddress = function () { + return Promise.resolve(this.address); + }; + VoidSigner.prototype._fail = function (message, operation) { + return Promise.resolve().then(function () { + logger$1.throwError(message, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); + }); + }; + VoidSigner.prototype.signMessage = function (message) { + return this._fail("VoidSigner cannot sign messages", "signMessage"); + }; + VoidSigner.prototype.signTransaction = function (transaction) { + return this._fail("VoidSigner cannot sign transactions", "signTransaction"); + }; + VoidSigner.prototype.connect = function (provider) { + return new VoidSigner(this.address, provider); + }; + return VoidSigner; + }(Signer)); + exports.VoidSigner = VoidSigner; + }); + + var index$c = unwrapExports(abstractSigner); + var abstractSigner_1 = abstractSigner.Signer; + var abstractSigner_2 = abstractSigner.VoidSigner; + + var _version$k = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "contracts/5.0.0-beta.137"; + }); + + var _version$l = unwrapExports(_version$k); + var _version_1$a = _version$k.version; + + var contracts = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + + + var logger$1 = new logger.Logger(_version$k.version); + /////////////////////////////// + var allowedTransactionKeys = { + chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true + }; + // Recursively replaces ENS names with promises to resolve the name and resolves all properties + function resolveAddresses(signerOrProvider, value, paramType) { + if (Array.isArray(paramType)) { + return Promise.all(paramType.map(function (paramType, index) { + return resolveAddresses(signerOrProvider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); + })); + } + if (paramType.type === "address") { + return signerOrProvider.resolveName(value); + } + if (paramType.type === "tuple") { + return resolveAddresses(signerOrProvider, value, paramType.components); + } + if (paramType.baseType === "array") { + if (!Array.isArray(value)) { + throw new Error("invalid value for array"); + } + return Promise.all(value.map(function (v) { return resolveAddresses(signerOrProvider, v, paramType.arrayChildren); })); + } + return Promise.resolve(value); + } + function runMethod(contract, functionName, options) { + var method = contract.interface.functions[functionName]; + return function () { + var _this = this; + var params = []; + for (var _i = 0; _i < arguments.length; _i++) { + params[_i] = arguments[_i]; + } + var tx = {}; + var blockTag = null; + // If 1 extra parameter was passed in, it contains overrides + if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === "object") { + tx = properties.shallowCopy(params.pop()); + if (tx.blockTag != null) { + blockTag = tx.blockTag; + } + delete tx.blockTag; + // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") + for (var key in tx) { + if (!allowedTransactionKeys[key]) { + logger$1.throwError(("unknown transaxction override - " + key), "overrides", tx); + } + } + } + logger$1.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); + // Check overrides make sense + ["data", "to"].forEach(function (key) { + if (tx[key] != null) { + logger$1.throwError("cannot override " + key, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + } + }); + // If the contract was just deployed, wait until it is minded + if (contract.deployTransaction != null) { + tx.to = contract._deployed(blockTag).then(function () { + return contract.addressPromise; + }); + } + else { + tx.to = contract.addressPromise; + } + return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then(function (params) { + tx.data = contract.interface.encodeFunctionData(method, params); + if (method.constant || options.callStatic) { + // Call (constant functions) always cost 0 ether + if (options.estimate) { + return Promise.resolve(constants.Zero); + } + if (!contract.provider && !contract.signer) { + logger$1.throwError("call (constant functions) require a provider or signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" }); + } + // Check overrides make sense + ["gasLimit", "gasPrice", "value"].forEach(function (key) { + if (tx[key] != null) { + throw new Error("call cannot override " + key); + } + }); + if (options.transaction) { + return properties.resolveProperties(tx); + } + return (contract.signer || contract.provider).call(tx, blockTag).then(function (value) { + try { + var result = contract.interface.decodeFunctionResult(method, value); + if (method.outputs.length === 1) { + result = result[0]; + } + return result; + } + catch (error) { + if (error.code === logger.Logger.errors.CALL_EXCEPTION) { + error.address = contract.address; + error.args = params; + error.transaction = tx; + } + throw error; + } + }); + } + // Only computing the transaction estimate + if (options.estimate) { + if (!contract.provider && !contract.signer) { + logger$1.throwError("estimate require a provider or signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); + } + return (contract.signer || contract.provider).estimateGas(tx); + } + if (tx.gasLimit == null && method.gas != null) { + tx.gasLimit = bignumber$2.BigNumber.from(method.gas).add(21000); + } + if (tx.value != null && !method.payable) { + logger$1.throwArgumentError("contract method is not payable", "sendTransaction:" + method.format(), tx); + } + if (options.transaction) { + return properties.resolveProperties(tx); + } + if (!contract.signer) { + logger$1.throwError("sending a transaction require a signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); + } + return contract.signer.sendTransaction(tx).then(function (tx) { + var wait = tx.wait.bind(tx); + tx.wait = function (confirmations) { + return wait(confirmations).then(function (receipt) { + receipt.events = receipt.logs.map(function (log) { + var event = properties.deepCopy(log); + var parsed = contract.interface.parseLog(log); + if (parsed) { + event.values = parsed.values; + event.decode = function (data, topics) { + return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.event = parsed.name; + event.eventSignature = parsed.signature; + } + event.removeListener = function () { return contract.provider; }; + event.getBlock = function () { + return contract.provider.getBlock(receipt.blockHash); + }; + event.getTransaction = function () { + return contract.provider.getTransaction(receipt.transactionHash); + }; + event.getTransactionReceipt = function () { + return Promise.resolve(receipt); + }; + return event; + }); + return receipt; + }); + }; + return tx; + }); + }); + }; + } + function getEventTag(filter) { + if (filter.address && (filter.topics == null || filter.topics.length === 0)) { + return "*"; + } + return (filter.address || "*") + "@" + (filter.topics ? filter.topics.join(":") : ""); + } + var RunningEvent = /** @class */ (function () { + function RunningEvent(tag, filter) { + properties.defineReadOnly(this, "tag", tag); + properties.defineReadOnly(this, "filter", filter); + this._listeners = []; + } + RunningEvent.prototype.addListener = function (listener, once) { + this._listeners.push({ listener: listener, once: once }); + }; + RunningEvent.prototype.removeListener = function (listener) { + var done = false; + this._listeners = this._listeners.filter(function (item) { + if (done || item.listener !== listener) { + return true; + } + done = true; + return false; + }); + }; + RunningEvent.prototype.removeAllListeners = function () { + this._listeners = []; + }; + RunningEvent.prototype.listeners = function () { + return this._listeners.map(function (i) { return i.listener; }); + }; + RunningEvent.prototype.listenerCount = function () { + return this._listeners.length; + }; + RunningEvent.prototype.run = function (args) { + var _this = this; + var listenerCount = this.listenerCount(); + this._listeners = this._listeners.filter(function (item) { + var argsCopy = args.slice(); + // Call the callback in the next event loop + setTimeout(function () { + item.listener.apply(_this, argsCopy); + }, 0); + // Reschedule it if it not "once" + return !(item.once); + }); + return listenerCount; + }; + RunningEvent.prototype.prepareEvent = function (event) { + }; + return RunningEvent; + }()); + var ErrorRunningEvent = /** @class */ (function (_super) { + __extends(ErrorRunningEvent, _super); + function ErrorRunningEvent() { + return _super.call(this, "error", null) || this; + } + return ErrorRunningEvent; + }(RunningEvent)); + var FragmentRunningEvent = /** @class */ (function (_super) { + __extends(FragmentRunningEvent, _super); + function FragmentRunningEvent(address, contractInterface, fragment, topics) { + var _this = this; + var filter = { + address: address + }; + var topic = contractInterface.getEventTopic(fragment); + if (topics) { + if (topic !== topics[0]) { + logger$1.throwArgumentError("topic mismatch", "topics", topics); + } + filter.topics = topics.slice(); + } + else { + filter.topics = [topic]; + } + _this = _super.call(this, getEventTag(filter), filter) || this; + properties.defineReadOnly(_this, "address", address); + properties.defineReadOnly(_this, "interface", contractInterface); + properties.defineReadOnly(_this, "fragment", fragment); + return _this; + } + FragmentRunningEvent.prototype.prepareEvent = function (event) { + var _this = this; + _super.prototype.prepareEvent.call(this, event); + event.event = this.fragment.name; + event.eventSignature = this.fragment.format(); + event.decode = function (data, topics) { + return _this.interface.decodeEventLog(_this.fragment, data, topics); + }; + event.values = this.interface.decodeEventLog(this.fragment, event.data, event.topics); + }; + return FragmentRunningEvent; + }(RunningEvent)); + var WildcardRunningEvent = /** @class */ (function (_super) { + __extends(WildcardRunningEvent, _super); + function WildcardRunningEvent(address, contractInterface) { + var _this = _super.call(this, "*", { address: address }) || this; + properties.defineReadOnly(_this, "address", address); + properties.defineReadOnly(_this, "interface", contractInterface); + return _this; + } + WildcardRunningEvent.prototype.prepareEvent = function (event) { + var _this = this; + _super.prototype.prepareEvent.call(this, event); + var parsed = this.interface.parseLog(event); + if (parsed) { + event.event = parsed.name; + event.eventSignature = parsed.signature; + event.decode = function (data, topics) { + return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); + }; + event.values = parsed.values; + } + }; + return WildcardRunningEvent; + }(RunningEvent)); + var Contract = /** @class */ (function () { + function Contract(addressOrName, contractInterface, signerOrProvider) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, Contract); + // @TODO: Maybe still check the addressOrName looks like a valid address or name? + //address = getAddress(address); + properties.defineReadOnly(this, "interface", properties.getStatic((_newTarget), "getInterface")(contractInterface)); + if (abstractSigner.Signer.isSigner(signerOrProvider)) { + properties.defineReadOnly(this, "provider", signerOrProvider.provider || null); + properties.defineReadOnly(this, "signer", signerOrProvider); + } + else if (abstractProvider.Provider.isProvider(signerOrProvider)) { + properties.defineReadOnly(this, "provider", signerOrProvider); + properties.defineReadOnly(this, "signer", null); + } + else { + logger$1.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); + } + properties.defineReadOnly(this, "callStatic", {}); + properties.defineReadOnly(this, "estimate", {}); + properties.defineReadOnly(this, "functions", {}); + properties.defineReadOnly(this, "populateTransaction", {}); + properties.defineReadOnly(this, "filters", {}); + Object.keys(this.interface.events).forEach(function (eventName) { + var event = _this.interface.events[eventName]; + properties.defineReadOnly(_this.filters, eventName, function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return { + address: _this.address, + topics: _this.interface.encodeFilterTopics(event, args) + }; + }); + }); + properties.defineReadOnly(this, "_runningEvents", {}); + properties.defineReadOnly(this, "_wrappedEmits", {}); + properties.defineReadOnly(this, "address", addressOrName); + if (this.provider) { + properties.defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then(function (address) { + if (address == null) { + throw new Error("name not found"); + } + return address; + }).catch(function (error) { + console.log("ERROR: Cannot find Contract - " + addressOrName); + throw error; + })); + } + else { + try { + properties.defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); + } + catch (error) { + // Without a provider, we cannot use ENS names + logger$1.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); + } + } + Object.keys(this.interface.functions).forEach(function (name) { + var run = runMethod(_this, name, {}); + if (_this[name] == null) { + properties.defineReadOnly(_this, name, run); + } + if (_this.functions[name] == null) { + properties.defineReadOnly(_this.functions, name, run); + } + if (_this.callStatic[name] == null) { + properties.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true })); + } + if (_this.populateTransaction[name] == null) { + properties.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true })); + } + if (_this.estimate[name] == null) { + properties.defineReadOnly(_this.estimate, name, runMethod(_this, name, { estimate: true })); + } + }); + } + Contract.getContractAddress = function (transaction) { + return address.getContractAddress(transaction); + }; + Contract.getInterface = function (contractInterface) { + if (abi.Interface.isInterface(contractInterface)) { + return contractInterface; + } + return new abi.Interface(contractInterface); + }; + // @TODO: Allow timeout? + Contract.prototype.deployed = function () { + return this._deployed(); + }; + Contract.prototype._deployed = function (blockTag) { + var _this = this; + if (!this._deployedPromise) { + // If we were just deployed, we know the transaction we should occur in + if (this.deployTransaction) { + this._deployedPromise = this.deployTransaction.wait().then(function () { + return _this; + }); + } + else { + // @TODO: Once we allow a timeout to be passed in, we will wait + // up to that many blocks for getCode + // Otherwise, poll for our code to be deployed + this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) { + if (code === "0x") { + logger$1.throwError("contract not deployed", logger.Logger.errors.UNSUPPORTED_OPERATION, { + contractAddress: _this.address, + operation: "getDeployed" + }); + } + return _this; + }); + } + } + return this._deployedPromise; + }; + // @TODO: + // estimateFallback(overrides?: TransactionRequest): Promise + // @TODO: + // estimateDeploy(bytecode: string, ...args): Promise + Contract.prototype.fallback = function (overrides) { + var _this = this; + if (!this.signer) { + logger$1.throwError("sending a transaction require a signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + } + var tx = properties.shallowCopy(overrides || {}); + ["from", "to"].forEach(function (key) { + if (tx[key] == null) { + return; + } + logger$1.throwError("cannot override " + key, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + tx.to = this.addressPromise; + return this.deployed().then(function () { + return _this.signer.sendTransaction(tx); + }); + }; + // Reconnect to a different signer or provider + Contract.prototype.connect = function (signerOrProvider) { + if (typeof (signerOrProvider) === "string") { + signerOrProvider = new abstractSigner.VoidSigner(signerOrProvider, this.provider); + } + var contract = new (this.constructor)(this.address, this.interface, signerOrProvider); + if (this.deployTransaction) { + properties.defineReadOnly(contract, "deployTransaction", this.deployTransaction); + } + return contract; + }; + // Re-attach to a different on-chain instance of this contract + Contract.prototype.attach = function (addressOrName) { + return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider); + }; + Contract.isIndexed = function (value) { + return abi.Indexed.isIndexed(value); + }; + Contract.prototype._normalizeRunningEvent = function (runningEvent) { + // Already have an instance of this event running; we can re-use it + if (this._runningEvents[runningEvent.tag]) { + return this._runningEvents[runningEvent.tag]; + } + return runningEvent; + }; + Contract.prototype._getRunningEvent = function (eventName) { + if (typeof (eventName) === "string") { + // Listen for "error" events (if your contract has an error event, include + // the full signature to bypass this special event keyword) + if (eventName === "error") { + return this._normalizeRunningEvent(new ErrorRunningEvent()); + } + // Listen for any event + if (eventName === "*") { + return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); + } + var fragment = this.interface.getEvent(eventName); + if (!fragment) { + logger$1.throwArgumentError("unknown event - " + eventName, "eventName", eventName); + } + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); + } + var filter = { + address: this.address + }; + // Find the matching event in the ABI; if none, we still allow filtering + // since it may be a filter for an otherwise unknown event + if (eventName.topics) { + if (eventName.topics[0]) { + var fragment = this.interface.getEvent(eventName.topics[0]); + if (fragment) { + return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); + } + } + filter.topics = eventName.topics; + } + return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter)); + }; + Contract.prototype._checkRunningEvents = function (runningEvent) { + if (runningEvent.listenerCount() === 0) { + delete this._runningEvents[runningEvent.tag]; + } + // If we have a poller for this, remove it + var emit = this._wrappedEmits[runningEvent.tag]; + if (emit) { + this.provider.off(runningEvent.filter, emit); + delete this._wrappedEmits[runningEvent.tag]; + } + }; + Contract.prototype._wrapEvent = function (runningEvent, log, listener) { + var _this = this; + var event = properties.deepCopy(log); + try { + runningEvent.prepareEvent(event); + } + catch (error) { + this.emit("error", error); + throw error; + } + event.removeListener = function () { + if (!listener) { + return; + } + runningEvent.removeListener(listener); + _this._checkRunningEvents(runningEvent); + }; + event.getBlock = function () { return _this.provider.getBlock(log.blockHash); }; + event.getTransaction = function () { return _this.provider.getTransaction(log.transactionHash); }; + event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); }; + return event; + }; + Contract.prototype._addEventListener = function (runningEvent, listener, once) { + var _this = this; + if (!this.provider) { + logger$1.throwError("events require a provider or a signer with a provider", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); + } + runningEvent.addListener(listener, once); + // Track this running event and its listeners (may already be there; but no hard in updating) + this._runningEvents[runningEvent.tag] = runningEvent; + // If we are not polling the provider, start + if (!this._wrappedEmits[runningEvent.tag]) { + var wrappedEmit = function (log) { + var event = _this._wrapEvent(runningEvent, log, listener); + var values = (event.values || []); + values.push(event); + _this.emit.apply(_this, [runningEvent.filter].concat(values)); + }; + this._wrappedEmits[runningEvent.tag] = wrappedEmit; + // Special events, like "error" do not have a filter + if (runningEvent.filter != null) { + this.provider.on(runningEvent.filter, wrappedEmit); + } + } + }; + Contract.prototype.queryFilter = function (event, fromBlockOrBlockhash, toBlock) { + var _this = this; + var runningEvent = this._getRunningEvent(event); + var filter = properties.shallowCopy(runningEvent.filter); + if (typeof (fromBlockOrBlockhash) === "string" && bytes.isHexString(fromBlockOrBlockhash, 32)) { + if (toBlock != null) { + logger$1.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); + } + filter.blockhash = fromBlockOrBlockhash; + } + else { + filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0); + filter.toBlock = ((toBlock != null) ? toBlock : "latest"); + } + return this.provider.getLogs(filter).then(function (logs) { + return logs.map(function (log) { return _this._wrapEvent(runningEvent, log, null); }); + }); + }; + Contract.prototype.on = function (event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, false); + return this; + }; + Contract.prototype.once = function (event, listener) { + this._addEventListener(this._getRunningEvent(event), listener, true); + return this; + }; + Contract.prototype.emit = function (eventName) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + if (!this.provider) { + return false; + } + var runningEvent = this._getRunningEvent(eventName); + var result = (runningEvent.run(args) > 0); + // May have drained all the "once" events; check for living events + this._checkRunningEvents(runningEvent); + return result; + }; + Contract.prototype.listenerCount = function (eventName) { + if (!this.provider) { + return 0; + } + return this._getRunningEvent(eventName).listenerCount(); + }; + Contract.prototype.listeners = function (eventName) { + if (!this.provider) { + return []; + } + if (eventName == null) { + var result_1 = []; + for (var tag in this._runningEvents) { + this._runningEvents[tag].listeners().forEach(function (listener) { + result_1.push(listener); + }); + } + return result_1; + } + return this._getRunningEvent(eventName).listeners(); + }; + Contract.prototype.removeAllListeners = function (eventName) { + if (!this.provider) { + return this; + } + if (eventName == null) { + for (var tag in this._runningEvents) { + var runningEvent_1 = this._runningEvents[tag]; + runningEvent_1.removeAllListeners(); + this._checkRunningEvents(runningEvent_1); + } + return this; + } + // Delete any listeners + var runningEvent = this._getRunningEvent(eventName); + runningEvent.removeAllListeners(); + this._checkRunningEvents(runningEvent); + return this; + }; + Contract.prototype.off = function (eventName, listener) { + if (!this.provider) { + return this; + } + var runningEvent = this._getRunningEvent(eventName); + runningEvent.removeListener(listener); + this._checkRunningEvents(runningEvent); + return this; + }; + Contract.prototype.removeListener = function (eventName, listener) { + return this.off(eventName, listener); + }; + return Contract; + }()); + exports.Contract = Contract; + var ContractFactory = /** @class */ (function () { + function ContractFactory(contractInterface, bytecode, signer) { + var _newTarget = this.constructor; + var bytecodeHex = null; + if (typeof (bytecode) === "string") { + bytecodeHex = bytecode; + } + else if (bytes.isBytes(bytecode)) { + bytecodeHex = bytes.hexlify(bytecode); + } + else if (bytecode && typeof (bytecode.object) === "string") { + // Allow the bytecode object from the Solidity compiler + bytecodeHex = bytecode.object; + } + else { + // Crash in the next verification step + bytecodeHex = "!"; + } + // Make sure it is 0x prefixed + if (bytecodeHex.substring(0, 2) !== "0x") { + bytecodeHex = "0x" + bytecodeHex; + } + // Make sure the final result is valid bytecode + if (!bytes.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { + logger$1.throwArgumentError("invalid bytecode", "bytecode", bytecode); + } + // If we have a signer, make sure it is valid + if (signer && !abstractSigner.Signer.isSigner(signer)) { + logger$1.throwArgumentError("invalid signer", "signer", signer); + } + properties.defineReadOnly(this, "bytecode", bytecodeHex); + properties.defineReadOnly(this, "interface", properties.getStatic((_newTarget), "getInterface")(contractInterface)); + properties.defineReadOnly(this, "signer", signer || null); + } + ContractFactory.prototype.getDeployTransaction = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var tx = {}; + // If we have 1 additional argument, we allow transaction overrides + if (args.length === this.interface.deploy.inputs.length + 1) { + tx = properties.shallowCopy(args.pop()); + for (var key in tx) { + if (!allowedTransactionKeys[key]) { + throw new Error("unknown transaction override " + key); + } + } + } + // Do not allow these to be overridden in a deployment transaction + ["data", "from", "to"].forEach(function (key) { + if (tx[key] == null) { + return; + } + logger$1.throwError("cannot override " + key, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + }); + // Make sure the call matches the constructor signature + logger$1.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + // Set the data to the bytecode + the encoded constructor arguments + tx.data = bytes.hexlify(bytes.concat([ + this.bytecode, + this.interface.encodeDeploy(args) + ])); + return tx; + }; + ContractFactory.prototype.deploy = function () { + var _this = this; + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return resolveAddresses(this.signer, args, this.interface.deploy.inputs).then(function (args) { + // Get the deployment transaction (with optional overrides) + var tx = _this.getDeployTransaction.apply(_this, args); + // Send the deployment transaction + return _this.signer.sendTransaction(tx).then(function (tx) { + var address = (_this.constructor).getContractAddress(tx); + var contract = (_this.constructor).getContract(address, _this.interface, _this.signer); + properties.defineReadOnly(contract, "deployTransaction", tx); + return contract; + }); + }); + }; + ContractFactory.prototype.attach = function (address) { + return (this.constructor).getContract(address, this.interface, this.signer); + }; + ContractFactory.prototype.connect = function (signer) { + return new (this.constructor)(this.interface, this.bytecode, signer); + }; + ContractFactory.fromSolidity = function (compilerOutput, signer) { + if (compilerOutput == null) { + logger$1.throwError("missing compiler output", logger.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + } + if (typeof (compilerOutput) === "string") { + compilerOutput = JSON.parse(compilerOutput); + } + var abi = compilerOutput.abi; + var bytecode = null; + if (compilerOutput.bytecode) { + bytecode = compilerOutput.bytecode; + } + else if (compilerOutput.evm && compilerOutput.evm.bytecode) { + bytecode = compilerOutput.evm.bytecode; + } + return new this(abi, bytecode, signer); + }; + ContractFactory.getInterface = function (contractInterface) { + return Contract.getInterface(contractInterface); + }; + ContractFactory.getContractAddress = function (tx) { + return address.getContractAddress(tx); + }; + ContractFactory.getContract = function (address, contractInterface, signer) { + return new Contract(address, contractInterface, signer); + }; + return ContractFactory; + }()); + exports.ContractFactory = ContractFactory; + }); + + var index$d = unwrapExports(contracts); + var contracts_1 = contracts.Contract; + var contracts_2 = contracts.ContractFactory; + + var basex = createCommonjsModule(function (module, exports) { + "use strict"; + /** + * var basex = require("base-x"); + * + * This implementation is heavily based on base-x. The main reason to + * deviate was to prevent the dependency of Buffer. + * + * Contributors: + * + * base-x encoding + * Forked from https://github.com/cryptocoinjs/bs58 + * Originally written by Mike Hearn for BitcoinJ + * Copyright (c) 2011 Google Inc + * Ported to JavaScript by Stefan Thomas + * Merged Buffer refactorings from base58-native by Stephen Pair + * Copyright (c) 2013 BitPay Inc + * + * The MIT License (MIT) + * + * Copyright base-x contributors (c) 2016 + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + Object.defineProperty(exports, "__esModule", { value: true }); + + + var BaseX = /** @class */ (function () { + function BaseX(alphabet) { + properties.defineReadOnly(this, "alphabet", alphabet); + properties.defineReadOnly(this, "base", alphabet.length); + properties.defineReadOnly(this, "_alphabetMap", {}); + properties.defineReadOnly(this, "_leader", alphabet.charAt(0)); + // pre-compute lookup table + for (var i = 0; i < alphabet.length; i++) { + this._alphabetMap[alphabet.charAt(i)] = i; + } + } + BaseX.prototype.encode = function (value) { + var source = bytes.arrayify(value); + if (source.length === 0) { + return ""; + } + var digits = [0]; + for (var i = 0; i < source.length; ++i) { + var carry = source[i]; + for (var j = 0; j < digits.length; ++j) { + carry += digits[j] << 8; + digits[j] = carry % this.base; + carry = (carry / this.base) | 0; + } + while (carry > 0) { + digits.push(carry % this.base); + carry = (carry / this.base) | 0; + } + } + var string = ""; + // deal with leading zeros + for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) { + string += this._leader; + } + // convert digits to a string + for (var q = digits.length - 1; q >= 0; --q) { + string += this.alphabet[digits[q]]; + } + return string; + }; + BaseX.prototype.decode = function (value) { + if (typeof (value) !== "string") { + throw new TypeError("Expected String"); + } + var bytes$1 = []; + if (value.length === 0) { + return new Uint8Array(bytes$1); + } + bytes$1.push(0); + for (var i = 0; i < value.length; i++) { + var byte = this._alphabetMap[value[i]]; + if (byte === undefined) { + throw new Error("Non-base" + this.base + " character"); + } + var carry = byte; + for (var j = 0; j < bytes$1.length; ++j) { + carry += bytes$1[j] * this.base; + bytes$1[j] = carry & 0xff; + carry >>= 8; + } + while (carry > 0) { + bytes$1.push(carry & 0xff); + carry >>= 8; + } + } + // deal with leading zeros + for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) { + bytes$1.push(0); + } + return bytes.arrayify(new Uint8Array(bytes$1.reverse())); + }; + return BaseX; + }()); + exports.BaseX = BaseX; + var Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); + exports.Base32 = Base32; + var Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); + exports.Base58 = Base58; + //console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) + //console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) + }); + + var index$e = unwrapExports(basex); + var basex_1 = basex.BaseX; + var basex_2 = basex.Base32; + var basex_3 = basex.Base58; + + var minimalisticAssert = assert; + + function assert(val, msg) { + if (!val) + throw new Error(msg || 'Assertion failed'); + } + + assert.equal = function assertEqual(l, r, msg) { + if (l != r) + throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); + }; + + var inherits_browser = createCommonjsModule(function (module) { + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + }); + + 'use strict'; + + + + + var inherits_1 = inherits_browser; + + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg === 'string') { + if (!enc) { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } else if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } + } else { + for (i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + } + return res; + } + var toArray_1 = toArray; + + function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; + } + var toHex_1 = toHex; + + function htonl(w) { + var res = (w >>> 24) | + ((w >>> 8) & 0xff00) | + ((w << 8) & 0xff0000) | + ((w & 0xff) << 24); + return res >>> 0; + } + var htonl_1 = htonl; + + function toHex32(msg, endian) { + var res = ''; + for (var i = 0; i < msg.length; i++) { + var w = msg[i]; + if (endian === 'little') + w = htonl(w); + res += zero8(w.toString(16)); + } + return res; + } + var toHex32_1 = toHex32; + + function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; + } + var zero2_1 = zero2; + + function zero8(word) { + if (word.length === 7) + return '0' + word; + else if (word.length === 6) + return '00' + word; + else if (word.length === 5) + return '000' + word; + else if (word.length === 4) + return '0000' + word; + else if (word.length === 3) + return '00000' + word; + else if (word.length === 2) + return '000000' + word; + else if (word.length === 1) + return '0000000' + word; + else + return word; + } + var zero8_1 = zero8; + + function join32(msg, start, end, endian) { + var len = end - start; + minimalisticAssert(len % 4 === 0); + var res = new Array(len / 4); + for (var i = 0, k = start; i < res.length; i++, k += 4) { + var w; + if (endian === 'big') + w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; + else + w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; + res[i] = w >>> 0; + } + return res; + } + var join32_1 = join32; + + function split32(msg, endian) { + var res = new Array(msg.length * 4); + for (var i = 0, k = 0; i < msg.length; i++, k += 4) { + var m = msg[i]; + if (endian === 'big') { + res[k] = m >>> 24; + res[k + 1] = (m >>> 16) & 0xff; + res[k + 2] = (m >>> 8) & 0xff; + res[k + 3] = m & 0xff; + } else { + res[k + 3] = m >>> 24; + res[k + 2] = (m >>> 16) & 0xff; + res[k + 1] = (m >>> 8) & 0xff; + res[k] = m & 0xff; + } + } + return res; + } + var split32_1 = split32; + + function rotr32(w, b) { + return (w >>> b) | (w << (32 - b)); + } + var rotr32_1 = rotr32; + + function rotl32(w, b) { + return (w << b) | (w >>> (32 - b)); + } + var rotl32_1 = rotl32; + + function sum32(a, b) { + return (a + b) >>> 0; + } + var sum32_1 = sum32; + + function sum32_3(a, b, c) { + return (a + b + c) >>> 0; + } + var sum32_3_1 = sum32_3; + + function sum32_4(a, b, c, d) { + return (a + b + c + d) >>> 0; + } + var sum32_4_1 = sum32_4; + + function sum32_5(a, b, c, d, e) { + return (a + b + c + d + e) >>> 0; + } + var sum32_5_1 = sum32_5; + + function sum64(buf, pos, ah, al) { + var bh = buf[pos]; + var bl = buf[pos + 1]; + + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + buf[pos] = hi >>> 0; + buf[pos + 1] = lo; + } + var sum64_1 = sum64; + + function sum64_hi(ah, al, bh, bl) { + var lo = (al + bl) >>> 0; + var hi = (lo < al ? 1 : 0) + ah + bh; + return hi >>> 0; + } + var sum64_hi_1 = sum64_hi; + + function sum64_lo(ah, al, bh, bl) { + var lo = al + bl; + return lo >>> 0; + } + var sum64_lo_1 = sum64_lo; + + function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + + var hi = ah + bh + ch + dh + carry; + return hi >>> 0; + } + var sum64_4_hi_1 = sum64_4_hi; + + function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { + var lo = al + bl + cl + dl; + return lo >>> 0; + } + var sum64_4_lo_1 = sum64_4_lo; + + function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var carry = 0; + var lo = al; + lo = (lo + bl) >>> 0; + carry += lo < al ? 1 : 0; + lo = (lo + cl) >>> 0; + carry += lo < cl ? 1 : 0; + lo = (lo + dl) >>> 0; + carry += lo < dl ? 1 : 0; + lo = (lo + el) >>> 0; + carry += lo < el ? 1 : 0; + + var hi = ah + bh + ch + dh + eh + carry; + return hi >>> 0; + } + var sum64_5_hi_1 = sum64_5_hi; + + function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { + var lo = al + bl + cl + dl + el; + + return lo >>> 0; + } + var sum64_5_lo_1 = sum64_5_lo; + + function rotr64_hi(ah, al, num) { + var r = (al << (32 - num)) | (ah >>> num); + return r >>> 0; + } + var rotr64_hi_1 = rotr64_hi; + + function rotr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; + } + var rotr64_lo_1 = rotr64_lo; + + function shr64_hi(ah, al, num) { + return ah >>> num; + } + var shr64_hi_1 = shr64_hi; + + function shr64_lo(ah, al, num) { + var r = (ah << (32 - num)) | (al >>> num); + return r >>> 0; + } + var shr64_lo_1 = shr64_lo; + + var utils = { + inherits: inherits_1, + toArray: toArray_1, + toHex: toHex_1, + htonl: htonl_1, + toHex32: toHex32_1, + zero2: zero2_1, + zero8: zero8_1, + join32: join32_1, + split32: split32_1, + rotr32: rotr32_1, + rotl32: rotl32_1, + sum32: sum32_1, + sum32_3: sum32_3_1, + sum32_4: sum32_4_1, + sum32_5: sum32_5_1, + sum64: sum64_1, + sum64_hi: sum64_hi_1, + sum64_lo: sum64_lo_1, + sum64_4_hi: sum64_4_hi_1, + sum64_4_lo: sum64_4_lo_1, + sum64_5_hi: sum64_5_hi_1, + sum64_5_lo: sum64_5_lo_1, + rotr64_hi: rotr64_hi_1, + rotr64_lo: rotr64_lo_1, + shr64_hi: shr64_hi_1, + shr64_lo: shr64_lo_1 + }; + + 'use strict'; + + + + + function BlockHash() { + this.pending = null; + this.pendingTotal = 0; + this.blockSize = this.constructor.blockSize; + this.outSize = this.constructor.outSize; + this.hmacStrength = this.constructor.hmacStrength; + this.padLength = this.constructor.padLength / 8; + this.endian = 'big'; + + this._delta8 = this.blockSize / 8; + this._delta32 = this.blockSize / 32; + } + var BlockHash_1 = BlockHash; + + BlockHash.prototype.update = function update(msg, enc) { + // Convert message to array, pad it, and join into 32bit blocks + msg = utils.toArray(msg, enc); + if (!this.pending) + this.pending = msg; + else + this.pending = this.pending.concat(msg); + this.pendingTotal += msg.length; + + // Enough data, try updating + if (this.pending.length >= this._delta8) { + msg = this.pending; + + // Process pending data in blocks + var r = msg.length % this._delta8; + this.pending = msg.slice(msg.length - r, msg.length); + if (this.pending.length === 0) + this.pending = null; + + msg = utils.join32(msg, 0, msg.length - r, this.endian); + for (var i = 0; i < msg.length; i += this._delta32) + this._update(msg, i, i + this._delta32); + } + + return this; + }; + + BlockHash.prototype.digest = function digest(enc) { + this.update(this._pad()); + minimalisticAssert(this.pending === null); + + return this._digest(enc); + }; + + BlockHash.prototype._pad = function pad() { + var len = this.pendingTotal; + var bytes = this._delta8; + var k = bytes - ((len + this.padLength) % bytes); + var res = new Array(k + this.padLength); + res[0] = 0x80; + for (var i = 1; i < k; i++) + res[i] = 0; + + // Append length + len <<= 3; + if (this.endian === 'big') { + for (var t = 8; t < this.padLength; t++) + res[i++] = 0; + + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = (len >>> 24) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = len & 0xff; + } else { + res[i++] = len & 0xff; + res[i++] = (len >>> 8) & 0xff; + res[i++] = (len >>> 16) & 0xff; + res[i++] = (len >>> 24) & 0xff; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + res[i++] = 0; + + for (t = 8; t < this.padLength; t++) + res[i++] = 0; + } + + return res; + }; + + var common = { + BlockHash: BlockHash_1 + }; + + var _1 = {}; + + var _224 = {}; + + 'use strict'; + + + var rotr32$1 = utils.rotr32; + + function ft_1(s, x, y, z) { + if (s === 0) + return ch32(x, y, z); + if (s === 1 || s === 3) + return p32(x, y, z); + if (s === 2) + return maj32(x, y, z); + } + var ft_1_1 = ft_1; + + function ch32(x, y, z) { + return (x & y) ^ ((~x) & z); + } + var ch32_1 = ch32; + + function maj32(x, y, z) { + return (x & y) ^ (x & z) ^ (y & z); + } + var maj32_1 = maj32; + + function p32(x, y, z) { + return x ^ y ^ z; + } + var p32_1 = p32; + + function s0_256(x) { + return rotr32$1(x, 2) ^ rotr32$1(x, 13) ^ rotr32$1(x, 22); + } + var s0_256_1 = s0_256; + + function s1_256(x) { + return rotr32$1(x, 6) ^ rotr32$1(x, 11) ^ rotr32$1(x, 25); + } + var s1_256_1 = s1_256; + + function g0_256(x) { + return rotr32$1(x, 7) ^ rotr32$1(x, 18) ^ (x >>> 3); + } + var g0_256_1 = g0_256; + + function g1_256(x) { + return rotr32$1(x, 17) ^ rotr32$1(x, 19) ^ (x >>> 10); + } + var g1_256_1 = g1_256; + + var common$1 = { + ft_1: ft_1_1, + ch32: ch32_1, + maj32: maj32_1, + p32: p32_1, + s0_256: s0_256_1, + s1_256: s1_256_1, + g0_256: g0_256_1, + g1_256: g1_256_1 + }; + + 'use strict'; + + + + + + + var sum32$1 = utils.sum32; + var sum32_4$1 = utils.sum32_4; + var sum32_5$1 = utils.sum32_5; + var ch32$1 = common$1.ch32; + var maj32$1 = common$1.maj32; + var s0_256$1 = common$1.s0_256; + var s1_256$1 = common$1.s1_256; + var g0_256$1 = common$1.g0_256; + var g1_256$1 = common$1.g1_256; + + var BlockHash$1 = common.BlockHash; + + var sha256_K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + ]; + + function SHA256() { + if (!(this instanceof SHA256)) + return new SHA256(); + + BlockHash$1.call(this); + this.h = [ + 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, + 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 + ]; + this.k = sha256_K; + this.W = new Array(64); + } + utils.inherits(SHA256, BlockHash$1); + var _256 = SHA256; + + SHA256.blockSize = 512; + SHA256.outSize = 256; + SHA256.hmacStrength = 192; + SHA256.padLength = 64; + + SHA256.prototype._update = function _update(msg, start) { + var W = this.W; + + for (var i = 0; i < 16; i++) + W[i] = msg[start + i]; + for (; i < W.length; i++) + W[i] = sum32_4$1(g1_256$1(W[i - 2]), W[i - 7], g0_256$1(W[i - 15]), W[i - 16]); + + var a = this.h[0]; + var b = this.h[1]; + var c = this.h[2]; + var d = this.h[3]; + var e = this.h[4]; + var f = this.h[5]; + var g = this.h[6]; + var h = this.h[7]; + + minimalisticAssert(this.k.length === W.length); + for (i = 0; i < W.length; i++) { + var T1 = sum32_5$1(h, s1_256$1(e), ch32$1(e, f, g), this.k[i], W[i]); + var T2 = sum32$1(s0_256$1(a), maj32$1(a, b, c)); + h = g; + g = f; + f = e; + e = sum32$1(d, T1); + d = c; + c = b; + b = a; + a = sum32$1(T1, T2); + } + + this.h[0] = sum32$1(this.h[0], a); + this.h[1] = sum32$1(this.h[1], b); + this.h[2] = sum32$1(this.h[2], c); + this.h[3] = sum32$1(this.h[3], d); + this.h[4] = sum32$1(this.h[4], e); + this.h[5] = sum32$1(this.h[5], f); + this.h[6] = sum32$1(this.h[6], g); + this.h[7] = sum32$1(this.h[7], h); + }; + + SHA256.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); + }; + + var _384 = {}; + + 'use strict'; + + + + + + var rotr64_hi$1 = utils.rotr64_hi; + var rotr64_lo$1 = utils.rotr64_lo; + var shr64_hi$1 = utils.shr64_hi; + var shr64_lo$1 = utils.shr64_lo; + var sum64$1 = utils.sum64; + var sum64_hi$1 = utils.sum64_hi; + var sum64_lo$1 = utils.sum64_lo; + var sum64_4_hi$1 = utils.sum64_4_hi; + var sum64_4_lo$1 = utils.sum64_4_lo; + var sum64_5_hi$1 = utils.sum64_5_hi; + var sum64_5_lo$1 = utils.sum64_5_lo; + + var BlockHash$2 = common.BlockHash; + + var sha512_K = [ + 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, + 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, + 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, + 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, + 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, + 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, + 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, + 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, + 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, + 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, + 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, + 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, + 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, + 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, + 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, + 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, + 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, + 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, + 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, + 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, + 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, + 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, + 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, + 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, + 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, + 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, + 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, + 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, + 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, + 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, + 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, + 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, + 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, + 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, + 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, + 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, + 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, + 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, + 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, + 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 + ]; + + function SHA512() { + if (!(this instanceof SHA512)) + return new SHA512(); + + BlockHash$2.call(this); + this.h = [ + 0x6a09e667, 0xf3bcc908, + 0xbb67ae85, 0x84caa73b, + 0x3c6ef372, 0xfe94f82b, + 0xa54ff53a, 0x5f1d36f1, + 0x510e527f, 0xade682d1, + 0x9b05688c, 0x2b3e6c1f, + 0x1f83d9ab, 0xfb41bd6b, + 0x5be0cd19, 0x137e2179 ]; + this.k = sha512_K; + this.W = new Array(160); + } + utils.inherits(SHA512, BlockHash$2); + var _512 = SHA512; + + SHA512.blockSize = 1024; + SHA512.outSize = 512; + SHA512.hmacStrength = 192; + SHA512.padLength = 128; + + SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { + var W = this.W; + + // 32 x 32bit words + for (var i = 0; i < 32; i++) + W[i] = msg[start + i]; + for (; i < W.length; i += 2) { + var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 + var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); + var c1_hi = W[i - 14]; // i - 7 + var c1_lo = W[i - 13]; + var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 + var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); + var c3_hi = W[i - 32]; // i - 16 + var c3_lo = W[i - 31]; + + W[i] = sum64_4_hi$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + W[i + 1] = sum64_4_lo$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo); + } + }; + + SHA512.prototype._update = function _update(msg, start) { + this._prepareBlock(msg, start); + + var W = this.W; + + var ah = this.h[0]; + var al = this.h[1]; + var bh = this.h[2]; + var bl = this.h[3]; + var ch = this.h[4]; + var cl = this.h[5]; + var dh = this.h[6]; + var dl = this.h[7]; + var eh = this.h[8]; + var el = this.h[9]; + var fh = this.h[10]; + var fl = this.h[11]; + var gh = this.h[12]; + var gl = this.h[13]; + var hh = this.h[14]; + var hl = this.h[15]; + + minimalisticAssert(this.k.length === W.length); + for (var i = 0; i < W.length; i += 2) { + var c0_hi = hh; + var c0_lo = hl; + var c1_hi = s1_512_hi(eh, el); + var c1_lo = s1_512_lo(eh, el); + var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); + var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); + var c3_hi = this.k[i]; + var c3_lo = this.k[i + 1]; + var c4_hi = W[i]; + var c4_lo = W[i + 1]; + + var T1_hi = sum64_5_hi$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + var T1_lo = sum64_5_lo$1( + c0_hi, c0_lo, + c1_hi, c1_lo, + c2_hi, c2_lo, + c3_hi, c3_lo, + c4_hi, c4_lo); + + c0_hi = s0_512_hi(ah, al); + c0_lo = s0_512_lo(ah, al); + c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); + c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); + + var T2_hi = sum64_hi$1(c0_hi, c0_lo, c1_hi, c1_lo); + var T2_lo = sum64_lo$1(c0_hi, c0_lo, c1_hi, c1_lo); + + hh = gh; + hl = gl; + + gh = fh; + gl = fl; + + fh = eh; + fl = el; + + eh = sum64_hi$1(dh, dl, T1_hi, T1_lo); + el = sum64_lo$1(dl, dl, T1_hi, T1_lo); + + dh = ch; + dl = cl; + + ch = bh; + cl = bl; + + bh = ah; + bl = al; + + ah = sum64_hi$1(T1_hi, T1_lo, T2_hi, T2_lo); + al = sum64_lo$1(T1_hi, T1_lo, T2_hi, T2_lo); + } + + sum64$1(this.h, 0, ah, al); + sum64$1(this.h, 2, bh, bl); + sum64$1(this.h, 4, ch, cl); + sum64$1(this.h, 6, dh, dl); + sum64$1(this.h, 8, eh, el); + sum64$1(this.h, 10, fh, fl); + sum64$1(this.h, 12, gh, gl); + sum64$1(this.h, 14, hh, hl); + }; + + SHA512.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'big'); + else + return utils.split32(this.h, 'big'); + }; + + function ch64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ ((~xh) & zh); + if (r < 0) + r += 0x100000000; + return r; + } + + function ch64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ ((~xl) & zl); + if (r < 0) + r += 0x100000000; + return r; + } + + function maj64_hi(xh, xl, yh, yl, zh) { + var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); + if (r < 0) + r += 0x100000000; + return r; + } + + function maj64_lo(xh, xl, yh, yl, zh, zl) { + var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); + if (r < 0) + r += 0x100000000; + return r; + } + + function s0_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 28); + var c1_hi = rotr64_hi$1(xl, xh, 2); // 34 + var c2_hi = rotr64_hi$1(xl, xh, 7); // 39 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function s0_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 28); + var c1_lo = rotr64_lo$1(xl, xh, 2); // 34 + var c2_lo = rotr64_lo$1(xl, xh, 7); // 39 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + function s1_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 14); + var c1_hi = rotr64_hi$1(xh, xl, 18); + var c2_hi = rotr64_hi$1(xl, xh, 9); // 41 + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function s1_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 14); + var c1_lo = rotr64_lo$1(xh, xl, 18); + var c2_lo = rotr64_lo$1(xl, xh, 9); // 41 + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + function g0_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 1); + var c1_hi = rotr64_hi$1(xh, xl, 8); + var c2_hi = shr64_hi$1(xh, xl, 7); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function g0_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 1); + var c1_lo = rotr64_lo$1(xh, xl, 8); + var c2_lo = shr64_lo$1(xh, xl, 7); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + function g1_512_hi(xh, xl) { + var c0_hi = rotr64_hi$1(xh, xl, 19); + var c1_hi = rotr64_hi$1(xl, xh, 29); // 61 + var c2_hi = shr64_hi$1(xh, xl, 6); + + var r = c0_hi ^ c1_hi ^ c2_hi; + if (r < 0) + r += 0x100000000; + return r; + } + + function g1_512_lo(xh, xl) { + var c0_lo = rotr64_lo$1(xh, xl, 19); + var c1_lo = rotr64_lo$1(xl, xh, 29); // 61 + var c2_lo = shr64_lo$1(xh, xl, 6); + + var r = c0_lo ^ c1_lo ^ c2_lo; + if (r < 0) + r += 0x100000000; + return r; + } + + 'use strict'; + + var sha1 = _1; + var sha224 = _224; + var sha256 = _256; + var sha384 = _384; + var sha512 = _512; + + var sha = { + sha1: sha1, + sha224: sha224, + sha256: sha256, + sha384: sha384, + sha512: sha512 + }; + + 'use strict'; + + + + + var rotl32$1 = utils.rotl32; + var sum32$2 = utils.sum32; + var sum32_3$1 = utils.sum32_3; + var sum32_4$2 = utils.sum32_4; + var BlockHash$3 = common.BlockHash; + + function RIPEMD160() { + if (!(this instanceof RIPEMD160)) + return new RIPEMD160(); + + BlockHash$3.call(this); + + this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; + this.endian = 'little'; + } + utils.inherits(RIPEMD160, BlockHash$3); + var ripemd160 = RIPEMD160; + + RIPEMD160.blockSize = 512; + RIPEMD160.outSize = 160; + RIPEMD160.hmacStrength = 192; + RIPEMD160.padLength = 64; + + RIPEMD160.prototype._update = function update(msg, start) { + var A = this.h[0]; + var B = this.h[1]; + var C = this.h[2]; + var D = this.h[3]; + var E = this.h[4]; + var Ah = A; + var Bh = B; + var Ch = C; + var Dh = D; + var Eh = E; + for (var j = 0; j < 80; j++) { + var T = sum32$2( + rotl32$1( + sum32_4$2(A, f(j, B, C, D), msg[r[j] + start], K(j)), + s[j]), + E); + A = E; + E = D; + D = rotl32$1(C, 10); + C = B; + B = T; + T = sum32$2( + rotl32$1( + sum32_4$2(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), + sh[j]), + Eh); + Ah = Eh; + Eh = Dh; + Dh = rotl32$1(Ch, 10); + Ch = Bh; + Bh = T; + } + T = sum32_3$1(this.h[1], C, Dh); + this.h[1] = sum32_3$1(this.h[2], D, Eh); + this.h[2] = sum32_3$1(this.h[3], E, Ah); + this.h[3] = sum32_3$1(this.h[4], A, Bh); + this.h[4] = sum32_3$1(this.h[0], B, Ch); + this.h[0] = T; + }; + + RIPEMD160.prototype._digest = function digest(enc) { + if (enc === 'hex') + return utils.toHex32(this.h, 'little'); + else + return utils.split32(this.h, 'little'); + }; + + function f(j, x, y, z) { + if (j <= 15) + return x ^ y ^ z; + else if (j <= 31) + return (x & y) | ((~x) & z); + else if (j <= 47) + return (x | (~y)) ^ z; + else if (j <= 63) + return (x & z) | (y & (~z)); + else + return x ^ (y | (~z)); + } + + function K(j) { + if (j <= 15) + return 0x00000000; + else if (j <= 31) + return 0x5a827999; + else if (j <= 47) + return 0x6ed9eba1; + else if (j <= 63) + return 0x8f1bbcdc; + else + return 0xa953fd4e; + } + + function Kh(j) { + if (j <= 15) + return 0x50a28be6; + else if (j <= 31) + return 0x5c4dd124; + else if (j <= 47) + return 0x6d703ef3; + else if (j <= 63) + return 0x7a6d76e9; + else + return 0x00000000; + } + + var r = [ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 + ]; + + var rh = [ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 + ]; + + var s = [ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 + ]; + + var sh = [ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 + ]; + + var ripemd = { + ripemd160: ripemd160 + }; + + 'use strict'; + + + + + function Hmac(hash, key, enc) { + if (!(this instanceof Hmac)) + return new Hmac(hash, key, enc); + this.Hash = hash; + this.blockSize = hash.blockSize / 8; + this.outSize = hash.outSize / 8; + this.inner = null; + this.outer = null; + + this._init(utils.toArray(key, enc)); + } + var hmac = Hmac; + + Hmac.prototype._init = function init(key) { + // Shorten key, if needed + if (key.length > this.blockSize) + key = new this.Hash().update(key).digest(); + minimalisticAssert(key.length <= this.blockSize); + + // Add padding to key + for (var i = key.length; i < this.blockSize; i++) + key.push(0); + + for (i = 0; i < key.length; i++) + key[i] ^= 0x36; + this.inner = new this.Hash().update(key); + + // 0x36 ^ 0x5c = 0x6a + for (i = 0; i < key.length; i++) + key[i] ^= 0x6a; + this.outer = new this.Hash().update(key); + }; + + Hmac.prototype.update = function update(msg, enc) { + this.inner.update(msg, enc); + return this; + }; + + Hmac.prototype.digest = function digest(enc) { + this.outer.update(this.inner.digest()); + return this.outer.digest(enc); + }; + + var hash_1$1 = createCommonjsModule(function (module, exports) { + var hash = exports; + + hash.utils = utils; + hash.common = common; + hash.sha = sha; + hash.ripemd = ripemd; + hash.hmac = hmac; + + // Proxy hash functions to the main object + hash.sha1 = hash.sha.sha1; + hash.sha256 = hash.sha.sha256; + hash.sha224 = hash.sha.sha224; + hash.sha384 = hash.sha.sha384; + hash.sha512 = hash.sha.sha512; + hash.ripemd160 = hash.ripemd.ripemd160; + }); + + var _version$m = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "sha2/5.0.0-beta.129"; + }); + + var _version$n = unwrapExports(_version$m); + var _version_1$b = _version$m.version; + + var browser = createCommonjsModule(function (module, exports) { + "use strict"; + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var hash = __importStar(hash_1$1); + + + + var logger$1 = new logger.Logger(_version$m.version); + var SupportedAlgorithms; + (function (SupportedAlgorithms) { + SupportedAlgorithms["sha256"] = "sha256"; + SupportedAlgorithms["sha512"] = "sha512"; + })(SupportedAlgorithms = exports.SupportedAlgorithms || (exports.SupportedAlgorithms = {})); + ; + function ripemd160(data) { + return "0x" + (hash.ripemd160().update(bytes.arrayify(data)).digest("hex")); + } + exports.ripemd160 = ripemd160; + function sha256(data) { + return "0x" + (hash.sha256().update(bytes.arrayify(data)).digest("hex")); + } + exports.sha256 = sha256; + function sha512(data) { + return "0x" + (hash.sha512().update(bytes.arrayify(data)).digest("hex")); + } + exports.sha512 = sha512; + function computeHmac(algorithm, key, data) { + if (!SupportedAlgorithms[algorithm]) { + logger$1.throwError("unsupported algorithm " + algorithm, logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "hmac", + algorithm: algorithm + }); + } + return "0x" + hash.hmac(hash[algorithm], bytes.arrayify(key)).update(bytes.arrayify(data)).digest("hex"); + } + exports.computeHmac = computeHmac; + }); + + var browser$1 = unwrapExports(browser); + var browser_1 = browser.SupportedAlgorithms; + var browser_2 = browser.ripemd160; + var browser_3 = browser.sha256; + var browser_4 = browser.sha512; + var browser_5 = browser.computeHmac; + + var browser$2 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { + password = bytes.arrayify(password); + salt = bytes.arrayify(salt); + var hLen; + var l = 1; + var DK = new Uint8Array(keylen); + var block1 = new Uint8Array(salt.length + 4); + block1.set(salt); + //salt.copy(block1, 0, 0, salt.length) + var r; + var T; + for (var i = 1; i <= l; i++) { + //block1.writeUInt32BE(i, salt.length) + block1[salt.length] = (i >> 24) & 0xff; + block1[salt.length + 1] = (i >> 16) & 0xff; + block1[salt.length + 2] = (i >> 8) & 0xff; + block1[salt.length + 3] = i & 0xff; + //let U = createHmac(password).update(block1).digest(); + var U = bytes.arrayify(browser.computeHmac(hashAlgorithm, password, block1)); + if (!hLen) { + hLen = U.length; + T = new Uint8Array(hLen); + l = Math.ceil(keylen / hLen); + r = keylen - (l - 1) * hLen; + } + //U.copy(T, 0, 0, hLen) + T.set(U); + for (var j = 1; j < iterations; j++) { + //U = createHmac(password).update(U).digest(); + U = bytes.arrayify(browser.computeHmac(hashAlgorithm, password, U)); + for (var k = 0; k < hLen; k++) + T[k] ^= U[k]; + } + var destPos = (i - 1) * hLen; + var len = (i === l ? r : hLen); + //T.copy(DK, destPos, 0, len) + DK.set(bytes.arrayify(T).slice(0, len), destPos); + } + return bytes.hexlify(DK); + } + exports.pbkdf2 = pbkdf2; + }); + + var browser$3 = unwrapExports(browser$2); + var browser_1$1 = browser$2.pbkdf2; + + var version = "6.5.0"; + var _package = { + version: version + }; + + var _package$1 = /*#__PURE__*/Object.freeze({ + version: version, + 'default': _package + }); + + var utils_1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + var utils = exports; + + function toArray(msg, enc) { + if (Array.isArray(msg)) + return msg.slice(); + if (!msg) + return []; + var res = []; + if (typeof msg !== 'string') { + for (var i = 0; i < msg.length; i++) + res[i] = msg[i] | 0; + return res; + } + if (enc === 'hex') { + msg = msg.replace(/[^a-z0-9]+/ig, ''); + if (msg.length % 2 !== 0) + msg = '0' + msg; + for (var i = 0; i < msg.length; i += 2) + res.push(parseInt(msg[i] + msg[i + 1], 16)); + } else { + for (var i = 0; i < msg.length; i++) { + var c = msg.charCodeAt(i); + var hi = c >> 8; + var lo = c & 0xff; + if (hi) + res.push(hi, lo); + else + res.push(lo); + } + } + return res; + } + utils.toArray = toArray; + + function zero2(word) { + if (word.length === 1) + return '0' + word; + else + return word; + } + utils.zero2 = zero2; + + function toHex(msg) { + var res = ''; + for (var i = 0; i < msg.length; i++) + res += zero2(msg[i].toString(16)); + return res; + } + utils.toHex = toHex; + + utils.encode = function encode(arr, enc) { + if (enc === 'hex') + return toHex(arr); + else + return arr; + }; + }); + + var utils_1$1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + var utils = exports; + + + + + utils.assert = minimalisticAssert; + utils.toArray = utils_1.toArray; + utils.zero2 = utils_1.zero2; + utils.toHex = utils_1.toHex; + utils.encode = utils_1.encode; + + // Represent num in a w-NAF form + function getNAF(num, w) { + var naf = []; + var ws = 1 << (w + 1); + var k = num.clone(); + while (k.cmpn(1) >= 0) { + var z; + if (k.isOdd()) { + var mod = k.andln(ws - 1); + if (mod > (ws >> 1) - 1) + z = (ws >> 1) - mod; + else + z = mod; + k.isubn(z); + } else { + z = 0; + } + naf.push(z); + + // Optimization, shift by word if possible + var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; + for (var i = 1; i < shift; i++) + naf.push(0); + k.iushrn(shift); + } + + return naf; + } + utils.getNAF = getNAF; + + // Represent k1, k2 in a Joint Sparse Form + function getJSF(k1, k2) { + var jsf = [ + [], + [] + ]; + + k1 = k1.clone(); + k2 = k2.clone(); + var d1 = 0; + var d2 = 0; + while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { + + // First phase + var m14 = (k1.andln(3) + d1) & 3; + var m24 = (k2.andln(3) + d2) & 3; + if (m14 === 3) + m14 = -1; + if (m24 === 3) + m24 = -1; + var u1; + if ((m14 & 1) === 0) { + u1 = 0; + } else { + var m8 = (k1.andln(7) + d1) & 7; + if ((m8 === 3 || m8 === 5) && m24 === 2) + u1 = -m14; + else + u1 = m14; + } + jsf[0].push(u1); + + var u2; + if ((m24 & 1) === 0) { + u2 = 0; + } else { + var m8 = (k2.andln(7) + d2) & 7; + if ((m8 === 3 || m8 === 5) && m14 === 2) + u2 = -m24; + else + u2 = m24; + } + jsf[1].push(u2); + + // Second phase + if (2 * d1 === u1 + 1) + d1 = 1 - d1; + if (2 * d2 === u2 + 1) + d2 = 1 - d2; + k1.iushrn(1); + k2.iushrn(1); + } + + return jsf; + } + utils.getJSF = getJSF; + + function cachedProperty(obj, name, computer) { + var key = '_' + name; + obj.prototype[name] = function cachedProperty() { + return this[key] !== undefined ? this[key] : + this[key] = computer.call(this); + }; + } + utils.cachedProperty = cachedProperty; + + function parseBytes(bytes) { + return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : + bytes; + } + utils.parseBytes = parseBytes; + + function intFromLE(bytes) { + return new bn(bytes, 'hex', 'le'); + } + utils.intFromLE = intFromLE; + }); + + var brorand = function(length) { var result = new Uint8Array(length); (commonjsGlobal.crypto || commonjsGlobal.msCrypto).getRandomValues(result); return result; }; + + 'use strict'; + + + + var getNAF = utils_1$1.getNAF; + var getJSF = utils_1$1.getJSF; + var assert$1 = utils_1$1.assert; + + function BaseCurve(type, conf) { + this.type = type; + this.p = new bn(conf.p, 16); + + // Use Montgomery, when there is no fast reduction for the prime + this.red = conf.prime ? bn.red(conf.prime) : bn.mont(this.p); + + // Useful for many curves + this.zero = new bn(0).toRed(this.red); + this.one = new bn(1).toRed(this.red); + this.two = new bn(2).toRed(this.red); + + // Curve configuration, optional + this.n = conf.n && new bn(conf.n, 16); + this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); + + // Temporary arrays + this._wnafT1 = new Array(4); + this._wnafT2 = new Array(4); + this._wnafT3 = new Array(4); + this._wnafT4 = new Array(4); + + // Generalized Greg Maxwell's trick + var adjustCount = this.n && this.p.div(this.n); + if (!adjustCount || adjustCount.cmpn(100) > 0) { + this.redN = null; + } else { + this._maxwellTrick = true; + this.redN = this.n.toRed(this.red); + } + } + var base = BaseCurve; + + BaseCurve.prototype.point = function point() { + throw new Error('Not implemented'); + }; + + BaseCurve.prototype.validate = function validate() { + throw new Error('Not implemented'); + }; + + BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { + assert$1(p.precomputed); + var doubles = p._getDoubles(); + + var naf = getNAF(k, 1); + var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); + I /= 3; + + // Translate into more windowed form + var repr = []; + for (var j = 0; j < naf.length; j += doubles.step) { + var nafW = 0; + for (var k = j + doubles.step - 1; k >= j; k--) + nafW = (nafW << 1) + naf[k]; + repr.push(nafW); + } + + var a = this.jpoint(null, null, null); + var b = this.jpoint(null, null, null); + for (var i = I; i > 0; i--) { + for (var j = 0; j < repr.length; j++) { + var nafW = repr[j]; + if (nafW === i) + b = b.mixedAdd(doubles.points[j]); + else if (nafW === -i) + b = b.mixedAdd(doubles.points[j].neg()); + } + a = a.add(b); + } + return a.toP(); + }; + + BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { + var w = 4; + + // Precompute window + var nafPoints = p._getNAFPoints(w); + w = nafPoints.wnd; + var wnd = nafPoints.points; + + // Get NAF form + var naf = getNAF(k, w); + + // Add `this`*(N+1) for every w-NAF index + var acc = this.jpoint(null, null, null); + for (var i = naf.length - 1; i >= 0; i--) { + // Count zeroes + for (var k = 0; i >= 0 && naf[i] === 0; i--) + k++; + if (i >= 0) + k++; + acc = acc.dblp(k); + + if (i < 0) + break; + var z = naf[i]; + assert$1(z !== 0); + if (p.type === 'affine') { + // J +- P + if (z > 0) + acc = acc.mixedAdd(wnd[(z - 1) >> 1]); + else + acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); + } else { + // J +- J + if (z > 0) + acc = acc.add(wnd[(z - 1) >> 1]); + else + acc = acc.add(wnd[(-z - 1) >> 1].neg()); + } + } + return p.type === 'affine' ? acc.toP() : acc; + }; + + BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, + points, + coeffs, + len, + jacobianResult) { + var wndWidth = this._wnafT1; + var wnd = this._wnafT2; + var naf = this._wnafT3; + + // Fill all arrays + var max = 0; + for (var i = 0; i < len; i++) { + var p = points[i]; + var nafPoints = p._getNAFPoints(defW); + wndWidth[i] = nafPoints.wnd; + wnd[i] = nafPoints.points; + } + + // Comb small window NAFs + for (var i = len - 1; i >= 1; i -= 2) { + var a = i - 1; + var b = i; + if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { + naf[a] = getNAF(coeffs[a], wndWidth[a]); + naf[b] = getNAF(coeffs[b], wndWidth[b]); + max = Math.max(naf[a].length, max); + max = Math.max(naf[b].length, max); + continue; + } + + var comb = [ + points[a], /* 1 */ + null, /* 3 */ + null, /* 5 */ + points[b] /* 7 */ + ]; + + // Try to avoid Projective points, if possible + if (points[a].y.cmp(points[b].y) === 0) { + comb[1] = points[a].add(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].add(points[b].neg()); + } else { + comb[1] = points[a].toJ().mixedAdd(points[b]); + comb[2] = points[a].toJ().mixedAdd(points[b].neg()); + } + + var index = [ + -3, /* -1 -1 */ + -1, /* -1 0 */ + -5, /* -1 1 */ + -7, /* 0 -1 */ + 0, /* 0 0 */ + 7, /* 0 1 */ + 5, /* 1 -1 */ + 1, /* 1 0 */ + 3 /* 1 1 */ + ]; + + var jsf = getJSF(coeffs[a], coeffs[b]); + max = Math.max(jsf[0].length, max); + naf[a] = new Array(max); + naf[b] = new Array(max); + for (var j = 0; j < max; j++) { + var ja = jsf[0][j] | 0; + var jb = jsf[1][j] | 0; + + naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; + naf[b][j] = 0; + wnd[a] = comb; + } + } + + var acc = this.jpoint(null, null, null); + var tmp = this._wnafT4; + for (var i = max; i >= 0; i--) { + var k = 0; + + while (i >= 0) { + var zero = true; + for (var j = 0; j < len; j++) { + tmp[j] = naf[j][i] | 0; + if (tmp[j] !== 0) + zero = false; + } + if (!zero) + break; + k++; + i--; + } + if (i >= 0) + k++; + acc = acc.dblp(k); + if (i < 0) + break; + + for (var j = 0; j < len; j++) { + var z = tmp[j]; + var p; + if (z === 0) + continue; + else if (z > 0) + p = wnd[j][(z - 1) >> 1]; + else if (z < 0) + p = wnd[j][(-z - 1) >> 1].neg(); + + if (p.type === 'affine') + acc = acc.mixedAdd(p); + else + acc = acc.add(p); + } + } + // Zeroify references + for (var i = 0; i < len; i++) + wnd[i] = null; + + if (jacobianResult) + return acc; + else + return acc.toP(); + }; + + function BasePoint(curve, type) { + this.curve = curve; + this.type = type; + this.precomputed = null; + } + BaseCurve.BasePoint = BasePoint; + + BasePoint.prototype.eq = function eq(/*other*/) { + throw new Error('Not implemented'); + }; + + BasePoint.prototype.validate = function validate() { + return this.curve.validate(this); + }; + + BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { + bytes = utils_1$1.toArray(bytes, enc); + + var len = this.p.byteLength(); + + // uncompressed, hybrid-odd, hybrid-even + if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && + bytes.length - 1 === 2 * len) { + if (bytes[0] === 0x06) + assert$1(bytes[bytes.length - 1] % 2 === 0); + else if (bytes[0] === 0x07) + assert$1(bytes[bytes.length - 1] % 2 === 1); + + var res = this.point(bytes.slice(1, 1 + len), + bytes.slice(1 + len, 1 + 2 * len)); + + return res; + } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && + bytes.length - 1 === len) { + return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); + } + throw new Error('Unknown point format'); + }; + + BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { + return this.encode(enc, true); + }; + + BasePoint.prototype._encode = function _encode(compact) { + var len = this.curve.p.byteLength(); + var x = this.getX().toArray('be', len); + + if (compact) + return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); + + return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; + }; + + BasePoint.prototype.encode = function encode(enc, compact) { + return utils_1$1.encode(this._encode(compact), enc); + }; + + BasePoint.prototype.precompute = function precompute(power) { + if (this.precomputed) + return this; + + var precomputed = { + doubles: null, + naf: null, + beta: null + }; + precomputed.naf = this._getNAFPoints(8); + precomputed.doubles = this._getDoubles(4, power); + precomputed.beta = this._getBeta(); + this.precomputed = precomputed; + + return this; + }; + + BasePoint.prototype._hasDoubles = function _hasDoubles(k) { + if (!this.precomputed) + return false; + + var doubles = this.precomputed.doubles; + if (!doubles) + return false; + + return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); + }; + + BasePoint.prototype._getDoubles = function _getDoubles(step, power) { + if (this.precomputed && this.precomputed.doubles) + return this.precomputed.doubles; + + var doubles = [ this ]; + var acc = this; + for (var i = 0; i < power; i += step) { + for (var j = 0; j < step; j++) + acc = acc.dbl(); + doubles.push(acc); + } + return { + step: step, + points: doubles + }; + }; + + BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { + if (this.precomputed && this.precomputed.naf) + return this.precomputed.naf; + + var res = [ this ]; + var max = (1 << wnd) - 1; + var dbl = max === 1 ? null : this.dbl(); + for (var i = 1; i < max; i++) + res[i] = res[i - 1].add(dbl); + return { + wnd: wnd, + points: res + }; + }; + + BasePoint.prototype._getBeta = function _getBeta() { + return null; + }; + + BasePoint.prototype.dblp = function dblp(k) { + var r = this; + for (var i = 0; i < k; i++) + r = r.dbl(); + return r; + }; + + 'use strict'; + + + + + + + var assert$2 = utils_1$1.assert; + + function ShortCurve(conf) { + base.call(this, 'short', conf); + + this.a = new bn(conf.a, 16).toRed(this.red); + this.b = new bn(conf.b, 16).toRed(this.red); + this.tinv = this.two.redInvm(); + + this.zeroA = this.a.fromRed().cmpn(0) === 0; + this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; + + // If the curve is endomorphic, precalculate beta and lambda + this.endo = this._getEndomorphism(conf); + this._endoWnafT1 = new Array(4); + this._endoWnafT2 = new Array(4); + } + inherits_browser(ShortCurve, base); + var short_1 = ShortCurve; + + ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { + // No efficient endomorphism + if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) + return; + + // Compute beta and lambda, that lambda * P = (beta * Px; Py) + var beta; + var lambda; + if (conf.beta) { + beta = new bn(conf.beta, 16).toRed(this.red); + } else { + var betas = this._getEndoRoots(this.p); + // Choose the smallest beta + beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; + beta = beta.toRed(this.red); + } + if (conf.lambda) { + lambda = new bn(conf.lambda, 16); + } else { + // Choose the lambda that is matching selected beta + var lambdas = this._getEndoRoots(this.n); + if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { + lambda = lambdas[0]; + } else { + lambda = lambdas[1]; + assert$2(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); + } + } + + // Get basis vectors, used for balanced length-two representation + var basis; + if (conf.basis) { + basis = conf.basis.map(function(vec) { + return { + a: new bn(vec.a, 16), + b: new bn(vec.b, 16) + }; + }); + } else { + basis = this._getEndoBasis(lambda); + } + + return { + beta: beta, + lambda: lambda, + basis: basis + }; + }; + + ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { + // Find roots of for x^2 + x + 1 in F + // Root = (-1 +- Sqrt(-3)) / 2 + // + var red = num === this.p ? this.red : bn.mont(num); + var tinv = new bn(2).toRed(red).redInvm(); + var ntinv = tinv.redNeg(); + + var s = new bn(3).toRed(red).redNeg().redSqrt().redMul(tinv); + + var l1 = ntinv.redAdd(s).fromRed(); + var l2 = ntinv.redSub(s).fromRed(); + return [ l1, l2 ]; + }; + + ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { + // aprxSqrt >= sqrt(this.n) + var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); + + // 3.74 + // Run EGCD, until r(L + 1) < aprxSqrt + var u = lambda; + var v = this.n.clone(); + var x1 = new bn(1); + var y1 = new bn(0); + var x2 = new bn(0); + var y2 = new bn(1); + + // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) + var a0; + var b0; + // First vector + var a1; + var b1; + // Second vector + var a2; + var b2; + + var prevR; + var i = 0; + var r; + var x; + while (u.cmpn(0) !== 0) { + var q = v.div(u); + r = v.sub(q.mul(u)); + x = x2.sub(q.mul(x1)); + var y = y2.sub(q.mul(y1)); + + if (!a1 && r.cmp(aprxSqrt) < 0) { + a0 = prevR.neg(); + b0 = x1; + a1 = r.neg(); + b1 = x; + } else if (a1 && ++i === 2) { + break; + } + prevR = r; + + v = u; + u = r; + x2 = x1; + x1 = x; + y2 = y1; + y1 = y; + } + a2 = r.neg(); + b2 = x; + + var len1 = a1.sqr().add(b1.sqr()); + var len2 = a2.sqr().add(b2.sqr()); + if (len2.cmp(len1) >= 0) { + a2 = a0; + b2 = b0; + } + + // Normalize signs + if (a1.negative) { + a1 = a1.neg(); + b1 = b1.neg(); + } + if (a2.negative) { + a2 = a2.neg(); + b2 = b2.neg(); + } + + return [ + { a: a1, b: b1 }, + { a: a2, b: b2 } + ]; + }; + + ShortCurve.prototype._endoSplit = function _endoSplit(k) { + var basis = this.endo.basis; + var v1 = basis[0]; + var v2 = basis[1]; + + var c1 = v2.b.mul(k).divRound(this.n); + var c2 = v1.b.neg().mul(k).divRound(this.n); + + var p1 = c1.mul(v1.a); + var p2 = c2.mul(v2.a); + var q1 = c1.mul(v1.b); + var q2 = c2.mul(v2.b); + + // Calculate answer + var k1 = k.sub(p1).sub(p2); + var k2 = q1.add(q2).neg(); + return { k1: k1, k2: k2 }; + }; + + ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { + x = new bn(x, 16); + if (!x.red) + x = x.toRed(this.red); + + var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); + var y = y2.redSqrt(); + if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) + throw new Error('invalid point'); + + // XXX Is there any way to tell if the number is odd without converting it + // to non-red form? + var isOdd = y.fromRed().isOdd(); + if (odd && !isOdd || !odd && isOdd) + y = y.redNeg(); + + return this.point(x, y); + }; + + ShortCurve.prototype.validate = function validate(point) { + if (point.inf) + return true; + + var x = point.x; + var y = point.y; + + var ax = this.a.redMul(x); + var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); + return y.redSqr().redISub(rhs).cmpn(0) === 0; + }; + + ShortCurve.prototype._endoWnafMulAdd = + function _endoWnafMulAdd(points, coeffs, jacobianResult) { + var npoints = this._endoWnafT1; + var ncoeffs = this._endoWnafT2; + for (var i = 0; i < points.length; i++) { + var split = this._endoSplit(coeffs[i]); + var p = points[i]; + var beta = p._getBeta(); + + if (split.k1.negative) { + split.k1.ineg(); + p = p.neg(true); + } + if (split.k2.negative) { + split.k2.ineg(); + beta = beta.neg(true); + } + + npoints[i * 2] = p; + npoints[i * 2 + 1] = beta; + ncoeffs[i * 2] = split.k1; + ncoeffs[i * 2 + 1] = split.k2; + } + var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); + + // Clean-up references to points and coefficients + for (var j = 0; j < i * 2; j++) { + npoints[j] = null; + ncoeffs[j] = null; + } + return res; + }; + + function Point(curve, x, y, isRed) { + base.BasePoint.call(this, curve, 'affine'); + if (x === null && y === null) { + this.x = null; + this.y = null; + this.inf = true; + } else { + this.x = new bn(x, 16); + this.y = new bn(y, 16); + // Force redgomery representation when loading from JSON + if (isRed) { + this.x.forceRed(this.curve.red); + this.y.forceRed(this.curve.red); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + this.inf = false; + } + } + inherits_browser(Point, base.BasePoint); + + ShortCurve.prototype.point = function point(x, y, isRed) { + return new Point(this, x, y, isRed); + }; + + ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { + return Point.fromJSON(this, obj, red); + }; + + Point.prototype._getBeta = function _getBeta() { + if (!this.curve.endo) + return; + + var pre = this.precomputed; + if (pre && pre.beta) + return pre.beta; + + var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); + if (pre) { + var curve = this.curve; + var endoMul = function(p) { + return curve.point(p.x.redMul(curve.endo.beta), p.y); + }; + pre.beta = beta; + beta.precomputed = { + beta: null, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(endoMul) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(endoMul) + } + }; + } + return beta; + }; + + Point.prototype.toJSON = function toJSON() { + if (!this.precomputed) + return [ this.x, this.y ]; + + return [ this.x, this.y, this.precomputed && { + doubles: this.precomputed.doubles && { + step: this.precomputed.doubles.step, + points: this.precomputed.doubles.points.slice(1) + }, + naf: this.precomputed.naf && { + wnd: this.precomputed.naf.wnd, + points: this.precomputed.naf.points.slice(1) + } + } ]; + }; + + Point.fromJSON = function fromJSON(curve, obj, red) { + if (typeof obj === 'string') + obj = JSON.parse(obj); + var res = curve.point(obj[0], obj[1], red); + if (!obj[2]) + return res; + + function obj2point(obj) { + return curve.point(obj[0], obj[1], red); + } + + var pre = obj[2]; + res.precomputed = { + beta: null, + doubles: pre.doubles && { + step: pre.doubles.step, + points: [ res ].concat(pre.doubles.points.map(obj2point)) + }, + naf: pre.naf && { + wnd: pre.naf.wnd, + points: [ res ].concat(pre.naf.points.map(obj2point)) + } + }; + return res; + }; + + Point.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; + }; + + Point.prototype.isInfinity = function isInfinity() { + return this.inf; + }; + + Point.prototype.add = function add(p) { + // O + P = P + if (this.inf) + return p; + + // P + O = P + if (p.inf) + return this; + + // P + P = 2P + if (this.eq(p)) + return this.dbl(); + + // P + (-P) = O + if (this.neg().eq(p)) + return this.curve.point(null, null); + + // P + Q = O + if (this.x.cmp(p.x) === 0) + return this.curve.point(null, null); + + var c = this.y.redSub(p.y); + if (c.cmpn(0) !== 0) + c = c.redMul(this.x.redSub(p.x).redInvm()); + var nx = c.redSqr().redISub(this.x).redISub(p.x); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + + Point.prototype.dbl = function dbl() { + if (this.inf) + return this; + + // 2P = O + var ys1 = this.y.redAdd(this.y); + if (ys1.cmpn(0) === 0) + return this.curve.point(null, null); + + var a = this.curve.a; + + var x2 = this.x.redSqr(); + var dyinv = ys1.redInvm(); + var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); + + var nx = c.redSqr().redISub(this.x.redAdd(this.x)); + var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); + return this.curve.point(nx, ny); + }; + + Point.prototype.getX = function getX() { + return this.x.fromRed(); + }; + + Point.prototype.getY = function getY() { + return this.y.fromRed(); + }; + + Point.prototype.mul = function mul(k) { + k = new bn(k, 16); + + if (this._hasDoubles(k)) + return this.curve._fixedNafMul(this, k); + else if (this.curve.endo) + return this.curve._endoWnafMulAdd([ this ], [ k ]); + else + return this.curve._wnafMul(this, k); + }; + + Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2); + }; + + Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { + var points = [ this, p2 ]; + var coeffs = [ k1, k2 ]; + if (this.curve.endo) + return this.curve._endoWnafMulAdd(points, coeffs, true); + else + return this.curve._wnafMulAdd(1, points, coeffs, 2, true); + }; + + Point.prototype.eq = function eq(p) { + return this === p || + this.inf === p.inf && + (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); + }; + + Point.prototype.neg = function neg(_precompute) { + if (this.inf) + return this; + + var res = this.curve.point(this.x, this.y.redNeg()); + if (_precompute && this.precomputed) { + var pre = this.precomputed; + var negate = function(p) { + return p.neg(); + }; + res.precomputed = { + naf: pre.naf && { + wnd: pre.naf.wnd, + points: pre.naf.points.map(negate) + }, + doubles: pre.doubles && { + step: pre.doubles.step, + points: pre.doubles.points.map(negate) + } + }; + } + return res; + }; + + Point.prototype.toJ = function toJ() { + if (this.inf) + return this.curve.jpoint(null, null, null); + + var res = this.curve.jpoint(this.x, this.y, this.curve.one); + return res; + }; + + function JPoint(curve, x, y, z) { + base.BasePoint.call(this, curve, 'jacobian'); + if (x === null && y === null && z === null) { + this.x = this.curve.one; + this.y = this.curve.one; + this.z = new bn(0); + } else { + this.x = new bn(x, 16); + this.y = new bn(y, 16); + this.z = new bn(z, 16); + } + if (!this.x.red) + this.x = this.x.toRed(this.curve.red); + if (!this.y.red) + this.y = this.y.toRed(this.curve.red); + if (!this.z.red) + this.z = this.z.toRed(this.curve.red); + + this.zOne = this.z === this.curve.one; + } + inherits_browser(JPoint, base.BasePoint); + + ShortCurve.prototype.jpoint = function jpoint(x, y, z) { + return new JPoint(this, x, y, z); + }; + + JPoint.prototype.toP = function toP() { + if (this.isInfinity()) + return this.curve.point(null, null); + + var zinv = this.z.redInvm(); + var zinv2 = zinv.redSqr(); + var ax = this.x.redMul(zinv2); + var ay = this.y.redMul(zinv2).redMul(zinv); + + return this.curve.point(ax, ay); + }; + + JPoint.prototype.neg = function neg() { + return this.curve.jpoint(this.x, this.y.redNeg(), this.z); + }; + + JPoint.prototype.add = function add(p) { + // O + P = P + if (this.isInfinity()) + return p; + + // P + O = P + if (p.isInfinity()) + return this; + + // 12M + 4S + 7A + var pz2 = p.z.redSqr(); + var z2 = this.z.redSqr(); + var u1 = this.x.redMul(pz2); + var u2 = p.x.redMul(z2); + var s1 = this.y.redMul(pz2.redMul(p.z)); + var s2 = p.y.redMul(z2.redMul(this.z)); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(p.z).redMul(h); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.mixedAdd = function mixedAdd(p) { + // O + P = P + if (this.isInfinity()) + return p.toJ(); + + // P + O = P + if (p.isInfinity()) + return this; + + // 8M + 3S + 7A + var z2 = this.z.redSqr(); + var u1 = this.x; + var u2 = p.x.redMul(z2); + var s1 = this.y; + var s2 = p.y.redMul(z2).redMul(this.z); + + var h = u1.redSub(u2); + var r = s1.redSub(s2); + if (h.cmpn(0) === 0) { + if (r.cmpn(0) !== 0) + return this.curve.jpoint(null, null, null); + else + return this.dbl(); + } + + var h2 = h.redSqr(); + var h3 = h2.redMul(h); + var v = u1.redMul(h2); + + var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); + var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); + var nz = this.z.redMul(h); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.dblp = function dblp(pow) { + if (pow === 0) + return this; + if (this.isInfinity()) + return this; + if (!pow) + return this.dbl(); + + if (this.curve.zeroA || this.curve.threeA) { + var r = this; + for (var i = 0; i < pow; i++) + r = r.dbl(); + return r; + } + + // 1M + 2S + 1A + N * (4S + 5M + 8A) + // N = 1 => 6M + 6S + 9A + var a = this.curve.a; + var tinv = this.curve.tinv; + + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + // Reuse results + var jyd = jy.redAdd(jy); + for (var i = 0; i < pow; i++) { + var jx2 = jx.redSqr(); + var jyd2 = jyd.redSqr(); + var jyd4 = jyd2.redSqr(); + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var t1 = jx.redMul(jyd2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + var dny = c.redMul(t2); + dny = dny.redIAdd(dny).redISub(jyd4); + var nz = jyd.redMul(jz); + if (i + 1 < pow) + jz4 = jz4.redMul(jyd4); + + jx = nx; + jz = nz; + jyd = dny; + } + + return this.curve.jpoint(jx, jyd.redMul(tinv), jz); + }; + + JPoint.prototype.dbl = function dbl() { + if (this.isInfinity()) + return this; + + if (this.curve.zeroA) + return this._zeroDbl(); + else if (this.curve.threeA) + return this._threeDbl(); + else + return this._dbl(); + }; + + JPoint.prototype._zeroDbl = function _zeroDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 14A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // T = M ^ 2 - 2*S + var t = m.redSqr().redISub(s).redISub(s); + + // 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2*Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html + // #doubling-dbl-2009-l + // 2M + 5S + 13A + + // A = X1^2 + var a = this.x.redSqr(); + // B = Y1^2 + var b = this.y.redSqr(); + // C = B^2 + var c = b.redSqr(); + // D = 2 * ((X1 + B)^2 - A - C) + var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); + d = d.redIAdd(d); + // E = 3 * A + var e = a.redAdd(a).redIAdd(a); + // F = E^2 + var f = e.redSqr(); + + // 8 * C + var c8 = c.redIAdd(c); + c8 = c8.redIAdd(c8); + c8 = c8.redIAdd(c8); + + // X3 = F - 2 * D + nx = f.redISub(d).redISub(d); + // Y3 = E * (D - X3) - 8 * C + ny = e.redMul(d.redISub(nx)).redISub(c8); + // Z3 = 2 * Y1 * Z1 + nz = this.y.redMul(this.z); + nz = nz.redIAdd(nz); + } + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype._threeDbl = function _threeDbl() { + var nx; + var ny; + var nz; + // Z = 1 + if (this.zOne) { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html + // #doubling-mdbl-2007-bl + // 1M + 5S + 15A + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // S = 2 * ((X1 + YY)^2 - XX - YYYY) + var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + s = s.redIAdd(s); + // M = 3 * XX + a + var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); + // T = M^2 - 2 * S + var t = m.redSqr().redISub(s).redISub(s); + // X3 = T + nx = t; + // Y3 = M * (S - T) - 8 * YYYY + var yyyy8 = yyyy.redIAdd(yyyy); + yyyy8 = yyyy8.redIAdd(yyyy8); + yyyy8 = yyyy8.redIAdd(yyyy8); + ny = m.redMul(s.redISub(t)).redISub(yyyy8); + // Z3 = 2 * Y1 + nz = this.y.redAdd(this.y); + } else { + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b + // 3M + 5S + + // delta = Z1^2 + var delta = this.z.redSqr(); + // gamma = Y1^2 + var gamma = this.y.redSqr(); + // beta = X1 * gamma + var beta = this.x.redMul(gamma); + // alpha = 3 * (X1 - delta) * (X1 + delta) + var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); + alpha = alpha.redAdd(alpha).redIAdd(alpha); + // X3 = alpha^2 - 8 * beta + var beta4 = beta.redIAdd(beta); + beta4 = beta4.redIAdd(beta4); + var beta8 = beta4.redAdd(beta4); + nx = alpha.redSqr().redISub(beta8); + // Z3 = (Y1 + Z1)^2 - gamma - delta + nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); + // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 + var ggamma8 = gamma.redSqr(); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ggamma8 = ggamma8.redIAdd(ggamma8); + ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); + } + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype._dbl = function _dbl() { + var a = this.curve.a; + + // 4M + 6S + 10A + var jx = this.x; + var jy = this.y; + var jz = this.z; + var jz4 = jz.redSqr().redSqr(); + + var jx2 = jx.redSqr(); + var jy2 = jy.redSqr(); + + var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); + + var jxd4 = jx.redAdd(jx); + jxd4 = jxd4.redIAdd(jxd4); + var t1 = jxd4.redMul(jy2); + var nx = c.redSqr().redISub(t1.redAdd(t1)); + var t2 = t1.redISub(nx); + + var jyd8 = jy2.redSqr(); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + jyd8 = jyd8.redIAdd(jyd8); + var ny = c.redMul(t2).redISub(jyd8); + var nz = jy.redAdd(jy).redMul(jz); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.trpl = function trpl() { + if (!this.curve.zeroA) + return this.dbl().add(this); + + // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl + // 5M + 10S + ... + + // XX = X1^2 + var xx = this.x.redSqr(); + // YY = Y1^2 + var yy = this.y.redSqr(); + // ZZ = Z1^2 + var zz = this.z.redSqr(); + // YYYY = YY^2 + var yyyy = yy.redSqr(); + // M = 3 * XX + a * ZZ2; a = 0 + var m = xx.redAdd(xx).redIAdd(xx); + // MM = M^2 + var mm = m.redSqr(); + // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM + var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); + e = e.redIAdd(e); + e = e.redAdd(e).redIAdd(e); + e = e.redISub(mm); + // EE = E^2 + var ee = e.redSqr(); + // T = 16*YYYY + var t = yyyy.redIAdd(yyyy); + t = t.redIAdd(t); + t = t.redIAdd(t); + t = t.redIAdd(t); + // U = (M + E)^2 - MM - EE - T + var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); + // X3 = 4 * (X1 * EE - 4 * YY * U) + var yyu4 = yy.redMul(u); + yyu4 = yyu4.redIAdd(yyu4); + yyu4 = yyu4.redIAdd(yyu4); + var nx = this.x.redMul(ee).redISub(yyu4); + nx = nx.redIAdd(nx); + nx = nx.redIAdd(nx); + // Y3 = 8 * Y1 * (U * (T - U) - E * EE) + var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + ny = ny.redIAdd(ny); + // Z3 = (Z1 + E)^2 - ZZ - EE + var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); + + return this.curve.jpoint(nx, ny, nz); + }; + + JPoint.prototype.mul = function mul(k, kbase) { + k = new bn(k, kbase); + + return this.curve._wnafMul(this, k); + }; + + JPoint.prototype.eq = function eq(p) { + if (p.type === 'affine') + return this.eq(p.toJ()); + + if (this === p) + return true; + + // x1 * z2^2 == x2 * z1^2 + var z2 = this.z.redSqr(); + var pz2 = p.z.redSqr(); + if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) + return false; + + // y1 * z2^3 == y2 * z1^3 + var z3 = z2.redMul(this.z); + var pz3 = pz2.redMul(p.z); + return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; + }; + + JPoint.prototype.eqXToP = function eqXToP(x) { + var zs = this.z.redSqr(); + var rx = x.toRed(this.curve.red).redMul(zs); + if (this.x.cmp(rx) === 0) + return true; + + var xc = x.clone(); + var t = this.curve.redN.redMul(zs); + for (;;) { + xc.iadd(this.curve.n); + if (xc.cmp(this.curve.p) >= 0) + return false; + + rx.redIAdd(t); + if (this.x.cmp(rx) === 0) + return true; + } + }; + + JPoint.prototype.inspect = function inspect() { + if (this.isInfinity()) + return ''; + return ''; + }; + + JPoint.prototype.isInfinity = function isInfinity() { + // XXX This code assumes that zero is always zero in red + return this.z.cmpn(0) === 0; + }; + + var mont = {}; + + var edwards = {}; + + var curve_1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + var curve = exports; + + curve.base = base; + curve.short = short_1; + curve.mont = mont; + curve.edwards = edwards; + }); + + var secp256k1 = undefined; + + var curves_1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + var curves = exports; + + + + + + var assert = utils_1$1.assert; + + function PresetCurve(options) { + if (options.type === 'short') + this.curve = new curve_1.short(options); + else if (options.type === 'edwards') + this.curve = new curve_1.edwards(options); + else + this.curve = new curve_1.mont(options); + this.g = this.curve.g; + this.n = this.curve.n; + this.hash = options.hash; + + assert(this.g.validate(), 'Invalid curve'); + assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); + } + curves.PresetCurve = PresetCurve; + + function defineCurve(name, options) { + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + get: function() { + var curve = new PresetCurve(options); + Object.defineProperty(curves, name, { + configurable: true, + enumerable: true, + value: curve + }); + return curve; + } + }); + } + + defineCurve('p192', { + type: 'short', + prime: 'p192', + p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', + b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', + n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', + hash: hash_1$1.sha256, + gRed: false, + g: [ + '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', + '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' + ] + }); + + defineCurve('p224', { + type: 'short', + prime: 'p224', + p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', + a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', + b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', + n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', + hash: hash_1$1.sha256, + gRed: false, + g: [ + 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', + 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' + ] + }); + + defineCurve('p256', { + type: 'short', + prime: null, + p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', + a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', + b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', + n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', + hash: hash_1$1.sha256, + gRed: false, + g: [ + '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', + '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' + ] + }); + + defineCurve('p384', { + type: 'short', + prime: null, + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 ffffffff', + a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'fffffffe ffffffff 00000000 00000000 fffffffc', + b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + + '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', + n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', + hash: hash_1$1.sha384, + gRed: false, + g: [ + 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + + '5502f25d bf55296c 3a545e38 72760ab7', + '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + + '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' + ] + }); + + defineCurve('p521', { + type: 'short', + prime: null, + p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff', + a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff ffffffff ffffffff fffffffc', + b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + + '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + + '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', + n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', + hash: hash_1$1.sha512, + gRed: false, + g: [ + '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + + '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + + 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', + '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + + '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + + '3fad0761 353c7086 a272c240 88be9476 9fd16650' + ] + }); + + defineCurve('curve25519', { + type: 'mont', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '76d06', + b: '1', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash_1$1.sha256, + gRed: false, + g: [ + '9' + ] + }); + + defineCurve('ed25519', { + type: 'edwards', + prime: 'p25519', + p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', + a: '-1', + c: '1', + // -121665 * (121666^(-1)) (mod P) + d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', + n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', + hash: hash_1$1.sha256, + gRed: false, + g: [ + '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', + + // 4/5 + '6666666666666666666666666666666666666666666666666666666666666658' + ] + }); + + var pre; + try { + pre = secp256k1; + } catch (e) { + pre = undefined; + } + + defineCurve('secp256k1', { + type: 'short', + prime: 'k256', + p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', + a: '0', + b: '7', + n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', + h: '1', + hash: hash_1$1.sha256, + + // Precomputed endomorphism + beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', + lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', + basis: [ + { + a: '3086d221a7d46bcde86c90e49284eb15', + b: '-e4437ed6010e88286f547fa90abfe4c3' + }, + { + a: '114ca50f7a8e2f3f657c1108d9d44cfd8', + b: '3086d221a7d46bcde86c90e49284eb15' + } + ], + + gRed: false, + g: [ + '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', + '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', + pre + ] + }); + }); + + 'use strict'; + + + + + + function HmacDRBG(options) { + if (!(this instanceof HmacDRBG)) + return new HmacDRBG(options); + this.hash = options.hash; + this.predResist = !!options.predResist; + + this.outLen = this.hash.outSize; + this.minEntropy = options.minEntropy || this.hash.hmacStrength; + + this._reseed = null; + this.reseedInterval = null; + this.K = null; + this.V = null; + + var entropy = utils_1.toArray(options.entropy, options.entropyEnc || 'hex'); + var nonce = utils_1.toArray(options.nonce, options.nonceEnc || 'hex'); + var pers = utils_1.toArray(options.pers, options.persEnc || 'hex'); + minimalisticAssert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + this._init(entropy, nonce, pers); + } + var hmacDrbg = HmacDRBG; + + HmacDRBG.prototype._init = function init(entropy, nonce, pers) { + var seed = entropy.concat(nonce).concat(pers); + + this.K = new Array(this.outLen / 8); + this.V = new Array(this.outLen / 8); + for (var i = 0; i < this.V.length; i++) { + this.K[i] = 0x00; + this.V[i] = 0x01; + } + + this._update(seed); + this._reseed = 1; + this.reseedInterval = 0x1000000000000; // 2^48 + }; + + HmacDRBG.prototype._hmac = function hmac() { + return new hash_1$1.hmac(this.hash, this.K); + }; + + HmacDRBG.prototype._update = function update(seed) { + var kmac = this._hmac() + .update(this.V) + .update([ 0x00 ]); + if (seed) + kmac = kmac.update(seed); + this.K = kmac.digest(); + this.V = this._hmac().update(this.V).digest(); + if (!seed) + return; + + this.K = this._hmac() + .update(this.V) + .update([ 0x01 ]) + .update(seed) + .digest(); + this.V = this._hmac().update(this.V).digest(); + }; + + HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { + // Optional entropy enc + if (typeof entropyEnc !== 'string') { + addEnc = add; + add = entropyEnc; + entropyEnc = null; + } + + entropy = utils_1.toArray(entropy, entropyEnc); + add = utils_1.toArray(add, addEnc); + + minimalisticAssert(entropy.length >= (this.minEntropy / 8), + 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); + + this._update(entropy.concat(add || [])); + this._reseed = 1; + }; + + HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { + if (this._reseed > this.reseedInterval) + throw new Error('Reseed is required'); + + // Optional encoding + if (typeof enc !== 'string') { + addEnc = add; + add = enc; + enc = null; + } + + // Optional additional data + if (add) { + add = utils_1.toArray(add, addEnc || 'hex'); + this._update(add); + } + + var temp = []; + while (temp.length < len) { + this.V = this._hmac().update(this.V).digest(); + temp = temp.concat(this.V); + } + + var res = temp.slice(0, len); + this._update(add); + this._reseed++; + return utils_1.encode(res, enc); + }; + + 'use strict'; + + + + var assert$3 = utils_1$1.assert; + + function KeyPair(ec, options) { + this.ec = ec; + this.priv = null; + this.pub = null; + + // KeyPair(ec, { priv: ..., pub: ... }) + if (options.priv) + this._importPrivate(options.priv, options.privEnc); + if (options.pub) + this._importPublic(options.pub, options.pubEnc); + } + var key = KeyPair; + + KeyPair.fromPublic = function fromPublic(ec, pub, enc) { + if (pub instanceof KeyPair) + return pub; + + return new KeyPair(ec, { + pub: pub, + pubEnc: enc + }); + }; + + KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { + if (priv instanceof KeyPair) + return priv; + + return new KeyPair(ec, { + priv: priv, + privEnc: enc + }); + }; + + KeyPair.prototype.validate = function validate() { + var pub = this.getPublic(); + + if (pub.isInfinity()) + return { result: false, reason: 'Invalid public key' }; + if (!pub.validate()) + return { result: false, reason: 'Public key is not a point' }; + if (!pub.mul(this.ec.curve.n).isInfinity()) + return { result: false, reason: 'Public key * N != O' }; + + return { result: true, reason: null }; + }; + + KeyPair.prototype.getPublic = function getPublic(compact, enc) { + // compact is optional argument + if (typeof compact === 'string') { + enc = compact; + compact = null; + } + + if (!this.pub) + this.pub = this.ec.g.mul(this.priv); + + if (!enc) + return this.pub; + + return this.pub.encode(enc, compact); + }; + + KeyPair.prototype.getPrivate = function getPrivate(enc) { + if (enc === 'hex') + return this.priv.toString(16, 2); + else + return this.priv; + }; + + KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { + this.priv = new bn(key, enc || 16); + + // Ensure that the priv won't be bigger than n, otherwise we may fail + // in fixed multiplication method + this.priv = this.priv.umod(this.ec.curve.n); + }; + + KeyPair.prototype._importPublic = function _importPublic(key, enc) { + if (key.x || key.y) { + // Montgomery points only have an `x` coordinate. + // Weierstrass/Edwards points on the other hand have both `x` and + // `y` coordinates. + if (this.ec.curve.type === 'mont') { + assert$3(key.x, 'Need x coordinate'); + } else if (this.ec.curve.type === 'short' || + this.ec.curve.type === 'edwards') { + assert$3(key.x && key.y, 'Need both x and y coordinate'); + } + this.pub = this.ec.curve.point(key.x, key.y); + return; + } + this.pub = this.ec.curve.decodePoint(key, enc); + }; + + // ECDH + KeyPair.prototype.derive = function derive(pub) { + return pub.mul(this.priv).getX(); + }; + + // ECDSA + KeyPair.prototype.sign = function sign(msg, enc, options) { + return this.ec.sign(msg, this, enc, options); + }; + + KeyPair.prototype.verify = function verify(msg, signature) { + return this.ec.verify(msg, signature, this); + }; + + KeyPair.prototype.inspect = function inspect() { + return ''; + }; + + 'use strict'; + + + + + var assert$4 = utils_1$1.assert; + + function Signature(options, enc) { + if (options instanceof Signature) + return options; + + if (this._importDER(options, enc)) + return; + + assert$4(options.r && options.s, 'Signature without r or s'); + this.r = new bn(options.r, 16); + this.s = new bn(options.s, 16); + if (options.recoveryParam === undefined) + this.recoveryParam = null; + else + this.recoveryParam = options.recoveryParam; + } + var signature = Signature; + + function Position() { + this.place = 0; + } + + function getLength(buf, p) { + var initial = buf[p.place++]; + if (!(initial & 0x80)) { + return initial; + } + var octetLen = initial & 0xf; + var val = 0; + for (var i = 0, off = p.place; i < octetLen; i++, off++) { + val <<= 8; + val |= buf[off]; + } + p.place = off; + return val; + } + + function rmPadding(buf) { + var i = 0; + var len = buf.length - 1; + while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { + i++; + } + if (i === 0) { + return buf; + } + return buf.slice(i); + } + + Signature.prototype._importDER = function _importDER(data, enc) { + data = utils_1$1.toArray(data, enc); + var p = new Position(); + if (data[p.place++] !== 0x30) { + return false; + } + var len = getLength(data, p); + if ((len + p.place) !== data.length) { + return false; + } + if (data[p.place++] !== 0x02) { + return false; + } + var rlen = getLength(data, p); + var r = data.slice(p.place, rlen + p.place); + p.place += rlen; + if (data[p.place++] !== 0x02) { + return false; + } + var slen = getLength(data, p); + if (data.length !== slen + p.place) { + return false; + } + var s = data.slice(p.place, slen + p.place); + if (r[0] === 0 && (r[1] & 0x80)) { + r = r.slice(1); + } + if (s[0] === 0 && (s[1] & 0x80)) { + s = s.slice(1); + } + + this.r = new bn(r); + this.s = new bn(s); + this.recoveryParam = null; + + return true; + }; + + function constructLength(arr, len) { + if (len < 0x80) { + arr.push(len); + return; + } + var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); + arr.push(octets | 0x80); + while (--octets) { + arr.push((len >>> (octets << 3)) & 0xff); + } + arr.push(len); + } + + Signature.prototype.toDER = function toDER(enc) { + var r = this.r.toArray(); + var s = this.s.toArray(); + + // Pad values + if (r[0] & 0x80) + r = [ 0 ].concat(r); + // Pad values + if (s[0] & 0x80) + s = [ 0 ].concat(s); + + r = rmPadding(r); + s = rmPadding(s); + + while (!s[0] && !(s[1] & 0x80)) { + s = s.slice(1); + } + var arr = [ 0x02 ]; + constructLength(arr, r.length); + arr = arr.concat(r); + arr.push(0x02); + constructLength(arr, s.length); + var backHalf = arr.concat(s); + var res = [ 0x30 ]; + constructLength(res, backHalf.length); + res = res.concat(backHalf); + return utils_1$1.encode(res, enc); + }; + + 'use strict'; + + + + + + + var assert$5 = utils_1$1.assert; + + + + + function EC(options) { + if (!(this instanceof EC)) + return new EC(options); + + // Shortcut `elliptic.ec(curve-name)` + if (typeof options === 'string') { + assert$5(curves_1.hasOwnProperty(options), 'Unknown curve ' + options); + + options = curves_1[options]; + } + + // Shortcut for `elliptic.ec(elliptic.curves.curveName)` + if (options instanceof curves_1.PresetCurve) + options = { curve: options }; + + this.curve = options.curve.curve; + this.n = this.curve.n; + this.nh = this.n.ushrn(1); + this.g = this.curve.g; + + // Point on curve + this.g = options.curve.g; + this.g.precompute(options.curve.n.bitLength() + 1); + + // Hash for function for DRBG + this.hash = options.hash || options.curve.hash; + } + var ec = EC; + + EC.prototype.keyPair = function keyPair(options) { + return new key(this, options); + }; + + EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { + return key.fromPrivate(this, priv, enc); + }; + + EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { + return key.fromPublic(this, pub, enc); + }; + + EC.prototype.genKeyPair = function genKeyPair(options) { + if (!options) + options = {}; + + // Instantiate Hmac_DRBG + var drbg = new hmacDrbg({ + hash: this.hash, + pers: options.pers, + persEnc: options.persEnc || 'utf8', + entropy: options.entropy || brorand(this.hash.hmacStrength), + entropyEnc: options.entropy && options.entropyEnc || 'utf8', + nonce: this.n.toArray() + }); + + var bytes = this.n.byteLength(); + var ns2 = this.n.sub(new bn(2)); + do { + var priv = new bn(drbg.generate(bytes)); + if (priv.cmp(ns2) > 0) + continue; + + priv.iaddn(1); + return this.keyFromPrivate(priv); + } while (true); + }; + + EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { + var delta = msg.byteLength() * 8 - this.n.bitLength(); + if (delta > 0) + msg = msg.ushrn(delta); + if (!truncOnly && msg.cmp(this.n) >= 0) + return msg.sub(this.n); + else + return msg; + }; + + EC.prototype.sign = function sign(msg, key, enc, options) { + if (typeof enc === 'object') { + options = enc; + enc = null; + } + if (!options) + options = {}; + + key = this.keyFromPrivate(key, enc); + msg = this._truncateToN(new bn(msg, 16)); + + // Zero-extend key to provide enough entropy + var bytes = this.n.byteLength(); + var bkey = key.getPrivate().toArray('be', bytes); + + // Zero-extend nonce to have the same byte size as N + var nonce = msg.toArray('be', bytes); + + // Instantiate Hmac_DRBG + var drbg = new hmacDrbg({ + hash: this.hash, + entropy: bkey, + nonce: nonce, + pers: options.pers, + persEnc: options.persEnc || 'utf8' + }); + + // Number of bytes to generate + var ns1 = this.n.sub(new bn(1)); + + for (var iter = 0; true; iter++) { + var k = options.k ? + options.k(iter) : + new bn(drbg.generate(this.n.byteLength())); + k = this._truncateToN(k, true); + if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) + continue; + + var kp = this.g.mul(k); + if (kp.isInfinity()) + continue; + + var kpX = kp.getX(); + var r = kpX.umod(this.n); + if (r.cmpn(0) === 0) + continue; + + var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); + s = s.umod(this.n); + if (s.cmpn(0) === 0) + continue; + + var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | + (kpX.cmp(r) !== 0 ? 2 : 0); + + // Use complement of `s`, if it is > `n / 2` + if (options.canonical && s.cmp(this.nh) > 0) { + s = this.n.sub(s); + recoveryParam ^= 1; + } + + return new signature({ r: r, s: s, recoveryParam: recoveryParam }); + } + }; + + EC.prototype.verify = function verify(msg, signature$1, key, enc) { + msg = this._truncateToN(new bn(msg, 16)); + key = this.keyFromPublic(key, enc); + signature$1 = new signature(signature$1, 'hex'); + + // Perform primitive values validation + var r = signature$1.r; + var s = signature$1.s; + if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) + return false; + if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) + return false; + + // Validate signature + var sinv = s.invm(this.n); + var u1 = sinv.mul(msg).umod(this.n); + var u2 = sinv.mul(r).umod(this.n); + + if (!this.curve._maxwellTrick) { + var p = this.g.mulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + return p.getX().umod(this.n).cmp(r) === 0; + } + + // NOTE: Greg Maxwell's trick, inspired by: + // https://git.io/vad3K + + var p = this.g.jmulAdd(u1, key.getPublic(), u2); + if (p.isInfinity()) + return false; + + // Compare `p.x` of Jacobian point with `r`, + // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the + // inverse of `p.z^2` + return p.eqXToP(r); + }; + + EC.prototype.recoverPubKey = function(msg, signature$1, j, enc) { + assert$5((3 & j) === j, 'The recovery param is more than two bits'); + signature$1 = new signature(signature$1, enc); + + var n = this.n; + var e = new bn(msg); + var r = signature$1.r; + var s = signature$1.s; + + // A set LSB signifies that the y-coordinate is odd + var isYOdd = j & 1; + var isSecondKey = j >> 1; + if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) + throw new Error('Unable to find sencond key candinate'); + + // 1.1. Let x = r + jn. + if (isSecondKey) + r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); + else + r = this.curve.pointFromX(r, isYOdd); + + var rInv = signature$1.r.invm(n); + var s1 = n.sub(e).mul(rInv).umod(n); + var s2 = s.mul(rInv).umod(n); + + // 1.6.1 Compute Q = r^-1 (sR - eG) + // Q = r^-1 (sR + -eG) + return this.g.mulAdd(s1, r, s2); + }; + + EC.prototype.getKeyRecoveryParam = function(e, signature$1, Q, enc) { + signature$1 = new signature(signature$1, enc); + if (signature$1.recoveryParam !== null) + return signature$1.recoveryParam; + + for (var i = 0; i < 4; i++) { + var Qprime; + try { + Qprime = this.recoverPubKey(e, signature$1, i); + } catch (e) { + continue; + } + + if (Qprime.eq(Q)) + return i; + } + throw new Error('Unable to find valid recovery factor'); + }; + + var eddsa = {}; + + var require$$0$1 = getCjsExportFromNamespace(_package$1); + + var elliptic_1 = createCommonjsModule(function (module, exports) { + 'use strict'; + + var elliptic = exports; + + elliptic.version = require$$0$1.version; + elliptic.utils = utils_1$1; + elliptic.rand = brorand; + elliptic.curve = curve_1; + elliptic.curves = curves_1; + + // Protocols + elliptic.ec = ec; + elliptic.eddsa = eddsa; + }); + var elliptic_2 = elliptic_1.ec; + + var _version$o = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "signing-key/5.0.0-beta.129"; + }); + + var _version$p = unwrapExports(_version$o); + var _version_1$c = _version$o.version; + + var signingKey = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + var logger$1 = new logger.Logger(_version$o.version); + var _curve = null; + function getCurve() { + if (!_curve) { + _curve = new elliptic_1.ec("secp256k1"); + } + return _curve; + } + var SigningKey = /** @class */ (function () { + function SigningKey(privateKey) { + properties.defineReadOnly(this, "curve", "secp256k1"); + properties.defineReadOnly(this, "privateKey", bytes.hexlify(privateKey)); + var keyPair = getCurve().keyFromPrivate(bytes.arrayify(this.privateKey)); + properties.defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + properties.defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + properties.defineReadOnly(this, "_isSigningKey", true); + } + SigningKey.prototype._addPoint = function (other) { + var p0 = getCurve().keyFromPublic(bytes.arrayify(this.publicKey)); + var p1 = getCurve().keyFromPublic(bytes.arrayify(other)); + return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); + }; + SigningKey.prototype.signDigest = function (digest) { + var keyPair = getCurve().keyFromPrivate(bytes.arrayify(this.privateKey)); + var signature = keyPair.sign(bytes.arrayify(digest), { canonical: true }); + return bytes.splitSignature({ + recoveryParam: signature.recoveryParam, + r: bytes.hexZeroPad("0x" + signature.r.toString(16), 32), + s: bytes.hexZeroPad("0x" + signature.s.toString(16), 32), + }); + }; + SigningKey.prototype.computeSharedSecret = function (otherKey) { + var keyPair = getCurve().keyFromPrivate(bytes.arrayify(this.privateKey)); + var otherKeyPair = getCurve().keyFromPublic(bytes.arrayify(computePublicKey(otherKey))); + return bytes.hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + }; + SigningKey.isSigningKey = function (value) { + return !!(value && value._isSigningKey); + }; + return SigningKey; + }()); + exports.SigningKey = SigningKey; + function recoverPublicKey(digest, signature) { + var sig = bytes.splitSignature(signature); + var rs = { r: bytes.arrayify(sig.r), s: bytes.arrayify(sig.s) }; + return "0x" + getCurve().recoverPubKey(bytes.arrayify(digest), rs, sig.recoveryParam).encode("hex", false); + } + exports.recoverPublicKey = recoverPublicKey; + function computePublicKey(key, compressed) { + var bytes$1 = bytes.arrayify(key); + if (bytes$1.length === 32) { + var signingKey = new SigningKey(bytes$1); + if (compressed) { + return "0x" + getCurve().keyFromPrivate(bytes$1).getPublic(true, "hex"); + } + return signingKey.publicKey; + } + else if (bytes$1.length === 33) { + if (compressed) { + return bytes.hexlify(bytes$1); + } + return "0x" + getCurve().keyFromPublic(bytes$1).getPublic(false, "hex"); + } + else if (bytes$1.length === 65) { + if (!compressed) { + return bytes.hexlify(bytes$1); + } + return "0x" + getCurve().keyFromPublic(bytes$1).getPublic(true, "hex"); + } + return logger$1.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); + } + exports.computePublicKey = computePublicKey; + }); + + var index$f = unwrapExports(signingKey); + var signingKey_1 = signingKey.SigningKey; + var signingKey_2 = signingKey.recoverPublicKey; + var signingKey_3 = signingKey.computePublicKey; + + var _version$q = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "transactions/5.0.0-beta.128"; + }); + + var _version$r = unwrapExports(_version$q); + var _version_1$d = _version$q.version; + + var transactions = createCommonjsModule(function (module, exports) { + "use strict"; + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + var RLP = __importStar(rlp); + + + + var logger$1 = new logger.Logger(_version$q.version); + /////////////////////////////// + function handleAddress(value) { + if (value === "0x") { + return null; + } + return address.getAddress(value); + } + function handleNumber(value) { + if (value === "0x") { + return constants.Zero; + } + return bignumber$2.BigNumber.from(value); + } + var transactionFields = [ + { name: "nonce", maxLength: 32 }, + { name: "gasPrice", maxLength: 32 }, + { name: "gasLimit", maxLength: 32 }, + { name: "to", length: 20 }, + { name: "value", maxLength: 32 }, + { name: "data" }, + ]; + var allowedTransactionKeys = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true + }; + function computeAddress(key) { + var publicKey = signingKey.computePublicKey(key); + return address.getAddress(bytes.hexDataSlice(keccak256_1.keccak256(bytes.hexDataSlice(publicKey, 1)), 12)); + } + exports.computeAddress = computeAddress; + function recoverAddress(digest, signature) { + return computeAddress(signingKey.recoverPublicKey(bytes.arrayify(digest), signature)); + } + exports.recoverAddress = recoverAddress; + function serialize(transaction, signature) { + properties.checkProperties(transaction, allowedTransactionKeys); + var raw = []; + transactionFields.forEach(function (fieldInfo) { + var value = transaction[fieldInfo.name] || ([]); + value = bytes.arrayify(bytes.hexlify(value)); + // Fixed-width field + if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { + logger$1.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + } + // Variable-width (with a maximum) + if (fieldInfo.maxLength) { + value = bytes.stripZeros(value); + if (value.length > fieldInfo.maxLength) { + logger$1.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + } + } + raw.push(bytes.hexlify(value)); + }); + if (transaction.chainId != null && transaction.chainId !== 0) { + raw.push(bytes.hexlify(transaction.chainId)); + raw.push("0x"); + raw.push("0x"); + } + var unsignedTransaction = RLP.encode(raw); + // Requesting an unsigned transation + if (!signature) { + return unsignedTransaction; + } + // The splitSignature will ensure the transaction has a recoveryParam in the + // case that the signTransaction function only adds a v. + var sig = bytes.splitSignature(signature); + // We pushed a chainId and null r, s on for hashing only; remove those + var v = 27 + sig.recoveryParam; + if (raw.length === 9) { + raw.pop(); + raw.pop(); + raw.pop(); + v += transaction.chainId * 2 + 8; + } + raw.push(bytes.hexlify(v)); + raw.push(bytes.stripZeros(bytes.arrayify(sig.r))); + raw.push(bytes.stripZeros(bytes.arrayify(sig.s))); + return RLP.encode(raw); + } + exports.serialize = serialize; + function parse(rawTransaction) { + var transaction = RLP.decode(rawTransaction); + if (transaction.length !== 9 && transaction.length !== 6) { + logger$1.throwArgumentError("invalid raw transaction", "rawTransactin", rawTransaction); + } + var tx = { + nonce: handleNumber(transaction[0]).toNumber(), + gasPrice: handleNumber(transaction[1]), + gasLimit: handleNumber(transaction[2]), + to: handleAddress(transaction[3]), + value: handleNumber(transaction[4]), + data: transaction[5], + chainId: 0 + }; + // Legacy unsigned transaction + if (transaction.length === 6) { + return tx; + } + try { + tx.v = bignumber$2.BigNumber.from(transaction[6]).toNumber(); + } + catch (error) { + console.log(error); + return tx; + } + tx.r = bytes.hexZeroPad(transaction[7], 32); + tx.s = bytes.hexZeroPad(transaction[8], 32); + if (bignumber$2.BigNumber.from(tx.r).isZero() && bignumber$2.BigNumber.from(tx.s).isZero()) { + // EIP-155 unsigned transaction + tx.chainId = tx.v; + tx.v = 0; + } + else { + // Signed Tranasaction + tx.chainId = Math.floor((tx.v - 35) / 2); + if (tx.chainId < 0) { + tx.chainId = 0; + } + var recoveryParam = tx.v - 27; + var raw = transaction.slice(0, 6); + if (tx.chainId !== 0) { + raw.push(bytes.hexlify(tx.chainId)); + raw.push("0x"); + raw.push("0x"); + recoveryParam -= tx.chainId * 2 + 8; + } + var digest = keccak256_1.keccak256(RLP.encode(raw)); + try { + tx.from = recoverAddress(digest, { r: bytes.hexlify(tx.r), s: bytes.hexlify(tx.s), recoveryParam: recoveryParam }); + } + catch (error) { + console.log(error); + } + tx.hash = keccak256_1.keccak256(rawTransaction); + } + return tx; + } + exports.parse = parse; + }); + + var index$g = unwrapExports(transactions); + var transactions_1 = transactions.computeAddress; + var transactions_2 = transactions.recoverAddress; + var transactions_3 = transactions.serialize; + var transactions_4 = transactions.parse; + + var _version$s = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "wordlists/5.0.0-beta.128"; + }); + + var _version$t = unwrapExports(_version$s); + var _version_1$e = _version$s.version; + + var wordlist = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + // This gets overriddenby gulp during bip39-XX + var exportWordlist = false; + + + + + var logger$1 = new logger.Logger(_version$s.version); + function check(wordlist) { + var words = []; + for (var i = 0; i < 2048; i++) { + var word = wordlist.getWord(i); + if (i !== wordlist.getWordIndex(word)) { + return "0x"; + } + words.push(word); + } + return hash.id(words.join("\n") + "\n"); + } + exports.check = check; + var Wordlist = /** @class */ (function () { + function Wordlist(locale) { + var _newTarget = this.constructor; + logger$1.checkAbstract(_newTarget, Wordlist); + properties.defineReadOnly(this, "locale", locale); + } + // Subclasses may override this + Wordlist.prototype.split = function (mnemonic) { + return mnemonic.toLowerCase().split(/ +/g); + }; + // Subclasses may override this + Wordlist.prototype.join = function (words) { + return words.join(" "); + }; + return Wordlist; + }()); + exports.Wordlist = Wordlist; + function register(lang, name) { + if (!name) { + name = lang.locale; + } + if (exportWordlist) { + var g = commonjsGlobal; + if (!(g.wordlists)) { + properties.defineReadOnly(g, "wordlists", {}); + } + if (!g.wordlists[name]) { + properties.defineReadOnly(g.wordlists, name, lang); + } + if (g.ethers && g.ethers.wordlists) { + if (!g.ethers.wordlists[name]) { + properties.defineReadOnly(g.ethers.wordlists, name, lang); + } + } + } + } + exports.register = register; + }); + + var wordlist$1 = unwrapExports(wordlist); + var wordlist_1 = wordlist.check; + var wordlist_2 = wordlist.Wordlist; + var wordlist_3 = wordlist.register; + + var langEn_1 = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + var words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo"; + var wordlist$1 = null; + function loadWords(lang) { + if (wordlist$1 != null) { + return; + } + wordlist$1 = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); + if (wordlist.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") { + wordlist$1 = null; + throw new Error("BIP39 Wordlist for en (English) FAILED"); + } + } + var LangEn = /** @class */ (function (_super) { + __extends(LangEn, _super); + function LangEn() { + return _super.call(this, "en") || this; + } + LangEn.prototype.getWord = function (index) { + loadWords(this); + return wordlist$1[index]; + }; + LangEn.prototype.getWordIndex = function (word) { + loadWords(this); + return wordlist$1.indexOf(word); + }; + return LangEn; + }(wordlist.Wordlist)); + var langEn = new LangEn(); + exports.langEn = langEn; + wordlist.register(langEn); + }); + + var langEn = unwrapExports(langEn_1); + var langEn_2 = langEn_1.langEn; + + var browser$4 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + // Wordlists + // See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md + + exports.Wordlist = wordlist.Wordlist; + + var wordlists = { en: langEn_1.langEn }; + exports.wordlists = wordlists; + }); + + var browser$5 = unwrapExports(browser$4); + var browser_1$2 = browser$4.Wordlist; + var browser_2$1 = browser$4.wordlists; + + var _version$u = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "hdnode/5.0.0-beta.130"; + }); + + var _version$v = unwrapExports(_version$u); + var _version_1$f = _version$u.version; + + var hdnode = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + + + + + var logger$1 = new logger.Logger(_version$u.version); + var N = bignumber$2.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); + // "Bitcoin seed" + var MasterSecret = strings.toUtf8Bytes("Bitcoin seed"); + var HardenedBit = 0x80000000; + // Returns a byte with the MSB bits set + function getUpperMask(bits) { + return ((1 << bits) - 1) << (8 - bits); + } + // Returns a byte with the LSB bits set + function getLowerMask(bits) { + return (1 << bits) - 1; + } + function bytes32(value) { + return bytes.hexZeroPad(bytes.hexlify(value), 32); + } + function base58check(data) { + var checksum = bytes.hexDataSlice(browser.sha256(browser.sha256(data)), 0, 4); + return basex.Base58.encode(bytes.concat([data, checksum])); + } + var _constructorGuard = {}; + exports.defaultPath = "m/44'/60'/0'/0/0"; + var HDNode = /** @class */ (function () { + /** + * This constructor should not be called directly. + * + * Please use: + * - fromMnemonic + * - fromSeed + */ + function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) { + var _newTarget = this.constructor; + logger$1.checkNew(_newTarget, HDNode); + if (constructorGuard !== _constructorGuard) { + throw new Error("HDNode constructor cannot be called directly"); + } + if (privateKey) { + var signingKey$1 = new signingKey.SigningKey(privateKey); + properties.defineReadOnly(this, "privateKey", signingKey$1.privateKey); + properties.defineReadOnly(this, "publicKey", signingKey$1.compressedPublicKey); + } + else { + properties.defineReadOnly(this, "privateKey", null); + properties.defineReadOnly(this, "publicKey", bytes.hexlify(publicKey)); + } + properties.defineReadOnly(this, "parentFingerprint", parentFingerprint); + properties.defineReadOnly(this, "fingerprint", bytes.hexDataSlice(browser.ripemd160(browser.sha256(this.publicKey)), 0, 4)); + properties.defineReadOnly(this, "address", transactions.computeAddress(this.publicKey)); + properties.defineReadOnly(this, "chainCode", chainCode); + properties.defineReadOnly(this, "index", index); + properties.defineReadOnly(this, "depth", depth); + properties.defineReadOnly(this, "mnemonic", mnemonic); + properties.defineReadOnly(this, "path", path); + } + Object.defineProperty(HDNode.prototype, "extendedKey", { + get: function () { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current senitment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + if (this.depth >= 256) { + throw new Error("Depth too large!"); + } + return base58check(bytes.concat([ + ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"), + bytes.hexlify(this.depth), + this.parentFingerprint, + bytes.hexZeroPad(bytes.hexlify(this.index), 4), + this.chainCode, + ((this.privateKey != null) ? bytes.concat(["0x00", this.privateKey]) : this.publicKey), + ])); + }, + enumerable: true, + configurable: true + }); + HDNode.prototype.neuter = function () { + return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, null, this.path); + }; + HDNode.prototype._derive = function (index) { + if (index > 0xffffffff) { + throw new Error("invalid index - " + String(index)); + } + // Base path + var path = this.path; + if (path) { + path += "/" + (index & ~HardenedBit); + } + var data = new Uint8Array(37); + if (index & HardenedBit) { + if (!this.privateKey) { + throw new Error("cannot derive child of neutered node"); + } + // Data = 0x00 || ser_256(k_par) + data.set(bytes.arrayify(this.privateKey), 1); + // Hardened path + if (path) { + path += "'"; + } + } + else { + // Data = ser_p(point(k_par)) + data.set(bytes.arrayify(this.publicKey)); + } + // Data += ser_32(i) + for (var i = 24; i >= 0; i -= 8) { + data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); + } + var I = bytes.arrayify(browser.computeHmac(browser.SupportedAlgorithms.sha512, this.chainCode, data)); + var IL = I.slice(0, 32); + var IR = I.slice(32); + // The private key + var ki = null; + // The public key + var Ki = null; + if (this.privateKey) { + ki = bytes32(bignumber$2.BigNumber.from(IL).add(this.privateKey).mod(N)); + } + else { + var ek = new signingKey.SigningKey(bytes.hexlify(IL)); + Ki = ek._addPoint(this.publicKey); + } + return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); + }; + HDNode.prototype.derivePath = function (path) { + var components = path.split("/"); + if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) { + throw new Error("invalid path - " + path); + } + if (components[0] === "m") { + components.shift(); + } + var result = this; + for (var i = 0; i < components.length; i++) { + var component = components[i]; + if (component.match(/^[0-9]+'$/)) { + var index = parseInt(component.substring(0, component.length - 1)); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(HardenedBit + index); + } + else if (component.match(/^[0-9]+$/)) { + var index = parseInt(component); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(index); + } + else { + throw new Error("invlaid path component - " + component); + } + } + return result; + }; + HDNode._fromSeed = function (seed, mnemonic) { + var seedArray = bytes.arrayify(seed); + if (seedArray.length < 16 || seedArray.length > 64) { + throw new Error("invalid seed"); + } + var I = bytes.arrayify(browser.computeHmac(browser.SupportedAlgorithms.sha512, MasterSecret, seedArray)); + return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); + }; + HDNode.fromMnemonic = function (mnemonic, password, wordlist) { + // Normalize the case and spacing in the mnemonic (throws if the mnemonic is invalid) + mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist); + return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), mnemonic); + }; + HDNode.fromSeed = function (seed) { + return HDNode._fromSeed(seed, null); + }; + HDNode.fromExtendedKey = function (extendedKey) { + var bytes$1 = basex.Base58.decode(extendedKey); + if (bytes$1.length !== 82 || base58check(bytes$1.slice(0, 78)) !== extendedKey) { + logger$1.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); + } + var depth = bytes$1[4]; + var parentFingerprint = bytes.hexlify(bytes$1.slice(5, 9)); + var index = parseInt(bytes.hexlify(bytes$1.slice(9, 13)).substring(2), 16); + var chainCode = bytes.hexlify(bytes$1.slice(13, 45)); + var key = bytes$1.slice(45, 78); + switch (bytes.hexlify(bytes$1.slice(0, 4))) { + // Public Key + case "0x0488b21e": + case "0x043587cf": + return new HDNode(_constructorGuard, null, bytes.hexlify(key), parentFingerprint, chainCode, index, depth, null, null); + // Private Key + case "0x0488ade4": + case "0x04358394 ": + if (key[0] !== 0) { + break; + } + return new HDNode(_constructorGuard, bytes.hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); + } + return logger$1.throwError("invalid extended key", "extendedKey", "[REDACTED]"); + }; + return HDNode; + }()); + exports.HDNode = HDNode; + function mnemonicToSeed(mnemonic, password) { + if (!password) { + password = ""; + } + var salt = strings.toUtf8Bytes("mnemonic" + password, strings.UnicodeNormalizationForm.NFKD); + return browser$2.pbkdf2(strings.toUtf8Bytes(mnemonic, strings.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); + } + exports.mnemonicToSeed = mnemonicToSeed; + function mnemonicToEntropy(mnemonic, wordlist) { + if (!wordlist) { + wordlist = browser$4.wordlists["en"]; + } + logger$1.checkNormalize(); + var words = wordlist.split(mnemonic); + if ((words.length % 3) !== 0) { + throw new Error("invalid mnemonic"); + } + var entropy = bytes.arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); + var offset = 0; + for (var i = 0; i < words.length; i++) { + var index = wordlist.getWordIndex(words[i].normalize("NFKD")); + if (index === -1) { + throw new Error("invalid mnemonic"); + } + for (var bit = 0; bit < 11; bit++) { + if (index & (1 << (10 - bit))) { + entropy[offset >> 3] |= (1 << (7 - (offset % 8))); + } + offset++; + } + } + var entropyBits = 32 * words.length / 3; + var checksumBits = words.length / 3; + var checksumMask = getUpperMask(checksumBits); + var checksum = bytes.arrayify(browser.sha256(entropy.slice(0, entropyBits / 8)))[0]; + checksum &= checksumMask; + if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { + throw new Error("invalid checksum"); + } + return bytes.hexlify(entropy.slice(0, entropyBits / 8)); + } + exports.mnemonicToEntropy = mnemonicToEntropy; + function entropyToMnemonic(entropy, wordlist) { + entropy = bytes.arrayify(entropy); + if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { + throw new Error("invalid entropy"); + } + var indices = [0]; + var remainingBits = 11; + for (var i = 0; i < entropy.length; i++) { + // Consume the whole byte (with still more to go) + if (remainingBits > 8) { + indices[indices.length - 1] <<= 8; + indices[indices.length - 1] |= entropy[i]; + remainingBits -= 8; + // This byte will complete an 11-bit index + } + else { + indices[indices.length - 1] <<= remainingBits; + indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); + // Start the next word + indices.push(entropy[i] & getLowerMask(8 - remainingBits)); + remainingBits += 3; + } + } + // Compute the checksum bits + var checksum = bytes.arrayify(browser.sha256(entropy))[0]; + var checksumBits = entropy.length / 4; + checksum &= getUpperMask(checksumBits); + // Shift the checksum into the word indices + indices[indices.length - 1] <<= checksumBits; + indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); + if (!wordlist) { + wordlist = browser$4.wordlists["en"]; + } + return wordlist.join(indices.map(function (index) { return wordlist.getWord(index); })); + } + exports.entropyToMnemonic = entropyToMnemonic; + function isValidMnemonic(mnemonic, wordlist) { + try { + mnemonicToEntropy(mnemonic, wordlist); + return true; + } + catch (error) { } + return false; + } + exports.isValidMnemonic = isValidMnemonic; + }); + + var index$h = unwrapExports(hdnode); + var hdnode_1 = hdnode.defaultPath; + var hdnode_2 = hdnode.HDNode; + var hdnode_3 = hdnode.mnemonicToSeed; + var hdnode_4 = hdnode.mnemonicToEntropy; + var hdnode_5 = hdnode.entropyToMnemonic; + var hdnode_6 = hdnode.isValidMnemonic; + + var _version$w = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "random/5.0.0-beta.128"; + }); + + var _version$x = unwrapExports(_version$w); + var _version_1$g = _version$w.version; + + var shuffle = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + function shuffled(array) { + array = array.slice(); + for (var i = array.length - 1; i > 0; i--) { + var j = Math.floor(Math.random() * (i + 1)); + var tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + return array; + } + exports.shuffled = shuffled; + }); + + var shuffle$1 = unwrapExports(shuffle); + var shuffle_1 = shuffle.shuffled; + + var browser$6 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$w.version); + + exports.shuffled = shuffle.shuffled; + var crypto = commonjsGlobal.crypto || commonjsGlobal.msCrypto; + if (!crypto || !crypto.getRandomValues) { + logger$1.warn("WARNING: Missing strong random number source"); + crypto = { + getRandomValues: function (buffer) { + return logger$1.throwError("no secure random source avaialble", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "crypto.getRandomValues" + }); + } + }; + } + function randomBytes(length) { + if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { + logger$1.throwArgumentError("invalid length", "length", length); + } + var result = new Uint8Array(length); + crypto.getRandomValues(result); + return bytes.arrayify(result); + } + exports.randomBytes = randomBytes; + ; + }); + + var browser$7 = unwrapExports(browser$6); + var browser_1$3 = browser$6.shuffled; + var browser_2$2 = browser$6.randomBytes; + + var aesJs = createCommonjsModule(function (module, exports) { + "use strict"; + + (function(root) { + + function checkInt(value) { + return (parseInt(value) === value); + } + + function checkInts(arrayish) { + if (!checkInt(arrayish.length)) { return false; } + + for (var i = 0; i < arrayish.length; i++) { + if (!checkInt(arrayish[i]) || arrayish[i] < 0 || arrayish[i] > 255) { + return false; + } + } + + return true; + } + + function coerceArray(arg, copy) { + + // ArrayBuffer view + if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === 'Uint8Array') { + + if (copy) { + if (arg.slice) { + arg = arg.slice(); + } else { + arg = Array.prototype.slice.call(arg); + } + } + + return arg; + } + + // It's an array; check it is a valid representation of a byte + if (Array.isArray(arg)) { + if (!checkInts(arg)) { + throw new Error('Array contains invalid value: ' + arg); + } + + return new Uint8Array(arg); + } + + // Something else, but behaves like an array (maybe a Buffer? Arguments?) + if (checkInt(arg.length) && checkInts(arg)) { + return new Uint8Array(arg); + } + + throw new Error('unsupported array-like object'); + } + + function createArray(length) { + return new Uint8Array(length); + } + + function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { + if (sourceStart != null || sourceEnd != null) { + if (sourceArray.slice) { + sourceArray = sourceArray.slice(sourceStart, sourceEnd); + } else { + sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); + } + } + targetArray.set(sourceArray, targetStart); + } + + + + var convertUtf8 = (function() { + function toBytes(text) { + var result = [], i = 0; + text = encodeURI(text); + while (i < text.length) { + var c = text.charCodeAt(i++); + + // if it is a % sign, encode the following 2 bytes as a hex value + if (c === 37) { + result.push(parseInt(text.substr(i, 2), 16)); + i += 2; + + // otherwise, just the actual byte + } else { + result.push(c); + } + } + + return coerceArray(result); + } + + function fromBytes(bytes) { + var result = [], i = 0; + + while (i < bytes.length) { + var c = bytes[i]; + + if (c < 128) { + result.push(String.fromCharCode(c)); + i++; + } else if (c > 191 && c < 224) { + result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f))); + i += 2; + } else { + result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f))); + i += 3; + } + } + + return result.join(''); + } + + return { + toBytes: toBytes, + fromBytes: fromBytes, + } + })(); + + var convertHex = (function() { + function toBytes(text) { + var result = []; + for (var i = 0; i < text.length; i += 2) { + result.push(parseInt(text.substr(i, 2), 16)); + } + + return result; + } + + // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html + var Hex = '0123456789abcdef'; + + function fromBytes(bytes) { + var result = []; + for (var i = 0; i < bytes.length; i++) { + var v = bytes[i]; + result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]); + } + return result.join(''); + } + + return { + toBytes: toBytes, + fromBytes: fromBytes, + } + })(); + + + // Number of rounds by keysize + var numberOfRounds = {16: 10, 24: 12, 32: 14}; + + // Round constant words + var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91]; + + // S-box and Inverse S-box (S is for Substitution) + var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; + var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]; + + // Transformations for encryption + var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a]; + var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616]; + var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16]; + var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c]; + + // Transformations for decryption + var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742]; + var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857]; + var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8]; + var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0]; + + // Transformations for decryption key expansion + var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]; + var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697]; + var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46]; + var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d]; + + function convertToInt32(bytes) { + var result = []; + for (var i = 0; i < bytes.length; i += 4) { + result.push( + (bytes[i ] << 24) | + (bytes[i + 1] << 16) | + (bytes[i + 2] << 8) | + bytes[i + 3] + ); + } + return result; + } + + var AES = function(key) { + if (!(this instanceof AES)) { + throw Error('AES must be instanitated with `new`'); + } + + Object.defineProperty(this, 'key', { + value: coerceArray(key, true) + }); + + this._prepare(); + }; + + + AES.prototype._prepare = function() { + + var rounds = numberOfRounds[this.key.length]; + if (rounds == null) { + throw new Error('invalid key size (must be 16, 24 or 32 bytes)'); + } + + // encryption round keys + this._Ke = []; + + // decryption round keys + this._Kd = []; + + for (var i = 0; i <= rounds; i++) { + this._Ke.push([0, 0, 0, 0]); + this._Kd.push([0, 0, 0, 0]); + } + + var roundKeyCount = (rounds + 1) * 4; + var KC = this.key.length / 4; + + // convert the key into ints + var tk = convertToInt32(this.key); + + // copy values into round key arrays + var index; + for (var i = 0; i < KC; i++) { + index = i >> 2; + this._Ke[index][i % 4] = tk[i]; + this._Kd[rounds - index][i % 4] = tk[i]; + } + + // key expansion (fips-197 section 5.2) + var rconpointer = 0; + var t = KC, tt; + while (t < roundKeyCount) { + tt = tk[KC - 1]; + tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^ + (S[(tt >> 8) & 0xFF] << 16) ^ + (S[ tt & 0xFF] << 8) ^ + S[(tt >> 24) & 0xFF] ^ + (rcon[rconpointer] << 24)); + rconpointer += 1; + + // key expansion (for non-256 bit) + if (KC != 8) { + for (var i = 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + + // key expansion for 256-bit keys is "slightly different" (fips-197) + } else { + for (var i = 1; i < (KC / 2); i++) { + tk[i] ^= tk[i - 1]; + } + tt = tk[(KC / 2) - 1]; + + tk[KC / 2] ^= (S[ tt & 0xFF] ^ + (S[(tt >> 8) & 0xFF] << 8) ^ + (S[(tt >> 16) & 0xFF] << 16) ^ + (S[(tt >> 24) & 0xFF] << 24)); + + for (var i = (KC / 2) + 1; i < KC; i++) { + tk[i] ^= tk[i - 1]; + } + } + + // copy values into round key arrays + var i = 0, r, c; + while (i < KC && t < roundKeyCount) { + r = t >> 2; + c = t % 4; + this._Ke[r][c] = tk[i]; + this._Kd[rounds - r][c] = tk[i++]; + t++; + } + } + + // inverse-cipher-ify the decryption round key (fips-197 section 5.3) + for (var r = 1; r < rounds; r++) { + for (var c = 0; c < 4; c++) { + tt = this._Kd[r][c]; + this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^ + U2[(tt >> 16) & 0xFF] ^ + U3[(tt >> 8) & 0xFF] ^ + U4[ tt & 0xFF]); + } + } + }; + + AES.prototype.encrypt = function(plaintext) { + if (plaintext.length != 16) { + throw new Error('invalid plaintext size (must be 16 bytes)'); + } + + var rounds = this._Ke.length - 1; + var a = [0, 0, 0, 0]; + + // convert plaintext to (ints ^ key) + var t = convertToInt32(plaintext); + for (var i = 0; i < 4; i++) { + t[i] ^= this._Ke[0][i]; + } + + // apply round transforms + for (var r = 1; r < rounds; r++) { + for (var i = 0; i < 4; i++) { + a[i] = (T1[(t[ i ] >> 24) & 0xff] ^ + T2[(t[(i + 1) % 4] >> 16) & 0xff] ^ + T3[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T4[ t[(i + 3) % 4] & 0xff] ^ + this._Ke[r][i]); + } + t = a.slice(); + } + + // the last round is special + var result = createArray(16), tt; + for (var i = 0; i < 4; i++) { + tt = this._Ke[rounds][i]; + result[4 * i ] = (S[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (S[ t[(i + 3) % 4] & 0xff] ^ tt ) & 0xff; + } + + return result; + }; + + AES.prototype.decrypt = function(ciphertext) { + if (ciphertext.length != 16) { + throw new Error('invalid ciphertext size (must be 16 bytes)'); + } + + var rounds = this._Kd.length - 1; + var a = [0, 0, 0, 0]; + + // convert plaintext to (ints ^ key) + var t = convertToInt32(ciphertext); + for (var i = 0; i < 4; i++) { + t[i] ^= this._Kd[0][i]; + } + + // apply round transforms + for (var r = 1; r < rounds; r++) { + for (var i = 0; i < 4; i++) { + a[i] = (T5[(t[ i ] >> 24) & 0xff] ^ + T6[(t[(i + 3) % 4] >> 16) & 0xff] ^ + T7[(t[(i + 2) % 4] >> 8) & 0xff] ^ + T8[ t[(i + 1) % 4] & 0xff] ^ + this._Kd[r][i]); + } + t = a.slice(); + } + + // the last round is special + var result = createArray(16), tt; + for (var i = 0; i < 4; i++) { + tt = this._Kd[rounds][i]; + result[4 * i ] = (Si[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; + result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; + result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; + result[4 * i + 3] = (Si[ t[(i + 1) % 4] & 0xff] ^ tt ) & 0xff; + } + + return result; + }; + + + /** + * Mode Of Operation - Electonic Codebook (ECB) + */ + var ModeOfOperationECB = function(key) { + if (!(this instanceof ModeOfOperationECB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Electronic Code Block"; + this.name = "ecb"; + + this._aes = new AES(key); + }; + + ModeOfOperationECB.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + + if ((plaintext.length % 16) !== 0) { + throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); + } + + var ciphertext = createArray(plaintext.length); + var block = createArray(16); + + for (var i = 0; i < plaintext.length; i += 16) { + copyArray(plaintext, block, 0, i, i + 16); + block = this._aes.encrypt(block); + copyArray(block, ciphertext, i); + } + + return ciphertext; + }; + + ModeOfOperationECB.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + + if ((ciphertext.length % 16) !== 0) { + throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); + } + + var plaintext = createArray(ciphertext.length); + var block = createArray(16); + + for (var i = 0; i < ciphertext.length; i += 16) { + copyArray(ciphertext, block, 0, i, i + 16); + block = this._aes.decrypt(block); + copyArray(block, plaintext, i); + } + + return plaintext; + }; + + + /** + * Mode Of Operation - Cipher Block Chaining (CBC) + */ + var ModeOfOperationCBC = function(key, iv) { + if (!(this instanceof ModeOfOperationCBC)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Cipher Block Chaining"; + this.name = "cbc"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 bytes)'); + } + + this._lastCipherblock = coerceArray(iv, true); + + this._aes = new AES(key); + }; + + ModeOfOperationCBC.prototype.encrypt = function(plaintext) { + plaintext = coerceArray(plaintext); + + if ((plaintext.length % 16) !== 0) { + throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); + } + + var ciphertext = createArray(plaintext.length); + var block = createArray(16); + + for (var i = 0; i < plaintext.length; i += 16) { + copyArray(plaintext, block, 0, i, i + 16); + + for (var j = 0; j < 16; j++) { + block[j] ^= this._lastCipherblock[j]; + } + + this._lastCipherblock = this._aes.encrypt(block); + copyArray(this._lastCipherblock, ciphertext, i); + } + + return ciphertext; + }; + + ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { + ciphertext = coerceArray(ciphertext); + + if ((ciphertext.length % 16) !== 0) { + throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); + } + + var plaintext = createArray(ciphertext.length); + var block = createArray(16); + + for (var i = 0; i < ciphertext.length; i += 16) { + copyArray(ciphertext, block, 0, i, i + 16); + block = this._aes.decrypt(block); + + for (var j = 0; j < 16; j++) { + plaintext[i + j] = block[j] ^ this._lastCipherblock[j]; + } + + copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16); + } + + return plaintext; + }; + + + /** + * Mode Of Operation - Cipher Feedback (CFB) + */ + var ModeOfOperationCFB = function(key, iv, segmentSize) { + if (!(this instanceof ModeOfOperationCFB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Cipher Feedback"; + this.name = "cfb"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 size)'); + } + + if (!segmentSize) { segmentSize = 1; } + + this.segmentSize = segmentSize; + + this._shiftRegister = coerceArray(iv, true); + + this._aes = new AES(key); + }; + + ModeOfOperationCFB.prototype.encrypt = function(plaintext) { + if ((plaintext.length % this.segmentSize) != 0) { + throw new Error('invalid plaintext size (must be segmentSize bytes)'); + } + + var encrypted = coerceArray(plaintext, true); + + var xorSegment; + for (var i = 0; i < encrypted.length; i += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + for (var j = 0; j < this.segmentSize; j++) { + encrypted[i + j] ^= xorSegment[j]; + } + + // Shift the register + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); + } + + return encrypted; + }; + + ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { + if ((ciphertext.length % this.segmentSize) != 0) { + throw new Error('invalid ciphertext size (must be segmentSize bytes)'); + } + + var plaintext = coerceArray(ciphertext, true); + + var xorSegment; + for (var i = 0; i < plaintext.length; i += this.segmentSize) { + xorSegment = this._aes.encrypt(this._shiftRegister); + + for (var j = 0; j < this.segmentSize; j++) { + plaintext[i + j] ^= xorSegment[j]; + } + + // Shift the register + copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); + copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); + } + + return plaintext; + }; + + /** + * Mode Of Operation - Output Feedback (OFB) + */ + var ModeOfOperationOFB = function(key, iv) { + if (!(this instanceof ModeOfOperationOFB)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Output Feedback"; + this.name = "ofb"; + + if (!iv) { + iv = createArray(16); + + } else if (iv.length != 16) { + throw new Error('invalid initialation vector size (must be 16 bytes)'); + } + + this._lastPrecipher = coerceArray(iv, true); + this._lastPrecipherIndex = 16; + + this._aes = new AES(key); + }; + + ModeOfOperationOFB.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + + for (var i = 0; i < encrypted.length; i++) { + if (this._lastPrecipherIndex === 16) { + this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); + this._lastPrecipherIndex = 0; + } + encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++]; + } + + return encrypted; + }; + + // Decryption is symetric + ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; + + + /** + * Counter object for CTR common mode of operation + */ + var Counter = function(initialValue) { + if (!(this instanceof Counter)) { + throw Error('Counter must be instanitated with `new`'); + } + + // We allow 0, but anything false-ish uses the default 1 + if (initialValue !== 0 && !initialValue) { initialValue = 1; } + + if (typeof(initialValue) === 'number') { + this._counter = createArray(16); + this.setValue(initialValue); + + } else { + this.setBytes(initialValue); + } + }; + + Counter.prototype.setValue = function(value) { + if (typeof(value) !== 'number' || parseInt(value) != value) { + throw new Error('invalid counter value (must be an integer)'); + } + + for (var index = 15; index >= 0; --index) { + this._counter[index] = value % 256; + value = value >> 8; + } + }; + + Counter.prototype.setBytes = function(bytes) { + bytes = coerceArray(bytes, true); + + if (bytes.length != 16) { + throw new Error('invalid counter bytes size (must be 16 bytes)'); + } + + this._counter = bytes; + }; + + Counter.prototype.increment = function() { + for (var i = 15; i >= 0; i--) { + if (this._counter[i] === 255) { + this._counter[i] = 0; + } else { + this._counter[i]++; + break; + } + } + }; + + + /** + * Mode Of Operation - Counter (CTR) + */ + var ModeOfOperationCTR = function(key, counter) { + if (!(this instanceof ModeOfOperationCTR)) { + throw Error('AES must be instanitated with `new`'); + } + + this.description = "Counter"; + this.name = "ctr"; + + if (!(counter instanceof Counter)) { + counter = new Counter(counter); + } + + this._counter = counter; + + this._remainingCounter = null; + this._remainingCounterIndex = 16; + + this._aes = new AES(key); + }; + + ModeOfOperationCTR.prototype.encrypt = function(plaintext) { + var encrypted = coerceArray(plaintext, true); + + for (var i = 0; i < encrypted.length; i++) { + if (this._remainingCounterIndex === 16) { + this._remainingCounter = this._aes.encrypt(this._counter._counter); + this._remainingCounterIndex = 0; + this._counter.increment(); + } + encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++]; + } + + return encrypted; + }; + + // Decryption is symetric + ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; + + + /////////////////////// + // Padding + + // See:https://tools.ietf.org/html/rfc2315 + function pkcs7pad(data) { + data = coerceArray(data, true); + var padder = 16 - (data.length % 16); + var result = createArray(data.length + padder); + copyArray(data, result); + for (var i = data.length; i < result.length; i++) { + result[i] = padder; + } + return result; + } + + function pkcs7strip(data) { + data = coerceArray(data, true); + if (data.length < 16) { throw new Error('PKCS#7 invalid length'); } + + var padder = data[data.length - 1]; + if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); } + + var length = data.length - padder; + for (var i = 0; i < padder; i++) { + if (data[length + i] !== padder) { + throw new Error('PKCS#7 invalid padding byte'); + } + } + + var result = createArray(length); + copyArray(data, result, 0, 0, length); + return result; + } + + /////////////////////// + // Exporting + + + // The block cipher + var aesjs = { + AES: AES, + Counter: Counter, + + ModeOfOperation: { + ecb: ModeOfOperationECB, + cbc: ModeOfOperationCBC, + cfb: ModeOfOperationCFB, + ofb: ModeOfOperationOFB, + ctr: ModeOfOperationCTR + }, + + utils: { + hex: convertHex, + utf8: convertUtf8 + }, + + padding: { + pkcs7: { + pad: pkcs7pad, + strip: pkcs7strip + } + }, + + _arrayTest: { + coerceArray: coerceArray, + createArray: createArray, + copyArray: copyArray, + } + }; + + + // node.js + if ('object' !== 'undefined') { + module.exports = aesjs; + + // RequireJS/AMD + // http://www.requirejs.org/docs/api.html + // https://github.com/amdjs/amdjs-api/wiki/AMD + } else if (typeof(undefined) === 'function' && undefined.amd) { + undefined(aesjs); + + // Web Browsers + } else { + + // If there was an existing library at "aesjs" make sure it's still available + if (root.aesjs) { + aesjs._aesjs = root.aesjs; + } + + root.aesjs = aesjs; + } + + + })(commonjsGlobal); + }); + + var _version$y = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "json-wallets/5.0.0-beta.129"; + }); + + var _version$z = unwrapExports(_version$y); + var _version_1$h = _version$y.version; + + var utils$1 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + //import { Description } from "@ethersproject/properties"; + + /* + export class Account extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + + // static isAccount(value: any): value is Account { + // return Description._isType(value); + // } + } + //defineReadOnly(Account, "name", "Account"); + */ + function looseArrayify(hexString) { + if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') { + hexString = '0x' + hexString; + } + return bytes.arrayify(hexString); + } + exports.looseArrayify = looseArrayify; + function zpad(value, length) { + value = String(value); + while (value.length < length) { + value = '0' + value; + } + return value; + } + exports.zpad = zpad; + function getPassword(password) { + if (typeof (password) === 'string') { + return strings.toUtf8Bytes(password, strings.UnicodeNormalizationForm.NFKC); + } + return bytes.arrayify(password); + } + exports.getPassword = getPassword; + function searchPath(object, path) { + var currentChild = object; + var comps = path.toLowerCase().split('/'); + for (var i = 0; i < comps.length; i++) { + // Search for a child object with a case-insensitive matching key + var matchingChild = null; + for (var key in currentChild) { + if (key.toLowerCase() === comps[i]) { + matchingChild = currentChild[key]; + break; + } + } + // Didn't find one. :'( + if (matchingChild === null) { + return null; + } + // Now check this child... + currentChild = matchingChild; + } + return currentChild; + } + exports.searchPath = searchPath; + }); + + var utils$2 = unwrapExports(utils$1); + var utils_1$2 = utils$1.looseArrayify; + var utils_2 = utils$1.zpad; + var utils_3 = utils$1.getPassword; + var utils_4 = utils$1.searchPath; + + var crowdsale = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var aes_js_1 = __importDefault(aesJs); + + + + + + + + + var logger$1 = new logger.Logger(_version$y.version); + + var CrowdsaleAccount = /** @class */ (function (_super) { + __extends(CrowdsaleAccount, _super); + function CrowdsaleAccount() { + return _super !== null && _super.apply(this, arguments) || this; + } + CrowdsaleAccount.prototype.isCrowdsaleAccount = function (value) { + return !!(value && value._isCrowdsaleAccount); + }; + return CrowdsaleAccount; + }(properties.Description)); + exports.CrowdsaleAccount = CrowdsaleAccount; + // See: https://github.com/ethereum/pyethsaletool + function decrypt(json, password) { + var data = JSON.parse(json); + password = utils$1.getPassword(password); + // Ethereum Address + var ethaddr = address.getAddress(utils$1.searchPath(data, "ethaddr")); + // Encrypted Seed + var encseed = utils$1.looseArrayify(utils$1.searchPath(data, "encseed")); + if (!encseed || (encseed.length % 16) !== 0) { + logger$1.throwArgumentError("invalid encseed", "json", json); + } + var key = bytes.arrayify(browser$2.pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); + var iv = encseed.slice(0, 16); + var encryptedSeed = encseed.slice(16); + // Decrypt the seed + var aesCbc = new aes_js_1.default.ModeOfOperation.cbc(key, iv); + var seed = bytes.arrayify(aesCbc.decrypt(encryptedSeed)); + seed = aes_js_1.default.padding.pkcs7.strip(seed); + // This wallet format is weird... Convert the binary encoded hex to a string. + var seedHex = ""; + for (var i = 0; i < seed.length; i++) { + seedHex += String.fromCharCode(seed[i]); + } + var seedHexBytes = strings.toUtf8Bytes(seedHex); + var privateKey = keccak256_1.keccak256(seedHexBytes); + return new CrowdsaleAccount({ + _isCrowdsaleAccount: true, + address: ethaddr, + privateKey: privateKey + }); + } + exports.decrypt = decrypt; + }); + + var crowdsale$1 = unwrapExports(crowdsale); + var crowdsale_1 = crowdsale.CrowdsaleAccount; + var crowdsale_2 = crowdsale.decrypt; + + var inspect = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + function isCrowdsaleWallet(json) { + var data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + return (data.encseed && data.ethaddr); + } + exports.isCrowdsaleWallet = isCrowdsaleWallet; + function isKeystoreWallet(json) { + var data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { + return false; + } + // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff + return true; + } + exports.isKeystoreWallet = isKeystoreWallet; + //export function isJsonWallet(json: string): boolean { + // return (isSecretStorageWallet(json) || isCrowdsaleWallet(json)); + //} + function getJsonWalletAddress(json) { + if (isCrowdsaleWallet(json)) { + try { + return address.getAddress(JSON.parse(json).ethaddr); + } + catch (error) { + return null; + } + } + if (isKeystoreWallet(json)) { + try { + return address.getAddress(JSON.parse(json).address); + } + catch (error) { + return null; + } + } + return null; + } + exports.getJsonWalletAddress = getJsonWalletAddress; + }); + + var inspect$1 = unwrapExports(inspect); + var inspect_1 = inspect.isCrowdsaleWallet; + var inspect_2 = inspect.isKeystoreWallet; + var inspect_3 = inspect.getJsonWalletAddress; + + var scrypt = createCommonjsModule(function (module, exports) { + "use strict"; + + (function(root) { + var MAX_VALUE = 0x7fffffff; + + // The SHA256 and PBKDF2 implementation are from scrypt-async-js: + // See: https://github.com/dchest/scrypt-async-js + function SHA256(m) { + var K = [ + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, + 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, + 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, + 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, + 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, + 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, + 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, + 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, + 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, + 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 + ]; + + var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a; + var h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19; + var w = new Array(64); + + function blocks(p) { + var off = 0, len = p.length; + while (len >= 64) { + var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, u, i, j, t1, t2; + + for (i = 0; i < 16; i++) { + j = off + i*4; + w[i] = ((p[j] & 0xff)<<24) | ((p[j+1] & 0xff)<<16) | + ((p[j+2] & 0xff)<<8) | (p[j+3] & 0xff); + } + + for (i = 16; i < 64; i++) { + u = w[i-2]; + t1 = ((u>>>17) | (u<<(32-17))) ^ ((u>>>19) | (u<<(32-19))) ^ (u>>>10); + + u = w[i-15]; + t2 = ((u>>>7) | (u<<(32-7))) ^ ((u>>>18) | (u<<(32-18))) ^ (u>>>3); + + w[i] = (((t1 + w[i-7]) | 0) + ((t2 + w[i-16]) | 0)) | 0; + } + + for (i = 0; i < 64; i++) { + t1 = ((((((e>>>6) | (e<<(32-6))) ^ ((e>>>11) | (e<<(32-11))) ^ + ((e>>>25) | (e<<(32-25)))) + ((e & f) ^ (~e & g))) | 0) + + ((h + ((K[i] + w[i]) | 0)) | 0)) | 0; + + t2 = ((((a>>>2) | (a<<(32-2))) ^ ((a>>>13) | (a<<(32-13))) ^ + ((a>>>22) | (a<<(32-22)))) + ((a & b) ^ (a & c) ^ (b & c))) | 0; + + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } + + h0 = (h0 + a) | 0; + h1 = (h1 + b) | 0; + h2 = (h2 + c) | 0; + h3 = (h3 + d) | 0; + h4 = (h4 + e) | 0; + h5 = (h5 + f) | 0; + h6 = (h6 + g) | 0; + h7 = (h7 + h) | 0; + + off += 64; + len -= 64; + } + } + + blocks(m); + + var i, bytesLeft = m.length % 64, + bitLenHi = (m.length / 0x20000000) | 0, + bitLenLo = m.length << 3, + numZeros = (bytesLeft < 56) ? 56 : 120, + p = m.slice(m.length - bytesLeft, m.length); + + p.push(0x80); + for (i = bytesLeft + 1; i < numZeros; i++) { p.push(0); } + p.push((bitLenHi>>>24) & 0xff); + p.push((bitLenHi>>>16) & 0xff); + p.push((bitLenHi>>>8) & 0xff); + p.push((bitLenHi>>>0) & 0xff); + p.push((bitLenLo>>>24) & 0xff); + p.push((bitLenLo>>>16) & 0xff); + p.push((bitLenLo>>>8) & 0xff); + p.push((bitLenLo>>>0) & 0xff); + + blocks(p); + + return [ + (h0>>>24) & 0xff, (h0>>>16) & 0xff, (h0>>>8) & 0xff, (h0>>>0) & 0xff, + (h1>>>24) & 0xff, (h1>>>16) & 0xff, (h1>>>8) & 0xff, (h1>>>0) & 0xff, + (h2>>>24) & 0xff, (h2>>>16) & 0xff, (h2>>>8) & 0xff, (h2>>>0) & 0xff, + (h3>>>24) & 0xff, (h3>>>16) & 0xff, (h3>>>8) & 0xff, (h3>>>0) & 0xff, + (h4>>>24) & 0xff, (h4>>>16) & 0xff, (h4>>>8) & 0xff, (h4>>>0) & 0xff, + (h5>>>24) & 0xff, (h5>>>16) & 0xff, (h5>>>8) & 0xff, (h5>>>0) & 0xff, + (h6>>>24) & 0xff, (h6>>>16) & 0xff, (h6>>>8) & 0xff, (h6>>>0) & 0xff, + (h7>>>24) & 0xff, (h7>>>16) & 0xff, (h7>>>8) & 0xff, (h7>>>0) & 0xff + ]; + } + + function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) { + // compress password if it's longer than hash block length + password = password.length <= 64 ? password : SHA256(password); + + var i; + var innerLen = 64 + salt.length + 4; + var inner = new Array(innerLen); + var outerKey = new Array(64); + var dk = []; + + // inner = (password ^ ipad) || salt || counter + for (i = 0; i < 64; i++) inner[i] = 0x36; + for (i = 0; i < password.length; i++) inner[i] ^= password[i]; + for (i = 0; i < salt.length; i++) inner[64+i] = salt[i]; + for (i = innerLen - 4; i < innerLen; i++) inner[i] = 0; + + // outerKey = password ^ opad + for (i = 0; i < 64; i++) outerKey[i] = 0x5c; + for (i = 0; i < password.length; i++) outerKey[i] ^= password[i]; + + // increments counter inside inner + function incrementCounter() { + for (var i = innerLen-1; i >= innerLen-4; i--) { + inner[i]++; + if (inner[i] <= 0xff) return; + inner[i] = 0; + } + } + + // output blocks = SHA256(outerKey || SHA256(inner)) ... + while (dkLen >= 32) { + incrementCounter(); + dk = dk.concat(SHA256(outerKey.concat(SHA256(inner)))); + dkLen -= 32; + } + if (dkLen > 0) { + incrementCounter(); + dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen)); + } + + return dk; + } + + // The following is an adaptation of scryptsy + // See: https://www.npmjs.com/package/scryptsy + function blockmix_salsa8(BY, Yi, r, x, _X) { + var i; + + arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16); + for (i = 0; i < 2 * r; i++) { + blockxor(BY, i * 16, _X, 16); + salsa20_8(_X, x); + arraycopy(_X, 0, BY, Yi + (i * 16), 16); + } + + for (i = 0; i < r; i++) { + arraycopy(BY, Yi + (i * 2) * 16, BY, (i * 16), 16); + } + + for (i = 0; i < r; i++) { + arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16); + } + } + + function R(a, b) { + return (a << b) | (a >>> (32 - b)); + } + + function salsa20_8(B, x) { + arraycopy(B, 0, x, 0, 16); + + for (var i = 8; i > 0; i -= 2) { + x[ 4] ^= R(x[ 0] + x[12], 7); + x[ 8] ^= R(x[ 4] + x[ 0], 9); + x[12] ^= R(x[ 8] + x[ 4], 13); + x[ 0] ^= R(x[12] + x[ 8], 18); + x[ 9] ^= R(x[ 5] + x[ 1], 7); + x[13] ^= R(x[ 9] + x[ 5], 9); + x[ 1] ^= R(x[13] + x[ 9], 13); + x[ 5] ^= R(x[ 1] + x[13], 18); + x[14] ^= R(x[10] + x[ 6], 7); + x[ 2] ^= R(x[14] + x[10], 9); + x[ 6] ^= R(x[ 2] + x[14], 13); + x[10] ^= R(x[ 6] + x[ 2], 18); + x[ 3] ^= R(x[15] + x[11], 7); + x[ 7] ^= R(x[ 3] + x[15], 9); + x[11] ^= R(x[ 7] + x[ 3], 13); + x[15] ^= R(x[11] + x[ 7], 18); + x[ 1] ^= R(x[ 0] + x[ 3], 7); + x[ 2] ^= R(x[ 1] + x[ 0], 9); + x[ 3] ^= R(x[ 2] + x[ 1], 13); + x[ 0] ^= R(x[ 3] + x[ 2], 18); + x[ 6] ^= R(x[ 5] + x[ 4], 7); + x[ 7] ^= R(x[ 6] + x[ 5], 9); + x[ 4] ^= R(x[ 7] + x[ 6], 13); + x[ 5] ^= R(x[ 4] + x[ 7], 18); + x[11] ^= R(x[10] + x[ 9], 7); + x[ 8] ^= R(x[11] + x[10], 9); + x[ 9] ^= R(x[ 8] + x[11], 13); + x[10] ^= R(x[ 9] + x[ 8], 18); + x[12] ^= R(x[15] + x[14], 7); + x[13] ^= R(x[12] + x[15], 9); + x[14] ^= R(x[13] + x[12], 13); + x[15] ^= R(x[14] + x[13], 18); + } + + for (i = 0; i < 16; ++i) { + B[i] += x[i]; + } + } + + // naive approach... going back to loop unrolling may yield additional performance + function blockxor(S, Si, D, len) { + for (var i = 0; i < len; i++) { + D[i] ^= S[Si + i]; + } + } + + function arraycopy(src, srcPos, dest, destPos, length) { + while (length--) { + dest[destPos++] = src[srcPos++]; + } + } + + function checkBufferish(o) { + if (!o || typeof(o.length) !== 'number') { + return false; + } + for (var i = 0; i < o.length; i++) { + if (typeof(o[i]) !== 'number') { return false; } + + var v = parseInt(o[i]); + if (v != o[i] || v < 0 || v >= 256) { + return false; + } + } + return true; + } + + function ensureInteger(value, name) { + var intValue = parseInt(value); + if (value != intValue) { throw new Error('invalid ' + name); } + return intValue; + } + + // N = Cpu cost, r = Memory cost, p = parallelization cost + // callback(error, progress, key) + function scrypt(password, salt, N, r, p, dkLen, callback) { + + if (!callback) { throw new Error('missing callback'); } + + N = ensureInteger(N, 'N'); + r = ensureInteger(r, 'r'); + p = ensureInteger(p, 'p'); + + dkLen = ensureInteger(dkLen, 'dkLen'); + + if (N === 0 || (N & (N - 1)) !== 0) { throw new Error('N must be power of 2'); } + + if (N > MAX_VALUE / 128 / r) { throw new Error('N too large'); } + if (r > MAX_VALUE / 128 / p) { throw new Error('r too large'); } + + if (!checkBufferish(password)) { + throw new Error('password must be an array or buffer'); + } + password = Array.prototype.slice.call(password); + + if (!checkBufferish(salt)) { + throw new Error('salt must be an array or buffer'); + } + salt = Array.prototype.slice.call(salt); + + var b = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r); + var B = new Uint32Array(p * 32 * r); + for (var i = 0; i < B.length; i++) { + var j = i * 4; + B[i] = ((b[j + 3] & 0xff) << 24) | + ((b[j + 2] & 0xff) << 16) | + ((b[j + 1] & 0xff) << 8) | + ((b[j + 0] & 0xff) << 0); + } + + var XY = new Uint32Array(64 * r); + var V = new Uint32Array(32 * r * N); + + var Yi = 32 * r; + + // scratch space + var x = new Uint32Array(16); // salsa20_8 + var _X = new Uint32Array(16); // blockmix_salsa8 + + var totalOps = p * N * 2; + var currentOp = 0; + var lastPercent10 = null; + + // Set this to true to abandon the scrypt on the next step + var stop = false; + + // State information + var state = 0; + var i0 = 0, i1; + var Bi; + + // How many blockmix_salsa8 can we do per step? + var limit = parseInt(1000 / r); + + // Trick from scrypt-async; if there is a setImmediate shim in place, use it + var nextTick = (typeof(setImmediate) !== 'undefined') ? setImmediate : setTimeout; + + // This is really all I changed; making scryptsy a state machine so we occasionally + // stop and give other evnts on the evnt loop a chance to run. ~RicMoo + var incrementalSMix = function() { + if (stop) { + return callback(new Error('cancelled'), currentOp / totalOps); + } + + switch (state) { + case 0: + // for (var i = 0; i < p; i++)... + Bi = i0 * 32 * r; + + arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1 + + state = 1; // Move to ROMix 2 + i1 = 0; + + // Fall through + + case 1: + + // Run up to 1000 steps of the first inner smix loop + var steps = N - i1; + if (steps > limit) { steps = limit; } + for (var i = 0; i < steps; i++) { // ROMix - 2 + arraycopy(XY, 0, V, (i1 + i) * Yi, Yi); // ROMix - 3 + blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 4 + } + + // for (var i = 0; i < N; i++) + i1 += steps; + currentOp += steps; + + // Call the callback with the progress (optionally stopping us) + var percent10 = parseInt(1000 * currentOp / totalOps); + if (percent10 !== lastPercent10) { + stop = callback(null, currentOp / totalOps); + if (stop) { break; } + lastPercent10 = percent10; + } + + if (i1 < N) { + break; + } + + i1 = 0; // Move to ROMix 6 + state = 2; + + // Fall through + + case 2: + + // Run up to 1000 steps of the second inner smix loop + var steps = N - i1; + if (steps > limit) { steps = limit; } + for (var i = 0; i < steps; i++) { // ROMix - 6 + var offset = (2 * r - 1) * 16; // ROMix - 7 + var j = XY[offset] & (N - 1); + blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner) + blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer) + } + + // for (var i = 0; i < N; i++)... + i1 += steps; + currentOp += steps; + + // Call the callback with the progress (optionally stopping us) + var percent10 = parseInt(1000 * currentOp / totalOps); + if (percent10 !== lastPercent10) { + stop = callback(null, currentOp / totalOps); + if (stop) { break; } + lastPercent10 = percent10; + } + + if (i1 < N) { + break; + } + + arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10 + + // for (var i = 0; i < p; i++)... + i0++; + if (i0 < p) { + state = 0; + break; + } + + b = []; + for (var i = 0; i < B.length; i++) { + b.push((B[i] >> 0) & 0xff); + b.push((B[i] >> 8) & 0xff); + b.push((B[i] >> 16) & 0xff); + b.push((B[i] >> 24) & 0xff); + } + + var derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b, dkLen); + + // Done; don't break (which would reschedule) + return callback(null, 1.0, derivedKey); + } + + // Schedule the next steps + nextTick(incrementalSMix); + }; + + // Bootstrap the incremental smix + incrementalSMix(); + } + + // node.js + if ('object' !== 'undefined') { + module.exports = scrypt; + + // RequireJS/AMD + // http://www.requirejs.org/docs/api.html + // https://github.com/amdjs/amdjs-api/wiki/AMD + } else if (typeof(undefined) === 'function' && undefined.amd) { + undefined(scrypt); + + // Web Browsers + } else if (root) { + + // If there was an existing library "scrypt", make sure it is still available + if (root.scrypt) { + root._scrypt = root.scrypt; + } + + root.scrypt = scrypt; + } + + })(commonjsGlobal); + }); + + var rng; + + if (commonjsGlobal.crypto && crypto.getRandomValues) { + // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto + // Moderately fast, high quality + var _rnds8 = new Uint8Array(16); + rng = function whatwgRNG() { + crypto.getRandomValues(_rnds8); + return _rnds8; + }; + } + + if (!rng) { + // Math.random()-based (RNG) + // + // If all else fails, use Math.random(). It's fast, but is of unspecified + // quality. + var _rnds = new Array(16); + rng = function() { + for (var i = 0, r; i < 16; i++) { + if ((i & 0x03) === 0) r = Math.random() * 0x100000000; + _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; + } + + return _rnds; + }; + } + + var rngBrowser = rng; + + // uuid.js + // + // Copyright (c) 2010-2012 Robert Kieffer + // MIT License - http://opensource.org/licenses/mit-license.php + + // Unique ID creation requires a high quality random # generator. We feature + // detect to determine the best RNG source, normalizing to a function that + // returns 128-bits of randomness, since that's what's usually required + + + // Maps for number <-> hex string conversion + var _byteToHex = []; + var _hexToByte = {}; + for (var i = 0; i < 256; i++) { + _byteToHex[i] = (i + 0x100).toString(16).substr(1); + _hexToByte[_byteToHex[i]] = i; + } + + // **`parse()` - Parse a UUID into it's component bytes** + function parse(s, buf, offset) { + var i = (buf && offset) || 0, ii = 0; + + buf = buf || []; + s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { + if (ii < 16) { // Don't overflow! + buf[i + ii++] = _hexToByte[oct]; + } + }); + + // Zero out remaining bytes if string was short + while (ii < 16) { + buf[i + ii++] = 0; + } + + return buf; + } + + // **`unparse()` - Convert UUID byte array (ala parse()) into a string** + function unparse(buf, offset) { + var i = offset || 0, bth = _byteToHex; + return bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + '-' + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]] + + bth[buf[i++]] + bth[buf[i++]]; + } + + // **`v1()` - Generate time-based UUID** + // + // Inspired by https://github.com/LiosK/UUID.js + // and http://docs.python.org/library/uuid.html + + // random #'s we need to init node and clockseq + var _seedBytes = rngBrowser(); + + // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) + var _nodeId = [ + _seedBytes[0] | 0x01, + _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] + ]; + + // Per 4.2.2, randomize (14 bit) clockseq + var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; + + // Previous uuid creation time + var _lastMSecs = 0, _lastNSecs = 0; + + // See https://github.com/broofa/node-uuid for API details + function v1(options, buf, offset) { + var i = buf && offset || 0; + var b = buf || []; + + options = options || {}; + + var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; + + // UUID timestamps are 100 nano-second units since the Gregorian epoch, + // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so + // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' + // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. + var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); + + // Per 4.2.1.2, use count of uuid's generated during the current clock + // cycle to simulate higher resolution clock + var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; + + // Time since last uuid creation (in msecs) + var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; + + // Per 4.2.1.2, Bump clockseq on clock regression + if (dt < 0 && options.clockseq === undefined) { + clockseq = clockseq + 1 & 0x3fff; + } + + // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new + // time interval + if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { + nsecs = 0; + } + + // Per 4.2.1.2 Throw error if too many uuids are requested + if (nsecs >= 10000) { + throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); + } + + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + + // Per 4.1.4 - Convert from unix epoch to Gregorian epoch + msecs += 12219292800000; + + // `time_low` + var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + b[i++] = tl >>> 24 & 0xff; + b[i++] = tl >>> 16 & 0xff; + b[i++] = tl >>> 8 & 0xff; + b[i++] = tl & 0xff; + + // `time_mid` + var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; + b[i++] = tmh >>> 8 & 0xff; + b[i++] = tmh & 0xff; + + // `time_high_and_version` + b[i++] = tmh >>> 24 & 0xf | 0x10; // include version + b[i++] = tmh >>> 16 & 0xff; + + // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) + b[i++] = clockseq >>> 8 | 0x80; + + // `clock_seq_low` + b[i++] = clockseq & 0xff; + + // `node` + var node = options.node || _nodeId; + for (var n = 0; n < 6; n++) { + b[i + n] = node[n]; + } + + return buf ? buf : unparse(b); + } + + // **`v4()` - Generate random UUID** + + // See https://github.com/broofa/node-uuid for API details + function v4(options, buf, offset) { + // Deprecated - 'format' argument, as supported in v1.2 + var i = buf && offset || 0; + + if (typeof(options) == 'string') { + buf = options == 'binary' ? new Array(16) : null; + options = null; + } + options = options || {}; + + var rnds = options.random || (options.rng || rngBrowser)(); + + // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + + // Copy bytes to buffer, if provided + if (buf) { + for (var ii = 0; ii < 16; ii++) { + buf[i + ii] = rnds[ii]; + } + } + + return buf || unparse(rnds); + } + + // Export public API + var uuid = v4; + uuid.v1 = v1; + uuid.v4 = v4; + uuid.parse = parse; + uuid.unparse = unparse; + + var uuid_1 = uuid; + + var keystore = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var aes_js_1 = __importDefault(aesJs); + var scrypt_js_1 = __importDefault(scrypt); + var uuid_1$1 = __importDefault(uuid_1); + + + + + + + + + + // Exported Types + var KeystoreAccount = /** @class */ (function (_super) { + __extends(KeystoreAccount, _super); + function KeystoreAccount() { + return _super !== null && _super.apply(this, arguments) || this; + } + KeystoreAccount.prototype.isKeystoreAccount = function (value) { + return !!(value && value._isKeystoreAccount); + }; + return KeystoreAccount; + }(properties.Description)); + exports.KeystoreAccount = KeystoreAccount; + function decrypt(json, password, progressCallback) { + var data = JSON.parse(json); + var passwordBytes = utils$1.getPassword(password); + var decrypt = function (key, ciphertext) { + var cipher = utils$1.searchPath(data, "crypto/cipher"); + if (cipher === "aes-128-ctr") { + var iv = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/cipherparams/iv")); + var counter = new aes_js_1.default.Counter(iv); + var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter); + return bytes.arrayify(aesCtr.decrypt(ciphertext)); + } + return null; + }; + var computeMAC = function (derivedHalf, ciphertext) { + return keccak256_1.keccak256(bytes.concat([derivedHalf, ciphertext])); + }; + var getAccount = function (key, reject) { + var ciphertext = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/ciphertext")); + var computedMAC = bytes.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); + if (computedMAC !== utils$1.searchPath(data, "crypto/mac").toLowerCase()) { + reject(new Error("invalid password")); + return null; + } + var privateKey = decrypt(key.slice(0, 16), ciphertext); + var mnemonicKey = key.slice(32, 64); + if (!privateKey) { + reject(new Error("unsupported cipher")); + return null; + } + var address$1 = transactions.computeAddress(privateKey); + if (data.address) { + var check = data.address.toLowerCase(); + if (check.substring(0, 2) !== "0x") { + check = "0x" + check; + } + try { + if (address.getAddress(check) !== address$1) { + reject(new Error("address mismatch")); + return null; + } + } + catch (e) { } + } + var account = { + _isKeystoreAccount: true, + address: address$1, + privateKey: bytes.hexlify(privateKey) + }; + // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase + if (utils$1.searchPath(data, "x-ethers/version") === "0.1") { + var mnemonicCiphertext = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCiphertext")); + var mnemonicIv = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCounter")); + var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); + var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + var path = utils$1.searchPath(data, "x-ethers/path") || hdnode.defaultPath; + var entropy = bytes.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); + var mnemonic = hdnode.entropyToMnemonic(entropy); + var node = hdnode.HDNode.fromMnemonic(mnemonic).derivePath(path); + if (node.privateKey != account.privateKey) { + reject(new Error("mnemonic mismatch")); + return null; + } + account.mnemonic = node.mnemonic; + account.path = node.path; + } + return new KeystoreAccount(account); + }; + return new Promise(function (resolve, reject) { + var kdf = utils$1.searchPath(data, "crypto/kdf"); + if (kdf && typeof (kdf) === "string") { + if (kdf.toLowerCase() === "scrypt") { + var salt = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/kdfparams/salt")); + var N = parseInt(utils$1.searchPath(data, "crypto/kdfparams/n")); + var r = parseInt(utils$1.searchPath(data, "crypto/kdfparams/r")); + var p = parseInt(utils$1.searchPath(data, "crypto/kdfparams/p")); + if (!N || !r || !p) { + reject(new Error("unsupported key-derivation function parameters")); + return; + } + // Make sure N is a power of 2 + if ((N & (N - 1)) !== 0) { + reject(new Error("unsupported key-derivation function parameter value for N")); + return; + } + var dkLen = parseInt(utils$1.searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + if (progressCallback) { + progressCallback(0); + } + scrypt_js_1.default(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = bytes.arrayify(key); + var account = getAccount(key, reject); + if (!account) { + return; + } + if (progressCallback) { + progressCallback(1); + } + resolve(account); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + } + else if (kdf.toLowerCase() === "pbkdf2") { + var salt = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/kdfparams/salt")); + var prfFunc = null; + var prf = utils$1.searchPath(data, "crypto/kdfparams/prf"); + if (prf === "hmac-sha256") { + prfFunc = "sha256"; + } + else if (prf === "hmac-sha512") { + prfFunc = "sha512"; + } + else { + reject(new Error("unsupported prf")); + return; + } + var c = parseInt(utils$1.searchPath(data, "crypto/kdfparams/c")); + var dkLen = parseInt(utils$1.searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + var key = bytes.arrayify(browser$2.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); + var account = getAccount(key, reject); + if (!account) { + return; + } + resolve(account); + } + else { + reject(new Error("unsupported key-derivation function")); + } + } + else { + reject(new Error("unsupported key-derivation function")); + } + }); + } + exports.decrypt = decrypt; + function encrypt(account, password, options, progressCallback) { + try { + if (address.getAddress(account.address) !== transactions.computeAddress(account.privateKey)) { + throw new Error("address/privateKey mismatch"); + } + if (account.mnemonic != null) { + var node = hdnode.HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || hdnode.defaultPath); + if (node.privateKey != account.privateKey) { + throw new Error("mnemonic mismatch"); + } + } + else if (account.path != null) { + throw new Error("cannot specify path without mnemonic"); + } + } + catch (e) { + return Promise.reject(e); + } + // the options are optional, so adjust the call as needed + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (!options) { + options = {}; + } + var privateKey = bytes.arrayify(account.privateKey); + var passwordBytes = utils$1.getPassword(password); + var entropy = null; + var path = account.path; + if (account.mnemonic) { + entropy = bytes.arrayify(hdnode.mnemonicToEntropy(account.mnemonic)); + if (!path) { + path = hdnode.defaultPath; + } + } + var client = options.client; + if (!client) { + client = "ethers.js"; + } + // Check/generate the salt + var salt = null; + if (options.salt) { + salt = bytes.arrayify(options.salt); + } + else { + salt = browser$6.randomBytes(32); + ; + } + // Override initialization vector + var iv = null; + if (options.iv) { + iv = bytes.arrayify(options.iv); + if (iv.length !== 16) { + throw new Error("invalid iv"); + } + } + else { + iv = browser$6.randomBytes(16); + } + // Override the uuid + var uuidRandom = null; + if (options.uuid) { + uuidRandom = bytes.arrayify(options.uuid); + if (uuidRandom.length !== 16) { + throw new Error("invalid uuid"); + } + } + else { + uuidRandom = browser$6.randomBytes(16); + } + // Override the scrypt password-based key derivation function parameters + var N = (1 << 17), r = 8, p = 1; + if (options.scrypt) { + if (options.scrypt.N) { + N = options.scrypt.N; + } + if (options.scrypt.r) { + r = options.scrypt.r; + } + if (options.scrypt.p) { + p = options.scrypt.p; + } + } + return new Promise(function (resolve, reject) { + if (progressCallback) { + progressCallback(0); + } + // We take 64 bytes: + // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) + // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) + scrypt_js_1.default(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = bytes.arrayify(key); + // This will be used to encrypt the wallet (as per Web3 secret storage) + var derivedKey = key.slice(0, 16); + var macPrefix = key.slice(16, 32); + // This will be used to encrypt the mnemonic phrase (if any) + var mnemonicKey = key.slice(32, 64); + // Encrypt the private key + var counter = new aes_js_1.default.Counter(iv); + var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(derivedKey, counter); + var ciphertext = bytes.arrayify(aesCtr.encrypt(privateKey)); + // Compute the message authentication code, used to check the password + var mac = keccak256_1.keccak256(bytes.concat([macPrefix, ciphertext])); + // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition + var data = { + address: account.address.substring(2).toLowerCase(), + id: uuid_1$1.default.v4({ random: uuidRandom }), + version: 3, + Crypto: { + cipher: "aes-128-ctr", + cipherparams: { + iv: bytes.hexlify(iv).substring(2), + }, + ciphertext: bytes.hexlify(ciphertext).substring(2), + kdf: "scrypt", + kdfparams: { + salt: bytes.hexlify(salt).substring(2), + n: N, + dklen: 32, + p: p, + r: r + }, + mac: mac.substring(2) + } + }; + // If we have a mnemonic, encrypt it into the JSON wallet + if (entropy) { + var mnemonicIv = browser$6.randomBytes(16); + var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); + var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + var mnemonicCiphertext = bytes.arrayify(mnemonicAesCtr.encrypt(entropy)); + var now = new Date(); + var timestamp = (now.getUTCFullYear() + "-" + + utils$1.zpad(now.getUTCMonth() + 1, 2) + "-" + + utils$1.zpad(now.getUTCDate(), 2) + "T" + + utils$1.zpad(now.getUTCHours(), 2) + "-" + + utils$1.zpad(now.getUTCMinutes(), 2) + "-" + + utils$1.zpad(now.getUTCSeconds(), 2) + ".0Z"); + data["x-ethers"] = { + client: client, + gethFilename: ("UTC--" + timestamp + "--" + data.address), + mnemonicCounter: bytes.hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: bytes.hexlify(mnemonicCiphertext).substring(2), + path: path, + version: "0.1" + }; + } + if (progressCallback) { + progressCallback(1); + } + resolve(JSON.stringify(data)); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + }); + } + exports.encrypt = encrypt; + }); + + var keystore$1 = unwrapExports(keystore); + var keystore_1 = keystore.KeystoreAccount; + var keystore_2 = keystore.decrypt; + var keystore_3 = keystore.encrypt; + + var jsonWallets = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.decryptCrowdsale = crowdsale.decrypt; + + exports.getJsonWalletAddress = inspect.getJsonWalletAddress; + exports.isCrowdsaleWallet = inspect.isCrowdsaleWallet; + exports.isKeystoreWallet = inspect.isKeystoreWallet; + + exports.decryptKeystore = keystore.decrypt; + exports.encryptKeystore = keystore.encrypt; + function decryptJsonWallet(json, password, progressCallback) { + if (inspect.isCrowdsaleWallet(json)) { + if (progressCallback) { + progressCallback(0); + } + var account = crowdsale.decrypt(json, password); + if (progressCallback) { + progressCallback(1); + } + return Promise.resolve(account); + } + if (inspect.isKeystoreWallet(json)) { + return keystore.decrypt(json, password, progressCallback); + } + return Promise.reject(new Error("invalid JSON wallet")); + } + exports.decryptJsonWallet = decryptJsonWallet; + }); + + var index$i = unwrapExports(jsonWallets); + var jsonWallets_1 = jsonWallets.decryptCrowdsale; + var jsonWallets_2 = jsonWallets.getJsonWalletAddress; + var jsonWallets_3 = jsonWallets.isCrowdsaleWallet; + var jsonWallets_4 = jsonWallets.isKeystoreWallet; + var jsonWallets_5 = jsonWallets.decryptKeystore; + var jsonWallets_6 = jsonWallets.encryptKeystore; + var jsonWallets_7 = jsonWallets.decryptJsonWallet; + + var _version$A = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "wallet/5.0.0-beta.130"; + }); + + var _version$B = unwrapExports(_version$A); + var _version_1$i = _version$A.version; + + var wallet = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + + + + + + + var logger$1 = new logger.Logger(_version$A.version); + function isAccount(value) { + return (value != null && bytes.isHexString(value.privateKey, 32) && value.address != null); + } + var Wallet = /** @class */ (function (_super) { + __extends(Wallet, _super); + function Wallet(privateKey, provider) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, Wallet); + _this = _super.call(this) || this; + if (isAccount(privateKey)) { + var signingKey_1 = new signingKey.SigningKey(privateKey.privateKey); + properties.defineReadOnly(_this, "_signingKey", function () { return signingKey_1; }); + properties.defineReadOnly(_this, "address", transactions.computeAddress(_this.publicKey)); + if (_this.address !== address.getAddress(privateKey.address)) { + logger$1.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); + } + if (privateKey.mnemonic != null) { + var mnemonic_1 = privateKey.mnemonic; + var path = privateKey.path || hdnode.defaultPath; + properties.defineReadOnly(_this, "_mnemonic", function () { return mnemonic_1; }); + properties.defineReadOnly(_this, "path", privateKey.path); + var node = hdnode.HDNode.fromMnemonic(mnemonic_1).derivePath(path); + if (transactions.computeAddress(node.privateKey) !== _this.address) { + logger$1.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); + } + } + else { + properties.defineReadOnly(_this, "_mnemonic", function () { return null; }); + properties.defineReadOnly(_this, "path", null); + } + } + else { + if (signingKey.SigningKey.isSigningKey(privateKey)) { + if (privateKey.curve !== "secp256k1") { + logger$1.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); + } + properties.defineReadOnly(_this, "_signingKey", function () { return privateKey; }); + } + else { + var signingKey_2 = new signingKey.SigningKey(privateKey); + properties.defineReadOnly(_this, "_signingKey", function () { return signingKey_2; }); + } + properties.defineReadOnly(_this, "_mnemonic", function () { return null; }); + properties.defineReadOnly(_this, "path", null); + properties.defineReadOnly(_this, "address", transactions.computeAddress(_this.publicKey)); + } + if (provider && !abstractProvider.Provider.isProvider(provider)) { + logger$1.throwArgumentError("invalid provider", "provider", provider); + } + properties.defineReadOnly(_this, "provider", provider || null); + return _this; + } + Object.defineProperty(Wallet.prototype, "mnemonic", { + get: function () { return this._mnemonic(); }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Wallet.prototype, "privateKey", { + get: function () { return this._signingKey().privateKey; }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Wallet.prototype, "publicKey", { + get: function () { return this._signingKey().publicKey; }, + enumerable: true, + configurable: true + }); + Wallet.prototype.getAddress = function () { + return Promise.resolve(this.address); + }; + Wallet.prototype.connect = function (provider) { + return new Wallet(this, provider); + }; + Wallet.prototype.signTransaction = function (transaction) { + var _this = this; + return properties.resolveProperties(transaction).then(function (tx) { + if (tx.from != null) { + if (address.getAddress(tx.from) !== _this.address) { + throw new Error("transaction from address mismatch"); + } + delete tx.from; + } + var signature = _this._signingKey().signDigest(keccak256_1.keccak256(transactions.serialize(tx))); + return transactions.serialize(tx, signature); + }); + }; + Wallet.prototype.signMessage = function (message) { + return Promise.resolve(bytes.joinSignature(this._signingKey().signDigest(hash.hashMessage(message)))); + }; + Wallet.prototype.encrypt = function (password, options, progressCallback) { + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (progressCallback && typeof (progressCallback) !== "function") { + throw new Error("invalid callback"); + } + if (!options) { + options = {}; + } + return jsonWallets.encryptKeystore(this, password, options, progressCallback); + }; + /** + * Static methods to create Wallet instances. + */ + Wallet.createRandom = function (options) { + var entropy = browser$6.randomBytes(16); + if (!options) { + options = {}; + } + if (options.extraEntropy) { + entropy = bytes.arrayify(bytes.hexDataSlice(keccak256_1.keccak256(bytes.concat([entropy, options.extraEntropy])), 0, 16)); + } + var mnemonic = hdnode.entropyToMnemonic(entropy, options.locale); + return Wallet.fromMnemonic(mnemonic, options.path, options.locale); + }; + Wallet.fromEncryptedJson = function (json, password, progressCallback) { + return jsonWallets.decryptJsonWallet(json, password, progressCallback).then(function (account) { + return new Wallet(account); + }); + }; + Wallet.fromMnemonic = function (mnemonic, path, wordlist) { + if (!path) { + path = hdnode.defaultPath; + } + return new Wallet(hdnode.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); + }; + return Wallet; + }(abstractSigner.Signer)); + exports.Wallet = Wallet; + function verifyMessage(message, signature) { + return transactions.recoverAddress(hash.hashMessage(message), signature); + } + exports.verifyMessage = verifyMessage; + }); + + var index$j = unwrapExports(wallet); + var wallet_1 = wallet.Wallet; + var wallet_2 = wallet.verifyMessage; + + var _version$C = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "networks/5.0.0-beta.129"; + }); + + var _version$D = unwrapExports(_version$C); + var _version_1$j = _version$C.version; + + var networks_1 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + var logger$1 = new logger.Logger(_version$C.version); + function ethDefaultProvider(network) { + return function (providers, options) { + if (options == null) { + options = {}; + } + var providerList = []; + if (providers.InfuraProvider) { + try { + providerList.push(new providers.InfuraProvider(network, options.infura)); + } + catch (error) { } + } + if (providers.EtherscanProvider) { + try { + providerList.push(new providers.EtherscanProvider(network, options.etherscan)); + } + catch (error) { } + } + if (providers.NodesmithProvider) { + try { + providerList.push(new providers.NodesmithProvider(network, options.nodesmith)); + } + catch (error) { } + } + if (providers.AlchemyProvider) { + try { + providerList.push(new providers.AlchemyProvider(network, options.alchemy)); + } + catch (error) { } + } + if (providers.CloudflareProvider) { + try { + providerList.push(new providers.CloudflareProvider(network)); + } + catch (error) { } + } + if (providerList.length === 0) { + return null; + } + if (providers.FallbackProvider) { + return new providers.FallbackProvider(providerList); + ; + } + return providerList[0]; + }; + } + function etcDefaultProvider(url, network) { + return function (providers, options) { + if (providers.JsonRpcProvider) { + return new providers.JsonRpcProvider(url, network); + } + return null; + }; + } + var homestead = { + chainId: 1, + ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b", + name: "homestead", + _defaultProvider: ethDefaultProvider("homestead") + }; + var ropsten = { + chainId: 3, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "ropsten", + _defaultProvider: ethDefaultProvider("ropsten") + }; + var networks = { + unspecified: { + chainId: 0, + name: "unspecified" + }, + homestead: homestead, + mainnet: homestead, + morden: { + chainId: 2, + name: "morden" + }, + ropsten: ropsten, + testnet: ropsten, + rinkeby: { + chainId: 4, + ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A", + name: "rinkeby", + _defaultProvider: ethDefaultProvider("rinkeby") + }, + kovan: { + chainId: 42, + name: "kovan", + _defaultProvider: ethDefaultProvider("kovan") + }, + goerli: { + chainId: 5, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "goerli", + _defaultProvider: ethDefaultProvider("goerli") + }, + classic: { + chainId: 61, + name: "classic", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io", "classic") + }, + classicTestnet: { + chainId: 62, + name: "classicTestnet", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io/morden", "classicTestnet") + } + }; + /** + * getNetwork + * + * Converts a named common networks or chain ID (network ID) to a Network + * and verifies a network is a valid Network.. + */ + function getNetwork(network) { + // No network (null) + if (network == null) { + return null; + } + if (typeof (network) === "number") { + for (var name_1 in networks) { + var standard_1 = networks[name_1]; + if (standard_1.chainId === network) { + return { + name: standard_1.name, + chainId: standard_1.chainId, + ensAddress: (standard_1.ensAddress || null), + _defaultProvider: (standard_1._defaultProvider || null) + }; + } + } + return { + chainId: network, + name: "unknown" + }; + } + if (typeof (network) === "string") { + var standard_2 = networks[network]; + if (standard_2 == null) { + return null; + } + return { + name: standard_2.name, + chainId: standard_2.chainId, + ensAddress: standard_2.ensAddress, + _defaultProvider: (standard_2._defaultProvider || null) + }; + } + var standard = networks[network.name]; + // Not a standard network; check that it is a valid network in general + if (!standard) { + if (typeof (network.chainId) !== "number") { + logger$1.throwArgumentError("invalid network chainId", "network", network); + } + return network; + } + // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) + if (network.chainId !== 0 && network.chainId !== standard.chainId) { + logger$1.throwArgumentError("network chainId mismatch", "network", network); + } + // Standard Network (allow overriding the ENS address) + return { + name: network.name, + chainId: standard.chainId, + ensAddress: (network.ensAddress || standard.ensAddress || null), + _defaultProvider: (network._defaultProvider || standard._defaultProvider || null) + }; + } + exports.getNetwork = getNetwork; + }); + + var index$k = unwrapExports(networks_1); + var networks_2 = networks_1.getNetwork; + + var browserPonyfill = createCommonjsModule(function (module, exports) { + var __self__ = (function (root) { + function F() { + this.fetch = false; + this.DOMException = root.DOMException; + } + F.prototype = root; + return new F(); + })(typeof self !== 'undefined' ? self : commonjsGlobal); + (function(self) { + + var irrelevant = (function (exports) { + var support = { + searchParams: 'URLSearchParams' in self, + iterable: 'Symbol' in self && 'iterator' in Symbol, + blob: + 'FileReader' in self && + 'Blob' in self && + (function() { + try { + new Blob(); + return true + } catch (e) { + return false + } + })(), + formData: 'FormData' in self, + arrayBuffer: 'ArrayBuffer' in self + }; + + function isDataView(obj) { + return obj && DataView.prototype.isPrototypeOf(obj) + } + + if (support.arrayBuffer) { + var viewClasses = [ + '[object Int8Array]', + '[object Uint8Array]', + '[object Uint8ClampedArray]', + '[object Int16Array]', + '[object Uint16Array]', + '[object Int32Array]', + '[object Uint32Array]', + '[object Float32Array]', + '[object Float64Array]' + ]; + + var isArrayBufferView = + ArrayBuffer.isView || + function(obj) { + return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 + }; + } + + function normalizeName(name) { + if (typeof name !== 'string') { + name = String(name); + } + if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { + throw new TypeError('Invalid character in header field name') + } + return name.toLowerCase() + } + + function normalizeValue(value) { + if (typeof value !== 'string') { + value = String(value); + } + return value + } + + // Build a destructive iterator for the value list + function iteratorFor(items) { + var iterator = { + next: function() { + var value = items.shift(); + return {done: value === undefined, value: value} + } + }; + + if (support.iterable) { + iterator[Symbol.iterator] = function() { + return iterator + }; + } + + return iterator + } + + function Headers(headers) { + this.map = {}; + + if (headers instanceof Headers) { + headers.forEach(function(value, name) { + this.append(name, value); + }, this); + } else if (Array.isArray(headers)) { + headers.forEach(function(header) { + this.append(header[0], header[1]); + }, this); + } else if (headers) { + Object.getOwnPropertyNames(headers).forEach(function(name) { + this.append(name, headers[name]); + }, this); + } + } + + Headers.prototype.append = function(name, value) { + name = normalizeName(name); + value = normalizeValue(value); + var oldValue = this.map[name]; + this.map[name] = oldValue ? oldValue + ', ' + value : value; + }; + + Headers.prototype['delete'] = function(name) { + delete this.map[normalizeName(name)]; + }; + + Headers.prototype.get = function(name) { + name = normalizeName(name); + return this.has(name) ? this.map[name] : null + }; + + Headers.prototype.has = function(name) { + return this.map.hasOwnProperty(normalizeName(name)) + }; + + Headers.prototype.set = function(name, value) { + this.map[normalizeName(name)] = normalizeValue(value); + }; + + Headers.prototype.forEach = function(callback, thisArg) { + for (var name in this.map) { + if (this.map.hasOwnProperty(name)) { + callback.call(thisArg, this.map[name], name, this); + } + } + }; + + Headers.prototype.keys = function() { + var items = []; + this.forEach(function(value, name) { + items.push(name); + }); + return iteratorFor(items) + }; + + Headers.prototype.values = function() { + var items = []; + this.forEach(function(value) { + items.push(value); + }); + return iteratorFor(items) + }; + + Headers.prototype.entries = function() { + var items = []; + this.forEach(function(value, name) { + items.push([name, value]); + }); + return iteratorFor(items) + }; + + if (support.iterable) { + Headers.prototype[Symbol.iterator] = Headers.prototype.entries; + } + + function consumed(body) { + if (body.bodyUsed) { + return Promise.reject(new TypeError('Already read')) + } + body.bodyUsed = true; + } + + function fileReaderReady(reader) { + return new Promise(function(resolve, reject) { + reader.onload = function() { + resolve(reader.result); + }; + reader.onerror = function() { + reject(reader.error); + }; + }) + } + + function readBlobAsArrayBuffer(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsArrayBuffer(blob); + return promise + } + + function readBlobAsText(blob) { + var reader = new FileReader(); + var promise = fileReaderReady(reader); + reader.readAsText(blob); + return promise + } + + function readArrayBufferAsText(buf) { + var view = new Uint8Array(buf); + var chars = new Array(view.length); + + for (var i = 0; i < view.length; i++) { + chars[i] = String.fromCharCode(view[i]); + } + return chars.join('') + } + + function bufferClone(buf) { + if (buf.slice) { + return buf.slice(0) + } else { + var view = new Uint8Array(buf.byteLength); + view.set(new Uint8Array(buf)); + return view.buffer + } + } + + function Body() { + this.bodyUsed = false; + + this._initBody = function(body) { + this._bodyInit = body; + if (!body) { + this._bodyText = ''; + } else if (typeof body === 'string') { + this._bodyText = body; + } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { + this._bodyBlob = body; + } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { + this._bodyFormData = body; + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this._bodyText = body.toString(); + } else if (support.arrayBuffer && support.blob && isDataView(body)) { + this._bodyArrayBuffer = bufferClone(body.buffer); + // IE 10-11 can't handle a DataView body. + this._bodyInit = new Blob([this._bodyArrayBuffer]); + } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { + this._bodyArrayBuffer = bufferClone(body); + } else { + this._bodyText = body = Object.prototype.toString.call(body); + } + + if (!this.headers.get('content-type')) { + if (typeof body === 'string') { + this.headers.set('content-type', 'text/plain;charset=UTF-8'); + } else if (this._bodyBlob && this._bodyBlob.type) { + this.headers.set('content-type', this._bodyBlob.type); + } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { + this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); + } + } + }; + + if (support.blob) { + this.blob = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return Promise.resolve(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(new Blob([this._bodyArrayBuffer])) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as blob') + } else { + return Promise.resolve(new Blob([this._bodyText])) + } + }; + + this.arrayBuffer = function() { + if (this._bodyArrayBuffer) { + return consumed(this) || Promise.resolve(this._bodyArrayBuffer) + } else { + return this.blob().then(readBlobAsArrayBuffer) + } + }; + } + + this.text = function() { + var rejected = consumed(this); + if (rejected) { + return rejected + } + + if (this._bodyBlob) { + return readBlobAsText(this._bodyBlob) + } else if (this._bodyArrayBuffer) { + return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) + } else if (this._bodyFormData) { + throw new Error('could not read FormData body as text') + } else { + return Promise.resolve(this._bodyText) + } + }; + + if (support.formData) { + this.formData = function() { + return this.text().then(decode) + }; + } + + this.json = function() { + return this.text().then(JSON.parse) + }; + + return this + } + + // HTTP methods whose capitalization should be normalized + var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; + + function normalizeMethod(method) { + var upcased = method.toUpperCase(); + return methods.indexOf(upcased) > -1 ? upcased : method + } + + function Request(input, options) { + options = options || {}; + var body = options.body; + + if (input instanceof Request) { + if (input.bodyUsed) { + throw new TypeError('Already read') + } + this.url = input.url; + this.credentials = input.credentials; + if (!options.headers) { + this.headers = new Headers(input.headers); + } + this.method = input.method; + this.mode = input.mode; + this.signal = input.signal; + if (!body && input._bodyInit != null) { + body = input._bodyInit; + input.bodyUsed = true; + } + } else { + this.url = String(input); + } + + this.credentials = options.credentials || this.credentials || 'same-origin'; + if (options.headers || !this.headers) { + this.headers = new Headers(options.headers); + } + this.method = normalizeMethod(options.method || this.method || 'GET'); + this.mode = options.mode || this.mode || null; + this.signal = options.signal || this.signal; + this.referrer = null; + + if ((this.method === 'GET' || this.method === 'HEAD') && body) { + throw new TypeError('Body not allowed for GET or HEAD requests') + } + this._initBody(body); + } + + Request.prototype.clone = function() { + return new Request(this, {body: this._bodyInit}) + }; + + function decode(body) { + var form = new FormData(); + body + .trim() + .split('&') + .forEach(function(bytes) { + if (bytes) { + var split = bytes.split('='); + var name = split.shift().replace(/\+/g, ' '); + var value = split.join('=').replace(/\+/g, ' '); + form.append(decodeURIComponent(name), decodeURIComponent(value)); + } + }); + return form + } + + function parseHeaders(rawHeaders) { + var headers = new Headers(); + // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space + // https://tools.ietf.org/html/rfc7230#section-3.2 + var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); + preProcessedHeaders.split(/\r?\n/).forEach(function(line) { + var parts = line.split(':'); + var key = parts.shift().trim(); + if (key) { + var value = parts.join(':').trim(); + headers.append(key, value); + } + }); + return headers + } + + Body.call(Request.prototype); + + function Response(bodyInit, options) { + if (!options) { + options = {}; + } + + this.type = 'default'; + this.status = options.status === undefined ? 200 : options.status; + this.ok = this.status >= 200 && this.status < 300; + this.statusText = 'statusText' in options ? options.statusText : 'OK'; + this.headers = new Headers(options.headers); + this.url = options.url || ''; + this._initBody(bodyInit); + } + + Body.call(Response.prototype); + + Response.prototype.clone = function() { + return new Response(this._bodyInit, { + status: this.status, + statusText: this.statusText, + headers: new Headers(this.headers), + url: this.url + }) + }; + + Response.error = function() { + var response = new Response(null, {status: 0, statusText: ''}); + response.type = 'error'; + return response + }; + + var redirectStatuses = [301, 302, 303, 307, 308]; + + Response.redirect = function(url, status) { + if (redirectStatuses.indexOf(status) === -1) { + throw new RangeError('Invalid status code') + } + + return new Response(null, {status: status, headers: {location: url}}) + }; + + exports.DOMException = self.DOMException; + try { + new exports.DOMException(); + } catch (err) { + exports.DOMException = function(message, name) { + this.message = message; + this.name = name; + var error = Error(message); + this.stack = error.stack; + }; + exports.DOMException.prototype = Object.create(Error.prototype); + exports.DOMException.prototype.constructor = exports.DOMException; + } + + function fetch(input, init) { + return new Promise(function(resolve, reject) { + var request = new Request(input, init); + + if (request.signal && request.signal.aborted) { + return reject(new exports.DOMException('Aborted', 'AbortError')) + } + + var xhr = new XMLHttpRequest(); + + function abortXhr() { + xhr.abort(); + } + + xhr.onload = function() { + var options = { + status: xhr.status, + statusText: xhr.statusText, + headers: parseHeaders(xhr.getAllResponseHeaders() || '') + }; + options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); + var body = 'response' in xhr ? xhr.response : xhr.responseText; + resolve(new Response(body, options)); + }; + + xhr.onerror = function() { + reject(new TypeError('Network request failed')); + }; + + xhr.ontimeout = function() { + reject(new TypeError('Network request failed')); + }; + + xhr.onabort = function() { + reject(new exports.DOMException('Aborted', 'AbortError')); + }; + + xhr.open(request.method, request.url, true); + + if (request.credentials === 'include') { + xhr.withCredentials = true; + } else if (request.credentials === 'omit') { + xhr.withCredentials = false; + } + + if ('responseType' in xhr && support.blob) { + xhr.responseType = 'blob'; + } + + request.headers.forEach(function(value, name) { + xhr.setRequestHeader(name, value); + }); + + if (request.signal) { + request.signal.addEventListener('abort', abortXhr); + + xhr.onreadystatechange = function() { + // DONE (success or failure) + if (xhr.readyState === 4) { + request.signal.removeEventListener('abort', abortXhr); + } + }; + } + + xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); + }) + } + + fetch.polyfill = true; + + if (!self.fetch) { + self.fetch = fetch; + self.Headers = Headers; + self.Request = Request; + self.Response = Response; + } + + exports.Headers = Headers; + exports.Request = Request; + exports.Response = Response; + exports.fetch = fetch; + + return exports; + + }({})); + })(__self__); + delete __self__.fetch.polyfill; + exports = __self__.fetch; // To enable: import fetch from 'cross-fetch' + exports.default = __self__.fetch; // For TypeScript consumers without esModuleInterop. + exports.fetch = __self__.fetch; // To enable: import {fetch} from 'cross-fetch' + exports.Headers = __self__.Headers; + exports.Request = __self__.Request; + exports.Response = __self__.Response; + module.exports = exports; + }); + var browserPonyfill_1 = browserPonyfill.fetch; + var browserPonyfill_2 = browserPonyfill.Headers; + var browserPonyfill_3 = browserPonyfill.Request; + var browserPonyfill_4 = browserPonyfill.Response; + + var browser$8 = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + function decode(textData) { + textData = atob(textData); + var data = []; + for (var i = 0; i < textData.length; i++) { + data.push(textData.charCodeAt(i)); + } + return bytes.arrayify(data); + } + exports.decode = decode; + function encode(data) { + data = bytes.arrayify(data); + var textData = ""; + for (var i = 0; i < data.length; i++) { + textData += String.fromCharCode(data[i]); + } + return btoa(textData); + } + exports.encode = encode; + }); + + var browser$9 = unwrapExports(browser$8); + var browser_1$4 = browser$8.decode; + var browser_2$3 = browser$8.encode; + + var _version$E = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "web/5.0.0-beta.129"; + }); + + var _version$F = unwrapExports(_version$E); + var _version_1$k = _version$E.version; + + var web = createCommonjsModule(function (module, exports) { + "use strict"; + var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var cross_fetch_1 = __importDefault(browserPonyfill); + + + + + + var logger$1 = new logger.Logger(_version$E.version); + function fetchJson(connection, json, processFunc) { + var headers = {}; + var url = null; + // @TODO: Allow ConnectionInfo to override some of these values + var options = { + method: "GET", + mode: "cors", + cache: "no-cache", + credentials: "same-origin", + redirect: "follow", + referrer: "client", + }; + var timeout = 2 * 60 * 1000; + if (typeof (connection) === "string") { + url = connection; + } + else if (typeof (connection) === "object") { + if (connection == null || connection.url == null) { + logger$1.throwArgumentError("missing URL", "connection.url", connection); + } + url = connection.url; + if (typeof (connection.timeout) === "number" && connection.timeout > 0) { + timeout = connection.timeout; + } + if (connection.headers) { + for (var key in connection.headers) { + headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) }; + } + } + if (connection.user != null && connection.password != null) { + if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) { + logger$1.throwError("basic authentication requires a secure https url", logger.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" }); + } + var authorization = connection.user + ":" + connection.password; + headers["authorization"] = { + key: "Authorization", + value: "Basic " + browser$8.encode(strings.toUtf8Bytes(authorization)) + }; + } + } + return new Promise(function (resolve, reject) { + var timer = null; + if (timeout) { + timer = setTimeout(function () { + if (timer == null) { + return; + } + timer = null; + reject(logger$1.makeError("timeout", logger.Logger.errors.TIMEOUT, { timeout: timeout })); + }, timeout); + } + var cancelTimeout = function () { + if (timer == null) { + return; + } + clearTimeout(timer); + timer = null; + }; + if (json) { + options.method = "POST"; + options.body = json; + headers["content-type"] = { key: "Content-Type", value: "application/json" }; + } + var flatHeaders = {}; + Object.keys(headers).forEach(function (key) { + var header = headers[key]; + flatHeaders[header.key] = header.value; + }); + options.headers = flatHeaders; + return cross_fetch_1.default(url, options).then(function (response) { + return response.text().then(function (body) { + if (!response.ok) { + logger$1.throwError("bad response", logger.Logger.errors.SERVER_ERROR, { + status: response.status, + body: body, + type: response.type, + url: response.url + }); + } + return body; + }); + }).then(function (text) { + var json = null; + try { + json = JSON.parse(text); + } + catch (error) { + logger$1.throwError("invalid JSON", logger.Logger.errors.SERVER_ERROR, { + body: text, + error: error, + url: url + }); + } + if (processFunc) { + try { + json = processFunc(json); + } + catch (error) { + logger$1.throwError("processing response error", logger.Logger.errors.SERVER_ERROR, { + body: json, + error: error + }); + } + } + return json; + }, function (error) { + throw error; + }).then(function (result) { + cancelTimeout(); + resolve(result); + }, function (error) { + cancelTimeout(); + reject(error); + }); + }); + } + exports.fetchJson = fetchJson; + function poll(func, options) { + if (!options) { + options = {}; + } + options = properties.shallowCopy(options); + if (options.floor == null) { + options.floor = 0; + } + if (options.ceiling == null) { + options.ceiling = 10000; + } + if (options.interval == null) { + options.interval = 250; + } + return new Promise(function (resolve, reject) { + var timer = null; + var done = false; + // Returns true if cancel was successful. Unsuccessful cancel means we're already done. + var cancel = function () { + if (done) { + return false; + } + done = true; + if (timer) { + clearTimeout(timer); + } + return true; + }; + if (options.timeout) { + timer = setTimeout(function () { + if (cancel()) { + reject(new Error("timeout")); + } + }, options.timeout); + } + var retryLimit = options.retryLimit; + var attempt = 0; + function check() { + return func().then(function (result) { + // If we have a result, or are allowed null then we're done + if (result !== undefined) { + if (cancel()) { + resolve(result); + } + } + else if (options.onceBlock) { + options.onceBlock.once("block", check); + // Otherwise, exponential back-off (up to 10s) our next request + } + else if (!done) { + attempt++; + if (attempt > retryLimit) { + if (cancel()) { + reject(new Error("retry limit reached")); + } + return; + } + var timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); + if (timeout < options.floor) { + timeout = options.floor; + } + if (timeout > options.ceiling) { + timeout = options.ceiling; + } + setTimeout(check, timeout); + } + return null; + }, function (error) { + if (cancel()) { + reject(error); + } + }); + } + check(); + }); + } + exports.poll = poll; + }); + + var index$l = unwrapExports(web); + var web_1 = web.fetchJson; + var web_2 = web.poll; + + var _version$G = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "providers/5.0.0-beta.141"; + }); + + var _version$H = unwrapExports(_version$G); + var _version_1$l = _version$G.version; + + var formatter = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + var logger$1 = new logger.Logger(_version$G.version); + var Formatter = /** @class */ (function () { + function Formatter() { + var _newTarget = this.constructor; + logger$1.checkNew(_newTarget, Formatter); + this.formats = this.getDefaultFormats(); + } + Formatter.prototype.getDefaultFormats = function () { + var _this = this; + var formats = ({}); + var address = this.address.bind(this); + var bigNumber = this.bigNumber.bind(this); + var blockTag = this.blockTag.bind(this); + var data = this.data.bind(this); + var hash = this.hash.bind(this); + var hex = this.hex.bind(this); + var number = this.number.bind(this); + var strictData = function (v) { return _this.data(v, true); }; + formats.transaction = { + hash: hash, + blockHash: Formatter.allowNull(hash, null), + blockNumber: Formatter.allowNull(number, null), + transactionIndex: Formatter.allowNull(number, null), + confirmations: Formatter.allowNull(number, null), + from: address, + gasPrice: bigNumber, + gasLimit: bigNumber, + to: Formatter.allowNull(address, null), + value: bigNumber, + nonce: number, + data: data, + r: Formatter.allowNull(this.uint256), + s: Formatter.allowNull(this.uint256), + v: Formatter.allowNull(number), + creates: Formatter.allowNull(address, null), + raw: Formatter.allowNull(data), + }; + formats.transactionRequest = { + from: Formatter.allowNull(address), + nonce: Formatter.allowNull(number), + gasLimit: Formatter.allowNull(bigNumber), + gasPrice: Formatter.allowNull(bigNumber), + to: Formatter.allowNull(address), + value: Formatter.allowNull(bigNumber), + data: Formatter.allowNull(strictData), + }; + formats.receiptLog = { + transactionLogIndex: Formatter.allowNull(number), + transactionIndex: number, + blockNumber: number, + transactionHash: hash, + address: address, + topics: Formatter.arrayOf(hash), + data: data, + logIndex: number, + blockHash: hash, + }; + formats.receipt = { + to: Formatter.allowNull(this.address), + from: Formatter.allowNull(this.address), + contractAddress: Formatter.allowNull(address, null), + transactionIndex: number, + root: Formatter.allowNull(hash), + gasUsed: bigNumber, + logsBloom: Formatter.allowNull(data), + blockHash: hash, + transactionHash: hash, + logs: Formatter.arrayOf(this.receiptLog.bind(this)), + blockNumber: number, + confirmations: Formatter.allowNull(number, null), + cumulativeGasUsed: bigNumber, + status: Formatter.allowNull(number) + }; + formats.block = { + hash: hash, + parentHash: hash, + number: number, + timestamp: number, + nonce: Formatter.allowNull(hex), + difficulty: this.difficulty.bind(this), + gasLimit: bigNumber, + gasUsed: bigNumber, + miner: address, + extraData: data, + transactions: Formatter.allowNull(Formatter.arrayOf(hash)), + }; + formats.blockWithTransactions = properties.shallowCopy(formats.block); + formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); + formats.filter = { + fromBlock: Formatter.allowNull(blockTag, undefined), + toBlock: Formatter.allowNull(blockTag, undefined), + blockHash: Formatter.allowNull(hash, undefined), + address: Formatter.allowNull(address, undefined), + topics: Formatter.allowNull(this.topics.bind(this), undefined), + }; + formats.filterLog = { + blockNumber: Formatter.allowNull(number), + blockHash: Formatter.allowNull(hash), + transactionIndex: number, + removed: Formatter.allowNull(this.boolean.bind(this)), + address: address, + data: Formatter.allowFalsish(data, "0x"), + topics: Formatter.arrayOf(hash), + transactionHash: hash, + logIndex: number, + }; + return formats; + }; + // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number + // Strict! Used on input. + Formatter.prototype.number = function (number) { + return bignumber$2.BigNumber.from(number).toNumber(); + }; + // Strict! Used on input. + Formatter.prototype.bigNumber = function (value) { + return bignumber$2.BigNumber.from(value); + }; + // Requires a boolean, "true" or "false"; returns a boolean + Formatter.prototype.boolean = function (value) { + if (typeof (value) === "boolean") { + return value; + } + if (typeof (value) === "string") { + value = value.toLowerCase(); + if (value === "true") { + return true; + } + if (value === "false") { + return false; + } + } + throw new Error("invaid boolean - " + value); + }; + Formatter.prototype.hex = function (value, strict) { + if (typeof (value) === "string") { + if (!strict && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (bytes.isHexString(value)) { + return value.toLowerCase(); + } + } + return logger$1.throwArgumentError("invalid hash", "value", value); + }; + Formatter.prototype.data = function (value, strict) { + var result = this.hex(value, strict); + if ((result.length % 2) !== 0) { + throw new Error("invalid data; odd-length - " + value); + } + return result; + }; + // Requires an address + // Strict! Used on input. + Formatter.prototype.address = function (value) { + return address.getAddress(value); + }; + Formatter.prototype.callAddress = function (value) { + if (!bytes.isHexString(value, 32)) { + return null; + } + var address$1 = address.getAddress(bytes.hexDataSlice(value, 12)); + return (address$1 === constants.AddressZero) ? null : address$1; + }; + Formatter.prototype.contractAddress = function (value) { + return address.getContractAddress(value); + }; + // Strict! Used on input. + Formatter.prototype.blockTag = function (blockTag) { + if (blockTag == null) { + return "latest"; + } + if (blockTag === "earliest") { + return "0x0"; + } + if (blockTag === "latest" || blockTag === "pending") { + return blockTag; + } + if (typeof (blockTag) === "number" || bytes.isHexString(blockTag)) { + return bytes.hexValue(blockTag); + } + throw new Error("invalid blockTag"); + }; + // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. + Formatter.prototype.hash = function (value, strict) { + var result = this.hex(value, strict); + if (bytes.hexDataLength(result) !== 32) { + return logger$1.throwArgumentError("invalid hash", "value", value); + } + return result; + }; + // Returns the difficulty as a number, or if too large (i.e. PoA network) null + Formatter.prototype.difficulty = function (value) { + var v = bignumber$2.BigNumber.from(value); + try { + return v.toNumber(); + } + catch (error) { } + return null; + }; + Formatter.prototype.uint256 = function (value) { + if (!bytes.isHexString(value)) { + throw new Error("invalid uint256"); + } + return bytes.hexZeroPad(value, 32); + }; + Formatter.prototype._block = function (value, format) { + if (value.author != null && value.miner == null) { + value.miner = value.author; + } + return Formatter.check(format, value); + }; + Formatter.prototype.block = function (value) { + return this._block(value, this.formats.block); + }; + Formatter.prototype.blockWithTransactions = function (value) { + return this._block(value, this.formats.blockWithTransactions); + }; + // Strict! Used on input. + Formatter.prototype.transactionRequest = function (value) { + return Formatter.check(this.formats.transactionRequest, value); + }; + Formatter.prototype.transactionResponse = function (transaction) { + // Rename gas to gasLimit + if (transaction.gas != null && transaction.gasLimit == null) { + transaction.gasLimit = transaction.gas; + } + // Some clients (TestRPC) do strange things like return 0x0 for the + // 0 address; correct this to be a real address + if (transaction.to && bignumber$2.BigNumber.from(transaction.to).isZero()) { + transaction.to = "0x0000000000000000000000000000000000000000"; + } + // Rename input to data + if (transaction.input != null && transaction.data == null) { + transaction.data = transaction.input; + } + // If to and creates are empty, populate the creates from the transaction + if (transaction.to == null && transaction.creates == null) { + transaction.creates = this.contractAddress(transaction); + } + // @TODO: use transaction.serialize? Have to add support for including v, r, and s... + /* + if (!transaction.raw) { + + // Very loose providers (e.g. TestRPC) do not provide a signature or raw + if (transaction.v && transaction.r && transaction.s) { + let raw = [ + stripZeros(hexlify(transaction.nonce)), + stripZeros(hexlify(transaction.gasPrice)), + stripZeros(hexlify(transaction.gasLimit)), + (transaction.to || "0x"), + stripZeros(hexlify(transaction.value || "0x")), + hexlify(transaction.data || "0x"), + stripZeros(hexlify(transaction.v || "0x")), + stripZeros(hexlify(transaction.r)), + stripZeros(hexlify(transaction.s)), + ]; + + transaction.raw = rlpEncode(raw); + } + } + */ + var result = Formatter.check(this.formats.transaction, transaction); + var networkId = transaction.networkId; + // geth-etc returns chainId + if (transaction.chainId != null && networkId == null && result.v == null) { + networkId = transaction.chainId; + } + if (bytes.isHexString(networkId)) { + networkId = bignumber$2.BigNumber.from(networkId).toNumber(); + } + if (typeof (networkId) !== "number" && result.v != null) { + networkId = (result.v - 35) / 2; + if (networkId < 0) { + networkId = 0; + } + networkId = parseInt(networkId); + } + if (typeof (networkId) !== "number") { + networkId = 0; + } + result.networkId = networkId; + // 0x0000... should actually be null + if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { + result.blockHash = null; + } + return result; + }; + Formatter.prototype.transaction = function (value) { + return transactions.parse(value); + }; + Formatter.prototype.receiptLog = function (value) { + return Formatter.check(this.formats.receiptLog, value); + }; + Formatter.prototype.receipt = function (value) { + //let status = transactionReceipt.status; + //let root = transactionReceipt.root; + var result = Formatter.check(this.formats.receipt, value); + result.logs.forEach(function (entry, index) { + if (entry.transactionLogIndex == null) { + entry.transactionLogIndex = index; + } + }); + if (value.status != null) { + result.byzantium = true; + } + return result; + }; + Formatter.prototype.topics = function (value) { + var _this = this; + if (Array.isArray(value)) { + return value.map(function (v) { return _this.topics(v); }); + } + else if (value != null) { + return this.hash(value, true); + } + return null; + }; + Formatter.prototype.filter = function (value) { + return Formatter.check(this.formats.filter, value); + }; + Formatter.prototype.filterLog = function (value) { + return Formatter.check(this.formats.filterLog, value); + }; + Formatter.check = function (format, object) { + var result = {}; + for (var key in format) { + try { + var value = format[key](object[key]); + if (value !== undefined) { + result[key] = value; + } + } + catch (error) { + error.checkKey = key; + error.checkValue = object[key]; + throw error; + } + } + return result; + }; + // if value is null-ish, nullValue is returned + Formatter.allowNull = function (format, nullValue) { + return (function (value) { + if (value == null) { + return nullValue; + } + return format(value); + }); + }; + // If value is false-ish, replaceValue is returned + Formatter.allowFalsish = function (format, replaceValue) { + return (function (value) { + if (!value) { + return replaceValue; + } + return format(value); + }); + }; + // Requires an Array satisfying check + Formatter.arrayOf = function (format) { + return (function (array) { + if (!Array.isArray(array)) { + throw new Error("not an array"); + } + var result = []; + array.forEach(function (value) { + result.push(format(value)); + }); + return result; + }); + }; + return Formatter; + }()); + exports.Formatter = Formatter; + }); + + var formatter$1 = unwrapExports(formatter); + var formatter_1 = formatter.Formatter; + + var baseProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + + + var logger$1 = new logger.Logger(_version$G.version); + + ////////////////////////////// + // Event Serializeing + function checkTopic(topic) { + if (topic == null) { + return "null"; + } + if (bytes.hexDataLength(topic) !== 32) { + logger$1.throwArgumentError("invalid topic", "topic", topic); + } + return topic.toLowerCase(); + } + function serializeTopics(topics) { + // Remove trailing null AND-topics; they are redundant + topics = topics.slice(); + while (topics[topics.length - 1] == null) { + topics.pop(); + } + return topics.map(function (topic) { + if (Array.isArray(topic)) { + // Only track unique OR-topics + var unique_1 = {}; + topic.forEach(function (topic) { + unique_1[checkTopic(topic)] = true; + }); + // The order of OR-topics does not matter + var sorted = Object.keys(unique_1); + sorted.sort(); + return sorted.join("|"); + } + else { + return checkTopic(topic); + } + }).join("&"); + } + function deserializeTopics(data) { + return data.split(/&/g).map(function (topic) { + return topic.split("|").map(function (topic) { + return ((topic === "null") ? null : topic); + }); + }); + } + function getEventTag(eventName) { + if (typeof (eventName) === "string") { + eventName = eventName.toLowerCase(); + if (bytes.hexDataLength(eventName) === 32) { + return "tx:" + eventName; + } + if (eventName.indexOf(":") === -1) { + return eventName; + } + } + else if (Array.isArray(eventName)) { + return "filter:*:" + serializeTopics(eventName); + } + else if (abstractProvider.ForkEvent.isForkEvent(eventName)) { + logger$1.warn("not implemented"); + throw new Error("not implemented"); + } + else if (eventName && typeof (eventName) === "object") { + return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); + } + throw new Error("invalid event - " + eventName); + } + ////////////////////////////// + // Helper Object + function getTime() { + return (new Date()).getTime(); + } + ////////////////////////////// + // Provider Object + /** + * EventType + * - "block" + * - "pending" + * - "error" + * - filter + * - topics array + * - transaction hash + */ + var Event = /** @class */ (function () { + function Event(tag, listener, once) { + properties.defineReadOnly(this, "tag", tag); + properties.defineReadOnly(this, "listener", listener); + properties.defineReadOnly(this, "once", once); + } + Event.prototype.pollable = function () { + return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); + }; + return Event; + }()); + var defaultFormatter = null; + var nextPollId = 1; + var BaseProvider = /** @class */ (function (_super) { + __extends(BaseProvider, _super); + function BaseProvider(network) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, abstractProvider.Provider); + _this = _super.call(this) || this; + _this.formatter = _newTarget.getFormatter(); + if (network instanceof Promise) { + properties.defineReadOnly(_this, "ready", network.then(function (network) { + properties.defineReadOnly(_this, "_network", network); + return network; + })); + // Squash any "unhandled promise" errors; that do not need to be handled + _this.ready.catch(function (error) { }); + } + else { + var knownNetwork = properties.getStatic((_newTarget), "getNetwork")(network); + if (knownNetwork) { + properties.defineReadOnly(_this, "_network", knownNetwork); + properties.defineReadOnly(_this, "ready", Promise.resolve(_this._network)); + } + else { + logger$1.throwArgumentError("invalid network", "network", network); + } + } + _this._lastBlockNumber = -2; + // Events being listened to + _this._events = []; + _this._pollingInterval = 4000; + _this._emitted = { block: -2 }; + _this._fastQueryDate = 0; + return _this; + } + BaseProvider.getFormatter = function () { + if (defaultFormatter == null) { + defaultFormatter = new formatter.Formatter(); + } + return defaultFormatter; + }; + BaseProvider.getNetwork = function (network) { + return networks_1.getNetwork((network == null) ? "homestead" : network); + }; + BaseProvider.prototype.poll = function () { + var _this = this; + var pollId = nextPollId++; + this.emit("willPoll", pollId); + // Track all running promises, so we can trigger a post-poll once they are complete + var runners = []; + this.getBlockNumber().then(function (blockNumber) { + _this._setFastBlockNumber(blockNumber); + // If the block has not changed, meh. + if (blockNumber === _this._lastBlockNumber) { + return; + } + // First polling cycle, trigger a "block" events + if (_this._emitted.block === -2) { + _this._emitted.block = blockNumber - 1; + } + // Notify all listener for each block that has passed + for (var i = _this._emitted.block + 1; i <= blockNumber; i++) { + _this.emit("block", i); + } + // The emitted block was updated, check for obsolete events + if (_this._emitted.block !== blockNumber) { + _this._emitted.block = blockNumber; + Object.keys(_this._emitted).forEach(function (key) { + // The block event does not expire + if (key === "block") { + return; + } + // The block we were at when we emitted this event + var eventBlockNumber = _this._emitted[key]; + // We cannot garbage collect pending transactions or blocks here + // They should be garbage collected by the Provider when setting + // "pending" events + if (eventBlockNumber === "pending") { + return; + } + // Evict any transaction hashes or block hashes over 12 blocks + // old, since they should not return null anyways + if (blockNumber - eventBlockNumber > 12) { + delete _this._emitted[key]; + } + }); + } + // First polling cycle + if (_this._lastBlockNumber === -2) { + _this._lastBlockNumber = blockNumber - 1; + } + // Find all transaction hashes we are waiting on + _this._events.forEach(function (event) { + var comps = event.tag.split(":"); + switch (comps[0]) { + case "tx": { + var hash_2 = comps[1]; + var runner = _this.getTransactionReceipt(hash_2).then(function (receipt) { + if (!receipt || receipt.blockNumber == null) { + return null; + } + _this._emitted["t:" + hash_2] = receipt.blockNumber; + _this.emit(hash_2, receipt); + return null; + }).catch(function (error) { _this.emit("error", error); }); + runners.push(runner); + break; + } + case "filter": { + var topics = deserializeTopics(comps[2]); + var filter_1 = { + address: comps[1], + fromBlock: _this._lastBlockNumber + 1, + toBlock: blockNumber, + topics: topics + }; + if (!filter_1.address) { + delete filter_1.address; + } + var runner = _this.getLogs(filter_1).then(function (logs) { + if (logs.length === 0) { + return; + } + logs.forEach(function (log) { + _this._emitted["b:" + log.blockHash] = log.blockNumber; + _this._emitted["t:" + log.transactionHash] = log.blockNumber; + _this.emit(filter_1, log); + }); + return null; + }).catch(function (error) { _this.emit("error", error); }); + runners.push(runner); + break; + } + } + }); + _this._lastBlockNumber = blockNumber; + return null; + }).catch(function (error) { }); + Promise.all(runners).then(function () { + _this.emit("didPoll", pollId); + }); + }; + BaseProvider.prototype.resetEventsBlock = function (blockNumber) { + this._lastBlockNumber = blockNumber - 1; + if (this.polling) { + this.poll(); + } + }; + Object.defineProperty(BaseProvider.prototype, "network", { + get: function () { + return this._network; + }, + enumerable: true, + configurable: true + }); + BaseProvider.prototype.getNetwork = function () { + return this.ready; + }; + Object.defineProperty(BaseProvider.prototype, "blockNumber", { + get: function () { + return this._fastBlockNumber; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseProvider.prototype, "polling", { + get: function () { + return (this._poller != null); + }, + set: function (value) { + var _this = this; + setTimeout(function () { + if (value && !_this._poller) { + _this._poller = setInterval(_this.poll.bind(_this), _this.pollingInterval); + } + else if (!value && _this._poller) { + clearInterval(_this._poller); + _this._poller = null; + } + }, 0); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseProvider.prototype, "pollingInterval", { + get: function () { + return this._pollingInterval; + }, + set: function (value) { + var _this = this; + if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) { + throw new Error("invalid polling interval"); + } + this._pollingInterval = value; + if (this._poller) { + clearInterval(this._poller); + this._poller = setInterval(function () { _this.poll(); }, this._pollingInterval); + } + }, + enumerable: true, + configurable: true + }); + BaseProvider.prototype._getFastBlockNumber = function () { + var _this = this; + var now = getTime(); + // Stale block number, request a newer value + if ((now - this._fastQueryDate) > 2 * this._pollingInterval) { + this._fastQueryDate = now; + this._fastBlockNumberPromise = this.getBlockNumber().then(function (blockNumber) { + if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) { + _this._fastBlockNumber = blockNumber; + } + return _this._fastBlockNumber; + }); + } + return this._fastBlockNumberPromise; + }; + BaseProvider.prototype._setFastBlockNumber = function (blockNumber) { + // Older block, maybe a stale request + if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { + return; + } + // Update the time we updated the blocknumber + this._fastQueryDate = getTime(); + // Newer block number, use it + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + this._fastBlockNumberPromise = Promise.resolve(blockNumber); + } + }; + // @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event; + // this will be used once we move to the WebSocket or other alternatives to polling + BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations) { + var _this = this; + if (confirmations == null) { + confirmations = 1; + } + if (confirmations === 0) { + return this.getTransactionReceipt(transactionHash); + } + return new Promise(function (resolve) { + var handler = function (receipt) { + if (receipt.confirmations < confirmations) { + return; + } + _this.removeListener(transactionHash, handler); + resolve(receipt); + }; + _this.on(transactionHash, handler); + }); + }; + BaseProvider.prototype._runPerform = function (method, params) { + var _this = this; + return this.ready.then(function () { + // Execute all the functions now that we are "ready" + Object.keys(params).forEach(function (key) { + params[key] = params[key](); + }); + return properties.resolveProperties(params).then(function (params) { + return _this.perform(method, params); + }); + }); + }; + BaseProvider.prototype.getBlockNumber = function () { + var _this = this; + return this._runPerform("getBlockNumber", {}).then(function (result) { + var value = parseInt(result); + if (value != result) { + throw new Error("invalid response - getBlockNumber"); + } + _this._setFastBlockNumber(value); + return value; + }); + }; + BaseProvider.prototype.getGasPrice = function () { + return this._runPerform("getGasPrice", {}).then(function (result) { + return bignumber$2.BigNumber.from(result); + }); + }; + BaseProvider.prototype.getBalance = function (addressOrName, blockTag) { + var _this = this; + return this._runPerform("getBalance", { + address: function () { return _this._getAddress(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bignumber$2.BigNumber.from(result); + }); + }; + BaseProvider.prototype.getTransactionCount = function (addressOrName, blockTag) { + var _this = this; + return this._runPerform("getTransactionCount", { + address: function () { return _this._getAddress(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bignumber$2.BigNumber.from(result).toNumber(); + }); + }; + BaseProvider.prototype.getCode = function (addressOrName, blockTag) { + var _this = this; + return this._runPerform("getCode", { + address: function () { return _this._getAddress(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bytes.hexlify(result); + }); + }; + BaseProvider.prototype.getStorageAt = function (addressOrName, position, blockTag) { + var _this = this; + return this._runPerform("getStorageAt", { + address: function () { return _this._getAddress(addressOrName); }, + blockTag: function () { return _this._getBlockTag(blockTag); }, + position: function () { return Promise.resolve(position).then(function (p) { return bytes.hexValue(p); }); } + }).then(function (result) { + return bytes.hexlify(result); + }); + }; + // This should be called by any subclass wrapping a TransactionResponse + BaseProvider.prototype._wrapTransaction = function (tx, hash) { + var _this = this; + if (hash != null && bytes.hexDataLength(hash) !== 32) { + throw new Error("invalid response - sendTransaction"); + } + var result = tx; + // Check the hash we expect is the same as the hash the server reported + if (hash != null && tx.hash !== hash) { + logger$1.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + } + // @TODO: (confirmations? number, timeout? number) + result.wait = function (confirmations) { + // We know this transaction *must* exist (whether it gets mined is + // another story), so setting an emitted value forces us to + // wait even if the node returns null for the receipt + if (confirmations !== 0) { + _this._emitted["t:" + tx.hash] = "pending"; + } + return _this.waitForTransaction(tx.hash, confirmations).then(function (receipt) { + if (receipt == null && confirmations === 0) { + return null; + } + // No longer pending, allow the polling loop to garbage collect this + _this._emitted["t:" + tx.hash] = receipt.blockNumber; + if (receipt.status === 0) { + logger$1.throwError("transaction failed", logger.Logger.errors.CALL_EXCEPTION, { + transactionHash: tx.hash, + transaction: tx, + receipt: receipt + }); + } + return receipt; + }); + }; + return result; + }; + BaseProvider.prototype.sendTransaction = function (signedTransaction) { + var _this = this; + return this._runPerform("sendTransaction", { + signedTransaction: function () { return Promise.resolve(signedTransaction).then(function (t) { return bytes.hexlify(t); }); } + }).then(function (result) { + return _this._wrapTransaction(_this.formatter.transaction(signedTransaction), result); + }, function (error) { + error.transaction = _this.formatter.transaction(signedTransaction); + if (error.transaction.hash) { + error.transactionHash = error.transaction.hash; + } + throw error; + }); + }; + BaseProvider.prototype._getTransactionRequest = function (transaction) { + var _this = this; + return Promise.resolve(transaction).then(function (t) { + var tx = {}; + ["from", "to"].forEach(function (key) { + if (t[key] == null) { + return; + } + tx[key] = Promise.resolve(t[key]).then(function (a) { return (a ? _this._getAddress(a) : null); }); + }); + ["data", "gasLimit", "gasPrice", "value"].forEach(function (key) { + if (t[key] == null) { + return; + } + tx[key] = t[key]; + }); + return properties.resolveProperties(tx).then(function (t) { return _this.formatter.transactionRequest(t); }); + }); + }; + BaseProvider.prototype._getFilter = function (filter) { + var _this = this; + return Promise.resolve(filter).then(function (f) { + var filter = {}; + if (f.address != null) { + filter.address = _this._getAddress(f.address); + } + if (f.topics) { + filter.topics = f.topics; + } + if (f.blockHash != null) { + filter.blockHash = f.blockHash; + } + ["fromBlock", "toBlock"].forEach(function (key) { + if (f[key] == null) { + return; + } + filter[key] = _this._getBlockTag(f[key]); + }); + return properties.resolveProperties(filter).then(function (f) { return _this.formatter.filter(f); }); + }); + }; + BaseProvider.prototype.call = function (transaction, blockTag) { + var _this = this; + return this._runPerform("call", { + transaction: function () { return _this._getTransactionRequest(transaction); }, + blockTag: function () { return _this._getBlockTag(blockTag); } + }).then(function (result) { + return bytes.hexlify(result); + }); + }; + BaseProvider.prototype.estimateGas = function (transaction) { + var _this = this; + return this._runPerform("estimateGas", { + transaction: function () { return _this._getTransactionRequest(transaction); } + }).then(function (result) { + return bignumber$2.BigNumber.from(result); + }); + }; + BaseProvider.prototype._getAddress = function (addressOrName) { + return this.resolveName(addressOrName).then(function (address) { + if (address == null) { + logger$1.throwError("ENS name not configured", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "resolveName(" + JSON.stringify(addressOrName) + ")" + }); + } + return address; + }); + }; + BaseProvider.prototype._getBlock = function (blockHashOrBlockTag, includeTransactions) { + var _this = this; + return this.ready.then(function () { + return _this._getBlockTag(blockHashOrBlockTag).then(function (blockHashOrBlockTag) { + var params = { + includeTransactions: !!includeTransactions + }; + // Exactly one of blockHash or blockTag will be set + var blockHash = null; + var blockTag = null; + // If blockTag is a number (not "latest", etc), this is the block number + var blockNumber = -128; + if (bytes.isHexString(blockHashOrBlockTag, 32)) { + params.blockHash = blockHashOrBlockTag; + } + else { + try { + params.blockTag = _this.formatter.blockTag(blockHashOrBlockTag); + if (bytes.isHexString(params.blockTag)) { + blockNumber = parseInt(params.blockTag.substring(2), 16); + } + } + catch (error) { + logger$1.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + } + } + return web.poll(function () { + return _this.perform("getBlock", params).then(function (block) { + // Block was not found + if (block == null) { + // For blockhashes, if we didn't say it existed, that blockhash may + // not exist. If we did see it though, perhaps from a log, we know + // it exists, and this node is just not caught up yet. + if (blockHash) { + if (_this._emitted["b:" + blockHash] == null) { + return null; + } + } + // For block tags, if we are asking for a future block, we return null + if (blockTag) { + if (blockNumber > _this._emitted.block) { + return null; + } + } + // Retry on the next block + return undefined; + } + // Add transactions + if (includeTransactions) { + return _this.formatter.blockWithTransactions(block); + } + return _this.formatter.block(block); + }); + }, { onceBlock: _this }); + }); + }); + }; + BaseProvider.prototype.getBlock = function (blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, false)); + }; + BaseProvider.prototype.getBlockWithTransactions = function (blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, true)); + }; + BaseProvider.prototype.getTransaction = function (transactionHash) { + var _this = this; + return this.ready.then(function () { + return properties.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { + var transactionHash = _a.transactionHash; + var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; + return web.poll(function () { + return _this.perform("getTransaction", params).then(function (result) { + if (result == null) { + if (_this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + var tx = _this.formatter.transactionResponse(result); + if (tx.blockNumber == null) { + tx.confirmations = 0; + } + else if (tx.confirmations == null) { + return _this._getFastBlockNumber().then(function (blockNumber) { + // Add the confirmations using the fast block number (pessimistic) + var confirmations = (blockNumber - tx.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + tx.confirmations = confirmations; + return _this._wrapTransaction(tx); + }); + } + return _this._wrapTransaction(tx); + }); + }, { onceBlock: _this }); + }); + }); + }; + BaseProvider.prototype.getTransactionReceipt = function (transactionHash) { + var _this = this; + return this.ready.then(function () { + return properties.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { + var transactionHash = _a.transactionHash; + var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; + return web.poll(function () { + return _this.perform("getTransactionReceipt", params).then(function (result) { + if (result == null) { + if (_this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + // "geth-etc" returns receipts before they are ready + if (result.blockHash == null) { + return undefined; + } + var receipt = _this.formatter.receipt(result); + if (receipt.blockNumber == null) { + receipt.confirmations = 0; + } + else if (receipt.confirmations == null) { + return _this._getFastBlockNumber().then(function (blockNumber) { + // Add the confirmations using the fast block number (pessimistic) + var confirmations = (blockNumber - receipt.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + receipt.confirmations = confirmations; + return receipt; + }); + } + return receipt; + }); + }, { onceBlock: _this }); + }); + }); + }; + BaseProvider.prototype.getLogs = function (filter) { + var _this = this; + return this._runPerform("getLogs", { + filter: function () { return _this._getFilter(filter); } + }).then(function (result) { + return formatter.Formatter.arrayOf(_this.formatter.filterLog.bind(_this.formatter))(result); + }); + }; + BaseProvider.prototype.getEtherPrice = function () { + return this._runPerform("getEtherPrice", {}).then(function (result) { + return result; + }); + }; + BaseProvider.prototype._getBlockTag = function (blockTag) { + var _this = this; + if (blockTag instanceof Promise) { + return blockTag.then(function (b) { return _this._getBlockTag(b); }); + } + if (typeof (blockTag) === "number" && blockTag < 0) { + if (blockTag % 1) { + logger$1.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + } + return this._getFastBlockNumber().then(function (bn) { + bn += blockTag; + if (bn < 0) { + bn = 0; + } + return _this.formatter.blockTag(bn); + }); + } + return Promise.resolve(this.formatter.blockTag(blockTag)); + }; + BaseProvider.prototype._getResolver = function (name) { + var _this = this; + // Get the resolver from the blockchain + return this.getNetwork().then(function (network) { + // No ENS... + if (!network.ensAddress) { + logger$1.throwError("network does support ENS", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); + } + // keccak256("resolver(bytes32)") + var data = "0x0178b8bf" + hash.namehash(name).substring(2); + var transaction = { to: network.ensAddress, data: data }; + return _this.call(transaction).then(function (data) { + return _this.formatter.callAddress(data); + }); + }); + }; + BaseProvider.prototype.resolveName = function (name) { + var _this = this; + // If it is a promise, resolve it then recurse + if (name instanceof Promise) { + return name.then(function (addressOrName) { return _this.resolveName(addressOrName); }); + } + // If it is already an address, nothing to resolve + try { + return Promise.resolve(this.formatter.address(name)); + } + catch (error) { } + // Get the addr from the resovler + return this._getResolver(name).then(function (resolverAddress) { + if (!resolverAddress) { + return null; + } + // keccak256("addr(bytes32)") + var data = "0x3b3b57de" + hash.namehash(name).substring(2); + var transaction = { to: resolverAddress, data: data }; + return _this.call(transaction).then(function (data) { + return _this.formatter.callAddress(data); + }); + }); + }; + BaseProvider.prototype.lookupAddress = function (address) { + var _this = this; + if (address instanceof Promise) { + return address.then(function (address) { return _this.lookupAddress(address); }); + } + address = this.formatter.address(address); + var name = address.substring(2) + ".addr.reverse"; + return this._getResolver(name).then(function (resolverAddress) { + if (!resolverAddress) { + return null; + } + // keccak("name(bytes32)") + var data = "0x691f3431" + hash.namehash(name).substring(2); + return _this.call({ to: resolverAddress, data: data }).then(function (data) { + var bytes$1 = bytes.arrayify(data); + // Strip off the dynamic string pointer (0x20) + if (bytes$1.length < 32 || !bignumber$2.BigNumber.from(bytes$1.slice(0, 32)).eq(32)) { + return null; + } + bytes$1 = bytes$1.slice(32); + if (bytes$1.length < 32) { + return null; + } + var length = bignumber$2.BigNumber.from(bytes$1.slice(0, 32)).toNumber(); + bytes$1 = bytes$1.slice(32); + if (length > bytes$1.length) { + return null; + } + var name = strings.toUtf8String(bytes$1.slice(0, length)); + // Make sure the reverse record matches the foward record + return _this.resolveName(name).then(function (addr) { + if (addr != address) { + return null; + } + return name; + }); + }); + }); + }; + BaseProvider.prototype.perform = function (method, params) { + return logger$1.throwError(method + " not implemented", logger.Logger.errors.NOT_IMPLEMENTED, { operation: method }); + }; + BaseProvider.prototype._startPending = function () { + console.log("WARNING: this provider does not support pending events"); + }; + BaseProvider.prototype._stopPending = function () { + }; + // Returns true if there are events that still require polling + BaseProvider.prototype._checkPolling = function () { + this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0); + }; + BaseProvider.prototype._addEventListener = function (eventName, listener, once) { + this._events.push(new Event(getEventTag(eventName), listener, once)); + if (eventName === "pending") { + this._startPending(); + } + // Do we still now have any events that require polling? + this._checkPolling(); + return this; + }; + BaseProvider.prototype.on = function (eventName, listener) { + return this._addEventListener(eventName, listener, false); + }; + BaseProvider.prototype.once = function (eventName, listener) { + return this._addEventListener(eventName, listener, true); + }; + BaseProvider.prototype.emit = function (eventName) { + var _this = this; + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + var result = false; + var eventTag = getEventTag(eventName); + this._events = this._events.filter(function (event) { + if (event.tag !== eventTag) { + return true; + } + setTimeout(function () { + event.listener.apply(_this, args); + }, 0); + result = true; + return !(event.once); + }); + // Do we still have any events that require polling? ("once" events remove themselves) + this._checkPolling(); + return result; + }; + BaseProvider.prototype.listenerCount = function (eventName) { + if (!eventName) { + return this._events.length; + } + var eventTag = getEventTag(eventName); + return this._events.filter(function (event) { + return (event.tag === eventTag); + }).length; + }; + BaseProvider.prototype.listeners = function (eventName) { + if (eventName == null) { + return this._events.map(function (event) { return event.listener; }); + } + var eventTag = getEventTag(eventName); + return this._events + .filter(function (event) { return (event.tag === eventTag); }) + .map(function (event) { return event.listener; }); + }; + BaseProvider.prototype.off = function (eventName, listener) { + if (listener == null) { + return this.removeAllListeners(eventName); + } + var found = false; + var eventTag = getEventTag(eventName); + this._events = this._events.filter(function (event) { + if (event.tag !== eventTag || event.listener != listener) { + return true; + } + if (found) { + return true; + } + found = true; + return false; + }); + if (eventName === "pending" && this.listenerCount("pending") === 0) { + this._stopPending(); + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + }; + BaseProvider.prototype.removeAllListeners = function (eventName) { + if (eventName == null) { + this._events = []; + this._stopPending(); + } + else { + var eventTag_1 = getEventTag(eventName); + this._events = this._events.filter(function (event) { + return (event.tag !== eventTag_1); + }); + if (eventName === "pending") { + this._stopPending(); + } + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + }; + return BaseProvider; + }(abstractProvider.Provider)); + exports.BaseProvider = BaseProvider; + }); + + var baseProvider$1 = unwrapExports(baseProvider); + var baseProvider_1 = baseProvider.BaseProvider; + + var jsonRpcProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + + + + + var logger$1 = new logger.Logger(_version$G.version); + + function timer(timeout) { + return new Promise(function (resolve) { + setTimeout(function () { + resolve(); + }, timeout); + }); + } + function getResult(payload) { + if (payload.error) { + // @TODO: not any + var error = new Error(payload.error.message); + error.code = payload.error.code; + error.data = payload.error.data; + throw error; + } + return payload.result; + } + function getLowerCase(value) { + if (value) { + return value.toLowerCase(); + } + return value; + } + var _constructorGuard = {}; + var JsonRpcSigner = /** @class */ (function (_super) { + __extends(JsonRpcSigner, _super); + function JsonRpcSigner(constructorGuard, provider, addressOrIndex) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, JsonRpcSigner); + _this = _super.call(this) || this; + if (constructorGuard !== _constructorGuard) { + throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); + } + properties.defineReadOnly(_this, "provider", provider); + if (addressOrIndex == null) { + addressOrIndex = 0; + } + if (typeof (addressOrIndex) === "string") { + properties.defineReadOnly(_this, "_address", _this.provider.formatter.address(addressOrIndex)); + properties.defineReadOnly(_this, "_index", null); + } + else if (typeof (addressOrIndex) === "number") { + properties.defineReadOnly(_this, "_index", addressOrIndex); + properties.defineReadOnly(_this, "_address", null); + } + else { + logger$1.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); + } + return _this; + } + JsonRpcSigner.prototype.connect = function (provider) { + return logger$1.throwError("cannot alter JSON-RPC Signer connection", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "connect" + }); + }; + JsonRpcSigner.prototype.connectUnchecked = function () { + return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); + }; + JsonRpcSigner.prototype.getAddress = function () { + var _this = this; + if (this._address) { + return Promise.resolve(this._address); + } + return this.provider.send("eth_accounts", []).then(function (accounts) { + if (accounts.length <= _this._index) { + logger$1.throwError("unknown account #" + _this._index, logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getAddress" + }); + } + return _this.provider.formatter.address(accounts[_this._index]); + }); + }; + JsonRpcSigner.prototype.sendUncheckedTransaction = function (transaction) { + var _this = this; + transaction = properties.shallowCopy(transaction); + var fromAddress = this.getAddress().then(function (address) { + if (address) { + address = address.toLowerCase(); + } + return address; + }); + // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user + // wishes to use this, it is easy to specify explicitly, otherwise + // we look it up for them. + if (transaction.gasLimit == null) { + var estimate = properties.shallowCopy(transaction); + estimate.from = fromAddress; + transaction.gasLimit = this.provider.estimateGas(estimate); + } + return Promise.all([ + properties.resolveProperties(transaction), + fromAddress + ]).then(function (results) { + var tx = results[0]; + var hexTx = _this.provider.constructor.hexlifyTransaction(tx); + hexTx.from = results[1]; + return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) { + return hash; + }, function (error) { + if (error.responseText) { + // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) + if (error.responseText.indexOf("insufficient funds") >= 0) { + logger$1.throwError("insufficient funds", logger.Logger.errors.INSUFFICIENT_FUNDS, { + transaction: tx + }); + } + if (error.responseText.indexOf("nonce too low") >= 0) { + logger$1.throwError("nonce has already been used", logger.Logger.errors.NONCE_EXPIRED, { + transaction: tx + }); + } + if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { + logger$1.throwError("replacement fee too low", logger.Logger.errors.REPLACEMENT_UNDERPRICED, { + transaction: tx + }); + } + } + throw error; + }); + }); + }; + JsonRpcSigner.prototype.signTransaction = function (transaction) { + return logger$1.throwError("signing transactions is unsupported", logger.Logger.errors.UNSUPPORTED_OPERATION, { + operation: "signTransaction" + }); + }; + JsonRpcSigner.prototype.sendTransaction = function (transaction) { + var _this = this; + return this.sendUncheckedTransaction(transaction).then(function (hash) { + return web.poll(function () { + return _this.provider.getTransaction(hash).then(function (tx) { + if (tx === null) { + return undefined; + } + return _this.provider._wrapTransaction(tx, hash); + }); + }, { onceBlock: _this.provider }).catch(function (error) { + error.transactionHash = hash; + throw error; + }); + }); + }; + JsonRpcSigner.prototype.signMessage = function (message) { + var _this = this; + var data = ((typeof (message) === "string") ? strings.toUtf8Bytes(message) : message); + return this.getAddress().then(function (address) { + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + return _this.provider.send("eth_sign", [address.toLowerCase(), bytes.hexlify(data)]); + }); + }; + JsonRpcSigner.prototype.unlock = function (password) { + var provider = this.provider; + return this.getAddress().then(function (address) { + return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]); + }); + }; + return JsonRpcSigner; + }(abstractSigner.Signer)); + exports.JsonRpcSigner = JsonRpcSigner; + var UncheckedJsonRpcSigner = /** @class */ (function (_super) { + __extends(UncheckedJsonRpcSigner, _super); + function UncheckedJsonRpcSigner() { + return _super !== null && _super.apply(this, arguments) || this; + } + UncheckedJsonRpcSigner.prototype.sendTransaction = function (transaction) { + var _this = this; + return this.sendUncheckedTransaction(transaction).then(function (hash) { + return { + hash: hash, + nonce: null, + gasLimit: null, + gasPrice: null, + data: null, + value: null, + chainId: null, + confirmations: 0, + from: null, + wait: function (confirmations) { return _this.provider.waitForTransaction(hash, confirmations); } + }; + }); + }; + return UncheckedJsonRpcSigner; + }(JsonRpcSigner)); + var allowedTransactionKeys = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true + }; + var JsonRpcProvider = /** @class */ (function (_super) { + __extends(JsonRpcProvider, _super); + function JsonRpcProvider(url, network) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, JsonRpcProvider); + // One parameter, but it is a network name, so swap it with the URL + if (typeof (url) === "string") { + if (network === null && networks_1.getNetwork(url)) { + network = url; + url = null; + } + } + if (network) { + // The network has been specified explicitly, we can use it + _this = _super.call(this, network) || this; + } + else { + // The network is unknown, query the JSON-RPC for it + var ready = new Promise(function (resolve, reject) { + setTimeout(function () { + _this.send("eth_chainId", []).then(function (result) { + resolve(networks_1.getNetwork(bignumber$2.BigNumber.from(result).toNumber())); + }).catch(function (error) { + _this.send("net_version", []).then(function (result) { + resolve(networks_1.getNetwork(bignumber$2.BigNumber.from(result).toNumber())); + }).catch(function (error) { + reject(logger$1.makeError("could not detect network", logger.Logger.errors.NETWORK_ERROR)); + }); + }); + }); + }); + _this = _super.call(this, ready) || this; + } + // Default URL + if (!url) { + url = "http:/" + "/localhost:8545"; + } + if (typeof (url) === "string") { + _this.connection = { + url: url + }; + } + else { + _this.connection = url; + } + _this._nextId = 42; + return _this; + } + JsonRpcProvider.prototype.getSigner = function (addressOrIndex) { + return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); + }; + JsonRpcProvider.prototype.getUncheckedSigner = function (addressOrIndex) { + return this.getSigner(addressOrIndex).connectUnchecked(); + }; + JsonRpcProvider.prototype.listAccounts = function () { + var _this = this; + return this.send("eth_accounts", []).then(function (accounts) { + return accounts.map(function (a) { return _this.formatter.address(a); }); + }); + }; + JsonRpcProvider.prototype.send = function (method, params) { + var _this = this; + var request = { + method: method, + params: params, + id: (this._nextId++), + jsonrpc: "2.0" + }; + this.emit("debug", { + action: "request", + request: properties.deepCopy(request), + provider: this + }); + return web.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) { + _this.emit("debug", { + action: "response", + request: request, + response: result, + provider: _this + }); + return result; + }); + }; + JsonRpcProvider.prototype.perform = function (method, params) { + switch (method) { + case "getBlockNumber": + return this.send("eth_blockNumber", []); + case "getGasPrice": + return this.send("eth_gasPrice", []); + case "getBalance": + return this.send("eth_getBalance", [getLowerCase(params.address), params.blockTag]); + case "getTransactionCount": + return this.send("eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]); + case "getCode": + return this.send("eth_getCode", [getLowerCase(params.address), params.blockTag]); + case "getStorageAt": + return this.send("eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]); + case "sendTransaction": + return this.send("eth_sendRawTransaction", [params.signedTransaction]).catch(function (error) { + if (error.responseText) { + // "insufficient funds for gas * price + value" + if (error.responseText.indexOf("insufficient funds") > 0) { + logger$1.throwError("insufficient funds", logger.Logger.errors.INSUFFICIENT_FUNDS, {}); + } + // "nonce too low" + if (error.responseText.indexOf("nonce too low") > 0) { + logger$1.throwError("nonce has already been used", logger.Logger.errors.NONCE_EXPIRED, {}); + } + // "replacement transaction underpriced" + if (error.responseText.indexOf("replacement transaction underpriced") > 0) { + logger$1.throwError("replacement fee too low", logger.Logger.errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + return this.send("eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]); + } + else if (params.blockHash) { + return this.send("eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]); + } + return logger$1.throwArgumentError("invalid block tag or block hash", "params", params); + case "getTransaction": + return this.send("eth_getTransactionByHash", [params.transactionHash]); + case "getTransactionReceipt": + return this.send("eth_getTransactionReceipt", [params.transactionHash]); + case "call": + return this.send("eth_call", [this.constructor.hexlifyTransaction(params.transaction, { from: true }), params.blockTag]); + case "estimateGas": + return this.send("eth_estimateGas", [this.constructor.hexlifyTransaction(params.transaction, { from: true })]); + case "getLogs": + if (params.filter && params.filter.address != null) { + params.filter.address = getLowerCase(params.filter.address); + } + return this.send("eth_getLogs", [params.filter]); + default: + break; + } + return logger$1.throwError(method + " not implemented", logger.Logger.errors.NOT_IMPLEMENTED, { operation: method }); + }; + JsonRpcProvider.prototype._startPending = function () { + if (this._pendingFilter != null) { + return; + } + var self = this; + var pendingFilter = this.send("eth_newPendingTransactionFilter", []); + this._pendingFilter = pendingFilter; + pendingFilter.then(function (filterId) { + function poll() { + self.send("eth_getFilterChanges", [filterId]).then(function (hashes) { + if (self._pendingFilter != pendingFilter) { + return null; + } + var seq = Promise.resolve(); + hashes.forEach(function (hash) { + // @TODO: This should be garbage collected at some point... How? When? + self._emitted["t:" + hash.toLowerCase()] = "pending"; + seq = seq.then(function () { + return self.getTransaction(hash).then(function (tx) { + self.emit("pending", tx); + return null; + }); + }); + }); + return seq.then(function () { + return timer(1000); + }); + }).then(function () { + if (self._pendingFilter != pendingFilter) { + self.send("eth_uninstallFilter", [filterId]); + return; + } + setTimeout(function () { poll(); }, 0); + return null; + }).catch(function (error) { }); + } + poll(); + return filterId; + }).catch(function (error) { }); + }; + JsonRpcProvider.prototype._stopPending = function () { + this._pendingFilter = null; + }; + // Convert an ethers.js transaction into a JSON-RPC transaction + // - gasLimit => gas + // - All values hexlified + // - All numeric values zero-striped + // NOTE: This allows a TransactionRequest, but all values should be resolved + // before this is called + JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) { + // Check only allowed properties are given + var allowed = properties.shallowCopy(allowedTransactionKeys); + if (allowExtra) { + for (var key in allowExtra) { + if (allowExtra[key]) { + allowed[key] = true; + } + } + } + properties.checkProperties(transaction, allowed); + var result = {}; + // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. + ["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + var value = bytes.hexValue(transaction[key]); + if (key === "gasLimit") { + key = "gas"; + } + result[key] = value; + }); + ["from", "to", "data"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + result[key] = bytes.hexlify(transaction[key]); + }); + return result; + }; + return JsonRpcProvider; + }(baseProvider.BaseProvider)); + exports.JsonRpcProvider = JsonRpcProvider; + }); + + var jsonRpcProvider$1 = unwrapExports(jsonRpcProvider); + var jsonRpcProvider_1 = jsonRpcProvider.JsonRpcSigner; + var jsonRpcProvider_2 = jsonRpcProvider.JsonRpcProvider; + + var urlJsonRpcProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + var logger$1 = new logger.Logger(_version$G.version); + + var UrlJsonRpcProvider = /** @class */ (function (_super) { + __extends(UrlJsonRpcProvider, _super); + function UrlJsonRpcProvider(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkAbstract(_newTarget, UrlJsonRpcProvider); + // Normalize the Network and API Key + network = properties.getStatic((_newTarget), "getNetwork")(network); + apiKey = properties.getStatic((_newTarget), "getApiKey")(apiKey); + var url = properties.getStatic((_newTarget), "getUrl")(network, apiKey); + _this = _super.call(this, url, network) || this; + properties.defineReadOnly(_this, "apiKey", apiKey); + return _this; + } + UrlJsonRpcProvider.prototype._startPending = function () { + logger$1.warn("WARNING: API provider does not support pending filters"); + }; + UrlJsonRpcProvider.prototype.getSigner = function (address) { + logger$1.throwError("API provider does not support signing", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); + return null; + }; + UrlJsonRpcProvider.prototype.listAccounts = function () { + return Promise.resolve([]); + }; + UrlJsonRpcProvider.getNetwork = function (network) { + return networks_1.getNetwork((network == null) ? "homestead" : network); + }; + // Return a defaultApiKey if null, otherwise validate the API key + UrlJsonRpcProvider.getApiKey = function (apiKey) { + return apiKey; + }; + // Returns the url for the given network and API key + UrlJsonRpcProvider.getUrl = function (network, apiKey) { + return logger$1.throwError("not implemented; sub-classes must override getUrl", logger.Logger.errors.NOT_IMPLEMENTED, { + operation: "getUrl" + }); + }; + return UrlJsonRpcProvider; + }(jsonRpcProvider.JsonRpcProvider)); + exports.UrlJsonRpcProvider = UrlJsonRpcProvider; + }); + + var urlJsonRpcProvider$1 = unwrapExports(urlJsonRpcProvider); + var urlJsonRpcProvider_1 = urlJsonRpcProvider.UrlJsonRpcProvider; + + var alchemyProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + var logger$1 = new logger.Logger(_version$G.version); + + // This key was provided to ethers.js by Alchemy to be used by the + // default provider, but it is recommended that for your own + // production environments, that you acquire your own API key at: + // https://dashboard.alchemyapi.io + var defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"; + var AlchemyProvider = /** @class */ (function (_super) { + __extends(AlchemyProvider, _super); + function AlchemyProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + AlchemyProvider.getApiKey = function (apiKey) { + if (apiKey == null) { + return defaultApiKey; + } + return apiKey; + }; + AlchemyProvider.getUrl = function (network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "eth-mainnet.alchemyapi.io/jsonrpc/"; + break; + case "ropsten": + host = "eth-ropsten.alchemyapi.io/jsonrpc/"; + break; + case "rinkeby": + host = "eth-rinkeby.alchemyapi.io/jsonrpc/"; + break; + case "kovan": + host = "eth-kovan.alchemyapi.io/jsonrpc/"; + break; + default: + logger$1.throwArgumentError("unsupported network", "network", arguments[0]); + } + return ("https:/" + "/" + host + apiKey); + }; + return AlchemyProvider; + }(urlJsonRpcProvider.UrlJsonRpcProvider)); + exports.AlchemyProvider = AlchemyProvider; + }); + + var alchemyProvider$1 = unwrapExports(alchemyProvider); + var alchemyProvider_1 = alchemyProvider.AlchemyProvider; + + var cloudflareProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$G.version); + var CloudflareProvider = /** @class */ (function (_super) { + __extends(CloudflareProvider, _super); + function CloudflareProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + CloudflareProvider.getUrl = function (network, apiKey) { + if (apiKey != null) { + logger$1.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); + } + var host = null; + switch (network.name) { + case "homestead": + host = "https://cloudflare-eth.com/"; + break; + default: + logger$1.throwArgumentError("unsupported network", "network", arguments[0]); + } + return host; + }; + return CloudflareProvider; + }(urlJsonRpcProvider.UrlJsonRpcProvider)); + exports.CloudflareProvider = CloudflareProvider; + }); + + var cloudflareProvider$1 = unwrapExports(cloudflareProvider); + var cloudflareProvider_1 = cloudflareProvider.CloudflareProvider; + + var etherscanProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + var logger$1 = new logger.Logger(_version$G.version); + + // The transaction has already been sanitized by the calls in Provider + function getTransactionString(transaction) { + var result = []; + for (var key in transaction) { + if (transaction[key] == null) { + continue; + } + var value = bytes.hexlify(transaction[key]); + if ({ gasLimit: true, gasPrice: true, nonce: true, value: true }[key]) { + value = bytes.hexValue(value); + } + result.push(key + "=" + value); + } + return result.join("&"); + } + function getResult(result) { + // getLogs, getHistory have weird success responses + if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) { + return result.result; + } + if (result.status != 1 || result.message != "OK") { + // @TODO: not any + var error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + return result.result; + } + function getJsonResult(result) { + if (result.jsonrpc != "2.0") { + // @TODO: not any + var error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + if (result.error) { + // @TODO: not any + var error = new Error(result.error.message || "unknown error"); + if (result.error.code) { + error.code = result.error.code; + } + if (result.error.data) { + error.data = result.error.data; + } + throw error; + } + return result.result; + } + // The blockTag was normalized as a string by the Provider pre-perform operations + function checkLogTag(blockTag) { + if (blockTag === "pending") { + throw new Error("pending not supported"); + } + if (blockTag === "latest") { + return blockTag; + } + return parseInt(blockTag.substring(2), 16); + } + var EtherscanProvider = /** @class */ (function (_super) { + __extends(EtherscanProvider, _super); + function EtherscanProvider(network, apiKey) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, EtherscanProvider); + _this = _super.call(this, network) || this; + var name = "invalid"; + if (_this.network) { + name = _this.network.name; + } + var baseUrl = null; + switch (name) { + case "homestead": + baseUrl = "https://api.etherscan.io"; + break; + case "ropsten": + baseUrl = "https://api-ropsten.etherscan.io"; + break; + case "rinkeby": + baseUrl = "https://api-rinkeby.etherscan.io"; + break; + case "kovan": + baseUrl = "https://api-kovan.etherscan.io"; + break; + case "goerli": + baseUrl = "https://api-goerli.etherscan.io"; + break; + default: + throw new Error("unsupported network"); + } + properties.defineReadOnly(_this, "baseUrl", baseUrl); + properties.defineReadOnly(_this, "apiKey", apiKey); + return _this; + } + EtherscanProvider.prototype.perform = function (method, params) { + var _this = this; + var url = this.baseUrl; + var apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + var get = function (url, procFunc) { + _this.emit("debug", { + action: "request", + request: url, + provider: _this + }); + return web.fetchJson(url, null, procFunc || getJsonResult).then(function (result) { + _this.emit("debug", { + action: "response", + request: url, + response: properties.deepCopy(result), + provider: _this + }); + return result; + }); + }; + switch (method) { + case "getBlockNumber": + url += "/api?module=proxy&action=eth_blockNumber" + apiKey; + return get(url); + case "getGasPrice": + url += "/api?module=proxy&action=eth_gasPrice" + apiKey; + return get(url); + case "getBalance": + // Returns base-10 result + url += "/api?module=account&action=balance&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getResult); + case "getTransactionCount": + url += "/api?module=proxy&action=eth_getTransactionCount&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url); + case "getCode": + url += "/api?module=proxy&action=eth_getCode&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "getStorageAt": + url += "/api?module=proxy&action=eth_getStorageAt&address=" + params.address; + url += "&position=" + params.position; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "sendTransaction": + url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; + url += apiKey; + return get(url).catch(function (error) { + if (error.responseText) { + // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" + if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { + logger$1.throwError("insufficient funds", logger.Logger.errors.INSUFFICIENT_FUNDS, {}); + } + // "Transaction with the same hash was already imported." + if (error.responseText.indexOf("same hash was already imported") >= 0) { + logger$1.throwError("nonce has already been used", logger.Logger.errors.NONCE_EXPIRED, {}); + } + // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." + if (error.responseText.indexOf("another transaction with same nonce") >= 0) { + logger$1.throwError("replacement fee too low", logger.Logger.errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + url += "/api?module=proxy&action=eth_getBlockByNumber&tag=" + params.blockTag; + if (params.includeTransactions) { + url += "&boolean=true"; + } + else { + url += "&boolean=false"; + } + url += apiKey; + return get(url); + } + throw new Error("getBlock by blockHash not implmeneted"); + case "getTransaction": + url += "/api?module=proxy&action=eth_getTransactionByHash&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "getTransactionReceipt": + url += "/api?module=proxy&action=eth_getTransactionReceipt&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "call": { + var transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_call" + transaction; + //url += "&tag=" + params.blockTag + apiKey; + if (params.blockTag !== "latest") { + throw new Error("EtherscanProvider does not support blockTag for call"); + } + url += apiKey; + return get(url); + } + case "estimateGas": { + var transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_estimateGas&" + transaction; + url += apiKey; + return get(url); + } + case "getLogs": + url += "/api?module=logs&action=getLogs"; + try { + if (params.filter.fromBlock) { + url += "&fromBlock=" + checkLogTag(params.filter.fromBlock); + } + if (params.filter.toBlock) { + url += "&toBlock=" + checkLogTag(params.filter.toBlock); + } + if (params.filter.address) { + url += "&address=" + params.filter.address; + } + // @TODO: We can handle slightly more complicated logs using the logs API + if (params.filter.topics && params.filter.topics.length > 0) { + if (params.filter.topics.length > 1) { + throw new Error("unsupported topic format"); + } + var topic0 = params.filter.topics[0]; + if (typeof (topic0) !== "string" || topic0.length !== 66) { + throw new Error("unsupported topic0 format"); + } + url += "&topic0=" + topic0; + } + } + catch (error) { + return Promise.reject(error); + } + url += apiKey; + var self_1 = this; + return get(url, getResult).then(function (logs) { + var txs = {}; + var seq = Promise.resolve(); + logs.forEach(function (log) { + seq = seq.then(function () { + if (log.blockHash != null) { + return null; + } + log.blockHash = txs[log.transactionHash]; + if (log.blockHash == null) { + return self_1.getTransaction(log.transactionHash).then(function (tx) { + txs[log.transactionHash] = tx.blockHash; + log.blockHash = tx.blockHash; + return null; + }); + } + return null; + }); + }); + return seq.then(function () { + return logs; + }); + }); + case "getEtherPrice": + if (this.network.name !== "homestead") { + return Promise.resolve(0.0); + } + url += "/api?module=stats&action=ethprice"; + url += apiKey; + return get(url, getResult).then(function (result) { + return parseFloat(result.ethusd); + }); + default: + break; + } + return _super.prototype.perform.call(this, method, params); + }; + // @TODO: Allow startBlock and endBlock to be Promises + EtherscanProvider.prototype.getHistory = function (addressOrName, startBlock, endBlock) { + var _this = this; + var url = this.baseUrl; + var apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + if (startBlock == null) { + startBlock = 0; + } + if (endBlock == null) { + endBlock = 99999999; + } + return this.resolveName(addressOrName).then(function (address) { + url += "/api?module=account&action=txlist&address=" + address; + url += "&startblock=" + startBlock; + url += "&endblock=" + endBlock; + url += "&sort=asc" + apiKey; + _this.emit("debug", { + action: "request", + request: url, + provider: _this + }); + return web.fetchJson(url, null, getResult).then(function (result) { + _this.emit("debug", { + action: "response", + request: url, + response: properties.deepCopy(result), + provider: _this + }); + var output = []; + result.forEach(function (tx) { + ["contractAddress", "to"].forEach(function (key) { + if (tx[key] == "") { + delete tx[key]; + } + }); + if (tx.creates == null && tx.contractAddress != null) { + tx.creates = tx.contractAddress; + } + var item = _this.formatter.transactionResponse(tx); + if (tx.timeStamp) { + item.timestamp = parseInt(tx.timeStamp); + } + output.push(item); + }); + return output; + }); + }); + }; + return EtherscanProvider; + }(baseProvider.BaseProvider)); + exports.EtherscanProvider = EtherscanProvider; + }); + + var etherscanProvider$1 = unwrapExports(etherscanProvider); + var etherscanProvider_1 = etherscanProvider.EtherscanProvider; + + var fallbackProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + var logger$1 = new logger.Logger(_version$G.version); + + function now() { return (new Date()).getTime(); } + // Returns: + // - true is all networks match + // - false if any network is null + // - throws if any 2 networks do not match + function checkNetworks(networks) { + var result = true; + var check = null; + networks.forEach(function (network) { + // Null + if (network == null) { + result = false; + return; + } + // Have nothing to compre to yet + if (check == null) { + check = network; + return; + } + // Matches! + if (check.name === network.name && + check.chainId === network.chainId && + ((check.ensAddress === network.ensAddress) || + (check.ensAddress == null && network.ensAddress == null))) { + return; + } + logger$1.throwArgumentError("provider mismatch", "networks", networks); + }); + return result; + } + function serialize(result) { + if (Array.isArray(result)) { + return JSON.stringify(result.map(function (r) { return serialize(r); })); + } + else if (result === null) { + return "null"; + } + else if (typeof (result) === "object") { + var keys = Object.keys(result); + keys.sort(); + return "{" + keys.map(function (key) { + var value = result[key]; + if (typeof (value) === "function") { + value = "function{}"; + } + else { + value = serialize(value); + } + return JSON.stringify(key) + "=" + serialize(value); + }).join(",") + "}"; + } + return JSON.stringify(result); + } + var nextRid = 1; + var FallbackProvider = /** @class */ (function (_super) { + __extends(FallbackProvider, _super); + function FallbackProvider(providers, quorum, weights) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, FallbackProvider); + if (providers.length === 0) { + logger$1.throwArgumentError("missing providers", "providers", providers); + } + if (weights != null && weights.length !== providers.length) { + logger$1.throwArgumentError("too many weights", "weights", weights); + } + else if (!weights) { + weights = providers.map(function (p) { return 1; }); + } + else { + weights.forEach(function (w) { + if (w % 1 || w > 512 || w < 1) { + logger$1.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); + } + }); + } + var total = weights.reduce(function (accum, w) { return (accum + w); }); + if (quorum == null) { + quorum = total / 2; + } + else { + if (quorum > total) { + logger$1.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + } + } + // All networks are ready, we can know the network for certain + var ready = checkNetworks(providers.map(function (p) { return p.network; })); + if (ready) { + _this = _super.call(this, providers[0].network) || this; + } + else { + // The network won't be known until all child providers know + var ready_1 = Promise.all(providers.map(function (p) { return p.getNetwork(); })).then(function (networks) { + if (!checkNetworks(networks)) { + logger$1.throwError("getNetwork returned null", logger.Logger.errors.UNKNOWN_ERROR); + } + return networks[0]; + }); + _this = _super.call(this, ready_1) || this; + } + // Preserve a copy, so we do not get mutated + properties.defineReadOnly(_this, "providers", Object.freeze(providers.slice())); + properties.defineReadOnly(_this, "quorum", quorum); + properties.defineReadOnly(_this, "weights", Object.freeze(weights.slice())); + return _this; + } + FallbackProvider.doPerform = function (provider, method, params) { + switch (method) { + case "getBlockNumber": + case "getGasPrice": + case "getEtherPrice": + return provider[method](); + case "getBalance": + case "getTransactionCount": + case "getCode": + return provider[method](params.address, params.blockTag || "latest"); + case "getStorageAt": + return provider.getStorageAt(params.address, params.position, params.blockTag || "latest"); + case "sendTransaction": + return provider.sendTransaction(params.signedTransaction).then(function (result) { + return result.hash; + }); + case "getBlock": + return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash); + case "call": + case "estimateGas": + return provider[method](params.transaction); + case "getTransaction": + case "getTransactionReceipt": + return provider[method](params.transactionHash); + case "getLogs": + return provider.getLogs(params.filter); + } + return logger$1.throwError("unknown method error", logger.Logger.errors.UNKNOWN_ERROR, { + method: method, + params: params + }); + }; + FallbackProvider.prototype.perform = function (method, params) { + var _this = this; + var T0 = now(); + var runners = (browser$6.shuffled(this.providers)).map(function (provider, i) { + var weight = _this.weights[i]; + var rid = nextRid++; + return { + run: function () { + var t0 = now(); + var start = t0 - T0; + _this.emit("debug", { + action: "request", + rid: rid, + backend: { weight: weight, start: start, provider: provider }, + request: { method: method, params: properties.deepCopy(params) }, + provider: _this + }); + return FallbackProvider.doPerform(provider, method, params).then(function (result) { + var duration = now() - t0; + _this.emit("debug", { + action: "response", + rid: rid, + backend: { weight: weight, start: start, duration: duration, provider: provider }, + request: { method: method, params: properties.deepCopy(params) }, + response: properties.deepCopy(result) + }); + return { weight: weight, result: result }; + }, function (error) { + var duration = now() - t0; + _this.emit("debug", { + action: "response", + rid: rid, + backend: { weight: weight, start: start, duration: duration, provider: provider }, + request: { method: method, params: properties.deepCopy(params) }, + error: error + }); + return { weight: weight, error: error }; + }); + }, + weight: weight + }; + }); + // Broadcast transactions to all backends, any that succeed is good enough + if (method === "sendTransaction") { + return Promise.all(runners.map(function (r) { return r.run(); })).then(function (results) { + for (var i = 0; i < results.length; i++) { + var result = results[i]; + if (result.result) { + return result.result; + } + } + return Promise.reject(results[0].error); + }); + } + // Otherwise query backends (randomly) until we have a quorum agreement + // on the correct result + return new Promise(function (resolve, reject) { + var firstError = null; + // How much weight is inflight + var inflightWeight = 0; + // All results, indexed by the serialized response. + var results = {}; + var next = function () { + if (runners.length === 0) { + return; + } + var runner = runners.shift(); + inflightWeight += runner.weight; + runner.run().then(function (result) { + if (results === null) { + return; + } + inflightWeight -= runner.weight; + if (result.error) { + if (firstError == null) { + firstError = result.error; + } + } + else { + var unique = serialize(result.result); + if (results[unique] == null) { + results[unique] = []; + } + results[unique].push(result); + // Do any results meet our quroum? + for (var u in results) { + var weight = results[u].reduce(function (accum, r) { return (accum + r.weight); }, 0); + if (weight >= _this.quorum) { + var result_1 = results[u][0].result; + _this.emit("debug", "quorum", -1, { weight: weight, result: result_1 }); + resolve(result_1); + results = null; + return; + } + } + } + // Out of options; give up + if (runners.length === 0 && inflightWeight === 0) { + // @TODO: this might need some more thinking... Maybe only if half + // of the results contain non-error? + if (method === "getGasPrice") { + var values_1 = []; + Object.keys(results).forEach(function (key) { + results[key].forEach(function (result) { + if (!result.result) { + return; + } + values_1.push(result.result); + }); + }); + values_1.sort(function (a, b) { + if (a.lt(b)) { + return -1; + } + if (a.gt(b)) { + return 1; + } + return 0; + }); + var index = parseInt(String(values_1.length / 2)); + if (values_1.length % 2) { + resolve(values_1[index]); + return; + } + resolve(values_1[index - 1].add(values_1[index]).div(2)); + return; + } + if (firstError === null) { + firstError = logger$1.makeError("failed to meet quorum", logger.Logger.errors.SERVER_ERROR, { + results: Object.keys(results).map(function (u) { + return { + method: method, + params: params, + result: u, + weight: results[u].reduce(function (accum, r) { return (accum + r.weight); }, 0) + }; + }) + }); + } + reject(firstError); + return; + } + // Queue up the next round + setTimeout(next, 0); + }); + // Fire off requests until we could possibly meet quorum + if (inflightWeight < _this.quorum) { + setTimeout(next, 0); + return; + } + }; + // bootstrap firing requests + next(); + }); + }; + return FallbackProvider; + }(baseProvider.BaseProvider)); + exports.FallbackProvider = FallbackProvider; + }); + + var fallbackProvider$1 = unwrapExports(fallbackProvider); + var fallbackProvider_1 = fallbackProvider.FallbackProvider; + + "use strict"; + var IpcProvider = null; + + var browserIpcProvider = { + IpcProvider: IpcProvider + }; + + var infuraProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + var logger$1 = new logger.Logger(_version$G.version); + + var defaultProjectId = "84842078b09946638c03157f83405213"; + var InfuraProvider = /** @class */ (function (_super) { + __extends(InfuraProvider, _super); + function InfuraProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(InfuraProvider.prototype, "projectId", { + get: function () { return this.apiKey; }, + enumerable: true, + configurable: true + }); + InfuraProvider.getApiKey = function (apiKey) { + if (apiKey == null) { + return defaultProjectId; + } + return apiKey; + }; + InfuraProvider.getUrl = function (network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "mainnet.infura.io"; + break; + case "ropsten": + host = "ropsten.infura.io"; + break; + case "rinkeby": + host = "rinkeby.infura.io"; + break; + case "kovan": + host = "kovan.infura.io"; + break; + case "goerli": + host = "goerli.infura.io"; + break; + default: + logger$1.throwError("unsupported network", logger.Logger.errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + return "https:/" + "/" + host + "/v3/" + apiKey; + }; + return InfuraProvider; + }(urlJsonRpcProvider.UrlJsonRpcProvider)); + exports.InfuraProvider = InfuraProvider; + }); + + var infuraProvider$1 = unwrapExports(infuraProvider); + var infuraProvider_1 = infuraProvider.InfuraProvider; + + var nodesmithProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$G.version); + // Special API key provided by Nodesmith for ethers.js + var defaultApiKey = "ETHERS_JS_SHARED"; + var NodesmithProvider = /** @class */ (function (_super) { + __extends(NodesmithProvider, _super); + function NodesmithProvider() { + return _super !== null && _super.apply(this, arguments) || this; + } + NodesmithProvider.getApiKey = function (apiKey) { + return apiKey || defaultApiKey; + }; + NodesmithProvider.getUrl = function (network, apiKey) { + var host = null; + switch (network.name) { + case "homestead": + host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; + break; + case "ropsten": + host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; + break; + case "rinkeby": + host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; + break; + case "goerli": + host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; + break; + case "kovan": + host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; + break; + default: + logger$1.throwArgumentError("unsupported network", "network", arguments[0]); + } + return (host + "?apiKey=" + apiKey); + }; + return NodesmithProvider; + }(urlJsonRpcProvider.UrlJsonRpcProvider)); + exports.NodesmithProvider = NodesmithProvider; + }); + + var nodesmithProvider$1 = unwrapExports(nodesmithProvider); + var nodesmithProvider_1 = nodesmithProvider.NodesmithProvider; + + var web3Provider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$G.version); + + /* + @TODO + utils.defineProperty(Web3Signer, "onchange", { + + }); + + */ + var Web3Provider = /** @class */ (function (_super) { + __extends(Web3Provider, _super); + function Web3Provider(web3Provider, network) { + var _newTarget = this.constructor; + var _this = this; + logger$1.checkNew(_newTarget, Web3Provider); + // HTTP has a host; IPC has a path. + _this = _super.call(this, web3Provider.host || web3Provider.path || "", network) || this; + if (web3Provider) { + if (web3Provider.sendAsync) { + _this._sendAsync = web3Provider.sendAsync.bind(web3Provider); + } + else if (web3Provider.send) { + _this._sendAsync = web3Provider.send.bind(web3Provider); + } + } + if (!web3Provider || !_this._sendAsync) { + logger$1.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); + } + properties.defineReadOnly(_this, "_web3Provider", web3Provider); + return _this; + } + Web3Provider.prototype.send = function (method, params) { + var _this = this; + // Metamask complains about eth_sign (and on some versions hangs) + if (method == "eth_sign" && this._web3Provider.isMetaMask) { + // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + method = "personal_sign"; + params = [params[1], params[0]]; + } + return new Promise(function (resolve, reject) { + var request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + _this._sendAsync(request, function (error, result) { + if (error) { + reject(error); + return; + } + if (result.error) { + // @TODO: not any + var error_1 = new Error(result.error.message); + error_1.code = result.error.code; + error_1.data = result.error.data; + reject(error_1); + return; + } + resolve(result.result); + }); + }); + }; + return Web3Provider; + }(jsonRpcProvider.JsonRpcProvider)); + exports.Web3Provider = Web3Provider; + }); + + var web3Provider$1 = unwrapExports(web3Provider); + var web3Provider_1 = web3Provider.Web3Provider; + + var providers = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.Provider = abstractProvider.Provider; + + exports.getNetwork = networks_1.getNetwork; + + exports.BaseProvider = baseProvider.BaseProvider; + + exports.AlchemyProvider = alchemyProvider.AlchemyProvider; + + exports.CloudflareProvider = cloudflareProvider.CloudflareProvider; + + exports.EtherscanProvider = etherscanProvider.EtherscanProvider; + + exports.FallbackProvider = fallbackProvider.FallbackProvider; + + exports.IpcProvider = browserIpcProvider.IpcProvider; + + exports.InfuraProvider = infuraProvider.InfuraProvider; + + exports.JsonRpcProvider = jsonRpcProvider.JsonRpcProvider; + exports.JsonRpcSigner = jsonRpcProvider.JsonRpcSigner; + + exports.NodesmithProvider = nodesmithProvider.NodesmithProvider; + + exports.Web3Provider = web3Provider.Web3Provider; + + exports.Formatter = formatter.Formatter; + }); + + var index$m = unwrapExports(providers); + var providers_1 = providers.Provider; + var providers_2 = providers.getNetwork; + var providers_3 = providers.BaseProvider; + var providers_4 = providers.AlchemyProvider; + var providers_5 = providers.CloudflareProvider; + var providers_6 = providers.EtherscanProvider; + var providers_7 = providers.FallbackProvider; + var providers_8 = providers.IpcProvider; + var providers_9 = providers.InfuraProvider; + var providers_10 = providers.JsonRpcProvider; + var providers_11 = providers.JsonRpcSigner; + var providers_12 = providers.NodesmithProvider; + var providers_13 = providers.Web3Provider; + var providers_14 = providers.Formatter; + + var solidity = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + + + var regexBytes = new RegExp("^bytes([0-9]+)$"); + var regexNumber = new RegExp("^(u?int)([0-9]*)$"); + var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); + var Zeros = "0000000000000000000000000000000000000000000000000000000000000000"; + function _pack(type, value, isArray) { + switch (type) { + case "address": + if (isArray) { + return bytes.zeroPad(value, 32); + } + return bytes.arrayify(value); + case "string": + return strings.toUtf8Bytes(value); + case "bytes": + return bytes.arrayify(value); + case "bool": + value = (value ? "0x01" : "0x00"); + if (isArray) { + return bytes.zeroPad(value, 32); + } + return bytes.arrayify(value); + } + var match = type.match(regexNumber); + if (match) { + //let signed = (match[1] === "int") + var size = parseInt(match[2] || "256"); + if ((size % 8 != 0) || size === 0 || size > 256) { + throw new Error("invalid number type - " + type); + } + if (isArray) { + size = 256; + } + value = bignumber$2.BigNumber.from(value).toTwos(size); + return bytes.zeroPad(value, size / 8); + } + match = type.match(regexBytes); + if (match) { + var size = parseInt(match[1]); + if (String(size) != match[1] || size === 0 || size > 32) { + throw new Error("invalid number type - " + type); + } + if (bytes.arrayify(value).byteLength !== size) { + throw new Error("invalid value for " + type); + } + if (isArray) { + return bytes.arrayify((value + Zeros).substring(0, 66)); + } + return value; + } + match = type.match(regexArray); + if (match && Array.isArray(value)) { + var baseType_1 = match[1]; + var count = parseInt(match[2] || String(value.length)); + if (count != value.length) { + throw new Error("invalid value for " + type); + } + var result_1 = []; + value.forEach(function (value) { + result_1.push(_pack(baseType_1, value, true)); + }); + return bytes.concat(result_1); + } + throw new Error("unknown type - " + type); + } + // @TODO: Array Enum + function pack(types, values) { + if (types.length != values.length) { + throw new Error("type/value count mismatch"); + } + var tight = []; + types.forEach(function (type, index) { + tight.push(_pack(type, values[index])); + }); + return bytes.hexlify(bytes.concat(tight)); + } + exports.pack = pack; + function keccak256(types, values) { + return keccak256_1.keccak256(pack(types, values)); + } + exports.keccak256 = keccak256; + function sha256(types, values) { + return browser.sha256(pack(types, values)); + } + exports.sha256 = sha256; + }); + + var index$n = unwrapExports(solidity); + var solidity_1 = solidity.pack; + var solidity_2 = solidity.keccak256; + var solidity_3 = solidity.sha256; + + var _version$I = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "units/5.0.0-beta.127"; + }); + + var _version$J = unwrapExports(_version$I); + var _version_1$m = _version$I.version; + + var units = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + + + + var logger$1 = new logger.Logger(_version$I.version); + var names = [ + "wei", + "kwei", + "mwei", + "gwei", + "szabo", + "finney", + "ether", + ]; + // Some environments have issues with RegEx that contain back-tracking, so we cannot + // use them. + function commify(value) { + var comps = String(value).split("."); + if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { + logger$1.throwArgumentError("invalid value", "value", value); + } + // Make sure we have at least one whole digit (0 if none) + var whole = comps[0]; + var negative = ""; + if (whole.substring(0, 1) === "-") { + negative = "-"; + whole = whole.substring(1); + } + // Make sure we have at least 1 whole digit with no leading zeros + while (whole.substring(0, 1) === "0") { + whole = whole.substring(1); + } + if (whole === "") { + whole = "0"; + } + var suffix = ""; + if (comps.length === 2) { + suffix = "." + (comps[1] || "0"); + } + var formatted = []; + while (whole.length) { + if (whole.length <= 3) { + formatted.unshift(whole); + break; + } + else { + var index = whole.length - 3; + formatted.unshift(whole.substring(index)); + whole = whole.substring(0, index); + } + } + return negative + formatted.join(",") + suffix; + } + exports.commify = commify; + function formatUnits(value, unitName) { + if (typeof (unitName) === "string") { + var index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return fixednumber.formatFixed(value, (unitName != null) ? unitName : 18); + } + exports.formatUnits = formatUnits; + function parseUnits(value, unitName) { + if (typeof (unitName) === "string") { + var index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return fixednumber.parseFixed(value, (unitName != null) ? unitName : 18); + } + exports.parseUnits = parseUnits; + function formatEther(wei) { + return formatUnits(wei, 18); + } + exports.formatEther = formatEther; + function parseEther(ether) { + return parseUnits(ether, 18); + } + exports.parseEther = parseEther; + }); + + var index$o = unwrapExports(units); + var units_1 = units.commify; + var units_2 = units.formatUnits; + var units_3 = units.parseUnits; + var units_4 = units.formatEther; + var units_5 = units.parseEther; + + var utils$3 = createCommonjsModule(function (module, exports) { + "use strict"; + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.AbiCoder = abi.AbiCoder; + exports.defaultAbiCoder = abi.defaultAbiCoder; + exports.EventFragment = abi.EventFragment; + exports.FormatTypes = abi.FormatTypes; + exports.Fragment = abi.Fragment; + exports.FunctionFragment = abi.FunctionFragment; + exports.Indexed = abi.Indexed; + exports.Interface = abi.Interface; + exports.ParamType = abi.ParamType; + + exports.getAddress = address.getAddress; + exports.getContractAddress = address.getContractAddress; + exports.getIcapAddress = address.getIcapAddress; + exports.isAddress = address.isAddress; + var base64 = __importStar(browser$8); + exports.base64 = base64; + + exports.arrayify = bytes.arrayify; + exports.concat = bytes.concat; + exports.hexDataSlice = bytes.hexDataSlice; + exports.hexDataLength = bytes.hexDataLength; + exports.hexlify = bytes.hexlify; + exports.hexStripZeros = bytes.hexStripZeros; + exports.hexValue = bytes.hexValue; + exports.hexZeroPad = bytes.hexZeroPad; + exports.isHexString = bytes.isHexString; + exports.joinSignature = bytes.joinSignature; + exports.zeroPad = bytes.zeroPad; + exports.splitSignature = bytes.splitSignature; + exports.stripZeros = bytes.stripZeros; + + exports.hashMessage = hash.hashMessage; + exports.id = hash.id; + exports.isValidName = hash.isValidName; + exports.namehash = hash.namehash; + + exports.defaultPath = hdnode.defaultPath; + exports.entropyToMnemonic = hdnode.entropyToMnemonic; + exports.HDNode = hdnode.HDNode; + exports.isValidMnemonic = hdnode.isValidMnemonic; + exports.mnemonicToEntropy = hdnode.mnemonicToEntropy; + exports.mnemonicToSeed = hdnode.mnemonicToSeed; + + exports.getJsonWalletAddress = jsonWallets.getJsonWalletAddress; + + exports.keccak256 = keccak256_1.keccak256; + + exports.Logger = logger.Logger; + + exports.sha256 = browser.sha256; + + exports.solidityKeccak256 = solidity.keccak256; + exports.solidityPack = solidity.pack; + exports.soliditySha256 = solidity.sha256; + + exports.randomBytes = browser$6.randomBytes; + + exports.checkProperties = properties.checkProperties; + exports.deepCopy = properties.deepCopy; + exports.defineReadOnly = properties.defineReadOnly; + exports.getStatic = properties.getStatic; + exports.resolveProperties = properties.resolveProperties; + exports.shallowCopy = properties.shallowCopy; + var RLP = __importStar(rlp); + exports.RLP = RLP; + + exports.computePublicKey = signingKey.computePublicKey; + exports.recoverPublicKey = signingKey.recoverPublicKey; + exports.SigningKey = signingKey.SigningKey; + + exports.formatBytes32String = strings.formatBytes32String; + exports.nameprep = strings.nameprep; + exports.parseBytes32String = strings.parseBytes32String; + exports._toEscapedUtf8String = strings._toEscapedUtf8String; + exports.toUtf8Bytes = strings.toUtf8Bytes; + exports.toUtf8CodePoints = strings.toUtf8CodePoints; + exports.toUtf8String = strings.toUtf8String; + + exports.computeAddress = transactions.computeAddress; + exports.parseTransaction = transactions.parse; + exports.recoverAddress = transactions.recoverAddress; + exports.serializeTransaction = transactions.serialize; + + exports.commify = units.commify; + exports.formatEther = units.formatEther; + exports.parseEther = units.parseEther; + exports.formatUnits = units.formatUnits; + exports.parseUnits = units.parseUnits; + + exports.verifyMessage = wallet.verifyMessage; + + exports.fetchJson = web.fetchJson; + exports.poll = web.poll; + //////////////////////// + // Enums + var sha2_2 = browser; + exports.SupportedAlgorithms = sha2_2.SupportedAlgorithms; + var strings_2 = strings; + exports.UnicodeNormalizationForm = strings_2.UnicodeNormalizationForm; + }); + + var utils$4 = unwrapExports(utils$3); + var utils_1$3 = utils$3.AbiCoder; + var utils_2$1 = utils$3.defaultAbiCoder; + var utils_3$1 = utils$3.EventFragment; + var utils_4$1 = utils$3.FormatTypes; + var utils_5 = utils$3.Fragment; + var utils_6 = utils$3.FunctionFragment; + var utils_7 = utils$3.Indexed; + var utils_8 = utils$3.Interface; + var utils_9 = utils$3.ParamType; + var utils_10 = utils$3.getAddress; + var utils_11 = utils$3.getContractAddress; + var utils_12 = utils$3.getIcapAddress; + var utils_13 = utils$3.isAddress; + var utils_14 = utils$3.base64; + var utils_15 = utils$3.arrayify; + var utils_16 = utils$3.concat; + var utils_17 = utils$3.hexDataSlice; + var utils_18 = utils$3.hexDataLength; + var utils_19 = utils$3.hexlify; + var utils_20 = utils$3.hexStripZeros; + var utils_21 = utils$3.hexValue; + var utils_22 = utils$3.hexZeroPad; + var utils_23 = utils$3.isHexString; + var utils_24 = utils$3.joinSignature; + var utils_25 = utils$3.zeroPad; + var utils_26 = utils$3.splitSignature; + var utils_27 = utils$3.stripZeros; + var utils_28 = utils$3.hashMessage; + var utils_29 = utils$3.id; + var utils_30 = utils$3.isValidName; + var utils_31 = utils$3.namehash; + var utils_32 = utils$3.defaultPath; + var utils_33 = utils$3.entropyToMnemonic; + var utils_34 = utils$3.HDNode; + var utils_35 = utils$3.isValidMnemonic; + var utils_36 = utils$3.mnemonicToEntropy; + var utils_37 = utils$3.mnemonicToSeed; + var utils_38 = utils$3.getJsonWalletAddress; + var utils_39 = utils$3.keccak256; + var utils_40 = utils$3.Logger; + var utils_41 = utils$3.sha256; + var utils_42 = utils$3.solidityKeccak256; + var utils_43 = utils$3.solidityPack; + var utils_44 = utils$3.soliditySha256; + var utils_45 = utils$3.randomBytes; + var utils_46 = utils$3.checkProperties; + var utils_47 = utils$3.deepCopy; + var utils_48 = utils$3.defineReadOnly; + var utils_49 = utils$3.getStatic; + var utils_50 = utils$3.resolveProperties; + var utils_51 = utils$3.shallowCopy; + var utils_52 = utils$3.RLP; + var utils_53 = utils$3.computePublicKey; + var utils_54 = utils$3.recoverPublicKey; + var utils_55 = utils$3.SigningKey; + var utils_56 = utils$3.formatBytes32String; + var utils_57 = utils$3.nameprep; + var utils_58 = utils$3.parseBytes32String; + var utils_59 = utils$3._toEscapedUtf8String; + var utils_60 = utils$3.toUtf8Bytes; + var utils_61 = utils$3.toUtf8CodePoints; + var utils_62 = utils$3.toUtf8String; + var utils_63 = utils$3.computeAddress; + var utils_64 = utils$3.parseTransaction; + var utils_65 = utils$3.recoverAddress; + var utils_66 = utils$3.serializeTransaction; + var utils_67 = utils$3.commify; + var utils_68 = utils$3.formatEther; + var utils_69 = utils$3.parseEther; + var utils_70 = utils$3.formatUnits; + var utils_71 = utils$3.parseUnits; + var utils_72 = utils$3.verifyMessage; + var utils_73 = utils$3.fetchJson; + var utils_74 = utils$3.poll; + var utils_75 = utils$3.SupportedAlgorithms; + var utils_76 = utils$3.UnicodeNormalizationForm; + + var platform = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.platform = "node"; + }); + + var platform$1 = unwrapExports(platform); + var platform_1 = platform.platform; + + var _version$K = createCommonjsModule(function (module, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.version = "ethers/5.0.0-beta.156"; + }); + + var _version$L = unwrapExports(_version$K); + var _version_1$n = _version$K.version; + + var ethers = createCommonjsModule(function (module, exports) { + "use strict"; + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + + exports.Contract = contracts.Contract; + exports.ContractFactory = contracts.ContractFactory; + + exports.BigNumber = bignumber$2.BigNumber; + exports.FixedNumber = bignumber$2.FixedNumber; + + exports.Signer = abstractSigner.Signer; + exports.VoidSigner = abstractSigner.VoidSigner; + + exports.Wallet = wallet.Wallet; + var constants$1 = __importStar(constants); + exports.constants = constants$1; + var providers$1 = __importStar(providers); + exports.providers = providers$1; + + exports.Wordlist = browser$4.Wordlist; + exports.wordlists = browser$4.wordlists; + var utils = __importStar(utils$3); + exports.utils = utils; + + var errors = logger.Logger.errors; + exports.errors = errors; + //////////////////////// + // Compile-Time Constants + // This is empty in node, and used by browserify to inject extra goodies + + exports.platform = platform.platform; + // This is generated by "npm run dist" + + exports.version = _version$K.version; + var logger$1 = new logger.Logger(_version$K.version); + exports.logger = logger$1; + //////////////////////// + // Helper Functions + function getDefaultProvider(network, options) { + if (network == null) { + network = "homestead"; + } + var n = providers$1.getNetwork(network); + if (!n || !n._defaultProvider) { + logger$1.throwError("unsupported getDefaultProvider network", logger.Logger.errors.NETWORK_ERROR, { + operation: "getDefaultProvider", + network: network + }); + } + return n._defaultProvider(providers$1, options); + } + exports.getDefaultProvider = getDefaultProvider; + }); + + var ethers$1 = unwrapExports(ethers); + var ethers_1 = ethers.Contract; + var ethers_2 = ethers.ContractFactory; + var ethers_3 = ethers.BigNumber; + var ethers_4 = ethers.FixedNumber; + var ethers_5 = ethers.Signer; + var ethers_6 = ethers.VoidSigner; + var ethers_7 = ethers.Wallet; + var ethers_8 = ethers.constants; + var ethers_9 = ethers.providers; + var ethers_10 = ethers.Wordlist; + var ethers_11 = ethers.wordlists; + var ethers_12 = ethers.utils; + var ethers_13 = ethers.errors; + var ethers_14 = ethers.platform; + var ethers_15 = ethers.version; + var ethers_16 = ethers.logger; + var ethers_17 = ethers.getDefaultProvider; + + var ethers_1$1 = createCommonjsModule(function (module, exports) { + "use strict"; + function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; + } + var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; + result["default"] = mod; + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + var ethers$1 = __importStar(ethers); + exports.ethers = ethers$1; + __export(ethers); + }); + + var index$p = unwrapExports(ethers_1$1); + var ethers_2$1 = ethers_1$1.ethers; + + exports.default = index$p; + exports.ethers = ethers_2$1; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/packages/ethers/dist/ethers.umd.min.js b/packages/ethers/dist/ethers.umd.min.js new file mode 100644 index 000000000..3a78bbf63 --- /dev/null +++ b/packages/ethers/dist/ethers.umd.min.js @@ -0,0 +1 @@ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],C=8191&T,R=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],q=8191&K,W=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,W)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(C,z),i=(i=Math.imul(C,H))+Math.imul(R,z)|0,o=Math.imul(R,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,$)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(C,le)|0,i=(i=i+Math.imul(C,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Ce=(f+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(R,pe)|0))<<13)|0;f=((o=o+Math.imul(R,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Re=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Ce,u[17]=Re,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.129"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.129"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.130"})),d=(r(h),h.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(h.version),a={};r.isBigNumberish=function(e){return null!=e&&(u.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var u=function(){function e(t,r){var n=this.constructor;o.checkNew(n,e),t!==a&&o.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return d(p(this).fromTwos(e))},e.prototype.toTwos=function(e){return d(p(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return d(p(this).add(p(e)))},e.prototype.sub=function(e){return d(p(this).sub(p(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&m("division by zero","div"),d(p(this).div(p(t)))},e.prototype.mul=function(e){return d(p(this).mul(p(e)))},e.prototype.mod=function(e){return d(p(this).mod(p(e)))},e.prototype.pow=function(e){return d(p(this).pow(p(e)))},e.prototype.maskn=function(e){return d(p(this).maskn(e))},e.prototype.eq=function(e){return p(this).eq(p(e))},e.prototype.lt=function(e){return p(this).lt(p(e))},e.prototype.lte=function(e){return p(this).lte(p(e))},e.prototype.gt=function(e){return p(this).gt(p(e))},e.prototype.gte=function(e){return p(this).gte(p(e))},e.prototype.isZero=function(){return p(this).isZero()},e.prototype.toNumber=function(){try{return p(this).toNumber()}catch(e){m("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&o.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(a,c(t)):t.match(/^-?[0-9]+$/)?new e(a,c(new i.BN(t))):o.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&m("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&m("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):o.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function c(e){if("string"!=typeof e)return c(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&o.throwArgumentError("invalid hex","value",e),"0x00"===(e=c(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return u.from(c(e))}function p(e){var t=u.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function m(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.FixedNumber=p.FixedNumber})),g=(r(m),m.BigNumber,m.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.131"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.137"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,C,R,B,I,F,L,j,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,C=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&C,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&R,e[15]=N^~C&B,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~R&S,e[17]=C^~B&M,e[26]=z^~K&I,e[27]=H^~q&F,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=R^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=q^~F&j,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.128"})),S=(r(A),A.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(A.version);function a(e){l.isHexString(e,20)||o.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=l.arrayify(E.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var u={},c=0;c<10;c++)u[String(c)]=String(c);for(c=0;c<26;c++)u[String.fromCharCode(65+c)]=String(10+c);var h,d=Math.floor((h=9007199254740991,Math.log10?Math.log10(h):Math.log(h)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=u[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=a(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=a("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=l.stripZeros(l.arrayify(e.nonce));return m(l.hexDataSlice(E.keccak256(P.encode([t,r])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,R.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new C.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.128"})),q=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(q.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(W),W.LogDescription,W.TransactionDescription,W.Indexed,W.Result,W.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=W.Indexed,t.Interface=W.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.131"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.132"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.137"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger($.version),a={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function s(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return s(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return s(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return s(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function u(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],u=0;u0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=v;var b=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&o.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&o.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ct=Tt;function Rt(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Rt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Ct.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Ct,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var qt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new qt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new qt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.129"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.128"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?R.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.128"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return q.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.130"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invlaid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.128"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},C.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},C.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var R=function(e,t){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof C||(t=new C(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};R.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}C(R)};R()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Cr=0;Cr<256;Cr++)Nr[Cr]=(Cr+256).toString(16).substr(1),Tr[Nr[Cr]]=Cr;function Rr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Rr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Rr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Rr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),C=l.arrayify(T.encrypt(f)),R=new Date,B=R.getUTCFullYear()+"-"+Pr.zpad(R.getUTCMonth()+1,2)+"-"+Pr.zpad(R.getUTCDate(),2)+"T"+Pr.zpad(R.getUTCHours(),2)+"-"+Pr.zpad(R.getUTCMinutes(),2)+"-"+Pr.zpad(R.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(C).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),qr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.130"})),Wr=(r(qr),qr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(qr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(q.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(q.hashMessage(e),t)}})),Gr=(r(Wr),Wr.Wallet,Wr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.129"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.141"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===R.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),pn=(r(dn),dn.pack,dn.keccak256,dn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.127"})),mn=(r(pn),pn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(pn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return p.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return p.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),gn=(r(mn),mn.commify,mn.formatUnits,mn.parseUnits,mn.formatEther,mn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=q.hashMessage,r.id=q.id,r.isValidName=q.isValidName,r.namehash=q.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=dn.keccak256,r.solidityPack=dn.pack,r.soliditySha256=dn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=mn.commify,r.formatEther=mn.formatEther,r.parseEther=mn.parseEther,r.formatUnits=mn.formatUnits,r.parseUnits=mn.parseUnits,r.verifyMessage=Wr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),yn=(r(gn),gn.AbiCoder,gn.defaultAbiCoder,gn.EventFragment,gn.FormatTypes,gn.Fragment,gn.FunctionFragment,gn.Indexed,gn.Interface,gn.ParamType,gn.getAddress,gn.getContractAddress,gn.getIcapAddress,gn.isAddress,gn.base64,gn.arrayify,gn.concat,gn.hexDataSlice,gn.hexDataLength,gn.hexlify,gn.hexStripZeros,gn.hexValue,gn.hexZeroPad,gn.isHexString,gn.joinSignature,gn.zeroPad,gn.splitSignature,gn.stripZeros,gn.hashMessage,gn.id,gn.isValidName,gn.namehash,gn.defaultPath,gn.entropyToMnemonic,gn.HDNode,gn.isValidMnemonic,gn.mnemonicToEntropy,gn.mnemonicToSeed,gn.getJsonWalletAddress,gn.keccak256,gn.Logger,gn.sha256,gn.solidityKeccak256,gn.solidityPack,gn.soliditySha256,gn.randomBytes,gn.checkProperties,gn.deepCopy,gn.defineReadOnly,gn.getStatic,gn.resolveProperties,gn.shallowCopy,gn.RLP,gn.computePublicKey,gn.recoverPublicKey,gn.SigningKey,gn.formatBytes32String,gn.nameprep,gn.parseBytes32String,gn._toEscapedUtf8String,gn.toUtf8Bytes,gn.toUtf8CodePoints,gn.toUtf8String,gn.computeAddress,gn.parseTransaction,gn.recoverAddress,gn.serializeTransaction,gn.commify,gn.formatEther,gn.parseEther,gn.formatUnits,gn.parseUnits,gn.verifyMessage,gn.fetchJson,gn.poll,gn.SupportedAlgorithms,gn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.platform="node"})),vn=(r(yn),yn.platform,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.156"})),bn=(r(vn),vn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=Wr.Wallet;var i=n(R);r.constants=i;var o=n(hn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(gn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.platform=yn.platform,r.version=vn.version;var u=new f.Logger(vn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),wn=(r(bn),bn.Contract,bn.ContractFactory,bn.BigNumber,bn.FixedNumber,bn.Signer,bn.VoidSigner,bn.Wallet,bn.constants,bn.providers,bn.Wordlist,bn.wordlists,bn.utils,bn.errors,bn.platform,bn.version,bn.logger,bn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(bn);r.ethers=i,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(bn)})),_n=r(wn),En=wn.ethers;e.default=_n,e.ethers=En,Object.defineProperty(e,"__esModule",{value:!0})}); diff --git a/packages/ethers/_version.d.ts b/packages/ethers/lib.esm/_version.d.ts similarity index 100% rename from packages/ethers/_version.d.ts rename to packages/ethers/lib.esm/_version.d.ts diff --git a/packages/ethers/lib.esm/_version.js b/packages/ethers/lib.esm/_version.js new file mode 100644 index 000000000..389375c05 --- /dev/null +++ b/packages/ethers/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "ethers/5.0.0-beta.155"; diff --git a/packages/ethers/browser-platform.d.ts b/packages/ethers/lib.esm/browser-platform.d.ts similarity index 100% rename from packages/ethers/browser-platform.d.ts rename to packages/ethers/lib.esm/browser-platform.d.ts diff --git a/packages/ethers/lib.esm/browser-platform.js b/packages/ethers/lib.esm/browser-platform.js new file mode 100644 index 000000000..35e2016fe --- /dev/null +++ b/packages/ethers/lib.esm/browser-platform.js @@ -0,0 +1,2 @@ +"use strict"; +export const platform = "browser"; diff --git a/packages/ethers/ethers.d.ts b/packages/ethers/lib.esm/ethers.d.ts similarity index 100% rename from packages/ethers/ethers.d.ts rename to packages/ethers/lib.esm/ethers.d.ts diff --git a/packages/ethers/lib.esm/ethers.js b/packages/ethers/lib.esm/ethers.js new file mode 100644 index 000000000..7737aa8bb --- /dev/null +++ b/packages/ethers/lib.esm/ethers.js @@ -0,0 +1,39 @@ +"use strict"; +import { Contract, ContractFactory } from "@ethersproject/contracts"; +import { BigNumber, FixedNumber } from "@ethersproject/bignumber"; +import { Signer, VoidSigner } from "@ethersproject/abstract-signer"; +import { Wallet } from "@ethersproject/wallet"; +import * as constants from "@ethersproject/constants"; +import * as providers from "@ethersproject/providers"; +import { Wordlist, wordlists } from "@ethersproject/wordlists"; +import * as utils from "./utils"; +import { Logger } from "@ethersproject/logger"; +const errors = Logger.errors; +//////////////////////// +// Compile-Time Constants +// This is empty in node, and used by browserify to inject extra goodies +import { platform } from "./platform"; +// This is generated by "npm run dist" +import { version } from "./_version"; +const logger = new Logger(version); +//////////////////////// +// Helper Functions +function getDefaultProvider(network, options) { + if (network == null) { + network = "homestead"; + } + let n = providers.getNetwork(network); + if (!n || !n._defaultProvider) { + logger.throwError("unsupported getDefaultProvider network", Logger.errors.NETWORK_ERROR, { + operation: "getDefaultProvider", + network: network + }); + } + return n._defaultProvider(providers, options); +} +//////////////////////// +// Exports +export { version, Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, +//////////////////////// +// Compile-Time Constants +platform, Wordlist }; diff --git a/packages/ethers/index.d.ts b/packages/ethers/lib.esm/index.d.ts similarity index 100% rename from packages/ethers/index.d.ts rename to packages/ethers/lib.esm/index.d.ts diff --git a/packages/ethers/lib.esm/index.js b/packages/ethers/lib.esm/index.js new file mode 100644 index 000000000..464f20594 --- /dev/null +++ b/packages/ethers/lib.esm/index.js @@ -0,0 +1,4 @@ +"use strict"; +import * as ethers from "./ethers"; +export { ethers }; +export * from "./ethers"; diff --git a/packages/ethers/platform.d.ts b/packages/ethers/lib.esm/platform.d.ts similarity index 100% rename from packages/ethers/platform.d.ts rename to packages/ethers/lib.esm/platform.d.ts diff --git a/packages/ethers/lib.esm/platform.js b/packages/ethers/lib.esm/platform.js new file mode 100644 index 000000000..91714f6ba --- /dev/null +++ b/packages/ethers/lib.esm/platform.js @@ -0,0 +1,2 @@ +"use strict"; +export const platform = "node"; diff --git a/packages/ethers/utils.d.ts b/packages/ethers/lib.esm/utils.d.ts similarity index 100% rename from packages/ethers/utils.d.ts rename to packages/ethers/lib.esm/utils.d.ts diff --git a/packages/ethers/lib.esm/utils.js b/packages/ethers/lib.esm/utils.js new file mode 100644 index 000000000..72308e422 --- /dev/null +++ b/packages/ethers/lib.esm/utils.js @@ -0,0 +1,31 @@ +"use strict"; +import { AbiCoder, defaultAbiCoder, EventFragment, FormatTypes, Fragment, FunctionFragment, Indexed, Interface, ParamType } from "@ethersproject/abi"; +import { getAddress, getContractAddress, getIcapAddress, isAddress } from "@ethersproject/address"; +import * as base64 from "@ethersproject/base64"; +import { arrayify, concat, hexDataSlice, hexDataLength, hexlify, hexStripZeros, hexValue, hexZeroPad, isHexString, joinSignature, zeroPad, splitSignature, stripZeros } from "@ethersproject/bytes"; +import { hashMessage, id, isValidName, namehash } from "@ethersproject/hash"; +import { defaultPath, entropyToMnemonic, HDNode, isValidMnemonic, mnemonicToEntropy, mnemonicToSeed } from "@ethersproject/hdnode"; +import { getJsonWalletAddress } from "@ethersproject/json-wallets"; +import { keccak256 } from "@ethersproject/keccak256"; +import { Logger } from "@ethersproject/logger"; +import { sha256 } from "@ethersproject/sha2"; +import { keccak256 as solidityKeccak256, pack as solidityPack, sha256 as soliditySha256 } from "@ethersproject/solidity"; +import { randomBytes } from "@ethersproject/random"; +import { checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import * as RLP from "@ethersproject/rlp"; +import { computePublicKey, recoverPublicKey, SigningKey } from "@ethersproject/signing-key"; +import { formatBytes32String, nameprep, parseBytes32String, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String } from "@ethersproject/strings"; +import { computeAddress, parse as parseTransaction, recoverAddress, serialize as serializeTransaction } from "@ethersproject/transactions"; +import { commify, formatEther, parseEther, formatUnits, parseUnits } from "@ethersproject/units"; +import { verifyMessage } from "@ethersproject/wallet"; +import { fetchJson, poll } from "@ethersproject/web"; +//////////////////////// +// Enums +import { SupportedAlgorithms } from "@ethersproject/sha2"; +import { UnicodeNormalizationForm } from "@ethersproject/strings"; +//////////////////////// +// Exports +export { AbiCoder, defaultAbiCoder, Fragment, EventFragment, FunctionFragment, ParamType, FormatTypes, Logger, RLP, fetchJson, poll, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy, arrayify, concat, stripZeros, zeroPad, defaultPath, HDNode, SigningKey, Interface, base64, hexlify, isHexString, hexStripZeros, hexValue, hexZeroPad, hexDataLength, hexDataSlice, nameprep, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, isValidName, id, getAddress, getIcapAddress, getContractAddress, isAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, recoverAddress, computePublicKey, recoverPublicKey, verifyMessage, mnemonicToEntropy, entropyToMnemonic, isValidMnemonic, mnemonicToSeed, +//////////////////////// +// Enums +SupportedAlgorithms, UnicodeNormalizationForm, Indexed }; diff --git a/packages/ethers/lib/_version.d.ts b/packages/ethers/lib/_version.d.ts new file mode 100644 index 000000000..79b656504 --- /dev/null +++ b/packages/ethers/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "ethers/5.0.0-beta.155"; diff --git a/packages/ethers/_version.js b/packages/ethers/lib/_version.js similarity index 100% rename from packages/ethers/_version.js rename to packages/ethers/lib/_version.js diff --git a/packages/ethers/lib/browser-platform.d.ts b/packages/ethers/lib/browser-platform.d.ts new file mode 100644 index 000000000..c7ff4f86c --- /dev/null +++ b/packages/ethers/lib/browser-platform.d.ts @@ -0,0 +1 @@ +export declare const platform = "browser"; diff --git a/packages/ethers/browser-platform.js b/packages/ethers/lib/browser-platform.js similarity index 100% rename from packages/ethers/browser-platform.js rename to packages/ethers/lib/browser-platform.js diff --git a/packages/ethers/lib/ethers.d.ts b/packages/ethers/lib/ethers.d.ts new file mode 100644 index 000000000..6b8265238 --- /dev/null +++ b/packages/ethers/lib/ethers.d.ts @@ -0,0 +1,20 @@ +import { Contract, ContractFactory } from "@ethersproject/contracts"; +import { BigNumber, FixedNumber } from "@ethersproject/bignumber"; +import { Signer, VoidSigner } from "@ethersproject/abstract-signer"; +import { Wallet } from "@ethersproject/wallet"; +import * as constants from "@ethersproject/constants"; +import * as providers from "@ethersproject/providers"; +import { Wordlist, wordlists } from "@ethersproject/wordlists"; +import * as utils from "./utils"; +declare const errors: { + [name: string]: string; +}; +import { BigNumberish } from "@ethersproject/bignumber"; +import { Bytes, BytesLike, Signature } from "@ethersproject/bytes"; +import { Transaction, UnsignedTransaction } from "@ethersproject/transactions"; +import { platform } from "./platform"; +import { version } from "./_version"; +declare const logger: utils.Logger; +import { ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface } from "@ethersproject/contracts"; +declare function getDefaultProvider(network?: providers.Network | string, options?: any): providers.BaseProvider; +export { version, Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, platform, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist }; diff --git a/packages/ethers/ethers.js b/packages/ethers/lib/ethers.js similarity index 100% rename from packages/ethers/ethers.js rename to packages/ethers/lib/ethers.js diff --git a/packages/ethers/lib/index.d.ts b/packages/ethers/lib/index.d.ts new file mode 100644 index 000000000..957c0b432 --- /dev/null +++ b/packages/ethers/lib/index.d.ts @@ -0,0 +1,3 @@ +import * as ethers from "./ethers"; +export { ethers }; +export * from "./ethers"; diff --git a/packages/ethers/index.js b/packages/ethers/lib/index.js similarity index 100% rename from packages/ethers/index.js rename to packages/ethers/lib/index.js diff --git a/packages/ethers/lib/platform.d.ts b/packages/ethers/lib/platform.d.ts new file mode 100644 index 000000000..e0115f0b9 --- /dev/null +++ b/packages/ethers/lib/platform.d.ts @@ -0,0 +1 @@ +export declare const platform = "node"; diff --git a/packages/ethers/platform.js b/packages/ethers/lib/platform.js similarity index 100% rename from packages/ethers/platform.js rename to packages/ethers/lib/platform.js diff --git a/packages/ethers/lib/utils.d.ts b/packages/ethers/lib/utils.d.ts new file mode 100644 index 000000000..6ba9547d5 --- /dev/null +++ b/packages/ethers/lib/utils.d.ts @@ -0,0 +1,27 @@ +import { AbiCoder, defaultAbiCoder, EventFragment, FormatTypes, Fragment, FunctionFragment, Indexed, Interface, ParamType } from "@ethersproject/abi"; +import { getAddress, getContractAddress, getIcapAddress, isAddress } from "@ethersproject/address"; +import * as base64 from "@ethersproject/base64"; +import { arrayify, concat, hexDataSlice, hexDataLength, hexlify, hexStripZeros, hexValue, hexZeroPad, isHexString, joinSignature, zeroPad, splitSignature, stripZeros } from "@ethersproject/bytes"; +import { hashMessage, id, isValidName, namehash } from "@ethersproject/hash"; +import { defaultPath, entropyToMnemonic, HDNode, isValidMnemonic, mnemonicToEntropy, mnemonicToSeed } from "@ethersproject/hdnode"; +import { getJsonWalletAddress } from "@ethersproject/json-wallets"; +import { keccak256 } from "@ethersproject/keccak256"; +import { Logger } from "@ethersproject/logger"; +import { sha256 } from "@ethersproject/sha2"; +import { keccak256 as solidityKeccak256, pack as solidityPack, sha256 as soliditySha256 } from "@ethersproject/solidity"; +import { randomBytes } from "@ethersproject/random"; +import { checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import * as RLP from "@ethersproject/rlp"; +import { computePublicKey, recoverPublicKey, SigningKey } from "@ethersproject/signing-key"; +import { formatBytes32String, nameprep, parseBytes32String, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String } from "@ethersproject/strings"; +import { computeAddress, parse as parseTransaction, recoverAddress, serialize as serializeTransaction } from "@ethersproject/transactions"; +import { commify, formatEther, parseEther, formatUnits, parseUnits } from "@ethersproject/units"; +import { verifyMessage } from "@ethersproject/wallet"; +import { fetchJson, poll } from "@ethersproject/web"; +import { SupportedAlgorithms } from "@ethersproject/sha2"; +import { UnicodeNormalizationForm } from "@ethersproject/strings"; +import { CoerceFunc } from "@ethersproject/abi"; +import { Bytes, BytesLike, Hexable } from "@ethersproject/bytes"; +import { ConnectionInfo, OnceBlockable, PollOptions } from "@ethersproject/web"; +import { EncryptOptions, ProgressCallback } from "@ethersproject/json-wallets"; +export { AbiCoder, defaultAbiCoder, Fragment, EventFragment, FunctionFragment, ParamType, FormatTypes, Logger, RLP, fetchJson, poll, checkProperties, deepCopy, defineReadOnly, getStatic, resolveProperties, shallowCopy, arrayify, concat, stripZeros, zeroPad, defaultPath, HDNode, SigningKey, Interface, base64, hexlify, isHexString, hexStripZeros, hexValue, hexZeroPad, hexDataLength, hexDataSlice, nameprep, _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, formatBytes32String, parseBytes32String, hashMessage, namehash, isValidName, id, getAddress, getIcapAddress, getContractAddress, isAddress, formatEther, parseEther, formatUnits, parseUnits, commify, keccak256, sha256, randomBytes, solidityPack, solidityKeccak256, soliditySha256, splitSignature, joinSignature, parseTransaction, serializeTransaction, getJsonWalletAddress, computeAddress, recoverAddress, computePublicKey, recoverPublicKey, verifyMessage, mnemonicToEntropy, entropyToMnemonic, isValidMnemonic, mnemonicToSeed, SupportedAlgorithms, UnicodeNormalizationForm, Bytes, BytesLike, Hexable, CoerceFunc, Indexed, ConnectionInfo, OnceBlockable, PollOptions, EncryptOptions, ProgressCallback }; diff --git a/packages/ethers/utils.js b/packages/ethers/lib/utils.js similarity index 100% rename from packages/ethers/utils.js rename to packages/ethers/lib/utils.js diff --git a/packages/ethers/package.json b/packages/ethers/package.json index 6308ddc9a..a5d352ced 100644 --- a/packages/ethers/package.json +++ b/packages/ethers/package.json @@ -1,8 +1,8 @@ { "name": "ethers", - "version": "5.0.0-beta.155", + "version": "5.0.0-beta.156", "description": "Umbrella package for most common Ethers libraries.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "dist": "npm run dist-browser && npm run dist-minified", "dist-browser": "browserify -s ethers -g ./scripts/transform index.js -o ./dist/ethers.js", @@ -60,5 +60,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x625d8aa9d8fa371adbb0096dfa2558d5f5e24f8c50bee56694068938003b083b" + "module": "./lib.esm/index.js", + "tarballHash": "0xb405e54456bb9eda893991365e18b295b0ce48a434319f02299afee7c7c15320" } diff --git a/packages/ethers/tsconfig.json b/packages/ethers/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/ethers/tsconfig.json +++ b/packages/ethers/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/experimental/_version.d.ts b/packages/experimental/lib.esm/_version.d.ts similarity index 100% rename from packages/experimental/_version.d.ts rename to packages/experimental/lib.esm/_version.d.ts diff --git a/packages/experimental/lib.esm/_version.js b/packages/experimental/lib.esm/_version.js new file mode 100644 index 000000000..0272c2568 --- /dev/null +++ b/packages/experimental/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "experimental/5.0.0-beta.128"; diff --git a/packages/experimental/brain-wallet.d.ts b/packages/experimental/lib.esm/brain-wallet.d.ts similarity index 100% rename from packages/experimental/brain-wallet.d.ts rename to packages/experimental/lib.esm/brain-wallet.d.ts diff --git a/packages/experimental/lib.esm/brain-wallet.js b/packages/experimental/lib.esm/brain-wallet.js new file mode 100644 index 000000000..ce5bdd1e6 --- /dev/null +++ b/packages/experimental/lib.esm/brain-wallet.js @@ -0,0 +1,55 @@ +"use strict"; +import { ethers } from "ethers"; +import scrypt from "scrypt-js"; +import { version } from "./_version"; +const logger = new ethers.utils.Logger(version); +let warned = false; +export class BrainWallet extends ethers.Wallet { + static _generate(username, password, legacy, progressCallback) { + if (!warned) { + logger.warn("Warning: using Brain Wallets should be considered insecure (this warning will not be repeated)"); + warned = true; + } + let usernameBytes = null; + let passwordBytes = null; + if (typeof (username) === 'string') { + logger.checkNormalize(); + usernameBytes = ethers.utils.toUtf8Bytes(username.normalize('NFKC')); + } + else { + usernameBytes = ethers.utils.arrayify(username); + } + if (typeof (password) === 'string') { + logger.checkNormalize(); + passwordBytes = ethers.utils.toUtf8Bytes(password.normalize('NFKC')); + } + else { + passwordBytes = ethers.utils.arrayify(password); + } + return new Promise((resolve, reject) => { + scrypt(passwordBytes, usernameBytes, (1 << 18), 8, 1, 32, (error, progress, key) => { + if (error) { + reject(error); + } + else if (key) { + if (legacy) { + resolve(new BrainWallet(key)); + } + else { + let mnemonic = ethers.utils.entropyToMnemonic(ethers.utils.arrayify(key).slice(0, 16)); + resolve(new BrainWallet(ethers.Wallet.fromMnemonic(mnemonic))); + } + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + }); + } + static generate(username, password, progressCallback) { + return BrainWallet._generate(username, password, false, progressCallback); + } + static generateLegacy(username, password, progressCallback) { + return BrainWallet._generate(username, password, true, progressCallback); + } +} diff --git a/packages/experimental/index.d.ts b/packages/experimental/lib.esm/index.d.ts similarity index 100% rename from packages/experimental/index.d.ts rename to packages/experimental/lib.esm/index.d.ts diff --git a/packages/experimental/index.js b/packages/experimental/lib.esm/index.js similarity index 100% rename from packages/experimental/index.js rename to packages/experimental/lib.esm/index.js diff --git a/packages/experimental/metamask-provider.d.ts b/packages/experimental/lib.esm/metamask-provider.d.ts similarity index 100% rename from packages/experimental/metamask-provider.d.ts rename to packages/experimental/lib.esm/metamask-provider.d.ts diff --git a/packages/experimental/lib.esm/metamask-provider.js b/packages/experimental/lib.esm/metamask-provider.js new file mode 100644 index 000000000..414f75e4f --- /dev/null +++ b/packages/experimental/lib.esm/metamask-provider.js @@ -0,0 +1,66 @@ +"use strict"; +import { ethers } from "ethers"; +import { version } from "./_version"; +const logger = new ethers.utils.Logger(version); +export class MetamaskProvider extends ethers.providers.Web3Provider { + constructor(ethereum) { + if (!ethereum) { + ethereum = global.ethereum; + if (!ethereum) { + logger.throwError("could not auto-detect global.ethereum", ethers.errors.UNSUPPORTED_OPERATION, { + operation: "window.ethereum" + }); + } + } + super(ethereum); + let _account = null; + ethers.utils.defineReadOnly(this, "_pollAccountFunc", () => { + let account = null; + if (account === _account) { + return; + } + console.log("poll"); + this.emit("account", account, _account); + _account = account; + }); + super(ethereum); + } + getSigner(addressOrIndex) { + if (!this.enabled) { + return null; + } + return super.getSigner(addressOrIndex); + } + get enabled() { + return false; + } + _startPollingAccount() { + if (this._pollingAccount) { + return; + } + console.log("start polling for account changes including to/from null"); + this._pollingAccount = setInterval(this._pollAccountFunc, 1000); + } + _stopPollingAccount() { + if (!this._pollingAccount) { + return; + } + console.log("stop polling for account changes including to/from null"); + clearInterval(this._pollingAccount); + this._pollingAccount = null; + } + on(eventName, listener) { + super.on(eventName, listener); + if (this.listenerCount("account") > 0) { + this._startPollingAccount(); + } + return this; + } + off(eventName, listener) { + super.off(eventName, listener); + if (this.listenerCount("account") === 0) { + this._stopPollingAccount(); + } + return this; + } +} diff --git a/packages/experimental/nonce-manager.d.ts b/packages/experimental/lib.esm/nonce-manager.d.ts similarity index 100% rename from packages/experimental/nonce-manager.d.ts rename to packages/experimental/lib.esm/nonce-manager.d.ts diff --git a/packages/experimental/lib.esm/nonce-manager.js b/packages/experimental/lib.esm/nonce-manager.js new file mode 100644 index 000000000..8929c9954 --- /dev/null +++ b/packages/experimental/lib.esm/nonce-manager.js @@ -0,0 +1,54 @@ +"use strict"; +import { ethers } from "ethers"; +import { version } from "./_version"; +const logger = new ethers.utils.Logger(version); +export class NonceManager extends ethers.Signer { + constructor(signer) { + logger.checkNew(new.target, NonceManager); + super(); + ethers.utils.defineReadOnly(this, "signer", signer); + } + connect(provider) { + return new NonceManager(this.signer.connect(provider)); + } + getAddress() { + return this.signer.getAddress(); + } + getTransactionCount(blockTag) { + if (blockTag === "pending") { + if (!this._transactionCount) { + this._transactionCount = this.signer.getTransactionCount("pending"); + } + return this._transactionCount; + } + return this.signer.getTransactionCount(blockTag); + } + setTransactionCount(transactionCount) { + this._transactionCount = Promise.resolve(transactionCount).then((nonce) => { + return ethers.BigNumber.from(nonce).toNumber(); + }); + } + incrementTransactionCount(count) { + if (!count) { + count = 1; + } + this._transactionCount = this.getTransactionCount("pending").then((nonce) => { + return nonce + count; + }); + } + signMessage(message) { + return this.signer.signMessage(message); + ; + } + signTransaction(transaction) { + return this.signer.signTransaction(transaction); + } + sendTransaction(transaction) { + if (transaction.nonce == null) { + transaction = ethers.utils.shallowCopy(transaction); + transaction.nonce = this.getTransactionCount(); + } + this.setTransactionCount(transaction.nonce); + return this.signer.sendTransaction(transaction); + } +} diff --git a/packages/experimental/retry-provider.d.ts b/packages/experimental/lib.esm/retry-provider.d.ts similarity index 100% rename from packages/experimental/retry-provider.d.ts rename to packages/experimental/lib.esm/retry-provider.d.ts diff --git a/packages/experimental/lib.esm/retry-provider.js b/packages/experimental/lib.esm/retry-provider.js new file mode 100644 index 000000000..c17d36a30 --- /dev/null +++ b/packages/experimental/lib.esm/retry-provider.js @@ -0,0 +1,27 @@ +"use strict"; +// RetryProvider +// +// Wraps an existing Provider to provide retry logic. +// +// See: https://github.com/ethers-io/ethers.js/issues/427 +import { ethers } from "ethers"; +import { poll } from "@ethersproject/web"; +import { version } from "./_version"; +const logger = new ethers.utils.Logger(version); +export class RetryProvider extends ethers.providers.BaseProvider { + constructor(provider, options) { + logger.checkNew(new.target, RetryProvider); + super(provider.getNetwork()); + ethers.utils.defineReadOnly(this, "provider", provider); + ethers.utils.defineReadOnly(this, "options", options || {}); + } + perform(method, params) { + return poll(() => { + return this.provider.perform(method, params).then((result) => { + return result; + }, (error) => { + return undefined; + }); + }, this.options); + } +} diff --git a/packages/experimental/lib/_version.d.ts b/packages/experimental/lib/_version.d.ts new file mode 100644 index 000000000..072ebea41 --- /dev/null +++ b/packages/experimental/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "experimental/5.0.0-beta.128"; diff --git a/packages/experimental/_version.js b/packages/experimental/lib/_version.js similarity index 100% rename from packages/experimental/_version.js rename to packages/experimental/lib/_version.js diff --git a/packages/experimental/lib/brain-wallet.d.ts b/packages/experimental/lib/brain-wallet.d.ts new file mode 100644 index 000000000..b861543a9 --- /dev/null +++ b/packages/experimental/lib/brain-wallet.d.ts @@ -0,0 +1,6 @@ +import { ethers } from "ethers"; +export declare class BrainWallet extends ethers.Wallet { + static _generate(username: ethers.Bytes | string, password: ethers.Bytes | string, legacy: boolean, progressCallback?: ethers.utils.ProgressCallback): Promise; + static generate(username: ethers.Bytes | string, password: ethers.Bytes | string, progressCallback?: ethers.utils.ProgressCallback): Promise; + static generateLegacy(username: ethers.Bytes | string, password: ethers.Bytes | string, progressCallback?: ethers.utils.ProgressCallback): Promise; +} diff --git a/packages/experimental/brain-wallet.js b/packages/experimental/lib/brain-wallet.js similarity index 100% rename from packages/experimental/brain-wallet.js rename to packages/experimental/lib/brain-wallet.js diff --git a/packages/providers/browser-ipc-provider.d.ts b/packages/experimental/lib/index.d.ts similarity index 100% rename from packages/providers/browser-ipc-provider.d.ts rename to packages/experimental/lib/index.d.ts diff --git a/packages/experimental/lib/index.js b/packages/experimental/lib/index.js new file mode 100644 index 000000000..3918c74e4 --- /dev/null +++ b/packages/experimental/lib/index.js @@ -0,0 +1 @@ +"use strict"; diff --git a/packages/experimental/lib/metamask-provider.d.ts b/packages/experimental/lib/metamask-provider.d.ts new file mode 100644 index 000000000..4b134d4c9 --- /dev/null +++ b/packages/experimental/lib/metamask-provider.d.ts @@ -0,0 +1,12 @@ +import { ethers } from "ethers"; +export declare class MetamaskProvider extends ethers.providers.Web3Provider { + _pollingAccount: any; + _pollAccountFunc: () => void; + constructor(ethereum?: ethers.providers.AsyncSendable); + getSigner(addressOrIndex?: string | number): ethers.providers.JsonRpcSigner; + readonly enabled: boolean; + _startPollingAccount(): void; + _stopPollingAccount(): void; + on(eventName: ethers.providers.EventType, listener: ethers.providers.Listener): this; + off(eventName: ethers.providers.EventType, listener?: ethers.providers.Listener): this; +} diff --git a/packages/experimental/metamask-provider.js b/packages/experimental/lib/metamask-provider.js similarity index 100% rename from packages/experimental/metamask-provider.js rename to packages/experimental/lib/metamask-provider.js diff --git a/packages/experimental/lib/nonce-manager.d.ts b/packages/experimental/lib/nonce-manager.d.ts new file mode 100644 index 000000000..ae4a19d69 --- /dev/null +++ b/packages/experimental/lib/nonce-manager.d.ts @@ -0,0 +1,15 @@ +import { ethers } from "ethers"; +export declare class NonceManager extends ethers.Signer { + readonly signer: ethers.Signer; + readonly provider: ethers.providers.Provider; + _transactionCount: Promise; + constructor(signer: ethers.Signer); + connect(provider: ethers.providers.Provider): NonceManager; + getAddress(): Promise; + getTransactionCount(blockTag?: ethers.providers.BlockTag): Promise; + setTransactionCount(transactionCount: ethers.BigNumberish | Promise): void; + incrementTransactionCount(count?: number): void; + signMessage(message: ethers.Bytes | string): Promise; + signTransaction(transaction: ethers.providers.TransactionRequest): Promise; + sendTransaction(transaction: ethers.providers.TransactionRequest): Promise; +} diff --git a/packages/experimental/nonce-manager.js b/packages/experimental/lib/nonce-manager.js similarity index 100% rename from packages/experimental/nonce-manager.js rename to packages/experimental/lib/nonce-manager.js diff --git a/packages/experimental/lib/retry-provider.d.ts b/packages/experimental/lib/retry-provider.d.ts new file mode 100644 index 000000000..73a0f1bf4 --- /dev/null +++ b/packages/experimental/lib/retry-provider.d.ts @@ -0,0 +1,14 @@ +import { ethers } from "ethers"; +export declare type RetryOptions = { + timeout?: number; + floor?: number; + ceiling?: number; + interval?: number; + retryLimit?: number; +}; +export declare class RetryProvider extends ethers.providers.BaseProvider { + readonly provider: ethers.providers.BaseProvider; + readonly options: RetryOptions; + constructor(provider: ethers.providers.BaseProvider, options?: RetryOptions); + perform(method: string, params: any): Promise; +} diff --git a/packages/experimental/retry-provider.js b/packages/experimental/lib/retry-provider.js similarity index 100% rename from packages/experimental/retry-provider.js rename to packages/experimental/lib/retry-provider.js diff --git a/packages/experimental/package.json b/packages/experimental/package.json index 2995754a1..9c68fabcd 100644 --- a/packages/experimental/package.json +++ b/packages/experimental/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/experimental", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Experimental libraries for ethers. These should not be considered stable.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -24,5 +24,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x421b677f833795c78c1169e3f9c9ee1a5cd2759deae4b6481e0fd175648c85d1" + "module": "./lib.esm/index.js", + "tarballHash": "0xf5f098266abb3959cec1221ea114f9c9f4330440fd0ebe1e0993961c576675f8" } diff --git a/packages/experimental/tsconfig.json b/packages/experimental/tsconfig.json index f09aa6ba8..cf84c4c52 100644 --- a/packages/experimental/tsconfig.json +++ b/packages/experimental/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts", - "./thirdparty.d.ts" + "./src.ts/*.ts", + "./thirdparty.d.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/hash/_version.d.ts b/packages/hash/lib.esm/_version.d.ts similarity index 100% rename from packages/hash/_version.d.ts rename to packages/hash/lib.esm/_version.d.ts diff --git a/packages/hash/lib.esm/_version.js b/packages/hash/lib.esm/_version.js new file mode 100644 index 000000000..a66c6a899 --- /dev/null +++ b/packages/hash/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "hash/5.0.0-beta.127"; diff --git a/packages/hash/index.d.ts b/packages/hash/lib.esm/index.d.ts similarity index 100% rename from packages/hash/index.d.ts rename to packages/hash/lib.esm/index.d.ts diff --git a/packages/hash/lib.esm/index.js b/packages/hash/lib.esm/index.js new file mode 100644 index 000000000..2be26f038 --- /dev/null +++ b/packages/hash/lib.esm/index.js @@ -0,0 +1,50 @@ +"use strict"; +import { concat, hexlify } from "@ethersproject/bytes"; +import { nameprep, toUtf8Bytes } from "@ethersproject/strings"; +import { keccak256 } from "@ethersproject/keccak256"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +/////////////////////////////// +const Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); +const Partition = new RegExp("^((.*)\\.)?([^.]+)$"); +export function isValidName(name) { + try { + let comps = name.split("."); + for (let i = 0; i < comps.length; i++) { + if (nameprep(comps[i]).length === 0) { + throw new Error("empty"); + } + } + return true; + } + catch (error) { } + return false; +} +export function namehash(name) { + if (typeof (name) !== "string") { + logger.throwArgumentError("invalid address - " + String(name), "name", name); + } + let result = Zeros; + while (name.length) { + let partition = name.match(Partition); + let label = toUtf8Bytes(nameprep(partition[3])); + result = keccak256(concat([result, keccak256(label)])); + name = partition[2] || ""; + } + return hexlify(result); +} +export function id(text) { + return keccak256(toUtf8Bytes(text)); +} +export const messagePrefix = "\x19Ethereum Signed Message:\n"; +export function hashMessage(message) { + if (typeof (message) === "string") { + message = toUtf8Bytes(message); + } + return keccak256(concat([ + toUtf8Bytes(messagePrefix), + toUtf8Bytes(String(message.length)), + message + ])); +} diff --git a/packages/hash/lib/_version.d.ts b/packages/hash/lib/_version.d.ts new file mode 100644 index 000000000..b9919e883 --- /dev/null +++ b/packages/hash/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "hash/5.0.0-beta.127"; diff --git a/packages/hash/_version.js b/packages/hash/lib/_version.js similarity index 100% rename from packages/hash/_version.js rename to packages/hash/lib/_version.js diff --git a/packages/hash/lib/index.d.ts b/packages/hash/lib/index.d.ts new file mode 100644 index 000000000..0579db169 --- /dev/null +++ b/packages/hash/lib/index.d.ts @@ -0,0 +1,6 @@ +import { Bytes } from "@ethersproject/bytes"; +export declare function isValidName(name: string): boolean; +export declare function namehash(name: string): string; +export declare function id(text: string): string; +export declare const messagePrefix = "\u0019Ethereum Signed Message:\n"; +export declare function hashMessage(message: Bytes | string): string; diff --git a/packages/hash/index.js b/packages/hash/lib/index.js similarity index 100% rename from packages/hash/index.js rename to packages/hash/lib/index.js diff --git a/packages/hash/package.json b/packages/hash/package.json index 63f3b8a2b..03ad1116a 100644 --- a/packages/hash/package.json +++ b/packages/hash/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/hash", - "version": "5.0.0-beta.127", + "version": "5.0.0-beta.128", "description": "Hash utility functions for Ethereum.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -25,5 +25,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xddf38c1b1871553459c36253a18b6e47ef5478b6f2da69b1a192a5e3f74d19bc" + "module": "./lib.esm/index.js", + "tarballHash": "0x94e31ec73b1932a42dd0ddd31c4684252d8306336f04ad6c20d6fe99e6723e05" } diff --git a/packages/hash/tsconfig.json b/packages/hash/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/hash/tsconfig.json +++ b/packages/hash/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/hdnode/_version.d.ts b/packages/hdnode/lib.esm/_version.d.ts similarity index 100% rename from packages/hdnode/_version.d.ts rename to packages/hdnode/lib.esm/_version.d.ts diff --git a/packages/hdnode/lib.esm/_version.js b/packages/hdnode/lib.esm/_version.js new file mode 100644 index 000000000..055f90480 --- /dev/null +++ b/packages/hdnode/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "hdnode/5.0.0-beta.129"; diff --git a/packages/hdnode/index.d.ts b/packages/hdnode/lib.esm/index.d.ts similarity index 100% rename from packages/hdnode/index.d.ts rename to packages/hdnode/lib.esm/index.d.ts diff --git a/packages/hdnode/lib.esm/index.js b/packages/hdnode/lib.esm/index.js new file mode 100644 index 000000000..0494c10e4 --- /dev/null +++ b/packages/hdnode/lib.esm/index.js @@ -0,0 +1,288 @@ +"use strict"; +import { Base58 } from "@ethersproject/basex"; +import { arrayify, concat, hexDataSlice, hexZeroPad, hexlify } from "@ethersproject/bytes"; +import { BigNumber } from "@ethersproject/bignumber"; +import { toUtf8Bytes, UnicodeNormalizationForm } from "@ethersproject/strings"; +import { pbkdf2 } from "@ethersproject/pbkdf2"; +import { defineReadOnly } from "@ethersproject/properties"; +import { SigningKey } from "@ethersproject/signing-key"; +import { computeHmac, ripemd160, sha256, SupportedAlgorithms } from "@ethersproject/sha2"; +import { computeAddress } from "@ethersproject/transactions"; +import { wordlists } from "@ethersproject/wordlists"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +const N = BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); +// "Bitcoin seed" +const MasterSecret = toUtf8Bytes("Bitcoin seed"); +const HardenedBit = 0x80000000; +// Returns a byte with the MSB bits set +function getUpperMask(bits) { + return ((1 << bits) - 1) << (8 - bits); +} +// Returns a byte with the LSB bits set +function getLowerMask(bits) { + return (1 << bits) - 1; +} +function bytes32(value) { + return hexZeroPad(hexlify(value), 32); +} +function base58check(data) { + let checksum = hexDataSlice(sha256(sha256(data)), 0, 4); + return Base58.encode(concat([data, checksum])); +} +const _constructorGuard = {}; +export const defaultPath = "m/44'/60'/0'/0/0"; +export class HDNode { + /** + * This constructor should not be called directly. + * + * Please use: + * - fromMnemonic + * - fromSeed + */ + constructor(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) { + logger.checkNew(new.target, HDNode); + if (constructorGuard !== _constructorGuard) { + throw new Error("HDNode constructor cannot be called directly"); + } + if (privateKey) { + let signingKey = new SigningKey(privateKey); + defineReadOnly(this, "privateKey", signingKey.privateKey); + defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); + } + else { + defineReadOnly(this, "privateKey", null); + defineReadOnly(this, "publicKey", hexlify(publicKey)); + } + defineReadOnly(this, "parentFingerprint", parentFingerprint); + defineReadOnly(this, "fingerprint", hexDataSlice(ripemd160(sha256(this.publicKey)), 0, 4)); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + defineReadOnly(this, "chainCode", chainCode); + defineReadOnly(this, "index", index); + defineReadOnly(this, "depth", depth); + defineReadOnly(this, "mnemonic", mnemonic); + defineReadOnly(this, "path", path); + } + get extendedKey() { + // We only support the mainnet values for now, but if anyone needs + // testnet values, let me know. I believe current senitment is that + // we should always use mainnet, and use BIP-44 to derive the network + // - Mainnet: public=0x0488B21E, private=0x0488ADE4 + // - Testnet: public=0x043587CF, private=0x04358394 + if (this.depth >= 256) { + throw new Error("Depth too large!"); + } + return base58check(concat([ + ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"), + hexlify(this.depth), + this.parentFingerprint, + hexZeroPad(hexlify(this.index), 4), + this.chainCode, + ((this.privateKey != null) ? concat(["0x00", this.privateKey]) : this.publicKey), + ])); + } + neuter() { + return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, null, this.path); + } + _derive(index) { + if (index > 0xffffffff) { + throw new Error("invalid index - " + String(index)); + } + // Base path + let path = this.path; + if (path) { + path += "/" + (index & ~HardenedBit); + } + let data = new Uint8Array(37); + if (index & HardenedBit) { + if (!this.privateKey) { + throw new Error("cannot derive child of neutered node"); + } + // Data = 0x00 || ser_256(k_par) + data.set(arrayify(this.privateKey), 1); + // Hardened path + if (path) { + path += "'"; + } + } + else { + // Data = ser_p(point(k_par)) + data.set(arrayify(this.publicKey)); + } + // Data += ser_32(i) + for (let i = 24; i >= 0; i -= 8) { + data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); + } + let I = arrayify(computeHmac(SupportedAlgorithms.sha512, this.chainCode, data)); + let IL = I.slice(0, 32); + let IR = I.slice(32); + // The private key + let ki = null; + // The public key + let Ki = null; + if (this.privateKey) { + ki = bytes32(BigNumber.from(IL).add(this.privateKey).mod(N)); + } + else { + let ek = new SigningKey(hexlify(IL)); + Ki = ek._addPoint(this.publicKey); + } + return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); + } + derivePath(path) { + let components = path.split("/"); + if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) { + throw new Error("invalid path - " + path); + } + if (components[0] === "m") { + components.shift(); + } + let result = this; + for (let i = 0; i < components.length; i++) { + let component = components[i]; + if (component.match(/^[0-9]+'$/)) { + let index = parseInt(component.substring(0, component.length - 1)); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(HardenedBit + index); + } + else if (component.match(/^[0-9]+$/)) { + let index = parseInt(component); + if (index >= HardenedBit) { + throw new Error("invalid path index - " + component); + } + result = result._derive(index); + } + else { + throw new Error("invlaid path component - " + component); + } + } + return result; + } + static _fromSeed(seed, mnemonic) { + let seedArray = arrayify(seed); + if (seedArray.length < 16 || seedArray.length > 64) { + throw new Error("invalid seed"); + } + let I = arrayify(computeHmac(SupportedAlgorithms.sha512, MasterSecret, seedArray)); + return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); + } + static fromMnemonic(mnemonic, password, wordlist) { + // Normalize the case and spacing in the mnemonic (throws if the mnemonic is invalid) + mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist); + return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), mnemonic); + } + static fromSeed(seed) { + return HDNode._fromSeed(seed, null); + } + static fromExtendedKey(extendedKey) { + let bytes = Base58.decode(extendedKey); + if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { + logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); + } + let depth = bytes[4]; + let parentFingerprint = hexlify(bytes.slice(5, 9)); + let index = parseInt(hexlify(bytes.slice(9, 13)).substring(2), 16); + let chainCode = hexlify(bytes.slice(13, 45)); + let key = bytes.slice(45, 78); + switch (hexlify(bytes.slice(0, 4))) { + // Public Key + case "0x0488b21e": + case "0x043587cf": + return new HDNode(_constructorGuard, null, hexlify(key), parentFingerprint, chainCode, index, depth, null, null); + // Private Key + case "0x0488ade4": + case "0x04358394 ": + if (key[0] !== 0) { + break; + } + return new HDNode(_constructorGuard, hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); + } + return logger.throwError("invalid extended key", "extendedKey", "[REDACTED]"); + } +} +export function mnemonicToSeed(mnemonic, password) { + if (!password) { + password = ""; + } + let salt = toUtf8Bytes("mnemonic" + password, UnicodeNormalizationForm.NFKD); + return pbkdf2(toUtf8Bytes(mnemonic, UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); +} +export function mnemonicToEntropy(mnemonic, wordlist) { + if (!wordlist) { + wordlist = wordlists["en"]; + } + logger.checkNormalize(); + let words = wordlist.split(mnemonic); + if ((words.length % 3) !== 0) { + throw new Error("invalid mnemonic"); + } + let entropy = arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); + let offset = 0; + for (let i = 0; i < words.length; i++) { + let index = wordlist.getWordIndex(words[i].normalize("NFKD")); + if (index === -1) { + throw new Error("invalid mnemonic"); + } + for (let bit = 0; bit < 11; bit++) { + if (index & (1 << (10 - bit))) { + entropy[offset >> 3] |= (1 << (7 - (offset % 8))); + } + offset++; + } + } + let entropyBits = 32 * words.length / 3; + let checksumBits = words.length / 3; + let checksumMask = getUpperMask(checksumBits); + let checksum = arrayify(sha256(entropy.slice(0, entropyBits / 8)))[0]; + checksum &= checksumMask; + if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { + throw new Error("invalid checksum"); + } + return hexlify(entropy.slice(0, entropyBits / 8)); +} +export function entropyToMnemonic(entropy, wordlist) { + entropy = arrayify(entropy); + if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { + throw new Error("invalid entropy"); + } + let indices = [0]; + let remainingBits = 11; + for (let i = 0; i < entropy.length; i++) { + // Consume the whole byte (with still more to go) + if (remainingBits > 8) { + indices[indices.length - 1] <<= 8; + indices[indices.length - 1] |= entropy[i]; + remainingBits -= 8; + // This byte will complete an 11-bit index + } + else { + indices[indices.length - 1] <<= remainingBits; + indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); + // Start the next word + indices.push(entropy[i] & getLowerMask(8 - remainingBits)); + remainingBits += 3; + } + } + // Compute the checksum bits + let checksum = arrayify(sha256(entropy))[0]; + let checksumBits = entropy.length / 4; + checksum &= getUpperMask(checksumBits); + // Shift the checksum into the word indices + indices[indices.length - 1] <<= checksumBits; + indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); + if (!wordlist) { + wordlist = wordlists["en"]; + } + return wordlist.join(indices.map((index) => wordlist.getWord(index))); +} +export function isValidMnemonic(mnemonic, wordlist) { + try { + mnemonicToEntropy(mnemonic, wordlist); + return true; + } + catch (error) { } + return false; +} diff --git a/packages/hdnode/lib/_version.d.ts b/packages/hdnode/lib/_version.d.ts new file mode 100644 index 000000000..23866ebd5 --- /dev/null +++ b/packages/hdnode/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "hdnode/5.0.0-beta.129"; diff --git a/packages/hdnode/_version.js b/packages/hdnode/lib/_version.js similarity index 100% rename from packages/hdnode/_version.js rename to packages/hdnode/lib/_version.js diff --git a/packages/hdnode/lib/index.d.ts b/packages/hdnode/lib/index.d.ts new file mode 100644 index 000000000..d9ce67190 --- /dev/null +++ b/packages/hdnode/lib/index.d.ts @@ -0,0 +1,36 @@ +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { BytesLike } from "@ethersproject/bytes"; +import { Wordlist } from "@ethersproject/wordlists"; +export declare const defaultPath = "m/44'/60'/0'/0/0"; +export declare class HDNode implements ExternallyOwnedAccount { + readonly privateKey: string; + readonly publicKey: string; + readonly fingerprint: string; + readonly parentFingerprint: string; + readonly address: string; + readonly mnemonic: string; + readonly path: string; + readonly chainCode: string; + readonly index: number; + readonly depth: number; + /** + * This constructor should not be called directly. + * + * Please use: + * - fromMnemonic + * - fromSeed + */ + constructor(constructorGuard: any, privateKey: string, publicKey: string, parentFingerprint: string, chainCode: string, index: number, depth: number, mnemonic: string, path: string); + readonly extendedKey: string; + neuter(): HDNode; + private _derive; + derivePath(path: string): HDNode; + static _fromSeed(seed: BytesLike, mnemonic: string): HDNode; + static fromMnemonic(mnemonic: string, password?: string, wordlist?: Wordlist): HDNode; + static fromSeed(seed: BytesLike): HDNode; + static fromExtendedKey(extendedKey: string): HDNode; +} +export declare function mnemonicToSeed(mnemonic: string, password?: string): string; +export declare function mnemonicToEntropy(mnemonic: string, wordlist?: Wordlist): string; +export declare function entropyToMnemonic(entropy: BytesLike, wordlist?: Wordlist): string; +export declare function isValidMnemonic(mnemonic: string, wordlist?: Wordlist): boolean; diff --git a/packages/hdnode/index.js b/packages/hdnode/lib/index.js similarity index 100% rename from packages/hdnode/index.js rename to packages/hdnode/lib/index.js diff --git a/packages/hdnode/package.json b/packages/hdnode/package.json index fa8d3cfe5..34b7772e2 100644 --- a/packages/hdnode/package.json +++ b/packages/hdnode/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/hdnode", - "version": "5.0.0-beta.129", + "version": "5.0.0-beta.130", "description": "BIP32 Hierarchal Deterministic Node operations.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -33,5 +33,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xf55e5e184af14dbf060b53a66e6ba0de92af1882deebcb990c06df5aa8697d33" + "module": "./lib.esm/index.js", + "tarballHash": "0x2b740d2841d6666fdbed43d6bd35217d731e93ca51761a5e710140a230f7b159" } diff --git a/packages/hdnode/tsconfig.json b/packages/hdnode/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/hdnode/tsconfig.json +++ b/packages/hdnode/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/json-wallets/_version.d.ts b/packages/json-wallets/lib.esm/_version.d.ts similarity index 100% rename from packages/json-wallets/_version.d.ts rename to packages/json-wallets/lib.esm/_version.d.ts diff --git a/packages/json-wallets/lib.esm/_version.js b/packages/json-wallets/lib.esm/_version.js new file mode 100644 index 000000000..c85b2d28e --- /dev/null +++ b/packages/json-wallets/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "json-wallets/5.0.0-beta.128"; diff --git a/packages/json-wallets/crowdsale.d.ts b/packages/json-wallets/lib.esm/crowdsale.d.ts similarity index 100% rename from packages/json-wallets/crowdsale.d.ts rename to packages/json-wallets/lib.esm/crowdsale.d.ts diff --git a/packages/json-wallets/lib.esm/crowdsale.js b/packages/json-wallets/lib.esm/crowdsale.js new file mode 100644 index 000000000..71b6c9ef6 --- /dev/null +++ b/packages/json-wallets/lib.esm/crowdsale.js @@ -0,0 +1,48 @@ +"use strict"; +import aes from "aes-js"; +import { getAddress } from "@ethersproject/address"; +import { arrayify } from "@ethersproject/bytes"; +import { keccak256 } from "@ethersproject/keccak256"; +import { pbkdf2 } from "@ethersproject/pbkdf2"; +import { toUtf8Bytes } from "@ethersproject/strings"; +import { Description } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { getPassword, looseArrayify, searchPath } from "./utils"; +export class CrowdsaleAccount extends Description { + isCrowdsaleAccount(value) { + return !!(value && value._isCrowdsaleAccount); + } +} +// See: https://github.com/ethereum/pyethsaletool +export function decrypt(json, password) { + let data = JSON.parse(json); + password = getPassword(password); + // Ethereum Address + let ethaddr = getAddress(searchPath(data, "ethaddr")); + // Encrypted Seed + let encseed = looseArrayify(searchPath(data, "encseed")); + if (!encseed || (encseed.length % 16) !== 0) { + logger.throwArgumentError("invalid encseed", "json", json); + } + let key = arrayify(pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); + let iv = encseed.slice(0, 16); + let encryptedSeed = encseed.slice(16); + // Decrypt the seed + let aesCbc = new aes.ModeOfOperation.cbc(key, iv); + let seed = arrayify(aesCbc.decrypt(encryptedSeed)); + seed = aes.padding.pkcs7.strip(seed); + // This wallet format is weird... Convert the binary encoded hex to a string. + let seedHex = ""; + for (let i = 0; i < seed.length; i++) { + seedHex += String.fromCharCode(seed[i]); + } + let seedHexBytes = toUtf8Bytes(seedHex); + let privateKey = keccak256(seedHexBytes); + return new CrowdsaleAccount({ + _isCrowdsaleAccount: true, + address: ethaddr, + privateKey: privateKey + }); +} diff --git a/packages/json-wallets/index.d.ts b/packages/json-wallets/lib.esm/index.d.ts similarity index 100% rename from packages/json-wallets/index.d.ts rename to packages/json-wallets/lib.esm/index.d.ts diff --git a/packages/json-wallets/lib.esm/index.js b/packages/json-wallets/lib.esm/index.js new file mode 100644 index 000000000..4429f3773 --- /dev/null +++ b/packages/json-wallets/lib.esm/index.js @@ -0,0 +1,21 @@ +"use strict"; +import { decrypt as decryptCrowdsale } from "./crowdsale"; +import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect"; +import { decrypt as decryptKeystore, encrypt as encryptKeystore } from "./keystore"; +function decryptJsonWallet(json, password, progressCallback) { + if (isCrowdsaleWallet(json)) { + if (progressCallback) { + progressCallback(0); + } + let account = decryptCrowdsale(json, password); + if (progressCallback) { + progressCallback(1); + } + return Promise.resolve(account); + } + if (isKeystoreWallet(json)) { + return decryptKeystore(json, password, progressCallback); + } + return Promise.reject(new Error("invalid JSON wallet")); +} +export { decryptCrowdsale, decryptKeystore, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, }; diff --git a/packages/json-wallets/inspect.d.ts b/packages/json-wallets/lib.esm/inspect.d.ts similarity index 100% rename from packages/json-wallets/inspect.d.ts rename to packages/json-wallets/lib.esm/inspect.d.ts diff --git a/packages/json-wallets/lib.esm/inspect.js b/packages/json-wallets/lib.esm/inspect.js new file mode 100644 index 000000000..a77d1ecf1 --- /dev/null +++ b/packages/json-wallets/lib.esm/inspect.js @@ -0,0 +1,48 @@ +"use strict"; +import { getAddress } from "@ethersproject/address"; +export function isCrowdsaleWallet(json) { + let data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + return (data.encseed && data.ethaddr); +} +export function isKeystoreWallet(json) { + let data = null; + try { + data = JSON.parse(json); + } + catch (error) { + return false; + } + if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { + return false; + } + // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff + return true; +} +//export function isJsonWallet(json: string): boolean { +// return (isSecretStorageWallet(json) || isCrowdsaleWallet(json)); +//} +export function getJsonWalletAddress(json) { + if (isCrowdsaleWallet(json)) { + try { + return getAddress(JSON.parse(json).ethaddr); + } + catch (error) { + return null; + } + } + if (isKeystoreWallet(json)) { + try { + return getAddress(JSON.parse(json).address); + } + catch (error) { + return null; + } + } + return null; +} diff --git a/packages/json-wallets/keystore.d.ts b/packages/json-wallets/lib.esm/keystore.d.ts similarity index 100% rename from packages/json-wallets/keystore.d.ts rename to packages/json-wallets/lib.esm/keystore.d.ts diff --git a/packages/json-wallets/lib.esm/keystore.js b/packages/json-wallets/lib.esm/keystore.js new file mode 100644 index 000000000..64210ab1e --- /dev/null +++ b/packages/json-wallets/lib.esm/keystore.js @@ -0,0 +1,332 @@ +"use strict"; +import aes from "aes-js"; +import scrypt from "scrypt-js"; +import uuid from "uuid"; +import { getAddress } from "@ethersproject/address"; +import { arrayify, concat, hexlify } from "@ethersproject/bytes"; +import { defaultPath, entropyToMnemonic, HDNode, mnemonicToEntropy } from "@ethersproject/hdnode"; +import { keccak256 } from "@ethersproject/keccak256"; +import { pbkdf2 } from "@ethersproject/pbkdf2"; +import { randomBytes } from "@ethersproject/random"; +import { Description } from "@ethersproject/properties"; +import { computeAddress } from "@ethersproject/transactions"; +import { getPassword, looseArrayify, searchPath, zpad } from "./utils"; +// Exported Types +export class KeystoreAccount extends Description { + isKeystoreAccount(value) { + return !!(value && value._isKeystoreAccount); + } +} +export function decrypt(json, password, progressCallback) { + let data = JSON.parse(json); + let passwordBytes = getPassword(password); + let decrypt = function (key, ciphertext) { + let cipher = searchPath(data, "crypto/cipher"); + if (cipher === "aes-128-ctr") { + let iv = looseArrayify(searchPath(data, "crypto/cipherparams/iv")); + let counter = new aes.Counter(iv); + let aesCtr = new aes.ModeOfOperation.ctr(key, counter); + return arrayify(aesCtr.decrypt(ciphertext)); + } + return null; + }; + let computeMAC = function (derivedHalf, ciphertext) { + return keccak256(concat([derivedHalf, ciphertext])); + }; + let getAccount = function (key, reject) { + let ciphertext = looseArrayify(searchPath(data, "crypto/ciphertext")); + let computedMAC = hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); + if (computedMAC !== searchPath(data, "crypto/mac").toLowerCase()) { + reject(new Error("invalid password")); + return null; + } + let privateKey = decrypt(key.slice(0, 16), ciphertext); + let mnemonicKey = key.slice(32, 64); + if (!privateKey) { + reject(new Error("unsupported cipher")); + return null; + } + let address = computeAddress(privateKey); + if (data.address) { + let check = data.address.toLowerCase(); + if (check.substring(0, 2) !== "0x") { + check = "0x" + check; + } + try { + if (getAddress(check) !== address) { + reject(new Error("address mismatch")); + return null; + } + } + catch (e) { } + } + let account = { + _isKeystoreAccount: true, + address: address, + privateKey: hexlify(privateKey) + }; + // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase + if (searchPath(data, "x-ethers/version") === "0.1") { + let mnemonicCiphertext = looseArrayify(searchPath(data, "x-ethers/mnemonicCiphertext")); + let mnemonicIv = looseArrayify(searchPath(data, "x-ethers/mnemonicCounter")); + let mnemonicCounter = new aes.Counter(mnemonicIv); + let mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + let path = searchPath(data, "x-ethers/path") || defaultPath; + let entropy = arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); + let mnemonic = entropyToMnemonic(entropy); + let node = HDNode.fromMnemonic(mnemonic).derivePath(path); + if (node.privateKey != account.privateKey) { + reject(new Error("mnemonic mismatch")); + return null; + } + account.mnemonic = node.mnemonic; + account.path = node.path; + } + return new KeystoreAccount(account); + }; + return new Promise(function (resolve, reject) { + let kdf = searchPath(data, "crypto/kdf"); + if (kdf && typeof (kdf) === "string") { + if (kdf.toLowerCase() === "scrypt") { + let salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); + let N = parseInt(searchPath(data, "crypto/kdfparams/n")); + let r = parseInt(searchPath(data, "crypto/kdfparams/r")); + let p = parseInt(searchPath(data, "crypto/kdfparams/p")); + if (!N || !r || !p) { + reject(new Error("unsupported key-derivation function parameters")); + return; + } + // Make sure N is a power of 2 + if ((N & (N - 1)) !== 0) { + reject(new Error("unsupported key-derivation function parameter value for N")); + return; + } + let dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + if (progressCallback) { + progressCallback(0); + } + scrypt(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = arrayify(key); + let account = getAccount(key, reject); + if (!account) { + return; + } + if (progressCallback) { + progressCallback(1); + } + resolve(account); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + } + else if (kdf.toLowerCase() === "pbkdf2") { + let salt = looseArrayify(searchPath(data, "crypto/kdfparams/salt")); + let prfFunc = null; + let prf = searchPath(data, "crypto/kdfparams/prf"); + if (prf === "hmac-sha256") { + prfFunc = "sha256"; + } + else if (prf === "hmac-sha512") { + prfFunc = "sha512"; + } + else { + reject(new Error("unsupported prf")); + return; + } + let c = parseInt(searchPath(data, "crypto/kdfparams/c")); + let dkLen = parseInt(searchPath(data, "crypto/kdfparams/dklen")); + if (dkLen !== 32) { + reject(new Error("unsupported key-derivation derived-key length")); + return; + } + let key = arrayify(pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); + let account = getAccount(key, reject); + if (!account) { + return; + } + resolve(account); + } + else { + reject(new Error("unsupported key-derivation function")); + } + } + else { + reject(new Error("unsupported key-derivation function")); + } + }); +} +export function encrypt(account, password, options, progressCallback) { + try { + if (getAddress(account.address) !== computeAddress(account.privateKey)) { + throw new Error("address/privateKey mismatch"); + } + if (account.mnemonic != null) { + let node = HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || defaultPath); + if (node.privateKey != account.privateKey) { + throw new Error("mnemonic mismatch"); + } + } + else if (account.path != null) { + throw new Error("cannot specify path without mnemonic"); + } + } + catch (e) { + return Promise.reject(e); + } + // the options are optional, so adjust the call as needed + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (!options) { + options = {}; + } + let privateKey = arrayify(account.privateKey); + let passwordBytes = getPassword(password); + let entropy = null; + let path = account.path; + if (account.mnemonic) { + entropy = arrayify(mnemonicToEntropy(account.mnemonic)); + if (!path) { + path = defaultPath; + } + } + let client = options.client; + if (!client) { + client = "ethers.js"; + } + // Check/generate the salt + let salt = null; + if (options.salt) { + salt = arrayify(options.salt); + } + else { + salt = randomBytes(32); + ; + } + // Override initialization vector + let iv = null; + if (options.iv) { + iv = arrayify(options.iv); + if (iv.length !== 16) { + throw new Error("invalid iv"); + } + } + else { + iv = randomBytes(16); + } + // Override the uuid + let uuidRandom = null; + if (options.uuid) { + uuidRandom = arrayify(options.uuid); + if (uuidRandom.length !== 16) { + throw new Error("invalid uuid"); + } + } + else { + uuidRandom = randomBytes(16); + } + // Override the scrypt password-based key derivation function parameters + let N = (1 << 17), r = 8, p = 1; + if (options.scrypt) { + if (options.scrypt.N) { + N = options.scrypt.N; + } + if (options.scrypt.r) { + r = options.scrypt.r; + } + if (options.scrypt.p) { + p = options.scrypt.p; + } + } + return new Promise(function (resolve, reject) { + if (progressCallback) { + progressCallback(0); + } + // We take 64 bytes: + // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) + // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) + scrypt(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { + if (error) { + error.progress = progress; + reject(error); + } + else if (key) { + key = arrayify(key); + // This will be used to encrypt the wallet (as per Web3 secret storage) + let derivedKey = key.slice(0, 16); + let macPrefix = key.slice(16, 32); + // This will be used to encrypt the mnemonic phrase (if any) + let mnemonicKey = key.slice(32, 64); + // Encrypt the private key + let counter = new aes.Counter(iv); + let aesCtr = new aes.ModeOfOperation.ctr(derivedKey, counter); + let ciphertext = arrayify(aesCtr.encrypt(privateKey)); + // Compute the message authentication code, used to check the password + let mac = keccak256(concat([macPrefix, ciphertext])); + // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition + let data = { + address: account.address.substring(2).toLowerCase(), + id: uuid.v4({ random: uuidRandom }), + version: 3, + Crypto: { + cipher: "aes-128-ctr", + cipherparams: { + iv: hexlify(iv).substring(2), + }, + ciphertext: hexlify(ciphertext).substring(2), + kdf: "scrypt", + kdfparams: { + salt: hexlify(salt).substring(2), + n: N, + dklen: 32, + p: p, + r: r + }, + mac: mac.substring(2) + } + }; + // If we have a mnemonic, encrypt it into the JSON wallet + if (entropy) { + let mnemonicIv = randomBytes(16); + let mnemonicCounter = new aes.Counter(mnemonicIv); + let mnemonicAesCtr = new aes.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); + let mnemonicCiphertext = arrayify(mnemonicAesCtr.encrypt(entropy)); + let now = new Date(); + let timestamp = (now.getUTCFullYear() + "-" + + zpad(now.getUTCMonth() + 1, 2) + "-" + + zpad(now.getUTCDate(), 2) + "T" + + zpad(now.getUTCHours(), 2) + "-" + + zpad(now.getUTCMinutes(), 2) + "-" + + zpad(now.getUTCSeconds(), 2) + ".0Z"); + data["x-ethers"] = { + client: client, + gethFilename: ("UTC--" + timestamp + "--" + data.address), + mnemonicCounter: hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: hexlify(mnemonicCiphertext).substring(2), + path: path, + version: "0.1" + }; + } + if (progressCallback) { + progressCallback(1); + } + resolve(JSON.stringify(data)); + } + else if (progressCallback) { + return progressCallback(progress); + } + }); + }); +} diff --git a/packages/json-wallets/utils.d.ts b/packages/json-wallets/lib.esm/utils.d.ts similarity index 100% rename from packages/json-wallets/utils.d.ts rename to packages/json-wallets/lib.esm/utils.d.ts diff --git a/packages/json-wallets/lib.esm/utils.js b/packages/json-wallets/lib.esm/utils.js new file mode 100644 index 000000000..cd10efc6a --- /dev/null +++ b/packages/json-wallets/lib.esm/utils.js @@ -0,0 +1,57 @@ +"use strict"; +import { arrayify } from "@ethersproject/bytes"; +//import { Description } from "@ethersproject/properties"; +import { toUtf8Bytes, UnicodeNormalizationForm } from '@ethersproject/strings'; +/* +export class Account extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + +// static isAccount(value: any): value is Account { +// return Description._isType(value); +// } +} +//defineReadOnly(Account, "name", "Account"); +*/ +export function looseArrayify(hexString) { + if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') { + hexString = '0x' + hexString; + } + return arrayify(hexString); +} +export function zpad(value, length) { + value = String(value); + while (value.length < length) { + value = '0' + value; + } + return value; +} +export function getPassword(password) { + if (typeof (password) === 'string') { + return toUtf8Bytes(password, UnicodeNormalizationForm.NFKC); + } + return arrayify(password); +} +export function searchPath(object, path) { + let currentChild = object; + let comps = path.toLowerCase().split('/'); + for (let i = 0; i < comps.length; i++) { + // Search for a child object with a case-insensitive matching key + let matchingChild = null; + for (let key in currentChild) { + if (key.toLowerCase() === comps[i]) { + matchingChild = currentChild[key]; + break; + } + } + // Didn't find one. :'( + if (matchingChild === null) { + return null; + } + // Now check this child... + currentChild = matchingChild; + } + return currentChild; +} diff --git a/packages/json-wallets/lib/_version.d.ts b/packages/json-wallets/lib/_version.d.ts new file mode 100644 index 000000000..da1257b7e --- /dev/null +++ b/packages/json-wallets/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "json-wallets/5.0.0-beta.128"; diff --git a/packages/json-wallets/_version.js b/packages/json-wallets/lib/_version.js similarity index 100% rename from packages/json-wallets/_version.js rename to packages/json-wallets/lib/_version.js diff --git a/packages/json-wallets/lib/crowdsale.d.ts b/packages/json-wallets/lib/crowdsale.d.ts new file mode 100644 index 000000000..974a00da7 --- /dev/null +++ b/packages/json-wallets/lib/crowdsale.d.ts @@ -0,0 +1,12 @@ +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { Bytes } from "@ethersproject/bytes"; +import { Description } from "@ethersproject/properties"; +export declare class CrowdsaleAccount extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + readonly _isCrowdsaleAccount: boolean; + isCrowdsaleAccount(value: any): value is CrowdsaleAccount; +} +export declare function decrypt(json: string, password: Bytes | string): ExternallyOwnedAccount; diff --git a/packages/json-wallets/crowdsale.js b/packages/json-wallets/lib/crowdsale.js similarity index 100% rename from packages/json-wallets/crowdsale.js rename to packages/json-wallets/lib/crowdsale.js diff --git a/packages/json-wallets/lib/index.d.ts b/packages/json-wallets/lib/index.d.ts new file mode 100644 index 000000000..c5430a9f4 --- /dev/null +++ b/packages/json-wallets/lib/index.d.ts @@ -0,0 +1,7 @@ +import { Bytes } from "@ethersproject/bytes"; +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { decrypt as decryptCrowdsale } from "./crowdsale"; +import { getJsonWalletAddress, isCrowdsaleWallet, isKeystoreWallet } from "./inspect"; +import { decrypt as decryptKeystore, encrypt as encryptKeystore, EncryptOptions, ProgressCallback } from "./keystore"; +declare function decryptJsonWallet(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise; +export { decryptCrowdsale, decryptKeystore, encryptKeystore, isCrowdsaleWallet, isKeystoreWallet, getJsonWalletAddress, decryptJsonWallet, ProgressCallback, EncryptOptions, }; diff --git a/packages/json-wallets/index.js b/packages/json-wallets/lib/index.js similarity index 100% rename from packages/json-wallets/index.js rename to packages/json-wallets/lib/index.js diff --git a/packages/json-wallets/lib/inspect.d.ts b/packages/json-wallets/lib/inspect.d.ts new file mode 100644 index 000000000..1912f4b33 --- /dev/null +++ b/packages/json-wallets/lib/inspect.d.ts @@ -0,0 +1,3 @@ +export declare function isCrowdsaleWallet(json: string): boolean; +export declare function isKeystoreWallet(json: string): boolean; +export declare function getJsonWalletAddress(json: string): string; diff --git a/packages/json-wallets/inspect.js b/packages/json-wallets/lib/inspect.js similarity index 100% rename from packages/json-wallets/inspect.js rename to packages/json-wallets/lib/inspect.js diff --git a/packages/json-wallets/lib/keystore.d.ts b/packages/json-wallets/lib/keystore.d.ts new file mode 100644 index 000000000..e5aba86cb --- /dev/null +++ b/packages/json-wallets/lib/keystore.d.ts @@ -0,0 +1,26 @@ +import { ExternallyOwnedAccount } from "@ethersproject/abstract-signer"; +import { Bytes, BytesLike } from "@ethersproject/bytes"; +import { Description } from "@ethersproject/properties"; +export declare class KeystoreAccount extends Description implements ExternallyOwnedAccount { + readonly address: string; + readonly privateKey: string; + readonly mnemonic?: string; + readonly path?: string; + readonly _isKeystoreAccount: boolean; + isKeystoreAccount(value: any): value is KeystoreAccount; +} +export declare type ProgressCallback = (percent: number) => void; +export declare type EncryptOptions = { + iv?: BytesLike; + entropy?: BytesLike; + client?: string; + salt?: BytesLike; + uuid?: string; + scrypt?: { + N?: number; + r?: number; + p?: number; + }; +}; +export declare function decrypt(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise; +export declare function encrypt(account: ExternallyOwnedAccount, password: Bytes | string, options?: EncryptOptions, progressCallback?: ProgressCallback): Promise; diff --git a/packages/json-wallets/keystore.js b/packages/json-wallets/lib/keystore.js similarity index 100% rename from packages/json-wallets/keystore.js rename to packages/json-wallets/lib/keystore.js diff --git a/packages/json-wallets/lib/utils.d.ts b/packages/json-wallets/lib/utils.d.ts new file mode 100644 index 000000000..61a262805 --- /dev/null +++ b/packages/json-wallets/lib/utils.d.ts @@ -0,0 +1,5 @@ +import { Bytes } from "@ethersproject/bytes"; +export declare function looseArrayify(hexString: string): Uint8Array; +export declare function zpad(value: String | number, length: number): String; +export declare function getPassword(password: Bytes | string): Uint8Array; +export declare function searchPath(object: any, path: string): string; diff --git a/packages/json-wallets/utils.js b/packages/json-wallets/lib/utils.js similarity index 100% rename from packages/json-wallets/utils.js rename to packages/json-wallets/lib/utils.js diff --git a/packages/json-wallets/package.json b/packages/json-wallets/package.json index cacad2c92..042b252f6 100644 --- a/packages/json-wallets/package.json +++ b/packages/json-wallets/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/json-wallets", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Wallet management utilities for KeyStore and Crowdsale JSON wallets.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -35,5 +35,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x0b0bb2c6908fb0e54819bb2c5b41a15e7bab4763b782a7e3812d07d7ae69876f" + "module": "./lib.esm/index.js", + "tarballHash": "0xe51c8db7ea4eac9042c499bb95f21eeeb75205133771e2c65f965fcec53446f9" } diff --git a/packages/json-wallets/tsconfig.json b/packages/json-wallets/tsconfig.json index 026fe496a..0a9d2f16c 100644 --- a/packages/json-wallets/tsconfig.json +++ b/packages/json-wallets/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./thirdparty.d.ts", - "./src.ts/*" + "./thirdparty.d.ts", + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/keccak256/_version.d.ts b/packages/keccak256/lib.esm/_version.d.ts similarity index 100% rename from packages/keccak256/_version.d.ts rename to packages/keccak256/lib.esm/_version.d.ts diff --git a/packages/keccak256/lib.esm/_version.js b/packages/keccak256/lib.esm/_version.js new file mode 100644 index 000000000..763f5234a --- /dev/null +++ b/packages/keccak256/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "keccak256/5.0.0-beta.126"; diff --git a/packages/keccak256/index.d.ts b/packages/keccak256/lib.esm/index.d.ts similarity index 100% rename from packages/keccak256/index.d.ts rename to packages/keccak256/lib.esm/index.d.ts diff --git a/packages/keccak256/lib.esm/index.js b/packages/keccak256/lib.esm/index.js new file mode 100644 index 000000000..622e38b62 --- /dev/null +++ b/packages/keccak256/lib.esm/index.js @@ -0,0 +1,6 @@ +"use strict"; +import sha3 from "js-sha3"; +import { arrayify } from "@ethersproject/bytes"; +export function keccak256(data) { + return '0x' + sha3.keccak_256(arrayify(data)); +} diff --git a/packages/keccak256/lib/_version.d.ts b/packages/keccak256/lib/_version.d.ts new file mode 100644 index 000000000..78ab015f5 --- /dev/null +++ b/packages/keccak256/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "keccak256/5.0.0-beta.126"; diff --git a/packages/keccak256/_version.js b/packages/keccak256/lib/_version.js similarity index 100% rename from packages/keccak256/_version.js rename to packages/keccak256/lib/_version.js diff --git a/packages/keccak256/lib/index.d.ts b/packages/keccak256/lib/index.d.ts new file mode 100644 index 000000000..938a22d09 --- /dev/null +++ b/packages/keccak256/lib/index.d.ts @@ -0,0 +1,2 @@ +import { BytesLike } from "@ethersproject/bytes"; +export declare function keccak256(data: BytesLike): string; diff --git a/packages/keccak256/index.js b/packages/keccak256/lib/index.js similarity index 100% rename from packages/keccak256/index.js rename to packages/keccak256/lib/index.js diff --git a/packages/keccak256/package.json b/packages/keccak256/package.json index 9c681cacc..9537e8379 100644 --- a/packages/keccak256/package.json +++ b/packages/keccak256/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/keccak256", - "version": "5.0.0-beta.126", + "version": "5.0.0-beta.127", "description": "The keccak256 hash function for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -23,5 +23,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xf528931c83d037f8211abafdb96cea30b0d60a99a2f450f3bffa2cb7f69d3980" + "module": "./lib.esm/index.js", + "tarballHash": "0x321ddc3fd8264b4555fc6017e46fcd721aaefc45c72d8dfd42259abf2d7af9d1" } diff --git a/packages/keccak256/tsconfig.json b/packages/keccak256/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/keccak256/tsconfig.json +++ b/packages/keccak256/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/logger/_version.d.ts b/packages/logger/lib.esm/_version.d.ts similarity index 100% rename from packages/logger/_version.d.ts rename to packages/logger/lib.esm/_version.d.ts diff --git a/packages/logger/lib.esm/_version.js b/packages/logger/lib.esm/_version.js new file mode 100644 index 000000000..74c859677 --- /dev/null +++ b/packages/logger/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "logger/5.0.0-beta.128"; diff --git a/packages/logger/index.d.ts b/packages/logger/lib.esm/index.d.ts similarity index 100% rename from packages/logger/index.d.ts rename to packages/logger/lib.esm/index.d.ts diff --git a/packages/logger/lib.esm/index.js b/packages/logger/lib.esm/index.js new file mode 100644 index 000000000..db753739a --- /dev/null +++ b/packages/logger/lib.esm/index.js @@ -0,0 +1,264 @@ +"use strict"; +let _permanentCensorErrors = false; +let _censorErrors = false; +const LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; +let LogLevel = LogLevels["default"]; +import { version } from "./_version"; +let _globalLogger = null; +function _checkNormalize() { + try { + let missing = []; + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { + try { + if ("test".normalize(form) !== "test") { + throw new Error("bad normalize"); + } + ; + } + catch (error) { + missing.push(form); + } + }); + if (missing.length) { + throw new Error("missing " + missing.join(", ")); + } + if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { + throw new Error("broken implementation"); + } + } + catch (error) { + return error.message; + } + return null; +} +let _normalizeError = _checkNormalize(); +export class Logger { + constructor(version) { + Object.defineProperty(this, "version", { + enumerable: true, + value: version, + writable: false + }); + } + setLogLevel(logLevel) { + let level = LogLevels[logLevel]; + if (level == null) { + this.warn("invliad log level - " + logLevel); + return; + } + LogLevel = level; + } + _log(logLevel, args) { + if (LogLevel > LogLevels[logLevel]) { + return; + } + console.log.apply(console, args); + } + debug(...args) { + this._log(Logger.levels.DEBUG, args); + } + info(...args) { + this._log(Logger.levels.INFO, args); + } + warn(...args) { + this._log(Logger.levels.WARNING, args); + } + makeError(message, code, params) { + if (_censorErrors) { + return new Error("unknown error"); + } + if (!code) { + code = Logger.errors.UNKNOWN_ERROR; + } + if (!params) { + params = {}; + } + let messageDetails = []; + Object.keys(params).forEach((key) => { + try { + messageDetails.push(key + "=" + JSON.stringify(params[key])); + } + catch (error) { + messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); + } + }); + messageDetails.push("version=" + this.version); + let reason = message; + if (messageDetails.length) { + message += " (" + messageDetails.join(", ") + ")"; + } + // @TODO: Any?? + let error = new Error(message); + error.reason = reason; + error.code = code; + Object.keys(params).forEach(function (key) { + error[key] = params[key]; + }); + return error; + } + throwError(message, code, params) { + throw this.makeError(message, code, params); + } + throwArgumentError(message, name, value) { + return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { + argument: name, + value: value + }); + } + checkNormalize(message) { + if (message == null) { + message = "platform missing String.prototype.normalize"; + } + if (_normalizeError) { + this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "String.prototype.normalize", form: _normalizeError + }); + } + } + checkSafeUint53(value, message) { + if (typeof (value) !== "number") { + return; + } + if (message == null) { + message = "value not safe"; + } + if (value < 0 || value >= 0x1fffffffffffff) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "out-of-safe-range", + value: value + }); + } + if (value % 1) { + this.throwError(message, Logger.errors.NUMERIC_FAULT, { + operation: "checkSafeInteger", + fault: "non-integer", + value: value + }); + } + } + checkArgumentCount(count, expectedCount, message) { + if (message) { + message = ": " + message; + } + else { + message = ""; + } + if (count < expectedCount) { + this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + if (count > expectedCount) { + this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { + count: count, + expectedCount: expectedCount + }); + } + } + checkNew(target, kind) { + if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + } + checkAbstract(target, kind) { + if (target === kind) { + this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); + } + else if (target === Object || target == null) { + this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); + } + } + static globalLogger() { + if (!_globalLogger) { + _globalLogger = new Logger(version); + } + return _globalLogger; + } + static setCensorship(censorship, permanent) { + if (_permanentCensorErrors) { + if (!censorship) { + return; + } + this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "setCensorship" + }); + } + _censorErrors = !!censorship; + _permanentCensorErrors = !!permanent; + } +} +Logger.errors = { + /////////////////// + // Generic Errors + // Unknown Error + UNKNOWN_ERROR: "UNKNOWN_ERROR", + // Not Implemented + NOT_IMPLEMENTED: "NOT_IMPLEMENTED", + // Unsupported Operation + // - operation + UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION", + // Network Error (i.e. Ethereum Network, such as an invalid chain ID) + NETWORK_ERROR: "NETWORK_ERROR", + // Some sort of bad response from the server + SERVER_ERROR: "SERVER_ERROR", + // Timeout + TIMEOUT: "TIMEOUT", + /////////////////// + // Operational Errors + // Buffer Overrun + BUFFER_OVERRUN: "BUFFER_OVERRUN", + // Numeric Fault + // - operation: the operation being executed + // - fault: the reason this faulted + NUMERIC_FAULT: "NUMERIC_FAULT", + /////////////////// + // Argument Errors + // Missing new operator to an object + // - name: The name of the class + MISSING_NEW: "MISSING_NEW", + // Invalid argument (e.g. value is incompatible with type) to a function: + // - argument: The argument name that was invalid + // - value: The value of the argument + INVALID_ARGUMENT: "INVALID_ARGUMENT", + // Missing argument to a function: + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + MISSING_ARGUMENT: "MISSING_ARGUMENT", + // Too many arguments + // - count: The number of arguments received + // - expectedCount: The number of arguments expected + UNEXPECTED_ARGUMENT: "UNEXPECTED_ARGUMENT", + /////////////////// + // Blockchain Errors + // Call exception + // - transaction: the transaction + // - address?: the contract address + // - args?: The arguments passed into the function + // - method?: The Solidity method signature + // - errorSignature?: The EIP848 error signature + // - errorArgs?: The EIP848 error parameters + // - reason: The reason (only for EIP848 "Error(string)") + CALL_EXCEPTION: "CALL_EXCEPTION", + // Insufficien funds (< value + gasLimit * gasPrice) + // - transaction: the transaction attempted + INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS", + // Nonce has already been used + // - transaction: the transaction attempted + NONCE_EXPIRED: "NONCE_EXPIRED", + // The replacement fee for the transaction is too low + // - transaction: the transaction attempted + REPLACEMENT_UNDERPRICED: "REPLACEMENT_UNDERPRICED", + // The gas limit could not be estimated + // - transaction: the transaction passed to estimateGas + UNPREDICTABLE_GAS_LIMIT: "UNPREDICTABLE_GAS_LIMIT", +}; +Logger.levels = { + DEBUG: "DEBUG", + INFO: "INFO", + WARNING: "WARNING", + ERROR: "ERROR", + OFF: "OFF" +}; diff --git a/packages/logger/lib/_version.d.ts b/packages/logger/lib/_version.d.ts new file mode 100644 index 000000000..634b15348 --- /dev/null +++ b/packages/logger/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "logger/5.0.0-beta.128"; diff --git a/packages/logger/_version.js b/packages/logger/lib/_version.js similarity index 100% rename from packages/logger/_version.js rename to packages/logger/lib/_version.js diff --git a/packages/logger/lib/index.d.ts b/packages/logger/lib/index.d.ts new file mode 100644 index 000000000..902ea58b6 --- /dev/null +++ b/packages/logger/lib/index.d.ts @@ -0,0 +1,42 @@ +export declare type LogLevel = "DEBUG" | "INFO" | "WARNING" | "ERROR" | "OFF"; +export declare class Logger { + readonly version: string; + static errors: { + UNKNOWN_ERROR: string; + NOT_IMPLEMENTED: string; + UNSUPPORTED_OPERATION: string; + NETWORK_ERROR: string; + SERVER_ERROR: string; + TIMEOUT: string; + BUFFER_OVERRUN: string; + NUMERIC_FAULT: string; + MISSING_NEW: string; + INVALID_ARGUMENT: string; + MISSING_ARGUMENT: string; + UNEXPECTED_ARGUMENT: string; + CALL_EXCEPTION: string; + INSUFFICIENT_FUNDS: string; + NONCE_EXPIRED: string; + REPLACEMENT_UNDERPRICED: string; + UNPREDICTABLE_GAS_LIMIT: string; + }; + static levels: { + [name: string]: LogLevel; + }; + constructor(version: string); + setLogLevel(logLevel: LogLevel): void; + _log(logLevel: LogLevel, args: Array): void; + debug(...args: Array): void; + info(...args: Array): void; + warn(...args: Array): void; + makeError(message: string, code?: string, params?: any): Error; + throwError(message: string, code?: string, params?: any): never; + throwArgumentError(message: string, name: string, value: any): never; + checkNormalize(message?: string): void; + checkSafeUint53(value: number, message?: string): void; + checkArgumentCount(count: number, expectedCount: number, message?: string): void; + checkNew(target: any, kind: any): void; + checkAbstract(target: any, kind: any): void; + static globalLogger(): Logger; + static setCensorship(censorship: boolean, permanent?: boolean): void; +} diff --git a/packages/logger/index.js b/packages/logger/lib/index.js similarity index 100% rename from packages/logger/index.js rename to packages/logger/lib/index.js diff --git a/packages/logger/package.json b/packages/logger/package.json index ec188042b..0b5c108dd 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/logger", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Logger utility functions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -19,5 +19,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x990706768b6f7427838405daedfa9bde7f8b3a450612c5017b7bff8897c22857" + "module": "./lib.esm/index.js", + "tarballHash": "0xbed8c881ec0bb9bc2aed81dbac8c2bcf51889b7b8caed2053939a1344e402475" } diff --git a/packages/logger/tsconfig.json b/packages/logger/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/logger/tsconfig.json +++ b/packages/logger/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/networks/_version.d.ts b/packages/networks/lib.esm/_version.d.ts similarity index 100% rename from packages/networks/_version.d.ts rename to packages/networks/lib.esm/_version.d.ts diff --git a/packages/networks/lib.esm/_version.js b/packages/networks/lib.esm/_version.js new file mode 100644 index 000000000..4df309230 --- /dev/null +++ b/packages/networks/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "networks/5.0.0-beta.128"; diff --git a/packages/networks/index.d.ts b/packages/networks/lib.esm/index.d.ts similarity index 100% rename from packages/networks/index.d.ts rename to packages/networks/lib.esm/index.d.ts diff --git a/packages/networks/lib.esm/index.js b/packages/networks/lib.esm/index.js new file mode 100644 index 000000000..8e2b21a7b --- /dev/null +++ b/packages/networks/lib.esm/index.js @@ -0,0 +1,171 @@ +"use strict"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +function ethDefaultProvider(network) { + return function (providers, options) { + if (options == null) { + options = {}; + } + let providerList = []; + if (providers.InfuraProvider) { + try { + providerList.push(new providers.InfuraProvider(network, options.infura)); + } + catch (error) { } + } + if (providers.EtherscanProvider) { + try { + providerList.push(new providers.EtherscanProvider(network, options.etherscan)); + } + catch (error) { } + } + if (providers.NodesmithProvider) { + try { + providerList.push(new providers.NodesmithProvider(network, options.nodesmith)); + } + catch (error) { } + } + if (providers.AlchemyProvider) { + try { + providerList.push(new providers.AlchemyProvider(network, options.alchemy)); + } + catch (error) { } + } + if (providers.CloudflareProvider) { + try { + providerList.push(new providers.CloudflareProvider(network)); + } + catch (error) { } + } + if (providerList.length === 0) { + return null; + } + if (providers.FallbackProvider) { + return new providers.FallbackProvider(providerList); + ; + } + return providerList[0]; + }; +} +function etcDefaultProvider(url, network) { + return function (providers, options) { + if (providers.JsonRpcProvider) { + return new providers.JsonRpcProvider(url, network); + } + return null; + }; +} +const homestead = { + chainId: 1, + ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b", + name: "homestead", + _defaultProvider: ethDefaultProvider("homestead") +}; +const ropsten = { + chainId: 3, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "ropsten", + _defaultProvider: ethDefaultProvider("ropsten") +}; +const networks = { + unspecified: { + chainId: 0, + name: "unspecified" + }, + homestead: homestead, + mainnet: homestead, + morden: { + chainId: 2, + name: "morden" + }, + ropsten: ropsten, + testnet: ropsten, + rinkeby: { + chainId: 4, + ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A", + name: "rinkeby", + _defaultProvider: ethDefaultProvider("rinkeby") + }, + kovan: { + chainId: 42, + name: "kovan", + _defaultProvider: ethDefaultProvider("kovan") + }, + goerli: { + chainId: 5, + ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", + name: "goerli", + _defaultProvider: ethDefaultProvider("goerli") + }, + classic: { + chainId: 61, + name: "classic", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io", "classic") + }, + classicTestnet: { + chainId: 62, + name: "classicTestnet", + _defaultProvider: etcDefaultProvider("https://web3.gastracker.io/morden", "classicTestnet") + } +}; +/** + * getNetwork + * + * Converts a named common networks or chain ID (network ID) to a Network + * and verifies a network is a valid Network.. + */ +export function getNetwork(network) { + // No network (null) + if (network == null) { + return null; + } + if (typeof (network) === "number") { + for (let name in networks) { + let standard = networks[name]; + if (standard.chainId === network) { + return { + name: standard.name, + chainId: standard.chainId, + ensAddress: (standard.ensAddress || null), + _defaultProvider: (standard._defaultProvider || null) + }; + } + } + return { + chainId: network, + name: "unknown" + }; + } + if (typeof (network) === "string") { + let standard = networks[network]; + if (standard == null) { + return null; + } + return { + name: standard.name, + chainId: standard.chainId, + ensAddress: standard.ensAddress, + _defaultProvider: (standard._defaultProvider || null) + }; + } + let standard = networks[network.name]; + // Not a standard network; check that it is a valid network in general + if (!standard) { + if (typeof (network.chainId) !== "number") { + logger.throwArgumentError("invalid network chainId", "network", network); + } + return network; + } + // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) + if (network.chainId !== 0 && network.chainId !== standard.chainId) { + logger.throwArgumentError("network chainId mismatch", "network", network); + } + // Standard Network (allow overriding the ENS address) + return { + name: network.name, + chainId: standard.chainId, + ensAddress: (network.ensAddress || standard.ensAddress || null), + _defaultProvider: (network._defaultProvider || standard._defaultProvider || null) + }; +} diff --git a/packages/networks/types.d.ts b/packages/networks/lib.esm/types.d.ts similarity index 100% rename from packages/networks/types.d.ts rename to packages/networks/lib.esm/types.d.ts diff --git a/packages/networks/lib.esm/types.js b/packages/networks/lib.esm/types.js new file mode 100644 index 000000000..3918c74e4 --- /dev/null +++ b/packages/networks/lib.esm/types.js @@ -0,0 +1 @@ +"use strict"; diff --git a/packages/networks/lib/_version.d.ts b/packages/networks/lib/_version.d.ts new file mode 100644 index 000000000..bbc64ab9f --- /dev/null +++ b/packages/networks/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "networks/5.0.0-beta.128"; diff --git a/packages/networks/_version.js b/packages/networks/lib/_version.js similarity index 100% rename from packages/networks/_version.js rename to packages/networks/lib/_version.js diff --git a/packages/networks/lib/index.d.ts b/packages/networks/lib/index.d.ts new file mode 100644 index 000000000..85b25e558 --- /dev/null +++ b/packages/networks/lib/index.d.ts @@ -0,0 +1,9 @@ +import { Network, Networkish } from "./types"; +export { Network, Networkish }; +/** + * getNetwork + * + * Converts a named common networks or chain ID (network ID) to a Network + * and verifies a network is a valid Network.. + */ +export declare function getNetwork(network: Networkish): Network; diff --git a/packages/networks/index.js b/packages/networks/lib/index.js similarity index 100% rename from packages/networks/index.js rename to packages/networks/lib/index.js diff --git a/packages/networks/lib/types.d.ts b/packages/networks/lib/types.d.ts new file mode 100644 index 000000000..f13419d49 --- /dev/null +++ b/packages/networks/lib/types.d.ts @@ -0,0 +1,7 @@ +export declare type Network = { + name: string; + chainId: number; + ensAddress?: string; + _defaultProvider?: (providers: any, options?: any) => any; +}; +export declare type Networkish = Network | string | number; diff --git a/packages/networks/types.js b/packages/networks/lib/types.js similarity index 100% rename from packages/networks/types.js rename to packages/networks/lib/types.js diff --git a/packages/networks/package.json b/packages/networks/package.json index 37787fb1f..29ed48c4e 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/networks", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Network definitions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -22,5 +22,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xe92e07d3a7c8206b3c5ff00ca361b20cec1606fd56e4be8224bd25855756fd0f" + "module": "./lib.esm/index.js", + "tarballHash": "0xd9e67edd9e4e88e2f320e073abc4f3e7ff0f41f7cb90cf94122c55ec17ce0f27" } diff --git a/packages/networks/tsconfig.json b/packages/networks/tsconfig.json index 969328db8..92930025f 100644 --- a/packages/networks/tsconfig.json +++ b/packages/networks/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts" + "./src.ts/*.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/pbkdf2/.gitignore b/packages/pbkdf2/.gitignore index aa5c62527..ac0298ec4 100644 --- a/packages/pbkdf2/.gitignore +++ b/packages/pbkdf2/.gitignore @@ -1 +1,2 @@ -browser.d.ts +lib/browser.d.ts +lib.esm/browser.d.ts diff --git a/packages/pbkdf2/_version.d.ts b/packages/pbkdf2/lib.esm/_version.d.ts similarity index 100% rename from packages/pbkdf2/_version.d.ts rename to packages/pbkdf2/lib.esm/_version.d.ts diff --git a/packages/pbkdf2/lib.esm/_version.js b/packages/pbkdf2/lib.esm/_version.js new file mode 100644 index 000000000..ae314de05 --- /dev/null +++ b/packages/pbkdf2/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "pbkdf2/5.0.0-beta.126"; diff --git a/packages/pbkdf2/lib.esm/browser.js b/packages/pbkdf2/lib.esm/browser.js new file mode 100644 index 000000000..424a3dff5 --- /dev/null +++ b/packages/pbkdf2/lib.esm/browser.js @@ -0,0 +1,43 @@ +"use strict"; +import { arrayify, hexlify } from "@ethersproject/bytes"; +import { computeHmac } from "@ethersproject/sha2"; +export function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { + password = arrayify(password); + salt = arrayify(salt); + let hLen; + let l = 1; + let DK = new Uint8Array(keylen); + let block1 = new Uint8Array(salt.length + 4); + block1.set(salt); + //salt.copy(block1, 0, 0, salt.length) + let r; + let T; + for (let i = 1; i <= l; i++) { + //block1.writeUInt32BE(i, salt.length) + block1[salt.length] = (i >> 24) & 0xff; + block1[salt.length + 1] = (i >> 16) & 0xff; + block1[salt.length + 2] = (i >> 8) & 0xff; + block1[salt.length + 3] = i & 0xff; + //let U = createHmac(password).update(block1).digest(); + let U = arrayify(computeHmac(hashAlgorithm, password, block1)); + if (!hLen) { + hLen = U.length; + T = new Uint8Array(hLen); + l = Math.ceil(keylen / hLen); + r = keylen - (l - 1) * hLen; + } + //U.copy(T, 0, 0, hLen) + T.set(U); + for (let j = 1; j < iterations; j++) { + //U = createHmac(password).update(U).digest(); + U = arrayify(computeHmac(hashAlgorithm, password, U)); + for (let k = 0; k < hLen; k++) + T[k] ^= U[k]; + } + let destPos = (i - 1) * hLen; + let len = (i === l ? r : hLen); + //T.copy(DK, destPos, 0, len) + DK.set(arrayify(T).slice(0, len), destPos); + } + return hexlify(DK); +} diff --git a/packages/pbkdf2/index.d.ts b/packages/pbkdf2/lib.esm/index.d.ts similarity index 100% rename from packages/pbkdf2/index.d.ts rename to packages/pbkdf2/lib.esm/index.d.ts diff --git a/packages/pbkdf2/lib.esm/index.js b/packages/pbkdf2/lib.esm/index.js new file mode 100644 index 000000000..70a72c6b6 --- /dev/null +++ b/packages/pbkdf2/lib.esm/index.js @@ -0,0 +1,9 @@ +"use strict"; +import { pbkdf2Sync as _pbkdf2 } from "crypto"; +import { arrayify, hexlify } from "@ethersproject/bytes"; +function bufferify(value) { + return Buffer.from(arrayify(value)); +} +export function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { + return hexlify(_pbkdf2(bufferify(password), bufferify(salt), iterations, keylen, hashAlgorithm)); +} diff --git a/packages/pbkdf2/lib/_version.d.ts b/packages/pbkdf2/lib/_version.d.ts new file mode 100644 index 000000000..d9b7b28a6 --- /dev/null +++ b/packages/pbkdf2/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "pbkdf2/5.0.0-beta.126"; diff --git a/packages/pbkdf2/_version.js b/packages/pbkdf2/lib/_version.js similarity index 100% rename from packages/pbkdf2/_version.js rename to packages/pbkdf2/lib/_version.js diff --git a/packages/pbkdf2/browser.js b/packages/pbkdf2/lib/browser.js similarity index 100% rename from packages/pbkdf2/browser.js rename to packages/pbkdf2/lib/browser.js diff --git a/packages/pbkdf2/lib/index.d.ts b/packages/pbkdf2/lib/index.d.ts new file mode 100644 index 000000000..c1449fa24 --- /dev/null +++ b/packages/pbkdf2/lib/index.d.ts @@ -0,0 +1,2 @@ +import { BytesLike } from "@ethersproject/bytes"; +export declare function pbkdf2(password: BytesLike, salt: BytesLike, iterations: number, keylen: number, hashAlgorithm: string): string; diff --git a/packages/pbkdf2/index.js b/packages/pbkdf2/lib/index.js similarity index 100% rename from packages/pbkdf2/index.js rename to packages/pbkdf2/lib/index.js diff --git a/packages/pbkdf2/package.json b/packages/pbkdf2/package.json index 67eaec7c6..077d6a130 100644 --- a/packages/pbkdf2/package.json +++ b/packages/pbkdf2/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/pbkdf2", - "version": "5.0.0-beta.126", + "version": "5.0.0-beta.127", "description": "The PBKDF2 password-pbased key derivation function for ethers.", - "main": "index.js", + "main": "./lib/index.js", "browser": "browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -25,5 +25,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x6be2011b2e3df7012482db367b10e80f4e00e6950bf57f9c8ec455a3e630110e" + "module": "./lib.esm/index.js", + "tarballHash": "0x4830330866b12fb72d882f27189212d4edbda5ad2257d5d5903ea265f28786e9" } diff --git a/packages/pbkdf2/tsconfig.json b/packages/pbkdf2/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/pbkdf2/tsconfig.json +++ b/packages/pbkdf2/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/properties/_version.d.ts b/packages/properties/lib.esm/_version.d.ts similarity index 100% rename from packages/properties/_version.d.ts rename to packages/properties/lib.esm/_version.d.ts diff --git a/packages/properties/lib.esm/_version.js b/packages/properties/lib.esm/_version.js new file mode 100644 index 000000000..378556b3f --- /dev/null +++ b/packages/properties/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "properties/5.0.0-beta.130"; diff --git a/packages/properties/index.d.ts b/packages/properties/lib.esm/index.d.ts similarity index 100% rename from packages/properties/index.d.ts rename to packages/properties/lib.esm/index.d.ts diff --git a/packages/properties/lib.esm/index.js b/packages/properties/lib.esm/index.js new file mode 100644 index 000000000..cff20b686 --- /dev/null +++ b/packages/properties/lib.esm/index.js @@ -0,0 +1,100 @@ +"use strict"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export function defineReadOnly(object, name, value) { + Object.defineProperty(object, name, { + enumerable: true, + value: value, + writable: false, + }); +} +// Crawl up the constructor chain to find a static method +export function getStatic(ctor, key) { + for (let i = 0; i < 32; i++) { + if (ctor[key]) { + return ctor[key]; + } + if (!ctor.prototype || typeof (ctor.prototype) !== "object") { + break; + } + ctor = Object.getPrototypeOf(ctor.prototype).constructor; + } + return null; +} +export function resolveProperties(object) { + let promises = Object.keys(object).map((key) => { + let value = object[key]; + if (!(value instanceof Promise)) { + return Promise.resolve({ key: key, value: value }); + } + return value.then((value) => { + return { key: key, value: value }; + }); + }); + return Promise.all(promises).then((results) => { + let result = {}; + return results.reduce((accum, result) => { + accum[result.key] = result.value; + return accum; + }, result); + }); +} +export function checkProperties(object, properties) { + if (!object || typeof (object) !== "object") { + logger.throwArgumentError("invalid object", "object", object); + } + Object.keys(object).forEach((key) => { + if (!properties[key]) { + logger.throwArgumentError("invalid object key - " + key, "transaction:" + key, object); + } + }); +} +export function shallowCopy(object) { + let result = {}; + for (let key in object) { + result[key] = object[key]; + } + return result; +} +let opaque = { bigint: true, boolean: true, number: true, string: true }; +// Returns a new copy of object, such that no properties may be replaced. +// New properties may be added only to objects. +export function deepCopy(object) { + // Opaque objects are not mutable, so safe to copy by assignment + if (object === undefined || object === null || opaque[typeof (object)]) { + return object; + } + // Arrays are mutable, so we need to create a copy + if (Array.isArray(object)) { + return Object.freeze(object.map((item) => deepCopy(item))); + } + if (typeof (object) === "object") { + // Immutable objects are safe to just use + if (Object.isFrozen(object)) { + return object; + } + let result = {}; + for (let key in object) { + let value = object[key]; + if (value === undefined) { + continue; + } + defineReadOnly(result, key, deepCopy(value)); + } + return result; + } + // The function type is also immutable, so safe to copy by assignment + if (typeof (object) === "function") { + return object; + } + throw new Error("Cannot deepCopy " + typeof (object)); +} +export class Description { + constructor(info) { + for (let key in info) { + this[key] = deepCopy(info[key]); + } + Object.freeze(this); + } +} diff --git a/packages/properties/lib/_version.d.ts b/packages/properties/lib/_version.d.ts new file mode 100644 index 000000000..7cdebce16 --- /dev/null +++ b/packages/properties/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "properties/5.0.0-beta.130"; diff --git a/packages/properties/_version.js b/packages/properties/lib/_version.js similarity index 100% rename from packages/properties/_version.js rename to packages/properties/lib/_version.js diff --git a/packages/properties/lib/index.d.ts b/packages/properties/lib/index.d.ts new file mode 100644 index 000000000..c4295d2ae --- /dev/null +++ b/packages/properties/lib/index.d.ts @@ -0,0 +1,11 @@ +export declare function defineReadOnly(object: any, name: string, value: any): void; +export declare function getStatic(ctor: any, key: string): T; +export declare function resolveProperties(object: any): Promise; +export declare function checkProperties(object: any, properties: { + [name: string]: boolean; +}): void; +export declare function shallowCopy(object: any): any; +export declare function deepCopy(object: any): any; +export declare class Description { + constructor(info: any); +} diff --git a/packages/properties/index.js b/packages/properties/lib/index.js similarity index 100% rename from packages/properties/index.js rename to packages/properties/lib/index.js diff --git a/packages/properties/package.json b/packages/properties/package.json index fc6f9bbfb..491d7949c 100644 --- a/packages/properties/package.json +++ b/packages/properties/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/properties", - "version": "5.0.0-beta.130", + "version": "5.0.0-beta.131", "description": "Properties utility functions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "build": "tsc -p ./tsconfig.json", "auto-build": "npm run build -- -w", @@ -24,5 +24,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x21a40461d34945d5d785224fb1be7b793511f6dd855f5fdbf0a05050b65359d0" + "module": "./lib.esm/index.js", + "tarballHash": "0x68656684c2b7d12224e1a4dc73bdead0b1043aadfedd139aa082036cbffc5a0e" } diff --git a/packages/properties/tsconfig.json b/packages/properties/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/properties/tsconfig.json +++ b/packages/properties/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/providers/_version.d.ts b/packages/providers/lib.esm/_version.d.ts similarity index 100% rename from packages/providers/_version.d.ts rename to packages/providers/lib.esm/_version.d.ts diff --git a/packages/providers/lib.esm/_version.js b/packages/providers/lib.esm/_version.js new file mode 100644 index 000000000..ce9409f2a --- /dev/null +++ b/packages/providers/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "providers/5.0.0-beta.140"; diff --git a/packages/providers/alchemy-provider.d.ts b/packages/providers/lib.esm/alchemy-provider.d.ts similarity index 100% rename from packages/providers/alchemy-provider.d.ts rename to packages/providers/lib.esm/alchemy-provider.d.ts diff --git a/packages/providers/lib.esm/alchemy-provider.js b/packages/providers/lib.esm/alchemy-provider.js new file mode 100644 index 000000000..51f99f77a --- /dev/null +++ b/packages/providers/lib.esm/alchemy-provider.js @@ -0,0 +1,38 @@ +"use strict"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +// This key was provided to ethers.js by Alchemy to be used by the +// default provider, but it is recommended that for your own +// production environments, that you acquire your own API key at: +// https://dashboard.alchemyapi.io +const defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"; +export class AlchemyProvider extends UrlJsonRpcProvider { + static getApiKey(apiKey) { + if (apiKey == null) { + return defaultApiKey; + } + return apiKey; + } + static getUrl(network, apiKey) { + let host = null; + switch (network.name) { + case "homestead": + host = "eth-mainnet.alchemyapi.io/jsonrpc/"; + break; + case "ropsten": + host = "eth-ropsten.alchemyapi.io/jsonrpc/"; + break; + case "rinkeby": + host = "eth-rinkeby.alchemyapi.io/jsonrpc/"; + break; + case "kovan": + host = "eth-kovan.alchemyapi.io/jsonrpc/"; + break; + default: + logger.throwArgumentError("unsupported network", "network", arguments[0]); + } + return ("https:/" + "/" + host + apiKey); + } +} diff --git a/packages/providers/base-provider.d.ts b/packages/providers/lib.esm/base-provider.d.ts similarity index 100% rename from packages/providers/base-provider.d.ts rename to packages/providers/lib.esm/base-provider.d.ts diff --git a/packages/providers/lib.esm/base-provider.js b/packages/providers/lib.esm/base-provider.js new file mode 100644 index 000000000..e32d19e59 --- /dev/null +++ b/packages/providers/lib.esm/base-provider.js @@ -0,0 +1,843 @@ +"use strict"; +import { ForkEvent, Provider } from "@ethersproject/abstract-provider"; +import { BigNumber } from "@ethersproject/bignumber"; +import { arrayify, hexDataLength, hexlify, hexValue, isHexString } from "@ethersproject/bytes"; +import { namehash } from "@ethersproject/hash"; +import { getNetwork } from "@ethersproject/networks"; +import { defineReadOnly, getStatic, resolveProperties } from "@ethersproject/properties"; +import { toUtf8String } from "@ethersproject/strings"; +import { poll } from "@ethersproject/web"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { Formatter } from "./formatter"; +////////////////////////////// +// Event Serializeing +function checkTopic(topic) { + if (topic == null) { + return "null"; + } + if (hexDataLength(topic) !== 32) { + logger.throwArgumentError("invalid topic", "topic", topic); + } + return topic.toLowerCase(); +} +function serializeTopics(topics) { + // Remove trailing null AND-topics; they are redundant + topics = topics.slice(); + while (topics[topics.length - 1] == null) { + topics.pop(); + } + return topics.map((topic) => { + if (Array.isArray(topic)) { + // Only track unique OR-topics + let unique = {}; + topic.forEach((topic) => { + unique[checkTopic(topic)] = true; + }); + // The order of OR-topics does not matter + let sorted = Object.keys(unique); + sorted.sort(); + return sorted.join("|"); + } + else { + return checkTopic(topic); + } + }).join("&"); +} +function deserializeTopics(data) { + return data.split(/&/g).map((topic) => { + return topic.split("|").map((topic) => { + return ((topic === "null") ? null : topic); + }); + }); +} +function getEventTag(eventName) { + if (typeof (eventName) === "string") { + eventName = eventName.toLowerCase(); + if (hexDataLength(eventName) === 32) { + return "tx:" + eventName; + } + if (eventName.indexOf(":") === -1) { + return eventName; + } + } + else if (Array.isArray(eventName)) { + return "filter:*:" + serializeTopics(eventName); + } + else if (ForkEvent.isForkEvent(eventName)) { + logger.warn("not implemented"); + throw new Error("not implemented"); + } + else if (eventName && typeof (eventName) === "object") { + return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); + } + throw new Error("invalid event - " + eventName); +} +////////////////////////////// +// Helper Object +function getTime() { + return (new Date()).getTime(); +} +////////////////////////////// +// Provider Object +/** + * EventType + * - "block" + * - "pending" + * - "error" + * - filter + * - topics array + * - transaction hash + */ +class Event { + constructor(tag, listener, once) { + defineReadOnly(this, "tag", tag); + defineReadOnly(this, "listener", listener); + defineReadOnly(this, "once", once); + } + pollable() { + return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); + } +} +let defaultFormatter = null; +let nextPollId = 1; +export class BaseProvider extends Provider { + constructor(network) { + logger.checkNew(new.target, Provider); + super(); + this.formatter = new.target.getFormatter(); + if (network instanceof Promise) { + defineReadOnly(this, "ready", network.then((network) => { + defineReadOnly(this, "_network", network); + return network; + })); + // Squash any "unhandled promise" errors; that do not need to be handled + this.ready.catch((error) => { }); + } + else { + let knownNetwork = getStatic((new.target), "getNetwork")(network); + if (knownNetwork) { + defineReadOnly(this, "_network", knownNetwork); + defineReadOnly(this, "ready", Promise.resolve(this._network)); + } + else { + logger.throwArgumentError("invalid network", "network", network); + } + } + this._lastBlockNumber = -2; + // Events being listened to + this._events = []; + this._pollingInterval = 4000; + this._emitted = { block: -2 }; + this._fastQueryDate = 0; + } + static getFormatter() { + if (defaultFormatter == null) { + defaultFormatter = new Formatter(); + } + return defaultFormatter; + } + static getNetwork(network) { + return getNetwork((network == null) ? "homestead" : network); + } + poll() { + let pollId = nextPollId++; + this.emit("willPoll", pollId); + // Track all running promises, so we can trigger a post-poll once they are complete + let runners = []; + this.getBlockNumber().then((blockNumber) => { + this._setFastBlockNumber(blockNumber); + // If the block has not changed, meh. + if (blockNumber === this._lastBlockNumber) { + return; + } + // First polling cycle, trigger a "block" events + if (this._emitted.block === -2) { + this._emitted.block = blockNumber - 1; + } + // Notify all listener for each block that has passed + for (let i = this._emitted.block + 1; i <= blockNumber; i++) { + this.emit("block", i); + } + // The emitted block was updated, check for obsolete events + if (this._emitted.block !== blockNumber) { + this._emitted.block = blockNumber; + Object.keys(this._emitted).forEach((key) => { + // The block event does not expire + if (key === "block") { + return; + } + // The block we were at when we emitted this event + let eventBlockNumber = this._emitted[key]; + // We cannot garbage collect pending transactions or blocks here + // They should be garbage collected by the Provider when setting + // "pending" events + if (eventBlockNumber === "pending") { + return; + } + // Evict any transaction hashes or block hashes over 12 blocks + // old, since they should not return null anyways + if (blockNumber - eventBlockNumber > 12) { + delete this._emitted[key]; + } + }); + } + // First polling cycle + if (this._lastBlockNumber === -2) { + this._lastBlockNumber = blockNumber - 1; + } + // Find all transaction hashes we are waiting on + this._events.forEach((event) => { + let comps = event.tag.split(":"); + switch (comps[0]) { + case "tx": { + let hash = comps[1]; + let runner = this.getTransactionReceipt(hash).then((receipt) => { + if (!receipt || receipt.blockNumber == null) { + return null; + } + this._emitted["t:" + hash] = receipt.blockNumber; + this.emit(hash, receipt); + return null; + }).catch((error) => { this.emit("error", error); }); + runners.push(runner); + break; + } + case "filter": { + let topics = deserializeTopics(comps[2]); + let filter = { + address: comps[1], + fromBlock: this._lastBlockNumber + 1, + toBlock: blockNumber, + topics: topics + }; + if (!filter.address) { + delete filter.address; + } + let runner = this.getLogs(filter).then((logs) => { + if (logs.length === 0) { + return; + } + logs.forEach((log) => { + this._emitted["b:" + log.blockHash] = log.blockNumber; + this._emitted["t:" + log.transactionHash] = log.blockNumber; + this.emit(filter, log); + }); + return null; + }).catch((error) => { this.emit("error", error); }); + runners.push(runner); + break; + } + } + }); + this._lastBlockNumber = blockNumber; + return null; + }).catch((error) => { }); + Promise.all(runners).then(() => { + this.emit("didPoll", pollId); + }); + } + resetEventsBlock(blockNumber) { + this._lastBlockNumber = blockNumber - 1; + if (this.polling) { + this.poll(); + } + } + get network() { + return this._network; + } + getNetwork() { + return this.ready; + } + get blockNumber() { + return this._fastBlockNumber; + } + get polling() { + return (this._poller != null); + } + set polling(value) { + setTimeout(() => { + if (value && !this._poller) { + this._poller = setInterval(this.poll.bind(this), this.pollingInterval); + } + else if (!value && this._poller) { + clearInterval(this._poller); + this._poller = null; + } + }, 0); + } + get pollingInterval() { + return this._pollingInterval; + } + set pollingInterval(value) { + if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) { + throw new Error("invalid polling interval"); + } + this._pollingInterval = value; + if (this._poller) { + clearInterval(this._poller); + this._poller = setInterval(() => { this.poll(); }, this._pollingInterval); + } + } + _getFastBlockNumber() { + let now = getTime(); + // Stale block number, request a newer value + if ((now - this._fastQueryDate) > 2 * this._pollingInterval) { + this._fastQueryDate = now; + this._fastBlockNumberPromise = this.getBlockNumber().then((blockNumber) => { + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + } + return this._fastBlockNumber; + }); + } + return this._fastBlockNumberPromise; + } + _setFastBlockNumber(blockNumber) { + // Older block, maybe a stale request + if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { + return; + } + // Update the time we updated the blocknumber + this._fastQueryDate = getTime(); + // Newer block number, use it + if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { + this._fastBlockNumber = blockNumber; + this._fastBlockNumberPromise = Promise.resolve(blockNumber); + } + } + // @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event; + // this will be used once we move to the WebSocket or other alternatives to polling + waitForTransaction(transactionHash, confirmations) { + if (confirmations == null) { + confirmations = 1; + } + if (confirmations === 0) { + return this.getTransactionReceipt(transactionHash); + } + return new Promise((resolve) => { + let handler = (receipt) => { + if (receipt.confirmations < confirmations) { + return; + } + this.removeListener(transactionHash, handler); + resolve(receipt); + }; + this.on(transactionHash, handler); + }); + } + _runPerform(method, params) { + return this.ready.then(() => { + // Execute all the functions now that we are "ready" + Object.keys(params).forEach((key) => { + params[key] = params[key](); + }); + return resolveProperties(params).then((params) => { + return this.perform(method, params); + }); + }); + } + getBlockNumber() { + return this._runPerform("getBlockNumber", {}).then((result) => { + let value = parseInt(result); + if (value != result) { + throw new Error("invalid response - getBlockNumber"); + } + this._setFastBlockNumber(value); + return value; + }); + } + getGasPrice() { + return this._runPerform("getGasPrice", {}).then((result) => { + return BigNumber.from(result); + }); + } + getBalance(addressOrName, blockTag) { + return this._runPerform("getBalance", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return BigNumber.from(result); + }); + } + getTransactionCount(addressOrName, blockTag) { + return this._runPerform("getTransactionCount", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return BigNumber.from(result).toNumber(); + }); + } + getCode(addressOrName, blockTag) { + return this._runPerform("getCode", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return hexlify(result); + }); + } + getStorageAt(addressOrName, position, blockTag) { + return this._runPerform("getStorageAt", { + address: () => this._getAddress(addressOrName), + blockTag: () => this._getBlockTag(blockTag), + position: () => Promise.resolve(position).then((p) => hexValue(p)) + }).then((result) => { + return hexlify(result); + }); + } + // This should be called by any subclass wrapping a TransactionResponse + _wrapTransaction(tx, hash) { + if (hash != null && hexDataLength(hash) !== 32) { + throw new Error("invalid response - sendTransaction"); + } + let result = tx; + // Check the hash we expect is the same as the hash the server reported + if (hash != null && tx.hash !== hash) { + logger.throwError("Transaction hash mismatch from Provider.sendTransaction.", Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + } + // @TODO: (confirmations? number, timeout? number) + result.wait = (confirmations) => { + // We know this transaction *must* exist (whether it gets mined is + // another story), so setting an emitted value forces us to + // wait even if the node returns null for the receipt + if (confirmations !== 0) { + this._emitted["t:" + tx.hash] = "pending"; + } + return this.waitForTransaction(tx.hash, confirmations).then((receipt) => { + if (receipt == null && confirmations === 0) { + return null; + } + // No longer pending, allow the polling loop to garbage collect this + this._emitted["t:" + tx.hash] = receipt.blockNumber; + if (receipt.status === 0) { + logger.throwError("transaction failed", Logger.errors.CALL_EXCEPTION, { + transactionHash: tx.hash, + transaction: tx, + receipt: receipt + }); + } + return receipt; + }); + }; + return result; + } + sendTransaction(signedTransaction) { + return this._runPerform("sendTransaction", { + signedTransaction: () => Promise.resolve(signedTransaction).then(t => hexlify(t)) + }).then((result) => { + return this._wrapTransaction(this.formatter.transaction(signedTransaction), result); + }, (error) => { + error.transaction = this.formatter.transaction(signedTransaction); + if (error.transaction.hash) { + error.transactionHash = error.transaction.hash; + } + throw error; + }); + } + _getTransactionRequest(transaction) { + return Promise.resolve(transaction).then((t) => { + let tx = {}; + ["from", "to"].forEach((key) => { + if (t[key] == null) { + return; + } + tx[key] = Promise.resolve(t[key]).then(a => (a ? this._getAddress(a) : null)); + }); + ["data", "gasLimit", "gasPrice", "value"].forEach((key) => { + if (t[key] == null) { + return; + } + tx[key] = t[key]; + }); + return resolveProperties(tx).then((t) => this.formatter.transactionRequest(t)); + }); + } + _getFilter(filter) { + return Promise.resolve(filter).then((f) => { + let filter = {}; + if (f.address != null) { + filter.address = this._getAddress(f.address); + } + if (f.topics) { + filter.topics = f.topics; + } + if (f.blockHash != null) { + filter.blockHash = f.blockHash; + } + ["fromBlock", "toBlock"].forEach((key) => { + if (f[key] == null) { + return; + } + filter[key] = this._getBlockTag(f[key]); + }); + return resolveProperties(filter).then((f) => this.formatter.filter(f)); + }); + } + call(transaction, blockTag) { + return this._runPerform("call", { + transaction: () => this._getTransactionRequest(transaction), + blockTag: () => this._getBlockTag(blockTag) + }).then((result) => { + return hexlify(result); + }); + } + estimateGas(transaction) { + return this._runPerform("estimateGas", { + transaction: () => this._getTransactionRequest(transaction) + }).then((result) => { + return BigNumber.from(result); + }); + } + _getAddress(addressOrName) { + return this.resolveName(addressOrName).then((address) => { + if (address == null) { + logger.throwError("ENS name not configured", Logger.errors.UNSUPPORTED_OPERATION, { + operation: `resolveName(${JSON.stringify(addressOrName)})` + }); + } + return address; + }); + } + _getBlock(blockHashOrBlockTag, includeTransactions) { + return this.ready.then(() => { + return this._getBlockTag(blockHashOrBlockTag).then((blockHashOrBlockTag) => { + let params = { + includeTransactions: !!includeTransactions + }; + // Exactly one of blockHash or blockTag will be set + let blockHash = null; + let blockTag = null; + // If blockTag is a number (not "latest", etc), this is the block number + let blockNumber = -128; + if (isHexString(blockHashOrBlockTag, 32)) { + params.blockHash = blockHashOrBlockTag; + } + else { + try { + params.blockTag = this.formatter.blockTag(blockHashOrBlockTag); + if (isHexString(params.blockTag)) { + blockNumber = parseInt(params.blockTag.substring(2), 16); + } + } + catch (error) { + logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + } + } + return poll(() => { + return this.perform("getBlock", params).then((block) => { + // Block was not found + if (block == null) { + // For blockhashes, if we didn't say it existed, that blockhash may + // not exist. If we did see it though, perhaps from a log, we know + // it exists, and this node is just not caught up yet. + if (blockHash) { + if (this._emitted["b:" + blockHash] == null) { + return null; + } + } + // For block tags, if we are asking for a future block, we return null + if (blockTag) { + if (blockNumber > this._emitted.block) { + return null; + } + } + // Retry on the next block + return undefined; + } + // Add transactions + if (includeTransactions) { + return this.formatter.blockWithTransactions(block); + } + return this.formatter.block(block); + }); + }, { onceBlock: this }); + }); + }); + } + getBlock(blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, false)); + } + getBlockWithTransactions(blockHashOrBlockTag) { + return (this._getBlock(blockHashOrBlockTag, true)); + } + getTransaction(transactionHash) { + return this.ready.then(() => { + return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => { + let params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return poll(() => { + return this.perform("getTransaction", params).then((result) => { + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + let tx = this.formatter.transactionResponse(result); + if (tx.blockNumber == null) { + tx.confirmations = 0; + } + else if (tx.confirmations == null) { + return this._getFastBlockNumber().then((blockNumber) => { + // Add the confirmations using the fast block number (pessimistic) + let confirmations = (blockNumber - tx.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + tx.confirmations = confirmations; + return this._wrapTransaction(tx); + }); + } + return this._wrapTransaction(tx); + }); + }, { onceBlock: this }); + }); + }); + } + getTransactionReceipt(transactionHash) { + return this.ready.then(() => { + return resolveProperties({ transactionHash: transactionHash }).then(({ transactionHash }) => { + let params = { transactionHash: this.formatter.hash(transactionHash, true) }; + return poll(() => { + return this.perform("getTransactionReceipt", params).then((result) => { + if (result == null) { + if (this._emitted["t:" + transactionHash] == null) { + return null; + } + return undefined; + } + // "geth-etc" returns receipts before they are ready + if (result.blockHash == null) { + return undefined; + } + let receipt = this.formatter.receipt(result); + if (receipt.blockNumber == null) { + receipt.confirmations = 0; + } + else if (receipt.confirmations == null) { + return this._getFastBlockNumber().then((blockNumber) => { + // Add the confirmations using the fast block number (pessimistic) + let confirmations = (blockNumber - receipt.blockNumber) + 1; + if (confirmations <= 0) { + confirmations = 1; + } + receipt.confirmations = confirmations; + return receipt; + }); + } + return receipt; + }); + }, { onceBlock: this }); + }); + }); + } + getLogs(filter) { + return this._runPerform("getLogs", { + filter: () => this._getFilter(filter) + }).then((result) => { + return Formatter.arrayOf(this.formatter.filterLog.bind(this.formatter))(result); + }); + } + getEtherPrice() { + return this._runPerform("getEtherPrice", {}).then((result) => { + return result; + }); + } + _getBlockTag(blockTag) { + if (blockTag instanceof Promise) { + return blockTag.then((b) => this._getBlockTag(b)); + } + if (typeof (blockTag) === "number" && blockTag < 0) { + if (blockTag % 1) { + logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + } + return this._getFastBlockNumber().then((bn) => { + bn += blockTag; + if (bn < 0) { + bn = 0; + } + return this.formatter.blockTag(bn); + }); + } + return Promise.resolve(this.formatter.blockTag(blockTag)); + } + _getResolver(name) { + // Get the resolver from the blockchain + return this.getNetwork().then((network) => { + // No ENS... + if (!network.ensAddress) { + logger.throwError("network does support ENS", Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); + } + // keccak256("resolver(bytes32)") + let data = "0x0178b8bf" + namehash(name).substring(2); + let transaction = { to: network.ensAddress, data: data }; + return this.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + }); + } + resolveName(name) { + // If it is a promise, resolve it then recurse + if (name instanceof Promise) { + return name.then((addressOrName) => this.resolveName(addressOrName)); + } + // If it is already an address, nothing to resolve + try { + return Promise.resolve(this.formatter.address(name)); + } + catch (error) { } + // Get the addr from the resovler + return this._getResolver(name).then((resolverAddress) => { + if (!resolverAddress) { + return null; + } + // keccak256("addr(bytes32)") + let data = "0x3b3b57de" + namehash(name).substring(2); + let transaction = { to: resolverAddress, data: data }; + return this.call(transaction).then((data) => { + return this.formatter.callAddress(data); + }); + }); + } + lookupAddress(address) { + if (address instanceof Promise) { + return address.then((address) => this.lookupAddress(address)); + } + address = this.formatter.address(address); + let name = address.substring(2) + ".addr.reverse"; + return this._getResolver(name).then((resolverAddress) => { + if (!resolverAddress) { + return null; + } + // keccak("name(bytes32)") + let data = "0x691f3431" + namehash(name).substring(2); + return this.call({ to: resolverAddress, data: data }).then((data) => { + let bytes = arrayify(data); + // Strip off the dynamic string pointer (0x20) + if (bytes.length < 32 || !BigNumber.from(bytes.slice(0, 32)).eq(32)) { + return null; + } + bytes = bytes.slice(32); + if (bytes.length < 32) { + return null; + } + let length = BigNumber.from(bytes.slice(0, 32)).toNumber(); + bytes = bytes.slice(32); + if (length > bytes.length) { + return null; + } + let name = toUtf8String(bytes.slice(0, length)); + // Make sure the reverse record matches the foward record + return this.resolveName(name).then((addr) => { + if (addr != address) { + return null; + } + return name; + }); + }); + }); + } + perform(method, params) { + return logger.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); + } + _startPending() { + console.log("WARNING: this provider does not support pending events"); + } + _stopPending() { + } + // Returns true if there are events that still require polling + _checkPolling() { + this.polling = (this._events.filter((e) => e.pollable()).length > 0); + } + _addEventListener(eventName, listener, once) { + this._events.push(new Event(getEventTag(eventName), listener, once)); + if (eventName === "pending") { + this._startPending(); + } + // Do we still now have any events that require polling? + this._checkPolling(); + return this; + } + on(eventName, listener) { + return this._addEventListener(eventName, listener, false); + } + once(eventName, listener) { + return this._addEventListener(eventName, listener, true); + } + emit(eventName, ...args) { + let result = false; + let eventTag = getEventTag(eventName); + this._events = this._events.filter((event) => { + if (event.tag !== eventTag) { + return true; + } + setTimeout(() => { + event.listener.apply(this, args); + }, 0); + result = true; + return !(event.once); + }); + // Do we still have any events that require polling? ("once" events remove themselves) + this._checkPolling(); + return result; + } + listenerCount(eventName) { + if (!eventName) { + return this._events.length; + } + let eventTag = getEventTag(eventName); + return this._events.filter((event) => { + return (event.tag === eventTag); + }).length; + } + listeners(eventName) { + if (eventName == null) { + return this._events.map((event) => event.listener); + } + let eventTag = getEventTag(eventName); + return this._events + .filter((event) => (event.tag === eventTag)) + .map((event) => event.listener); + } + off(eventName, listener) { + if (listener == null) { + return this.removeAllListeners(eventName); + } + let found = false; + let eventTag = getEventTag(eventName); + this._events = this._events.filter((event) => { + if (event.tag !== eventTag || event.listener != listener) { + return true; + } + if (found) { + return true; + } + found = true; + return false; + }); + if (eventName === "pending" && this.listenerCount("pending") === 0) { + this._stopPending(); + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + } + removeAllListeners(eventName) { + if (eventName == null) { + this._events = []; + this._stopPending(); + } + else { + let eventTag = getEventTag(eventName); + this._events = this._events.filter((event) => { + return (event.tag !== eventTag); + }); + if (eventName === "pending") { + this._stopPending(); + } + } + // Do we still have any events that require polling? + this._checkPolling(); + return this; + } +} diff --git a/packages/providers/browser-net.d.ts b/packages/providers/lib.esm/browser-ipc-provider.d.ts similarity index 100% rename from packages/providers/browser-net.d.ts rename to packages/providers/lib.esm/browser-ipc-provider.d.ts diff --git a/packages/providers/browser-ipc-provider.js b/packages/providers/lib.esm/browser-ipc-provider.js similarity index 100% rename from packages/providers/browser-ipc-provider.js rename to packages/providers/lib.esm/browser-ipc-provider.js diff --git a/packages/providers/lib.esm/browser-net.d.ts b/packages/providers/lib.esm/browser-net.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/providers/browser-net.js b/packages/providers/lib.esm/browser-net.js similarity index 100% rename from packages/providers/browser-net.js rename to packages/providers/lib.esm/browser-net.js diff --git a/packages/providers/cloudflare-provider.d.ts b/packages/providers/lib.esm/cloudflare-provider.d.ts similarity index 100% rename from packages/providers/cloudflare-provider.d.ts rename to packages/providers/lib.esm/cloudflare-provider.d.ts diff --git a/packages/providers/lib.esm/cloudflare-provider.js b/packages/providers/lib.esm/cloudflare-provider.js new file mode 100644 index 000000000..55e527b4e --- /dev/null +++ b/packages/providers/lib.esm/cloudflare-provider.js @@ -0,0 +1,21 @@ +"use strict"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export class CloudflareProvider extends UrlJsonRpcProvider { + static getUrl(network, apiKey) { + if (apiKey != null) { + logger.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); + } + let host = null; + switch (network.name) { + case "homestead": + host = "https://cloudflare-eth.com/"; + break; + default: + logger.throwArgumentError("unsupported network", "network", arguments[0]); + } + return host; + } +} diff --git a/packages/providers/etherscan-provider.d.ts b/packages/providers/lib.esm/etherscan-provider.d.ts similarity index 100% rename from packages/providers/etherscan-provider.d.ts rename to packages/providers/lib.esm/etherscan-provider.d.ts diff --git a/packages/providers/lib.esm/etherscan-provider.js b/packages/providers/lib.esm/etherscan-provider.js new file mode 100644 index 000000000..3a17f34bc --- /dev/null +++ b/packages/providers/lib.esm/etherscan-provider.js @@ -0,0 +1,324 @@ +"use strict"; +import { hexlify, hexValue } from "@ethersproject/bytes"; +import { deepCopy, defineReadOnly } from "@ethersproject/properties"; +import { fetchJson } from "@ethersproject/web"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { BaseProvider } from "./base-provider"; +// The transaction has already been sanitized by the calls in Provider +function getTransactionString(transaction) { + let result = []; + for (let key in transaction) { + if (transaction[key] == null) { + continue; + } + let value = hexlify(transaction[key]); + if ({ gasLimit: true, gasPrice: true, nonce: true, value: true }[key]) { + value = hexValue(value); + } + result.push(key + "=" + value); + } + return result.join("&"); +} +function getResult(result) { + // getLogs, getHistory have weird success responses + if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) { + return result.result; + } + if (result.status != 1 || result.message != "OK") { + // @TODO: not any + let error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + return result.result; +} +function getJsonResult(result) { + if (result.jsonrpc != "2.0") { + // @TODO: not any + let error = new Error("invalid response"); + error.result = JSON.stringify(result); + throw error; + } + if (result.error) { + // @TODO: not any + let error = new Error(result.error.message || "unknown error"); + if (result.error.code) { + error.code = result.error.code; + } + if (result.error.data) { + error.data = result.error.data; + } + throw error; + } + return result.result; +} +// The blockTag was normalized as a string by the Provider pre-perform operations +function checkLogTag(blockTag) { + if (blockTag === "pending") { + throw new Error("pending not supported"); + } + if (blockTag === "latest") { + return blockTag; + } + return parseInt(blockTag.substring(2), 16); +} +export class EtherscanProvider extends BaseProvider { + constructor(network, apiKey) { + logger.checkNew(new.target, EtherscanProvider); + super(network); + let name = "invalid"; + if (this.network) { + name = this.network.name; + } + let baseUrl = null; + switch (name) { + case "homestead": + baseUrl = "https://api.etherscan.io"; + break; + case "ropsten": + baseUrl = "https://api-ropsten.etherscan.io"; + break; + case "rinkeby": + baseUrl = "https://api-rinkeby.etherscan.io"; + break; + case "kovan": + baseUrl = "https://api-kovan.etherscan.io"; + break; + case "goerli": + baseUrl = "https://api-goerli.etherscan.io"; + break; + default: + throw new Error("unsupported network"); + } + defineReadOnly(this, "baseUrl", baseUrl); + defineReadOnly(this, "apiKey", apiKey); + } + perform(method, params) { + let url = this.baseUrl; + let apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + let get = (url, procFunc) => { + this.emit("debug", { + action: "request", + request: url, + provider: this + }); + return fetchJson(url, null, procFunc || getJsonResult).then((result) => { + this.emit("debug", { + action: "response", + request: url, + response: deepCopy(result), + provider: this + }); + return result; + }); + }; + switch (method) { + case "getBlockNumber": + url += "/api?module=proxy&action=eth_blockNumber" + apiKey; + return get(url); + case "getGasPrice": + url += "/api?module=proxy&action=eth_gasPrice" + apiKey; + return get(url); + case "getBalance": + // Returns base-10 result + url += "/api?module=account&action=balance&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getResult); + case "getTransactionCount": + url += "/api?module=proxy&action=eth_getTransactionCount&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url); + case "getCode": + url += "/api?module=proxy&action=eth_getCode&address=" + params.address; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "getStorageAt": + url += "/api?module=proxy&action=eth_getStorageAt&address=" + params.address; + url += "&position=" + params.position; + url += "&tag=" + params.blockTag + apiKey; + return get(url, getJsonResult); + case "sendTransaction": + url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; + url += apiKey; + return get(url).catch((error) => { + if (error.responseText) { + // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" + if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { + logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {}); + } + // "Transaction with the same hash was already imported." + if (error.responseText.indexOf("same hash was already imported") >= 0) { + logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {}); + } + // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." + if (error.responseText.indexOf("another transaction with same nonce") >= 0) { + logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + url += "/api?module=proxy&action=eth_getBlockByNumber&tag=" + params.blockTag; + if (params.includeTransactions) { + url += "&boolean=true"; + } + else { + url += "&boolean=false"; + } + url += apiKey; + return get(url); + } + throw new Error("getBlock by blockHash not implmeneted"); + case "getTransaction": + url += "/api?module=proxy&action=eth_getTransactionByHash&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "getTransactionReceipt": + url += "/api?module=proxy&action=eth_getTransactionReceipt&txhash=" + params.transactionHash; + url += apiKey; + return get(url); + case "call": { + let transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_call" + transaction; + //url += "&tag=" + params.blockTag + apiKey; + if (params.blockTag !== "latest") { + throw new Error("EtherscanProvider does not support blockTag for call"); + } + url += apiKey; + return get(url); + } + case "estimateGas": { + let transaction = getTransactionString(params.transaction); + if (transaction) { + transaction = "&" + transaction; + } + url += "/api?module=proxy&action=eth_estimateGas&" + transaction; + url += apiKey; + return get(url); + } + case "getLogs": + url += "/api?module=logs&action=getLogs"; + try { + if (params.filter.fromBlock) { + url += "&fromBlock=" + checkLogTag(params.filter.fromBlock); + } + if (params.filter.toBlock) { + url += "&toBlock=" + checkLogTag(params.filter.toBlock); + } + if (params.filter.address) { + url += "&address=" + params.filter.address; + } + // @TODO: We can handle slightly more complicated logs using the logs API + if (params.filter.topics && params.filter.topics.length > 0) { + if (params.filter.topics.length > 1) { + throw new Error("unsupported topic format"); + } + let topic0 = params.filter.topics[0]; + if (typeof (topic0) !== "string" || topic0.length !== 66) { + throw new Error("unsupported topic0 format"); + } + url += "&topic0=" + topic0; + } + } + catch (error) { + return Promise.reject(error); + } + url += apiKey; + let self = this; + return get(url, getResult).then(function (logs) { + let txs = {}; + let seq = Promise.resolve(); + logs.forEach(function (log) { + seq = seq.then(function () { + if (log.blockHash != null) { + return null; + } + log.blockHash = txs[log.transactionHash]; + if (log.blockHash == null) { + return self.getTransaction(log.transactionHash).then(function (tx) { + txs[log.transactionHash] = tx.blockHash; + log.blockHash = tx.blockHash; + return null; + }); + } + return null; + }); + }); + return seq.then(function () { + return logs; + }); + }); + case "getEtherPrice": + if (this.network.name !== "homestead") { + return Promise.resolve(0.0); + } + url += "/api?module=stats&action=ethprice"; + url += apiKey; + return get(url, getResult).then(function (result) { + return parseFloat(result.ethusd); + }); + default: + break; + } + return super.perform(method, params); + } + // @TODO: Allow startBlock and endBlock to be Promises + getHistory(addressOrName, startBlock, endBlock) { + let url = this.baseUrl; + let apiKey = ""; + if (this.apiKey) { + apiKey += "&apikey=" + this.apiKey; + } + if (startBlock == null) { + startBlock = 0; + } + if (endBlock == null) { + endBlock = 99999999; + } + return this.resolveName(addressOrName).then((address) => { + url += "/api?module=account&action=txlist&address=" + address; + url += "&startblock=" + startBlock; + url += "&endblock=" + endBlock; + url += "&sort=asc" + apiKey; + this.emit("debug", { + action: "request", + request: url, + provider: this + }); + return fetchJson(url, null, getResult).then((result) => { + this.emit("debug", { + action: "response", + request: url, + response: deepCopy(result), + provider: this + }); + let output = []; + result.forEach((tx) => { + ["contractAddress", "to"].forEach(function (key) { + if (tx[key] == "") { + delete tx[key]; + } + }); + if (tx.creates == null && tx.contractAddress != null) { + tx.creates = tx.contractAddress; + } + let item = this.formatter.transactionResponse(tx); + if (tx.timeStamp) { + item.timestamp = parseInt(tx.timeStamp); + } + output.push(item); + }); + return output; + }); + }); + } +} diff --git a/packages/providers/fallback-provider.d.ts b/packages/providers/lib.esm/fallback-provider.d.ts similarity index 100% rename from packages/providers/fallback-provider.d.ts rename to packages/providers/lib.esm/fallback-provider.d.ts diff --git a/packages/providers/lib.esm/fallback-provider.js b/packages/providers/lib.esm/fallback-provider.js new file mode 100644 index 000000000..3ebe85b66 --- /dev/null +++ b/packages/providers/lib.esm/fallback-provider.js @@ -0,0 +1,296 @@ +"use strict"; +import { shuffled } from "@ethersproject/random"; +import { deepCopy, defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { BaseProvider } from "./base-provider"; +function now() { return (new Date()).getTime(); } +// Returns: +// - true is all networks match +// - false if any network is null +// - throws if any 2 networks do not match +function checkNetworks(networks) { + let result = true; + let check = null; + networks.forEach((network) => { + // Null + if (network == null) { + result = false; + return; + } + // Have nothing to compre to yet + if (check == null) { + check = network; + return; + } + // Matches! + if (check.name === network.name && + check.chainId === network.chainId && + ((check.ensAddress === network.ensAddress) || + (check.ensAddress == null && network.ensAddress == null))) { + return; + } + logger.throwArgumentError("provider mismatch", "networks", networks); + }); + return result; +} +function serialize(result) { + if (Array.isArray(result)) { + return JSON.stringify(result.map((r) => serialize(r))); + } + else if (result === null) { + return "null"; + } + else if (typeof (result) === "object") { + let keys = Object.keys(result); + keys.sort(); + return "{" + keys.map((key) => { + let value = result[key]; + if (typeof (value) === "function") { + value = "function{}"; + } + else { + value = serialize(value); + } + return JSON.stringify(key) + "=" + serialize(value); + }).join(",") + "}"; + } + return JSON.stringify(result); +} +let nextRid = 1; +export class FallbackProvider extends BaseProvider { + constructor(providers, quorum, weights) { + logger.checkNew(new.target, FallbackProvider); + if (providers.length === 0) { + logger.throwArgumentError("missing providers", "providers", providers); + } + if (weights != null && weights.length !== providers.length) { + logger.throwArgumentError("too many weights", "weights", weights); + } + else if (!weights) { + weights = providers.map((p) => 1); + } + else { + weights.forEach((w) => { + if (w % 1 || w > 512 || w < 1) { + logger.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); + } + }); + } + let total = weights.reduce((accum, w) => (accum + w)); + if (quorum == null) { + quorum = total / 2; + } + else { + if (quorum > total) { + logger.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + } + } + // All networks are ready, we can know the network for certain + let ready = checkNetworks(providers.map((p) => p.network)); + if (ready) { + super(providers[0].network); + } + else { + // The network won't be known until all child providers know + let ready = Promise.all(providers.map((p) => p.getNetwork())).then((networks) => { + if (!checkNetworks(networks)) { + logger.throwError("getNetwork returned null", Logger.errors.UNKNOWN_ERROR); + } + return networks[0]; + }); + super(ready); + } + // Preserve a copy, so we do not get mutated + defineReadOnly(this, "providers", Object.freeze(providers.slice())); + defineReadOnly(this, "quorum", quorum); + defineReadOnly(this, "weights", Object.freeze(weights.slice())); + } + static doPerform(provider, method, params) { + switch (method) { + case "getBlockNumber": + case "getGasPrice": + case "getEtherPrice": + return provider[method](); + case "getBalance": + case "getTransactionCount": + case "getCode": + return provider[method](params.address, params.blockTag || "latest"); + case "getStorageAt": + return provider.getStorageAt(params.address, params.position, params.blockTag || "latest"); + case "sendTransaction": + return provider.sendTransaction(params.signedTransaction).then((result) => { + return result.hash; + }); + case "getBlock": + return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash); + case "call": + case "estimateGas": + return provider[method](params.transaction); + case "getTransaction": + case "getTransactionReceipt": + return provider[method](params.transactionHash); + case "getLogs": + return provider.getLogs(params.filter); + } + return logger.throwError("unknown method error", Logger.errors.UNKNOWN_ERROR, { + method: method, + params: params + }); + } + perform(method, params) { + let T0 = now(); + let runners = (shuffled(this.providers)).map((provider, i) => { + let weight = this.weights[i]; + let rid = nextRid++; + return { + run: () => { + let t0 = now(); + let start = t0 - T0; + this.emit("debug", { + action: "request", + rid: rid, + backend: { weight, start, provider }, + request: { method: method, params: deepCopy(params) }, + provider: this + }); + return FallbackProvider.doPerform(provider, method, params).then((result) => { + let duration = now() - t0; + this.emit("debug", { + action: "response", + rid: rid, + backend: { weight, start, duration, provider }, + request: { method: method, params: deepCopy(params) }, + response: deepCopy(result) + }); + return { weight: weight, result: result }; + }, (error) => { + let duration = now() - t0; + this.emit("debug", { + action: "response", + rid: rid, + backend: { weight, start, duration, provider }, + request: { method: method, params: deepCopy(params) }, + error: error + }); + return { weight: weight, error: error }; + }); + }, + weight: weight + }; + }); + // Broadcast transactions to all backends, any that succeed is good enough + if (method === "sendTransaction") { + return Promise.all(runners.map((r) => r.run())).then((results) => { + for (let i = 0; i < results.length; i++) { + let result = results[i]; + if (result.result) { + return result.result; + } + } + return Promise.reject(results[0].error); + }); + } + // Otherwise query backends (randomly) until we have a quorum agreement + // on the correct result + return new Promise((resolve, reject) => { + let firstError = null; + // How much weight is inflight + let inflightWeight = 0; + // All results, indexed by the serialized response. + let results = {}; + let next = () => { + if (runners.length === 0) { + return; + } + let runner = runners.shift(); + inflightWeight += runner.weight; + runner.run().then((result) => { + if (results === null) { + return; + } + inflightWeight -= runner.weight; + if (result.error) { + if (firstError == null) { + firstError = result.error; + } + } + else { + let unique = serialize(result.result); + if (results[unique] == null) { + results[unique] = []; + } + results[unique].push(result); + // Do any results meet our quroum? + for (let u in results) { + let weight = results[u].reduce((accum, r) => (accum + r.weight), 0); + if (weight >= this.quorum) { + let result = results[u][0].result; + this.emit("debug", "quorum", -1, { weight, result }); + resolve(result); + results = null; + return; + } + } + } + // Out of options; give up + if (runners.length === 0 && inflightWeight === 0) { + // @TODO: this might need some more thinking... Maybe only if half + // of the results contain non-error? + if (method === "getGasPrice") { + const values = []; + Object.keys(results).forEach((key) => { + results[key].forEach((result) => { + if (!result.result) { + return; + } + values.push(result.result); + }); + }); + values.sort((a, b) => { + if (a.lt(b)) { + return -1; + } + if (a.gt(b)) { + return 1; + } + return 0; + }); + let index = parseInt(String(values.length / 2)); + if (values.length % 2) { + resolve(values[index]); + return; + } + resolve(values[index - 1].add(values[index]).div(2)); + return; + } + if (firstError === null) { + firstError = logger.makeError("failed to meet quorum", Logger.errors.SERVER_ERROR, { + results: Object.keys(results).map((u) => { + return { + method: method, + params: params, + result: u, + weight: results[u].reduce((accum, r) => (accum + r.weight), 0) + }; + }) + }); + } + reject(firstError); + return; + } + // Queue up the next round + setTimeout(next, 0); + }); + // Fire off requests until we could possibly meet quorum + if (inflightWeight < this.quorum) { + setTimeout(next, 0); + return; + } + }; + // bootstrap firing requests + next(); + }); + } +} diff --git a/packages/providers/formatter.d.ts b/packages/providers/lib.esm/formatter.d.ts similarity index 100% rename from packages/providers/formatter.d.ts rename to packages/providers/lib.esm/formatter.d.ts diff --git a/packages/providers/lib.esm/formatter.js b/packages/providers/lib.esm/formatter.js new file mode 100644 index 000000000..0bd6c83a4 --- /dev/null +++ b/packages/providers/lib.esm/formatter.js @@ -0,0 +1,378 @@ +"use strict"; +import { getAddress, getContractAddress } from "@ethersproject/address"; +import { BigNumber } from "@ethersproject/bignumber"; +import { hexDataLength, hexDataSlice, hexValue, hexZeroPad, isHexString } from "@ethersproject/bytes"; +import { AddressZero } from "@ethersproject/constants"; +import { shallowCopy } from "@ethersproject/properties"; +import { parse as parseTransaction } from "@ethersproject/transactions"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export class Formatter { + constructor() { + logger.checkNew(new.target, Formatter); + this.formats = this.getDefaultFormats(); + } + getDefaultFormats() { + let formats = ({}); + let address = this.address.bind(this); + let bigNumber = this.bigNumber.bind(this); + let blockTag = this.blockTag.bind(this); + let data = this.data.bind(this); + let hash = this.hash.bind(this); + let hex = this.hex.bind(this); + let number = this.number.bind(this); + let strictData = (v) => { return this.data(v, true); }; + formats.transaction = { + hash: hash, + blockHash: Formatter.allowNull(hash, null), + blockNumber: Formatter.allowNull(number, null), + transactionIndex: Formatter.allowNull(number, null), + confirmations: Formatter.allowNull(number, null), + from: address, + gasPrice: bigNumber, + gasLimit: bigNumber, + to: Formatter.allowNull(address, null), + value: bigNumber, + nonce: number, + data: data, + r: Formatter.allowNull(this.uint256), + s: Formatter.allowNull(this.uint256), + v: Formatter.allowNull(number), + creates: Formatter.allowNull(address, null), + raw: Formatter.allowNull(data), + }; + formats.transactionRequest = { + from: Formatter.allowNull(address), + nonce: Formatter.allowNull(number), + gasLimit: Formatter.allowNull(bigNumber), + gasPrice: Formatter.allowNull(bigNumber), + to: Formatter.allowNull(address), + value: Formatter.allowNull(bigNumber), + data: Formatter.allowNull(strictData), + }; + formats.receiptLog = { + transactionLogIndex: Formatter.allowNull(number), + transactionIndex: number, + blockNumber: number, + transactionHash: hash, + address: address, + topics: Formatter.arrayOf(hash), + data: data, + logIndex: number, + blockHash: hash, + }; + formats.receipt = { + to: Formatter.allowNull(this.address), + from: Formatter.allowNull(this.address), + contractAddress: Formatter.allowNull(address, null), + transactionIndex: number, + root: Formatter.allowNull(hash), + gasUsed: bigNumber, + logsBloom: Formatter.allowNull(data), + blockHash: hash, + transactionHash: hash, + logs: Formatter.arrayOf(this.receiptLog.bind(this)), + blockNumber: number, + confirmations: Formatter.allowNull(number, null), + cumulativeGasUsed: bigNumber, + status: Formatter.allowNull(number) + }; + formats.block = { + hash: hash, + parentHash: hash, + number: number, + timestamp: number, + nonce: Formatter.allowNull(hex), + difficulty: this.difficulty.bind(this), + gasLimit: bigNumber, + gasUsed: bigNumber, + miner: address, + extraData: data, + transactions: Formatter.allowNull(Formatter.arrayOf(hash)), + }; + formats.blockWithTransactions = shallowCopy(formats.block); + formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); + formats.filter = { + fromBlock: Formatter.allowNull(blockTag, undefined), + toBlock: Formatter.allowNull(blockTag, undefined), + blockHash: Formatter.allowNull(hash, undefined), + address: Formatter.allowNull(address, undefined), + topics: Formatter.allowNull(this.topics.bind(this), undefined), + }; + formats.filterLog = { + blockNumber: Formatter.allowNull(number), + blockHash: Formatter.allowNull(hash), + transactionIndex: number, + removed: Formatter.allowNull(this.boolean.bind(this)), + address: address, + data: Formatter.allowFalsish(data, "0x"), + topics: Formatter.arrayOf(hash), + transactionHash: hash, + logIndex: number, + }; + return formats; + } + // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number + // Strict! Used on input. + number(number) { + return BigNumber.from(number).toNumber(); + } + // Strict! Used on input. + bigNumber(value) { + return BigNumber.from(value); + } + // Requires a boolean, "true" or "false"; returns a boolean + boolean(value) { + if (typeof (value) === "boolean") { + return value; + } + if (typeof (value) === "string") { + value = value.toLowerCase(); + if (value === "true") { + return true; + } + if (value === "false") { + return false; + } + } + throw new Error("invaid boolean - " + value); + } + hex(value, strict) { + if (typeof (value) === "string") { + if (!strict && value.substring(0, 2) !== "0x") { + value = "0x" + value; + } + if (isHexString(value)) { + return value.toLowerCase(); + } + } + return logger.throwArgumentError("invalid hash", "value", value); + } + data(value, strict) { + let result = this.hex(value, strict); + if ((result.length % 2) !== 0) { + throw new Error("invalid data; odd-length - " + value); + } + return result; + } + // Requires an address + // Strict! Used on input. + address(value) { + return getAddress(value); + } + callAddress(value) { + if (!isHexString(value, 32)) { + return null; + } + let address = getAddress(hexDataSlice(value, 12)); + return (address === AddressZero) ? null : address; + } + contractAddress(value) { + return getContractAddress(value); + } + // Strict! Used on input. + blockTag(blockTag) { + if (blockTag == null) { + return "latest"; + } + if (blockTag === "earliest") { + return "0x0"; + } + if (blockTag === "latest" || blockTag === "pending") { + return blockTag; + } + if (typeof (blockTag) === "number" || isHexString(blockTag)) { + return hexValue(blockTag); + } + throw new Error("invalid blockTag"); + } + // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. + hash(value, strict) { + let result = this.hex(value, strict); + if (hexDataLength(result) !== 32) { + return logger.throwArgumentError("invalid hash", "value", value); + } + return result; + } + // Returns the difficulty as a number, or if too large (i.e. PoA network) null + difficulty(value) { + let v = BigNumber.from(value); + try { + return v.toNumber(); + } + catch (error) { } + return null; + } + uint256(value) { + if (!isHexString(value)) { + throw new Error("invalid uint256"); + } + return hexZeroPad(value, 32); + } + _block(value, format) { + if (value.author != null && value.miner == null) { + value.miner = value.author; + } + return Formatter.check(format, value); + } + block(value) { + return this._block(value, this.formats.block); + } + blockWithTransactions(value) { + return this._block(value, this.formats.blockWithTransactions); + } + // Strict! Used on input. + transactionRequest(value) { + return Formatter.check(this.formats.transactionRequest, value); + } + transactionResponse(transaction) { + // Rename gas to gasLimit + if (transaction.gas != null && transaction.gasLimit == null) { + transaction.gasLimit = transaction.gas; + } + // Some clients (TestRPC) do strange things like return 0x0 for the + // 0 address; correct this to be a real address + if (transaction.to && BigNumber.from(transaction.to).isZero()) { + transaction.to = "0x0000000000000000000000000000000000000000"; + } + // Rename input to data + if (transaction.input != null && transaction.data == null) { + transaction.data = transaction.input; + } + // If to and creates are empty, populate the creates from the transaction + if (transaction.to == null && transaction.creates == null) { + transaction.creates = this.contractAddress(transaction); + } + // @TODO: use transaction.serialize? Have to add support for including v, r, and s... + /* + if (!transaction.raw) { + + // Very loose providers (e.g. TestRPC) do not provide a signature or raw + if (transaction.v && transaction.r && transaction.s) { + let raw = [ + stripZeros(hexlify(transaction.nonce)), + stripZeros(hexlify(transaction.gasPrice)), + stripZeros(hexlify(transaction.gasLimit)), + (transaction.to || "0x"), + stripZeros(hexlify(transaction.value || "0x")), + hexlify(transaction.data || "0x"), + stripZeros(hexlify(transaction.v || "0x")), + stripZeros(hexlify(transaction.r)), + stripZeros(hexlify(transaction.s)), + ]; + + transaction.raw = rlpEncode(raw); + } + } + */ + let result = Formatter.check(this.formats.transaction, transaction); + let networkId = transaction.networkId; + // geth-etc returns chainId + if (transaction.chainId != null && networkId == null && result.v == null) { + networkId = transaction.chainId; + } + if (isHexString(networkId)) { + networkId = BigNumber.from(networkId).toNumber(); + } + if (typeof (networkId) !== "number" && result.v != null) { + networkId = (result.v - 35) / 2; + if (networkId < 0) { + networkId = 0; + } + networkId = parseInt(networkId); + } + if (typeof (networkId) !== "number") { + networkId = 0; + } + result.networkId = networkId; + // 0x0000... should actually be null + if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { + result.blockHash = null; + } + return result; + } + transaction(value) { + return parseTransaction(value); + } + receiptLog(value) { + return Formatter.check(this.formats.receiptLog, value); + } + receipt(value) { + //let status = transactionReceipt.status; + //let root = transactionReceipt.root; + let result = Formatter.check(this.formats.receipt, value); + result.logs.forEach((entry, index) => { + if (entry.transactionLogIndex == null) { + entry.transactionLogIndex = index; + } + }); + if (value.status != null) { + result.byzantium = true; + } + return result; + } + topics(value) { + if (Array.isArray(value)) { + return value.map((v) => this.topics(v)); + } + else if (value != null) { + return this.hash(value, true); + } + return null; + } + filter(value) { + return Formatter.check(this.formats.filter, value); + } + filterLog(value) { + return Formatter.check(this.formats.filterLog, value); + } + static check(format, object) { + let result = {}; + for (let key in format) { + try { + let value = format[key](object[key]); + if (value !== undefined) { + result[key] = value; + } + } + catch (error) { + error.checkKey = key; + error.checkValue = object[key]; + throw error; + } + } + return result; + } + // if value is null-ish, nullValue is returned + static allowNull(format, nullValue) { + return (function (value) { + if (value == null) { + return nullValue; + } + return format(value); + }); + } + // If value is false-ish, replaceValue is returned + static allowFalsish(format, replaceValue) { + return (function (value) { + if (!value) { + return replaceValue; + } + return format(value); + }); + } + // Requires an Array satisfying check + static arrayOf(format) { + return (function (array) { + if (!Array.isArray(array)) { + throw new Error("not an array"); + } + let result = []; + array.forEach(function (value) { + result.push(format(value)); + }); + return result; + }); + } +} diff --git a/packages/providers/index.d.ts b/packages/providers/lib.esm/index.d.ts similarity index 100% rename from packages/providers/index.d.ts rename to packages/providers/lib.esm/index.d.ts diff --git a/packages/providers/lib.esm/index.js b/packages/providers/lib.esm/index.js new file mode 100644 index 000000000..a4695ca40 --- /dev/null +++ b/packages/providers/lib.esm/index.js @@ -0,0 +1,31 @@ +"use strict"; +import { Provider } from "@ethersproject/abstract-provider"; +import { getNetwork } from "@ethersproject/networks"; +import { BaseProvider } from "./base-provider"; +import { AlchemyProvider } from "./alchemy-provider"; +import { CloudflareProvider } from "./cloudflare-provider"; +import { EtherscanProvider } from "./etherscan-provider"; +import { FallbackProvider } from "./fallback-provider"; +import { IpcProvider } from "./ipc-provider"; +import { InfuraProvider } from "./infura-provider"; +import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider"; +import { NodesmithProvider } from "./nodesmith-provider"; +import { Web3Provider } from "./web3-provider"; +import { Formatter } from "./formatter"; +//////////////////////// +// Exports +export { +// Abstract Providers (or Abstract-ish) +Provider, BaseProvider, +/////////////////////// +// Concreate Providers +FallbackProvider, AlchemyProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, JsonRpcProvider, NodesmithProvider, Web3Provider, IpcProvider, +/////////////////////// +// Signer +JsonRpcSigner, +/////////////////////// +// Functions +getNetwork, +/////////////////////// +// Objects +Formatter }; diff --git a/packages/providers/infura-provider.d.ts b/packages/providers/lib.esm/infura-provider.d.ts similarity index 100% rename from packages/providers/infura-provider.d.ts rename to packages/providers/lib.esm/infura-provider.d.ts diff --git a/packages/providers/lib.esm/infura-provider.js b/packages/providers/lib.esm/infura-provider.js new file mode 100644 index 000000000..b637e594a --- /dev/null +++ b/packages/providers/lib.esm/infura-provider.js @@ -0,0 +1,41 @@ +"use strict"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +const defaultProjectId = "84842078b09946638c03157f83405213"; +export class InfuraProvider extends UrlJsonRpcProvider { + get projectId() { return this.apiKey; } + static getApiKey(apiKey) { + if (apiKey == null) { + return defaultProjectId; + } + return apiKey; + } + static getUrl(network, apiKey) { + let host = null; + switch (network.name) { + case "homestead": + host = "mainnet.infura.io"; + break; + case "ropsten": + host = "ropsten.infura.io"; + break; + case "rinkeby": + host = "rinkeby.infura.io"; + break; + case "kovan": + host = "kovan.infura.io"; + break; + case "goerli": + host = "goerli.infura.io"; + break; + default: + logger.throwError("unsupported network", Logger.errors.INVALID_ARGUMENT, { + argument: "network", + value: network + }); + } + return "https:/" + "/" + host + "/v3/" + apiKey; + } +} diff --git a/packages/providers/ipc-provider.d.ts b/packages/providers/lib.esm/ipc-provider.d.ts similarity index 100% rename from packages/providers/ipc-provider.d.ts rename to packages/providers/lib.esm/ipc-provider.d.ts diff --git a/packages/providers/lib.esm/ipc-provider.js b/packages/providers/lib.esm/ipc-provider.js new file mode 100644 index 000000000..6d4997722 --- /dev/null +++ b/packages/providers/lib.esm/ipc-provider.js @@ -0,0 +1,54 @@ +"use strict"; +import net from "net"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { JsonRpcProvider } from "./json-rpc-provider"; +export class IpcProvider extends JsonRpcProvider { + constructor(path, network) { + logger.checkNew(new.target, IpcProvider); + if (path == null) { + logger.throwError("missing path", Logger.errors.MISSING_ARGUMENT, { arg: "path" }); + } + super("ipc://" + path, network); + defineReadOnly(this, "path", path); + } + // @TODO: Create a connection to the IPC path and use filters instead of polling for block + send(method, params) { + // This method is very simple right now. We create a new socket + // connection each time, which may be slower, but the main + // advantage we are aiming for now is security. This simplifies + // multiplexing requests (since we do not need to multiplex). + let payload = JSON.stringify({ + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }); + return new Promise((resolve, reject) => { + let response = Buffer.alloc(0); + let stream = net.connect(this.path); + stream.on("data", (data) => { + response = Buffer.concat([response, data]); + }); + stream.on("end", () => { + try { + resolve(JSON.parse(response.toString()).result); + // @TODO: Better pull apart the error + stream.destroy(); + } + catch (error) { + reject(error); + stream.destroy(); + } + }); + stream.on("error", (error) => { + reject(error); + stream.destroy(); + }); + stream.write(payload); + stream.end(); + }); + } +} diff --git a/packages/providers/json-rpc-provider.d.ts b/packages/providers/lib.esm/json-rpc-provider.d.ts similarity index 100% rename from packages/providers/json-rpc-provider.d.ts rename to packages/providers/lib.esm/json-rpc-provider.d.ts diff --git a/packages/providers/lib.esm/json-rpc-provider.js b/packages/providers/lib.esm/json-rpc-provider.js new file mode 100644 index 000000000..52f6b5a50 --- /dev/null +++ b/packages/providers/lib.esm/json-rpc-provider.js @@ -0,0 +1,400 @@ +"use strict"; +import { Signer } from "@ethersproject/abstract-signer"; +import { BigNumber } from "@ethersproject/bignumber"; +import { hexlify, hexValue } from "@ethersproject/bytes"; +import { getNetwork } from "@ethersproject/networks"; +import { checkProperties, deepCopy, defineReadOnly, resolveProperties, shallowCopy } from "@ethersproject/properties"; +import { toUtf8Bytes } from "@ethersproject/strings"; +import { fetchJson, poll } from "@ethersproject/web"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { BaseProvider } from "./base-provider"; +function timer(timeout) { + return new Promise(function (resolve) { + setTimeout(function () { + resolve(); + }, timeout); + }); +} +function getResult(payload) { + if (payload.error) { + // @TODO: not any + let error = new Error(payload.error.message); + error.code = payload.error.code; + error.data = payload.error.data; + throw error; + } + return payload.result; +} +function getLowerCase(value) { + if (value) { + return value.toLowerCase(); + } + return value; +} +const _constructorGuard = {}; +export class JsonRpcSigner extends Signer { + constructor(constructorGuard, provider, addressOrIndex) { + logger.checkNew(new.target, JsonRpcSigner); + super(); + if (constructorGuard !== _constructorGuard) { + throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); + } + defineReadOnly(this, "provider", provider); + if (addressOrIndex == null) { + addressOrIndex = 0; + } + if (typeof (addressOrIndex) === "string") { + defineReadOnly(this, "_address", this.provider.formatter.address(addressOrIndex)); + defineReadOnly(this, "_index", null); + } + else if (typeof (addressOrIndex) === "number") { + defineReadOnly(this, "_index", addressOrIndex); + defineReadOnly(this, "_address", null); + } + else { + logger.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); + } + } + connect(provider) { + return logger.throwError("cannot alter JSON-RPC Signer connection", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "connect" + }); + } + connectUnchecked() { + return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); + } + getAddress() { + if (this._address) { + return Promise.resolve(this._address); + } + return this.provider.send("eth_accounts", []).then((accounts) => { + if (accounts.length <= this._index) { + logger.throwError("unknown account #" + this._index, Logger.errors.UNSUPPORTED_OPERATION, { + operation: "getAddress" + }); + } + return this.provider.formatter.address(accounts[this._index]); + }); + } + sendUncheckedTransaction(transaction) { + transaction = shallowCopy(transaction); + let fromAddress = this.getAddress().then((address) => { + if (address) { + address = address.toLowerCase(); + } + return address; + }); + // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user + // wishes to use this, it is easy to specify explicitly, otherwise + // we look it up for them. + if (transaction.gasLimit == null) { + let estimate = shallowCopy(transaction); + estimate.from = fromAddress; + transaction.gasLimit = this.provider.estimateGas(estimate); + } + return Promise.all([ + resolveProperties(transaction), + fromAddress + ]).then((results) => { + let tx = results[0]; + let hexTx = this.provider.constructor.hexlifyTransaction(tx); + hexTx.from = results[1]; + return this.provider.send("eth_sendTransaction", [hexTx]).then((hash) => { + return hash; + }, (error) => { + if (error.responseText) { + // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) + if (error.responseText.indexOf("insufficient funds") >= 0) { + logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, { + transaction: tx + }); + } + if (error.responseText.indexOf("nonce too low") >= 0) { + logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, { + transaction: tx + }); + } + if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { + logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, { + transaction: tx + }); + } + } + throw error; + }); + }); + } + signTransaction(transaction) { + return logger.throwError("signing transactions is unsupported", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "signTransaction" + }); + } + sendTransaction(transaction) { + return this.sendUncheckedTransaction(transaction).then((hash) => { + return poll(() => { + return this.provider.getTransaction(hash).then((tx) => { + if (tx === null) { + return undefined; + } + return this.provider._wrapTransaction(tx, hash); + }); + }, { onceBlock: this.provider }).catch((error) => { + error.transactionHash = hash; + throw error; + }); + }); + } + signMessage(message) { + let data = ((typeof (message) === "string") ? toUtf8Bytes(message) : message); + return this.getAddress().then((address) => { + // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign + return this.provider.send("eth_sign", [address.toLowerCase(), hexlify(data)]); + }); + } + unlock(password) { + let provider = this.provider; + return this.getAddress().then(function (address) { + return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]); + }); + } +} +class UncheckedJsonRpcSigner extends JsonRpcSigner { + sendTransaction(transaction) { + return this.sendUncheckedTransaction(transaction).then((hash) => { + return { + hash: hash, + nonce: null, + gasLimit: null, + gasPrice: null, + data: null, + value: null, + chainId: null, + confirmations: 0, + from: null, + wait: (confirmations) => { return this.provider.waitForTransaction(hash, confirmations); } + }; + }); + } +} +const allowedTransactionKeys = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +export class JsonRpcProvider extends BaseProvider { + constructor(url, network) { + logger.checkNew(new.target, JsonRpcProvider); + // One parameter, but it is a network name, so swap it with the URL + if (typeof (url) === "string") { + if (network === null && getNetwork(url)) { + network = url; + url = null; + } + } + if (network) { + // The network has been specified explicitly, we can use it + super(network); + } + else { + // The network is unknown, query the JSON-RPC for it + let ready = new Promise((resolve, reject) => { + setTimeout(() => { + this.send("eth_chainId", []).then((result) => { + resolve(getNetwork(BigNumber.from(result).toNumber())); + }).catch((error) => { + this.send("net_version", []).then((result) => { + resolve(getNetwork(BigNumber.from(result).toNumber())); + }).catch((error) => { + reject(logger.makeError("could not detect network", Logger.errors.NETWORK_ERROR)); + }); + }); + }); + }); + super(ready); + } + // Default URL + if (!url) { + url = "http:/" + "/localhost:8545"; + } + if (typeof (url) === "string") { + this.connection = { + url: url + }; + } + else { + this.connection = url; + } + this._nextId = 42; + } + getSigner(addressOrIndex) { + return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); + } + getUncheckedSigner(addressOrIndex) { + return this.getSigner(addressOrIndex).connectUnchecked(); + } + listAccounts() { + return this.send("eth_accounts", []).then((accounts) => { + return accounts.map((a) => this.formatter.address(a)); + }); + } + send(method, params) { + let request = { + method: method, + params: params, + id: (this._nextId++), + jsonrpc: "2.0" + }; + this.emit("debug", { + action: "request", + request: deepCopy(request), + provider: this + }); + return fetchJson(this.connection, JSON.stringify(request), getResult).then((result) => { + this.emit("debug", { + action: "response", + request: request, + response: result, + provider: this + }); + return result; + }); + } + perform(method, params) { + switch (method) { + case "getBlockNumber": + return this.send("eth_blockNumber", []); + case "getGasPrice": + return this.send("eth_gasPrice", []); + case "getBalance": + return this.send("eth_getBalance", [getLowerCase(params.address), params.blockTag]); + case "getTransactionCount": + return this.send("eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]); + case "getCode": + return this.send("eth_getCode", [getLowerCase(params.address), params.blockTag]); + case "getStorageAt": + return this.send("eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]); + case "sendTransaction": + return this.send("eth_sendRawTransaction", [params.signedTransaction]).catch((error) => { + if (error.responseText) { + // "insufficient funds for gas * price + value" + if (error.responseText.indexOf("insufficient funds") > 0) { + logger.throwError("insufficient funds", Logger.errors.INSUFFICIENT_FUNDS, {}); + } + // "nonce too low" + if (error.responseText.indexOf("nonce too low") > 0) { + logger.throwError("nonce has already been used", Logger.errors.NONCE_EXPIRED, {}); + } + // "replacement transaction underpriced" + if (error.responseText.indexOf("replacement transaction underpriced") > 0) { + logger.throwError("replacement fee too low", Logger.errors.REPLACEMENT_UNDERPRICED, {}); + } + } + throw error; + }); + case "getBlock": + if (params.blockTag) { + return this.send("eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]); + } + else if (params.blockHash) { + return this.send("eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]); + } + return logger.throwArgumentError("invalid block tag or block hash", "params", params); + case "getTransaction": + return this.send("eth_getTransactionByHash", [params.transactionHash]); + case "getTransactionReceipt": + return this.send("eth_getTransactionReceipt", [params.transactionHash]); + case "call": + return this.send("eth_call", [this.constructor.hexlifyTransaction(params.transaction, { from: true }), params.blockTag]); + case "estimateGas": + return this.send("eth_estimateGas", [this.constructor.hexlifyTransaction(params.transaction, { from: true })]); + case "getLogs": + if (params.filter && params.filter.address != null) { + params.filter.address = getLowerCase(params.filter.address); + } + return this.send("eth_getLogs", [params.filter]); + default: + break; + } + return logger.throwError(method + " not implemented", Logger.errors.NOT_IMPLEMENTED, { operation: method }); + } + _startPending() { + if (this._pendingFilter != null) { + return; + } + let self = this; + let pendingFilter = this.send("eth_newPendingTransactionFilter", []); + this._pendingFilter = pendingFilter; + pendingFilter.then(function (filterId) { + function poll() { + self.send("eth_getFilterChanges", [filterId]).then(function (hashes) { + if (self._pendingFilter != pendingFilter) { + return null; + } + let seq = Promise.resolve(); + hashes.forEach(function (hash) { + // @TODO: This should be garbage collected at some point... How? When? + self._emitted["t:" + hash.toLowerCase()] = "pending"; + seq = seq.then(function () { + return self.getTransaction(hash).then(function (tx) { + self.emit("pending", tx); + return null; + }); + }); + }); + return seq.then(function () { + return timer(1000); + }); + }).then(function () { + if (self._pendingFilter != pendingFilter) { + self.send("eth_uninstallFilter", [filterId]); + return; + } + setTimeout(function () { poll(); }, 0); + return null; + }).catch((error) => { }); + } + poll(); + return filterId; + }).catch((error) => { }); + } + _stopPending() { + this._pendingFilter = null; + } + // Convert an ethers.js transaction into a JSON-RPC transaction + // - gasLimit => gas + // - All values hexlified + // - All numeric values zero-striped + // NOTE: This allows a TransactionRequest, but all values should be resolved + // before this is called + static hexlifyTransaction(transaction, allowExtra) { + // Check only allowed properties are given + let allowed = shallowCopy(allowedTransactionKeys); + if (allowExtra) { + for (let key in allowExtra) { + if (allowExtra[key]) { + allowed[key] = true; + } + } + } + checkProperties(transaction, allowed); + let result = {}; + // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. + ["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + let value = hexValue(transaction[key]); + if (key === "gasLimit") { + key = "gas"; + } + result[key] = value; + }); + ["from", "to", "data"].forEach(function (key) { + if (transaction[key] == null) { + return; + } + result[key] = hexlify(transaction[key]); + }); + return result; + } +} diff --git a/packages/providers/nodesmith-provider.d.ts b/packages/providers/lib.esm/nodesmith-provider.d.ts similarity index 100% rename from packages/providers/nodesmith-provider.d.ts rename to packages/providers/lib.esm/nodesmith-provider.d.ts diff --git a/packages/providers/lib.esm/nodesmith-provider.js b/packages/providers/lib.esm/nodesmith-provider.js new file mode 100644 index 000000000..b8a4c352d --- /dev/null +++ b/packages/providers/lib.esm/nodesmith-provider.js @@ -0,0 +1,35 @@ +"use strict"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +// Special API key provided by Nodesmith for ethers.js +const defaultApiKey = "ETHERS_JS_SHARED"; +export class NodesmithProvider extends UrlJsonRpcProvider { + static getApiKey(apiKey) { + return apiKey || defaultApiKey; + } + static getUrl(network, apiKey) { + let host = null; + switch (network.name) { + case "homestead": + host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; + break; + case "ropsten": + host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; + break; + case "rinkeby": + host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; + break; + case "goerli": + host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; + break; + case "kovan": + host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; + break; + default: + logger.throwArgumentError("unsupported network", "network", arguments[0]); + } + return (host + "?apiKey=" + apiKey); + } +} diff --git a/packages/providers/url-json-rpc-provider.d.ts b/packages/providers/lib.esm/url-json-rpc-provider.d.ts similarity index 100% rename from packages/providers/url-json-rpc-provider.d.ts rename to packages/providers/lib.esm/url-json-rpc-provider.d.ts diff --git a/packages/providers/lib.esm/url-json-rpc-provider.js b/packages/providers/lib.esm/url-json-rpc-provider.js new file mode 100644 index 000000000..85ea423fa --- /dev/null +++ b/packages/providers/lib.esm/url-json-rpc-provider.js @@ -0,0 +1,41 @@ +"use strict"; +import { getNetwork } from "@ethersproject/networks"; +import { defineReadOnly, getStatic } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { JsonRpcProvider } from "./json-rpc-provider"; +export class UrlJsonRpcProvider extends JsonRpcProvider { + constructor(network, apiKey) { + logger.checkAbstract(new.target, UrlJsonRpcProvider); + // Normalize the Network and API Key + network = getStatic((new.target), "getNetwork")(network); + apiKey = getStatic((new.target), "getApiKey")(apiKey); + let url = getStatic((new.target), "getUrl")(network, apiKey); + super(url, network); + defineReadOnly(this, "apiKey", apiKey); + } + _startPending() { + logger.warn("WARNING: API provider does not support pending filters"); + } + getSigner(address) { + logger.throwError("API provider does not support signing", Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); + return null; + } + listAccounts() { + return Promise.resolve([]); + } + static getNetwork(network) { + return getNetwork((network == null) ? "homestead" : network); + } + // Return a defaultApiKey if null, otherwise validate the API key + static getApiKey(apiKey) { + return apiKey; + } + // Returns the url for the given network and API key + static getUrl(network, apiKey) { + return logger.throwError("not implemented; sub-classes must override getUrl", Logger.errors.NOT_IMPLEMENTED, { + operation: "getUrl" + }); + } +} diff --git a/packages/providers/web3-provider.d.ts b/packages/providers/lib.esm/web3-provider.d.ts similarity index 100% rename from packages/providers/web3-provider.d.ts rename to packages/providers/lib.esm/web3-provider.d.ts diff --git a/packages/providers/lib.esm/web3-provider.js b/packages/providers/lib.esm/web3-provider.js new file mode 100644 index 000000000..fec5ece83 --- /dev/null +++ b/packages/providers/lib.esm/web3-provider.js @@ -0,0 +1,63 @@ +"use strict"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { JsonRpcProvider } from "./json-rpc-provider"; +/* +@TODO +utils.defineProperty(Web3Signer, "onchange", { + +}); + +*/ +export class Web3Provider extends JsonRpcProvider { + constructor(web3Provider, network) { + logger.checkNew(new.target, Web3Provider); + // HTTP has a host; IPC has a path. + super(web3Provider.host || web3Provider.path || "", network); + if (web3Provider) { + if (web3Provider.sendAsync) { + this._sendAsync = web3Provider.sendAsync.bind(web3Provider); + } + else if (web3Provider.send) { + this._sendAsync = web3Provider.send.bind(web3Provider); + } + } + if (!web3Provider || !this._sendAsync) { + logger.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); + } + defineReadOnly(this, "_web3Provider", web3Provider); + } + send(method, params) { + // Metamask complains about eth_sign (and on some versions hangs) + if (method == "eth_sign" && this._web3Provider.isMetaMask) { + // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign + method = "personal_sign"; + params = [params[1], params[0]]; + } + return new Promise((resolve, reject) => { + let request = { + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }; + this._sendAsync(request, function (error, result) { + if (error) { + reject(error); + return; + } + if (result.error) { + // @TODO: not any + let error = new Error(result.error.message); + error.code = result.error.code; + error.data = result.error.data; + reject(error); + return; + } + resolve(result.result); + }); + }); + } +} diff --git a/packages/providers/lib/_version.d.ts b/packages/providers/lib/_version.d.ts new file mode 100644 index 000000000..d3f7fbc6f --- /dev/null +++ b/packages/providers/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "providers/5.0.0-beta.140"; diff --git a/packages/providers/_version.js b/packages/providers/lib/_version.js similarity index 100% rename from packages/providers/_version.js rename to packages/providers/lib/_version.js diff --git a/packages/providers/lib/alchemy-provider.d.ts b/packages/providers/lib/alchemy-provider.d.ts new file mode 100644 index 000000000..4117d99b5 --- /dev/null +++ b/packages/providers/lib/alchemy-provider.d.ts @@ -0,0 +1,7 @@ +import { Network } from "@ethersproject/networks"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +export declare class AlchemyProvider extends UrlJsonRpcProvider { + readonly apiKey: string; + static getApiKey(apiKey: string): string; + static getUrl(network: Network, apiKey: string): string; +} diff --git a/packages/providers/alchemy-provider.js b/packages/providers/lib/alchemy-provider.js similarity index 100% rename from packages/providers/alchemy-provider.js rename to packages/providers/lib/alchemy-provider.js diff --git a/packages/providers/lib/base-provider.d.ts b/packages/providers/lib/base-provider.d.ts new file mode 100644 index 000000000..f06395664 --- /dev/null +++ b/packages/providers/lib/base-provider.d.ts @@ -0,0 +1,98 @@ +import { Block, BlockTag, BlockWithTransactions, EventType, Filter, FilterByBlockHash, Listener, Log, Provider, TransactionReceipt, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { Network, Networkish } from "@ethersproject/networks"; +import { Transaction } from "@ethersproject/transactions"; +import { Formatter } from "./formatter"; +/** + * EventType + * - "block" + * - "pending" + * - "error" + * - filter + * - topics array + * - transaction hash + */ +declare class Event { + readonly listener: Listener; + readonly once: boolean; + readonly tag: string; + constructor(tag: string, listener: Listener, once: boolean); + pollable(): boolean; +} +export declare class BaseProvider extends Provider { + _network: Network; + _events: Array; + formatter: Formatter; + _emitted: { + [eventName: string]: number | "pending"; + }; + _pollingInterval: number; + _poller: any; + _lastBlockNumber: number; + _fastBlockNumber: number; + _fastBlockNumberPromise: Promise; + _fastQueryDate: number; + /** + * ready + * + * A Promise that resolves only once the provider is ready. + * + * Sub-classes that call the super with a network without a chainId + * MUST set this. Standard named networks have a known chainId. + * + */ + ready: Promise; + constructor(network: Networkish | Promise); + static getFormatter(): Formatter; + static getNetwork(network: Networkish): Network; + poll(): void; + resetEventsBlock(blockNumber: number): void; + readonly network: Network; + getNetwork(): Promise; + readonly blockNumber: number; + polling: boolean; + pollingInterval: number; + _getFastBlockNumber(): Promise; + _setFastBlockNumber(blockNumber: number): void; + waitForTransaction(transactionHash: string, confirmations?: number): Promise; + _runPerform(method: string, params: { + [key: string]: () => any; + }): Promise; + getBlockNumber(): Promise; + getGasPrice(): Promise; + getBalance(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + getTransactionCount(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + getCode(addressOrName: string | Promise, blockTag?: BlockTag | Promise): Promise; + getStorageAt(addressOrName: string | Promise, position: BigNumberish | Promise, blockTag?: BlockTag | Promise): Promise; + _wrapTransaction(tx: Transaction, hash?: string): TransactionResponse; + sendTransaction(signedTransaction: string | Promise): Promise; + _getTransactionRequest(transaction: TransactionRequest | Promise): Promise; + _getFilter(filter: Filter | FilterByBlockHash | Promise): Promise; + call(transaction: TransactionRequest | Promise, blockTag?: BlockTag | Promise): Promise; + estimateGas(transaction: TransactionRequest | Promise): Promise; + _getAddress(addressOrName: string | Promise): Promise; + _getBlock(blockHashOrBlockTag: BlockTag | string | Promise, includeTransactions?: boolean): Promise; + getBlock(blockHashOrBlockTag: BlockTag | string | Promise): Promise; + getBlockWithTransactions(blockHashOrBlockTag: BlockTag | string | Promise): Promise; + getTransaction(transactionHash: string): Promise; + getTransactionReceipt(transactionHash: string): Promise; + getLogs(filter: Filter | FilterByBlockHash | Promise): Promise>; + getEtherPrice(): Promise; + _getBlockTag(blockTag: BlockTag | Promise): Promise; + _getResolver(name: string): Promise; + resolveName(name: string | Promise): Promise; + lookupAddress(address: string | Promise): Promise; + perform(method: string, params: any): Promise; + _startPending(): void; + _stopPending(): void; + _checkPolling(): void; + _addEventListener(eventName: EventType, listener: Listener, once: boolean): this; + on(eventName: EventType, listener: Listener): this; + once(eventName: EventType, listener: Listener): this; + emit(eventName: EventType, ...args: Array): boolean; + listenerCount(eventName?: EventType): number; + listeners(eventName?: EventType): Array; + off(eventName: EventType, listener?: Listener): this; + removeAllListeners(eventName?: EventType): this; +} +export {}; diff --git a/packages/providers/base-provider.js b/packages/providers/lib/base-provider.js similarity index 100% rename from packages/providers/base-provider.js rename to packages/providers/lib/base-provider.js diff --git a/packages/providers/lib/browser-ipc-provider.d.ts b/packages/providers/lib/browser-ipc-provider.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/providers/lib/browser-ipc-provider.js b/packages/providers/lib/browser-ipc-provider.js new file mode 100644 index 000000000..d102e8a93 --- /dev/null +++ b/packages/providers/lib/browser-ipc-provider.js @@ -0,0 +1,2 @@ +"use strict"; +module.exports.IpcProvider = null; diff --git a/packages/providers/lib/browser-net.d.ts b/packages/providers/lib/browser-net.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/providers/lib/browser-net.js b/packages/providers/lib/browser-net.js new file mode 100644 index 000000000..66607aa7d --- /dev/null +++ b/packages/providers/lib/browser-net.js @@ -0,0 +1,2 @@ +"use strict"; +module.exports = {}; diff --git a/packages/providers/lib/cloudflare-provider.d.ts b/packages/providers/lib/cloudflare-provider.d.ts new file mode 100644 index 000000000..86e6cc0e7 --- /dev/null +++ b/packages/providers/lib/cloudflare-provider.d.ts @@ -0,0 +1,5 @@ +import { Network } from "@ethersproject/networks"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +export declare class CloudflareProvider extends UrlJsonRpcProvider { + static getUrl(network: Network, apiKey?: string): string; +} diff --git a/packages/providers/cloudflare-provider.js b/packages/providers/lib/cloudflare-provider.js similarity index 100% rename from packages/providers/cloudflare-provider.js rename to packages/providers/lib/cloudflare-provider.js diff --git a/packages/providers/lib/etherscan-provider.d.ts b/packages/providers/lib/etherscan-provider.d.ts new file mode 100644 index 000000000..a734f2517 --- /dev/null +++ b/packages/providers/lib/etherscan-provider.d.ts @@ -0,0 +1,10 @@ +import { BlockTag, TransactionResponse } from "@ethersproject/abstract-provider"; +import { Networkish } from "@ethersproject/networks"; +import { BaseProvider } from "./base-provider"; +export declare class EtherscanProvider extends BaseProvider { + readonly baseUrl: string; + readonly apiKey: string; + constructor(network?: Networkish, apiKey?: string); + perform(method: string, params: any): Promise; + getHistory(addressOrName: string | Promise, startBlock?: BlockTag, endBlock?: BlockTag): Promise>; +} diff --git a/packages/providers/etherscan-provider.js b/packages/providers/lib/etherscan-provider.js similarity index 100% rename from packages/providers/etherscan-provider.js rename to packages/providers/lib/etherscan-provider.js diff --git a/packages/providers/lib/fallback-provider.d.ts b/packages/providers/lib/fallback-provider.d.ts new file mode 100644 index 000000000..36f2c6b59 --- /dev/null +++ b/packages/providers/lib/fallback-provider.d.ts @@ -0,0 +1,13 @@ +import { BaseProvider } from "./base-provider"; +export declare class FallbackProvider extends BaseProvider { + readonly providers: Array; + readonly weights: Array; + readonly quorum: number; + constructor(providers: Array, quorum?: number, weights?: Array); + static doPerform(provider: BaseProvider, method: string, params: { + [name: string]: any; + }): Promise; + perform(method: string, params: { + [name: string]: any; + }): any; +} diff --git a/packages/providers/fallback-provider.js b/packages/providers/lib/fallback-provider.js similarity index 100% rename from packages/providers/fallback-provider.js rename to packages/providers/lib/fallback-provider.js diff --git a/packages/providers/lib/formatter.d.ts b/packages/providers/lib/formatter.d.ts new file mode 100644 index 000000000..63f10fee9 --- /dev/null +++ b/packages/providers/lib/formatter.d.ts @@ -0,0 +1,50 @@ +import { Block, TransactionReceipt, TransactionResponse } from "@ethersproject/abstract-provider"; +import { BigNumber } from "@ethersproject/bignumber"; +export declare type FormatFunc = (value: any) => any; +export declare type FormatFuncs = { + [key: string]: FormatFunc; +}; +export declare type Formats = { + transaction: FormatFuncs; + transactionRequest: FormatFuncs; + receipt: FormatFuncs; + receiptLog: FormatFuncs; + block: FormatFuncs; + blockWithTransactions: FormatFuncs; + filter: FormatFuncs; + filterLog: FormatFuncs; +}; +export declare class Formatter { + readonly formats: Formats; + constructor(); + getDefaultFormats(): Formats; + number(number: any): number; + bigNumber(value: any): BigNumber; + boolean(value: any): boolean; + hex(value: any, strict?: boolean): string; + data(value: any, strict?: boolean): string; + address(value: any): string; + callAddress(value: any): string; + contractAddress(value: any): string; + blockTag(blockTag: any): string; + hash(value: any, strict?: boolean): string; + difficulty(value: any): number; + uint256(value: any): string; + _block(value: any, format: any): Block; + block(value: any): Block; + blockWithTransactions(value: any): Block; + transactionRequest(value: any): any; + transactionResponse(transaction: any): TransactionResponse; + transaction(value: any): any; + receiptLog(value: any): any; + receipt(value: any): TransactionReceipt; + topics(value: any): any; + filter(value: any): any; + filterLog(value: any): any; + static check(format: { + [name: string]: FormatFunc; + }, object: any): any; + static allowNull(format: FormatFunc, nullValue?: any): FormatFunc; + static allowFalsish(format: FormatFunc, replaceValue: any): FormatFunc; + static arrayOf(format: FormatFunc): FormatFunc; +} diff --git a/packages/providers/formatter.js b/packages/providers/lib/formatter.js similarity index 100% rename from packages/providers/formatter.js rename to packages/providers/lib/formatter.js diff --git a/packages/providers/lib/index.d.ts b/packages/providers/lib/index.d.ts new file mode 100644 index 000000000..443c0af20 --- /dev/null +++ b/packages/providers/lib/index.d.ts @@ -0,0 +1,16 @@ +import { Block, BlockTag, EventType, Filter, Log, Listener, Provider, TransactionReceipt, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { getNetwork } from "@ethersproject/networks"; +import { Network, Networkish } from "@ethersproject/networks"; +import { BaseProvider } from "./base-provider"; +import { AlchemyProvider } from "./alchemy-provider"; +import { CloudflareProvider } from "./cloudflare-provider"; +import { EtherscanProvider } from "./etherscan-provider"; +import { FallbackProvider } from "./fallback-provider"; +import { IpcProvider } from "./ipc-provider"; +import { InfuraProvider } from "./infura-provider"; +import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider"; +import { NodesmithProvider } from "./nodesmith-provider"; +import { Web3Provider } from "./web3-provider"; +import { AsyncSendable } from "./web3-provider"; +import { Formatter } from "./formatter"; +export { Provider, BaseProvider, FallbackProvider, AlchemyProvider, CloudflareProvider, EtherscanProvider, InfuraProvider, JsonRpcProvider, NodesmithProvider, Web3Provider, IpcProvider, JsonRpcSigner, getNetwork, Formatter, Block, BlockTag, EventType, Filter, Log, Listener, TransactionReceipt, TransactionRequest, TransactionResponse, AsyncSendable, Network, Networkish }; diff --git a/packages/providers/index.js b/packages/providers/lib/index.js similarity index 100% rename from packages/providers/index.js rename to packages/providers/lib/index.js diff --git a/packages/providers/lib/infura-provider.d.ts b/packages/providers/lib/infura-provider.d.ts new file mode 100644 index 000000000..f3310084f --- /dev/null +++ b/packages/providers/lib/infura-provider.d.ts @@ -0,0 +1,7 @@ +import { Network } from "@ethersproject/networks"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +export declare class InfuraProvider extends UrlJsonRpcProvider { + readonly projectId: string; + static getApiKey(apiKey: string): string; + static getUrl(network: Network, apiKey: string): string; +} diff --git a/packages/providers/infura-provider.js b/packages/providers/lib/infura-provider.js similarity index 100% rename from packages/providers/infura-provider.js rename to packages/providers/lib/infura-provider.js diff --git a/packages/providers/lib/ipc-provider.d.ts b/packages/providers/lib/ipc-provider.d.ts new file mode 100644 index 000000000..736ea96b5 --- /dev/null +++ b/packages/providers/lib/ipc-provider.d.ts @@ -0,0 +1,7 @@ +import { Networkish } from "@ethersproject/networks"; +import { JsonRpcProvider } from "./json-rpc-provider"; +export declare class IpcProvider extends JsonRpcProvider { + readonly path: string; + constructor(path: string, network?: Networkish); + send(method: string, params: any): Promise; +} diff --git a/packages/providers/ipc-provider.js b/packages/providers/lib/ipc-provider.js similarity index 100% rename from packages/providers/ipc-provider.js rename to packages/providers/lib/ipc-provider.js diff --git a/packages/providers/lib/json-rpc-provider.d.ts b/packages/providers/lib/json-rpc-provider.d.ts new file mode 100644 index 000000000..8bf115919 --- /dev/null +++ b/packages/providers/lib/json-rpc-provider.d.ts @@ -0,0 +1,42 @@ +import { Provider, TransactionRequest, TransactionResponse } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { Bytes } from "@ethersproject/bytes"; +import { Networkish } from "@ethersproject/networks"; +import { ConnectionInfo } from "@ethersproject/web"; +import { BaseProvider } from "./base-provider"; +export declare class JsonRpcSigner extends Signer { + readonly provider: JsonRpcProvider; + _index: number; + _address: string; + constructor(constructorGuard: any, provider: JsonRpcProvider, addressOrIndex?: string | number); + connect(provider: Provider): JsonRpcSigner; + connectUnchecked(): JsonRpcSigner; + getAddress(): Promise; + sendUncheckedTransaction(transaction: TransactionRequest): Promise; + signTransaction(transaction: TransactionRequest): Promise; + sendTransaction(transaction: TransactionRequest): Promise; + signMessage(message: Bytes | string): Promise; + unlock(password: string): Promise; +} +declare class UncheckedJsonRpcSigner extends JsonRpcSigner { + sendTransaction(transaction: TransactionRequest): Promise; +} +export declare class JsonRpcProvider extends BaseProvider { + readonly connection: ConnectionInfo; + _pendingFilter: Promise; + _nextId: number; + constructor(url?: ConnectionInfo | string, network?: Networkish); + getSigner(addressOrIndex?: string | number): JsonRpcSigner; + getUncheckedSigner(addressOrIndex?: string | number): UncheckedJsonRpcSigner; + listAccounts(): Promise>; + send(method: string, params: any): Promise; + perform(method: string, params: any): Promise; + _startPending(): void; + _stopPending(): void; + static hexlifyTransaction(transaction: TransactionRequest, allowExtra?: { + [key: string]: boolean; + }): { + [key: string]: string; + }; +} +export {}; diff --git a/packages/providers/json-rpc-provider.js b/packages/providers/lib/json-rpc-provider.js similarity index 100% rename from packages/providers/json-rpc-provider.js rename to packages/providers/lib/json-rpc-provider.js diff --git a/packages/providers/lib/nodesmith-provider.d.ts b/packages/providers/lib/nodesmith-provider.d.ts new file mode 100644 index 000000000..8021a6b9a --- /dev/null +++ b/packages/providers/lib/nodesmith-provider.d.ts @@ -0,0 +1,6 @@ +import { Network } from "@ethersproject/networks"; +import { UrlJsonRpcProvider } from "./url-json-rpc-provider"; +export declare class NodesmithProvider extends UrlJsonRpcProvider { + static getApiKey(apiKey: string): string; + static getUrl(network: Network, apiKey?: string): string; +} diff --git a/packages/providers/nodesmith-provider.js b/packages/providers/lib/nodesmith-provider.js similarity index 100% rename from packages/providers/nodesmith-provider.js rename to packages/providers/lib/nodesmith-provider.js diff --git a/packages/providers/lib/url-json-rpc-provider.d.ts b/packages/providers/lib/url-json-rpc-provider.d.ts new file mode 100644 index 000000000..e4c51f0f5 --- /dev/null +++ b/packages/providers/lib/url-json-rpc-provider.d.ts @@ -0,0 +1,12 @@ +import { Network, Networkish } from "@ethersproject/networks"; +import { JsonRpcProvider, JsonRpcSigner } from "./json-rpc-provider"; +export declare class UrlJsonRpcProvider extends JsonRpcProvider { + readonly apiKey: string; + constructor(network?: Networkish, apiKey?: string); + _startPending(): void; + getSigner(address?: string): JsonRpcSigner; + listAccounts(): Promise>; + static getNetwork(network?: Networkish): Network; + static getApiKey(apiKey: string): string; + static getUrl(network: Network, apiKey: string): string; +} diff --git a/packages/providers/url-json-rpc-provider.js b/packages/providers/lib/url-json-rpc-provider.js similarity index 100% rename from packages/providers/url-json-rpc-provider.js rename to packages/providers/lib/url-json-rpc-provider.js diff --git a/packages/providers/lib/web3-provider.d.ts b/packages/providers/lib/web3-provider.d.ts new file mode 100644 index 000000000..1562b10a2 --- /dev/null +++ b/packages/providers/lib/web3-provider.d.ts @@ -0,0 +1,15 @@ +import { Networkish } from "@ethersproject/networks"; +import { JsonRpcProvider } from "./json-rpc-provider"; +export declare type AsyncSendable = { + isMetaMask?: boolean; + host?: string; + path?: string; + sendAsync?: (request: any, callback: (error: any, response: any) => void) => void; + send?: (request: any, callback: (error: any, response: any) => void) => void; +}; +export declare class Web3Provider extends JsonRpcProvider { + readonly _web3Provider: AsyncSendable; + private _sendAsync; + constructor(web3Provider: AsyncSendable, network?: Networkish); + send(method: string, params: any): Promise; +} diff --git a/packages/providers/web3-provider.js b/packages/providers/lib/web3-provider.js similarity index 100% rename from packages/providers/web3-provider.js rename to packages/providers/lib/web3-provider.js diff --git a/packages/providers/package.json b/packages/providers/package.json index 4a98e9417..21e1b3585 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/providers", - "version": "5.0.0-beta.140", + "version": "5.0.0-beta.141", "description": "Ethereum Providers for ethers.", - "main": "index.js", + "main": "./lib/index.js", "browser": { "net": "./browser-net.js", "./ipc-provider": "./browser-ipc-provider.js" @@ -43,5 +43,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xfdbe8dcebf941a3a954d318ad58e56687d180acf02b77ed3b5d6d7da300cda7c" + "module": "./lib.esm/index.js", + "tarballHash": "0x7d6d0ea53f6c97c8a247450d2ca7f3a6d85f9fc3911bbadb86c63f12e5295e63" } diff --git a/packages/providers/tsconfig.json b/packages/providers/tsconfig.json index 969328db8..92930025f 100644 --- a/packages/providers/tsconfig.json +++ b/packages/providers/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts" + "./src.ts/*.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/random/.gitignore b/packages/random/.gitignore index aa5c62527..ac0298ec4 100644 --- a/packages/random/.gitignore +++ b/packages/random/.gitignore @@ -1 +1,2 @@ -browser.d.ts +lib/browser.d.ts +lib.esm/browser.d.ts diff --git a/packages/random/_version.d.ts b/packages/random/lib.esm/_version.d.ts similarity index 100% rename from packages/random/_version.d.ts rename to packages/random/lib.esm/_version.d.ts diff --git a/packages/random/lib.esm/_version.js b/packages/random/lib.esm/_version.js new file mode 100644 index 000000000..0fdf0346e --- /dev/null +++ b/packages/random/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "random/5.0.0-beta.127"; diff --git a/packages/random/lib.esm/browser.js b/packages/random/lib.esm/browser.js new file mode 100644 index 000000000..0ca8882cb --- /dev/null +++ b/packages/random/lib.esm/browser.js @@ -0,0 +1,26 @@ +"use strict"; +import { arrayify } from "@ethersproject/bytes"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export { shuffled } from "./shuffle"; +let crypto = global.crypto || global.msCrypto; +if (!crypto || !crypto.getRandomValues) { + logger.warn("WARNING: Missing strong random number source"); + crypto = { + getRandomValues: function (buffer) { + return logger.throwError("no secure random source avaialble", Logger.errors.UNSUPPORTED_OPERATION, { + operation: "crypto.getRandomValues" + }); + } + }; +} +export function randomBytes(length) { + if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { + logger.throwArgumentError("invalid length", "length", length); + } + let result = new Uint8Array(length); + crypto.getRandomValues(result); + return arrayify(result); +} +; diff --git a/packages/random/index.d.ts b/packages/random/lib.esm/index.d.ts similarity index 100% rename from packages/random/index.d.ts rename to packages/random/lib.esm/index.d.ts diff --git a/packages/random/lib.esm/index.js b/packages/random/lib.esm/index.js new file mode 100644 index 000000000..4b42c8104 --- /dev/null +++ b/packages/random/lib.esm/index.js @@ -0,0 +1,7 @@ +"use strict"; +import { randomBytes as _randomBytes } from "crypto"; +import { arrayify } from "@ethersproject/bytes"; +export { shuffled } from "./shuffle"; +export function randomBytes(length) { + return arrayify(_randomBytes(length)); +} diff --git a/packages/random/shuffle.d.ts b/packages/random/lib.esm/shuffle.d.ts similarity index 100% rename from packages/random/shuffle.d.ts rename to packages/random/lib.esm/shuffle.d.ts diff --git a/packages/random/lib.esm/shuffle.js b/packages/random/lib.esm/shuffle.js new file mode 100644 index 000000000..8fb808423 --- /dev/null +++ b/packages/random/lib.esm/shuffle.js @@ -0,0 +1,11 @@ +"use strict"; +export function shuffled(array) { + array = array.slice(); + for (let i = array.length - 1; i > 0; i--) { + let j = Math.floor(Math.random() * (i + 1)); + let tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + return array; +} diff --git a/packages/random/lib/_version.d.ts b/packages/random/lib/_version.d.ts new file mode 100644 index 000000000..c97e93d8c --- /dev/null +++ b/packages/random/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "random/5.0.0-beta.127"; diff --git a/packages/random/_version.js b/packages/random/lib/_version.js similarity index 100% rename from packages/random/_version.js rename to packages/random/lib/_version.js diff --git a/packages/random/browser.js b/packages/random/lib/browser.js similarity index 100% rename from packages/random/browser.js rename to packages/random/lib/browser.js diff --git a/packages/random/lib/index.d.ts b/packages/random/lib/index.d.ts new file mode 100644 index 000000000..43bd1f8a7 --- /dev/null +++ b/packages/random/lib/index.d.ts @@ -0,0 +1,2 @@ +export { shuffled } from "./shuffle"; +export declare function randomBytes(length: number): Uint8Array; diff --git a/packages/random/index.js b/packages/random/lib/index.js similarity index 100% rename from packages/random/index.js rename to packages/random/lib/index.js diff --git a/packages/random/lib/shuffle.d.ts b/packages/random/lib/shuffle.d.ts new file mode 100644 index 000000000..fab6f5af3 --- /dev/null +++ b/packages/random/lib/shuffle.d.ts @@ -0,0 +1 @@ +export declare function shuffled(array: Array): Array; diff --git a/packages/random/shuffle.js b/packages/random/lib/shuffle.js similarity index 100% rename from packages/random/shuffle.js rename to packages/random/lib/shuffle.js diff --git a/packages/random/package.json b/packages/random/package.json index ce0d27ccf..aa5ea22d5 100644 --- a/packages/random/package.json +++ b/packages/random/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/random", - "version": "5.0.0-beta.127", + "version": "5.0.0-beta.128", "description": "Random utility functions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "browser": "browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -28,5 +28,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x6bf0f2433d11c1eabbf98034baebfacc42ed5392911aafda103b33b4af06c864" + "module": "./lib.esm/index.js", + "tarballHash": "0x12bbfa545217fbf34da3e01d4e42d231a202b4b8a615d2f4e10b84c6fa354edb" } diff --git a/packages/random/tsconfig.json b/packages/random/tsconfig.json index 969328db8..92930025f 100644 --- a/packages/random/tsconfig.json +++ b/packages/random/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*.ts" + "./src.ts/*.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/rlp/_version.d.ts b/packages/rlp/lib.esm/_version.d.ts similarity index 100% rename from packages/rlp/_version.d.ts rename to packages/rlp/lib.esm/_version.d.ts diff --git a/packages/rlp/lib.esm/_version.js b/packages/rlp/lib.esm/_version.js new file mode 100644 index 000000000..973a53e12 --- /dev/null +++ b/packages/rlp/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "rlp/5.0.0-beta.125"; diff --git a/packages/rlp/index.d.ts b/packages/rlp/lib.esm/index.d.ts similarity index 100% rename from packages/rlp/index.d.ts rename to packages/rlp/lib.esm/index.d.ts diff --git a/packages/rlp/lib.esm/index.js b/packages/rlp/lib.esm/index.js new file mode 100644 index 000000000..4b77b514f --- /dev/null +++ b/packages/rlp/lib.esm/index.js @@ -0,0 +1,113 @@ +"use strict"; +//See: https://github.com/ethereum/wiki/wiki/RLP +import { arrayify, hexlify } from "@ethersproject/bytes"; +function arrayifyInteger(value) { + let result = []; + while (value) { + result.unshift(value & 0xff); + value >>= 8; + } + return result; +} +function unarrayifyInteger(data, offset, length) { + let result = 0; + for (let i = 0; i < length; i++) { + result = (result * 256) + data[offset + i]; + } + return result; +} +function _encode(object) { + if (Array.isArray(object)) { + let payload = []; + object.forEach(function (child) { + payload = payload.concat(_encode(child)); + }); + if (payload.length <= 55) { + payload.unshift(0xc0 + payload.length); + return payload; + } + let length = arrayifyInteger(payload.length); + length.unshift(0xf7 + length.length); + return length.concat(payload); + } + let data = Array.prototype.slice.call(arrayify(object)); + if (data.length === 1 && data[0] <= 0x7f) { + return data; + } + else if (data.length <= 55) { + data.unshift(0x80 + data.length); + return data; + } + let length = arrayifyInteger(data.length); + length.unshift(0xb7 + length.length); + return length.concat(data); +} +export function encode(object) { + return hexlify(_encode(object)); +} +function _decodeChildren(data, offset, childOffset, length) { + let result = []; + while (childOffset < offset + 1 + length) { + let decoded = _decode(data, childOffset); + result.push(decoded.result); + childOffset += decoded.consumed; + if (childOffset > offset + 1 + length) { + throw new Error("invalid rlp"); + } + } + return { consumed: (1 + length), result: result }; +} +// returns { consumed: number, result: Object } +function _decode(data, offset) { + if (data.length === 0) { + throw new Error("invalid rlp data"); + } + // Array with extra length prefix + if (data[offset] >= 0xf8) { + let lengthLength = data[offset] - 0xf7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("too short"); + } + let length = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length > data.length) { + throw new Error("to short"); + } + return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length); + } + else if (data[offset] >= 0xc0) { + let length = data[offset] - 0xc0; + if (offset + 1 + length > data.length) { + throw new Error("invalid rlp data"); + } + return _decodeChildren(data, offset, offset + 1, length); + } + else if (data[offset] >= 0xb8) { + let lengthLength = data[offset] - 0xb7; + if (offset + 1 + lengthLength > data.length) { + throw new Error("invalid rlp data"); + } + let length = unarrayifyInteger(data, offset + 1, lengthLength); + if (offset + 1 + lengthLength + length > data.length) { + throw new Error("invalid rlp data"); + } + let result = hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length)); + return { consumed: (1 + lengthLength + length), result: result }; + } + else if (data[offset] >= 0x80) { + let length = data[offset] - 0x80; + if (offset + 1 + length > data.length) { + throw new Error("invlaid rlp data"); + } + let result = hexlify(data.slice(offset + 1, offset + 1 + length)); + return { consumed: (1 + length), result: result }; + } + return { consumed: 1, result: hexlify(data[offset]) }; +} +export function decode(data) { + let bytes = arrayify(data); + let decoded = _decode(bytes, 0); + if (decoded.consumed !== bytes.length) { + throw new Error("invalid rlp data"); + } + return decoded.result; +} diff --git a/packages/rlp/lib/_version.d.ts b/packages/rlp/lib/_version.d.ts new file mode 100644 index 000000000..7284b7a3c --- /dev/null +++ b/packages/rlp/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "rlp/5.0.0-beta.125"; diff --git a/packages/rlp/_version.js b/packages/rlp/lib/_version.js similarity index 100% rename from packages/rlp/_version.js rename to packages/rlp/lib/_version.js diff --git a/packages/rlp/lib/index.d.ts b/packages/rlp/lib/index.d.ts new file mode 100644 index 000000000..6e5436e47 --- /dev/null +++ b/packages/rlp/lib/index.d.ts @@ -0,0 +1,3 @@ +import { BytesLike } from "@ethersproject/bytes"; +export declare function encode(object: any): string; +export declare function decode(data: BytesLike): any; diff --git a/packages/rlp/index.js b/packages/rlp/lib/index.js similarity index 100% rename from packages/rlp/index.js rename to packages/rlp/lib/index.js diff --git a/packages/rlp/package.json b/packages/rlp/package.json index 3eac0ae68..b40018a25 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/rlp", - "version": "5.0.0-beta.125", + "version": "5.0.0-beta.126", "description": "Recursive-Length Prefix (RLP) coder.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -23,5 +23,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x223297e79fecc91c953f76fef12f72b20c50a8f146581cacfe86bce39e5c639e" + "module": "./lib.esm/index.js", + "tarballHash": "0xb8ddada3158be8ee0419832c53ef51c466a07b862c56e5402567f5a096ce1f6d" } diff --git a/packages/rlp/tsconfig.json b/packages/rlp/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/rlp/tsconfig.json +++ b/packages/rlp/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/sha2/.gitignore b/packages/sha2/.gitignore index aa5c62527..ac0298ec4 100644 --- a/packages/sha2/.gitignore +++ b/packages/sha2/.gitignore @@ -1 +1,2 @@ -browser.d.ts +lib/browser.d.ts +lib.esm/browser.d.ts diff --git a/packages/sha2/_version.d.ts b/packages/sha2/lib.esm/_version.d.ts similarity index 100% rename from packages/sha2/_version.d.ts rename to packages/sha2/lib.esm/_version.d.ts diff --git a/packages/sha2/lib.esm/_version.js b/packages/sha2/lib.esm/_version.js new file mode 100644 index 000000000..ad6d984c3 --- /dev/null +++ b/packages/sha2/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "sha2/5.0.0-beta.128"; diff --git a/packages/sha2/lib.esm/browser.js b/packages/sha2/lib.esm/browser.js new file mode 100644 index 000000000..a3329b4d4 --- /dev/null +++ b/packages/sha2/lib.esm/browser.js @@ -0,0 +1,30 @@ +"use strict"; +import * as hash from "hash.js"; +import { arrayify } from "@ethersproject/bytes"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export var SupportedAlgorithms; +(function (SupportedAlgorithms) { + SupportedAlgorithms["sha256"] = "sha256"; + SupportedAlgorithms["sha512"] = "sha512"; +})(SupportedAlgorithms || (SupportedAlgorithms = {})); +; +export function ripemd160(data) { + return "0x" + (hash.ripemd160().update(arrayify(data)).digest("hex")); +} +export function sha256(data) { + return "0x" + (hash.sha256().update(arrayify(data)).digest("hex")); +} +export function sha512(data) { + return "0x" + (hash.sha512().update(arrayify(data)).digest("hex")); +} +export function computeHmac(algorithm, key, data) { + if (!SupportedAlgorithms[algorithm]) { + logger.throwError("unsupported algorithm " + algorithm, Logger.errors.UNSUPPORTED_OPERATION, { + operation: "hmac", + algorithm: algorithm + }); + } + return "0x" + hash.hmac(hash[algorithm], arrayify(key)).update(arrayify(data)).digest("hex"); +} diff --git a/packages/sha2/index.d.ts b/packages/sha2/lib.esm/index.d.ts similarity index 100% rename from packages/sha2/index.d.ts rename to packages/sha2/lib.esm/index.d.ts diff --git a/packages/sha2/lib.esm/index.js b/packages/sha2/lib.esm/index.js new file mode 100644 index 000000000..8a2a6550d --- /dev/null +++ b/packages/sha2/lib.esm/index.js @@ -0,0 +1,30 @@ +"use strict"; +import { createHash, createHmac } from 'crypto'; +import { arrayify } from '@ethersproject/bytes'; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export var SupportedAlgorithms; +(function (SupportedAlgorithms) { + SupportedAlgorithms["sha256"] = "sha256"; + SupportedAlgorithms["sha512"] = "sha512"; +})(SupportedAlgorithms || (SupportedAlgorithms = {})); +; +export function ripemd160(data) { + return "0x" + createHash("ripemd160").update(Buffer.from(arrayify(data))).digest("hex"); +} +export function sha256(data) { + return "0x" + createHash("sha256").update(Buffer.from(arrayify(data))).digest("hex"); +} +export function sha512(data) { + return "0x" + createHash("sha512").update(Buffer.from(arrayify(data))).digest("hex"); +} +export function computeHmac(algorithm, key, data) { + if (!SupportedAlgorithms[algorithm]) { + logger.throwError("unsupported algorithm - " + algorithm, Logger.errors.UNSUPPORTED_OPERATION, { + operation: "computeHmac", + algorithm: algorithm + }); + } + return "0x" + createHmac(algorithm, Buffer.from(arrayify(key))).update(Buffer.from(arrayify(data))).digest("hex"); +} diff --git a/packages/sha2/lib/_version.d.ts b/packages/sha2/lib/_version.d.ts new file mode 100644 index 000000000..5fe5a4b4f --- /dev/null +++ b/packages/sha2/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "sha2/5.0.0-beta.128"; diff --git a/packages/sha2/_version.js b/packages/sha2/lib/_version.js similarity index 100% rename from packages/sha2/_version.js rename to packages/sha2/lib/_version.js diff --git a/packages/sha2/browser.js b/packages/sha2/lib/browser.js similarity index 100% rename from packages/sha2/browser.js rename to packages/sha2/lib/browser.js diff --git a/packages/sha2/lib/index.d.ts b/packages/sha2/lib/index.d.ts new file mode 100644 index 000000000..ae271b7b0 --- /dev/null +++ b/packages/sha2/lib/index.d.ts @@ -0,0 +1,9 @@ +import { BytesLike } from '@ethersproject/bytes'; +export declare enum SupportedAlgorithms { + sha256 = "sha256", + sha512 = "sha512" +} +export declare function ripemd160(data: BytesLike): string; +export declare function sha256(data: BytesLike): string; +export declare function sha512(data: BytesLike): string; +export declare function computeHmac(algorithm: SupportedAlgorithms, key: BytesLike, data: BytesLike): string; diff --git a/packages/sha2/index.js b/packages/sha2/lib/index.js similarity index 100% rename from packages/sha2/index.js rename to packages/sha2/lib/index.js diff --git a/packages/sha2/package.json b/packages/sha2/package.json index 3ab746408..e8c724b14 100644 --- a/packages/sha2/package.json +++ b/packages/sha2/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/sha2", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "The SHA2 family hash functions and HMAC functions for ethers.", - "main": "index.js", + "main": "./lib/index.js", "browser": "browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -25,5 +25,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x860983c9837fee7ae27066cfefcba0a306898f8bcd8f3b0b6b354edf08d90b63" + "module": "./lib.esm/index.js", + "tarballHash": "0x1550ecce4b5da09b8f7b95a4313b68d767a73e3f5920ea5636d34022e2971957" } diff --git a/packages/sha2/tsconfig.json b/packages/sha2/tsconfig.json index d0d26fd98..a398e74f7 100644 --- a/packages/sha2/tsconfig.json +++ b/packages/sha2/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./thirdparty.d.ts", - "./src.ts/*.ts" + "./thirdparty.d.ts", + "./src.ts/*.ts" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/shims/package.json b/packages/shims/package.json index fcd12e7f6..9f8852d3c 100644 --- a/packages/shims/package.json +++ b/packages/shims/package.json @@ -1,9 +1,9 @@ { "name": "@ethersproject/shims", - "version": "5.0.0-beta.131", + "version": "5.0.0-beta.132", "_ethers_nobuild": true, "description": "Shims required for ethers in constrained environments.", - "main": "./src/index.js", + "main": "./lib/index.js", "scripts": { "dist": "browserify ./src/index.js -o ./dist/index.js && uglifyjs --compress --mangle --output ./dist/index.min.js -- ./dist/index.js", "test": "echo \"Error: no test specified\" && exit 1" @@ -25,5 +25,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x5662e167af083471aa4f3c085b5e41abc50f3f8de297c28c5e5c59b2f34207a3" + "module": "./lib.esm/index.js", + "tarballHash": "0xaf9de32ae819cac08b2c3ab1ca7ce1f527a2d3c656d8c6dfceb4e9d9d6824aeb" } diff --git a/packages/signing-key/_version.d.ts b/packages/signing-key/lib.esm/_version.d.ts similarity index 100% rename from packages/signing-key/_version.d.ts rename to packages/signing-key/lib.esm/_version.d.ts diff --git a/packages/signing-key/lib.esm/_version.js b/packages/signing-key/lib.esm/_version.js new file mode 100644 index 000000000..a45b58677 --- /dev/null +++ b/packages/signing-key/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "signing-key/5.0.0-beta.128"; diff --git a/packages/signing-key/index.d.ts b/packages/signing-key/lib.esm/index.d.ts similarity index 100% rename from packages/signing-key/index.d.ts rename to packages/signing-key/lib.esm/index.d.ts diff --git a/packages/signing-key/lib.esm/index.js b/packages/signing-key/lib.esm/index.js new file mode 100644 index 000000000..1bf15971a --- /dev/null +++ b/packages/signing-key/lib.esm/index.js @@ -0,0 +1,74 @@ +"use strict"; +import { ec as EC } from "elliptic"; +import { arrayify, hexlify, hexZeroPad, splitSignature } from "@ethersproject/bytes"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +let _curve = null; +function getCurve() { + if (!_curve) { + _curve = new EC("secp256k1"); + } + return _curve; +} +export class SigningKey { + constructor(privateKey) { + defineReadOnly(this, "curve", "secp256k1"); + defineReadOnly(this, "privateKey", hexlify(privateKey)); + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + defineReadOnly(this, "_isSigningKey", true); + } + _addPoint(other) { + let p0 = getCurve().keyFromPublic(arrayify(this.publicKey)); + let p1 = getCurve().keyFromPublic(arrayify(other)); + return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); + } + signDigest(digest) { + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + let signature = keyPair.sign(arrayify(digest), { canonical: true }); + return splitSignature({ + recoveryParam: signature.recoveryParam, + r: hexZeroPad("0x" + signature.r.toString(16), 32), + s: hexZeroPad("0x" + signature.s.toString(16), 32), + }); + } + computeSharedSecret(otherKey) { + let keyPair = getCurve().keyFromPrivate(arrayify(this.privateKey)); + let otherKeyPair = getCurve().keyFromPublic(arrayify(computePublicKey(otherKey))); + return hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + } + static isSigningKey(value) { + return !!(value && value._isSigningKey); + } +} +export function recoverPublicKey(digest, signature) { + let sig = splitSignature(signature); + let rs = { r: arrayify(sig.r), s: arrayify(sig.s) }; + return "0x" + getCurve().recoverPubKey(arrayify(digest), rs, sig.recoveryParam).encode("hex", false); +} +export function computePublicKey(key, compressed) { + let bytes = arrayify(key); + if (bytes.length === 32) { + let signingKey = new SigningKey(bytes); + if (compressed) { + return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); + } + return signingKey.publicKey; + } + else if (bytes.length === 33) { + if (compressed) { + return hexlify(bytes); + } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); + } + else if (bytes.length === 65) { + if (!compressed) { + return hexlify(bytes); + } + return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); + } + return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); +} diff --git a/packages/signing-key/lib/_version.d.ts b/packages/signing-key/lib/_version.d.ts new file mode 100644 index 000000000..4212cbd89 --- /dev/null +++ b/packages/signing-key/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "signing-key/5.0.0-beta.128"; diff --git a/packages/signing-key/_version.js b/packages/signing-key/lib/_version.js similarity index 100% rename from packages/signing-key/_version.js rename to packages/signing-key/lib/_version.js diff --git a/packages/signing-key/lib/index.d.ts b/packages/signing-key/lib/index.d.ts new file mode 100644 index 000000000..ffb11296e --- /dev/null +++ b/packages/signing-key/lib/index.d.ts @@ -0,0 +1,15 @@ +import { BytesLike, Signature, SignatureLike } from "@ethersproject/bytes"; +export declare class SigningKey { + readonly curve: string; + readonly privateKey: string; + readonly publicKey: string; + readonly compressedPublicKey: string; + readonly _isSigningKey: boolean; + constructor(privateKey: BytesLike); + _addPoint(other: BytesLike): string; + signDigest(digest: BytesLike): Signature; + computeSharedSecret(otherKey: BytesLike): string; + static isSigningKey(value: any): value is SigningKey; +} +export declare function recoverPublicKey(digest: BytesLike, signature: SignatureLike): string; +export declare function computePublicKey(key: BytesLike, compressed?: boolean): string; diff --git a/packages/signing-key/index.js b/packages/signing-key/lib/index.js similarity index 100% rename from packages/signing-key/index.js rename to packages/signing-key/lib/index.js diff --git a/packages/signing-key/package.json b/packages/signing-key/package.json index a93d5e219..33abe9832 100644 --- a/packages/signing-key/package.json +++ b/packages/signing-key/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/signing-key", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Elliptic curve library functions for the secp256k1 curve.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -10,7 +10,7 @@ "@ethersproject/bytes": ">5.0.0-beta.0", "@ethersproject/logger": ">5.0.0-beta.0", "@ethersproject/properties": ">5.0.0-beta.0", - "elliptic": "6.3.3" + "elliptic": "6.5.0" }, "keywords": [ "Ethereum", @@ -25,5 +25,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x52d8007c5e08be55f0a61256926afc9de9bbe2a02f07d3415e08da4e4cc78e3a" + "module": "./lib.esm/index.js", + "tarballHash": "0xf65693a06f04727d25829cc27edc77c7d0514ca87ecdd1593e968526380cad4b" } diff --git a/packages/signing-key/tsconfig.json b/packages/signing-key/tsconfig.json index a86d682a0..0a9d2f16c 100644 --- a/packages/signing-key/tsconfig.json +++ b/packages/signing-key/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ "./thirdparty.d.ts", - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/solidity/_version.d.ts b/packages/solidity/lib.esm/_version.d.ts similarity index 100% rename from packages/solidity/_version.d.ts rename to packages/solidity/lib.esm/_version.d.ts diff --git a/packages/solidity/lib.esm/_version.js b/packages/solidity/lib.esm/_version.js new file mode 100644 index 000000000..6c312c2df --- /dev/null +++ b/packages/solidity/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "solidity/5.0.0-beta.125"; diff --git a/packages/solidity/index.d.ts b/packages/solidity/lib.esm/index.d.ts similarity index 100% rename from packages/solidity/index.d.ts rename to packages/solidity/lib.esm/index.d.ts diff --git a/packages/solidity/lib.esm/index.js b/packages/solidity/lib.esm/index.js new file mode 100644 index 000000000..fc676ae53 --- /dev/null +++ b/packages/solidity/lib.esm/index.js @@ -0,0 +1,87 @@ +"use strict"; +import { BigNumber } from "@ethersproject/bignumber"; +import { arrayify, concat, hexlify, zeroPad } from "@ethersproject/bytes"; +import { keccak256 as hashKeccak256 } from "@ethersproject/keccak256"; +import { sha256 as hashSha256 } from "@ethersproject/sha2"; +import { toUtf8Bytes } from "@ethersproject/strings"; +const regexBytes = new RegExp("^bytes([0-9]+)$"); +const regexNumber = new RegExp("^(u?int)([0-9]*)$"); +const regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); +const Zeros = "0000000000000000000000000000000000000000000000000000000000000000"; +function _pack(type, value, isArray) { + switch (type) { + case "address": + if (isArray) { + return zeroPad(value, 32); + } + return arrayify(value); + case "string": + return toUtf8Bytes(value); + case "bytes": + return arrayify(value); + case "bool": + value = (value ? "0x01" : "0x00"); + if (isArray) { + return zeroPad(value, 32); + } + return arrayify(value); + } + let match = type.match(regexNumber); + if (match) { + //let signed = (match[1] === "int") + let size = parseInt(match[2] || "256"); + if ((size % 8 != 0) || size === 0 || size > 256) { + throw new Error("invalid number type - " + type); + } + if (isArray) { + size = 256; + } + value = BigNumber.from(value).toTwos(size); + return zeroPad(value, size / 8); + } + match = type.match(regexBytes); + if (match) { + let size = parseInt(match[1]); + if (String(size) != match[1] || size === 0 || size > 32) { + throw new Error("invalid number type - " + type); + } + if (arrayify(value).byteLength !== size) { + throw new Error("invalid value for " + type); + } + if (isArray) { + return arrayify((value + Zeros).substring(0, 66)); + } + return value; + } + match = type.match(regexArray); + if (match && Array.isArray(value)) { + let baseType = match[1]; + let count = parseInt(match[2] || String(value.length)); + if (count != value.length) { + throw new Error("invalid value for " + type); + } + let result = []; + value.forEach(function (value) { + result.push(_pack(baseType, value, true)); + }); + return concat(result); + } + throw new Error("unknown type - " + type); +} +// @TODO: Array Enum +export function pack(types, values) { + if (types.length != values.length) { + throw new Error("type/value count mismatch"); + } + let tight = []; + types.forEach(function (type, index) { + tight.push(_pack(type, values[index])); + }); + return hexlify(concat(tight)); +} +export function keccak256(types, values) { + return hashKeccak256(pack(types, values)); +} +export function sha256(types, values) { + return hashSha256(pack(types, values)); +} diff --git a/packages/solidity/lib/_version.d.ts b/packages/solidity/lib/_version.d.ts new file mode 100644 index 000000000..18d910f3d --- /dev/null +++ b/packages/solidity/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "solidity/5.0.0-beta.125"; diff --git a/packages/solidity/_version.js b/packages/solidity/lib/_version.js similarity index 100% rename from packages/solidity/_version.js rename to packages/solidity/lib/_version.js diff --git a/packages/solidity/lib/index.d.ts b/packages/solidity/lib/index.d.ts new file mode 100644 index 000000000..7aea17e74 --- /dev/null +++ b/packages/solidity/lib/index.d.ts @@ -0,0 +1,3 @@ +export declare function pack(types: Array, values: Array): string; +export declare function keccak256(types: Array, values: Array): string; +export declare function sha256(types: Array, values: Array): string; diff --git a/packages/solidity/index.js b/packages/solidity/lib/index.js similarity index 100% rename from packages/solidity/index.js rename to packages/solidity/lib/index.js diff --git a/packages/solidity/package.json b/packages/solidity/package.json index 718483a33..50ad82d51 100644 --- a/packages/solidity/package.json +++ b/packages/solidity/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/solidity", - "version": "5.0.0-beta.125", + "version": "5.0.0-beta.126", "description": "Solidity coder for non-standard (tight) packing.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x12b004482b8d515f0aeb7565ee5ac4b794ff39ba17da55e260098c9c87c8df57" + "module": "./lib.esm/index.js", + "tarballHash": "0x12c5fdd83ae961c1474dc119a576fd069d15dfd81c555072d8271f7da8b98bef" } diff --git a/packages/solidity/tsconfig.json b/packages/solidity/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/solidity/tsconfig.json +++ b/packages/solidity/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/strings/_version.d.ts b/packages/strings/lib.esm/_version.d.ts similarity index 100% rename from packages/strings/_version.d.ts rename to packages/strings/lib.esm/_version.d.ts diff --git a/packages/strings/lib.esm/_version.js b/packages/strings/lib.esm/_version.js new file mode 100644 index 000000000..1c1b92c06 --- /dev/null +++ b/packages/strings/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "strings/5.0.0-beta.129"; diff --git a/packages/strings/bytes32.d.ts b/packages/strings/lib.esm/bytes32.d.ts similarity index 100% rename from packages/strings/bytes32.d.ts rename to packages/strings/lib.esm/bytes32.d.ts diff --git a/packages/strings/lib.esm/bytes32.js b/packages/strings/lib.esm/bytes32.js new file mode 100644 index 000000000..4260da729 --- /dev/null +++ b/packages/strings/lib.esm/bytes32.js @@ -0,0 +1,31 @@ +"use strict"; +import { HashZero } from "@ethersproject/constants"; +import { arrayify, concat, hexlify } from "@ethersproject/bytes"; +import { toUtf8Bytes, toUtf8String } from "./utf8"; +export function formatBytes32String(text) { + // Get the bytes + let bytes = toUtf8Bytes(text); + // Check we have room for null-termination + if (bytes.length > 31) { + throw new Error("bytes32 string must be less than 32 bytes"); + } + // Zero-pad (implicitly null-terminates) + return hexlify(concat([bytes, HashZero]).slice(0, 32)); +} +export function parseBytes32String(bytes) { + let data = arrayify(bytes); + // Must be 32 bytes with a null-termination + if (data.length !== 32) { + throw new Error("invalid bytes32 - not 32 bytes long"); + } + if (data[31] !== 0) { + throw new Error("invalid bytes32 string - no null terminator"); + } + // Find the null termination + let length = 31; + while (data[length - 1] === 0) { + length--; + } + // Determine the string value + return toUtf8String(data.slice(0, length)); +} diff --git a/packages/strings/idna.d.ts b/packages/strings/lib.esm/idna.d.ts similarity index 100% rename from packages/strings/idna.d.ts rename to packages/strings/lib.esm/idna.d.ts diff --git a/packages/strings/lib.esm/idna.js b/packages/strings/lib.esm/idna.js new file mode 100644 index 000000000..43e35778b --- /dev/null +++ b/packages/strings/lib.esm/idna.js @@ -0,0 +1,187 @@ +"use strict"; +import { toUtf8CodePoints, _toUtf8String, UnicodeNormalizationForm } from "./utf8"; +function bytes2(data) { + if ((data.length % 4) !== 0) { + throw new Error("bad data"); + } + let result = []; + for (let i = 0; i < data.length; i += 4) { + result.push(parseInt(data.substring(i, i + 4), 16)); + } + return result; +} +function createTable(data, func) { + if (!func) { + func = function (value) { return [parseInt(value, 16)]; }; + } + let lo = 0; + let result = {}; + data.split(",").forEach((pair) => { + let comps = pair.split(":"); + lo += parseInt(comps[0], 16); + result[lo] = func(comps[1]); + }); + return result; +} +function createRangeTable(data) { + let hi = 0; + return data.split(",").map((v) => { + let comps = v.split("-"); + if (comps.length === 1) { + comps[1] = "0"; + } + else if (comps[1] === "") { + comps[1] = "1"; + } + let lo = hi + parseInt(comps[0], 16); + hi = parseInt(comps[1], 16); + return { l: lo, h: hi }; + }); +} +function matchMap(value, ranges) { + let lo = 0; + for (let i = 0; i < ranges.length; i++) { + let range = ranges[i]; + lo += range.l; + if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) { + if (range.e && range.e.indexOf(value - lo) !== -1) { + continue; + } + return range; + } + } + return null; +} +const Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); +// @TODO: Make this relative... +const Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map((v) => parseInt(v, 16)); +const Table_B_2_ranges = [ + { h: 25, s: 32, l: 65 }, + { h: 30, s: 32, e: [23], l: 127 }, + { h: 54, s: 1, e: [48], l: 64, d: 2 }, + { h: 14, s: 1, l: 57, d: 2 }, + { h: 44, s: 1, l: 17, d: 2 }, + { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 }, + { h: 16, s: 1, l: 68, d: 2 }, + { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 }, + { h: 26, s: 32, e: [17], l: 435 }, + { h: 22, s: 1, l: 71, d: 2 }, + { h: 15, s: 80, l: 40 }, + { h: 31, s: 32, l: 16 }, + { h: 32, s: 1, l: 80, d: 2 }, + { h: 52, s: 1, l: 42, d: 2 }, + { h: 12, s: 1, l: 55, d: 2 }, + { h: 40, s: 1, e: [38], l: 15, d: 2 }, + { h: 14, s: 1, l: 48, d: 2 }, + { h: 37, s: 48, l: 49 }, + { h: 148, s: 1, l: 6351, d: 2 }, + { h: 88, s: 1, l: 160, d: 2 }, + { h: 15, s: 16, l: 704 }, + { h: 25, s: 26, l: 854 }, + { h: 25, s: 32, l: 55915 }, + { h: 37, s: 40, l: 1247 }, + { h: 25, s: -119711, l: 53248 }, + { h: 25, s: -119763, l: 52 }, + { h: 25, s: -119815, l: 52 }, + { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 }, + { h: 25, s: -119919, l: 52 }, + { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 }, + { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 }, + { h: 25, s: -120075, l: 52 }, + { h: 25, s: -120127, l: 52 }, + { h: 25, s: -120179, l: 52 }, + { h: 25, s: -120231, l: 52 }, + { h: 25, s: -120283, l: 52 }, + { h: 25, s: -120335, l: 52 }, + { h: 24, s: -119543, e: [17], l: 56 }, + { h: 24, s: -119601, e: [17], l: 58 }, + { h: 24, s: -119659, e: [17], l: 58 }, + { h: 24, s: -119717, e: [17], l: 58 }, + { h: 24, s: -119775, e: [17], l: 58 } +]; +const Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); +const Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); +const Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); +const Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); +function flatten(values) { + return values.reduce((accum, value) => { + value.forEach((value) => { accum.push(value); }); + return accum; + }, []); +} +export function _nameprepTableA1(codepoint) { + return !!matchMap(codepoint, Table_A_1_ranges); +} +export function _nameprepTableB2(codepoint) { + let range = matchMap(codepoint, Table_B_2_ranges); + if (range) { + return [codepoint + range.s]; + } + let codes = Table_B_2_lut_abs[codepoint]; + if (codes) { + return codes; + } + let shift = Table_B_2_lut_rel[codepoint]; + if (shift) { + return [codepoint + shift[0]]; + } + let complex = Table_B_2_complex[codepoint]; + if (complex) { + return complex; + } + return null; +} +export function _nameprepTableC(codepoint) { + return !!matchMap(codepoint, Table_C_ranges); +} +export function nameprep(value) { + // This allows platforms with incomplete normalize to bypass + // it for very basic names which the built-in toLowerCase + // will certainly handle correctly + if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) { + return value.toLowerCase(); + } + // Get the code points (keeping the current normalization) + let codes = toUtf8CodePoints(value); + codes = flatten(codes.map((code) => { + // Substitute Table B.1 (Maps to Nothing) + if (Table_B_1_flags.indexOf(code) >= 0) { + return []; + } + if (code >= 0xfe00 && code <= 0xfe0f) { + return []; + } + // Substitute Table B.2 (Case Folding) + let codesTableB2 = _nameprepTableB2(code); + if (codesTableB2) { + return codesTableB2; + } + // No Substitution + return [code]; + })); + // Normalize using form KC + codes = toUtf8CodePoints(_toUtf8String(codes), UnicodeNormalizationForm.NFKC); + // Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9 + codes.forEach((code) => { + if (_nameprepTableC(code)) { + throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); + } + }); + // Prohibit Unassigned Code Points (Table A.1) + codes.forEach((code) => { + if (_nameprepTableA1(code)) { + throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); + } + }); + // IDNA extras + let name = _toUtf8String(codes); + // IDNA: 4.2.3.1 + if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { + throw new Error("invalid hyphen"); + } + // IDNA: 4.2.4 + if (name.length > 63) { + throw new Error("too long"); + } + return name; +} diff --git a/packages/strings/index.d.ts b/packages/strings/lib.esm/index.d.ts similarity index 100% rename from packages/strings/index.d.ts rename to packages/strings/lib.esm/index.d.ts diff --git a/packages/strings/lib.esm/index.js b/packages/strings/lib.esm/index.js new file mode 100644 index 000000000..e70521fe7 --- /dev/null +++ b/packages/strings/lib.esm/index.js @@ -0,0 +1,5 @@ +"use strict"; +import { formatBytes32String, parseBytes32String } from "./bytes32"; +import { nameprep } from "./idna"; +import { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm } from "./utf8"; +export { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm, formatBytes32String, parseBytes32String, nameprep }; diff --git a/packages/strings/utf8.d.ts b/packages/strings/lib.esm/utf8.d.ts similarity index 100% rename from packages/strings/utf8.d.ts rename to packages/strings/lib.esm/utf8.d.ts diff --git a/packages/strings/lib.esm/utf8.js b/packages/strings/lib.esm/utf8.js new file mode 100644 index 000000000..48b2535d5 --- /dev/null +++ b/packages/strings/lib.esm/utf8.js @@ -0,0 +1,191 @@ +"use strict"; +import { arrayify } from "@ethersproject/bytes"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +/////////////////////////////// +export var UnicodeNormalizationForm; +(function (UnicodeNormalizationForm) { + UnicodeNormalizationForm["current"] = ""; + UnicodeNormalizationForm["NFC"] = "NFC"; + UnicodeNormalizationForm["NFD"] = "NFD"; + UnicodeNormalizationForm["NFKC"] = "NFKC"; + UnicodeNormalizationForm["NFKD"] = "NFKD"; +})(UnicodeNormalizationForm || (UnicodeNormalizationForm = {})); +; +// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 +function getUtf8CodePoints(bytes, ignoreErrors) { + bytes = arrayify(bytes); + let result = []; + let i = 0; + // Invalid bytes are ignored + while (i < bytes.length) { + let c = bytes[i++]; + // 0xxx xxxx + if (c >> 7 === 0) { + result.push(c); + continue; + } + // Multibyte; how many bytes left for this character? + let extraLength = null; + let overlongMask = null; + // 110x xxxx 10xx xxxx + if ((c & 0xe0) === 0xc0) { + extraLength = 1; + overlongMask = 0x7f; + // 1110 xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf0) === 0xe0) { + extraLength = 2; + overlongMask = 0x7ff; + // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx + } + else if ((c & 0xf8) === 0xf0) { + extraLength = 3; + overlongMask = 0xffff; + } + else { + if (!ignoreErrors) { + if ((c & 0xc0) === 0x80) { + throw new Error("invalid utf8 byte sequence; unexpected continuation byte"); + } + throw new Error("invalid utf8 byte sequence; invalid prefix"); + } + continue; + } + // Do we have enough bytes in our data? + if (i + extraLength > bytes.length) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; too short"); + } + // If there is an invalid unprocessed byte, skip continuation bytes + for (; i < bytes.length; i++) { + if (bytes[i] >> 6 !== 0x02) { + break; + } + } + continue; + } + // Remove the length prefix from the char + let res = c & ((1 << (8 - extraLength - 1)) - 1); + for (let j = 0; j < extraLength; j++) { + let nextChar = bytes[i]; + // Invalid continuation byte + if ((nextChar & 0xc0) != 0x80) { + res = null; + break; + } + ; + res = (res << 6) | (nextChar & 0x3f); + i++; + } + if (res === null) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; invalid continuation byte"); + } + continue; + } + // Check for overlong seuences (more bytes than needed) + if (res <= overlongMask) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; overlong"); + } + continue; + } + // Maximum code point + if (res > 0x10ffff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; out-of-range"); + } + continue; + } + // Reserved for UTF-16 surrogate halves + if (res >= 0xd800 && res <= 0xdfff) { + if (!ignoreErrors) { + throw new Error("invalid utf8 byte sequence; utf-16 surrogate"); + } + continue; + } + result.push(res); + } + return result; +} +// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array +export function toUtf8Bytes(str, form = UnicodeNormalizationForm.current) { + if (form != UnicodeNormalizationForm.current) { + logger.checkNormalize(); + str = str.normalize(form); + } + let result = []; + for (let i = 0; i < str.length; i++) { + let c = str.charCodeAt(i); + if (c < 0x80) { + result.push(c); + } + else if (c < 0x800) { + result.push((c >> 6) | 0xc0); + result.push((c & 0x3f) | 0x80); + } + else if ((c & 0xfc00) == 0xd800) { + i++; + let c2 = str.charCodeAt(i); + if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { + throw new Error("invalid utf-8 string"); + } + // Surrogate Pair + c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); + result.push((c >> 18) | 0xf0); + result.push(((c >> 12) & 0x3f) | 0x80); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + else { + result.push((c >> 12) | 0xe0); + result.push(((c >> 6) & 0x3f) | 0x80); + result.push((c & 0x3f) | 0x80); + } + } + return arrayify(result); +} +; +function escapeChar(value) { + let hex = ("0000" + value.toString(16)); + return "\\u" + hex.substring(hex.length - 4); +} +export function _toEscapedUtf8String(bytes, ignoreErrors) { + return '"' + getUtf8CodePoints(bytes, ignoreErrors).map((codePoint) => { + if (codePoint < 256) { + switch (codePoint) { + case 8: return "\\b"; + case 9: return "\\t"; + case 10: return "\\n"; + case 13: return "\\r"; + case 34: return "\\\""; + case 92: return "\\\\"; + } + if (codePoint >= 32 && codePoint < 127) { + return String.fromCharCode(codePoint); + } + } + if (codePoint <= 0xffff) { + return escapeChar(codePoint); + } + codePoint -= 0x10000; + return escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) + escapeChar((codePoint & 0x3ff) + 0xdc00); + }).join("") + '"'; +} +export function _toUtf8String(codePoints) { + return codePoints.map((codePoint) => { + if (codePoint <= 0xffff) { + return String.fromCharCode(codePoint); + } + codePoint -= 0x10000; + return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00)); + }).join(""); +} +export function toUtf8String(bytes, ignoreErrors) { + return _toUtf8String(getUtf8CodePoints(bytes, ignoreErrors)); +} +export function toUtf8CodePoints(str, form = UnicodeNormalizationForm.current) { + return getUtf8CodePoints(toUtf8Bytes(str, form)); +} diff --git a/packages/strings/lib/_version.d.ts b/packages/strings/lib/_version.d.ts new file mode 100644 index 000000000..6e8268c01 --- /dev/null +++ b/packages/strings/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "strings/5.0.0-beta.129"; diff --git a/packages/strings/_version.js b/packages/strings/lib/_version.js similarity index 100% rename from packages/strings/_version.js rename to packages/strings/lib/_version.js diff --git a/packages/strings/lib/bytes32.d.ts b/packages/strings/lib/bytes32.d.ts new file mode 100644 index 000000000..88fcb87bc --- /dev/null +++ b/packages/strings/lib/bytes32.d.ts @@ -0,0 +1,3 @@ +import { BytesLike } from "@ethersproject/bytes"; +export declare function formatBytes32String(text: string): string; +export declare function parseBytes32String(bytes: BytesLike): string; diff --git a/packages/strings/bytes32.js b/packages/strings/lib/bytes32.js similarity index 100% rename from packages/strings/bytes32.js rename to packages/strings/lib/bytes32.js diff --git a/packages/strings/lib/idna.d.ts b/packages/strings/lib/idna.d.ts new file mode 100644 index 000000000..3436fd942 --- /dev/null +++ b/packages/strings/lib/idna.d.ts @@ -0,0 +1,4 @@ +export declare function _nameprepTableA1(codepoint: number): boolean; +export declare function _nameprepTableB2(codepoint: number): Array; +export declare function _nameprepTableC(codepoint: number): boolean; +export declare function nameprep(value: string): string; diff --git a/packages/strings/idna.js b/packages/strings/lib/idna.js similarity index 100% rename from packages/strings/idna.js rename to packages/strings/lib/idna.js diff --git a/packages/strings/lib/index.d.ts b/packages/strings/lib/index.d.ts new file mode 100644 index 000000000..38ac15937 --- /dev/null +++ b/packages/strings/lib/index.d.ts @@ -0,0 +1,4 @@ +import { formatBytes32String, parseBytes32String } from "./bytes32"; +import { nameprep } from "./idna"; +import { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm } from "./utf8"; +export { _toEscapedUtf8String, toUtf8Bytes, toUtf8CodePoints, toUtf8String, UnicodeNormalizationForm, formatBytes32String, parseBytes32String, nameprep }; diff --git a/packages/strings/index.js b/packages/strings/lib/index.js similarity index 97% rename from packages/strings/index.js rename to packages/strings/lib/index.js index fc7669a7a..e05478ce0 100644 --- a/packages/strings/index.js +++ b/packages/strings/lib/index.js @@ -1,4 +1,3 @@ -"use strcit"; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var bytes32_1 = require("./bytes32"); diff --git a/packages/strings/lib/utf8.d.ts b/packages/strings/lib/utf8.d.ts new file mode 100644 index 000000000..b102b7078 --- /dev/null +++ b/packages/strings/lib/utf8.d.ts @@ -0,0 +1,13 @@ +import { BytesLike } from "@ethersproject/bytes"; +export declare enum UnicodeNormalizationForm { + current = "", + NFC = "NFC", + NFD = "NFD", + NFKC = "NFKC", + NFKD = "NFKD" +} +export declare function toUtf8Bytes(str: string, form?: UnicodeNormalizationForm): Uint8Array; +export declare function _toEscapedUtf8String(bytes: BytesLike, ignoreErrors?: boolean): string; +export declare function _toUtf8String(codePoints: Array): string; +export declare function toUtf8String(bytes: BytesLike, ignoreErrors?: boolean): string; +export declare function toUtf8CodePoints(str: string, form?: UnicodeNormalizationForm): Array; diff --git a/packages/strings/utf8.js b/packages/strings/lib/utf8.js similarity index 100% rename from packages/strings/utf8.js rename to packages/strings/lib/utf8.js diff --git a/packages/strings/package.json b/packages/strings/package.json index 96d312878..7fc2a27f0 100644 --- a/packages/strings/package.json +++ b/packages/strings/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/strings", - "version": "5.0.0-beta.129", + "version": "5.0.0-beta.130", "description": "String utility functions.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x35d6b6566f2aa9de4e2d7abe253e83f60fb08d157a331fcd27d3d3a9b9361e7e" + "module": "./lib.esm/index.js", + "tarballHash": "0xc677425c7f1ff6b76a370731692da0995eba3a44861dd93b147874b8fae74007" } diff --git a/packages/strings/src.ts/index.ts b/packages/strings/src.ts/index.ts index 441264664..07293a321 100644 --- a/packages/strings/src.ts/index.ts +++ b/packages/strings/src.ts/index.ts @@ -1,4 +1,4 @@ -"use strcit"; +"use strict"; import { formatBytes32String, parseBytes32String } from "./bytes32"; import { nameprep } from "./idna"; diff --git a/packages/strings/tsconfig.json b/packages/strings/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/strings/tsconfig.json +++ b/packages/strings/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/testcases/.gitignore b/packages/testcases/.gitignore index 6499ea436..45a310664 100644 --- a/packages/testcases/.gitignore +++ b/packages/testcases/.gitignore @@ -1 +1,2 @@ -generation-scripts/*.d.ts +lib/generation-scripts/*.d.ts +lib.esm/generation-scripts/*.d.ts diff --git a/packages/testcases/_version.d.ts b/packages/testcases/lib.esm/_version.d.ts similarity index 100% rename from packages/testcases/_version.d.ts rename to packages/testcases/lib.esm/_version.d.ts diff --git a/packages/testcases/lib.esm/_version.js b/packages/testcases/lib.esm/_version.js new file mode 100644 index 000000000..c316fc72d --- /dev/null +++ b/packages/testcases/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "testcases/5.0.0-beta.130"; diff --git a/packages/testcases/browser-fs.json b/packages/testcases/lib.esm/browser-fs.json similarity index 100% rename from packages/testcases/browser-fs.json rename to packages/testcases/lib.esm/browser-fs.json diff --git a/packages/testcases/browser.d.ts b/packages/testcases/lib.esm/browser.d.ts similarity index 100% rename from packages/testcases/browser.d.ts rename to packages/testcases/lib.esm/browser.d.ts diff --git a/packages/testcases/lib.esm/browser.js b/packages/testcases/lib.esm/browser.js new file mode 100644 index 000000000..c10d36d70 --- /dev/null +++ b/packages/testcases/lib.esm/browser.js @@ -0,0 +1,15 @@ +'use strict'; +import path from 'path'; +import zlib from "browserify-zlib"; +import * as data from "./browser-fs.json"; +export function loadTests(tag) { + let filename = 'testcases/' + tag + ".json.gz"; + console.log("loading:", filename); + return JSON.parse(zlib.gunzipSync(new Buffer(data[filename], "base64")).toString()); +} +export function loadData(filename) { + // Strip any leading relative paths (e.g. "./foo" => "foo") + filename = path.join(filename); + console.log("loading:", filename); + return new Buffer(data[filename], "base64"); +} diff --git a/packages/testcases/lib.esm/generation-scripts/abi.js b/packages/testcases/lib.esm/generation-scripts/abi.js new file mode 100644 index 000000000..efb3c8fd0 --- /dev/null +++ b/packages/testcases/lib.esm/generation-scripts/abi.js @@ -0,0 +1,523 @@ +"use strict"; +//let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8549')); +//import { compile as _compile } from "solc"; +import { compile } from "@ethersproject/cli/solc"; +import { randomHexString, randomNumber } from ".."; +import { BN, keccak256, toChecksumAddress } from "ethereumjs-util"; +function hasPrefix(str, prefix) { + return (str.substring(0, prefix.length) === prefix); +} +function repeat(str, count) { + let result = ""; + for (let i = 0; i < count; i++) { + result += str; + } + return result; +} +function indent(tabs) { + let result = ''; + while (result.length < 4 * tabs) { + result += " "; + } + return result; +} +function getStructName(base) { + return "Struct" + keccak256(base).slice(0, 4).toString("hex"); +} +class Code { + constructor() { + this.depth = 0; + this.lines = []; + } + get code() { + return this.lines.join("\n"); //.replace(/ +\n/g, "\n").replace(/(\}\n\n+)/g, "}\n"); + } + comment(line) { + this.add(""); + this.add("/" + "/ " + line); + } + add(line) { + let open = (line.trim().substring(line.trim().length - 1) === "{"); + let close = line.trim()[0] === "}"; + if (close) { + this.depth--; + } + this.lines.push(indent(this.depth) + line); + //if (close) { this.lines.push(""); } + if (open) { + this.depth++; + } + } +} +let chars = []; +function addChars(start, length) { + for (let i = start; i < start + length; i++) { + chars.push(String.fromCharCode(i)); + } +} +addChars(48, 10); +addChars(65, 26); +// Returns the functions required to generate code for a specific parameter type and value +function getGenCode(testData) { + let type = testData.type; + let value = (testData.value != null) ? testData.value : "__crash__"; + let isArray = type.match(/^(.*)(\[[0-9]*\])$/); + if (isArray) { + let base = isArray[1]; + let suffix = isArray[2]; + let isDynamic = (isArray[2] === "[]"); + return { + assign: (name, code) => { + if (isDynamic) { + //let child = getGenCode({ type: base }); + //let decl = child.decl(name).split(" "); + let struct = base; + if (type.substring(0, 5) === "tuple") { + struct = getStructName(base); + } + code.add(name + " = new " + struct + "[](" + String(value.length) + ");"); + } + value.forEach((value, index) => { + console.log("SSS", base, value); + let child = getGenCode({ type: base, value: value }); + child.assign(name + "[" + String(index) + "]", code); + }); + }, + decl: (name) => { + let child = getGenCode({ type: isArray[1] }); + // Inject the array suffix to the type and add memory location + // - uint256 p0 => uint256[] memory p0 + // - bytes memory p0 => bytes[] memory p0 + let result = child.decl(name).split(" "); + result[0] = result[0] + suffix; + if (result[1] !== "memory") { + result.splice(1, 0, "memory"); + } + return result.join(" "); + }, + structs: (code) => { + let child = getGenCode({ type: isArray[1] }); + child.structs(code); + } + }; + } + let isTuple = type.match(/^tuple\((.*)\)$/); + if (isTuple) { + let children = []; + // Split up the child types + let accum = ""; + let balance = 0; + let types = isTuple[1]; + for (let i = 0; i < types.length; i++) { + let c = types[i]; + if (c === "(") { + balance++; + accum += c; + } + else if (c === ")") { + balance--; + accum += c; + } + else if (c === ",") { + if (balance === 0) { + children.push(accum); + accum = ""; + } + else { + accum += c; + } + } + else { + accum += c; + } + } + if (accum) { + children.push(accum); + } + return { + assign: (name, code) => { + children.forEach((child, index) => { + console.log("TT", child, value[index]); + getGenCode({ + type: child, + value: value[index] + }).assign(name + ".m" + String(index), code); + }); + }, + decl: (name) => { + return (getStructName(type) + " memory " + name); + }, + structs: (code) => { + // Include any dependency Structs first + children.forEach((child) => { + getGenCode({ type: child }).structs(code); + }); + // Add this struct + code.add("struct " + getStructName(type) + " {"); + children.forEach((child, index) => { + let decl = getGenCode({ + type: child + }).decl("m" + String(index)).replace(" memory ", " "); + code.add(decl + ";"); + }); + code.add("}"); + } + }; + } + let isFixedBytes = type.match(/^bytes([0-9]+)$/); + let isNumber = type.match(/^(u?)int([0-9]*)$/); + let isFixedNumber = type.match(/^(u?)fixed(([0-9]+)x([0-9]+))?$/); + if (type === "address" || type === "bool" || isNumber || isFixedNumber || isFixedBytes) { + return { + assign: (name, code) => { + if (type === "boolean") { + code.add(name + " = " + (value ? "true" : "false") + ";"); + } + else if (isFixedBytes) { + code.add(name + " = hex\"" + value.substring(2) + "\";"); + } + else { + code.add(name + " = " + value + ";"); + } + }, + decl: (name) => { + return (type + " " + name); + }, + structs: (code) => { } + }; + } + if (type === "string") { + return { + assign: (name, code) => { + code.add(name + " = " + JSON.stringify(value) + ";"); + }, + decl: (name) => { + return ("string memory " + name); + }, + structs: (code) => { } + }; + } + if (type === "bytes") { + let valueBytes = Buffer.from(value.substring(2), "hex"); + return { + assign: (name, code) => { + code.add("{"); + code.add("bytes memory temp = new bytes(" + valueBytes.length + ");"); + code.add(name + " = temp;"); + code.add("assembly {"); + // Store the length + code.add("mstore(temp, " + valueBytes.length + ")"); + // Store each byte + for (let i = 0; i < valueBytes.length; i++) { + code.add("mstore8(add(temp, " + (32 + i) + "), " + valueBytes[i] + ")"); + } + code.add("}"); + code.add("}"); + }, + decl: (name) => { + return ("bytes memory " + name); + }, + structs: (code) => { } + }; + } + throw new Error("Could not produce GenCode: " + type); + return null; +} +// Generates a random type and value for the type +function generateTest(seed) { + let basetype = randomNumber(seed + "-type", 0, 10); + switch (basetype) { + // Address + case 0: + return (seed) => { + let value = toChecksumAddress(randomHexString(seed + "-value", 20)); + return { + type: "address", + value: value + }; + }; + // Boolean + case 1: + return (seed) => { + let value = (randomNumber(seed + "-value", 0, 2) ? true : false); + return { + type: "bool", + value: value + }; + }; + // Number + case 2: { + let signed = randomNumber(seed + "-signed", 0, 2); + let width = randomNumber(seed + "-width", 0, 33) * 8; + let type = (signed ? "" : "u") + "int"; + // Allow base int and uint + if (width) { + type += String(width); + } + else { + width = 256; + } + return (seed) => { + let hex = randomHexString(seed + "-value", width / 8).substring(2); + if (signed) { + // Sign bit set (we don't bother with 2's compliment + let msb = parseInt(hex[0], 16); + if (msb >= 8) { + hex = "-" + String(msb & 0x7) + hex.substring(1); + } + } + let value = (new BN(hex, 16)).toString(); + return { + type: type, + value: value + }; + }; + } + // Fixed + case 3: { + // Fixed Point values are not supported yet + return generateTest(seed + "-next"); + let signed = randomNumber(seed + "-signed", 0, 2); + let width = randomNumber(seed + "-width", 0, 33) * 8; + let decimals = 0; + let maxDecimals = (new BN(repeat("7f", ((width === 0) ? 32 : (width / 8))), 16)).toString().length - 1; + let attempt = 0; + while (true) { + decimals = randomNumber(seed + "-decimals" + String(attempt), 0, 80); + if (decimals < maxDecimals) { + break; + } + attempt++; + } + let type = (signed ? "" : "u") + "fixed"; + // Allow base int and uint + if (width) { + type += String(width) + "x" + String(decimals); + } + else { + width = 128; + decimals = 18; + } + return (seed) => { + let hex = randomHexString(seed + "-value", width / 8).substring(2); + // Use the top bit to indicate negative values + let negative = false; + if (signed) { + // Sign bit set (we don't bother with 2's compliment + let msb = parseInt(hex[0], 16); + if (msb >= 8) { + hex = String(msb & 0x7) + hex.substring(1); + negative = true; + } + } + // Zero-pad the value so we get at least 1 whole digit + let dec = (new BN(hex, 16)).toString(); + while (dec.length < decimals + 1) { + dec = "0" + dec; + } + // Split the decimals with the decimal point + let split = dec.length - decimals; + let value = dec.substring(0, split) + "." + dec.substring(split); + if (negative) { + value = "-" + value; + } + // Prevent ending in a decimal (e.g. "45." + if (value.substring(value.length - 1) === ".") { + value = value.substring(0, value.length - 1); + } + return { + type: type, + value: value + }; + }; + } + // BytesXX + case 4: { + let length = randomNumber(seed + "-length", 1, 33); + let type = "bytes" + String(length); + return (seed) => { + let value = randomHexString(seed + "-value", length); + return { + type: type, + value: value + }; + }; + } + // String + case 5: + return (seed) => { + let length = randomNumber(seed + "-length", 0, 36); + let value = ""; + while (value.length < length) { + value += chars[randomNumber(seed + "-value" + String(value.length), 0, chars.length)]; + } + return { + type: "string", + value: value + }; + }; + // Bytes + case 6: + return (seed) => { + let length = randomNumber(seed + "-length", 0, 12); // @TODO: increase this + let value = randomHexString(seed + "-value", length); + //let valueBytes = Buffer.from(value.substring(2), "hex"); + return { + type: "bytes", + value: value + }; + }; + // Fixed-Length Array (e.g. address[4]) + case 7: + // Falls-through + // Dynamic-Length Array (e.g. address[]) + case 8: { + let dynamic = (basetype === 8); + let subType = generateTest(seed + "-subtype"); + let length = randomNumber(seed + "-length", 1, 3); + let suffix = "[" + ((!dynamic) ? length : "") + "]"; + let type = subType("-index0").type + suffix; + return (seed) => { + if (dynamic) { + length = randomNumber(seed + "-length", 0, 3); + } + let children = []; + for (let i = 0; i < length; i++) { + children.push(subType(seed + "-index" + String(i))); + } + return { + type: type, + value: children.map((data) => data.value) + }; + }; + } + // Tuple + case 9: { + let count = randomNumber(seed + "-count", 1, 8); + let subTypes = []; + for (let i = 0; i < count; i++) { + let cSeed = seed + "-subtype" + String(i); + subTypes.push(generateTest(cSeed)); + } + let type = "tuple(" + subTypes.map(s => s("-index0").type).join(",") + ")"; + let struct = "Struct" + randomHexString(seed + "-name", 4).substring(2); + return (seed) => { + let children = []; + subTypes.forEach((subType) => { + children.push(subType(seed + "-value")); + }); + return { + type: type, + struct: struct, + value: children.map(c => c.value), + }; + }; + } + } + throw new Error("bad things"); + return null; +} +// Returns true iff the types are able to be non-standard pack encoded +function checkPack(types) { + for (let i = 0; i < types.length; i++) { + let type = types[i]; + if (hasPrefix(type, "tuple")) { + return false; + } + if (hasPrefix(type, "bytes[")) { + return false; + } + if (hasPrefix(type, "string[")) { + return false; + } + let firstDynamic = type.indexOf("[]"); + if (firstDynamic >= 0 && firstDynamic != type.length - 2) { + return false; + } + } + return true; +} +// Generates a Solidity source files with the parameter types and values +function generateSolidity(params) { + let plist = []; + for (let i = 0; i < params.length; i++) { + plist.push("p" + String(i)); + } + let genCodes = params.map(p => getGenCode(p)); + let code = new Code(); + /////////////////// + // Pragma + code.add("pragma experimental ABIEncoderV2;"); + code.add("pragma solidity ^0.5.5;"); + code.add(""); + /////////////////// + // Header + code.add("contract Test {"); + /////////////////// + // Structs + genCodes.forEach((genCode) => { + genCode.structs(code); + }); + /////////////////// + // test function + code.add("function test() public pure returns (" + genCodes.map((g, i) => (g.decl("p" + String(i)))).join(", ") + ") {"); + genCodes.forEach((genCode, index) => { + genCode.assign("p" + index, code); + }); + code.add("}"); + /////////////////// + // encode + code.add("function encode() public pure returns (bytes memory data){"); + code.comment("Declare all parameters"); + genCodes.forEach((genCode, index) => { + code.add(genCode.decl("p" + index) + ";"); + }); + code.comment("Assign all parameters"); + genCodes.forEach((genCode, index) => { + genCode.assign("p" + index, code); + }); + code.add(""); + code.add("return abi.encode(" + params.map((p, i) => ("p" + i)).join(", ") + ");"); + code.add("}"); + /////////////////// + // encodePacked + if (checkPack(params.map(p => p.type))) { + code.add("function encodePacked() public pure returns (bytes memory data){"); + code.comment("Declare all parameters"); + genCodes.forEach((genCode, index) => { + code.add(genCode.decl("p" + index) + ";"); + }); + code.comment("Assign all parameters"); + genCodes.forEach((genCode, index) => { + genCode.assign("p" + index, code); + }); + code.add(""); + code.add("return abi.encodePacked(" + params.map((p, i) => ("p" + i)).join(", ") + ");"); + code.add("}"); + } + /////////////////// + // Footer + code.add("}"); + return code.code; +} +for (let i = 0; i < 100; i++) { + let params = []; + console.log(i, randomNumber(String(i) + "-length", 1, 6)); + let length = randomNumber(String(i) + "-length", 1, 6); + for (let j = 0; j < length; j++) { + params.push(generateTest(String(i) + String(j) + "-type")(String(i) + String(j) + "-test")); + } + let solidity = generateSolidity(params); + console.log(solidity); + console.log(i); + let bytecode = compile(solidity)[0].bytecode; + //console.log(params.map(p => p.type).join(", ")); + //console.log(bytecode); + let testcase = { + //solidity: solidity, + bytecode: bytecode, + types: params.map(p => p.type), + value: params.map(p => p.value), + }; + console.log(testcase); +} diff --git a/packages/testcases/lib.esm/generation-scripts/hdnode.js b/packages/testcases/lib.esm/generation-scripts/hdnode.js new file mode 100644 index 000000000..df3c6c6ae --- /dev/null +++ b/packages/testcases/lib.esm/generation-scripts/hdnode.js @@ -0,0 +1,106 @@ +'use strict'; +import fs from "fs"; +import { resolve } from "path"; +import * as bip39 from "bip39"; +import { HDNode } from "bitcoinjs-lib"; +import * as ethereumUtil from "ethereumjs-util"; +import { randomHexString, randomNumber, saveTests } from ".."; +function getPath(seed) { + let path = "m"; + let count = randomNumber(seed + "-getPath-1", 1, 7); + let hardened = randomNumber(seed + "-getPath-2", 0, count + 2); + for (let i = 0; i < count; i++) { + path += "/" + randomNumber(seed + "-getPath-3" + i, 0, 12); + if (i < hardened) { + path += "'"; + } + } + return path; +} +function getHD(seed) { + let rootNode = HDNode.fromSeedHex(seed); + let privateKey = rootNode.keyPair.d.toBuffer(32); + let hdnodes = [{ + path: 'm', + privateKey: '0x' + privateKey.toString('hex'), + address: '0x' + ethereumUtil.privateToAddress(privateKey).toString('hex'), + }]; + for (let j = 0; j < 5; j++) { + let path = getPath(seed + '-hdnode-' + j); + let node = rootNode.derivePath(path); + let privateKey = node.keyPair.d.toBuffer(32); + hdnodes.push({ + path: path, + privateKey: '0x' + privateKey.toString('hex'), + address: '0x' + ethereumUtil.privateToAddress(privateKey).toString('hex'), + }); + } + return hdnodes; +} +const testcases = []; +// https://medium.com/@alexberegszaszi/why-do-my-bip32-wallets-disagree-6f3254cc5846#.6tqszlvf4 +testcases.push({ + name: "axic", + locale: "en", + entropy: '0xb0a30c7e93a58094d213c4c0aaba22da', + mnemonic: 'radar blur cabbage chef fix engine embark joy scheme fiction master release', + seed: '0xed37b3442b3d550d0fbb6f01f20aac041c245d4911e13452cac7b1676a070eda66771b71c0083b34cc57ca9c327c459a0ec3600dbaf7f238ff27626c8430a806', + hdnodes: [ + { + path: "m/44'/60'/0'/0/0", + address: '0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9', + privateKey: '0xb96e9ccb774cc33213cbcb2c69d3cdae17b0fe4888a1ccd343cbd1a17fd98b18', + } + ] +}); +["en", "es", "fr", "it", "ja", "ko", "zh_cn", "zh_tw"].forEach((locale) => { + let tests = JSON.parse(fs.readFileSync(resolve(__dirname, "../input/easyseed-bip39/bip39_vectors." + locale + ".json")).toString()); + tests.forEach((test, index) => { + testcases.push({ + name: ("easyseed-" + locale + "-" + index), + entropy: "0x" + test.entropy, + locale: locale, + mnemonic: test.mnemonic, + password: (test.passphrase || ''), + seed: "0x" + test.seed, + hdnodes: [] + }); + }); +}); +console.log("@TODO: This should be 1024"); +for (let i = 0; i < 10; i++) { + let strength = 16 + 4 * randomNumber('random-1-' + i, 0, 5); + let entropy = randomHexString('random-2-' + i, strength); + let mnemonic = bip39.entropyToMnemonic(entropy.substring(2)); + let seed = bip39.mnemonicToSeedHex(mnemonic); + testcases.push({ + name: "random-" + i, + locale: "en", + entropy: entropy, + mnemonic: mnemonic, + seed: '0x' + seed, + hdnodes: getHD(seed), + }); +} +let trezor = require('../input/tests-trezor-bip39.json'); +trezor.english.forEach((testcase, i) => { + testcases.push({ + name: "trezor-" + i, + locale: "en", + entropy: '0x' + testcase[0], + mnemonic: testcase[1], + seed: '0x' + testcase[2], + hdnodes: getHD(testcase[2]), + password: 'TREZOR', + }); +}); +/* +let seed = bip39.mnemonicToSeedHex('radar blur cabbage chef fix engine embark joy scheme fiction master release'); +console.log('Seed', seed); +let entropy = bip39.mnemonicToEntropy('radar blur cabbage chef fix engine embark joy scheme fiction master release'); +console.log('Entropy', entropy); +let rootNode = HDNode.fromSeedHex(seed); +let node = rootNode.derivePath("m/44'/60'/0'/0/0"); +console.log('PrivateKey', node.keyPair.d.toBuffer(32).toString('hex')), +*/ +saveTests('hdnode', testcases); diff --git a/packages/testcases/lib.esm/generation-scripts/nameprep.js b/packages/testcases/lib.esm/generation-scripts/nameprep.js new file mode 100644 index 000000000..620f7bf4c --- /dev/null +++ b/packages/testcases/lib.esm/generation-scripts/nameprep.js @@ -0,0 +1,6 @@ +'use strict'; +import fs from "fs"; +import { resolve } from "path"; +import { saveTests } from ".."; +const testcases = JSON.parse(fs.readFileSync(resolve(__dirname, "../input/nameprep-josefsson-idn.json")).toString()); +saveTests("nameprep", testcases); diff --git a/packages/testcases/lib.esm/generation-scripts/units.js b/packages/testcases/lib.esm/generation-scripts/units.js new file mode 100644 index 000000000..feb55940e --- /dev/null +++ b/packages/testcases/lib.esm/generation-scripts/units.js @@ -0,0 +1,6 @@ +'use strict'; +import fs from "fs"; +import { resolve } from "path"; +import { saveTests } from ".."; +const testcases = JSON.parse(fs.readFileSync(resolve(__dirname, "../input/units.json")).toString()); +saveTests("units", testcases); diff --git a/packages/testcases/lib.esm/generation-scripts/wallets.js b/packages/testcases/lib.esm/generation-scripts/wallets.js new file mode 100644 index 000000000..8ee89a891 --- /dev/null +++ b/packages/testcases/lib.esm/generation-scripts/wallets.js @@ -0,0 +1,26 @@ +'use strict'; +import fs from "fs"; +import { resolve } from "path"; +import { saveTests } from ".."; +const testcases = []; +const mnemonics = { + '15db397ed5f682acb22b0afc6c8de4cdfbda7cbc': 'debris glass rich exotic window other film slow expose flight either wealth', + '012363d61bdc53d0290a0f25e9c89f8257550fb8': 'service basket parent alcohol fault similar survey twelve hockey cloud walk panel' +}; +const inputDir = resolve(__dirname, "../input/wallets"); +fs.readdirSync(inputDir).forEach((filename) => { + let content = fs.readFileSync(resolve(inputDir, filename)).toString(); + let data = JSON.parse(content); + const comps = filename.split(".")[0].split("-"); + testcases.push({ + name: comps[1], + type: (data.ethaddr ? "crowdsale" : "secret-storage"), + hasAddress: !!data.address, + address: ("0x" + comps[2]), + privateKey: ("0x" + comps[3]), + mnemonic: (mnemonics[comps[2]] || null), + password: comps[4], + json: content + }); +}); +saveTests("wallets", testcases); diff --git a/packages/testcases/lib.esm/generation-scripts/wordlists.js b/packages/testcases/lib.esm/generation-scripts/wordlists.js new file mode 100644 index 000000000..9da33e5f4 --- /dev/null +++ b/packages/testcases/lib.esm/generation-scripts/wordlists.js @@ -0,0 +1,13 @@ +'use strict'; +import fs from "fs"; +import { resolve } from "path"; +import { saveTests } from ".."; +const testcases = []; +["en", "es", "fr", "it", "ja", "ko", "zh_cn", "zh_tw"].forEach((locale) => { + let content = fs.readFileSync(resolve(__dirname, "../input/wordlists", "lang-" + locale + ".txt")).toString(); + testcases.push({ + content: content, + locale: locale + }); +}); +saveTests("wordlists", testcases); diff --git a/packages/testcases/index.d.ts b/packages/testcases/lib.esm/index.d.ts similarity index 100% rename from packages/testcases/index.d.ts rename to packages/testcases/lib.esm/index.d.ts diff --git a/packages/testcases/lib.esm/index.js b/packages/testcases/lib.esm/index.js new file mode 100644 index 000000000..5e82b975d --- /dev/null +++ b/packages/testcases/lib.esm/index.js @@ -0,0 +1,43 @@ +'use strict'; +import fs from 'fs'; +import path from 'path'; +import zlib from 'browserify-zlib'; +import { arrayify, concat, hexlify } from "@ethersproject/bytes"; +import { keccak256 } from "@ethersproject/keccak256"; +import { toUtf8Bytes } from "@ethersproject/strings"; +export function saveTests(tag, data) { + //let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); + let filename = path.resolve('testcases', tag + '.json.gz'); + fs.writeFileSync(filename, zlib.gzipSync(JSON.stringify(data, undefined, ' ') + '\n')); + console.log('Save testcase: ' + filename); +} +export function loadTests(tag) { + let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); + return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString()); +} +export function loadData(filename) { + return fs.readFileSync(path.resolve(__dirname, filename)); +} +export function randomBytes(seed, lower, upper) { + if (!upper) { + upper = lower; + } + if (upper === 0 && upper === lower) { + return new Uint8Array(0); + } + let result = arrayify(keccak256(toUtf8Bytes(seed))); + while (result.length < upper) { + result = concat([result, keccak256(result)]); + } + let top = arrayify(keccak256(result)); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + return result.slice(0, lower + Math.floor((upper - lower) * percent)); +} +export function randomHexString(seed, lower, upper) { + return hexlify(randomBytes(seed, lower, upper)); +} +export function randomNumber(seed, lower, upper) { + let top = randomBytes(seed, 3); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + return lower + Math.floor((upper - lower) * percent); +} diff --git a/packages/testcases/lib/_version.d.ts b/packages/testcases/lib/_version.d.ts new file mode 100644 index 000000000..7fb072329 --- /dev/null +++ b/packages/testcases/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "testcases/5.0.0-beta.130"; diff --git a/packages/testcases/_version.js b/packages/testcases/lib/_version.js similarity index 100% rename from packages/testcases/_version.js rename to packages/testcases/lib/_version.js diff --git a/packages/testcases/lib/browser-fs.json b/packages/testcases/lib/browser-fs.json new file mode 100644 index 000000000..ce27a421f --- /dev/null +++ b/packages/testcases/lib/browser-fs.json @@ -0,0 +1 @@ +{ "dirs": ["./easyseed-bip39", "./testcases", "./wordlists"] } diff --git a/packages/testcases/lib/browser.d.ts b/packages/testcases/lib/browser.d.ts new file mode 100644 index 000000000..2836d6bcf --- /dev/null +++ b/packages/testcases/lib/browser.d.ts @@ -0,0 +1,3 @@ +/// +export declare function loadTests(tag: string): any; +export declare function loadData(filename: string): Buffer; diff --git a/packages/testcases/browser.js b/packages/testcases/lib/browser.js similarity index 100% rename from packages/testcases/browser.js rename to packages/testcases/lib/browser.js diff --git a/packages/testcases/generation-scripts/abi.js b/packages/testcases/lib/generation-scripts/abi.js similarity index 99% rename from packages/testcases/generation-scripts/abi.js rename to packages/testcases/lib/generation-scripts/abi.js index d22e85517..bcce1dcb7 100644 --- a/packages/testcases/generation-scripts/abi.js +++ b/packages/testcases/lib/generation-scripts/abi.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); //let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8549')); //import { compile as _compile } from "solc"; -var solc_1 = require("@ethersproject/cli/solc"); +var cli_1 = require("@ethersproject/cli"); var __1 = require(".."); var ethereumjs_util_1 = require("ethereumjs-util"); function hasPrefix(str, prefix) { @@ -516,7 +516,7 @@ for (var i = 0; i < 100; i++) { var solidity = generateSolidity(params); console.log(solidity); console.log(i); - var bytecode = solc_1.compile(solidity)[0].bytecode; + var bytecode = cli_1.solc.compile(solidity)[0].bytecode; //console.log(params.map(p => p.type).join(", ")); //console.log(bytecode); var testcase = { diff --git a/packages/testcases/generation-scripts/hdnode.js b/packages/testcases/lib/generation-scripts/hdnode.js similarity index 100% rename from packages/testcases/generation-scripts/hdnode.js rename to packages/testcases/lib/generation-scripts/hdnode.js diff --git a/packages/testcases/generation-scripts/nameprep.js b/packages/testcases/lib/generation-scripts/nameprep.js similarity index 100% rename from packages/testcases/generation-scripts/nameprep.js rename to packages/testcases/lib/generation-scripts/nameprep.js diff --git a/packages/testcases/generation-scripts/units.js b/packages/testcases/lib/generation-scripts/units.js similarity index 100% rename from packages/testcases/generation-scripts/units.js rename to packages/testcases/lib/generation-scripts/units.js diff --git a/packages/testcases/generation-scripts/wallets.js b/packages/testcases/lib/generation-scripts/wallets.js similarity index 100% rename from packages/testcases/generation-scripts/wallets.js rename to packages/testcases/lib/generation-scripts/wallets.js diff --git a/packages/testcases/generation-scripts/wordlists.js b/packages/testcases/lib/generation-scripts/wordlists.js similarity index 100% rename from packages/testcases/generation-scripts/wordlists.js rename to packages/testcases/lib/generation-scripts/wordlists.js diff --git a/packages/testcases/lib/index.d.ts b/packages/testcases/lib/index.d.ts new file mode 100644 index 000000000..39366ee44 --- /dev/null +++ b/packages/testcases/lib/index.d.ts @@ -0,0 +1,62 @@ +/// +export declare module TestCase { + type HDWalletNode = { + path: string; + address: string; + privateKey: string; + }; + type HDWallet = { + name: string; + seed: string; + locale: string; + password?: string; + entropy: string; + mnemonic: string; + hdnodes: Array; + }; + type Nameprep = { + comment: string; + input: Array; + output: Array; + rc?: string; + flags?: string; + }; + type Wallet = { + name: string; + type: "crowdsale" | "secret-storage"; + hasAddress: boolean; + address: string; + privateKey: string; + mnemonic?: string; + password?: string; + json: string; + }; + type Wordlist = { + locale: string; + content: string; + }; + type Unit = { + name: string; + ether: string; + ether_format: string; + wei: string; + kwei?: string; + mwei?: string; + gwei?: string; + szabo?: string; + finney?: string; + satoshi?: string; + kwei_format?: string; + mwei_format?: string; + gwei_format?: string; + szabo_format?: string; + finney_format?: string; + satoshi_format?: string; + }; +} +export declare function saveTests(tag: string, data: any): void; +export declare function loadTests(tag: string): any; +export declare function loadData(filename: string): Buffer; +export declare function randomBytes(seed: string, lower: number, upper?: number): Uint8Array; +export declare function randomHexString(seed: string, lower: number, upper?: number): string; +export declare function randomNumber(seed: string, lower: number, upper: number): number; diff --git a/packages/testcases/index.js b/packages/testcases/lib/index.js similarity index 92% rename from packages/testcases/index.js rename to packages/testcases/lib/index.js index 1ac2e410f..e2a2caaf1 100644 --- a/packages/testcases/index.js +++ b/packages/testcases/lib/index.js @@ -11,13 +11,13 @@ var keccak256_1 = require("@ethersproject/keccak256"); var strings_1 = require("@ethersproject/strings"); function saveTests(tag, data) { //let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); - var filename = path_1.default.resolve('testcases', tag + '.json.gz'); + var filename = path_1.default.resolve('../testcases', tag + '.json.gz'); fs_1.default.writeFileSync(filename, browserify_zlib_1.default.gzipSync(JSON.stringify(data, undefined, ' ') + '\n')); console.log('Save testcase: ' + filename); } exports.saveTests = saveTests; function loadTests(tag) { - var filename = path_1.default.resolve(__dirname, 'testcases', tag + '.json.gz'); + var filename = path_1.default.resolve(__dirname, '../testcases', tag + '.json.gz'); return JSON.parse(browserify_zlib_1.default.gunzipSync(fs_1.default.readFileSync(filename)).toString()); } exports.loadTests = loadTests; diff --git a/packages/testcases/package.json b/packages/testcases/package.json index 781bbd9c3..082483c13 100644 --- a/packages/testcases/package.json +++ b/packages/testcases/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/testcases", - "version": "5.0.0-beta.130", + "version": "5.0.0-beta.131", "description": "Testcases for Ethereum and scripts to generate testcases.", - "main": "index.js", + "main": "./lib/index.js", "browser": "browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -36,5 +36,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xc236a9348ed50fa69f51250c552f0857af80c944e0edcb750e61a73132ce307f" + "module": "./lib.esm/index.js", + "tarballHash": "0xecb1966755ccacc53768d87bf4a91cf0ca5b46d1ce30268daf651f27bd2a07a9" } diff --git a/packages/testcases/src.ts/generation-scripts/abi.ts b/packages/testcases/src.ts/generation-scripts/abi.ts index 9118ac764..b59763a34 100644 --- a/packages/testcases/src.ts/generation-scripts/abi.ts +++ b/packages/testcases/src.ts/generation-scripts/abi.ts @@ -3,7 +3,7 @@ //let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8549')); //import { compile as _compile } from "solc"; -import { compile } from "@ethersproject/cli/solc"; +import { solc } from "@ethersproject/cli"; import { randomHexString, randomNumber } from ".." import { BN, keccak256, toChecksumAddress } from "ethereumjs-util"; @@ -617,7 +617,7 @@ for (let i = 0; i < 100; i++) { let solidity = generateSolidity(params); console.log(solidity); console.log(i); - let bytecode = compile(solidity)[0].bytecode; + let bytecode = solc.compile(solidity)[0].bytecode; //console.log(params.map(p => p.type).join(", ")); //console.log(bytecode); let testcase = { diff --git a/packages/testcases/src.ts/index.ts b/packages/testcases/src.ts/index.ts index b5c436e8a..1d949fd75 100644 --- a/packages/testcases/src.ts/index.ts +++ b/packages/testcases/src.ts/index.ts @@ -77,7 +77,7 @@ export module TestCase { export function saveTests(tag: string, data: any) { //let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); - let filename = path.resolve('testcases', tag + '.json.gz'); + let filename = path.resolve('../testcases', tag + '.json.gz'); fs.writeFileSync(filename, zlib.gzipSync(JSON.stringify(data, undefined, ' ') + '\n')); @@ -85,7 +85,7 @@ export function saveTests(tag: string, data: any) { } export function loadTests(tag: string): any { - let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); + let filename = path.resolve(__dirname, '../testcases', tag + '.json.gz'); return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString()); } diff --git a/packages/testcases/tsconfig.json b/packages/testcases/tsconfig.json index 693cfac0a..afdea7af0 100644 --- a/packages/testcases/tsconfig.json +++ b/packages/testcases/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./", - + "outDir": "./lib/", "resolveJsonModule": true }, "include": [ @@ -12,6 +11,5 @@ "./src.ts/*.json", "./src.ts/generation-scripts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/tests/.gitignore b/packages/tests/.gitignore index 49cd42df6..a40fd0237 100644 --- a/packages/tests/.gitignore +++ b/packages/tests/.gitignore @@ -1,2 +1,3 @@ dist/ -tests/*.d.ts +lib/test-*.d.ts +lib.esm/test-*.d.ts diff --git a/packages/tests/lib.esm/_version.d.ts b/packages/tests/lib.esm/_version.d.ts new file mode 100644 index 000000000..dff9b0879 --- /dev/null +++ b/packages/tests/lib.esm/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "tests/5.0.0-beta.137"; diff --git a/packages/tests/lib.esm/_version.js b/packages/tests/lib.esm/_version.js new file mode 100644 index 000000000..3f2cc2afa --- /dev/null +++ b/packages/tests/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "tests/5.0.0-beta.137"; diff --git a/packages/tests/lib.esm/browser-ethers.d.ts b/packages/tests/lib.esm/browser-ethers.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/tests/tests/browser-ethers.js b/packages/tests/lib.esm/browser-ethers.js similarity index 100% rename from packages/tests/tests/browser-ethers.js rename to packages/tests/lib.esm/browser-ethers.js diff --git a/packages/tests/lib.esm/browser.d.ts b/packages/tests/lib.esm/browser.d.ts new file mode 100644 index 000000000..73d65f131 --- /dev/null +++ b/packages/tests/lib.esm/browser.d.ts @@ -0,0 +1,9 @@ +import * as accounts from "./test-account"; +import * as contract from "./test-contract"; +import * as contractInterface from "./test-contract-interface"; +import * as hdnode from "./test-hdnode"; +import * as providers from "./test-providers"; +import * as utils from "./test-utils"; +import * as wallet from "./test-wallet"; +import * as wordlists from "./test-wordlists"; +export { accounts, contract, contractInterface, hdnode, providers, utils, wallet, wordlists, }; diff --git a/packages/tests/lib.esm/browser.js b/packages/tests/lib.esm/browser.js new file mode 100644 index 000000000..08419c74f --- /dev/null +++ b/packages/tests/lib.esm/browser.js @@ -0,0 +1,11 @@ +'use strict'; +import * as accounts from "./test-account"; +import * as contract from "./test-contract"; +import * as contractInterface from "./test-contract-interface"; +import * as hdnode from "./test-hdnode"; +import * as providers from "./test-providers"; +import * as utils from "./test-utils"; +import * as wallet from "./test-wallet"; +import * as wordlists from "./test-wordlists"; +// build: require('./test-build'), +export { accounts, contract, contractInterface, hdnode, providers, utils, wallet, wordlists, }; diff --git a/packages/tests/lib.esm/test-account.js b/packages/tests/lib.esm/test-account.js new file mode 100644 index 000000000..f9a8b28a4 --- /dev/null +++ b/packages/tests/lib.esm/test-account.js @@ -0,0 +1,29 @@ +'use strict'; +import assert from 'assert'; +import { ethers } from "ethers"; +import { loadTests } from "@ethersproject/testcases"; +describe('Private key generation', function () { + let tests = loadTests('accounts'); + tests.forEach((test) => { + if (!test.privateKey) { + return; + } + it(('correctly converts private key - ' + test.name), function () { + let wallet = new ethers.Wallet(test.privateKey); + assert.equal(wallet.address.toLowerCase(), test.address.toLowerCase(), 'correctly computes privateKey - ' + test.privateKey); + }); + }); +}); +describe('Checksum and ICAP address generation', function () { + let tests = loadTests('accounts'); + tests.forEach((test) => { + it(('correctly transforms address - ' + test.name), function () { + assert.equal(ethers.utils.getAddress(test.address), test.checksumAddress, 'correctly computes checksum address from address'); + assert.equal(ethers.utils.getIcapAddress(test.address), test.icapAddress, 'correctly computes ICAP address from address'); + assert.equal(ethers.utils.getAddress(test.checksumAddress), test.checksumAddress, 'correctly computes checksum address from checksum address'); + assert.equal(ethers.utils.getIcapAddress(test.checksumAddress), test.icapAddress, 'correctly computes ICAP address from checksum address'); + assert.equal(ethers.utils.getAddress(test.icapAddress), test.checksumAddress, 'correctly computes checksum address from icap address'); + assert.equal(ethers.utils.getIcapAddress(test.icapAddress), test.icapAddress, 'correctly computes ICAP address from icap address'); + }); + }); +}); diff --git a/packages/tests/lib.esm/test-contract-interface.js b/packages/tests/lib.esm/test-contract-interface.js new file mode 100644 index 000000000..f0d07677c --- /dev/null +++ b/packages/tests/lib.esm/test-contract-interface.js @@ -0,0 +1,477 @@ +'use strict'; +import assert from "assert"; +import { ethers } from "ethers"; +import { loadTests } from "@ethersproject/testcases"; +const bnify = ethers.BigNumber.from; +function equals(actual, expected) { + // Array (treat recursively) + if (Array.isArray(actual)) { + if (!Array.isArray(expected) || actual.length !== expected.length) { + return false; + } + for (let i = 0; i < actual.length; i++) { + if (!equals(actual[i], expected[i])) { + return false; + } + } + return true; + } + if (typeof (actual) === 'number') { + actual = bnify(actual); + } + if (typeof (expected) === 'number') { + expected = bnify(expected); + } + // BigNumber + if (actual.eq) { + if (typeof (expected) === 'string' && expected.match(/^-?0x[0-9A-Fa-f]*$/)) { + let neg = (expected.substring(0, 1) === '-'); + if (neg) { + expected = expected.substring(1); + } + expected = bnify(expected); + if (neg) { + expected = expected.mul(-1); + } + } + if (!actual.eq(expected)) { + return false; + } + return true; + } + // Uint8Array + if (expected.buffer) { + if (!ethers.utils.isHexString(actual)) { + return false; + } + actual = ethers.utils.arrayify(actual); + if (!actual.buffer || actual.length !== expected.length) { + return false; + } + for (let i = 0; i < actual.length; i++) { + if (actual[i] !== expected[i]) { + return false; + } + } + return true; + } + // Maybe address? + try { + let actualAddress = ethers.utils.getAddress(actual); + let expectedAddress = ethers.utils.getAddress(expected); + return (actualAddress === expectedAddress); + } + catch (error) { } + // Something else + return (actual === expected); +} +function getValues(object, named) { + if (Array.isArray(object)) { + let result = []; + object.forEach(function (object) { + result.push(getValues(object, named)); + }); + return result; + } + switch (object.type) { + case 'number': + return bnify(object.value); + case 'boolean': + case 'string': + return object.value; + case 'buffer': + return ethers.utils.arrayify(object.value); + case 'tuple': + let result = getValues(object.value, named); + if (named) { + let namedResult = {}; + result.forEach((value, index) => { + namedResult['r' + String(index)] = value; + }); + return namedResult; + } + return result; + default: + throw new Error('invalid type - ' + object.type); + } +} +describe('ABI Coder Encoding', function () { + let coder = ethers.utils.defaultAbiCoder; + let tests = loadTests('contract-interface'); + tests.forEach((test) => { + let values = getValues(JSON.parse(test.normalizedValues)); + let types = JSON.parse(test.types); + let result = test.result; + let title = test.name + ' => (' + test.types + ') = (' + test.normalizedValues + ')'; + it(('encodes paramters - ' + test.name + ' - ' + test.types), function () { + this.timeout(120000); + let encoded = coder.encode(types, values); + assert.equal(encoded, result, 'encoded data - ' + title); + }); + }); +}); +describe('ABI Coder Decoding', function () { + let coder = ethers.utils.defaultAbiCoder; + let tests = loadTests('contract-interface'); + tests.forEach((test) => { + let values = getValues(JSON.parse(test.normalizedValues)); + let types = JSON.parse(test.types); + let result = test.result; + let title = test.name + ' => (' + test.types + ') = (' + test.normalizedValues + ')'; + it(('decodes parameters - ' + test.name + ' - ' + test.types), function () { + this.timeout(120000); + let decoded = coder.decode(types, result); + assert.ok(equals(decoded, values), 'decoded parameters - ' + title); + }); + }); +}); +describe('ABI Coder ABIv2 Encoding', function () { + let coder = ethers.utils.defaultAbiCoder; + let tests = loadTests('contract-interface-abi2'); + tests.forEach((test) => { + let values = getValues(JSON.parse(test.values)); + //let namedValues = getValues(JSON.parse(test.values), true); + let types = JSON.parse(test.types); + let expected = test.result; + let title = test.name + ' => (' + test.types + ') = (' + test.values + ')'; + it(('encodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function () { + this.timeout(120000); + let encoded = coder.encode(types, values); + assert.equal(encoded, expected, 'encoded positional parameters - ' + title); + let namedEncoded = coder.encode(types, values); + assert.equal(namedEncoded, expected, 'encoded named parameters - ' + title); + }); + }); +}); +describe('ABI Coder ABIv2 Decoding', function () { + let coder = ethers.utils.defaultAbiCoder; + let tests = loadTests('contract-interface-abi2'); + tests.forEach((test) => { + let values = getValues(JSON.parse(test.values)); + let types = JSON.parse(test.types); + let result = test.result; + let title = test.name + ' => (' + test.types + ') = (' + test.values + ')'; + it(('decodes ABIv2 parameters - ' + test.name + ' - ' + test.types), function () { + this.timeout(120000); + let decoded = coder.decode(types, result); + assert.ok(equals(decoded, values), 'decoded positional parameters - ' + title); + }); + }); +}); +describe('Test Contract Events', function () { + let tests = loadTests('contract-events'); + tests.forEach((test, index) => { + it(('decodes event parameters - ' + test.name + ' - ' + test.types), function () { + this.timeout(120000); + let iface = new ethers.utils.Interface(test.interface); + let parsed = iface.decodeEventLog(iface.events.testEvent, test.data, test.topics); + test.normalizedValues.forEach((expected, index) => { + if (test.hashed[index]) { + assert.ok(equals(parsed[index].hash, expected), 'parsed event indexed parameter matches - ' + index); + } + else { + assert.ok(equals(parsed[index], expected), 'parsed event parameter matches - ' + index); + } + }); + }); + }); + tests.forEach((test, index) => { + it(('decodes event data - ' + test.name + ' - ' + test.types), function () { + this.timeout(120000); + let iface = new ethers.utils.Interface(test.interface); + let parsed = iface.decodeEventLog(iface.events.testEvent, test.data); + test.normalizedValues.forEach((expected, index) => { + if (test.indexed[index]) { + assert.ok((ethers.Contract.isIndexed(parsed[index]) && parsed[index].hash == null), 'parsed event data has empty Indexed - ' + index); + } + else { + assert.ok(equals(parsed[index], expected), 'parsed event data matches - ' + index); + } + }); + }); + }); +}); +describe('Test Interface Signatures', function () { + let tests = loadTests('contract-signatures'); + tests.forEach((test) => { + it('derives the correct signature - ' + test.name, function () { + let iface = new ethers.utils.Interface(test.abi); + this.timeout(120000); + assert.equal(iface.functions.testSig.format(), test.signature, 'derived the correct signature'); + assert.equal(iface.getSighash(iface.functions.testSig), test.sigHash, 'derived the correct signature hash'); + }); + }); + it('derives correct description for human-readable ABI', function () { + let iface = new ethers.utils.Interface(["function transfer(address from, uint amount)"]); + [ + "transfer", + "transfer(address,uint256)" + ].forEach(function (key) { + let descr = iface.functions[key]; + assert.equal(descr.name, "transfer", "incorrect name key - " + key); + assert.equal(descr.format(), "transfer(address,uint256)", "incorrect signature key - " + key); + assert.equal(iface.getSighash(descr), "0xa9059cbb", "incorrect sighash key - " + key); + }); + }); + // See: https://github.com/ethers-io/ethers.js/issues/370 + it('parses transaction function', function () { + let iface = new ethers.utils.Interface(["function transfer(address from, uint amount)"]); + // Transaction: 0x820cc57bc77be44d8f4f024a18e18f64a8b6e62a82a3d7897db5970dbe181ba1 + let rawTx = "0xf8aa028502540be4008316e36094334eec1482109bd802d9e72a447848de3bcc106380b844a9059cbb000000000000000000000000851b9167b7cbf772d38efaf89705b35022880a070000000000000000000000000000000000000000000000000de0b6b3a764000026a03200bf26e5f10f7eda59c0aad9adc2334dda79e785b9b004342524d97a66fca9a0450b07a4dc450bb472e08f8370350fa365fcef6db1a95309ae4c06c9d0748092"; + let tx = ethers.utils.parseTransaction(rawTx); + let descr = iface.parseTransaction(tx); + assert.equal(descr.args[0], '0x851b9167B7cbf772D38eFaf89705b35022880A07', 'parsed tx - args[0]'); + assert.equal(descr.args[1].toString(), '1000000000000000000', 'parsed tx - args[1]'); + assert.equal(descr.name, 'transfer', 'parsed tx - name'); + assert.equal(descr.signature, 'transfer(address,uint256)', 'parsed tx - signature'); + assert.equal(descr.sighash, '0xa9059cbb', 'parsed tx - sighash'); + assert.equal(descr.value.toString(), '0', 'parsed tx - value'); + }); +}); +describe('Test Number Coder', function () { + let coder = ethers.utils.defaultAbiCoder; + it('null input failed', function () { + this.timeout(120000); + assert.throws(() => { + let result = coder.decode(['bool'], '0x'); + console.log(result); + }, (error) => { + assert.equal(error.reason, 'data out-of-bounds', 'got invalid bool'); + return true; + }, 'null bytes throws an error'); + }); + let overflowAboveHex = '0x10000000000000000000000000000000000000000000000000000000000000000'; + let overflowBelowHex = '-0x10000000000000000000000000000000000000000000000000000000000000000'; + let maxHex = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; + let maxLessOneHex = '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe'; + let maxSignedHex = '0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; + let maxSignedLessOneHex = '0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe'; + let minSignedHex = '-0x8000000000000000000000000000000000000000000000000000000000000000'; + let minSignedHex2s = '0x8000000000000000000000000000000000000000000000000000000000000000'; + let minMoreOneSignedHex = '-0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; + let minMoreOneSignedHex2s = '0x8000000000000000000000000000000000000000000000000000000000000001'; + let zeroHex = '0x0000000000000000000000000000000000000000000000000000000000000000'; + let oneHex = '0x0000000000000000000000000000000000000000000000000000000000000001'; + it('encodes zero', function () { + let ZeroValues = [ + { n: 'number zero', v: 0 }, + { n: 'hex zero', v: '0x0' }, + { n: 'hex leading even length', v: '0x0000' }, + { n: 'hex leading odd length', v: '0x00000' }, + { n: 'BigNumber', v: ethers.constants.Zero } + ]; + let expected = zeroHex; + ['uint8', 'uint256', 'int8', 'int256'].forEach(function (type) { + ZeroValues.forEach(function (value) { + let result = coder.encode([type], [value.v]); + assert.equal(result, expected, value.n + ' ' + type); + }); + }); + }); + it('encodes one', function () { + let ZeroValues = [ + { n: 'number', v: 1 }, + { n: 'hex', v: '0x1' }, + { n: 'hex leading even length', v: '0x0001' }, + { n: 'hex leading odd length', v: '0x00001' }, + { n: 'BigNumber', v: ethers.constants.One } + ]; + let expected = oneHex; + ['uint8', 'uint256', 'int8', 'int256'].forEach(function (type) { + ZeroValues.forEach(function (value) { + let result = coder.encode([type], [value.v]); + assert.equal(result, expected, value.n + ' ' + type); + }); + }); + }); + it('encodes negative one', function () { + let Values = [ + { n: 'number', v: -1 }, + { n: 'hex', v: '-0x1' }, + { n: 'hex leading even length', v: '-0x0001' }, + { n: 'hex leading odd length', v: '-0x00001' }, + { n: 'BigNumber', v: ethers.constants.NegativeOne } + ]; + let expected = maxHex; + ['int8', 'int256'].forEach(function (type) { + Values.forEach(function (value) { + let result = coder.encode([type], [value.v]); + assert.equal(result, expected, value.n + ' ' + type); + }); + }); + }); + it('encodes full uint8 range', function () { + for (let i = 0; i < 256; i++) { + let expected = '0x00000000000000000000000000000000000000000000000000000000000000'; + expected += ethers.utils.hexlify(i).substring(2); + let result = coder.encode(['uint8'], [i]); + assert.equal(result, expected, 'int8 ' + i); + } + }); + it('encodes full int8 range', function () { + for (let i = -128; i < 128; i++) { + let expected = null; + if (i === -128) { + expected = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80'; + } + else if (i < 0) { + expected = '0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'; + expected += ethers.utils.hexlify(256 + i).substring(2); + } + else { + expected = '0x00000000000000000000000000000000000000000000000000000000000000'; + expected += ethers.utils.hexlify(i).substring(2); + } + let result = coder.encode(['int8'], [i]); + assert.equal(result, expected, 'int8 ' + i); + } + }); + it('encodes uint256 end range', function () { + assert.equal(coder.encode(['uint256'], [bnify(maxHex)]), maxHex, 'uint256 max'); + assert.equal(coder.encode(['uint256'], [bnify(maxLessOneHex)]), maxLessOneHex, 'uint256 max'); + }); + it('encodes int256 end ranges', function () { + assert.equal(coder.encode(['int256'], [bnify(maxSignedHex)]), maxSignedHex, 'int256 max'); + assert.equal(coder.encode(['int256'], [bnify(maxSignedLessOneHex)]), maxSignedLessOneHex, 'int256 max'); + assert.equal(coder.encode(['int256'], [bnify(minSignedHex)]), minSignedHex2s, 'int256 max'); + assert.equal(coder.encode(['int256'], [bnify(minMoreOneSignedHex)]), minMoreOneSignedHex2s, 'int256 max'); + }); + it('fails to encode out-of-range uint8', function () { + [-128, -127, -2, -1, 256, 1000, bnify(maxHex), bnify(maxSignedHex).add(1), bnify(minSignedHex), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function (value) { + assert.throws(() => { + let result = coder.encode(['uint8'], [value]); + console.log('RESULT', value, result); + }, (error) => { + assert.equal(error.reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + it('fails to encode out-of-range int8', function () { + [-129, -130, -1000, 128, 129, 1000, bnify(maxHex), bnify(maxSignedHex).add(1), bnify(minSignedHex).sub(1), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function (value) { + assert.throws(() => { + let result = coder.encode(['int8'], [value]); + console.log('RESULT', value, result); + }, (error) => { + assert.equal(error.reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + it('fails to encode out-of-range uint256', function () { + [-128, -127, -2, -1, bnify(maxHex).add(1), bnify('-' + maxHex), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function (value) { + assert.throws(() => { + let result = coder.encode(['uint256'], [value]); + console.log('RESULT', value, result); + }, (error) => { + assert.equal(error.reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); + it('fails to encode out-of-range int256', function () { + [bnify(maxHex), bnify(maxSignedHex).add(1), bnify(minSignedHex).sub(1), bnify(overflowAboveHex), bnify(overflowBelowHex)].forEach(function (value, index) { + assert.throws(() => { + let result = coder.encode(['int256'], [value]); + console.log('RESULT', index, value, result); + }, (error) => { + assert.equal(error.reason, 'value out-of-bounds', 'wrong error'); + return true; + }, 'out-of-range numbers throw an error'); + }); + }); +}); +describe('Test Fixed Bytes Coder', function () { + let coder = ethers.utils.defaultAbiCoder; + let zeroHex = '0x0000000000000000000000000000000000000000000000000000000000000000'; + it('fails to encode out-of-range bytes4', function () { + ['0x', '0x00000', '0x000', zeroHex, '0x12345', '0x123456', '0x123', '0x12'].forEach(function (value, index) { + assert.throws(() => { + let result = coder.encode(['bytes4'], [value]); + console.log('RESULT', index, value, result); + }, (error) => { + if (value.length % 2) { + assert.equal(error.reason, 'hex data is odd-length', 'wrong error'); + } + else { + assert.equal(error.reason, 'incorrect data length', 'wrong error'); + } + return true; + }, 'out-of-range fixed bytes throw an error'); + }); + }); + it('fails to encode out-of-range bytes32', function () { + ['0x', '0x00000', '0x000', '0x12345', '0x123456', (zeroHex + '0'), (zeroHex + '00')].forEach(function (value, index) { + assert.throws(() => { + let result = coder.encode(['bytes32'], [value]); + console.log('RESULT', index, value, result); + }, (error) => { + if (value.length % 2) { + assert.equal(error.reason, 'hex data is odd-length', 'wrong error'); + } + else { + assert.equal(error.reason, 'incorrect data length', 'wrong error'); + } + return true; + }, 'out-of-range fixed bytes throw an error'); + }); + }); +}); +describe('Test Filters', function () { + // @TODO: Add a LOT more tests here + function doTest(test) { + it(test.name, function () { + let iface = new ethers.utils.Interface([test.signature]); + let eventDescription = iface.events[test.event]; + let filter = iface.encodeFilterTopics(eventDescription, test.args); + assert.equal(filter.length, test.expected.length, 'filter length matches - ' + test.name); + filter.forEach((expected, index) => { + assert.equal(expected, test.expected[index], 'signature topic matches - ' + index + ' - ' + test.name); + }); + }); + } + let Tests = [ + // Skips null in non-indexed fields + // See: https://github.com/ethers-io/ethers.js/issues/305 + { + name: "creates correct filters for null non-indexed fields", + args: [null, 2, null, null], + event: "LogSomething", + signature: "event LogSomething(int hup, int indexed two, bool three, address indexed four)", + expected: [ + "0xf6b983969813047dce97b9ff8a48cfb0a13306eb2caae2ef186b280bc27491c8", + "0x0000000000000000000000000000000000000000000000000000000000000002" + ] + }, + // https://etherscan.io/tx/0x820cc57bc77be44d8f4f024a18e18f64a8b6e62a82a3d7897db5970dbe181ba1 + { + name: "transfer filtering from", + args: [ + "0x59DEa134510ebce4a0c7146595dc8A61Eb9D0D79" + ], + event: "Transfer", + signature: "event Transfer(address indexed from, address indexed to, uint value)", + expected: [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "0x00000000000000000000000059dea134510ebce4a0c7146595dc8a61eb9d0d79" + ] + }, + { + name: "transfer filtering to", + args: [ + null, + "0x851b9167B7cbf772D38eFaf89705b35022880A07" + ], + event: "Transfer", + signature: "event Transfer(address indexed from, address indexed to, uint value)", + expected: [ + "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + null, + "0x000000000000000000000000851b9167b7cbf772d38efaf89705b35022880a07" + ] + } + ]; + Tests.forEach(function (test) { + doTest(test); + }); +}); diff --git a/packages/tests/lib.esm/test-contract.js b/packages/tests/lib.esm/test-contract.js new file mode 100644 index 000000000..82217d669 --- /dev/null +++ b/packages/tests/lib.esm/test-contract.js @@ -0,0 +1,119 @@ +'use strict'; +import assert from "assert"; +import { ethers } from "ethers"; +const provider = new ethers.providers.InfuraProvider('rinkeby'); +const contract = (function () { + let data = require('../contracts/test-contract.json'); + return new ethers.Contract(data.contractAddress, data.interface, provider); +})(); +//let event = contract.foo("TestP0"); +//console.log(event); +//process.exit(); +function equals(name, actual, expected) { + if (Array.isArray(expected)) { + assert.equal(actual.length, expected.length, 'array length mismatch - ' + name); + expected.forEach(function (expected, index) { + equals(name + ':' + index, actual[index], expected); + }); + return; + } + if (typeof (actual) === 'object') { + if (expected.indexed) { + assert.ok(ethers.Contract.isIndexed(actual), 'index property has index - ' + name); + if (expected.hash) { + assert.equal(actual.hash, expected.hash, 'index property with known hash matches - ' + name); + } + return; + } + if (actual.eq) { + assert.ok(actual.eq(expected), 'numeric value matches - ' + name); + } + } + assert.equal(actual, expected, 'value matches - ' + name); +} +function TestContractEvents() { + return ethers.utils.fetchJson('https://api.ethers.io/api/v1/?action=triggerTest&address=' + contract.address).then(function (data) { + console.log(' *** Triggered Transaction Hash: ' + data.hash); + contract.on("error", (error) => { + console.log(error); + assert(false); + contract.removeAllListeners(); + }); + function waitForEvent(eventName, expected) { + return new Promise(function (resolve, reject) { + contract.on(eventName, function () { + let args = Array.prototype.slice.call(arguments); + let event = args.pop(); + event.removeListener(); + equals(event.event, args, expected); + resolve(); + }); + }); + } + return new Promise(function (resolve, reject) { + let p0 = '0x06B5955A67D827CDF91823E3bB8F069e6c89c1D6'; + let p0_1 = '0x06b5955A67d827CdF91823e3Bb8F069e6C89C1d7'; + let p1 = 0x42; + let p1_1 = 0x43; + return Promise.all([ + waitForEvent('Test', [p0, p1]), + waitForEvent('TestP0', [p0, p1]), + waitForEvent('TestP0P1', [p0, p1]), + waitForEvent('TestIndexedString', [{ indexed: true, hash: '0x7c5ea36004851c764c44143b1dcb59679b11c9a68e5f41497f6cf3d480715331' }, p1]), + waitForEvent('TestV2', [{ indexed: true }, [p0, p1]]), + waitForEvent('TestV2Nested', [{ indexed: true }, [p0_1, p1_1, [p0, p1]]]), + ]).then(function (result) { + resolve(); + }); + }); + }); +} +describe('Test Contract Objects', function () { + it('parses events', function () { + this.timeout(120000); + return TestContractEvents(); + }); + it('ABIv2 parameters and return types work', function () { + this.timeout(120000); + let p0 = '0x06B5955A67D827CDF91823E3bB8F069e6c89c1D6'; + let p0_0f = '0x06B5955a67d827cDF91823e3bB8F069E6c89c1e5'; + let p0_f0 = '0x06b5955a67D827CDF91823e3Bb8F069E6C89c2C6'; + let p1 = 0x42; + let p1_0f = 0x42 + 0x0f; + let p1_f0 = 0x42 + 0xf0; + let expectedPosStruct = [p0_f0, p1_f0, [p0_0f, p1_0f]]; + let seq = Promise.resolve(); + [ + [p0, p1, [p0, p1]], + { p0: p0, p1: p1, child: [p0, p1] }, + [p0, p1, { p0: p0, p1: p1 }], + { p0: p0, p1: p1, child: { p0: p0, p1: p1 } } + ].forEach(function (struct) { + seq = seq.then(function () { + return contract.testV2(struct).then((result) => { + equals('position input', result, expectedPosStruct); + equals('keyword input p0', result.p0, expectedPosStruct[0]); + equals('keyword input p1', result.p1, expectedPosStruct[1]); + equals('keyword input child.p0', result.child.p0, expectedPosStruct[2][0]); + equals('keyword input child.p1', result.child.p1, expectedPosStruct[2][1]); + }); + }); + }); + return seq; + }); + it('collapses single argument solidity methods', function () { + this.timeout(120000); + return contract.testSingleResult(4).then((result) => { + assert.equal(result, 5, 'single value returned'); + }); + }); + it('does not collapses multi argument solidity methods', function () { + this.timeout(120000); + return contract.testMultiResult(6).then((result) => { + assert.equal(result[0], 7, 'multi value [0] returned'); + assert.equal(result[1], 8, 'multi value [1] returned'); + assert.equal(result.r0, 7, 'multi value [r0] returned'); + assert.equal(result.r1, 8, 'multi value [r1] returned'); + }); + }); +}); diff --git a/packages/tests/lib.esm/test-hdnode.js b/packages/tests/lib.esm/test-hdnode.js new file mode 100644 index 000000000..02af73cd5 --- /dev/null +++ b/packages/tests/lib.esm/test-hdnode.js @@ -0,0 +1,83 @@ +'use strict'; +import assert from "assert"; +import { ethers } from "ethers"; +import { loadTests, randomNumber } from "@ethersproject/testcases"; +function randomCase(seed, text) { + return text.split("").map(function (c, index) { + if (randomNumber(seed + "-" + index, 0, 2)) { + return c.toUpperCase(); + } + return c; + }).join(""); +} +describe('Test HD Node Derivation is Case Agnostic', function () { + let tests = loadTests('hdnode'); + tests.forEach((test) => { + it("Normalizes case - " + test.name, function () { + this.timeout(10000); + let wordlist = (ethers.wordlists)[test.locale]; + let rootNode = ethers.utils.HDNode.fromMnemonic(test.mnemonic, test.password || null, wordlist); + let altMnemonic = randomCase(test.name, test.mnemonic); + let altNode = ethers.utils.HDNode.fromMnemonic(altMnemonic, test.password || null, wordlist); + assert.equal(altNode.privateKey, rootNode.privateKey, altMnemonic); + }); + }); +}); +describe('Test HD Node Derivation from Seed', function () { + let tests = loadTests('hdnode'); + tests.forEach((test) => { + // If there is nothing to derive, skip this portion of the test + if (test.hdnodes.length === 0) { + return; + } + it('Derives the HD nodes - ' + test.name, function () { + this.timeout(10000); + let rootNode = ethers.utils.HDNode.fromSeed(test.seed); + test.hdnodes.forEach((nodeTest) => { + let node = rootNode.derivePath(nodeTest.path); + assert.equal(node.privateKey, nodeTest.privateKey, 'Generates privateKey - ' + nodeTest.privateKey); + let wallet = new ethers.Wallet(node.privateKey); + assert.equal(wallet.address.toLowerCase(), nodeTest.address, 'Generates address - ' + nodeTest.privateKey); + }); + }); + }); +}); +describe('Test HD Node Derivation from Mnemonic', function () { + let tests = loadTests('hdnode'); + tests.forEach((test) => { + // If there is nothing to derive, skip this portion of the test + if (test.hdnodes.length === 0) { + return; + } + it('Derives the HD nodes - ' + test.name, function () { + this.timeout(10000); + let rootNode = ethers.utils.HDNode.fromMnemonic(test.mnemonic, test.password || null); + test.hdnodes.forEach((nodeTest) => { + let node = rootNode.derivePath(nodeTest.path); + assert.equal(node.privateKey, nodeTest.privateKey, 'Matches privateKey - ' + nodeTest.privateKey); + assert.equal(node.mnemonic, test.mnemonic, 'Matches mnemonic - ' + nodeTest.privateKey); + assert.equal(node.path, nodeTest.path, 'Matches path - ' + nodeTest.privateKey); + let wallet = new ethers.Wallet(node.privateKey); + assert.equal(wallet.address.toLowerCase(), nodeTest.address, 'Generates address - ' + nodeTest.privateKey); + }); + }); + }); +}); +describe('Test HD Mnemonic Phrases', function testMnemonic() { + let tests = loadTests('hdnode'); + tests.forEach(function (test) { + it(('converts mnemonic phrases - ' + test.name), function () { + this.timeout(1000000); + assert.equal(ethers.utils.mnemonicToSeed(test.mnemonic, test.password), test.seed, 'Converts mnemonic to seed - ' + test.mnemonic + ':' + test.password); + // Test default english + if (test.locale === "en") { + assert.equal(ethers.utils.entropyToMnemonic(test.entropy), test.mnemonic, "Converts entropy to mnemonic " + test.name + " (default en)"); + assert.equal(ethers.utils.mnemonicToEntropy(test.mnemonic), test.entropy, "Converts mnemonic to entropy - " + test.mnemonic + " (default en)"); + } + let wordlist = (ethers.wordlists)[test.locale]; + let mnemonic = ethers.utils.entropyToMnemonic(test.entropy, wordlist); + assert.equal(mnemonic.normalize('NFKD'), test.mnemonic.normalize('NFKD'), 'Converts entropy to mnemonic ' + test.name); + assert.equal(ethers.utils.mnemonicToEntropy(test.mnemonic, wordlist), test.entropy, 'Converts mnemonic to entropy - ' + test.mnemonic); + }); + }); +}); diff --git a/packages/tests/lib.esm/test-providers.js b/packages/tests/lib.esm/test-providers.js new file mode 100644 index 000000000..1fa32421c --- /dev/null +++ b/packages/tests/lib.esm/test-providers.js @@ -0,0 +1,487 @@ +"use strict"; +import assert from "assert"; +const Web3HttpProvider = require("web3-providers-http"); +import { ethers } from "ethers"; +const bnify = ethers.BigNumber.from; +const blockchainData = { + homestead: { + balance: { + address: "0xAC1639CF97a3A46D431e6d1216f576622894cBB5", + balance: bnify("4918774100000000") + }, + block3: { + hash: "0x3d6122660cc824376f11ee842f83addc3525e2dd6756b9bcf0affa6aa88cf741", + parentHash: "0xb495a1d7e6663152ae92708da4843337b958146015a2802f4193a410044698c9", + number: 3, + timestamp: 1438270048, + nonce: "0x2e9344e0cbde83ce", + difficulty: 17154715646, + gasLimit: bnify("0x1388"), + gasUsed: bnify("0"), + miner: "0x5088D623ba0fcf0131E0897a91734A4D83596AA0", + extraData: "0x476574682f76312e302e302d66633739643332642f6c696e75782f676f312e34", + transactions: [] + }, + transaction: { + hash: "0xccc90ab97a74c952fb3376c4a3efb566a58a10df62eb4d44a61e106fcf10ec61", + blockHash: "0x9653f180a5720f3634816eb945a6d722adee52cc47526f6357ac10adaf368135", + blockNumber: 4097745, + transactionIndex: 18, + from: "0x32DEF047DeFd076DB21A2D759aff2A591c972248", + gasPrice: bnify("0x4a817c800"), + gasLimit: bnify("0x3d090"), + to: "0x6fC21092DA55B392b045eD78F4732bff3C580e2c", + value: bnify("0x186cc6acd4b0000"), + nonce: 0, + data: "0xf2c298be000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067269636d6f6f0000000000000000000000000000000000000000000000000000", + r: "0x1e5605197a03e3f0a168f14749168dfeefc44c9228312dacbffdcbbb13263265", + s: "0x269c3e5b3558267ad91b0a887d51f9f10098771c67b82ea6cb74f29638754f54", + v: 38, + creates: null, + raw: "0xf8d2808504a817c8008303d090946fc21092da55b392b045ed78f4732bff3c580e2c880186cc6acd4b0000b864f2c298be000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000067269636d6f6f000000000000000000000000000000000000000000000000000026a01e5605197a03e3f0a168f14749168dfeefc44c9228312dacbffdcbbb13263265a0269c3e5b3558267ad91b0a887d51f9f10098771c67b82ea6cb74f29638754f54", + networkId: 1 + }, + transactionReceipt: { + blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566", + blockNumber: 0x3c92b5, + contractAddress: null, + cumulativeGasUsed: 0x1cca2e, + from: "0x18C6045651826824FEBBD39d8560584078d1b247", + gasUsed: 0x14bb7, + logs: [ + { + address: "0x314159265dD8dbb310642f98f50C066173C1259b", + blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566", + blockNumber: 0x3c92b5, + data: "0x00000000000000000000000018c6045651826824febbd39d8560584078d1b247", + logIndex: 0x1a, + topics: ["0xce0457fe73731f824cc272376169235128c118b49d344817417c6d108d155e82", "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae", "0xf0106919d12469348e14ad6a051d0656227e1aba2fefed41737fdf78421b20e1"], + transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616", + transactionIndex: 0x39, + transactionLogIndex: 0x0 + }, + { + address: "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef", + blockHash: "0x36b4af7f0538559e581c8588f16477df0f676439ea67fe8d7a2ae4abb20e2566", + blockNumber: 0x3c92b5, + data: "0x000000000000000000000000000000000000000000000000002386f26fc1000000000000000000000000000000000000000000000000000000000000595a32ce", + logIndex: 0x1b, + topics: ["0x0f0c27adfd84b60b6f456b0e87cdccb1e5fb9603991588d87fa99f5b6b61e670", "0xf0106919d12469348e14ad6a051d0656227e1aba2fefed41737fdf78421b20e1", "0x00000000000000000000000018c6045651826824febbd39d8560584078d1b247"], + transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616", + transactionIndex: 0x39, + transactionLogIndex: 0x1 + } + ], + logsBloom: "0x00000000000000040000000000100000010000000000000040000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000200000010000000004000000000000000000000000000000000002000000000000000000000000400000000020000000000000000000000000000000000000004000000000000000000000000000000000000000000000000801000000000000000000000020000000000040000000040000000000000000002000000004000000000000000000000000000000000000000000000010000000000000000000000000000000000200000000000000000", + root: "0x9b550a9a640ce50331b64504ef87aaa7e2aaf97344acb6ff111f879b319d2590", + status: null, + to: "0x6090A6e47849629b7245Dfa1Ca21D94cd15878Ef", + transactionHash: "0xc6fcb7d00d536e659a4559d2de29afa9e364094438fef3e72ba80728ce1cb616", + transactionIndex: 0x39 + }, + transactionReceiptByzantium: { + byzantium: true, + blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9", + blockNumber: 0x444f76, + contractAddress: null, + cumulativeGasUsed: 0x15bfe7, + from: "0x18C6045651826824FEBBD39d8560584078d1b247", + gasUsed: 0x1b968, + logs: [ + { + address: "0xb90E64082D00437e65A76d4c8187596BC213480a", + blockHash: "0x34e5a6cfbdbb84f7625df1de69d218ade4da72f4a2558064a156674e72e976c9", + blockNumber: 0x444f76, + data: "0x", + logIndex: 0x10, + topics: ["0x748d071d1992ee1bfe7a39058114d0a50d5798fe8eb3a9bfb4687f024629a2ce", "0x5574aa58f7191ccab6de6cf75fe2ea0484f010b852fdd8c6b7ae151d6c2f4b83"], + transactionHash: "0x7f1c6a58dc880438236d0b0a4ae166e9e9a038dbea8ec074149bd8b176332cac", + transactionIndex: 0x1e, + transactionLogIndex: 0x0 + } + ], + logsBloom: "0x00000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000200000000000000008000000000000000000000000000000000000000000000000000000000000000010000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000800000000000000000800000000000000000000000000000000000000", + status: 1, + to: "0xb90E64082D00437e65A76d4c8187596BC213480a", + transactionHash: "0x7f1c6a58dc880438236d0b0a4ae166e9e9a038dbea8ec074149bd8b176332cac", + transactionIndex: 0x1e + } + }, + kovan: { + balance: { + address: "0x09c967A0385eE3B3717779738cA0B9D116e0EcE7", + balance: bnify("997787946734641021") + }, + block3: { + hash: "0xf0ec9bf41b99a6bd1f6cd29f91302f71a1a82d14634d2e207edea4b7962f3676", + parentHash: "0xf110ecd84454f116e2222378e7bca81ac3e59be0dac96d7ec56d5ef1c3bc1d64", + number: 3, + timestamp: 1488459452, + difficulty: 131072, + gasLimit: bnify("0x5b48ec"), + gasUsed: bnify("0"), + miner: "0x00A0A24b9f0E5EC7Aa4c7389b8302fd0123194dE", + extraData: "0xd5830105048650617269747986312e31352e31826c69", + transactions: [] + }, + }, + rinkeby: { + balance: { + address: "0xd09a624630a656a7dbb122cb05e41c12c7cd8c0e", + balance: bnify("3000000000000000000") + }, + block3: { + hash: "0x9eb9db9c3ec72918c7db73ae44e520139e95319c421ed6f9fc11fa8dd0cddc56", + parentHash: "0x9b095b36c15eaf13044373aef8ee0bd3a382a5abb92e402afa44b8249c3a90e9", + number: 3, + timestamp: 1492010489, + nonce: "0x0000000000000000", + difficulty: 2, + gasLimit: bnify("0x47e7c4"), + gasUsed: bnify(0), + miner: "0x0000000000000000000000000000000000000000", + extraData: "0xd783010600846765746887676f312e372e33856c696e757800000000000000004e10f96536e45ceca7e34cc1bdda71db3f3bb029eb69afd28b57eb0202c0ec0859d383a99f63503c4df9ab6c1dc63bf6b9db77be952f47d86d2d7b208e77397301", + transactions: [] + }, + }, + ropsten: { + balance: { + address: "0x03a6F7a5ce5866d9A0CCC1D4C980b8d523f80480", + balance: bnify("15861113897828552666") + }, + block3: { + hash: "0xaf2f2d55e6514389bcc388ccaf40c6ebf7b3814a199a214f1203fb674076e6df", + parentHash: "0x88e8bc1dd383672e96d77ee247e7524622ff3b15c337bd33ef602f15ba82d920", + number: 3, + timestamp: 1479642588, + nonce: "0x04668f72247a130c", + difficulty: 996427, + gasLimit: bnify("0xff4033"), + gasUsed: bnify("0"), + miner: "0xD1aEb42885A43b72B518182Ef893125814811048", + extraData: "0xd883010503846765746887676f312e372e318664617277696e", + transactions: [] + }, + transactionReceipt: { + blockHash: "0xc9235b8253fce455942147aa8b450d23081b867ffbb2a1e4dec934827cd80f8f", + blockNumber: 0x1564d8, + contractAddress: null, + cumulativeGasUsed: bnify("0x80b9"), + from: "0xb346D5019EeafC028CfC01A5f789399C2314ae8D", + gasUsed: bnify("0x80b9"), + logs: [ + { + address: "0x6fC21092DA55B392b045eD78F4732bff3C580e2c", + blockHash: "0xc9235b8253fce455942147aa8b450d23081b867ffbb2a1e4dec934827cd80f8f", + blockNumber: 0x1564d8, + data: "0x00000000000000000000000006b5955a67d827cdf91823e3bb8f069e6c89c1d6000000000000000000000000000000000000000000000000016345785d8a0000", + logIndex: 0x0, + topics: ["0xac375770417e1cb46c89436efcf586a74d0298fee9838f66a38d40c65959ffda"], + transactionHash: "0x55c477790b105e69e98afadf0505cbda606414b0187356137132bf24945016ce", + transactionIndex: 0x0, + transactionLogIndex: 0x0 + } + ], + logsBloom: "0x00000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000010000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + root: "0xf1c3506ab619ac1b5e8f1ca355b16d6b9a1b7436b2960b0e9ec9a91f4238b5cc", + to: "0x6fC21092DA55B392b045eD78F4732bff3C580e2c", + transactionHash: "0x55c477790b105e69e98afadf0505cbda606414b0187356137132bf24945016ce", + transactionIndex: 0x0 + }, + transactionReceiptByzantium: { + byzantium: true, + blockHash: "0x61d343e0e081b60ac53bab381e07bdd5d0815b204091a576fd05106b814e7e1e", + blockNumber: 0x1e1e3b, + contractAddress: null, + cumulativeGasUsed: bnify("0x4142f"), + from: "0xdc8F20170C0946ACCF9627b3EB1513CFD1c0499f", + gasUsed: bnify("0x1eb6d"), + logs: [ + { + address: "0xCBf1735Aad8C4B337903cD44b419eFE6538aaB40", + blockHash: "0x61d343e0e081b60ac53bab381e07bdd5d0815b204091a576fd05106b814e7e1e", + blockNumber: 0x1e1e3b, + data: "0x000000000000000000000000b70560a43a9abf6ea2016f40a3e84b8821e134c5f6c95607c490f4f379c0160ef5c8898770f8a52959abf0e9de914647b377fa290000000000000000000000000000000000000000000000000000000000001c20000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000030d4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000355524c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004c6a736f6e2868747470733a2f2f6170692e6b72616b656e2e636f6d2f302f7075626c69632f5469636b65723f706169723d455448555344292e726573756c742e584554485a5553442e632e300000000000000000000000000000000000000000", + logIndex: 0x1, + topics: ["0xb76d0edd90c6a07aa3ff7a222d7f5933e29c6acc660c059c97837f05c4ca1a84"], + transactionHash: "0xf724f1d6813f13fb523c5f6af6261d06d41138dd094fff723e09fb0f893f03e6", + transactionIndex: 0x2, + transactionLogIndex: 0x0 + } + ], + logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000080000000202000000", + status: 1, + to: "0xB70560a43A9aBf6ea2016F40a3e84B8821E134c5", + transactionHash: "0xf724f1d6813f13fb523c5f6af6261d06d41138dd094fff723e09fb0f893f03e6", + transactionIndex: 0x2 + }, + }, + goerli: { + balance: { + address: "0x06B5955A67D827CDF91823E3bB8F069e6c89c1D6", + balance: bnify("314159000000000000") + }, + block3: { + hash: "0xd5daa825732729bb0d2fd187a1b888e6bfc890f1fc5333984740d9052afb2920", + parentHash: "0xe675f1362d82cdd1ec260b16fb046c17f61d8a84808150f5d715ccce775f575e", + number: 3, + timestamp: 1548947483, + difficulty: 2, + gasLimit: bnify("10455073"), + gasUsed: bnify("0"), + miner: "0x0000000000000000000000000000000000000000", + extraData: "0x506172697479205465636820417574686f7269747900000000000000000000002822e1b202411c38084d96c84302b8361ec4840a51cd2fad9cb4bd9921cad7e64bc2e5dc7b41f3f75b33358be3aec718cf4d4317ace940e01b3581a95c9259ac01", + transactions: [] + }, + transactionReceipt: { + blockHash: "0x2384e8e8bdcf6eb87ec7c138fa503ac34adb32cac817e4b35f14d4339eaa1993", + blockNumber: 47464, + byzantium: true, + contractAddress: null, + cumulativeGasUsed: bnify(21000), + from: "0x8c1e1e5b47980D214965f3bd8ea34C413E120ae4", + gasUsed: bnify(21000), + logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + to: "0x58Bb4221245461E1d4cf886f18a01E3Df40Bd359", + transactionHash: "0xec8b1ac5d787f36c738cc7793fec606283b41f1efa69df4ae6b2a014dcd12797", + transactionIndex: 0, + logs: [], + status: 1 + } + } +}; +blockchainData["default"] = blockchainData.homestead; +function equals(name, actual, expected) { + if (expected && expected.eq) { + if (actual == null) { + assert.ok(false, name + " - actual big number null"); + } + assert.ok(expected.eq(actual), name + " matches"); + } + else if (Array.isArray(expected)) { + if (actual == null) { + assert.ok(false, name + " - actual array null"); + } + assert.equal(actual.length, expected.length, name + " array lengths match"); + for (let i = 0; i < expected.length; i++) { + equals("(" + name + " - item " + i + ")", actual[i], expected[i]); + } + } + else if (typeof (expected) === "object") { + if (actual == null) { + if (expected === actual) { + return; + } + assert.ok(false, name + " - actual object null"); + } + let keys = {}; + Object.keys(expected).forEach((key) => { keys[key] = true; }); + Object.keys(actual).forEach((key) => { keys[key] = true; }); + Object.keys(keys).forEach((key) => { + equals("(" + name + " - key + " + key + ")", actual[key], expected[key]); + }); + } + else { + if (actual == null) { + assert.ok(false, name + " - actual null"); + } + assert.equal(actual, expected, name + " matches"); + } +} +function testProvider(providerName, networkName) { + describe(("Read-Only " + providerName + " (" + networkName + ")"), function () { + let provider = null; + if (networkName === "default") { + if (providerName === "getDefaultProvider") { + provider = ethers.getDefaultProvider(); + } + else if (providerName === "Web3Provider") { + let infuraUrl = (new ethers.providers.InfuraProvider()).connection.url; + provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl)); + } + else { + provider = new (ethers.providers)[providerName](); + } + } + else { + if (providerName === "getDefaultProvider") { + provider = ethers.getDefaultProvider(networkName); + } + else if (providerName === "Web3Provider") { + let infuraUrl = (new ethers.providers.InfuraProvider(networkName)).connection.url; + provider = new ethers.providers.Web3Provider(new Web3HttpProvider(infuraUrl), networkName); + } + else { + provider = new (ethers.providers)[providerName](networkName); + } + } + it("fetches block #3", function () { + this.timeout(20000); + let test = blockchainData[networkName].block3; + return provider.getBlock(3).then((block) => { + for (let key in test) { + equals("Block " + key, block[key], test[key]); + } + }, (error) => { + console.log("Error", error); + assert.ok(false); + }); + }); + it("fetches address balance", function () { + // @TODO: These tests could be fiddled with if someone sends ether to our address + // We should set up a contract on each network like: + // + // contract TestBalance { + // function resetBalance() { + // assert(_owner.send(this.balance - 0.0000314159 ether)); + // } + // } + this.timeout(100000); + let test = blockchainData[networkName].balance; + return provider.getBalance(test.address).then(function (balance) { + equals("Balance", test.balance, balance); + }); + }); + function testTransactionReceipt(expected) { + let title = ("Receipt " + expected.transactionHash.substring(0, 10) + " - "); + return provider.getTransactionReceipt(expected.transactionHash).then(function (receipt) { + // This changes with every block + assert.equal(typeof (receipt.confirmations), "number", "confirmations is a number"); + delete receipt.confirmations; + for (let key in receipt) { + equals((title + key), receipt[key], expected[key]); + } + //equals(("Receipt " + expected.transactionHash.substring(0, 10)), receipt, expected); + }); + } + if (blockchainData[networkName].transactionReceipt) { + it("fetches pre-Byzantium transaction receipt", function () { + this.timeout(100000); + return testTransactionReceipt(blockchainData[networkName].transactionReceipt); + }); + } + if (blockchainData[networkName].transactionReceiptByzantium) { + it("fetches Byzantium transaction receipt", function () { + this.timeout(20000); + return testTransactionReceipt(blockchainData[networkName].transactionReceiptByzantium); + }); + } + function testTransaction(expected) { + let title = ("Transaction " + expected.hash.substring(0, 10) + " - "); + return provider.getTransaction(expected.hash).then((tx) => { + // This changes with every block + assert.equal(typeof (tx.confirmations), "number", "confirmations is a number"); + delete tx.confirmations; + assert.equal(typeof (tx.wait), "function", "wait is a function"); + delete tx.wait; + for (let key in tx) { + equals((title + key), tx[key], expected[key]); + } + }); + } + if (blockchainData[networkName].transaction) { + it("fetches transaction", function () { + this.timeout(20000); + return testTransaction(blockchainData[networkName].transaction); + }); + } + // Obviously many more cases to add here + // - getTransactionCount + // - getCode + // - getStorageAt + // - getBlockNumber + // - getGasPrice + // - estimateGas + // - sendTransaction + // - getTransaction (for other chains) + // - call + // - getLogs + // + // Many of these are tLegacyParametersested in run-providers, which uses nodeunit, but + // also creates a local private key which must then be funded to + // execute the tests. I am working on a better test contract to deploy + // to all the networks to help test these. + }); +} +["default", "homestead", "ropsten", "rinkeby", "kovan", "goerli"].forEach(function (networkName) { + ["getDefaultProvider", "AlchemyProvider", "CloudflareProvider", "InfuraProvider", "EtherscanProvider", "NodesmithProvider", "Web3Provider"].forEach(function (providerName) { + if (networkName === "goerli" && providerName === "AlchemyProvider") { + return; + } + if ((networkName !== "homestead" && networkName !== "default") && providerName === "CloudflareProvider") { + return; + } + testProvider(providerName, networkName); + }); +}); +/* +function getDefaults(network, extra) { + let network = ethers.utils.getNetwork(network); + let result = { + chainId: network.chainId, + ensAddress: (network.ensAddress ? getAddress(network.ensAddress): null), + name: network.name, + testnet: (network.name !== "homestead"), + }; + for (let key in extra) { + result[key] = extra[key]; + } + return result; +} +*/ +/* +describe("Test extra Etherscan operations", function() { + let provider = new providers.EtherscanProvider(); + it("fethces the current price of ether", function() { + this.timeout(20000); + return provider.getEtherPrice().then(function(price) { + assert.ok(typeof(price) === "number", "Etherscan price returns a number"); + assert.ok(price > 0.0, "Etherscan price returns non-zero"); + }); + }); + it("fetches the history", function() { + this.timeout(100000); + return provider.getHistory("ricmoo.firefly.eth").then(function(history) { + assert.ok(history.length > 40, "Etherscan history returns results"); + assert.equal(history[0].hash, "0xd25f550cfdff90c086a6496a84dbb2c4577df15b1416e5b3319a3e4ebb5b25d8", "Etherscan history returns correct transaction"); + }); + }); +}); +*/ +describe("Test Basic Authentication", function () { + // https://stackoverflow.com/questions/6509278/authentication-test-servers#16756383 + function test(name, url) { + it("tests " + name, function () { + this.timeout(20000); + return ethers.utils.fetchJson(url).then((data) => { + assert.equal(data.authenticated, true, "authenticates user"); + }); + }); + } + let secure = { + url: "https://httpbin.org/basic-auth/user/passwd", + user: "user", + password: "passwd" + }; + let insecure = { + url: "http://httpbin.org/basic-auth/user/passwd", + user: "user", + password: "passwd" + }; + let insecureForced = { + url: "http://httpbin.org/basic-auth/user/passwd", + user: "user", + password: "passwd", + allowInsecureAuthentication: true + }; + test("secure url", secure); + test("insecure url", insecureForced); + it("tests insecure connections fail", function () { + this.timeout(20000); + assert.throws(() => { + return ethers.utils.fetchJson(insecure); + }, (error) => { + return (error.reason === "basic authentication requires a secure https url"); + }, "throws an exception for insecure connections"); + }); +}); diff --git a/packages/tests/lib.esm/test-utils.js b/packages/tests/lib.esm/test-utils.js new file mode 100644 index 000000000..bbb0983c9 --- /dev/null +++ b/packages/tests/lib.esm/test-utils.js @@ -0,0 +1,319 @@ +'use strict'; +import assert from 'assert'; +import { ethers } from "ethers"; +import { loadTests } from "@ethersproject/testcases"; +import * as utils from './utils'; +function equals(a, b) { + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) { + return false; + } + for (let i = 0; i < a.length; i++) { + if (!equals(a[i], b[i])) { + return false; + } + } + return true; + } + return a === b; +} +describe('Test Contract Address Generation', function () { + // @TODO: Mine a large collection of these from the blockchain + let getContractAddress = ethers.utils.getContractAddress; + // Transaction: 0x939aa17985bc2a52a0c1cba9497ef09e092355a805a8150e30e24b753bac6864 + let Tests = [ + { + address: '0x3474627D4F63A678266BC17171D87f8570936622', + name: 'tx-0x939aa17985bc2a52a0c1cba9497ef09e092355a805a8150e30e24b753bac6864', + tx: { + from: '0xb2682160c482eb985ec9f3e364eec0a904c44c23', + nonce: 10, + } + }, + // Ropsten: 0x5bdfd14fcc917abc2f02a30721d152a6f147f09e8cbaad4e0d5405d646c5c3e1 + { + address: '0x0CcCC7507aEDf9FEaF8C8D731421746e16b4d39D', + name: 'zero-nonce', + tx: { + from: '0xc6af6e1a78a6752c7f8cd63877eb789a2adb776c', + nonce: 0 + } + }, + ]; + Tests.forEach(function (test) { + it(('Computes the transaction address - ' + test.name), function () { + this.timeout(120000); + assert.equal(getContractAddress(test.tx), test.address, 'computes the transaction address'); + }); + }); +}); +describe('Test RLP Coder', function () { + const tests = loadTests('rlp-coder'); + tests.forEach(function (test) { + it(('RLP coder encoded - ' + test.name), function () { + this.timeout(120000); + assert.equal(ethers.utils.RLP.encode(test.decoded), test.encoded, 'RLP encoded - ' + test.name); + }); + }); + tests.forEach((test) => { + it(('RLP coder decoded - ' + test.name), function () { + this.timeout(120000); + assert.ok(equals(ethers.utils.RLP.decode(test.encoded), test.decoded), 'RLP decoded - ' + test.name); + }); + }); +}); +describe('Test Unit Conversion', function () { + const tests = loadTests('units'); + tests.forEach((test) => { + let wei = ethers.BigNumber.from(test.wei); + it(('parses ' + test.ether + ' ether'), function () { + assert.ok(ethers.utils.parseEther(test.ether.replace(/,/g, '')).eq(wei), 'parsing ether failed - ' + test.name); + }); + it(('formats ' + wei.toString() + ' wei to ether'), function () { + let actual = ethers.utils.formatEther(wei); + assert.equal(actual, test.ether_format, 'formatting wei failed - ' + test.name); + }); + }); + tests.forEach((test) => { + let wei = ethers.BigNumber.from(test.wei); + ['kwei', 'mwei', 'gwei', 'szabo', 'finney', 'satoshi'].forEach((name) => { + let unitName = name; + if (name === 'satoshi') { + unitName = 8; + } + if (test[name]) { + it(('parses ' + test[name] + ' ' + name), function () { + this.timeout(120000); + assert.ok(ethers.utils.parseUnits(test[name].replace(/,/g, ''), unitName).eq(wei), ('parsing ' + name + ' failed - ' + test.name)); + }); + } + let expectedKey = (name + '_format'); + if (test[expectedKey]) { + it(('formats ' + wei.toString() + ' wei to ' + name + ')'), function () { + let actual = ethers.utils.formatUnits(wei, unitName); + let expected = test[expectedKey]; + assert.equal(actual, expected, ('formats ' + name + ' - ' + test.name)); + }); + } + }); + }); +}); +describe('Test Namehash', function () { + const tests = loadTests('namehash'); + tests.forEach((test) => { + it(('computes namehash - "' + test.name + '"'), function () { + this.timeout(120000); + assert.equal(ethers.utils.namehash(test.name), test.expected, 'computes namehash(' + test.name + ')'); + }); + }); +}); +describe('Test ID Hash Functione', function () { + const tests = [ + { + name: 'setAddr signature hash', + text: 'setAddr(bytes32,address)', + expected: '0xd5fa2b00b0756613052388dd576d941ba16904757996b8bb03a737ef4fd1f9ce' + } + ]; + tests.forEach((test) => { + it(('computes id - ' + test.name), function () { + this.timeout(120000); + let actual = ethers.utils.id(test.text); + assert.equal(actual, test.expected, 'computes id(' + test.text + ')'); + }); + }); +}); +describe('Test Solidity Hash Functions', function () { + const tests = loadTests('solidity-hashes'); + function test(funcName, testKey) { + it(('computes ' + funcName + ' correctly'), function () { + this.timeout(120000); + tests.forEach((test, index) => { + let actual = (ethers.utils)['solidity' + funcName](test.types, test.values); + let expected = test[testKey]; + assert.equal(actual, expected, ('computes solidity-' + funcName + '(' + JSON.stringify(test.values) + ') - ' + test.types)); + }); + }); + } + test('Keccak256', 'keccak256'); + test('Sha256', 'sha256'); +}); +describe('Test Hash Functions', function () { + const tests = loadTests('hashes'); + it('computes keccak256 correctly', function () { + this.timeout(120000); + tests.forEach(function (test) { + assert.equal(ethers.utils.keccak256(test.data), test.keccak256, ('Keccak256 - ' + test.data)); + }); + }); + it('computes sha2566 correctly', function () { + this.timeout(120000); + tests.forEach(function (test) { + assert.equal(ethers.utils.sha256(test.data), test.sha256, ('SHA256 - ' + test.data)); + }); + }); +}); +describe('Test Solidity splitSignature', function () { + it('splits a canonical signature', function () { + this.timeout(120000); + let r = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'; + let s = '0xcafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7e'; + for (let v = 27; v <= 28; v++) { + let signature = ethers.utils.concat([r, s, [v]]); + let sig = ethers.utils.splitSignature(signature); + assert.equal(sig.r, r, 'split r correctly'); + assert.equal(sig.s, s, 'split s correctly'); + assert.equal(sig.v, v, 'split v correctly'); + } + }); + it('splits a legacy signature', function () { + this.timeout(120000); + let r = '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef'; + let s = '0xcafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7ecafe1a7e'; + for (let v = 27; v <= 28; v++) { + let signature = ethers.utils.concat([r, s, [v - 27]]); + let sig = ethers.utils.splitSignature(signature); + assert.equal(sig.r, r, 'split r correctly'); + assert.equal(sig.s, s, 'split s correctly'); + assert.equal(sig.v, v, 'split v correctly'); + } + }); +}); +describe('Test Base64 coder', function () { + // https://en.wikipedia.org/wiki/Base64#Examples + it('encodes and decodes the example from wikipedia', function () { + this.timeout(120000); + let decodedText = 'Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.'; + let decoded = ethers.utils.toUtf8Bytes(decodedText); + let encoded = 'TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4='; + assert.equal(ethers.utils.base64.encode(decoded), encoded, 'encodes to base64 string'); + assert.equal(ethers.utils.toUtf8String(ethers.utils.base64.decode(encoded)), decodedText, 'decodes from base64 sstring'); + }); +}); +describe('Test UTF-8 coder', function () { + let BadUTF = [ + // See: https://en.wikipedia.org/wiki/UTF-8#Overlong_encodings + { bytes: [0xF0, 0x82, 0x82, 0xAC], reason: 'overlong', name: 'wikipedia overlong encoded Euro sign' }, + { bytes: [0xc0, 0x80], reason: 'overlong', name: '2-byte overlong - 0xc080' }, + { bytes: [0xc0, 0xbf], reason: 'overlong', name: '2-byte overlong - 0xc0bf' }, + { bytes: [0xc1, 0x80], reason: 'overlong', name: '2-byte overlong - 0xc180' }, + { bytes: [0xc1, 0xbf], reason: 'overlong', name: '2-byte overlong - 0xc1bf' }, + // Reserved UTF-16 Surrogate halves + { bytes: [0xed, 0xa0, 0x80], reason: 'utf-16 surrogate', name: 'utf-16 surrogate - U+d800' }, + { bytes: [0xed, 0xbf, 0xbf], reason: 'utf-16 surrogate', name: 'utf-16 surrogate - U+dfff' }, + // a leading byte not followed by enough continuation bytes + { bytes: [0xdf], reason: 'too short', name: 'too short - 2-bytes - 0x00' }, + { bytes: [0xe0], reason: 'too short', name: 'too short - 3-bytes' }, + { bytes: [0xe0, 0x80], reason: 'too short', name: 'too short - 3-bytes with 1' }, + { bytes: [0x80], reason: 'unexpected continuation byte', name: 'unexpected continuation byte' }, + { bytes: [0xc2, 0x00], reason: 'invalid continuation byte', name: 'invalid continuation byte - 0xc200' }, + { bytes: [0xc2, 0x40], reason: 'invalid continuation byte', name: 'invalid continuation byte - 0xc240' }, + { bytes: [0xc2, 0xc0], reason: 'invalid continuation byte', name: 'invalid continuation byte - 0xc2c0' }, + // Out of range + { bytes: [0xf4, 0x90, 0x80, 0x80], reason: 'out-of-range', name: 'out of range' }, + ]; + BadUTF.forEach(function (test) { + it('toUtf8String - ' + test.name, function () { + assert.throws(function () { + let result = ethers.utils.toUtf8String(test.bytes); + console.log('Result', result); + }, function (error) { + return (error.message.split(';').pop().trim() === test.reason); + }, test.name); + }); + }); + it('toUtf8String - random conversions', function () { + this.timeout(200000); + function randomChar(seed) { + switch (utils.randomNumber(seed + '-range', 0, 4)) { + case 0: + return String.fromCharCode(utils.randomNumber(seed + '-value', 0, 0x100)); + case 1: + return String.fromCharCode(utils.randomNumber(seed + '-value', 0, 0xd800)); + case 2: + return String.fromCharCode(utils.randomNumber(seed + '-value', 0xdfff + 1, 0xffff)); + case 3: + let left = utils.randomNumber(seed + '-value', 0xd800, 0xdbff + 1); + let right = utils.randomNumber(seed + '-value', 0xdc00, 0xdfff + 1); + return String.fromCharCode(left, right); + } + throw new Error('this should not happen'); + } + function randomString(seed) { + let length = utils.randomNumber(seed + '-length', 1, 5); + let str = ''; + for (let i = 0; i < length; i++) { + str += randomChar(seed + '-char-' + i); + } + return str; + } + for (let i = 0; i < 100000; i++) { + let seed = 'test-' + String(i); + let str = randomString(seed); + let bytes = ethers.utils.toUtf8Bytes(str); + let str2 = ethers.utils.toUtf8String(bytes); + let escaped = JSON.parse(ethers.utils._toEscapedUtf8String(bytes)); + assert.ok(Buffer.from(str).equals(Buffer.from(bytes)), 'bytes not generated correctly - ' + bytes); + assert.equal(str2, str, 'conversion not reflexive - ' + bytes); + assert.equal(escaped, str, 'conversion not reflexive - ' + bytes); + } + }); +}); +describe('Test Bytes32String coder', function () { + // @TODO: a LOT more test cases; generated from Solidity + it("encodes an ens name", function () { + let str = "ricmoo.firefly.eth"; + let bytes32 = ethers.utils.formatBytes32String(str); + let str2 = ethers.utils.parseBytes32String(bytes32); + assert.equal(bytes32, '0x7269636d6f6f2e66697265666c792e6574680000000000000000000000000000', 'formatted correctly'); + assert.equal(str2, str, "parsed correctly"); + }); +}); +describe('Test BigNumber', function () { + it("computes absoltue values", function () { + function testAbs(test) { + let value = ethers.BigNumber.from(test.value); + let expected = ethers.BigNumber.from(test.expected); + assert.ok(value.abs().eq(expected), 'BigNumber.abs - ' + test.value); + } + [ + { value: "0x0", expected: "0x0" }, + { value: "-0x0", expected: "0x0" }, + { value: "0x5", expected: "0x5" }, + { value: "-0x5", expected: "0x5" }, + { value: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + { value: "-0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + { value: "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + { value: "-0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", expected: "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }, + ].forEach(testAbs); + }); +}); +function getHex(value) { + return "0x" + Buffer.from(value).toString("hex"); +} +describe("Test nameprep", function () { + const Tests = loadTests("nameprep"); + Tests.forEach((test) => { + it(test.comment, function () { + let input = ethers.utils.toUtf8String(test.input); + if (test.output) { + let expected = ethers.utils.toUtf8String(test.output); + let actual = ethers.utils.nameprep(input); + assert.equal(actual, expected, `actual("${getHex(actual)}") !== expected("${getHex(expected)}")`); + } + else { + let ok = true; + let reason = ""; + try { + let actual = ethers.utils.nameprep(input); + console.log(actual); + reason = `should has thrown ${test.rc} - actual("${getHex(actual)}")`; + ok = false; + } + catch (error) { + } + assert.ok(ok, reason); + } + }); + }); +}); diff --git a/packages/tests/lib.esm/test-wallet.js b/packages/tests/lib.esm/test-wallet.js new file mode 100644 index 000000000..c86350444 --- /dev/null +++ b/packages/tests/lib.esm/test-wallet.js @@ -0,0 +1,182 @@ +'use strict'; +import assert from "assert"; +import { ethers } from "ethers"; +import { loadTests } from "@ethersproject/testcases"; +import * as utils from "./utils"; +describe('Test JSON Wallets', function () { + let tests = loadTests('wallets'); + tests.forEach(function (test) { + it(('decrypts wallet - ' + test.name), function () { + this.timeout(1200000); + if (test.hasAddress) { + assert.ok((ethers.utils.getJsonWalletAddress(test.json) !== null), 'detect encrypted JSON wallet'); + } + return ethers.Wallet.fromEncryptedJson(test.json, test.password).then((wallet) => { + assert.equal(wallet.privateKey, test.privateKey, 'generated correct private key - ' + wallet.privateKey); + assert.equal(wallet.address.toLowerCase(), test.address, 'generate correct address - ' + wallet.address); + if (test.mnemonic) { + assert.equal(wallet.mnemonic, test.mnemonic, 'mnemonic enabled encrypted wallet has a mnemonic'); + } + }); + }); + }); + // A few extra test cases to test encrypting/decrypting + ['one', 'two', 'three'].forEach(function (i) { + let password = 'foobar' + i; + let wallet = ethers.Wallet.createRandom({ path: "m/56'/82", extraEntropy: utils.randomHexString('test-' + i, 32) }); + it('encrypts and decrypts a random wallet - ' + i, function () { + this.timeout(1200000); + return wallet.encrypt(password).then((json) => { + return ethers.Wallet.fromEncryptedJson(json, password).then((decryptedWallet) => { + assert.equal(decryptedWallet.address, wallet.address, 'decrypted wallet - ' + wallet.privateKey); + assert.equal(decryptedWallet.mnemonic, wallet.mnemonic, "decrypted wallet menonic - " + wallet.privateKey); + assert.equal(decryptedWallet.path, wallet.path, "decrypted wallet path - " + wallet.privateKey); + return decryptedWallet.encrypt(password).then((encryptedWallet) => { + let parsedWallet = JSON.parse(encryptedWallet); + assert.equal(decryptedWallet.address.toLowerCase().substring(2), parsedWallet.address, 're-encrypted wallet - ' + wallet.privateKey); + }); + }); + }); + }); + }); +}); +describe('Test Transaction Signing and Parsing', function () { + function checkTransaction(parsedTransaction, test) { + let transaction = {}; + ['nonce', 'gasLimit', 'gasPrice', 'to', 'value', 'data'].forEach((key) => { + let expected = test[key]; + let value = parsedTransaction[key]; + if (["gasLimit", "gasPrice", "value"].indexOf(key) >= 0) { + assert.ok((ethers.BigNumber.isBigNumber(value)), 'parsed into a big number - ' + key); + value = value.toHexString(); + if (!expected || expected === '0x') { + expected = '0x00'; + } + } + else if (key === 'nonce') { + assert.equal(typeof (value), 'number', 'parse into a number - nonce'); + value = ethers.utils.hexlify(value); + if (!expected || expected === '0x') { + expected = '0x00'; + } + } + else if (key === 'data') { + if (!expected) { + expected = '0x'; + } + } + else if (key === 'to') { + if (value) { + // Make sure the address is valid + ethers.utils.getAddress(value); + value = value.toLowerCase(); + } + } + assert.equal(value, expected, 'parses ' + key + ' (legacy)'); + transaction[key] = test[key]; + }); + return transaction; + } + let tests = loadTests('transactions'); + tests.forEach((test) => { + it(('parses and signs transaction - ' + test.name), function () { + this.timeout(120000); + let signingKey = new ethers.utils.SigningKey(test.privateKey); + let signDigest = signingKey.signDigest.bind(signingKey); + // Legacy parsing unsigned transaction + checkTransaction(ethers.utils.parseTransaction(test.unsignedTransaction), test); + let parsedTransaction = ethers.utils.parseTransaction(test.signedTransaction); + let transaction = checkTransaction(parsedTransaction, test); + // Legacy signed transaction ecrecover + assert.equal(parsedTransaction.from, ethers.utils.getAddress(test.accountAddress), 'computed from'); + // Legacy transaction chain ID + assert.equal(parsedTransaction.chainId, 0, 'parses chainId (legacy)'); + // Legacy serializes unsigned transaction + (function () { + let unsignedTx = ethers.utils.serializeTransaction(transaction); + assert.equal(unsignedTx, test.unsignedTransaction, 'serializes undsigned transaction (legacy)'); + // Legacy signed serialized transaction + let signature = signDigest(ethers.utils.keccak256(unsignedTx)); + assert.equal(ethers.utils.serializeTransaction(transaction, signature), test.signedTransaction, 'signs transaction (legacy)'); + })(); + // EIP155 + // EIP-155 parsing unsigned transaction + let parsedUnsignedTransactionChainId5 = ethers.utils.parseTransaction(test.unsignedTransactionChainId5); + checkTransaction(parsedUnsignedTransactionChainId5, test); + assert.equal(parsedUnsignedTransactionChainId5.chainId, 5, 'parses chainId (eip155)'); + // EIP-155 fields + let parsedTransactionChainId5 = ethers.utils.parseTransaction(test.signedTransactionChainId5); + ['data', 'from', 'nonce', 'to'].forEach((key) => { + assert.equal(parsedTransaction[key], parsedTransactionChainId5[key], 'parses ' + key + ' (eip155)'); + }); + ['gasLimit', 'gasPrice', 'value'].forEach((key) => { + assert.ok(parsedTransaction[key].eq(parsedTransactionChainId5[key]), 'parses ' + key + ' (eip155)'); + }); + // EIP-155 chain ID + assert.equal(parsedTransactionChainId5.chainId, 5, 'parses chainId (eip155)'); + transaction.chainId = 5; + (function () { + // EIP-155 serialized unsigned transaction + let unsignedTx = ethers.utils.serializeTransaction(transaction); + assert.equal(unsignedTx, test.unsignedTransactionChainId5, 'serializes unsigned transaction (eip155) '); + // EIP-155 signed serialized transaction + let signature = signDigest(ethers.utils.keccak256(unsignedTx)); + assert.equal(ethers.utils.serializeTransaction(transaction, signature), test.signedTransactionChainId5, 'signs transaction (eip155)'); + })(); + }); + }); +}); +describe('Test Signing Messages', function () { + let tests = [ + // See: https://etherscan.io/verifySig/57 + { + address: '0x14791697260E4c9A71f18484C9f997B308e59325', + name: 'string("hello world")', + message: 'hello world', + messageHash: '0xd9eba16ed0ecae432b71fe008c98cc872bb4cc214d3220a36f365326cf807d68', + privateKey: '0x0123456789012345678901234567890123456789012345678901234567890123', + signature: '0xddd0a7290af9526056b4e35a077b9a11b513aa0028ec6c9880948544508f3c63265e99e47ad31bb2cab9646c504576b3abc6939a1710afc08cbf3034d73214b81c' + }, + // See: https://github.com/ethers-io/ethers.js/issues/80 + { + address: '0xD351c7c627ad5531Edb9587f4150CaF393c33E87', + name: 'bytes(0x47173285...4cb01fad)', + message: ethers.utils.arrayify('0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad'), + messageHash: '0x93100cc9477ba6522a2d7d5e83d0e075b167224ed8aa0c5860cfd47fa9f22797', + privateKey: '0x51d1d6047622bca92272d36b297799ecc152dc2ef91b229debf84fc41e8c73ee', + signature: '0x546f0c996fa4cfbf2b68fd413bfb477f05e44e66545d7782d87d52305831cd055fc9943e513297d0f6755ad1590a5476bf7d1761d4f9dc07dfe473824bbdec751b' + }, + // See: https://github.com/ethers-io/ethers.js/issues/85 + { + address: '0xe7deA7e64B62d1Ca52f1716f29cd27d4FE28e3e1', + name: 'zero-prefixed signature', + message: ethers.utils.arrayify(ethers.utils.id('0x7f23b5eed5bc7e89f267f339561b2697faab234a2')), + messageHash: '0x06c9d148d268f9a13d8f94f4ce351b0beff3b9ba69f23abbf171168202b2dd67', + privateKey: '0x09a11afa58d6014843fd2c5fd4e21e7fadf96ca2d8ce9934af6b8e204314f25c', + signature: '0x7222038446034a0425b6e3f0cc3594f0d979c656206408f937c37a8180bb1bea047d061e4ded4aeac77fa86eb02d42ba7250964ac3eb9da1337090258ce798491c' + } + ]; + tests.forEach(function (test) { + it(('signs a message "' + test.name + '"'), function () { + this.timeout(120000); + let wallet = new ethers.Wallet(test.privateKey); + return wallet.signMessage(test.message).then(function (signature) { + assert.equal(signature, test.signature, 'computes message signature'); + }); + }); + }); + tests.forEach(function (test) { + it(('verifies a message "' + test.name + '"'), function () { + this.timeout(120000); + // let address = ethers.utils.verifyMessage(test.message, test.signature); + // assert.equal(address, test.address, 'verifies message signature'); + }); + }); + tests.forEach(function (test) { + it(('hashes a message "' + test.name + '"'), function () { + this.timeout(120000); + let hash = ethers.utils.hashMessage(test.message); + assert.equal(hash, test.messageHash, 'calculates message hash'); + }); + }); +}); diff --git a/packages/tests/lib.esm/test-wordlists.js b/packages/tests/lib.esm/test-wordlists.js new file mode 100644 index 000000000..58e313aa4 --- /dev/null +++ b/packages/tests/lib.esm/test-wordlists.js @@ -0,0 +1,31 @@ +'use strict'; +import assert from 'assert'; +import { ethers } from "ethers"; +import { loadTests } from "@ethersproject/testcases"; +function checkWordlist(content, wordlist) { + let words = content.split('\n'); + it('matches wordlists for ' + wordlist.locale, function () { + for (let i = 0; i < 2048; i++) { + let actual = wordlist.getWord(i); + let expected = words[i]; + assert.equal(actual, expected, 'failed to match word ' + i + ': ' + words[i] + ' !=' + wordlist.getWord(i)); + } + }); +} +describe('Check Wordlists', function () { + let tests = loadTests("wordlists"); + tests.forEach((test) => { + let wordlist = (ethers.wordlists)[test.locale]; + checkWordlist(test.content, wordlist); + }); + /* + checkWordlist('./wordlists/lang-es.txt', ethers.wordlists.es); + checkWordlist('./wordlists/lang-fr.txt', ethers.wordlists.fr); + checkWordlist('./wordlists/lang-it.txt', ethers.wordlists.it); + checkWordlist('./wordlists/lang-ja.txt', ethers.wordlists.ja); + checkWordlist('./wordlists/lang-ko.txt', ethers.wordlists.ko); + checkWordlist('./wordlists/lang-zh_cn.txt', ethers.wordlists.zh); + checkWordlist('./wordlists/lang-zh_cn.txt', ethers.wordlists.zh_cn); + checkWordlist('./wordlists/lang-zh_tw.txt', ethers.wordlists.zh_tw); + */ +}); diff --git a/packages/tests/lib.esm/utils.d.ts b/packages/tests/lib.esm/utils.d.ts new file mode 100644 index 000000000..667696f08 --- /dev/null +++ b/packages/tests/lib.esm/utils.d.ts @@ -0,0 +1,5 @@ +declare function randomBytes(seed: string, lower: number, upper?: number): Uint8Array; +declare function randomHexString(seed: string, lower: number, upper?: number): string; +declare function randomNumber(seed: string, lower: number, upper: number): number; +declare function equals(a: any, b: any): boolean; +export { randomBytes, randomHexString, randomNumber, equals }; diff --git a/packages/tests/lib.esm/utils.js b/packages/tests/lib.esm/utils.js new file mode 100644 index 000000000..76e57058d --- /dev/null +++ b/packages/tests/lib.esm/utils.js @@ -0,0 +1,61 @@ +'use strict'; +import { ethers } from "ethers"; +function randomBytes(seed, lower, upper) { + if (!upper) { + upper = lower; + } + if (upper === 0 && upper === lower) { + return new Uint8Array(0); + } + let result = ethers.utils.arrayify(ethers.utils.keccak256(ethers.utils.toUtf8Bytes(seed))); + while (result.length < upper) { + result = ethers.utils.concat([result, ethers.utils.keccak256(ethers.utils.concat([seed, result]))]); + } + let top = ethers.utils.arrayify(ethers.utils.keccak256(result)); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + return result.slice(0, lower + Math.floor((upper - lower) * percent)); +} +function randomHexString(seed, lower, upper) { + return ethers.utils.hexlify(randomBytes(seed, lower, upper)); +} +function randomNumber(seed, lower, upper) { + let top = randomBytes(seed, 3); + let percent = ((top[0] << 16) | (top[1] << 8) | top[2]) / 0x01000000; + return lower + Math.floor((upper - lower) * percent); +} +function equals(a, b) { + // Array (treat recursively) + if (Array.isArray(a)) { + if (!Array.isArray(b) || a.length !== b.length) { + return false; + } + for (let i = 0; i < a.length; i++) { + if (!equals(a[i], b[i])) { + return false; + } + } + return true; + } + // BigNumber + if (a.eq) { + if (!b.eq || !a.eq(b)) { + return false; + } + return true; + } + // Uint8Array + if (a.buffer) { + if (!b.buffer || a.length !== b.length) { + return false; + } + for (let i = 0; i < a.length; i++) { + if (a[i] !== b[i]) { + return false; + } + } + return true; + } + // Something else + return a === b; +} +export { randomBytes, randomHexString, randomNumber, equals }; diff --git a/packages/tests/lib/_version.d.ts b/packages/tests/lib/_version.d.ts new file mode 100644 index 000000000..dff9b0879 --- /dev/null +++ b/packages/tests/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "tests/5.0.0-beta.137"; diff --git a/packages/tests/tests/_version.js b/packages/tests/lib/_version.js similarity index 100% rename from packages/tests/tests/_version.js rename to packages/tests/lib/_version.js diff --git a/packages/tests/lib/browser-ethers.d.ts b/packages/tests/lib/browser-ethers.d.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/tests/lib/browser-ethers.js b/packages/tests/lib/browser-ethers.js new file mode 100644 index 000000000..f0c67aa6f --- /dev/null +++ b/packages/tests/lib/browser-ethers.js @@ -0,0 +1,4 @@ +'use strict'; +console.log("Using global.ethers"); +module.exports = global.ethers; +console.log("FOO"); diff --git a/packages/tests/lib/browser.d.ts b/packages/tests/lib/browser.d.ts new file mode 100644 index 000000000..73d65f131 --- /dev/null +++ b/packages/tests/lib/browser.d.ts @@ -0,0 +1,9 @@ +import * as accounts from "./test-account"; +import * as contract from "./test-contract"; +import * as contractInterface from "./test-contract-interface"; +import * as hdnode from "./test-hdnode"; +import * as providers from "./test-providers"; +import * as utils from "./test-utils"; +import * as wallet from "./test-wallet"; +import * as wordlists from "./test-wordlists"; +export { accounts, contract, contractInterface, hdnode, providers, utils, wallet, wordlists, }; diff --git a/packages/tests/tests/browser.js b/packages/tests/lib/browser.js similarity index 100% rename from packages/tests/tests/browser.js rename to packages/tests/lib/browser.js diff --git a/packages/tests/tests/test-account.js b/packages/tests/lib/test-account.js similarity index 100% rename from packages/tests/tests/test-account.js rename to packages/tests/lib/test-account.js diff --git a/packages/tests/tests/test-contract-interface.js b/packages/tests/lib/test-contract-interface.js similarity index 100% rename from packages/tests/tests/test-contract-interface.js rename to packages/tests/lib/test-contract-interface.js diff --git a/packages/tests/tests/test-contract.js b/packages/tests/lib/test-contract.js similarity index 100% rename from packages/tests/tests/test-contract.js rename to packages/tests/lib/test-contract.js diff --git a/packages/tests/tests/test-hdnode.js b/packages/tests/lib/test-hdnode.js similarity index 100% rename from packages/tests/tests/test-hdnode.js rename to packages/tests/lib/test-hdnode.js diff --git a/packages/tests/tests/test-providers.js b/packages/tests/lib/test-providers.js similarity index 100% rename from packages/tests/tests/test-providers.js rename to packages/tests/lib/test-providers.js diff --git a/packages/tests/tests/test-utils.js b/packages/tests/lib/test-utils.js similarity index 100% rename from packages/tests/tests/test-utils.js rename to packages/tests/lib/test-utils.js diff --git a/packages/tests/tests/test-wallet.js b/packages/tests/lib/test-wallet.js similarity index 100% rename from packages/tests/tests/test-wallet.js rename to packages/tests/lib/test-wallet.js diff --git a/packages/tests/tests/test-wordlists.js b/packages/tests/lib/test-wordlists.js similarity index 100% rename from packages/tests/tests/test-wordlists.js rename to packages/tests/lib/test-wordlists.js diff --git a/packages/tests/lib/utils.d.ts b/packages/tests/lib/utils.d.ts new file mode 100644 index 000000000..667696f08 --- /dev/null +++ b/packages/tests/lib/utils.d.ts @@ -0,0 +1,5 @@ +declare function randomBytes(seed: string, lower: number, upper?: number): Uint8Array; +declare function randomHexString(seed: string, lower: number, upper?: number): string; +declare function randomNumber(seed: string, lower: number, upper: number): number; +declare function equals(a: any, b: any): boolean; +export { randomBytes, randomHexString, randomNumber, equals }; diff --git a/packages/tests/tests/utils.js b/packages/tests/lib/utils.js similarity index 100% rename from packages/tests/tests/utils.js rename to packages/tests/lib/utils.js diff --git a/packages/tests/package.json b/packages/tests/package.json index 348bd6d6f..926165890 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/tests", - "version": "5.0.0-beta.137", + "version": "5.0.0-beta.138", "description": "Testing package for ethers.", - "main": "index.js", + "main": "./lib/index.js", "browser": { "@ethersproject/ethers": "./tests/browser-ethers.js" }, @@ -36,5 +36,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xe51761b9ebb32aed2fd59b2564e33e905b4e100b8a384ca0d4b85600362c8f49" + "module": "./lib.esm/index.js", + "tarballHash": "0x6cb1911af4d7c3550c1225b39891e54a8c67276f2d1f9b38ed0b6168711c7dd0" } diff --git a/packages/tests/tests/reporter.js b/packages/tests/tests/reporter.js deleted file mode 100644 index da9969955..000000000 --- a/packages/tests/tests/reporter.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; -function getTime() { - return (new Date()).getTime(); -} -function trunc(value) { - if (value >= 0) { - return Math.floor(value); - } - return Math.ceil(value); -} -function getDelta(t0) { - var ds = trunc((getTime() - t0) / 1000); - var minutes = trunc(ds / 60); - var seconds = String(trunc(ds) % 60); - while (seconds.length < 2) { - seconds = '0' + seconds; - } - return '(' + minutes + ':' + seconds + ')'; -} -function Reporter(runner) { - var suites = []; - var lastOutput = getTime(); - function getIndent() { - var result = ''; - for (var i = 0; i < suites.length; i++) { - result += ' '; - } - return result; - } - function log(message) { - if (!message) { - message = ''; - } - var indent = getIndent(); - console.log(indent + message); - lastOutput = getTime(); - } - runner.on('suite', function (suite) { - if (!suite.title) { - log('Testing: Found ' + suite.suites.length + ' test suites'); - } - else { - var filename = (suite.file || '').split('/').pop(); - if (filename) { - filename = ' (' + filename + ')'; - } - log('Test Suite: ' + suite.title + filename); - } - suites.push(suite); - suite._t0 = getTime(); - suite._countFail = 0; - suite._countPass = 0; - suite._countTotal = 0; - }); - runner.on('suite end', function () { - var suite = suites.pop(); - var failure = ''; - if (suite._countTotal > suite._countPass) { - failure = ' (' + (suite._countTotal - suite._countPass) + ' failed)'; - } - log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure); - log(); - if (suites.length > 0) { - var currentSuite = suites[suites.length - 1]; - currentSuite._countFail += suite._countFail; - currentSuite._countPass += suite._countPass; - currentSuite._countTotal += suite._countTotal; - } - }); - runner.on('test', function (test) { - var currentSuite = suites[suites.length - 1]; - if (((getTime() - lastOutput) / 1000) > 60) { - log('[ Still running suite - test #' + currentSuite._countTotal + ' ]'); - lastOutput = getTime(); - } - currentSuite._countTotal++; - }); - runner.on('fail', function (test, error) { - var currentSuite = suites[suites.length - 1]; - currentSuite._countFail++; - var countFail = currentSuite._countFail; - if (countFail > 100) { - if (countFail === 101) { - log('[ Over 100 errors; skipping remaining suite output ]'); - } - return; - } - if (countFail > 25) { - log('Failure: ' + test.title + ' (too many errors; skipping dump)'); - return; - } - log('Failure: ' + test.title); - error.toString().split('\n').forEach(function (line) { - log(' ' + line); - }); - Object.keys(error).forEach(function (key) { - log(' ' + key + ': ' + error[key]); - }); - if (error.stack) { - log("Stack Trace:"); - error.stack.split('\n').forEach(function (line) { - log(' ' + line); - }); - } - }); - runner.on('pass', function (test) { - var currentSuite = suites[suites.length - 1]; - currentSuite._countPass++; - }); -} -module.exports = Reporter; diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index 1fb196964..c08252782 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -2,12 +2,13 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./tests" + "outDir": "./lib/" }, "include": [ - "./thirdparty.d.ts", - "./src.ts/*" + "./thirdparty.d.ts", + "./src.ts/*" ], - "exclude": [ ] + "exclude": [ + "./src.ts/reporter.ts" + ] } - diff --git a/packages/transactions/_version.d.ts b/packages/transactions/lib.esm/_version.d.ts similarity index 100% rename from packages/transactions/_version.d.ts rename to packages/transactions/lib.esm/_version.d.ts diff --git a/packages/transactions/lib.esm/_version.js b/packages/transactions/lib.esm/_version.js new file mode 100644 index 000000000..5438ac8ee --- /dev/null +++ b/packages/transactions/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "transactions/5.0.0-beta.127"; diff --git a/packages/transactions/index.d.ts b/packages/transactions/lib.esm/index.d.ts similarity index 100% rename from packages/transactions/index.d.ts rename to packages/transactions/lib.esm/index.d.ts diff --git a/packages/transactions/lib.esm/index.js b/packages/transactions/lib.esm/index.js new file mode 100644 index 000000000..54bacd4fb --- /dev/null +++ b/packages/transactions/lib.esm/index.js @@ -0,0 +1,145 @@ +"use strict"; +import { getAddress } from "@ethersproject/address"; +import { BigNumber } from "@ethersproject/bignumber"; +import { arrayify, hexDataSlice, hexlify, hexZeroPad, splitSignature, stripZeros, } from "@ethersproject/bytes"; +import { Zero } from "@ethersproject/constants"; +import { keccak256 } from "@ethersproject/keccak256"; +import { checkProperties } from "@ethersproject/properties"; +import * as RLP from "@ethersproject/rlp"; +import { computePublicKey, recoverPublicKey } from "@ethersproject/signing-key"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +/////////////////////////////// +function handleAddress(value) { + if (value === "0x") { + return null; + } + return getAddress(value); +} +function handleNumber(value) { + if (value === "0x") { + return Zero; + } + return BigNumber.from(value); +} +const transactionFields = [ + { name: "nonce", maxLength: 32 }, + { name: "gasPrice", maxLength: 32 }, + { name: "gasLimit", maxLength: 32 }, + { name: "to", length: 20 }, + { name: "value", maxLength: 32 }, + { name: "data" }, +]; +const allowedTransactionKeys = { + chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true +}; +export function computeAddress(key) { + let publicKey = computePublicKey(key); + return getAddress(hexDataSlice(keccak256(hexDataSlice(publicKey, 1)), 12)); +} +export function recoverAddress(digest, signature) { + return computeAddress(recoverPublicKey(arrayify(digest), signature)); +} +export function serialize(transaction, signature) { + checkProperties(transaction, allowedTransactionKeys); + let raw = []; + transactionFields.forEach(function (fieldInfo) { + let value = transaction[fieldInfo.name] || ([]); + value = arrayify(hexlify(value)); + // Fixed-width field + if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { + logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + } + // Variable-width (with a maximum) + if (fieldInfo.maxLength) { + value = stripZeros(value); + if (value.length > fieldInfo.maxLength) { + logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + } + } + raw.push(hexlify(value)); + }); + if (transaction.chainId != null && transaction.chainId !== 0) { + raw.push(hexlify(transaction.chainId)); + raw.push("0x"); + raw.push("0x"); + } + let unsignedTransaction = RLP.encode(raw); + // Requesting an unsigned transation + if (!signature) { + return unsignedTransaction; + } + // The splitSignature will ensure the transaction has a recoveryParam in the + // case that the signTransaction function only adds a v. + let sig = splitSignature(signature); + // We pushed a chainId and null r, s on for hashing only; remove those + let v = 27 + sig.recoveryParam; + if (raw.length === 9) { + raw.pop(); + raw.pop(); + raw.pop(); + v += transaction.chainId * 2 + 8; + } + raw.push(hexlify(v)); + raw.push(stripZeros(arrayify(sig.r))); + raw.push(stripZeros(arrayify(sig.s))); + return RLP.encode(raw); +} +export function parse(rawTransaction) { + let transaction = RLP.decode(rawTransaction); + if (transaction.length !== 9 && transaction.length !== 6) { + logger.throwArgumentError("invalid raw transaction", "rawTransactin", rawTransaction); + } + let tx = { + nonce: handleNumber(transaction[0]).toNumber(), + gasPrice: handleNumber(transaction[1]), + gasLimit: handleNumber(transaction[2]), + to: handleAddress(transaction[3]), + value: handleNumber(transaction[4]), + data: transaction[5], + chainId: 0 + }; + // Legacy unsigned transaction + if (transaction.length === 6) { + return tx; + } + try { + tx.v = BigNumber.from(transaction[6]).toNumber(); + } + catch (error) { + console.log(error); + return tx; + } + tx.r = hexZeroPad(transaction[7], 32); + tx.s = hexZeroPad(transaction[8], 32); + if (BigNumber.from(tx.r).isZero() && BigNumber.from(tx.s).isZero()) { + // EIP-155 unsigned transaction + tx.chainId = tx.v; + tx.v = 0; + } + else { + // Signed Tranasaction + tx.chainId = Math.floor((tx.v - 35) / 2); + if (tx.chainId < 0) { + tx.chainId = 0; + } + let recoveryParam = tx.v - 27; + let raw = transaction.slice(0, 6); + if (tx.chainId !== 0) { + raw.push(hexlify(tx.chainId)); + raw.push("0x"); + raw.push("0x"); + recoveryParam -= tx.chainId * 2 + 8; + } + let digest = keccak256(RLP.encode(raw)); + try { + tx.from = recoverAddress(digest, { r: hexlify(tx.r), s: hexlify(tx.s), recoveryParam: recoveryParam }); + } + catch (error) { + console.log(error); + } + tx.hash = keccak256(rawTransaction); + } + return tx; +} diff --git a/packages/transactions/lib/_version.d.ts b/packages/transactions/lib/_version.d.ts new file mode 100644 index 000000000..8f4cc385c --- /dev/null +++ b/packages/transactions/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "transactions/5.0.0-beta.127"; diff --git a/packages/transactions/_version.js b/packages/transactions/lib/_version.js similarity index 100% rename from packages/transactions/_version.js rename to packages/transactions/lib/_version.js diff --git a/packages/transactions/lib/index.d.ts b/packages/transactions/lib/index.d.ts new file mode 100644 index 000000000..c51a2e8b9 --- /dev/null +++ b/packages/transactions/lib/index.d.ts @@ -0,0 +1,29 @@ +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +import { BytesLike, SignatureLike } from "@ethersproject/bytes"; +export declare type UnsignedTransaction = { + to?: string; + nonce?: number; + gasLimit?: BigNumberish; + gasPrice?: BigNumberish; + data?: BytesLike; + value?: BigNumberish; + chainId?: number; +}; +export interface Transaction { + hash?: string; + to?: string; + from?: string; + nonce: number; + gasLimit: BigNumber; + gasPrice: BigNumber; + data: string; + value: BigNumber; + chainId: number; + r?: string; + s?: string; + v?: number; +} +export declare function computeAddress(key: BytesLike | string): string; +export declare function recoverAddress(digest: BytesLike, signature: SignatureLike): string; +export declare function serialize(transaction: UnsignedTransaction, signature?: SignatureLike): string; +export declare function parse(rawTransaction: BytesLike): Transaction; diff --git a/packages/transactions/index.js b/packages/transactions/lib/index.js similarity index 100% rename from packages/transactions/index.js rename to packages/transactions/lib/index.js diff --git a/packages/transactions/package.json b/packages/transactions/package.json index 1337cf88a..faba8c5d3 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/transactions", - "version": "5.0.0-beta.127", + "version": "5.0.0-beta.128", "description": "Utilities for decoding and encoding Ethereum transaction for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -30,5 +30,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x48a9f535708cc0252492a8b2a17d6d18fb3e5893e7826875def2ad584f59e1a0" + "module": "./lib.esm/index.js", + "tarballHash": "0x98659289537d6259256584ecd435405580a14f5219f8312be9d95ce30eea5b21" } diff --git a/packages/transactions/tsconfig.json b/packages/transactions/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/transactions/tsconfig.json +++ b/packages/transactions/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/units/_version.d.ts b/packages/units/lib.esm/_version.d.ts similarity index 100% rename from packages/units/_version.d.ts rename to packages/units/lib.esm/_version.d.ts diff --git a/packages/units/lib.esm/_version.js b/packages/units/lib.esm/_version.js new file mode 100644 index 000000000..3193a5322 --- /dev/null +++ b/packages/units/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "units/5.0.0-beta.126"; diff --git a/packages/units/index.d.ts b/packages/units/lib.esm/index.d.ts similarity index 100% rename from packages/units/index.d.ts rename to packages/units/lib.esm/index.d.ts diff --git a/packages/units/lib.esm/index.js b/packages/units/lib.esm/index.js new file mode 100644 index 000000000..32227e997 --- /dev/null +++ b/packages/units/lib.esm/index.js @@ -0,0 +1,77 @@ +"use strict"; +import { formatFixed, parseFixed } from "@ethersproject/bignumber/fixednumber"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +const names = [ + "wei", + "kwei", + "mwei", + "gwei", + "szabo", + "finney", + "ether", +]; +// Some environments have issues with RegEx that contain back-tracking, so we cannot +// use them. +export function commify(value) { + let comps = String(value).split("."); + if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { + logger.throwArgumentError("invalid value", "value", value); + } + // Make sure we have at least one whole digit (0 if none) + let whole = comps[0]; + let negative = ""; + if (whole.substring(0, 1) === "-") { + negative = "-"; + whole = whole.substring(1); + } + // Make sure we have at least 1 whole digit with no leading zeros + while (whole.substring(0, 1) === "0") { + whole = whole.substring(1); + } + if (whole === "") { + whole = "0"; + } + let suffix = ""; + if (comps.length === 2) { + suffix = "." + (comps[1] || "0"); + } + let formatted = []; + while (whole.length) { + if (whole.length <= 3) { + formatted.unshift(whole); + break; + } + else { + let index = whole.length - 3; + formatted.unshift(whole.substring(index)); + whole = whole.substring(0, index); + } + } + return negative + formatted.join(",") + suffix; +} +export function formatUnits(value, unitName) { + if (typeof (unitName) === "string") { + let index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return formatFixed(value, (unitName != null) ? unitName : 18); +} +export function parseUnits(value, unitName) { + if (typeof (unitName) === "string") { + let index = names.indexOf(unitName); + if (index !== -1) { + unitName = 3 * index; + } + } + return parseFixed(value, (unitName != null) ? unitName : 18); +} +export function formatEther(wei) { + return formatUnits(wei, 18); +} +export function parseEther(ether) { + return parseUnits(ether, 18); +} diff --git a/packages/units/lib/_version.d.ts b/packages/units/lib/_version.d.ts new file mode 100644 index 000000000..daa9ae7d7 --- /dev/null +++ b/packages/units/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "units/5.0.0-beta.126"; diff --git a/packages/units/_version.js b/packages/units/lib/_version.js similarity index 100% rename from packages/units/_version.js rename to packages/units/lib/_version.js diff --git a/packages/units/lib/index.d.ts b/packages/units/lib/index.d.ts new file mode 100644 index 000000000..cf02e582a --- /dev/null +++ b/packages/units/lib/index.d.ts @@ -0,0 +1,6 @@ +import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; +export declare function commify(value: string | number): string; +export declare function formatUnits(value: BigNumberish, unitName?: string | BigNumberish): string; +export declare function parseUnits(value: string, unitName?: BigNumberish): BigNumber; +export declare function formatEther(wei: BigNumberish): string; +export declare function parseEther(ether: string): BigNumber; diff --git a/packages/units/index.js b/packages/units/lib/index.js similarity index 90% rename from packages/units/index.js rename to packages/units/lib/index.js index 8d92cf096..8f08c6047 100644 --- a/packages/units/index.js +++ b/packages/units/lib/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var fixednumber_1 = require("@ethersproject/bignumber/fixednumber"); +var bignumber_1 = require("@ethersproject/bignumber"); var logger_1 = require("@ethersproject/logger"); var _version_1 = require("./_version"); var logger = new logger_1.Logger(_version_1.version); @@ -60,7 +60,7 @@ function formatUnits(value, unitName) { unitName = 3 * index; } } - return fixednumber_1.formatFixed(value, (unitName != null) ? unitName : 18); + return bignumber_1.formatFixed(value, (unitName != null) ? unitName : 18); } exports.formatUnits = formatUnits; function parseUnits(value, unitName) { @@ -70,7 +70,7 @@ function parseUnits(value, unitName) { unitName = 3 * index; } } - return fixednumber_1.parseFixed(value, (unitName != null) ? unitName : 18); + return bignumber_1.parseFixed(value, (unitName != null) ? unitName : 18); } exports.parseUnits = parseUnits; function formatEther(wei) { diff --git a/packages/units/package.json b/packages/units/package.json index 4987cd2db..394dde412 100644 --- a/packages/units/package.json +++ b/packages/units/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/units", - "version": "5.0.0-beta.126", + "version": "5.0.0-beta.127", "description": "Unit conversion functions for Ethereum.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0xf932dff9c5ab4a46776070c0e16cfcb579365a2db9d79b9330cc6a530a5eb18c" + "module": "./lib.esm/index.js", + "tarballHash": "0x5479e371548e25506a64d279c312e51f06828b3802cece3c5f3f621b67b61abd" } diff --git a/packages/units/src.ts/index.ts b/packages/units/src.ts/index.ts index 3d7a09ea8..5893b840b 100644 --- a/packages/units/src.ts/index.ts +++ b/packages/units/src.ts/index.ts @@ -1,7 +1,7 @@ "use strict"; import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; -import { formatFixed, parseFixed } from "@ethersproject/bignumber/fixednumber"; +import { formatFixed, parseFixed } from "@ethersproject/bignumber"; import { Logger } from "@ethersproject/logger"; import { version } from "./_version"; diff --git a/packages/units/tsconfig.json b/packages/units/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/units/tsconfig.json +++ b/packages/units/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/wallet/_version.d.ts b/packages/wallet/lib.esm/_version.d.ts similarity index 100% rename from packages/wallet/_version.d.ts rename to packages/wallet/lib.esm/_version.d.ts diff --git a/packages/wallet/lib.esm/_version.js b/packages/wallet/lib.esm/_version.js new file mode 100644 index 000000000..a5c4b009a --- /dev/null +++ b/packages/wallet/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "wallet/5.0.0-beta.129"; diff --git a/packages/wallet/index.d.ts b/packages/wallet/lib.esm/index.d.ts similarity index 100% rename from packages/wallet/index.d.ts rename to packages/wallet/lib.esm/index.d.ts diff --git a/packages/wallet/lib.esm/index.js b/packages/wallet/lib.esm/index.js new file mode 100644 index 000000000..a646f3106 --- /dev/null +++ b/packages/wallet/lib.esm/index.js @@ -0,0 +1,131 @@ +"use strict"; +import { getAddress } from "@ethersproject/address"; +import { Provider } from "@ethersproject/abstract-provider"; +import { Signer } from "@ethersproject/abstract-signer"; +import { arrayify, concat, hexDataSlice, isHexString, joinSignature } from "@ethersproject/bytes"; +import { hashMessage } from "@ethersproject/hash"; +import { defaultPath, HDNode, entropyToMnemonic } from "@ethersproject/hdnode"; +import { keccak256 } from "@ethersproject/keccak256"; +import { defineReadOnly, resolveProperties } from "@ethersproject/properties"; +import { randomBytes } from "@ethersproject/random"; +import { SigningKey } from "@ethersproject/signing-key"; +import { decryptJsonWallet, encryptKeystore } from "@ethersproject/json-wallets"; +import { computeAddress, recoverAddress, serialize } from "@ethersproject/transactions"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +function isAccount(value) { + return (value != null && isHexString(value.privateKey, 32) && value.address != null); +} +export class Wallet extends Signer { + constructor(privateKey, provider) { + logger.checkNew(new.target, Wallet); + super(); + if (isAccount(privateKey)) { + let signingKey = new SigningKey(privateKey.privateKey); + defineReadOnly(this, "_signingKey", () => signingKey); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + if (this.address !== getAddress(privateKey.address)) { + logger.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); + } + if (privateKey.mnemonic != null) { + let mnemonic = privateKey.mnemonic; + let path = privateKey.path || defaultPath; + defineReadOnly(this, "_mnemonic", () => mnemonic); + defineReadOnly(this, "path", privateKey.path); + let node = HDNode.fromMnemonic(mnemonic).derivePath(path); + if (computeAddress(node.privateKey) !== this.address) { + logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); + } + } + else { + defineReadOnly(this, "_mnemonic", () => null); + defineReadOnly(this, "path", null); + } + } + else { + if (SigningKey.isSigningKey(privateKey)) { + if (privateKey.curve !== "secp256k1") { + logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); + } + defineReadOnly(this, "_signingKey", () => privateKey); + } + else { + let signingKey = new SigningKey(privateKey); + defineReadOnly(this, "_signingKey", () => signingKey); + } + defineReadOnly(this, "_mnemonic", () => null); + defineReadOnly(this, "path", null); + defineReadOnly(this, "address", computeAddress(this.publicKey)); + } + if (provider && !Provider.isProvider(provider)) { + logger.throwArgumentError("invalid provider", "provider", provider); + } + defineReadOnly(this, "provider", provider || null); + } + get mnemonic() { return this._mnemonic(); } + get privateKey() { return this._signingKey().privateKey; } + get publicKey() { return this._signingKey().publicKey; } + getAddress() { + return Promise.resolve(this.address); + } + connect(provider) { + return new Wallet(this, provider); + } + signTransaction(transaction) { + return resolveProperties(transaction).then((tx) => { + if (tx.from != null) { + if (getAddress(tx.from) !== this.address) { + throw new Error("transaction from address mismatch"); + } + delete tx.from; + } + let signature = this._signingKey().signDigest(keccak256(serialize(tx))); + return serialize(tx, signature); + }); + } + signMessage(message) { + return Promise.resolve(joinSignature(this._signingKey().signDigest(hashMessage(message)))); + } + encrypt(password, options, progressCallback) { + if (typeof (options) === "function" && !progressCallback) { + progressCallback = options; + options = {}; + } + if (progressCallback && typeof (progressCallback) !== "function") { + throw new Error("invalid callback"); + } + if (!options) { + options = {}; + } + return encryptKeystore(this, password, options, progressCallback); + } + /** + * Static methods to create Wallet instances. + */ + static createRandom(options) { + let entropy = randomBytes(16); + if (!options) { + options = {}; + } + if (options.extraEntropy) { + entropy = arrayify(hexDataSlice(keccak256(concat([entropy, options.extraEntropy])), 0, 16)); + } + let mnemonic = entropyToMnemonic(entropy, options.locale); + return Wallet.fromMnemonic(mnemonic, options.path, options.locale); + } + static fromEncryptedJson(json, password, progressCallback) { + return decryptJsonWallet(json, password, progressCallback).then((account) => { + return new Wallet(account); + }); + } + static fromMnemonic(mnemonic, path, wordlist) { + if (!path) { + path = defaultPath; + } + return new Wallet(HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); + } +} +export function verifyMessage(message, signature) { + return recoverAddress(hashMessage(message), signature); +} diff --git a/packages/wallet/lib/_version.d.ts b/packages/wallet/lib/_version.d.ts new file mode 100644 index 000000000..bc71f7274 --- /dev/null +++ b/packages/wallet/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "wallet/5.0.0-beta.129"; diff --git a/packages/wallet/_version.js b/packages/wallet/lib/_version.js similarity index 100% rename from packages/wallet/_version.js rename to packages/wallet/lib/_version.js diff --git a/packages/wallet/lib/index.d.ts b/packages/wallet/lib/index.d.ts new file mode 100644 index 000000000..aa53291fd --- /dev/null +++ b/packages/wallet/lib/index.d.ts @@ -0,0 +1,29 @@ +import { Provider, TransactionRequest } from "@ethersproject/abstract-provider"; +import { ExternallyOwnedAccount, Signer } from "@ethersproject/abstract-signer"; +import { Bytes, BytesLike, SignatureLike } from "@ethersproject/bytes"; +import { SigningKey } from "@ethersproject/signing-key"; +import { ProgressCallback } from "@ethersproject/json-wallets"; +import { Wordlist } from "@ethersproject/wordlists"; +export declare class Wallet extends Signer implements ExternallyOwnedAccount { + readonly address: string; + readonly provider: Provider; + readonly path: string; + readonly _signingKey: () => SigningKey; + readonly _mnemonic: () => string; + constructor(privateKey: BytesLike | ExternallyOwnedAccount | SigningKey, provider?: Provider); + readonly mnemonic: string; + readonly privateKey: string; + readonly publicKey: string; + getAddress(): Promise; + connect(provider: Provider): Wallet; + signTransaction(transaction: TransactionRequest): Promise; + signMessage(message: Bytes | string): Promise; + encrypt(password: Bytes | string, options?: any, progressCallback?: ProgressCallback): Promise; + /** + * Static methods to create Wallet instances. + */ + static createRandom(options?: any): Wallet; + static fromEncryptedJson(json: string, password: Bytes | string, progressCallback?: ProgressCallback): Promise; + static fromMnemonic(mnemonic: string, path?: string, wordlist?: Wordlist): Wallet; +} +export declare function verifyMessage(message: Bytes | string, signature: SignatureLike): string; diff --git a/packages/wallet/index.js b/packages/wallet/lib/index.js similarity index 100% rename from packages/wallet/index.js rename to packages/wallet/lib/index.js diff --git a/packages/wallet/package.json b/packages/wallet/package.json index a02514bda..8eac5f424 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/wallet", - "version": "5.0.0-beta.129", + "version": "5.0.0-beta.130", "description": "Classes for managing, encrypting and decrypting Ethereum private keys as a Signer for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -36,5 +36,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x52e75ab9005c6955a41f09e411b01e1e7f7bdd5a6f17248f0e1e8ae9b65ec2d2" + "module": "./lib.esm/index.js", + "tarballHash": "0x460a045fc0b735ecdb14c5dd2c93c0dc45658ff46071f41dbf4a7cc6d3af1450" } diff --git a/packages/wallet/src.ts/index.ts b/packages/wallet/src.ts/index.ts index 81c7d0aed..bc12e2344 100644 --- a/packages/wallet/src.ts/index.ts +++ b/packages/wallet/src.ts/index.ts @@ -12,7 +12,7 @@ import { randomBytes } from "@ethersproject/random"; import { SigningKey } from "@ethersproject/signing-key"; import { decryptJsonWallet, encryptKeystore, ProgressCallback } from "@ethersproject/json-wallets"; import { computeAddress, recoverAddress, serialize } from "@ethersproject/transactions"; -import { Wordlist } from "@ethersproject/wordlists/wordlist"; +import { Wordlist } from "@ethersproject/wordlists"; import { Logger } from "@ethersproject/logger"; import { version } from "./_version"; diff --git a/packages/wallet/tsconfig.json b/packages/wallet/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/wallet/tsconfig.json +++ b/packages/wallet/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/web/.gitignore b/packages/web/.gitignore deleted file mode 100644 index 6d5a3baaf..000000000 --- a/packages/web/.gitignore +++ /dev/null @@ -1 +0,0 @@ -browser-xmlhttprequest.d.ts diff --git a/packages/web/browser-xmlhttprequest.js b/packages/web/browser-xmlhttprequest.js deleted file mode 100644 index 2a6389ea6..000000000 --- a/packages/web/browser-xmlhttprequest.js +++ /dev/null @@ -1,8 +0,0 @@ -"use strict"; -try { - module.exports.XMLHttpRequest = XMLHttpRequest; -} -catch (error) { - console.log("Warning: XMLHttpRequest is not defined"); - module.exports.XMLHttpRequest = null; -} diff --git a/packages/web/_version.d.ts b/packages/web/lib.esm/_version.d.ts similarity index 100% rename from packages/web/_version.d.ts rename to packages/web/lib.esm/_version.d.ts diff --git a/packages/web/lib.esm/_version.js b/packages/web/lib.esm/_version.js new file mode 100644 index 000000000..7f411f313 --- /dev/null +++ b/packages/web/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "web/5.0.0-beta.128"; diff --git a/packages/web/index.d.ts b/packages/web/lib.esm/index.d.ts similarity index 100% rename from packages/web/index.d.ts rename to packages/web/lib.esm/index.d.ts diff --git a/packages/web/lib.esm/index.js b/packages/web/lib.esm/index.js new file mode 100644 index 000000000..4cd1863dc --- /dev/null +++ b/packages/web/lib.esm/index.js @@ -0,0 +1,200 @@ +"use strict"; +import fetch from "cross-fetch"; +import { encode as base64Encode } from "@ethersproject/base64"; +import { shallowCopy } from "@ethersproject/properties"; +import { toUtf8Bytes } from "@ethersproject/strings"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export function fetchJson(connection, json, processFunc) { + let headers = {}; + let url = null; + // @TODO: Allow ConnectionInfo to override some of these values + let options = { + method: "GET", + mode: "cors", + cache: "no-cache", + credentials: "same-origin", + redirect: "follow", + referrer: "client", + }; + let timeout = 2 * 60 * 1000; + if (typeof (connection) === "string") { + url = connection; + } + else if (typeof (connection) === "object") { + if (connection == null || connection.url == null) { + logger.throwArgumentError("missing URL", "connection.url", connection); + } + url = connection.url; + if (typeof (connection.timeout) === "number" && connection.timeout > 0) { + timeout = connection.timeout; + } + if (connection.headers) { + for (let key in connection.headers) { + headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) }; + } + } + if (connection.user != null && connection.password != null) { + if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) { + logger.throwError("basic authentication requires a secure https url", Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" }); + } + let authorization = connection.user + ":" + connection.password; + headers["authorization"] = { + key: "Authorization", + value: "Basic " + base64Encode(toUtf8Bytes(authorization)) + }; + } + } + return new Promise(function (resolve, reject) { + let timer = null; + if (timeout) { + timer = setTimeout(() => { + if (timer == null) { + return; + } + timer = null; + reject(logger.makeError("timeout", Logger.errors.TIMEOUT, { timeout: timeout })); + }, timeout); + } + let cancelTimeout = () => { + if (timer == null) { + return; + } + clearTimeout(timer); + timer = null; + }; + if (json) { + options.method = "POST"; + options.body = json; + headers["content-type"] = { key: "Content-Type", value: "application/json" }; + } + let flatHeaders = {}; + Object.keys(headers).forEach((key) => { + let header = headers[key]; + flatHeaders[header.key] = header.value; + }); + options.headers = flatHeaders; + return fetch(url, options).then((response) => { + return response.text().then((body) => { + if (!response.ok) { + logger.throwError("bad response", Logger.errors.SERVER_ERROR, { + status: response.status, + body: body, + type: response.type, + url: response.url + }); + } + return body; + }); + }).then((text) => { + let json = null; + try { + json = JSON.parse(text); + } + catch (error) { + logger.throwError("invalid JSON", Logger.errors.SERVER_ERROR, { + body: text, + error: error, + url: url + }); + } + if (processFunc) { + try { + json = processFunc(json); + } + catch (error) { + logger.throwError("processing response error", Logger.errors.SERVER_ERROR, { + body: json, + error: error + }); + } + } + return json; + }, (error) => { + throw error; + }).then((result) => { + cancelTimeout(); + resolve(result); + }, (error) => { + cancelTimeout(); + reject(error); + }); + }); +} +export function poll(func, options) { + if (!options) { + options = {}; + } + options = shallowCopy(options); + if (options.floor == null) { + options.floor = 0; + } + if (options.ceiling == null) { + options.ceiling = 10000; + } + if (options.interval == null) { + options.interval = 250; + } + return new Promise(function (resolve, reject) { + let timer = null; + let done = false; + // Returns true if cancel was successful. Unsuccessful cancel means we're already done. + let cancel = () => { + if (done) { + return false; + } + done = true; + if (timer) { + clearTimeout(timer); + } + return true; + }; + if (options.timeout) { + timer = setTimeout(() => { + if (cancel()) { + reject(new Error("timeout")); + } + }, options.timeout); + } + let retryLimit = options.retryLimit; + let attempt = 0; + function check() { + return func().then(function (result) { + // If we have a result, or are allowed null then we're done + if (result !== undefined) { + if (cancel()) { + resolve(result); + } + } + else if (options.onceBlock) { + options.onceBlock.once("block", check); + // Otherwise, exponential back-off (up to 10s) our next request + } + else if (!done) { + attempt++; + if (attempt > retryLimit) { + if (cancel()) { + reject(new Error("retry limit reached")); + } + return; + } + let timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); + if (timeout < options.floor) { + timeout = options.floor; + } + if (timeout > options.ceiling) { + timeout = options.ceiling; + } + setTimeout(check, timeout); + } + return null; + }, function (error) { + if (cancel()) { + reject(error); + } + }); + } + check(); + }); +} diff --git a/packages/web/lib/_version.d.ts b/packages/web/lib/_version.d.ts new file mode 100644 index 000000000..bff6fa713 --- /dev/null +++ b/packages/web/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "web/5.0.0-beta.128"; diff --git a/packages/web/_version.js b/packages/web/lib/_version.js similarity index 100% rename from packages/web/_version.js rename to packages/web/lib/_version.js diff --git a/packages/web/lib/index.d.ts b/packages/web/lib/index.d.ts new file mode 100644 index 000000000..be2b5ca47 --- /dev/null +++ b/packages/web/lib/index.d.ts @@ -0,0 +1,23 @@ +export declare type ConnectionInfo = { + url: string; + user?: string; + password?: string; + allowInsecureAuthentication?: boolean; + timeout?: number; + headers?: { + [key: string]: string | number; + }; +}; +export interface OnceBlockable { + once(eventName: "block", handler: () => void): void; +} +export declare type PollOptions = { + timeout?: number; + floor?: number; + ceiling?: number; + interval?: number; + retryLimit?: number; + onceBlock?: OnceBlockable; +}; +export declare function fetchJson(connection: string | ConnectionInfo, json?: string, processFunc?: (value: any) => any): Promise; +export declare function poll(func: () => Promise, options?: PollOptions): Promise; diff --git a/packages/web/index.js b/packages/web/lib/index.js similarity index 100% rename from packages/web/index.js rename to packages/web/lib/index.js diff --git a/packages/web/package.json b/packages/web/package.json index ec8092383..ab0535109 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/web", - "version": "5.0.0-beta.128", + "version": "5.0.0-beta.129", "description": "Utility fucntions for managing web requests for ethers.", - "main": "index.js", + "main": "./lib/index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x351b5fccecc688586a060a590bf09d204c84b587da0a9fc647916f82a158a488" + "module": "./lib.esm/index.js", + "tarballHash": "0x79ab00f43c26bd2e93155b849eabaaac737c689bcee3dd73f401b4b2f953f82e" } diff --git a/packages/web/tsconfig.json b/packages/web/tsconfig.json index 026fe496a..0a9d2f16c 100644 --- a/packages/web/tsconfig.json +++ b/packages/web/tsconfig.json @@ -2,12 +2,11 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./thirdparty.d.ts", - "./src.ts/*" + "./thirdparty.d.ts", + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/packages/wordlists/_version.d.ts b/packages/wordlists/lib.esm/_version.d.ts similarity index 100% rename from packages/wordlists/_version.d.ts rename to packages/wordlists/lib.esm/_version.d.ts diff --git a/packages/wordlists/lib.esm/_version.js b/packages/wordlists/lib.esm/_version.js new file mode 100644 index 000000000..f806e86a4 --- /dev/null +++ b/packages/wordlists/lib.esm/_version.js @@ -0,0 +1 @@ +export const version = "wordlists/5.0.0-beta.127"; diff --git a/packages/wordlists/browser.d.ts b/packages/wordlists/lib.esm/browser.d.ts similarity index 100% rename from packages/wordlists/browser.d.ts rename to packages/wordlists/lib.esm/browser.d.ts diff --git a/packages/wordlists/lib.esm/browser.js b/packages/wordlists/lib.esm/browser.js new file mode 100644 index 000000000..1e1f498d0 --- /dev/null +++ b/packages/wordlists/lib.esm/browser.js @@ -0,0 +1,7 @@ +"use strict"; +// Wordlists +// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md +import { Wordlist } from "./wordlist"; +import { langEn as en } from "./lang-en"; +const wordlists = { en: en }; +export { Wordlist, wordlists }; diff --git a/packages/wordlists/index.d.ts b/packages/wordlists/lib.esm/index.d.ts similarity index 100% rename from packages/wordlists/index.d.ts rename to packages/wordlists/lib.esm/index.d.ts diff --git a/packages/wordlists/lib.esm/index.js b/packages/wordlists/lib.esm/index.js new file mode 100644 index 000000000..2f56e58ea --- /dev/null +++ b/packages/wordlists/lib.esm/index.js @@ -0,0 +1,23 @@ +"use strict"; +// Wordlists +// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md +import { Wordlist } from "./wordlist"; +import { langEn as en } from "./lang-en"; +import { langEs as es } from "./lang-es"; +import { langFr as fr } from "./lang-fr"; +import { langJa as ja } from "./lang-ja"; +import { langKo as ko } from "./lang-ko"; +import { langIt as it } from "./lang-it"; +import { langZhCn as zh_cn, langZhTw as zh_tw } from "./lang-zh"; +const wordlists = { + en: en, + es: es, + fr: fr, + it: it, + ja: ja, + ko: ko, + zh: zh_cn, + zh_cn: zh_cn, + zh_tw: zh_tw +}; +export { Wordlist, wordlists }; diff --git a/packages/wordlists/lang-en.d.ts b/packages/wordlists/lib.esm/lang-en.d.ts similarity index 100% rename from packages/wordlists/lang-en.d.ts rename to packages/wordlists/lib.esm/lang-en.d.ts diff --git a/packages/wordlists/lib.esm/lang-en.js b/packages/wordlists/lib.esm/lang-en.js new file mode 100644 index 000000000..f6fa7514c --- /dev/null +++ b/packages/wordlists/lib.esm/lang-en.js @@ -0,0 +1,30 @@ +"use strict"; +import { check, register, Wordlist } from "./wordlist"; +const words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo"; +let wordlist = null; +function loadWords(lang) { + if (wordlist != null) { + return; + } + wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); + if (check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") { + wordlist = null; + throw new Error("BIP39 Wordlist for en (English) FAILED"); + } +} +class LangEn extends Wordlist { + constructor() { + super("en"); + } + getWord(index) { + loadWords(this); + return wordlist[index]; + } + getWordIndex(word) { + loadWords(this); + return wordlist.indexOf(word); + } +} +const langEn = new LangEn(); +register(langEn); +export { langEn }; diff --git a/packages/wordlists/lang-es.d.ts b/packages/wordlists/lib.esm/lang-es.d.ts similarity index 100% rename from packages/wordlists/lang-es.d.ts rename to packages/wordlists/lib.esm/lang-es.d.ts diff --git a/packages/wordlists/lib.esm/lang-es.js b/packages/wordlists/lib.esm/lang-es.js new file mode 100644 index 000000000..d6368b6cd --- /dev/null +++ b/packages/wordlists/lib.esm/lang-es.js @@ -0,0 +1,68 @@ +"use strict"; +import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { check, register, Wordlist } from "./wordlist"; +const words = "A/bacoAbdomenAbejaAbiertoAbogadoAbonoAbortoAbrazoAbrirAbueloAbusoAcabarAcademiaAccesoAccio/nAceiteAcelgaAcentoAceptarA/cidoAclararAcne/AcogerAcosoActivoActoActrizActuarAcudirAcuerdoAcusarAdictoAdmitirAdoptarAdornoAduanaAdultoAe/reoAfectarAficio/nAfinarAfirmarA/gilAgitarAgoni/aAgostoAgotarAgregarAgrioAguaAgudoA/guilaAgujaAhogoAhorroAireAislarAjedrezAjenoAjusteAlacra/nAlambreAlarmaAlbaA/lbumAlcaldeAldeaAlegreAlejarAlertaAletaAlfilerAlgaAlgodo/nAliadoAlientoAlivioAlmaAlmejaAlmi/barAltarAltezaAltivoAltoAlturaAlumnoAlzarAmableAmanteAmapolaAmargoAmasarA/mbarA/mbitoAmenoAmigoAmistadAmorAmparoAmplioAnchoAncianoAnclaAndarAnde/nAnemiaA/nguloAnilloA/nimoAni/sAnotarAntenaAntiguoAntojoAnualAnularAnuncioA~adirA~ejoA~oApagarAparatoApetitoApioAplicarApodoAporteApoyoAprenderAprobarApuestaApuroAradoAra~aArarA/rbitroA/rbolArbustoArchivoArcoArderArdillaArduoA/reaA/ridoAriesArmoni/aArne/sAromaArpaArpo/nArregloArrozArrugaArteArtistaAsaAsadoAsaltoAscensoAsegurarAseoAsesorAsientoAsiloAsistirAsnoAsombroA/speroAstillaAstroAstutoAsumirAsuntoAtajoAtaqueAtarAtentoAteoA/ticoAtletaA/tomoAtraerAtrozAtu/nAudazAudioAugeAulaAumentoAusenteAutorAvalAvanceAvaroAveAvellanaAvenaAvestruzAvio/nAvisoAyerAyudaAyunoAzafra/nAzarAzoteAzu/carAzufreAzulBabaBaborBacheBahi/aBaileBajarBalanzaBalco/nBaldeBambu/BancoBandaBa~oBarbaBarcoBarnizBarroBa/sculaBasto/nBasuraBatallaBateri/aBatirBatutaBau/lBazarBebe/BebidaBelloBesarBesoBestiaBichoBienBingoBlancoBloqueBlusaBoaBobinaBoboBocaBocinaBodaBodegaBoinaBolaBoleroBolsaBombaBondadBonitoBonoBonsa/iBordeBorrarBosqueBoteBoti/nBo/vedaBozalBravoBrazoBrechaBreveBrilloBrincoBrisaBrocaBromaBronceBroteBrujaBruscoBrutoBuceoBucleBuenoBueyBufandaBufo/nBu/hoBuitreBultoBurbujaBurlaBurroBuscarButacaBuzo/nCaballoCabezaCabinaCabraCacaoCada/verCadenaCaerCafe/Cai/daCaima/nCajaCajo/nCalCalamarCalcioCaldoCalidadCalleCalmaCalorCalvoCamaCambioCamelloCaminoCampoCa/ncerCandilCanelaCanguroCanicaCantoCa~aCa~o/nCaobaCaosCapazCapita/nCapoteCaptarCapuchaCaraCarbo/nCa/rcelCaretaCargaCari~oCarneCarpetaCarroCartaCasaCascoCaseroCaspaCastorCatorceCatreCaudalCausaCazoCebollaCederCedroCeldaCe/lebreCelosoCe/lulaCementoCenizaCentroCercaCerdoCerezaCeroCerrarCertezaCe/spedCetroChacalChalecoChampu/ChanclaChapaCharlaChicoChisteChivoChoqueChozaChuletaChuparCiclo/nCiegoCieloCienCiertoCifraCigarroCimaCincoCineCintaCipre/sCircoCiruelaCisneCitaCiudadClamorClanClaroClaseClaveClienteClimaCli/nicaCobreCoccio/nCochinoCocinaCocoCo/digoCodoCofreCogerCoheteCoji/nCojoColaColchaColegioColgarColinaCollarColmoColumnaCombateComerComidaCo/modoCompraCondeConejoCongaConocerConsejoContarCopaCopiaCorazo/nCorbataCorchoCordo/nCoronaCorrerCoserCosmosCostaCra/neoCra/terCrearCrecerCrei/doCremaCri/aCrimenCriptaCrisisCromoCro/nicaCroquetaCrudoCruzCuadroCuartoCuatroCuboCubrirCucharaCuelloCuentoCuerdaCuestaCuevaCuidarCulebraCulpaCultoCumbreCumplirCunaCunetaCuotaCupo/nCu/pulaCurarCuriosoCursoCurvaCutisDamaDanzaDarDardoDa/tilDeberDe/bilDe/cadaDecirDedoDefensaDefinirDejarDelfi/nDelgadoDelitoDemoraDensoDentalDeporteDerechoDerrotaDesayunoDeseoDesfileDesnudoDestinoDesvi/oDetalleDetenerDeudaDi/aDiabloDiademaDiamanteDianaDiarioDibujoDictarDienteDietaDiezDifi/cilDignoDilemaDiluirDineroDirectoDirigirDiscoDise~oDisfrazDivaDivinoDobleDoceDolorDomingoDonDonarDoradoDormirDorsoDosDosisDrago/nDrogaDuchaDudaDueloDue~oDulceDu/oDuqueDurarDurezaDuroE/banoEbrioEcharEcoEcuadorEdadEdicio/nEdificioEditorEducarEfectoEficazEjeEjemploElefanteElegirElementoElevarElipseE/liteElixirElogioEludirEmbudoEmitirEmocio/nEmpateEmpe~oEmpleoEmpresaEnanoEncargoEnchufeEnci/aEnemigoEneroEnfadoEnfermoEnga~oEnigmaEnlaceEnormeEnredoEnsayoEnse~arEnteroEntrarEnvaseEnvi/oE/pocaEquipoErizoEscalaEscenaEscolarEscribirEscudoEsenciaEsferaEsfuerzoEspadaEspejoEspi/aEsposaEspumaEsqui/EstarEsteEstiloEstufaEtapaEternoE/ticaEtniaEvadirEvaluarEventoEvitarExactoExamenExcesoExcusaExentoExigirExilioExistirE/xitoExpertoExplicarExponerExtremoFa/bricaFa/bulaFachadaFa/cilFactorFaenaFajaFaldaFalloFalsoFaltarFamaFamiliaFamosoFarao/nFarmaciaFarolFarsaFaseFatigaFaunaFavorFaxFebreroFechaFelizFeoFeriaFerozFe/rtilFervorFesti/nFiableFianzaFiarFibraFiccio/nFichaFideoFiebreFielFieraFiestaFiguraFijarFijoFilaFileteFilialFiltroFinFincaFingirFinitoFirmaFlacoFlautaFlechaFlorFlotaFluirFlujoFlu/orFobiaFocaFogataFogo/nFolioFolletoFondoFormaForroFortunaForzarFosaFotoFracasoFra/gilFranjaFraseFraudeFrei/rFrenoFresaFri/oFritoFrutaFuegoFuenteFuerzaFugaFumarFuncio/nFundaFurgo/nFuriaFusilFu/tbolFuturoGacelaGafasGaitaGajoGalaGaleri/aGalloGambaGanarGanchoGangaGansoGarajeGarzaGasolinaGastarGatoGavila/nGemeloGemirGenGe/neroGenioGenteGeranioGerenteGermenGestoGiganteGimnasioGirarGiroGlaciarGloboGloriaGolGolfoGolosoGolpeGomaGordoGorilaGorraGotaGoteoGozarGradaGra/ficoGranoGrasaGratisGraveGrietaGrilloGripeGrisGritoGrosorGru/aGruesoGrumoGrupoGuanteGuapoGuardiaGuerraGui/aGui~oGuionGuisoGuitarraGusanoGustarHaberHa/bilHablarHacerHachaHadaHallarHamacaHarinaHazHaza~aHebillaHebraHechoHeladoHelioHembraHerirHermanoHe/roeHervirHieloHierroHi/gadoHigieneHijoHimnoHistoriaHocicoHogarHogueraHojaHombreHongoHonorHonraHoraHormigaHornoHostilHoyoHuecoHuelgaHuertaHuesoHuevoHuidaHuirHumanoHu/medoHumildeHumoHundirHuraca/nHurtoIconoIdealIdiomaI/doloIglesiaIglu/IgualIlegalIlusio/nImagenIma/nImitarImparImperioImponerImpulsoIncapazI/ndiceInerteInfielInformeIngenioInicioInmensoInmuneInnatoInsectoInstanteIntere/sI/ntimoIntuirInu/tilInviernoIraIrisIroni/aIslaIsloteJabali/Jabo/nJamo/nJarabeJardi/nJarraJaulaJazmi/nJefeJeringaJineteJornadaJorobaJovenJoyaJuergaJuevesJuezJugadorJugoJugueteJuicioJuncoJunglaJunioJuntarJu/piterJurarJustoJuvenilJuzgarKiloKoalaLabioLacioLacraLadoLadro/nLagartoLa/grimaLagunaLaicoLamerLa/minaLa/mparaLanaLanchaLangostaLanzaLa/pizLargoLarvaLa/stimaLataLa/texLatirLaurelLavarLazoLealLeccio/nLecheLectorLeerLegio/nLegumbreLejanoLenguaLentoLe~aLeo/nLeopardoLesio/nLetalLetraLeveLeyendaLibertadLibroLicorLi/derLidiarLienzoLigaLigeroLimaLi/miteLimo/nLimpioLinceLindoLi/neaLingoteLinoLinternaLi/quidoLisoListaLiteraLitioLitroLlagaLlamaLlantoLlaveLlegarLlenarLlevarLlorarLloverLluviaLoboLocio/nLocoLocuraLo/gicaLogroLombrizLomoLonjaLoteLuchaLucirLugarLujoLunaLunesLupaLustroLutoLuzMacetaMachoMaderaMadreMaduroMaestroMafiaMagiaMagoMai/zMaldadMaletaMallaMaloMama/MamboMamutMancoMandoManejarMangaManiqui/ManjarManoMansoMantaMa~anaMapaMa/quinaMarMarcoMareaMarfilMargenMaridoMa/rmolMarro/nMartesMarzoMasaMa/scaraMasivoMatarMateriaMatizMatrizMa/ximoMayorMazorcaMechaMedallaMedioMe/dulaMejillaMejorMelenaMelo/nMemoriaMenorMensajeMenteMenu/MercadoMerengueMe/ritoMesMeso/nMetaMeterMe/todoMetroMezclaMiedoMielMiembroMigaMilMilagroMilitarMillo/nMimoMinaMineroMi/nimoMinutoMiopeMirarMisaMiseriaMisilMismoMitadMitoMochilaMocio/nModaModeloMohoMojarMoldeMolerMolinoMomentoMomiaMonarcaMonedaMonjaMontoMo~oMoradaMorderMorenoMorirMorroMorsaMortalMoscaMostrarMotivoMoverMo/vilMozoMuchoMudarMuebleMuelaMuerteMuestraMugreMujerMulaMuletaMultaMundoMu~ecaMuralMuroMu/sculoMuseoMusgoMu/sicaMusloNa/carNacio/nNadarNaipeNaranjaNarizNarrarNasalNatalNativoNaturalNa/useaNavalNaveNavidadNecioNe/ctarNegarNegocioNegroNeo/nNervioNetoNeutroNevarNeveraNichoNidoNieblaNietoNi~ezNi~oNi/tidoNivelNoblezaNocheNo/minaNoriaNormaNorteNotaNoticiaNovatoNovelaNovioNubeNucaNu/cleoNudilloNudoNueraNueveNuezNuloNu/meroNutriaOasisObesoObispoObjetoObraObreroObservarObtenerObvioOcaOcasoOce/anoOchentaOchoOcioOcreOctavoOctubreOcultoOcuparOcurrirOdiarOdioOdiseaOesteOfensaOfertaOficioOfrecerOgroOi/doOi/rOjoOlaOleadaOlfatoOlivoOllaOlmoOlorOlvidoOmbligoOndaOnzaOpacoOpcio/nO/peraOpinarOponerOptarO/pticaOpuestoOracio/nOradorOralO/rbitaOrcaOrdenOrejaO/rganoOrgi/aOrgulloOrienteOrigenOrillaOroOrquestaOrugaOsadi/aOscuroOseznoOsoOstraOto~oOtroOvejaO/vuloO/xidoOxi/genoOyenteOzonoPactoPadrePaellaPa/ginaPagoPai/sPa/jaroPalabraPalcoPaletaPa/lidoPalmaPalomaPalparPanPanalPa/nicoPanteraPa~ueloPapa/PapelPapillaPaquetePararParcelaParedParirParoPa/rpadoParquePa/rrafoPartePasarPaseoPasio/nPasoPastaPataPatioPatriaPausaPautaPavoPayasoPeato/nPecadoPeceraPechoPedalPedirPegarPeinePelarPelda~oPeleaPeligroPellejoPeloPelucaPenaPensarPe~o/nPeo/nPeorPepinoPeque~oPeraPerchaPerderPerezaPerfilPericoPerlaPermisoPerroPersonaPesaPescaPe/simoPesta~aPe/taloPetro/leoPezPezu~aPicarPicho/nPiePiedraPiernaPiezaPijamaPilarPilotoPimientaPinoPintorPinzaPi~aPiojoPipaPirataPisarPiscinaPisoPistaPito/nPizcaPlacaPlanPlataPlayaPlazaPleitoPlenoPlomoPlumaPluralPobrePocoPoderPodioPoemaPoesi/aPoetaPolenPolici/aPolloPolvoPomadaPomeloPomoPompaPonerPorcio/nPortalPosadaPoseerPosiblePostePotenciaPotroPozoPradoPrecozPreguntaPremioPrensaPresoPrevioPrimoPri/ncipePrisio/nPrivarProaProbarProcesoProductoProezaProfesorProgramaProlePromesaProntoPropioPro/ximoPruebaPu/blicoPucheroPudorPuebloPuertaPuestoPulgaPulirPulmo/nPulpoPulsoPumaPuntoPu~alPu~oPupaPupilaPure/QuedarQuejaQuemarQuererQuesoQuietoQui/micaQuinceQuitarRa/banoRabiaRaboRacio/nRadicalRai/zRamaRampaRanchoRangoRapazRa/pidoRaptoRasgoRaspaRatoRayoRazaRazo/nReaccio/nRealidadReba~oReboteRecaerRecetaRechazoRecogerRecreoRectoRecursoRedRedondoReducirReflejoReformaRefra/nRefugioRegaloRegirReglaRegresoRehe/nReinoRei/rRejaRelatoRelevoRelieveRellenoRelojRemarRemedioRemoRencorRendirRentaRepartoRepetirReposoReptilResRescateResinaRespetoRestoResumenRetiroRetornoRetratoReunirReve/sRevistaReyRezarRicoRiegoRiendaRiesgoRifaRi/gidoRigorRinco/nRi~o/nRi/oRiquezaRisaRitmoRitoRizoRobleRoceRociarRodarRodeoRodillaRoerRojizoRojoRomeroRomperRonRoncoRondaRopaRoperoRosaRoscaRostroRotarRubi/RuborRudoRuedaRugirRuidoRuinaRuletaRuloRumboRumorRupturaRutaRutinaSa/badoSaberSabioSableSacarSagazSagradoSalaSaldoSaleroSalirSalmo/nSalo/nSalsaSaltoSaludSalvarSambaSancio/nSandi/aSanearSangreSanidadSanoSantoSapoSaqueSardinaSarte/nSastreSata/nSaunaSaxofo/nSeccio/nSecoSecretoSectaSedSeguirSeisSelloSelvaSemanaSemillaSendaSensorSe~alSe~orSepararSepiaSequi/aSerSerieSermo/nServirSesentaSesio/nSetaSetentaSeveroSexoSextoSidraSiestaSieteSigloSignoSi/labaSilbarSilencioSillaSi/mboloSimioSirenaSistemaSitioSituarSobreSocioSodioSolSolapaSoldadoSoledadSo/lidoSoltarSolucio/nSombraSondeoSonidoSonoroSonrisaSopaSoplarSoporteSordoSorpresaSorteoSoste/nSo/tanoSuaveSubirSucesoSudorSuegraSueloSue~oSuerteSufrirSujetoSulta/nSumarSuperarSuplirSuponerSupremoSurSurcoSure~oSurgirSustoSutilTabacoTabiqueTablaTabu/TacoTactoTajoTalarTalcoTalentoTallaTalo/nTama~oTamborTangoTanqueTapaTapeteTapiaTapo/nTaquillaTardeTareaTarifaTarjetaTarotTarroTartaTatuajeTauroTazaTazo/nTeatroTechoTeclaTe/cnicaTejadoTejerTejidoTelaTele/fonoTemaTemorTemploTenazTenderTenerTenisTensoTeori/aTerapiaTercoTe/rminoTernuraTerrorTesisTesoroTestigoTeteraTextoTezTibioTiburo/nTiempoTiendaTierraTiesoTigreTijeraTildeTimbreTi/midoTimoTintaTi/oTi/picoTipoTiraTiro/nTita/nTi/tereTi/tuloTizaToallaTobilloTocarTocinoTodoTogaToldoTomarTonoTontoToparTopeToqueTo/raxToreroTormentaTorneoToroTorpedoTorreTorsoTortugaTosToscoToserTo/xicoTrabajoTractorTraerTra/ficoTragoTrajeTramoTranceTratoTraumaTrazarTre/bolTreguaTreintaTrenTreparTresTribuTrigoTripaTristeTriunfoTrofeoTrompaTroncoTropaTroteTrozoTrucoTruenoTrufaTuberi/aTuboTuertoTumbaTumorTu/nelTu/nicaTurbinaTurismoTurnoTutorUbicarU/lceraUmbralUnidadUnirUniversoUnoUntarU~aUrbanoUrbeUrgenteUrnaUsarUsuarioU/tilUtopi/aUvaVacaVaci/oVacunaVagarVagoVainaVajillaValeVa/lidoValleValorVa/lvulaVampiroVaraVariarVaro/nVasoVecinoVectorVehi/culoVeinteVejezVelaVeleroVelozVenaVencerVendaVenenoVengarVenirVentaVenusVerVeranoVerboVerdeVeredaVerjaVersoVerterVi/aViajeVibrarVicioVi/ctimaVidaVi/deoVidrioViejoViernesVigorVilVillaVinagreVinoVi~edoVioli/nViralVirgoVirtudVisorVi/speraVistaVitaminaViudoVivazViveroVivirVivoVolca/nVolumenVolverVorazVotarVotoVozVueloVulgarYacerYateYeguaYemaYernoYesoYodoYogaYogurZafiroZanjaZapatoZarzaZonaZorroZumoZurdo"; +let lookup = {}; +let wordlist = null; +function dropDiacritic(word) { + logger.checkNormalize(); + return toUtf8String(Array.prototype.filter.call(toUtf8Bytes(word.normalize("NFD").toLowerCase()), (c) => { + return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123)); + })); +} +function expand(word) { + let output = []; + Array.prototype.forEach.call(toUtf8Bytes(word), (c) => { + // Acute accent + if (c === 47) { + output.push(204); + output.push(129); + // n-tilde + } + else if (c === 126) { + output.push(110); + output.push(204); + output.push(131); + } + else { + output.push(c); + } + }); + return toUtf8String(output); +} +function loadWords(lang) { + if (wordlist != null) { + return; + } + wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map((w) => expand(w)); + wordlist.forEach((word, index) => { + lookup[dropDiacritic(word)] = index; + }); + if (check(lang) !== "0xf74fb7092aeacdfbf8959557de22098da512207fb9f109cb526994938cf40300") { + wordlist = null; + throw new Error("BIP39 Wordlist for es (Spanish) FAILED"); + } +} +class LangEs extends Wordlist { + constructor() { + super("es"); + } + getWord(index) { + loadWords(this); + return wordlist[index]; + } + getWordIndex(word) { + loadWords(this); + let index = lookup[dropDiacritic(word)]; + if (typeof (index) !== "number") { + return -1; + } + return index; + } +} +const langEs = new LangEs(); +register(langEs); +export { langEs }; diff --git a/packages/wordlists/lang-fr.d.ts b/packages/wordlists/lib.esm/lang-fr.d.ts similarity index 100% rename from packages/wordlists/lang-fr.d.ts rename to packages/wordlists/lib.esm/lang-fr.d.ts diff --git a/packages/wordlists/lib.esm/lang-fr.js b/packages/wordlists/lib.esm/lang-fr.js new file mode 100644 index 000000000..ecc06d872 --- /dev/null +++ b/packages/wordlists/lib.esm/lang-fr.js @@ -0,0 +1,67 @@ +"use strict"; +import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { check, register, Wordlist } from "./wordlist"; +const words = "AbaisserAbandonAbdiquerAbeilleAbolirAborderAboutirAboyerAbrasifAbreuverAbriterAbrogerAbruptAbsenceAbsoluAbsurdeAbusifAbyssalAcade/mieAcajouAcarienAccablerAccepterAcclamerAccoladeAccrocheAccuserAcerbeAchatAcheterAcidulerAcierAcompteAcque/rirAcronymeActeurActifActuelAdepteAde/quatAdhe/sifAdjectifAdjugerAdmettreAdmirerAdopterAdorerAdoucirAdresseAdroitAdulteAdverbeAe/rerAe/ronefAffaireAffecterAfficheAffreuxAffublerAgacerAgencerAgileAgiterAgraferAgre/ableAgrumeAiderAiguilleAilierAimableAisanceAjouterAjusterAlarmerAlchimieAlerteAlge-breAlgueAlie/nerAlimentAlle/gerAlliageAllouerAllumerAlourdirAlpagaAltesseAlve/oleAmateurAmbiguAmbreAme/nagerAmertumeAmidonAmiralAmorcerAmourAmovibleAmphibieAmpleurAmusantAnalyseAnaphoreAnarchieAnatomieAncienAne/antirAngleAngoisseAnguleuxAnimalAnnexerAnnonceAnnuelAnodinAnomalieAnonymeAnormalAntenneAntidoteAnxieuxApaiserApe/ritifAplanirApologieAppareilAppelerApporterAppuyerAquariumAqueducArbitreArbusteArdeurArdoiseArgentArlequinArmatureArmementArmoireArmureArpenterArracherArriverArroserArsenicArte/rielArticleAspectAsphalteAspirerAssautAsservirAssietteAssocierAssurerAsticotAstreAstuceAtelierAtomeAtriumAtroceAttaqueAttentifAttirerAttraperAubaineAubergeAudaceAudibleAugurerAuroreAutomneAutrucheAvalerAvancerAvariceAvenirAverseAveugleAviateurAvideAvionAviserAvoineAvouerAvrilAxialAxiomeBadgeBafouerBagageBaguetteBaignadeBalancerBalconBaleineBalisageBambinBancaireBandageBanlieueBannie-reBanquierBarbierBarilBaronBarqueBarrageBassinBastionBatailleBateauBatterieBaudrierBavarderBeletteBe/lierBeloteBe/ne/ficeBerceauBergerBerlineBermudaBesaceBesogneBe/tailBeurreBiberonBicycleBiduleBijouBilanBilingueBillardBinaireBiologieBiopsieBiotypeBiscuitBisonBistouriBitumeBizarreBlafardBlagueBlanchirBlessantBlinderBlondBloquerBlousonBobardBobineBoireBoiserBolideBonbonBondirBonheurBonifierBonusBordureBorneBotteBoucleBoueuxBougieBoulonBouquinBourseBoussoleBoutiqueBoxeurBrancheBrasierBraveBrebisBre-cheBreuvageBricolerBrigadeBrillantBriocheBriqueBrochureBroderBronzerBrousseBroyeurBrumeBrusqueBrutalBruyantBuffleBuissonBulletinBureauBurinBustierButinerButoirBuvableBuvetteCabanonCabineCachetteCadeauCadreCafe/ineCaillouCaissonCalculerCalepinCalibreCalmerCalomnieCalvaireCamaradeCame/raCamionCampagneCanalCanetonCanonCantineCanularCapableCaporalCapriceCapsuleCapterCapucheCarabineCarboneCaresserCaribouCarnageCarotteCarreauCartonCascadeCasierCasqueCassureCauserCautionCavalierCaverneCaviarCe/dilleCeintureCe/lesteCelluleCendrierCensurerCentralCercleCe/re/bralCeriseCernerCerveauCesserChagrinChaiseChaleurChambreChanceChapitreCharbonChasseurChatonChaussonChavirerChemiseChenilleChe/quierChercherChevalChienChiffreChignonChime-reChiotChlorureChocolatChoisirChoseChouetteChromeChuteCigareCigogneCimenterCine/maCintrerCirculerCirerCirqueCiterneCitoyenCitronCivilClaironClameurClaquerClasseClavierClientClignerClimatClivageClocheClonageCloporteCobaltCobraCocasseCocotierCoderCodifierCoffreCognerCohe/sionCoifferCoincerCole-reColibriCollineColmaterColonelCombatCome/dieCommandeCompactConcertConduireConfierCongelerConnoterConsonneContactConvexeCopainCopieCorailCorbeauCordageCornicheCorpusCorrectCorte-geCosmiqueCostumeCotonCoudeCoupureCourageCouteauCouvrirCoyoteCrabeCrainteCravateCrayonCre/atureCre/diterCre/meuxCreuserCrevetteCriblerCrierCristalCrite-reCroireCroquerCrotaleCrucialCruelCrypterCubiqueCueillirCuille-reCuisineCuivreCulminerCultiverCumulerCupideCuratifCurseurCyanureCycleCylindreCyniqueDaignerDamierDangerDanseurDauphinDe/battreDe/biterDe/borderDe/briderDe/butantDe/calerDe/cembreDe/chirerDe/ciderDe/clarerDe/corerDe/crireDe/cuplerDe/daleDe/ductifDe/esseDe/fensifDe/filerDe/frayerDe/gagerDe/givrerDe/glutirDe/graferDe/jeunerDe/liceDe/logerDemanderDemeurerDe/molirDe/nicherDe/nouerDentelleDe/nuderDe/partDe/penserDe/phaserDe/placerDe/poserDe/rangerDe/roberDe/sastreDescenteDe/sertDe/signerDe/sobe/irDessinerDestrierDe/tacherDe/testerDe/tourerDe/tresseDevancerDevenirDevinerDevoirDiableDialogueDiamantDicterDiffe/rerDige/rerDigitalDigneDiluerDimancheDiminuerDioxydeDirectifDirigerDiscuterDisposerDissiperDistanceDivertirDiviserDocileDocteurDogmeDoigtDomaineDomicileDompterDonateurDonjonDonnerDopamineDortoirDorureDosageDoseurDossierDotationDouanierDoubleDouceurDouterDoyenDragonDraperDresserDribblerDroitureDuperieDuplexeDurableDurcirDynastieE/blouirE/carterE/charpeE/chelleE/clairerE/clipseE/cloreE/cluseE/coleE/conomieE/corceE/couterE/craserE/cre/merE/crivainE/crouE/cumeE/cureuilE/difierE/duquerEffacerEffectifEffigieEffortEffrayerEffusionE/galiserE/garerE/jecterE/laborerE/largirE/lectronE/le/gantE/le/phantE/le-veE/ligibleE/litismeE/logeE/luciderE/luderEmballerEmbellirEmbryonE/meraudeE/missionEmmenerE/motionE/mouvoirEmpereurEmployerEmporterEmpriseE/mulsionEncadrerEnche-reEnclaveEncocheEndiguerEndosserEndroitEnduireE/nergieEnfanceEnfermerEnfouirEngagerEnginEngloberE/nigmeEnjamberEnjeuEnleverEnnemiEnnuyeuxEnrichirEnrobageEnseigneEntasserEntendreEntierEntourerEntraverE/nume/rerEnvahirEnviableEnvoyerEnzymeE/olienE/paissirE/pargneE/patantE/pauleE/picerieE/pide/mieE/pierE/pilogueE/pineE/pisodeE/pitapheE/poqueE/preuveE/prouverE/puisantE/querreE/quipeE/rigerE/rosionErreurE/ruptionEscalierEspadonEspe-ceEspie-gleEspoirEspritEsquiverEssayerEssenceEssieuEssorerEstimeEstomacEstradeE/tage-reE/talerE/tancheE/tatiqueE/teindreE/tendoirE/ternelE/thanolE/thiqueEthnieE/tirerE/tofferE/toileE/tonnantE/tourdirE/trangeE/troitE/tudeEuphorieE/valuerE/vasionE/ventailE/videnceE/viterE/volutifE/voquerExactExage/rerExaucerExcellerExcitantExclusifExcuseExe/cuterExempleExercerExhalerExhorterExigenceExilerExisterExotiqueExpe/dierExplorerExposerExprimerExquisExtensifExtraireExulterFableFabuleuxFacetteFacileFactureFaiblirFalaiseFameuxFamilleFarceurFarfeluFarineFaroucheFascinerFatalFatigueFauconFautifFaveurFavoriFe/brileFe/conderFe/de/rerFe/linFemmeFe/murFendoirFe/odalFermerFe/roceFerveurFestivalFeuilleFeutreFe/vrierFiascoFicelerFictifFide-leFigureFilatureFiletageFilie-reFilleulFilmerFilouFiltrerFinancerFinirFioleFirmeFissureFixerFlairerFlammeFlasqueFlatteurFle/auFle-cheFleurFlexionFloconFloreFluctuerFluideFluvialFolieFonderieFongibleFontaineForcerForgeronFormulerFortuneFossileFoudreFouge-reFouillerFoulureFourmiFragileFraiseFranchirFrapperFrayeurFre/gateFreinerFrelonFre/mirFre/ne/sieFre-reFriableFrictionFrissonFrivoleFroidFromageFrontalFrotterFruitFugitifFuiteFureurFurieuxFurtifFusionFuturGagnerGalaxieGalerieGambaderGarantirGardienGarnirGarrigueGazelleGazonGe/antGe/latineGe/luleGendarmeGe/ne/ralGe/nieGenouGentilGe/ologieGe/ome-treGe/raniumGermeGestuelGeyserGibierGiclerGirafeGivreGlaceGlaiveGlisserGlobeGloireGlorieuxGolfeurGommeGonflerGorgeGorilleGoudronGouffreGoulotGoupilleGourmandGoutteGraduelGraffitiGraineGrandGrappinGratuitGravirGrenatGriffureGrillerGrimperGrognerGronderGrotteGroupeGrugerGrutierGruye-reGue/pardGuerrierGuideGuimauveGuitareGustatifGymnasteGyrostatHabitudeHachoirHalteHameauHangarHannetonHaricotHarmonieHarponHasardHe/liumHe/matomeHerbeHe/rissonHermineHe/ronHe/siterHeureuxHibernerHibouHilarantHistoireHiverHomardHommageHomoge-neHonneurHonorerHonteuxHordeHorizonHorlogeHormoneHorribleHouleuxHousseHublotHuileuxHumainHumbleHumideHumourHurlerHydromelHygie-neHymneHypnoseIdylleIgnorerIguaneIlliciteIllusionImageImbiberImiterImmenseImmobileImmuableImpactImpe/rialImplorerImposerImprimerImputerIncarnerIncendieIncidentInclinerIncoloreIndexerIndiceInductifIne/ditIneptieInexactInfiniInfligerInformerInfusionInge/rerInhalerInhiberInjecterInjureInnocentInoculerInonderInscrireInsecteInsigneInsoliteInspirerInstinctInsulterIntactIntenseIntimeIntrigueIntuitifInutileInvasionInventerInviterInvoquerIroniqueIrradierIrre/elIrriterIsolerIvoireIvresseJaguarJaillirJambeJanvierJardinJaugerJauneJavelotJetableJetonJeudiJeunesseJoindreJoncherJonglerJoueurJouissifJournalJovialJoyauJoyeuxJubilerJugementJuniorJuponJuristeJusticeJuteuxJuve/nileKayakKimonoKiosqueLabelLabialLabourerLace/rerLactoseLaguneLaineLaisserLaitierLambeauLamelleLampeLanceurLangageLanterneLapinLargeurLarmeLaurierLavaboLavoirLectureLe/galLe/gerLe/gumeLessiveLettreLevierLexiqueLe/zardLiasseLibe/rerLibreLicenceLicorneLie-geLie-vreLigatureLigoterLigueLimerLimiteLimonadeLimpideLine/aireLingotLionceauLiquideLisie-reListerLithiumLitigeLittoralLivreurLogiqueLointainLoisirLombricLoterieLouerLourdLoutreLouveLoyalLubieLucideLucratifLueurLugubreLuisantLumie-reLunaireLundiLuronLutterLuxueuxMachineMagasinMagentaMagiqueMaigreMaillonMaintienMairieMaisonMajorerMalaxerMale/ficeMalheurMaliceMalletteMammouthMandaterManiableManquantManteauManuelMarathonMarbreMarchandMardiMaritimeMarqueurMarronMartelerMascotteMassifMate/rielMatie-reMatraqueMaudireMaussadeMauveMaximalMe/chantMe/connuMe/dailleMe/decinMe/diterMe/duseMeilleurMe/langeMe/lodieMembreMe/moireMenacerMenerMenhirMensongeMentorMercrediMe/riteMerleMessagerMesureMe/talMe/te/oreMe/thodeMe/tierMeubleMiaulerMicrobeMietteMignonMigrerMilieuMillionMimiqueMinceMine/ralMinimalMinorerMinuteMiracleMiroiterMissileMixteMobileModerneMoelleuxMondialMoniteurMonnaieMonotoneMonstreMontagneMonumentMoqueurMorceauMorsureMortierMoteurMotifMoucheMoufleMoulinMoussonMoutonMouvantMultipleMunitionMurailleMure-neMurmureMuscleMuse/umMusicienMutationMuterMutuelMyriadeMyrtilleMyste-reMythiqueNageurNappeNarquoisNarrerNatationNationNatureNaufrageNautiqueNavireNe/buleuxNectarNe/fasteNe/gationNe/gligerNe/gocierNeigeNerveuxNettoyerNeuroneNeutronNeveuNicheNickelNitrateNiveauNobleNocifNocturneNoirceurNoisetteNomadeNombreuxNommerNormatifNotableNotifierNotoireNourrirNouveauNovateurNovembreNoviceNuageNuancerNuireNuisibleNume/roNuptialNuqueNutritifObe/irObjectifObligerObscurObserverObstacleObtenirObturerOccasionOccuperOce/anOctobreOctroyerOctuplerOculaireOdeurOdorantOffenserOfficierOffrirOgiveOiseauOisillonOlfactifOlivierOmbrageOmettreOnctueuxOndulerOne/reuxOniriqueOpaleOpaqueOpe/rerOpinionOpportunOpprimerOpterOptiqueOrageuxOrangeOrbiteOrdonnerOreilleOrganeOrgueilOrificeOrnementOrqueOrtieOscillerOsmoseOssatureOtarieOuraganOursonOutilOutragerOuvrageOvationOxydeOxyge-neOzonePaisiblePalacePalmare-sPalourdePalperPanachePandaPangolinPaniquerPanneauPanoramaPantalonPapayePapierPapoterPapyrusParadoxeParcelleParesseParfumerParlerParoleParrainParsemerPartagerParureParvenirPassionPaste-quePaternelPatiencePatronPavillonPavoiserPayerPaysagePeignePeintrePelagePe/licanPellePelousePeluchePendulePe/ne/trerPe/niblePensifPe/nuriePe/pitePe/plumPerdrixPerforerPe/riodePermuterPerplexePersilPertePeserPe/talePetitPe/trirPeuplePharaonPhobiePhoquePhotonPhrasePhysiquePianoPicturalPie-cePierrePieuvrePilotePinceauPipettePiquerPiroguePiscinePistonPivoterPixelPizzaPlacardPlafondPlaisirPlanerPlaquePlastronPlateauPleurerPlexusPliagePlombPlongerPluiePlumagePochettePoe/siePoe-tePointePoirierPoissonPoivrePolairePolicierPollenPolygonePommadePompierPonctuelPonde/rerPoneyPortiquePositionPosse/derPosturePotagerPoteauPotionPoucePoulainPoumonPourprePoussinPouvoirPrairiePratiquePre/cieuxPre/direPre/fixePre/ludePre/nomPre/sencePre/textePre/voirPrimitifPrincePrisonPriverProble-meProce/derProdigeProfondProgre-sProieProjeterProloguePromenerPropreProspe-reProte/gerProuesseProverbePrudencePruneauPsychosePublicPuceronPuiserPulpePulsarPunaisePunitifPupitrePurifierPuzzlePyramideQuasarQuerelleQuestionQuie/tudeQuitterQuotientRacineRaconterRadieuxRagondinRaideurRaisinRalentirRallongeRamasserRapideRasageRatisserRavagerRavinRayonnerRe/actifRe/agirRe/aliserRe/animerRecevoirRe/citerRe/clamerRe/colterRecruterReculerRecyclerRe/digerRedouterRefaireRe/flexeRe/formerRefrainRefugeRe/galienRe/gionRe/glageRe/gulierRe/ite/rerRejeterRejouerRelatifReleverReliefRemarqueReme-deRemiseRemonterRemplirRemuerRenardRenfortReniflerRenoncerRentrerRenvoiReplierReporterRepriseReptileRequinRe/serveRe/sineuxRe/soudreRespectResterRe/sultatRe/tablirRetenirRe/ticuleRetomberRetracerRe/unionRe/ussirRevancheRevivreRe/volteRe/vulsifRichesseRideauRieurRigideRigolerRincerRiposterRisibleRisqueRituelRivalRivie-reRocheuxRomanceRompreRonceRondinRoseauRosierRotatifRotorRotuleRougeRouilleRouleauRoutineRoyaumeRubanRubisRucheRuelleRugueuxRuinerRuisseauRuserRustiqueRythmeSablerSaboterSabreSacocheSafariSagesseSaisirSaladeSaliveSalonSaluerSamediSanctionSanglierSarcasmeSardineSaturerSaugrenuSaumonSauterSauvageSavantSavonnerScalpelScandaleSce/le/ratSce/narioSceptreSche/maScienceScinderScoreScrutinSculpterSe/anceSe/cableSe/cherSecouerSe/cre/terSe/datifSe/duireSeigneurSe/jourSe/lectifSemaineSemblerSemenceSe/minalSe/nateurSensibleSentenceSe/parerSe/quenceSereinSergentSe/rieuxSerrureSe/rumServiceSe/sameSe/virSevrageSextupleSide/ralSie-cleSie/gerSifflerSigleSignalSilenceSiliciumSimpleSince-reSinistreSiphonSiropSismiqueSituerSkierSocialSocleSodiumSoigneuxSoldatSoleilSolitudeSolubleSombreSommeilSomnolerSondeSongeurSonnetteSonoreSorcierSortirSosieSottiseSoucieuxSoudureSouffleSouleverSoupapeSourceSoutirerSouvenirSpacieuxSpatialSpe/cialSphe-reSpiralStableStationSternumStimulusStipulerStrictStudieuxStupeurStylisteSublimeSubstratSubtilSubvenirSucce-sSucreSuffixeSugge/rerSuiveurSulfateSuperbeSupplierSurfaceSuricateSurmenerSurpriseSursautSurvieSuspectSyllabeSymboleSyme/trieSynapseSyntaxeSyste-meTabacTablierTactileTaillerTalentTalismanTalonnerTambourTamiserTangibleTapisTaquinerTarderTarifTartineTasseTatamiTatouageTaupeTaureauTaxerTe/moinTemporelTenailleTendreTeneurTenirTensionTerminerTerneTerribleTe/tineTexteThe-meThe/orieThe/rapieThoraxTibiaTie-deTimideTirelireTiroirTissuTitaneTitreTituberTobogganTole/rantTomateToniqueTonneauToponymeTorcheTordreTornadeTorpilleTorrentTorseTortueTotemToucherTournageTousserToxineTractionTraficTragiqueTrahirTrainTrancherTravailTre-fleTremperTre/sorTreuilTriageTribunalTricoterTrilogieTriompheTriplerTriturerTrivialTromboneTroncTropicalTroupeauTuileTulipeTumulteTunnelTurbineTuteurTutoyerTuyauTympanTyphonTypiqueTyranUbuesqueUltimeUltrasonUnanimeUnifierUnionUniqueUnitaireUniversUraniumUrbainUrticantUsageUsineUsuelUsureUtileUtopieVacarmeVaccinVagabondVagueVaillantVaincreVaisseauValableValiseVallonValveVampireVanilleVapeurVarierVaseuxVassalVasteVecteurVedetteVe/ge/talVe/hiculeVeinardVe/loceVendrediVe/ne/rerVengerVenimeuxVentouseVerdureVe/rinVernirVerrouVerserVertuVestonVe/te/ranVe/tusteVexantVexerViaducViandeVictoireVidangeVide/oVignetteVigueurVilainVillageVinaigreViolonVipe-reVirementVirtuoseVirusVisageViseurVisionVisqueuxVisuelVitalVitesseViticoleVitrineVivaceVivipareVocationVoguerVoileVoisinVoitureVolailleVolcanVoltigerVolumeVoraceVortexVoterVouloirVoyageVoyelleWagonXe/nonYachtZe-breZe/nithZesteZoologie"; +let wordlist = null; +let lookup = {}; +function dropDiacritic(word) { + logger.checkNormalize(); + return toUtf8String(Array.prototype.filter.call(toUtf8Bytes(word.normalize("NFD").toLowerCase()), (c) => { + return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123)); + })); +} +function expand(word) { + let output = []; + Array.prototype.forEach.call(toUtf8Bytes(word), (c) => { + // Acute accent + if (c === 47) { + output.push(204); + output.push(129); + // Grave accent + } + else if (c === 45) { + output.push(204); + output.push(128); + } + else { + output.push(c); + } + }); + return toUtf8String(output); +} +function loadWords(lang) { + if (wordlist != null) { + return; + } + wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" ").map((w) => expand(w)); + wordlist.forEach((word, index) => { + lookup[dropDiacritic(word)] = index; + }); + if (check(lang) !== "0x51deb7ae009149dc61a6bd18a918eb7ac78d2775726c68e598b92d002519b045") { + wordlist = null; + throw new Error("BIP39 Wordlist for fr (French) FAILED"); + } +} +class LangFr extends Wordlist { + constructor() { + super("fr"); + } + getWord(index) { + loadWords(this); + return wordlist[index]; + } + getWordIndex(word) { + loadWords(this); + let index = lookup[dropDiacritic(word)]; + if (typeof (index) !== "number") { + return -1; + } + return index; + } +} +const langFr = new LangFr(); +register(langFr); +export { langFr }; diff --git a/packages/wordlists/lang-it.d.ts b/packages/wordlists/lib.esm/lang-it.d.ts similarity index 100% rename from packages/wordlists/lang-it.d.ts rename to packages/wordlists/lib.esm/lang-it.d.ts diff --git a/packages/wordlists/lib.esm/lang-it.js b/packages/wordlists/lib.esm/lang-it.js new file mode 100644 index 000000000..bac18c86e --- /dev/null +++ b/packages/wordlists/lib.esm/lang-it.js @@ -0,0 +1,30 @@ +"use strict"; +import { check, register, Wordlist } from "./wordlist"; +const words = "AbacoAbbaglioAbbinatoAbeteAbissoAbolireAbrasivoAbrogatoAccadereAccennoAccusatoAcetoneAchilleAcidoAcquaAcreAcrilicoAcrobataAcutoAdagioAddebitoAddomeAdeguatoAderireAdipeAdottareAdulareAffabileAffettoAffissoAffrantoAforismaAfosoAfricanoAgaveAgenteAgevoleAggancioAgireAgitareAgonismoAgricoloAgrumetoAguzzoAlabardaAlatoAlbatroAlberatoAlboAlbumeAlceAlcolicoAlettoneAlfaAlgebraAlianteAlibiAlimentoAllagatoAllegroAllievoAllodolaAllusivoAlmenoAlogenoAlpacaAlpestreAltalenaAlternoAlticcioAltroveAlunnoAlveoloAlzareAmalgamaAmanitaAmarenaAmbitoAmbratoAmebaAmericaAmetistaAmicoAmmassoAmmendaAmmirareAmmonitoAmoreAmpioAmpliareAmuletoAnacardoAnagrafeAnalistaAnarchiaAnatraAncaAncellaAncoraAndareAndreaAnelloAngeloAngolareAngustoAnimaAnnegareAnnidatoAnnoAnnuncioAnonimoAnticipoAnziApaticoAperturaApodeApparireAppetitoAppoggioApprodoAppuntoAprileArabicaArachideAragostaAraldicaArancioAraturaArazzoArbitroArchivioArditoArenileArgentoArgineArgutoAriaArmoniaArneseArredatoArringaArrostoArsenicoArsoArteficeArzilloAsciuttoAscoltoAsepsiAsetticoAsfaltoAsinoAsolaAspiratoAsproAssaggioAsseAssolutoAssurdoAstaAstenutoAsticeAstrattoAtavicoAteismoAtomicoAtonoAttesaAttivareAttornoAttritoAttualeAusilioAustriaAutistaAutonomoAutunnoAvanzatoAvereAvvenireAvvisoAvvolgereAzioneAzotoAzzimoAzzurroBabeleBaccanoBacinoBacoBadessaBadilataBagnatoBaitaBalconeBaldoBalenaBallataBalzanoBambinoBandireBaraondaBarbaroBarcaBaritonoBarlumeBaroccoBasilicoBassoBatostaBattutoBauleBavaBavosaBeccoBeffaBelgioBelvaBendaBenevoleBenignoBenzinaBereBerlinaBetaBibitaBiciBidoneBifidoBigaBilanciaBimboBinocoloBiologoBipedeBipolareBirbanteBirraBiscottoBisestoBisnonnoBisonteBisturiBizzarroBlandoBlattaBollitoBonificoBordoBoscoBotanicoBottinoBozzoloBraccioBradipoBramaBrancaBravuraBretellaBrevettoBrezzaBrigliaBrillanteBrindareBroccoloBrodoBronzinaBrulloBrunoBubboneBucaBudinoBuffoneBuioBulboBuonoBurloneBurrascaBussolaBustaCadettoCaducoCalamaroCalcoloCalesseCalibroCalmoCaloriaCambusaCamerataCamiciaCamminoCamolaCampaleCanapaCandelaCaneCaninoCanottoCantinaCapaceCapelloCapitoloCapogiroCapperoCapraCapsulaCarapaceCarcassaCardoCarismaCarovanaCarrettoCartolinaCasaccioCascataCasermaCasoCassoneCastelloCasualeCatastaCatenaCatrameCautoCavilloCedibileCedrataCefaloCelebreCellulareCenaCenoneCentesimoCeramicaCercareCertoCerumeCervelloCesoiaCespoCetoChelaChiaroChiccaChiedereChimeraChinaChirurgoChitarraCiaoCiclismoCifrareCignoCilindroCiottoloCircaCirrosiCitricoCittadinoCiuffoCivettaCivileClassicoClinicaCloroCoccoCodardoCodiceCoerenteCognomeCollareColmatoColoreColposoColtivatoColzaComaCometaCommandoComodoComputerComuneConcisoCondurreConfermaCongelareConiugeConnessoConoscereConsumoContinuoConvegnoCopertoCopioneCoppiaCopricapoCorazzaCordataCoricatoCorniceCorollaCorpoCorredoCorsiaCorteseCosmicoCostanteCotturaCovatoCratereCravattaCreatoCredereCremosoCrescitaCretaCricetoCrinaleCrisiCriticoCroceCronacaCrostataCrucialeCruscaCucireCuculoCuginoCullatoCupolaCuratoreCursoreCurvoCuscinoCustodeDadoDainoDalmataDamerinoDanielaDannosoDanzareDatatoDavantiDavveroDebuttoDecennioDecisoDeclinoDecolloDecretoDedicatoDefinitoDeformeDegnoDelegareDelfinoDelirioDeltaDemenzaDenotatoDentroDepositoDerapataDerivareDerogaDescrittoDesertoDesiderioDesumereDetersivoDevotoDiametroDicembreDiedroDifesoDiffusoDigerireDigitaleDiluvioDinamicoDinnanziDipintoDiplomaDipoloDiradareDireDirottoDirupoDisagioDiscretoDisfareDisgeloDispostoDistanzaDisumanoDitoDivanoDiveltoDividereDivoratoDobloneDocenteDoganaleDogmaDolceDomatoDomenicaDominareDondoloDonoDormireDoteDottoreDovutoDozzinaDragoDruidoDubbioDubitareDucaleDunaDuomoDupliceDuraturoEbanoEccessoEccoEclissiEconomiaEderaEdicolaEdileEditoriaEducareEgemoniaEgliEgoismoEgregioElaboratoElargireEleganteElencatoElettoElevareElficoElicaElmoElsaElusoEmanatoEmblemaEmessoEmiroEmotivoEmozioneEmpiricoEmuloEndemicoEnduroEnergiaEnfasiEnotecaEntrareEnzimaEpatiteEpilogoEpisodioEpocaleEppureEquatoreErarioErbaErbosoEredeEremitaErigereErmeticoEroeErosivoErranteEsagonoEsameEsanimeEsaudireEscaEsempioEsercitoEsibitoEsigenteEsistereEsitoEsofagoEsortatoEsosoEspansoEspressoEssenzaEssoEstesoEstimareEstoniaEstrosoEsultareEtilicoEtnicoEtruscoEttoEuclideoEuropaEvasoEvidenzaEvitatoEvolutoEvvivaFabbricaFaccendaFachiroFalcoFamigliaFanaleFanfaraFangoFantasmaFareFarfallaFarinosoFarmacoFasciaFastosoFasulloFaticareFatoFavolosoFebbreFecolaFedeFegatoFelpaFeltroFemminaFendereFenomenoFermentoFerroFertileFessuraFestivoFettaFeudoFiabaFiduciaFifaFiguratoFiloFinanzaFinestraFinireFioreFiscaleFisicoFiumeFlaconeFlamencoFleboFlemmaFloridoFluenteFluoroFobicoFocacciaFocosoFoderatoFoglioFolataFolcloreFolgoreFondenteFoneticoFoniaFontanaForbitoForchettaForestaFormicaFornaioForoFortezzaForzareFosfatoFossoFracassoFranaFrassinoFratelloFreccettaFrenataFrescoFrigoFrollinoFrondeFrugaleFruttaFucilataFucsiaFuggenteFulmineFulvoFumanteFumettoFumosoFuneFunzioneFuocoFurboFurgoneFuroreFusoFutileGabbianoGaffeGalateoGallinaGaloppoGamberoGammaGaranziaGarboGarofanoGarzoneGasdottoGasolioGastricoGattoGaudioGazeboGazzellaGecoGelatinaGelsoGemelloGemmatoGeneGenitoreGennaioGenotipoGergoGhepardoGhiaccioGhisaGialloGildaGineproGiocareGioielloGiornoGioveGiratoGironeGittataGiudizioGiuratoGiustoGlobuloGlutineGnomoGobbaGolfGomitoGommoneGonfioGonnaGovernoGracileGradoGraficoGrammoGrandeGrattareGravosoGraziaGrecaGreggeGrifoneGrigioGrinzaGrottaGruppoGuadagnoGuaioGuantoGuardareGufoGuidareIbernatoIconaIdenticoIdillioIdoloIdraIdricoIdrogenoIgieneIgnaroIgnoratoIlareIllesoIllogicoIlludereImballoImbevutoImboccoImbutoImmaneImmersoImmolatoImpaccoImpetoImpiegoImportoImprontaInalareInarcareInattivoIncantoIncendioInchinoIncisivoInclusoIncontroIncrocioIncuboIndagineIndiaIndoleIneditoInfattiInfilareInflittoIngaggioIngegnoIngleseIngordoIngrossoInnescoInodoreInoltrareInondatoInsanoInsettoInsiemeInsonniaInsulinaIntasatoInteroIntonacoIntuitoInumidireInvalidoInveceInvitoIperboleIpnoticoIpotesiIppicaIrideIrlandaIronicoIrrigatoIrrorareIsolatoIsotopoIstericoIstitutoIstriceItaliaIterareLabbroLabirintoLaccaLaceratoLacrimaLacunaLaddoveLagoLampoLancettaLanternaLardosoLargaLaringeLastraLatenzaLatinoLattugaLavagnaLavoroLegaleLeggeroLemboLentezzaLenzaLeoneLepreLesivoLessatoLestoLetteraleLevaLevigatoLiberoLidoLievitoLillaLimaturaLimitareLimpidoLineareLinguaLiquidoLiraLiricaLiscaLiteLitigioLivreaLocandaLodeLogicaLombareLondraLongevoLoquaceLorenzoLotoLotteriaLuceLucidatoLumacaLuminosoLungoLupoLuppoloLusingaLussoLuttoMacabroMacchinaMaceroMacinatoMadamaMagicoMagliaMagneteMagroMaiolicaMalafedeMalgradoMalintesoMalsanoMaltoMalumoreManaManciaMandorlaMangiareManifestoMannaroManovraMansardaMantideManubrioMappaMaratonaMarcireMarettaMarmoMarsupioMascheraMassaiaMastinoMaterassoMatricolaMattoneMaturoMazurcaMeandroMeccanicoMecenateMedesimoMeditareMegaMelassaMelisMelodiaMeningeMenoMensolaMercurioMerendaMerloMeschinoMeseMessereMestoloMetalloMetodoMettereMiagolareMicaMicelioMicheleMicroboMidolloMieleMiglioreMilanoMiliteMimosaMineraleMiniMinoreMirinoMirtilloMiscelaMissivaMistoMisurareMitezzaMitigareMitraMittenteMnemonicoModelloModificaModuloMoganoMogioMoleMolossoMonasteroMoncoMondinaMonetarioMonileMonotonoMonsoneMontatoMonvisoMoraMordereMorsicatoMostroMotivatoMotosegaMottoMovenzaMovimentoMozzoMuccaMucosaMuffaMughettoMugnaioMulattoMulinelloMultiploMummiaMuntoMuovereMuraleMusaMuscoloMusicaMutevoleMutoNababboNaftaNanometroNarcisoNariceNarratoNascereNastrareNaturaleNauticaNaviglioNebulosaNecrosiNegativoNegozioNemmenoNeofitaNerettoNervoNessunoNettunoNeutraleNeveNevroticoNicchiaNinfaNitidoNobileNocivoNodoNomeNominaNordicoNormaleNorvegeseNostranoNotareNotiziaNotturnoNovellaNucleoNullaNumeroNuovoNutrireNuvolaNuzialeOasiObbedireObbligoObeliscoOblioOboloObsoletoOccasioneOcchioOccidenteOccorrereOccultareOcraOculatoOdiernoOdorareOffertaOffrireOffuscatoOggettoOggiOgnunoOlandeseOlfattoOliatoOlivaOlogrammaOltreOmaggioOmbelicoOmbraOmegaOmissioneOndosoOnereOniceOnnivoroOnorevoleOntaOperatoOpinioneOppostoOracoloOrafoOrdineOrecchinoOreficeOrfanoOrganicoOrigineOrizzonteOrmaOrmeggioOrnativoOrologioOrrendoOrribileOrtensiaOrticaOrzataOrzoOsareOscurareOsmosiOspedaleOspiteOssaOssidareOstacoloOsteOtiteOtreOttagonoOttimoOttobreOvaleOvestOvinoOviparoOvocitoOvunqueOvviareOzioPacchettoPacePacificoPadellaPadronePaesePagaPaginaPalazzinaPalesarePallidoPaloPaludePandoroPannelloPaoloPaonazzoPapricaParabolaParcellaParerePargoloPariParlatoParolaPartireParvenzaParzialePassivoPasticcaPataccaPatologiaPattumePavonePeccatoPedalarePedonalePeggioPelosoPenarePendicePenisolaPennutoPenombraPensarePentolaPepePepitaPerbenePercorsoPerdonatoPerforarePergamenaPeriodoPermessoPernoPerplessoPersuasoPertugioPervasoPesatorePesistaPesoPestiferoPetaloPettinePetulantePezzoPiacerePiantaPiattinoPiccinoPicozzaPiegaPietraPifferoPigiamaPigolioPigroPilaPiliferoPillolaPilotaPimpantePinetaPinnaPinoloPioggiaPiomboPiramidePireticoPiritePirolisiPitonePizzicoPlaceboPlanarePlasmaPlatanoPlenarioPochezzaPoderosoPodismoPoesiaPoggiarePolentaPoligonoPollicePolmonitePolpettaPolsoPoltronaPolverePomicePomodoroPontePopolosoPorfidoPorosoPorporaPorrePortataPosaPositivoPossessoPostulatoPotassioPoterePranzoPrassiPraticaPreclusoPredicaPrefissoPregiatoPrelievoPremerePrenotarePreparatoPresenzaPretestoPrevalsoPrimaPrincipePrivatoProblemaProcuraProdurreProfumoProgettoProlungaPromessaPronomePropostaProrogaProtesoProvaPrudentePrugnaPruritoPsichePubblicoPudicaPugilatoPugnoPulcePulitoPulsantePuntarePupazzoPupillaPuroQuadroQualcosaQuasiQuerelaQuotaRaccoltoRaddoppioRadicaleRadunatoRafficaRagazzoRagioneRagnoRamarroRamingoRamoRandagioRantolareRapatoRapinaRappresoRasaturaRaschiatoRasenteRassegnaRastrelloRataRavvedutoRealeRecepireRecintoReclutaReconditoRecuperoRedditoRedimereRegalatoRegistroRegolaRegressoRelazioneRemareRemotoRennaReplicaReprimereReputareResaResidenteResponsoRestauroReteRetinaRetoricaRettificaRevocatoRiassuntoRibadireRibelleRibrezzoRicaricaRiccoRicevereRiciclatoRicordoRicredutoRidicoloRidurreRifasareRiflessoRiformaRifugioRigareRigettatoRighelloRilassatoRilevatoRimanereRimbalzoRimedioRimorchioRinascitaRincaroRinforzoRinnovoRinomatoRinsavitoRintoccoRinunciaRinvenireRiparatoRipetutoRipienoRiportareRipresaRipulireRisataRischioRiservaRisibileRisoRispettoRistoroRisultatoRisvoltoRitardoRitegnoRitmicoRitrovoRiunioneRivaRiversoRivincitaRivoltoRizomaRobaRoboticoRobustoRocciaRocoRodaggioRodereRoditoreRogitoRollioRomanticoRompereRonzioRosolareRospoRotanteRotondoRotulaRovescioRubizzoRubricaRugaRullinoRumineRumorosoRuoloRupeRussareRusticoSabatoSabbiareSabotatoSagomaSalassoSaldaturaSalgemmaSalivareSalmoneSaloneSaltareSalutoSalvoSapereSapidoSaporitoSaracenoSarcasmoSartoSassosoSatelliteSatiraSatolloSaturnoSavanaSavioSaziatoSbadiglioSbalzoSbancatoSbarraSbattereSbavareSbendareSbirciareSbloccatoSbocciatoSbrinareSbruffoneSbuffareScabrosoScadenzaScalaScambiareScandaloScapolaScarsoScatenareScavatoSceltoScenicoScettroSchedaSchienaSciarpaScienzaScindereScippoSciroppoScivoloSclerareScodellaScolpitoScompartoSconfortoScoprireScortaScossoneScozzeseScribaScrollareScrutinioScuderiaScultoreScuolaScuroScusareSdebitareSdoganareSeccaturaSecondoSedanoSeggiolaSegnalatoSegregatoSeguitoSelciatoSelettivoSellaSelvaggioSemaforoSembrareSemeSeminatoSempreSensoSentireSepoltoSequenzaSerataSerbatoSerenoSerioSerpenteSerraglioServireSestinaSetolaSettimanaSfaceloSfaldareSfamatoSfarzosoSfaticatoSferaSfidaSfilatoSfingeSfocatoSfoderareSfogoSfoltireSforzatoSfrattoSfruttatoSfuggitoSfumareSfusoSgabelloSgarbatoSgonfiareSgorbioSgrassatoSguardoSibiloSiccomeSierraSiglaSignoreSilenzioSillabaSimboloSimpaticoSimulatoSinfoniaSingoloSinistroSinoSintesiSinusoideSiparioSismaSistoleSituatoSlittaSlogaturaSlovenoSmarritoSmemoratoSmentitoSmeraldoSmilzoSmontareSmottatoSmussatoSnellireSnervatoSnodoSobbalzoSobrioSoccorsoSocialeSodaleSoffittoSognoSoldatoSolenneSolidoSollazzoSoloSolubileSolventeSomaticoSommaSondaSonettoSonniferoSopireSoppesoSopraSorgereSorpassoSorrisoSorsoSorteggioSorvolatoSospiroSostaSottileSpadaSpallaSpargereSpatolaSpaventoSpazzolaSpecieSpedireSpegnereSpelaturaSperanzaSpessoreSpettraleSpezzatoSpiaSpigolosoSpillatoSpinosoSpiraleSplendidoSportivoSposoSprangaSprecareSpronatoSpruzzoSpuntinoSquilloSradicareSrotolatoStabileStaccoStaffaStagnareStampatoStantioStarnutoStaseraStatutoSteloSteppaSterzoStilettoStimaStirpeStivaleStizzosoStonatoStoricoStrappoStregatoStriduloStrozzareStruttoStuccareStufoStupendoSubentroSuccosoSudoreSuggeritoSugoSultanoSuonareSuperboSupportoSurgelatoSurrogatoSussurroSuturaSvagareSvedeseSveglioSvelareSvenutoSveziaSviluppoSvistaSvizzeraSvoltaSvuotareTabaccoTabulatoTacciareTaciturnoTaleTalismanoTamponeTanninoTaraTardivoTargatoTariffaTarpareTartarugaTastoTatticoTavernaTavolataTazzaTecaTecnicoTelefonoTemerarioTempoTemutoTendoneTeneroTensioneTentacoloTeoremaTermeTerrazzoTerzettoTesiTesseratoTestatoTetroTettoiaTifareTigellaTimbroTintoTipicoTipografoTiraggioTiroTitanioTitoloTitubanteTizioTizzoneToccareTollerareToltoTombolaTomoTonfoTonsillaTopazioTopologiaToppaTorbaTornareTorroneTortoraToscanoTossireTostaturaTotanoTraboccoTracheaTrafilaTragediaTralcioTramontoTransitoTrapanoTrarreTraslocoTrattatoTraveTrecciaTremolioTrespoloTributoTrichecoTrifoglioTrilloTrinceaTrioTristezzaTrituratoTrivellaTrombaTronoTroppoTrottolaTrovareTruccatoTubaturaTuffatoTulipanoTumultoTunisiaTurbareTurchinoTutaTutelaUbicatoUccelloUccisoreUdireUditivoUffaUfficioUgualeUlisseUltimatoUmanoUmileUmorismoUncinettoUngereUnghereseUnicornoUnificatoUnisonoUnitarioUnteUovoUpupaUraganoUrgenzaUrloUsanzaUsatoUscitoUsignoloUsuraioUtensileUtilizzoUtopiaVacanteVaccinatoVagabondoVagliatoValangaValgoValicoVallettaValorosoValutareValvolaVampataVangareVanitosoVanoVantaggioVanveraVaporeVaranoVarcatoVarianteVascaVedettaVedovaVedutoVegetaleVeicoloVelcroVelinaVellutoVeloceVenatoVendemmiaVentoVeraceVerbaleVergognaVerificaVeroVerrucaVerticaleVescicaVessilloVestaleVeteranoVetrinaVetustoViandanteVibranteVicendaVichingoVicinanzaVidimareVigiliaVignetoVigoreVileVillanoViminiVincitoreViolaViperaVirgolaVirologoVirulentoViscosoVisioneVispoVissutoVisuraVitaVitelloVittimaVivandaVividoViziareVoceVogaVolatileVolereVolpeVoragineVulcanoZampognaZannaZappatoZatteraZavorraZefiroZelanteZeloZenzeroZerbinoZibettoZincoZirconeZittoZollaZoticoZuccheroZufoloZuluZuppa"; +let wordlist = null; +function loadWords(lang) { + if (wordlist != null) { + return; + } + wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); + if (check(lang) !== "0x5c1362d88fd4cf614a96f3234941d29f7d37c08c5292fde03bf62c2db6ff7620") { + wordlist = null; + throw new Error("BIP39 Wordlist for it (Italian) FAILED"); + } +} +class LangIt extends Wordlist { + constructor() { + super("it"); + } + getWord(index) { + loadWords(this); + return wordlist[index]; + } + getWordIndex(word) { + loadWords(this); + return wordlist.indexOf(word); + } +} +const langIt = new LangIt(); +register(langIt); +export { langIt }; diff --git a/packages/wordlists/lang-ja.d.ts b/packages/wordlists/lib.esm/lang-ja.d.ts similarity index 100% rename from packages/wordlists/lang-ja.d.ts rename to packages/wordlists/lib.esm/lang-ja.d.ts diff --git a/packages/wordlists/lib.esm/lang-ja.js b/packages/wordlists/lib.esm/lang-ja.js new file mode 100644 index 000000000..f8955f48f --- /dev/null +++ b/packages/wordlists/lib.esm/lang-ja.js @@ -0,0 +1,126 @@ +"use strict"; +import { hexlify } from "@ethersproject/bytes"; +import { toUtf8Bytes, toUtf8String } from "@ethersproject/strings"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +import { check, register, Wordlist } from "./wordlist"; +const data = [ + // 4-kana words + "AQRASRAGBAGUAIRAHBAghAURAdBAdcAnoAMEAFBAFCBKFBQRBSFBCXBCDBCHBGFBEQBpBBpQBIkBHNBeOBgFBVCBhBBhNBmOBmRBiHBiFBUFBZDBvFBsXBkFBlcBjYBwDBMBBTBBTRBWBBWXXaQXaRXQWXSRXCFXYBXpHXOQXHRXhRXuRXmXXbRXlXXwDXTRXrCXWQXWGaBWaKcaYgasFadQalmaMBacAKaRKKBKKXKKjKQRKDRKCYKCRKIDKeVKHcKlXKjHKrYNAHNBWNaRNKcNIBNIONmXNsXNdXNnBNMBNRBNrXNWDNWMNFOQABQAHQBrQXBQXFQaRQKXQKDQKOQKFQNBQNDQQgQCXQCDQGBQGDQGdQYXQpBQpQQpHQLXQHuQgBQhBQhCQuFQmXQiDQUFQZDQsFQdRQkHQbRQlOQlmQPDQjDQwXQMBQMDQcFQTBQTHQrDDXQDNFDGBDGQDGRDpFDhFDmXDZXDbRDMYDRdDTRDrXSAhSBCSBrSGQSEQSHBSVRShYShkSyQSuFSiBSdcSoESocSlmSMBSFBSFKSFNSFdSFcCByCaRCKcCSBCSRCCrCGbCEHCYXCpBCpQCIBCIHCeNCgBCgFCVECVcCmkCmwCZXCZFCdRClOClmClFCjDCjdCnXCwBCwXCcRCFQCFjGXhGNhGDEGDMGCDGCHGIFGgBGVXGVEGVRGmXGsXGdYGoSGbRGnXGwXGwDGWRGFNGFLGFOGFdGFkEABEBDEBFEXOEaBEKSENBENDEYXEIgEIkEgBEgQEgHEhFEudEuFEiBEiHEiFEZDEvBEsXEsFEdXEdREkFEbBEbRElFEPCEfkEFNYAEYAhYBNYQdYDXYSRYCEYYoYgQYgRYuRYmCYZTYdBYbEYlXYjQYRbYWRpKXpQopQnpSFpCXpIBpISphNpdBpdRpbRpcZpFBpFNpFDpFopFrLADLBuLXQLXcLaFLCXLEhLpBLpFLHXLeVLhILdHLdRLoDLbRLrXIABIBQIBCIBsIBoIBMIBRIXaIaRIKYIKRINBINuICDIGBIIDIIkIgRIxFIyQIiHIdRIbYIbRIlHIwRIMYIcRIRVITRIFBIFNIFQOABOAFOBQOaFONBONMOQFOSFOCDOGBOEQOpBOLXOIBOIFOgQOgFOyQOycOmXOsXOdIOkHOMEOMkOWWHBNHXNHXWHNXHDuHDRHSuHSRHHoHhkHmRHdRHkQHlcHlRHwBHWcgAEgAggAkgBNgBQgBEgXOgYcgLXgHjgyQgiBgsFgdagMYgWSgFQgFEVBTVXEVKBVKNVKDVKYVKRVNBVNYVDBVDxVSBVSRVCjVGNVLXVIFVhBVhcVsXVdRVbRVlRhBYhKYhDYhGShxWhmNhdahdkhbRhjohMXhTRxAXxXSxKBxNBxEQxeNxeQxhXxsFxdbxlHxjcxFBxFNxFQxFOxFoyNYyYoybcyMYuBQuBRuBruDMuCouHBudQukkuoBulVuMXuFEmCYmCRmpRmeDmiMmjdmTFmFQiADiBOiaRiKRiNBiNRiSFiGkiGFiERipRiLFiIFihYibHijBijEiMXiWBiFBiFCUBQUXFUaRUNDUNcUNRUNFUDBUSHUCDUGBUGFUEqULNULoUIRUeEUeYUgBUhFUuRUiFUsXUdFUkHUbBUjSUjYUwXUMDUcHURdUTBUrBUrXUrQZAFZXZZaRZKFZNBZQFZCXZGBZYdZpBZLDZIFZHXZHNZeQZVRZVFZmXZiBZvFZdFZkFZbHZbFZwXZcCZcRZRBvBQvBGvBLvBWvCovMYsAFsBDsaRsKFsNFsDrsSHsSFsCXsCRsEBsEHsEfspBsLBsLDsIgsIRseGsbRsFBsFQsFSdNBdSRdCVdGHdYDdHcdVbdySduDdsXdlRdwXdWYdWcdWRkBMkXOkaRkNIkNFkSFkCFkYBkpRkeNkgBkhVkmXksFklVkMBkWDkFNoBNoaQoaFoNBoNXoNaoNEoSRoEroYXoYCoYbopRopFomXojkowXorFbBEbEIbdBbjYlaRlDElMXlFDjKjjSRjGBjYBjYkjpRjLXjIBjOFjeVjbRjwBnXQnSHnpFnLXnINnMBnTRwXBwXNwXYwNFwQFwSBwGFwLXwLDweNwgBwuHwjDwnXMBXMpFMIBMeNMTHcaQcNBcDHcSFcCXcpBcLXcLDcgFcuFcnXcwXccDcTQcrFTQErXNrCHrpFrgFrbFrTHrFcWNYWNbWEHWMXWTR", + // 5-kana words + "ABGHABIJAEAVAYJQALZJAIaRAHNXAHdcAHbRAZJMAZJRAZTRAdVJAklmAbcNAjdRAMnRAMWYAWpRAWgRAFgBAFhBAFdcBNJBBNJDBQKBBQhcBQlmBDEJBYJkBYJTBpNBBpJFBIJBBIJDBIcABOKXBOEJBOVJBOiJBOZJBepBBeLXBeIFBegBBgGJBVJXBuocBiJRBUJQBlXVBlITBwNFBMYVBcqXBTlmBWNFBWiJBWnRBFGHBFwXXKGJXNJBXNZJXDTTXSHSXSVRXSlHXCJDXGQJXEhXXYQJXYbRXOfXXeNcXVJFXhQJXhEJXdTRXjdXXMhBXcQTXRGBXTEBXTnQXFCXXFOFXFgFaBaFaBNJaBCJaBpBaBwXaNJKaNJDaQIBaDpRaEPDaHMFamDJalEJaMZJaFaFaFNBaFQJaFLDaFVHKBCYKBEBKBHDKXaFKXGdKXEJKXpHKXIBKXZDKXwXKKwLKNacKNYJKNJoKNWcKDGdKDTRKChXKGaRKGhBKGbRKEBTKEaRKEPTKLMDKLWRKOHDKVJcKdBcKlIBKlOPKFSBKFEPKFpFNBNJNJBQNBGHNBEPNBHXNBgFNBVXNBZDNBsXNBwXNNaRNNJDNNJENNJkNDCJNDVDNGJRNJiDNZJNNsCJNJFNNFSBNFCXNFEPNFLXNFIFQJBFQCaRQJEQQLJDQLJFQIaRQOqXQHaFQHHQQVJXQVJDQhNJQmEIQZJFQsJXQJrFQWbRDJABDBYJDXNFDXCXDXLXDXZDDXsJDQqXDSJFDJCXDEPkDEqXDYmQDpSJDOCkDOGQDHEIDVJDDuDuDWEBDJFgSBNDSBSFSBGHSBIBSBTQSKVYSJQNSJQiSJCXSEqXSJYVSIiJSOMYSHAHSHaQSeCFSepQSegBSHdHSHrFShSJSJuHSJUFSkNRSrSrSWEBSFaHSJFQSFCXSFGDSFYXSFODSFgBSFVXSFhBSFxFSFkFSFbBSFMFCADdCJXBCXaFCXKFCXNFCXCXCXGBCXEJCXYBCXLDCXIBCXOPCXHXCXgBCXhBCXiBCXlDCXcHCJNBCJNFCDCJCDGBCDVXCDhBCDiDCDJdCCmNCpJFCIaRCOqXCHCHCHZJCViJCuCuCmddCJiFCdNBCdHhClEJCnUJCreSCWlgCWTRCFBFCFNBCFYBCFVFCFhFCFdSCFTBCFWDGBNBGBQFGJBCGBEqGBpBGBgQGNBEGNJYGNkOGNJRGDUFGJpQGHaBGJeNGJeEGVBlGVKjGiJDGvJHGsVJGkEBGMIJGWjNGFBFGFCXGFGBGFYXGFpBGFMFEASJEAWpEJNFECJVEIXSEIQJEOqXEOcFEeNcEHEJEHlFEJgFEhlmEmDJEmZJEiMBEUqXEoSREPBFEPXFEPKFEPSFEPEFEPpFEPLXEPIBEJPdEPcFEPTBEJnXEqlHEMpREFCXEFODEFcFYASJYJAFYBaBYBVXYXpFYDhBYCJBYJGFYYbRYeNcYJeVYiIJYZJcYvJgYvJRYJsXYsJFYMYMYreVpBNHpBEJpBwXpQxFpYEJpeNDpJeDpeSFpeCHpHUJpHbBpHcHpmUJpiiJpUJrpsJuplITpFaBpFQqpFGBpFEfpFYBpFpBpFLJpFIDpFgBpFVXpFyQpFuFpFlFpFjDpFnXpFwXpJFMpFTBLXCJLXEFLXhFLXUJLXbFLalmLNJBLSJQLCLCLGJBLLDJLHaFLeNFLeSHLeCXLepFLhaRLZsJLsJDLsJrLocaLlLlLMdbLFNBLFSBLFEHLFkFIBBFIBXFIBaQIBKXIBSFIBpHIBLXIBgBIBhBIBuHIBmXIBiFIBZXIBvFIBbFIBjQIBwXIBWFIKTRIQUJIDGFICjQIYSRIINXIJeCIVaRImEkIZJFIvJRIsJXIdCJIJoRIbBQIjYBIcqXITFVIreVIFKFIFSFIFCJIFGFIFLDIFIBIJFOIFgBIFVXIJFhIFxFIFmXIFdHIFbBIJFrIJFWOBGBOQfXOOKjOUqXOfXBOqXEOcqXORVJOFIBOFlDHBIOHXiFHNTRHCJXHIaRHHJDHHEJHVbRHZJYHbIBHRsJHRkDHWlmgBKFgBSBgBCDgBGHgBpBgBIBgBVJgBuBgBvFgKDTgQVXgDUJgGSJgOqXgmUMgZIJgTUJgWIEgFBFgFNBgFDJgFSFgFGBgFYXgJFOgFgQgFVXgFhBgFbHgJFWVJABVQKcVDgFVOfXVeDFVhaRVmGdViJYVMaRVFNHhBNDhBCXhBEqhBpFhBLXhNJBhSJRheVXhhKEhxlmhZIJhdBQhkIJhbMNhMUJhMZJxNJgxQUJxDEkxDdFxSJRxplmxeSBxeCXxeGFxeYXxepQxegBxWVcxFEQxFLXxFIBxFgBxFxDxFZtxFdcxFbBxFwXyDJXyDlcuASJuDJpuDIBuCpJuGSJuIJFueEFuZIJusJXudWEuoIBuWGJuFBcuFKEuFNFuFQFuFDJuFGJuFVJuFUtuFdHuFTBmBYJmNJYmQhkmLJDmLJomIdXmiJYmvJRmsJRmklmmMBymMuCmclmmcnQiJABiJBNiJBDiBSFiBCJiBEFiBYBiBpFiBLXiBTHiJNciDEfiCZJiECJiJEqiOkHiHKFieNDiHJQieQcieDHieSFieCXieGFieEFieIHiegFihUJixNoioNXiFaBiFKFiFNDiFEPiFYXitFOitFHiFgBiFVEiFmXiFitiFbBiFMFiFrFUCXQUIoQUIJcUHQJUeCEUHwXUUJDUUqXUdWcUcqXUrnQUFNDUFSHUFCFUFEfUFLXUtFOZBXOZXSBZXpFZXVXZEQJZEJkZpDJZOqXZeNHZeCDZUqXZFBQZFEHZFLXvBAFvBKFvBCXvBEPvBpHvBIDvBgFvBuHvQNJvFNFvFGBvFIBvJFcsXCDsXLXsXsXsXlFsXcHsQqXsJQFsEqXseIFsFEHsFjDdBxOdNpRdNJRdEJbdpJRdhZJdnSJdrjNdFNJdFQHdFhNkNJDkYaRkHNRkHSRkVbRkuMRkjSJkcqDoSJFoEiJoYZJoOfXohEBoMGQocqXbBAFbBXFbBaFbBNDbBGBbBLXbBTBbBWDbGJYbIJHbFQqbFpQlDgQlOrFlVJRjGEBjZJRnXvJnXbBnEfHnOPDngJRnxfXnUJWwXEJwNpJwDpBwEfXwrEBMDCJMDGHMDIJMLJDcQGDcQpHcqXccqNFcqCXcFCJRBSBRBGBRBEJRBpQTBNFTBQJTBpBTBVXTFABTFSBTFCFTFGBTFMDrXCJrXLDrDNJrEfHrFQJrFitWNjdWNTR", + // 6-kana words + "AKLJMANOPFASNJIAEJWXAYJNRAIIbRAIcdaAeEfDAgidRAdjNYAMYEJAMIbRAFNJBAFpJFBBIJYBDZJFBSiJhBGdEBBEJfXBEJqXBEJWRBpaUJBLXrXBIYJMBOcfXBeEfFBestXBjNJRBcDJOBFEqXXNvJRXDMBhXCJNYXOAWpXONJWXHDEBXeIaRXhYJDXZJSJXMDJOXcASJXFVJXaBQqXaBZJFasXdQaFSJQaFEfXaFpJHaFOqXKBNSRKXvJBKQJhXKEJQJKEJGFKINJBKIJjNKgJNSKVElmKVhEBKiJGFKlBgJKjnUJKwsJYKMFIJKFNJDKFIJFKFOfXNJBSFNJBCXNBpJFNJBvQNJBMBNJLJXNJOqXNJeCXNJeGFNdsJCNbTKFNwXUJQNFEPQDiJcQDMSJQSFpBQGMQJQJeOcQyCJEQUJEBQJFBrQFEJqDXDJFDJXpBDJXIMDGiJhDIJGRDJeYcDHrDJDVXgFDkAWpDkIgRDjDEqDMvJRDJFNFDJFIBSKclmSJQOFSJQVHSJQjDSJGJBSJGJFSECJoSHEJqSJHTBSJVJDSViJYSZJNBSJsJDSFSJFSFEfXSJFLXCBUJVCJXSBCJXpBCXVJXCJXsXCJXdFCJNJHCLIJgCHiJFCVNJMChCJhCUHEJCsJTRCJdYcCoQJCCFEfXCFIJgCFUJxCFstFGJBaQGJBIDGQJqXGYJNRGJHKFGeQqDGHEJFGJeLXGHIiJGHdBlGUJEBGkIJTGFQPDGJFEqEAGegEJIJBEJVJXEhQJTEiJNcEJZJFEJoEqEjDEqEPDsXEPGJBEPOqXEPeQFEfDiDEJfEFEfepQEfMiJEqXNBEqDIDEqeSFEqVJXEMvJRYXNJDYXEJHYKVJcYYJEBYJeEcYJUqXYFpJFYFstXpAZJMpBSJFpNBNFpeQPDpHLJDpHIJFpHgJFpeitFpHZJFpJFADpFSJFpJFCJpFOqXpFitBpJFZJLXIJFLIJgRLVNJWLVHJMLwNpJLFGJBLFLJDLFOqXLJFUJIBDJXIBGJBIJBYQIJBIBIBOqXIBcqDIEGJFILNJTIIJEBIOiJhIJeNBIJeIBIhiJIIWoTRIJFAHIJFpBIJFuHIFUtFIJFTHOSBYJOEcqXOHEJqOvBpFOkVJrObBVJOncqDOcNJkHhNJRHuHJuHdMhBgBUqXgBsJXgONJBgHNJDgHHJQgJeitgHsJXgJyNagyDJBgZJDrgsVJQgkEJNgkjSJgJFAHgFCJDgFZtMVJXNFVXQfXVJXDJVXoQJVQVJQVDEfXVDvJHVEqNFVeQfXVHpJFVHxfXVVJSRVVmaRVlIJOhCXVJhHjYkhxCJVhWVUJhWiJcxBNJIxeEqDxfXBFxcFEPxFSJFxFYJXyBDQJydaUJyFOPDuYCJYuLvJRuHLJXuZJLDuFOPDuFZJHuFcqXmKHJdmCQJcmOsVJiJAGFitLCFieOfXiestXiZJMEikNJQirXzFiFQqXiFIJFiFZJFiFvtFUHpJFUteIcUteOcUVCJkUhdHcUbEJEUJqXQUMNJhURjYkUFitFZDGJHZJIxDZJVJXZJFDJZJFpQvBNJBvBSJFvJxBrseQqDsVFVJdFLJDkEJNBkmNJYkFLJDoQJOPoGsJRoEAHBoEJfFbBQqDbBZJHbFVJXlFIJBjYIrXjeitcjjCEBjWMNBwXQfXwXOaFwDsJXwCJTRwrCZJMDNJQcDDJFcqDOPRYiJFTBsJXTQIJBTFEfXTFLJDrXEJFrEJXMrFZJFWEJdEWYTlm", + // 7-kana words + "ABCDEFACNJTRAMBDJdAcNJVXBLNJEBXSIdWRXErNJkXYDJMBXZJCJaXMNJaYKKVJKcKDEJqXKDcNJhKVJrNYKbgJVXKFVJSBNBYBwDNJeQfXNJeEqXNhGJWENJFiJRQlIJbEQJfXxDQqXcfXQFNDEJQFwXUJDYcnUJDJIBgQDIUJTRDJFEqDSJQSJFSJQIJFSOPeZtSJFZJHCJXQfXCTDEqFGJBSJFGJBOfXGJBcqXGJHNJDGJRLiJEJfXEqEJFEJPEFpBEJYJBZJFYBwXUJYiJMEBYJZJyTYTONJXpQMFXFpeGIDdpJFstXpJFcPDLBVSJRLHQJqXLJFZJFIJBNJDIJBUqXIBkFDJIJEJPTIYJGWRIJeQPDIJeEfHIJFsJXOqGDSFHXEJqXgJCsJCgGQJqXgdQYJEgFMFNBgJFcqDVJwXUJVJFZJchIgJCCxOEJqXxOwXUJyDJBVRuscisciJBiJBieUtqXiJFDJkiFsJXQUGEZJcUJFsJXZtXIrXZDZJDrZJFNJDZJFstXvJFQqXvJFCJEsJXQJqkhkNGBbDJdTRbYJMEBlDwXUJMEFiJFcfXNJDRcNJWMTBLJXC", + // 8-kana words + "BraFUtHBFSJFdbNBLJXVJQoYJNEBSJBEJfHSJHwXUJCJdAZJMGjaFVJXEJPNJBlEJfFiJFpFbFEJqIJBVJCrIBdHiJhOPFChvJVJZJNJWxGFNIFLueIBQJqUHEJfUFstOZJDrlXEASJRlXVJXSFwVJNJWD", + // 9-kana words + "QJEJNNJDQJEJIBSFQJEJxegBQJEJfHEPSJBmXEJFSJCDEJqXLXNJFQqXIcQsFNJFIFEJqXUJgFsJXIJBUJEJfHNFvJxEqXNJnXUJFQqD", + // 10-kana words + "IJBEJqXZJ" +]; +// Maps each character into its kana value (the index) +const mapping = "~~AzB~X~a~KN~Q~D~S~C~G~E~Y~p~L~I~O~eH~g~V~hxyumi~~U~~Z~~v~~s~~dkoblPjfnqwMcRTr~W~~~F~~~~~Jt"; +let wordlist = null; +function hex(word) { + return hexlify(toUtf8Bytes(word)); +} +const KiYoKu = "0xe3818de38284e3818f"; +const KyoKu = "0xe3818de38283e3818f"; +function loadWords(lang) { + if (wordlist !== null) { + return; + } + wordlist = []; + // Transforms for normalizing (sort is a not quite UTF-8) + let transform = {}; + // Delete the diacritic marks + transform[toUtf8String([227, 130, 154])] = false; + transform[toUtf8String([227, 130, 153])] = false; + // Some simple transforms that sort out most of the order + transform[toUtf8String([227, 130, 133])] = toUtf8String([227, 130, 134]); + transform[toUtf8String([227, 129, 163])] = toUtf8String([227, 129, 164]); + transform[toUtf8String([227, 130, 131])] = toUtf8String([227, 130, 132]); + transform[toUtf8String([227, 130, 135])] = toUtf8String([227, 130, 136]); + // Normalize words using the transform + function normalize(word) { + let result = ""; + for (let i = 0; i < word.length; i++) { + let kana = word[i]; + let target = transform[kana]; + if (target === false) { + continue; + } + if (target) { + kana = target; + } + result += kana; + } + return result; + } + // Sort how the Japanese list is sorted + function sortJapanese(a, b) { + a = normalize(a); + b = normalize(b); + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } + // Load all the words + for (let length = 3; length <= 9; length++) { + let d = data[length - 3]; + for (let offset = 0; offset < d.length; offset += length) { + let word = []; + for (let i = 0; i < length; i++) { + let k = mapping.indexOf(d[offset + i]); + word.push(227); + word.push((k & 0x40) ? 130 : 129); + word.push((k & 0x3f) + 128); + } + wordlist.push(toUtf8String(word)); + } + } + wordlist.sort(sortJapanese); + // For some reason kyoku and kiyoku are flipped in node (!!). + // The order SHOULD be: + // - kyoku + // - kiyoku + if (hex(wordlist[442]) === KiYoKu && hex(wordlist[443]) === KyoKu) { + let tmp = wordlist[442]; + wordlist[442] = wordlist[443]; + wordlist[443] = tmp; + } + if (check(lang) !== "0xcb36b09e6baa935787fd762ce65e80b0c6a8dabdfbc3a7f86ac0e2c4fd111600") { + wordlist = null; + throw new Error("BIP39 Wordlist for ja (Japanese) FAILED"); + } +} +class LangJa extends Wordlist { + constructor() { + super("ja"); + } + getWord(index) { + loadWords(this); + return wordlist[index]; + } + getWordIndex(word) { + loadWords(this); + return wordlist.indexOf(word); + } + split(mnemonic) { + logger.checkNormalize(); + return mnemonic.split(/(?:\u3000| )+/g); + } + join(words) { + return words.join("\u3000"); + } +} +const langJa = new LangJa(); +register(langJa); +export { langJa }; diff --git a/packages/wordlists/lang-ko.d.ts b/packages/wordlists/lib.esm/lang-ko.d.ts similarity index 100% rename from packages/wordlists/lang-ko.d.ts rename to packages/wordlists/lib.esm/lang-ko.d.ts diff --git a/packages/wordlists/lib.esm/lang-ko.js b/packages/wordlists/lib.esm/lang-ko.js new file mode 100644 index 000000000..6d4e5b7bf --- /dev/null +++ b/packages/wordlists/lib.esm/lang-ko.js @@ -0,0 +1,61 @@ +"use strict"; +import { toUtf8String } from "@ethersproject/strings"; +import { check, register, Wordlist } from "./wordlist"; +const data = [ + "OYAa", + "ATAZoATBl3ATCTrATCl8ATDloATGg3ATHT8ATJT8ATJl3ATLlvATLn4ATMT8ATMX8ATMboATMgoAToLbAToMTATrHgATvHnAT3AnAT3JbAT3MTAT8DbAT8JTAT8LmAT8MYAT8MbAT#LnAUHT8AUHZvAUJXrAUJX8AULnrAXJnvAXLUoAXLgvAXMn6AXRg3AXrMbAX3JTAX3QbAYLn3AZLgvAZrSUAZvAcAZ8AaAZ8AbAZ8AnAZ8HnAZ8LgAZ8MYAZ8MgAZ8OnAaAboAaDTrAaFTrAaJTrAaJboAaLVoAaMXvAaOl8AaSeoAbAUoAbAg8AbAl4AbGnrAbMT8AbMXrAbMn4AbQb8AbSV8AbvRlAb8AUAb8AnAb8HgAb8JTAb8NTAb8RbAcGboAcLnvAcMT8AcMX8AcSToAcrAaAcrFnAc8AbAc8MgAfGgrAfHboAfJnvAfLV8AfLkoAfMT8AfMnoAfQb8AfScrAfSgrAgAZ8AgFl3AgGX8AgHZvAgHgrAgJXoAgJX8AgJboAgLZoAgLn4AgOX8AgoATAgoAnAgoCUAgoJgAgoLXAgoMYAgoSeAgrDUAgrJTAhrFnAhrLjAhrQgAjAgoAjJnrAkMX8AkOnoAlCTvAlCV8AlClvAlFg4AlFl6AlFn3AloSnAlrAXAlrAfAlrFUAlrFbAlrGgAlrOXAlvKnAlvMTAl3AbAl3MnAnATrAnAcrAnCZ3AnCl8AnDg8AnFboAnFl3AnHX4AnHbrAnHgrAnIl3AnJgvAnLXoAnLX4AnLbrAnLgrAnLhrAnMXoAnMgrAnOn3AnSbrAnSeoAnvLnAn3OnCTGgvCTSlvCTvAUCTvKnCTvNTCT3CZCT3GUCT3MTCT8HnCUCZrCULf8CULnvCU3HnCU3JUCY6NUCbDb8CbFZoCbLnrCboOTCboScCbrFnCbvLnCb8AgCb8HgCb$LnCkLfoClBn3CloDUDTHT8DTLl3DTSU8DTrAaDTrLXDTrLjDTrOYDTrOgDTvFXDTvFnDT3HUDT3LfDUCT9DUDT4DUFVoDUFV8DUFkoDUGgrDUJnrDULl8DUMT8DUMXrDUMX4DUMg8DUOUoDUOgvDUOg8DUSToDUSZ8DbDXoDbDgoDbGT8DbJn3DbLg3DbLn4DbMXrDbMg8DbOToDboJXGTClvGTDT8GTFZrGTLVoGTLlvGTLl3GTMg8GTOTvGTSlrGToCUGTrDgGTrJYGTrScGTtLnGTvAnGTvQgGUCZrGUDTvGUFZoGUHXrGULnvGUMT8GUoMgGXoLnGXrMXGXrMnGXvFnGYLnvGZOnvGZvOnGZ8LaGZ8LmGbAl3GbDYvGbDlrGbHX3GbJl4GbLV8GbLn3GbMn4GboJTGboRfGbvFUGb3GUGb4JnGgDX3GgFl$GgJlrGgLX6GgLZoGgLf8GgOXoGgrAgGgrJXGgrMYGgrScGgvATGgvOYGnAgoGnJgvGnLZoGnLg3GnLnrGnQn8GnSbrGnrMgHTClvHTDToHTFT3HTQT8HToJTHToJgHTrDUHTrMnHTvFYHTvRfHT8MnHT8SUHUAZ8HUBb4HUDTvHUoMYHXFl6HXJX6HXQlrHXrAUHXrMnHXrSbHXvFYHXvKXHX3LjHX3MeHYvQlHZrScHZvDbHbAcrHbFT3HbFl3HbJT8HbLTrHbMT8HbMXrHbMbrHbQb8HbSX3HboDbHboJTHbrFUHbrHgHbrJTHb8JTHb8MnHb8QgHgAlrHgDT3HgGgrHgHgrHgJTrHgJT8HgLX@HgLnrHgMT8HgMX8HgMboHgOnrHgQToHgRg3HgoHgHgrCbHgrFnHgrLVHgvAcHgvAfHnAloHnCTrHnCnvHnGTrHnGZ8HnGnvHnJT8HnLf8HnLkvHnMg8HnRTrITvFUITvFnJTAXrJTCV8JTFT3JTFT8JTFn4JTGgvJTHT8JTJT8JTJXvJTJl3JTJnvJTLX4JTLf8JTLhvJTMT8JTMXrJTMnrJTObrJTQT8JTSlvJT8DUJT8FkJT8MTJT8OXJT8OgJT8QUJT8RfJUHZoJXFT4JXFlrJXGZ8JXGnrJXLV8JXLgvJXMXoJXMX3JXNboJXPlvJXoJTJXoLkJXrAXJXrHUJXrJgJXvJTJXvOnJX4KnJYAl3JYJT8JYLhvJYQToJYrQXJY6NUJbAl3JbCZrJbDloJbGT8JbGgrJbJXvJbJboJbLf8JbLhrJbLl3JbMnvJbRg8JbSZ8JboDbJbrCZJbrSUJb3KnJb8LnJfRn8JgAXrJgCZrJgDTrJgGZrJgGZ8JgHToJgJT8JgJXoJgJgvJgLX4JgLZ3JgLZ8JgLn4JgMgrJgMn4JgOgvJgPX6JgRnvJgSToJgoCZJgoJbJgoMYJgrJXJgrJgJgrLjJg6MTJlCn3JlGgvJlJl8Jl4AnJl8FnJl8HgJnAToJnATrJnAbvJnDUoJnGnrJnJXrJnJXvJnLhvJnLnrJnLnvJnMToJnMT8JnMXvJnMX3JnMg8JnMlrJnMn4JnOX8JnST4JnSX3JnoAgJnoAnJnoJTJnoObJnrAbJnrAkJnrHnJnrJTJnrJYJnrOYJnrScJnvCUJnvFaJnvJgJnvJnJnvOYJnvQUJnvRUJn3FnJn3JTKnFl3KnLT6LTDlvLTMnoLTOn3LTRl3LTSb4LTSlrLToAnLToJgLTrAULTrAcLTrCULTrHgLTrMgLT3JnLULnrLUMX8LUoJgLVATrLVDTrLVLb8LVoJgLV8MgLV8RTLXDg3LXFlrLXrCnLXrLXLX3GTLX4GgLX4OYLZAXrLZAcrLZAgrLZAhrLZDXyLZDlrLZFbrLZFl3LZJX6LZJX8LZLc8LZLnrLZSU8LZoJTLZoJnLZrAgLZrAnLZrJYLZrLULZrMgLZrSkLZvAnLZvGULZvJeLZvOTLZ3FZLZ4JXLZ8STLZ8ScLaAT3LaAl3LaHT8LaJTrLaJT8LaJXrLaJgvLaJl4LaLVoLaMXrLaMXvLaMX8LbClvLbFToLbHlrLbJn4LbLZ3LbLhvLbMXrLbMnoLbvSULcLnrLc8HnLc8MTLdrMnLeAgoLeOgvLeOn3LfAl3LfLnvLfMl3LfOX8Lf8AnLf8JXLf8LXLgJTrLgJXrLgJl8LgMX8LgRZrLhCToLhrAbLhrFULhrJXLhvJYLjHTrLjHX4LjJX8LjLhrLjSX3LjSZ4LkFX4LkGZ8LkGgvLkJTrLkMXoLkSToLkSU8LkSZ8LkoOYLl3FfLl3MgLmAZrLmCbrLmGgrLmHboLmJnoLmJn3LmLfoLmLhrLmSToLnAX6LnAb6LnCZ3LnCb3LnDTvLnDb8LnFl3LnGnrLnHZvLnHgvLnITvLnJT8LnJX8LnJlvLnLf8LnLg6LnLhvLnLnoLnMXrLnMg8LnQlvLnSbrLnrAgLnrAnLnrDbLnrFkLnrJdLnrMULnrOYLnrSTLnvAnLnvDULnvHgLnvOYLnvOnLn3GgLn4DULn4JTLn4JnMTAZoMTAloMTDb8MTFT8MTJnoMTJnrMTLZrMTLhrMTLkvMTMX8MTRTrMToATMTrDnMTrOnMT3JnMT4MnMT8FUMT8FaMT8FlMT8GTMT8GbMT8GnMT8HnMT8JTMT8JbMT8OTMUCl8MUJTrMUJU8MUMX8MURTrMUSToMXAX6MXAb6MXCZoMXFXrMXHXrMXLgvMXOgoMXrAUMXrAnMXrHgMXrJYMXrJnMXrMTMXrMgMXrOYMXrSZMXrSgMXvDUMXvOTMX3JgMX3OTMX4JnMX8DbMX8FnMX8HbMX8HgMX8HnMX8LbMX8MnMX8OnMYAb8MYGboMYHTvMYHX4MYLTrMYLnvMYMToMYOgvMYRg3MYSTrMbAToMbAXrMbAl3MbAn8MbGZ8MbJT8MbJXrMbMXvMbMX8MbMnoMbrMUMb8AfMb8FbMb8FkMcJXoMeLnrMgFl3MgGTvMgGXoMgGgrMgGnrMgHT8MgHZrMgJnoMgLnrMgLnvMgMT8MgQUoMgrHnMgvAnMg8HgMg8JYMg8LfMloJnMl8ATMl8AXMl8JYMnAToMnAT4MnAZ8MnAl3MnAl4MnCl8MnHT8MnHg8MnJnoMnLZoMnLhrMnMXoMnMX3MnMnrMnOgvMnrFbMnrFfMnrFnMnrNTMnvJXNTMl8OTCT3OTFV8OTFn3OTHZvOTJXrOTOl3OT3ATOT3JUOT3LZOT3LeOT3MbOT8ATOT8AbOT8AgOT8MbOUCXvOUMX3OXHXvOXLl3OXrMUOXvDbOX6NUOX8JbOYFZoOYLbrOYLkoOYMg8OYSX3ObHTrObHT4ObJgrObLhrObMX3ObOX8Ob8FnOeAlrOeJT8OeJXrOeJnrOeLToOeMb8OgJXoOgLXoOgMnrOgOXrOgOloOgoAgOgoJbOgoMYOgoSTOg8AbOjLX4OjMnoOjSV8OnLVoOnrAgOn3DUPXQlrPXvFXPbvFTPdAT3PlFn3PnvFbQTLn4QToAgQToMTQULV8QURg8QUoJnQXCXvQbFbrQb8AaQb8AcQb8FbQb8MYQb8ScQeAlrQeLhrQjAn3QlFXoQloJgQloSnRTLnvRTrGURTrJTRUJZrRUoJlRUrQnRZrLmRZrMnRZrSnRZ8ATRZ8JbRZ8ScRbMT8RbST3RfGZrRfMX8RfMgrRfSZrRnAbrRnGT8RnvJgRnvLfRnvMTRn8AaSTClvSTJgrSTOXrSTRg3STRnvSToAcSToAfSToAnSToHnSToLjSToMTSTrAaSTrEUST3BYST8AgST8LmSUAZvSUAgrSUDT4SUDT8SUGgvSUJXoSUJXvSULTrSU8JTSU8LjSV8AnSV8JgSXFToSXLf8SYvAnSZrDUSZrMUSZrMnSZ8HgSZ8JTSZ8JgSZ8MYSZ8QUSaQUoSbCT3SbHToSbQYvSbSl4SboJnSbvFbSb8HbSb8JgSb8OTScGZrScHgrScJTvScMT8ScSToScoHbScrMTScvAnSeAZrSeAcrSeHboSeJUoSeLhrSeMT8SeMXrSe6JgSgHTrSkJnoSkLnvSk8CUSlFl3SlrSnSl8GnSmAboSmGT8SmJU8", + "ATLnDlATrAZoATrJX4ATrMT8ATrMX4ATrRTrATvDl8ATvJUoATvMl8AT3AToAT3MX8AT8CT3AT8DT8AT8HZrAT8HgoAUAgFnAUCTFnAXoMX8AXrAT8AXrGgvAXrJXvAXrOgoAXvLl3AZvAgoAZvFbrAZvJXoAZvJl8AZvJn3AZvMX8AZvSbrAZ8FZoAZ8LZ8AZ8MU8AZ8OTvAZ8SV8AZ8SX3AbAgFZAboJnoAbvGboAb8ATrAb8AZoAb8AgrAb8Al4Ab8Db8Ab8JnoAb8LX4Ab8LZrAb8LhrAb8MT8Ab8OUoAb8Qb8Ab8ST8AcrAUoAcrAc8AcrCZ3AcrFT3AcrFZrAcrJl4AcrJn3AcrMX3AcrOTvAc8AZ8Ac8MT8AfAcJXAgoFn4AgoGgvAgoGnrAgoLc8AgoMXoAgrLnrAkrSZ8AlFXCTAloHboAlrHbrAlrLhrAlrLkoAl3CZrAl3LUoAl3LZrAnrAl4AnrMT8An3HT4BT3IToBX4MnvBb!Ln$CTGXMnCToLZ4CTrHT8CT3JTrCT3RZrCT#GTvCU6GgvCU8Db8CU8GZrCU8HT8CboLl3CbrGgrCbrMU8Cb8DT3Cb8GnrCb8LX4Cb8MT8Cb8ObrCgrGgvCgrKX4Cl8FZoDTrAbvDTrDboDTrGT6DTrJgrDTrMX3DTrRZrDTrRg8DTvAVvDTvFZoDT3DT8DT3Ln3DT4HZrDT4MT8DT8AlrDT8MT8DUAkGbDUDbJnDYLnQlDbDUOYDbMTAnDbMXSnDboAT3DboFn4DboLnvDj6JTrGTCgFTGTGgFnGTJTMnGTLnPlGToJT8GTrCT3GTrLVoGTrLnvGTrMX3GTrMboGTvKl3GZClFnGZrDT3GZ8DTrGZ8FZ8GZ8MXvGZ8On8GZ8ST3GbCnQXGbMbFnGboFboGboJg3GboMXoGb3JTvGb3JboGb3Mn6Gb3Qb8GgDXLjGgMnAUGgrDloGgrHX4GgrSToGgvAXrGgvAZvGgvFbrGgvLl3GgvMnvGnDnLXGnrATrGnrMboGnuLl3HTATMnHTAgCnHTCTCTHTrGTvHTrHTvHTrJX8HTrLl8HTrMT8HTrMgoHTrOTrHTuOn3HTvAZrHTvDTvHTvGboHTvJU8HTvLl3HTvMXrHTvQb4HT4GT6HT4JT8HT4Jb#HT8Al3HT8GZrHT8GgrHT8HX4HT8Jb8HT8JnoHT8LTrHT8LgvHT8SToHT8SV8HUoJUoHUoJX8HUoLnrHXrLZoHXvAl3HX3LnrHX4FkvHX4LhrHX4MXoHX4OnoHZrAZ8HZrDb8HZrGZ8HZrJnrHZvGZ8HZvLnvHZ8JnvHZ8LhrHbCXJlHbMTAnHboJl4HbpLl3HbrJX8HbrLnrHbrMnvHbvRYrHgoSTrHgrFV8HgrGZ8HgrJXoHgrRnvHgvBb!HgvGTrHgvHX4HgvHn!HgvLTrHgvSU8HnDnLbHnFbJbHnvDn8Hn6GgvHn!BTvJTCTLnJTQgFnJTrAnvJTrLX4JTrOUoJTvFn3JTvLnrJTvNToJT3AgoJT3Jn4JT3LhvJT3ObrJT8AcrJT8Al3JT8JT8JT8JnoJT8LX4JT8LnrJT8MX3JT8Rg3JT8Sc8JUoBTvJU8AToJU8GZ8JU8GgvJU8JTrJU8JXrJU8JnrJU8LnvJU8ScvJXHnJlJXrGgvJXrJU8JXrLhrJXrMT8JXrMXrJXrQUoJXvCTvJXvGZ8JXvGgrJXvQT8JX8Ab8JX8DT8JX8GZ8JX8HZvJX8LnrJX8MT8JX8MXoJX8MnvJX8ST3JYGnCTJbAkGbJbCTAnJbLTAcJboDT3JboLb6JbrAnvJbrCn3JbrDl8JbrGboJbrIZoJbrJnvJbrMnvJbrQb4Jb8RZrJeAbAnJgJnFbJgScAnJgrATrJgvHZ8JgvMn4JlJlFbJlLiQXJlLjOnJlRbOlJlvNXoJlvRl3Jl4AcrJl8AUoJl8MnrJnFnMlJnHgGbJnoDT8JnoFV8JnoGgvJnoIT8JnoQToJnoRg3JnrCZ3JnrGgrJnrHTvJnrLf8JnrOX8JnvAT3JnvFZoJnvGT8JnvJl4JnvMT8JnvMX8JnvOXrJnvPX6JnvSX3JnvSZrJn3MT8Jn3MX8Jn3RTrLTATKnLTJnLTLTMXKnLTRTQlLToGb8LTrAZ8LTrCZ8LTrDb8LTrHT8LT3PX6LT4FZoLT$CTvLT$GgrLUvHX3LVoATrLVoAgoLVoJboLVoMX3LVoRg3LV8CZ3LV8FZoLV8GTvLXrDXoLXrFbrLXvAgvLXvFlrLXvLl3LXvRn6LX4Mb8LX8GT8LYCXMnLYrMnrLZoSTvLZrAZvLZrAloLZrFToLZrJXvLZrJboLZrJl4LZrLnrLZrMT8LZrOgvLZrRnvLZrST4LZvMX8LZvSlvLZ8AgoLZ8CT3LZ8JT8LZ8LV8LZ8LZoLZ8Lg8LZ8SV8LZ8SbrLZ$HT8LZ$Mn4La6CTvLbFbMnLbRYFTLbSnFZLboJT8LbrAT9LbrGb3LbrQb8LcrJX8LcrMXrLerHTvLerJbrLerNboLgrDb8LgrGZ8LgrHTrLgrMXrLgrSU8LgvJTrLgvLl3Lg6Ll3LhrLnrLhrMT8LhvAl4LiLnQXLkoAgrLkoJT8LkoJn4LlrSU8Ll3FZoLl3HTrLl3JX8Ll3JnoLl3LToLmLeFbLnDUFbLnLVAnLnrATrLnrAZoLnrAb8LnrAlrLnrGgvLnrJU8LnrLZrLnrLhrLnrMb8LnrOXrLnrSZ8LnvAb4LnvDTrLnvDl8LnvHTrLnvHbrLnvJT8LnvJU8LnvJbrLnvLhvLnvMX8LnvMb8LnvNnoLnvSU8Ln3Al3Ln4FZoLn4GT6Ln4JgvLn4LhrLn4MT8Ln4SToMToCZrMToJX8MToLX4MToLf8MToRg3MTrEloMTvGb6MT3BTrMT3Lb6MT8AcrMT8AgrMT8GZrMT8JnoMT8LnrMT8MX3MUOUAnMXAbFnMXoAloMXoJX8MXoLf8MXoLl8MXrAb8MXrDTvMXrGT8MXrGgrMXrHTrMXrLf8MXrMU8MXrOXvMXrQb8MXvGT8MXvHTrMXvLVoMX3AX3MX3Jn3MX3LhrMX3MX3MX4AlrMX4OboMX8GTvMX8GZrMX8GgrMX8JT8MX8JX8MX8LhrMX8MT8MYDUFbMYMgDbMbGnFfMbvLX4MbvLl3Mb8Mb8Mb8ST4MgGXCnMg8ATrMg8AgoMg8CZrMg8DTrMg8DboMg8HTrMg8JgrMg8LT8MloJXoMl8AhrMl8JT8MnLgAUMnoJXrMnoLX4MnoLhrMnoMT8MnrAl4MnrDb8MnrOTvMnrOgvMnrQb8MnrSU8MnvGgrMnvHZ8Mn3MToMn4DTrMn4LTrMn4Mg8NnBXAnOTFTFnOToAToOTrGgvOTrJX8OT3JXoOT6MTrOT8GgrOT8HTpOT8MToOUoHT8OUoJT8OUoLn3OXrAgoOXrDg8OXrMT8OXvSToOX6CTvOX8CZrOX8OgrOb6HgvOb8AToOb8MT8OcvLZ8OgvAlrOgvHTvOgvJTrOgvJnrOgvLZrOgvLn4OgvMT8OgvRTrOg8AZoOg8DbvOnrOXoOnvJn4OnvLhvOnvRTrOn3GgoOn3JnvOn6JbvOn8OTrPTGYFTPbBnFnPbGnDnPgDYQTPlrAnvPlrETvPlrLnvPlrMXvPlvFX4QTMTAnQTrJU8QYCnJlQYJlQlQbGTQbQb8JnrQb8LZoQb8LnvQb8MT8Qb8Ml8Qb8ST4QloAl4QloHZvQloJX8QloMn8QnJZOlRTrAZvRTrDTrRTvJn4RTvLhvRT4Jb8RZrAZrRZ8AkrRZ8JU8RZ8LV8RZ8LnvRbJlQXRg3GboRg3MnvRg8AZ8Rg8JboRg8Jl4RnLTCbRnvFl3RnvQb8SToAl4SToCZrSToFZoSToHXrSToJU8SToJgvSToJl4SToLhrSToMX3STrAlvSTrCT9STrCgrSTrGgrSTrHXrSTrHboSTrJnoSTrNboSTvLnrST4AZoST8Ab8ST8JT8SUoJn3SU6HZ#SU6JTvSU8Db8SU8HboSU8LgrSV8JT8SZrAcrSZrAl3SZrJT8SZrJnvSZrMT8SZvLUoSZ4FZoSZ8JnoSZ8RZrScoLnrScoMT8ScoMX8ScrAT4ScrAZ8ScrLZ8ScrLkvScvDb8ScvLf8ScvNToSgrFZrShvKnrSloHUoSloLnrSlrMXoSl8HgrSmrJUoSn3BX6", + "ATFlOn3ATLgrDYAT4MTAnAT8LTMnAYJnRTrAbGgJnrAbLV8LnAbvNTAnAeFbLg3AgOYMXoAlQbFboAnDboAfAnJgoJTBToDgAnBUJbAl3BboDUAnCTDlvLnCTFTrSnCYoQTLnDTwAbAnDUDTrSnDUHgHgrDX8LXFnDbJXAcrETvLTLnGTFTQbrGTMnGToGT3DUFbGUJlPX3GbQg8LnGboJbFnGb3GgAYGgAg8ScGgMbAXrGgvAbAnGnJTLnvGnvATFgHTDT6ATHTrDlJnHYLnMn8HZrSbJTHZ8LTFnHbFTJUoHgSeMT8HgrLjAnHgvAbAnHlFUrDlHnDgvAnHnHTFT3HnQTGnrJTAaMXvJTGbCn3JTOgrAnJXvAXMnJbMg8SnJbMnRg3Jb8LTMnJnAl3OnJnGYrQlJnJlQY3LTDlCn3LTJjLg3LTLgvFXLTMg3GTLV8HUOgLXFZLg3LXNXrMnLX8QXFnLX9AlMYLYLXPXrLZAbJU8LZDUJU8LZMXrSnLZ$AgFnLaPXrDULbFYrMnLbMn8LXLboJgJgLeFbLg3LgLZrSnLgOYAgoLhrRnJlLkCTrSnLkOnLhrLnFX%AYLnFZoJXLnHTvJbLnLloAbMTATLf8MTHgJn3MTMXrAXMT3MTFnMUITvFnMXFX%AYMXMXvFbMXrFTDbMYAcMX3MbLf8SnMb8JbFnMgMXrMTMgvAXFnMgvGgCmMnAloSnMnFnJTrOXvMXSnOX8HTMnObJT8ScObLZFl3ObMXCZoPTLgrQXPUFnoQXPU3RXJlPX3RkQXPbrJXQlPlrJbFnQUAhrDbQXGnCXvQYLnHlvQbLfLnvRTOgvJbRXJYrQlRYLnrQlRbLnrQlRlFT8JlRlFnrQXSTClCn3STHTrAnSTLZQlrSTMnGTrSToHgGbSTrGTDnSTvGXCnST3HgFbSU3HXAXSbAnJn3SbFT8LnScLfLnv", + "AT3JgJX8AT8FZoSnAT8JgFV8AT8LhrDbAZ8JT8DbAb8GgLhrAb8SkLnvAe8MT8SnAlMYJXLVAl3GYDTvAl3LfLnvBUDTvLl3CTOn3HTrCT3DUGgrCU8MT8AbCbFTrJUoCgrDb8MTDTLV8JX8DTLnLXQlDT8LZrSnDUQb8FZ8DUST4JnvDb8ScOUoDj6GbJl4GTLfCYMlGToAXvFnGboAXvLnGgAcrJn3GgvFnSToGnLf8JnvGn#HTDToHTLnFXJlHTvATFToHTvHTDToHTvMTAgoHT3STClvHT4AlFl6HT8HTDToHUoDgJTrHUoScMX3HbRZrMXoHboJg8LTHgDb8JTrHgMToLf8HgvLnLnoHnHn3HT4Hn6MgvAnJTJU8ScvJT3AaQT8JT8HTrAnJXrRg8AnJbAloMXoJbrATFToJbvMnoSnJgDb6GgvJgDb8MXoJgSX3JU8JguATFToJlPYLnQlJlQkDnLbJlQlFYJlJl8Lf8OTJnCTFnLbJnLTHXMnJnLXGXCnJnoFfRg3JnrMYRg3Jn3HgFl3KT8Dg8LnLTRlFnPTLTvPbLbvLVoSbrCZLXMY6HT3LXNU7DlrLXNXDTATLX8DX8LnLZDb8JU8LZMnoLhrLZSToJU8LZrLaLnrLZvJn3SnLZ8LhrSnLaJnoMT8LbFlrHTvLbrFTLnrLbvATLlvLb6OTFn3LcLnJZOlLeAT6Mn4LeJT3ObrLg6LXFlrLhrJg8LnLhvDlPX4LhvLfLnvLj6JTFT3LnFbrMXoLnQluCTvLnrQXCY6LnvLfLnvLnvMgLnvLnvSeLf8MTMbrJn3MT3JgST3MT8AnATrMT8LULnrMUMToCZrMUScvLf8MXoDT8SnMX6ATFToMX8AXMT8MX8FkMT8MX8HTrDUMX8ScoSnMYJT6CTvMgAcrMXoMg8SToAfMlvAXLg3MnFl3AnvOT3AnFl3OUoATHT8OU3RnLXrOXrOXrSnObPbvFn6Og8HgrSnOg8OX8DbPTvAgoJgPU3RYLnrPXrDnJZrPb8CTGgvPlrLTDlvPlvFUJnoQUvFXrQlQeMnoAl3QlrQlrSnRTFTrJUoSTDlLiLXSTFg6HT3STJgoMn4STrFTJTrSTrLZFl3ST4FnMXoSUrDlHUoScvHTvSnSfLkvMXo", + "AUoAcrMXoAZ8HboAg8AbOg6ATFgAg8AloMXoAl3AT8JTrAl8MX8MXoCT3SToJU8Cl8Db8MXoDT8HgrATrDboOT8MXoGTOTrATMnGT8LhrAZ8GnvFnGnQXHToGgvAcrHTvAXvLl3HbrAZoMXoHgBlFXLg3HgMnFXrSnHgrSb8JUoHn6HT8LgvITvATrJUoJUoLZrRnvJU8HT8Jb8JXvFX8QT8JXvLToJTrJYrQnGnQXJgrJnoATrJnoJU8ScvJnvMnvMXoLTCTLgrJXLTJlRTvQlLbRnJlQYvLbrMb8LnvLbvFn3RnoLdCVSTGZrLeSTvGXCnLg3MnoLn3MToLlrETvMT8SToAl3MbrDU6GTvMb8LX4LhrPlrLXGXCnSToLf8Rg3STrDb8LTrSTvLTHXMnSb3RYLnMnSgOg6ATFg", + "HUDlGnrQXrJTrHgLnrAcJYMb8DULc8LTvFgGnCk3Mg8JbAnLX4QYvFYHnMXrRUoJnGnvFnRlvFTJlQnoSTrBXHXrLYSUJgLfoMT8Se8DTrHbDb", + "AbDl8SToJU8An3RbAb8ST8DUSTrGnrAgoLbFU6Db8LTrMg8AaHT8Jb8ObDl8SToJU8Pb3RlvFYoJl" +]; +let codes = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*"; +function getHangul(code) { + if (code >= 40) { + code = code + 168 - 40; + } + else if (code >= 19) { + code = code + 97 - 19; + } + return toUtf8String([225, (code >> 6) + 132, (code & 0x3f) + 128]); +} +let wordlist = null; +function loadWords(lang) { + if (wordlist != null) { + return; + } + wordlist = []; + data.forEach((data, length) => { + length += 4; + for (let i = 0; i < data.length; i += length) { + let word = ""; + for (let j = 0; j < length; j++) { + word += getHangul(codes.indexOf(data[i + j])); + } + wordlist.push(word); + } + }); + wordlist.sort(); + if (check(lang) !== "0xf9eddeace9c5d3da9c93cf7d3cd38f6a13ed3affb933259ae865714e8a3ae71a") { + wordlist = null; + throw new Error("BIP39 Wordlist for ko (Korean) FAILED"); + } +} +class LangKo extends Wordlist { + constructor() { + super("ko"); + } + getWord(index) { + loadWords(this); + return wordlist[index]; + } + getWordIndex(word) { + loadWords(this); + return wordlist.indexOf(word); + } +} +const langKo = new LangKo(); +register(langKo); +export { langKo }; diff --git a/packages/wordlists/lang-zh.d.ts b/packages/wordlists/lib.esm/lang-zh.d.ts similarity index 100% rename from packages/wordlists/lang-zh.d.ts rename to packages/wordlists/lib.esm/lang-zh.d.ts diff --git a/packages/wordlists/lib.esm/lang-zh.js b/packages/wordlists/lib.esm/lang-zh.js new file mode 100644 index 000000000..baffc7ff3 --- /dev/null +++ b/packages/wordlists/lib.esm/lang-zh.js @@ -0,0 +1,65 @@ +"use strict"; +import { toUtf8String } from "@ethersproject/strings"; +import { check, register, Wordlist } from "./wordlist"; +const data = "}aE#4A=Yv&co#4N#6G=cJ&SM#66|/Z#4t&kn~46#4K~4q%b9=IR#7l,mB#7W_X2*dl}Uo~7s}Uf&Iw#9c&cw~6O&H6&wx&IG%v5=IQ~8a&Pv#47$PR&50%Ko&QM&3l#5f,D9#4L|/H&tQ;v0~6n]nN> 2), + 128 + codes.indexOf(data[i * 3 + 1]), + 128 + codes.indexOf(data[i * 3 + 2]), + ]; + if (lang.locale === "zh_tw") { + let common = s % 4; + for (let i = common; i < 3; i++) { + bytes[i] = codes.indexOf(deltaData[deltaOffset++]) + ((i == 0) ? 228 : 128); + } + } + wordlist[lang.locale].push(toUtf8String(bytes)); + } + if (check(lang) !== Checks[lang.locale]) { + wordlist[lang.locale] = null; + throw new Error("BIP39 Wordlist for " + lang.locale + " (Chinese) FAILED"); + } +} +class LangZh extends Wordlist { + constructor(country) { + super("zh_" + country); + } + getWord(index) { + loadWords(this); + return wordlist[this.locale][index]; + } + getWordIndex(word) { + loadWords(this); + return wordlist[this.locale].indexOf(word); + } + split(mnemonic) { + mnemonic = mnemonic.replace(/(?:\u3000| )+/g, ""); + return mnemonic.split(""); + } +} +const langZhCn = new LangZh("cn"); +register(langZhCn); +register(langZhCn, "zh"); +const langZhTw = new LangZh("tw"); +register(langZhTw); +export { langZhCn, langZhTw }; diff --git a/packages/wordlists/wordlist.d.ts b/packages/wordlists/lib.esm/wordlist.d.ts similarity index 100% rename from packages/wordlists/wordlist.d.ts rename to packages/wordlists/lib.esm/wordlist.d.ts diff --git a/packages/wordlists/lib.esm/wordlist.js b/packages/wordlists/lib.esm/wordlist.js new file mode 100644 index 000000000..60688b6db --- /dev/null +++ b/packages/wordlists/lib.esm/wordlist.js @@ -0,0 +1,52 @@ +"use strict"; +// This gets overriddenby gulp during bip39-XX +let exportWordlist = false; +import { id } from "@ethersproject/hash"; +import { defineReadOnly } from "@ethersproject/properties"; +import { Logger } from "@ethersproject/logger"; +import { version } from "./_version"; +const logger = new Logger(version); +export function check(wordlist) { + let words = []; + for (let i = 0; i < 2048; i++) { + let word = wordlist.getWord(i); + if (i !== wordlist.getWordIndex(word)) { + return "0x"; + } + words.push(word); + } + return id(words.join("\n") + "\n"); +} +export class Wordlist { + constructor(locale) { + logger.checkAbstract(new.target, Wordlist); + defineReadOnly(this, "locale", locale); + } + // Subclasses may override this + split(mnemonic) { + return mnemonic.toLowerCase().split(/ +/g); + } + // Subclasses may override this + join(words) { + return words.join(" "); + } +} +export function register(lang, name) { + if (!name) { + name = lang.locale; + } + if (exportWordlist) { + let g = global; + if (!(g.wordlists)) { + defineReadOnly(g, "wordlists", {}); + } + if (!g.wordlists[name]) { + defineReadOnly(g.wordlists, name, lang); + } + if (g.ethers && g.ethers.wordlists) { + if (!g.ethers.wordlists[name]) { + defineReadOnly(g.ethers.wordlists, name, lang); + } + } + } +} diff --git a/packages/wordlists/lib/_version.d.ts b/packages/wordlists/lib/_version.d.ts new file mode 100644 index 000000000..1265465ce --- /dev/null +++ b/packages/wordlists/lib/_version.d.ts @@ -0,0 +1 @@ +export declare const version = "wordlists/5.0.0-beta.127"; diff --git a/packages/wordlists/_version.js b/packages/wordlists/lib/_version.js similarity index 100% rename from packages/wordlists/_version.js rename to packages/wordlists/lib/_version.js diff --git a/packages/wordlists/lib/browser.d.ts b/packages/wordlists/lib/browser.d.ts new file mode 100644 index 000000000..10264f51b --- /dev/null +++ b/packages/wordlists/lib/browser.d.ts @@ -0,0 +1,5 @@ +import { Wordlist } from "./wordlist"; +declare const wordlists: { + en: Wordlist; +}; +export { Wordlist, wordlists }; diff --git a/packages/wordlists/browser.js b/packages/wordlists/lib/browser.js similarity index 100% rename from packages/wordlists/browser.js rename to packages/wordlists/lib/browser.js diff --git a/packages/wordlists/lib/index.d.ts b/packages/wordlists/lib/index.d.ts new file mode 100644 index 000000000..aa8ebdc7c --- /dev/null +++ b/packages/wordlists/lib/index.d.ts @@ -0,0 +1,5 @@ +import { Wordlist } from "./wordlist"; +declare const wordlists: { + [locale: string]: Wordlist; +}; +export { Wordlist, wordlists }; diff --git a/packages/wordlists/index.js b/packages/wordlists/lib/index.js similarity index 100% rename from packages/wordlists/index.js rename to packages/wordlists/lib/index.js diff --git a/packages/wordlists/lib/lang-en.d.ts b/packages/wordlists/lib/lang-en.d.ts new file mode 100644 index 000000000..1b1ce7aa1 --- /dev/null +++ b/packages/wordlists/lib/lang-en.d.ts @@ -0,0 +1,8 @@ +import { Wordlist } from "./wordlist"; +declare class LangEn extends Wordlist { + constructor(); + getWord(index: number): string; + getWordIndex(word: string): number; +} +declare const langEn: LangEn; +export { langEn }; diff --git a/packages/wordlists/lang-en.js b/packages/wordlists/lib/lang-en.js similarity index 100% rename from packages/wordlists/lang-en.js rename to packages/wordlists/lib/lang-en.js diff --git a/packages/wordlists/lib/lang-es.d.ts b/packages/wordlists/lib/lang-es.d.ts new file mode 100644 index 000000000..86414a956 --- /dev/null +++ b/packages/wordlists/lib/lang-es.d.ts @@ -0,0 +1,8 @@ +import { Wordlist } from "./wordlist"; +declare class LangEs extends Wordlist { + constructor(); + getWord(index: number): string; + getWordIndex(word: string): number; +} +declare const langEs: LangEs; +export { langEs }; diff --git a/packages/wordlists/lang-es.js b/packages/wordlists/lib/lang-es.js similarity index 100% rename from packages/wordlists/lang-es.js rename to packages/wordlists/lib/lang-es.js diff --git a/packages/wordlists/lib/lang-fr.d.ts b/packages/wordlists/lib/lang-fr.d.ts new file mode 100644 index 000000000..a7155a56a --- /dev/null +++ b/packages/wordlists/lib/lang-fr.d.ts @@ -0,0 +1,8 @@ +import { Wordlist } from "./wordlist"; +declare class LangFr extends Wordlist { + constructor(); + getWord(index: number): string; + getWordIndex(word: string): number; +} +declare const langFr: LangFr; +export { langFr }; diff --git a/packages/wordlists/lang-fr.js b/packages/wordlists/lib/lang-fr.js similarity index 100% rename from packages/wordlists/lang-fr.js rename to packages/wordlists/lib/lang-fr.js diff --git a/packages/wordlists/lib/lang-it.d.ts b/packages/wordlists/lib/lang-it.d.ts new file mode 100644 index 000000000..05de0f735 --- /dev/null +++ b/packages/wordlists/lib/lang-it.d.ts @@ -0,0 +1,8 @@ +import { Wordlist } from "./wordlist"; +declare class LangIt extends Wordlist { + constructor(); + getWord(index: number): string; + getWordIndex(word: string): number; +} +declare const langIt: LangIt; +export { langIt }; diff --git a/packages/wordlists/lang-it.js b/packages/wordlists/lib/lang-it.js similarity index 100% rename from packages/wordlists/lang-it.js rename to packages/wordlists/lib/lang-it.js diff --git a/packages/wordlists/lib/lang-ja.d.ts b/packages/wordlists/lib/lang-ja.d.ts new file mode 100644 index 000000000..860a96ef9 --- /dev/null +++ b/packages/wordlists/lib/lang-ja.d.ts @@ -0,0 +1,10 @@ +import { Wordlist } from "./wordlist"; +declare class LangJa extends Wordlist { + constructor(); + getWord(index: number): string; + getWordIndex(word: string): number; + split(mnemonic: string): Array; + join(words: Array): string; +} +declare const langJa: LangJa; +export { langJa }; diff --git a/packages/wordlists/lang-ja.js b/packages/wordlists/lib/lang-ja.js similarity index 100% rename from packages/wordlists/lang-ja.js rename to packages/wordlists/lib/lang-ja.js diff --git a/packages/wordlists/lib/lang-ko.d.ts b/packages/wordlists/lib/lang-ko.d.ts new file mode 100644 index 000000000..3edbaea31 --- /dev/null +++ b/packages/wordlists/lib/lang-ko.d.ts @@ -0,0 +1,8 @@ +import { Wordlist } from "./wordlist"; +declare class LangKo extends Wordlist { + constructor(); + getWord(index: number): string; + getWordIndex(word: string): number; +} +declare const langKo: LangKo; +export { langKo }; diff --git a/packages/wordlists/lang-ko.js b/packages/wordlists/lib/lang-ko.js similarity index 100% rename from packages/wordlists/lang-ko.js rename to packages/wordlists/lib/lang-ko.js diff --git a/packages/wordlists/lib/lang-zh.d.ts b/packages/wordlists/lib/lang-zh.d.ts new file mode 100644 index 000000000..3db0f3028 --- /dev/null +++ b/packages/wordlists/lib/lang-zh.d.ts @@ -0,0 +1,10 @@ +import { Wordlist } from "./wordlist"; +declare class LangZh extends Wordlist { + constructor(country: string); + getWord(index: number): string; + getWordIndex(word: string): number; + split(mnemonic: string): Array; +} +declare const langZhCn: LangZh; +declare const langZhTw: LangZh; +export { langZhCn, langZhTw }; diff --git a/packages/wordlists/lang-zh.js b/packages/wordlists/lib/lang-zh.js similarity index 100% rename from packages/wordlists/lang-zh.js rename to packages/wordlists/lib/lang-zh.js diff --git a/packages/wordlists/lib/wordlist.d.ts b/packages/wordlists/lib/wordlist.d.ts new file mode 100644 index 000000000..0aa7844c7 --- /dev/null +++ b/packages/wordlists/lib/wordlist.d.ts @@ -0,0 +1,10 @@ +export declare function check(wordlist: Wordlist): string; +export declare abstract class Wordlist { + readonly locale: string; + constructor(locale: string); + abstract getWord(index: number): string; + abstract getWordIndex(word: string): number; + split(mnemonic: string): Array; + join(words: Array): string; +} +export declare function register(lang: Wordlist, name?: string): void; diff --git a/packages/wordlists/wordlist.js b/packages/wordlists/lib/wordlist.js similarity index 100% rename from packages/wordlists/wordlist.js rename to packages/wordlists/lib/wordlist.js diff --git a/packages/wordlists/package.json b/packages/wordlists/package.json index dcfb81bec..fc99f6acd 100644 --- a/packages/wordlists/package.json +++ b/packages/wordlists/package.json @@ -1,8 +1,8 @@ { "name": "@ethersproject/wordlists", - "version": "5.0.0-beta.127", + "version": "5.0.0-beta.128", "description": "Word lists for BIP39 wallets.", - "main": "index.js", + "main": "./lib/index.js", "browser": "browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -27,5 +27,6 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "tarballHash": "0x5f663f196d056de34e9034d3be64bf8982ff07dbf9d9beb007de2f19b77dc90d" + "module": "./lib.esm/index.js", + "tarballHash": "0x2c13e3b70876f57cc7a6f8ad6240f177e2a5b65c80f865aff28c890e784ae1d8" } diff --git a/packages/wordlists/tsconfig.json b/packages/wordlists/tsconfig.json index f8b22b29e..324e49b1e 100644 --- a/packages/wordlists/tsconfig.json +++ b/packages/wordlists/tsconfig.json @@ -2,11 +2,10 @@ "extends": "../../tsconfig.package.json", "compilerOptions": { "rootDir": "./src.ts", - "outDir": "./" + "outDir": "./lib/" }, "include": [ - "./src.ts/*" + "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } - diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..dd0159f2e --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,115 @@ +import resolve from 'rollup-plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; +import json from 'rollup-plugin-json'; + +import { terser } from "rollup-plugin-terser"; + +import { createFilter } from 'rollup-pluginutils'; + +function Replacer(options = {}) { + const filter = createFilter(options.include, options.exclude); + let suffixes = Object.keys(options.replace); + return { + name: "file-replacer", + transform(code, id) { + //console.log(id, code.length); + if (!filter(id)) { return null; } + for (let i = 0; i < suffixes.length; i++) { + const suffix = suffixes[i]; + if (id.match(new RegExp(suffix))) { + //if (id.substring(id.length - suffix.length) === suffix) { + let newCode = options.replace[suffix]; + console.log(`Replace: ${ id } (${ code.length } => ${ newCode.length })`); + return { + code: newCode + }; + } + } + return null; + } + }; +} + +const undef = "module.exports = undefined;"; +const empty = "module.exports = {};"; +const brorand = "module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; }"; + +const ellipticPackage = (function() { + const ellipticPackage = require('./node_modules/elliptic/package.json'); + return JSON.stringify({ version: ellipticPackage.version }); +})(); + +export default commandLineArgs => { + let minify = commandLineArgs.configMinify; + let buildModule = commandLineArgs.configModule; + let testing = commandLineArgs.configTest; + + let input = "packages/ethers/index.js" + let output = [ "umd" ]; + let format = "umd"; + let mainFields = [ "browser", "main" ]; + + if (buildModule) { + input = "packages/ethers/module/index.js"; + output = [ "esm" ]; + format = "esm"; + mainFields = [ "browser", "module", "main" ]; + } + + const replacer = Replacer({ + replace: { + // Remove the precomputed secp256k1 points + "elliptic/lib/elliptic/precomputed/secp256k1.js$": undef, + + // Remove curves we don't care about + "elliptic/curve/edwards.js$": empty, + "elliptic/curve/mont.js$": empty, + "elliptic/lib/elliptic/eddsa/.*$": empty, + + // We only use the version from this JSON package + "elliptic/package.json$" : ellipticPackage, + + // Remove unneeded hashing algorithms + "hash.js/lib/hash/sha/1.js$": empty, + "hash.js/lib/hash/sha/224.js$": empty, + "hash.js/lib/hash/sha/384.js$": empty, + + // Swap out borland for the random bytes we already have + "brorand/index.js$": brorand, + } + }); + + const plugins = [ + replacer, + json(), + resolve({ + mainFields: mainFields + }), + commonjs({ + namedExports: { + "bn.js": [ "BN" ], + "elliptic": [ "ec" ] + } + }) + ]; + + if (minify) { + output.push("min"); + plugins.push(terser()); + } + + let outputFile = (("packages/") + + (testing ? "tests": "ethers") + + ("/dist/ethers." + output.join(".") + ".js")); + + return { + input: input, + output: { + file: outputFile, + format: format, + name: "ethers" + }, + treeshake: false, + plugins: plugins + }; +} diff --git a/tsconfig.package.json b/tsconfig.package.json index 0cbd12533..59836c8bb 100644 --- a/tsconfig.package.json +++ b/tsconfig.package.json @@ -1,28 +1,24 @@ { "compilerOptions": { "composite": true, - "esModuleInterop": true, - "lib": [ "es2015", "es5", "dom" ], - "module": "commonjs", - "target": "es5", + "lib": [ + "es2015", + "es5", + "dom" + ], "moduleResolution": "node", - "declaration": true, - "preserveSymlinks": true, - "preserveWatchOutput": true, "pretty": false, - "forceConsistentCasingInFileNames": true, - "noEmitOnError": true, - "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "noImplicitReturns": true, - "noUnusedLocals": true + "noUnusedLocals": true, + "module": "commonjs", + "target": "es5" } } - From 3a91e91df56c1ef6cf096c0322f74fd5060891e0 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 25 Aug 2019 16:20:34 -0400 Subject: [PATCH 03/13] Fixed build process to re-target browser field to ES version. --- admin/build.js | 27 +- admin/cmds/update-versions.js | 8 +- admin/config.js | 2 +- admin/index.js | 6 +- admin/npm.js | 2 +- package.json | 4 - packages/abi/package.json | 2 +- packages/abstract-provider/package.json | 6 +- packages/abstract-signer/package.json | 2 +- packages/address/package.json | 2 +- packages/base64/package.json | 4 +- packages/basex/package.json | 2 +- packages/bignumber/lib.esm/index.d.ts | 2 +- packages/bignumber/lib.esm/index.js | 2 +- packages/bignumber/package.json | 2 +- packages/bytes/package.json | 2 +- packages/cli/lib.esm/index.d.ts | 5 + packages/cli/lib.esm/index.js | 6 + packages/cli/package.json | 2 +- packages/constants/package.json | 2 +- packages/contracts/package.json | 2 +- packages/errors/package.json | 2 +- packages/ethers/dist/ethers.esm.js | 674 +- packages/ethers/dist/ethers.esm.min.js | 2 +- packages/ethers/dist/ethers.js | 19944 ---------------- packages/ethers/dist/ethers.min.js | 1 - packages/ethers/dist/ethers.umd.js | 2226 +- packages/ethers/dist/ethers.umd.min.js | 2 +- packages/ethers/package.json | 2 +- packages/experimental/package.json | 2 +- packages/hash/package.json | 2 +- packages/hdnode/package.json | 2 +- packages/json-wallets/package.json | 2 +- packages/keccak256/package.json | 2 +- packages/logger/package.json | 2 +- packages/networks/package.json | 2 +- packages/pbkdf2/package.json | 4 +- packages/properties/package.json | 2 +- packages/providers/package.json | 6 +- packages/random/package.json | 4 +- packages/rlp/package.json | 2 +- packages/sha2/package.json | 4 +- packages/signing-key/package.json | 2 +- packages/solidity/package.json | 2 +- packages/strings/package.json | 2 +- .../lib.esm/generation-scripts/abi.js | 4 +- packages/testcases/lib.esm/index.js | 4 +- packages/testcases/package.json | 4 +- packages/tests/package.json | 2 +- packages/transactions/package.json | 2 +- packages/units/lib.esm/index.js | 2 +- packages/units/package.json | 2 +- packages/wallet/lib.esm/index.d.ts | 2 +- packages/wallet/package.json | 2 +- packages/web/package.json | 2 +- packages/wordlists/package.json | 4 +- rollup.config.js | 4 +- 57 files changed, 1312 insertions(+), 21709 deletions(-) create mode 100644 packages/cli/lib.esm/index.d.ts create mode 100644 packages/cli/lib.esm/index.js delete mode 100644 packages/ethers/dist/ethers.js delete mode 100644 packages/ethers/dist/ethers.min.js diff --git a/admin/build.js b/admin/build.js index a410d202c..fb011bfc4 100644 --- a/admin/build.js +++ b/admin/build.js @@ -5,7 +5,7 @@ const resolve = require("path").resolve; const spawn = require("child_process").spawn; const { dirnames } = require("./local"); -const { loadPackage } = require("./depgraph"); +const { loadPackage, savePackage } = require("./local"); const { loadJson, saveJson } = require("./utils"); function run(progname, args, ignoreErrorStream) { @@ -49,6 +49,14 @@ function run(progname, args, ignoreErrorStream) { } function setupConfig(outDir, moduleType, targetType) { + function update(value) { + let comps = value.split("/"); + if (comps.length >= 3 && comps[0] === "." && comps[1].match(/^lib(\.esm)?$/)) { + return outDir + comps.slice(2).join("/"); + } + return value; + } + // Configure the tsconfit.package.json... const path = resolve(__dirname, "../tsconfig.package.json"); const content = loadJson(path); @@ -57,7 +65,20 @@ function setupConfig(outDir, moduleType, targetType) { saveJson(path, content); dirnames.forEach((dirname) => { - if (loadPackage(dirname)._ethers_nobuild) { return; } + let info = loadPackage(dirname); + + if (info._ethers_nobuild) { return; } + + if (info.browser) { + if (typeof(info.browser) === "string") { + info.browser = update(info.browser); + } else { + for (let key in info.browser) { + info.browser[key] = update(info.browser[key]); + } + } + } + savePackage(dirname, info); let path = resolve(__dirname, "../packages", dirname, "tsconfig.json"); let content = loadJson(path); @@ -82,7 +103,7 @@ function runBuild(buildModule) { } function runDist() { - return run("npx", [ "lerna", "run", "dist" ], true); + return run("npm", [ "run", "_dist_ethers" ], true); } module.exports = { diff --git a/admin/cmds/update-versions.js b/admin/cmds/update-versions.js index dc420353c..e7031847e 100644 --- a/admin/cmds/update-versions.js +++ b/admin/cmds/update-versions.js @@ -18,7 +18,7 @@ const { getPackageVersion } = require("../npm"); const { resolve } = require("../utils"); const { colorify, log } = require("../log"); -const { getProgressBar } = require("../../packages/cli/prompt"); +const { prompt } = require("../../packages/cli"); let dirnames = getOrdered(); @@ -41,7 +41,7 @@ if (process.argv.length > 2) { } (async function() { - let progress = getProgressBar(colorify("Updating versions", "bold")); + let progress = prompt.getProgressBar(colorify("Updating versions", "bold")); for (let i = 0; i < dirnames.length; i++) { progress(i / dirnames.length); @@ -87,7 +87,7 @@ if (process.argv.length > 2) { log(""); await runBuild(true); log(""); - await runBuild(); + await runBuild(false); log(""); let content = await runDist(); console.log(content); @@ -98,7 +98,7 @@ if (process.argv.length > 2) { } // Update the tarball hash now that _version and package.json may have changed. - progress = getProgressBar(colorify("Updating tarballHash", "bold")); + progress = prompt.getProgressBar(colorify("Updating tarballHash", "bold")); for (let i = 0; i < dirnames.length; i++) { progress(i / dirnames.length); await updatePackage(dirnames[i]); diff --git a/admin/config.js b/admin/config.js index 5d894c76c..aaa31443b 100644 --- a/admin/config.js +++ b/admin/config.js @@ -7,7 +7,7 @@ const resolve = require("path").resolve; const AES = require("aes-js"); const scrypt = require("scrypt-js"); -const prompt = require("../packages/cli/prompt"); +const { prompt } = require("../packages/cli"); const randomBytes = require("../packages/random").randomBytes; const computeHmac = require("../packages/sha2").computeHmac; diff --git a/admin/index.js b/admin/index.js index 3da0db121..83c0a4c6c 100644 --- a/admin/index.js +++ b/admin/index.js @@ -6,7 +6,7 @@ const resolve = require("path").resolve; const diff = require("diff"); const semver = require("semver"); -const { getProgressBar, prompt } = require("../packages/cli/prompt"); +const { prompt } = require("../packages/cli"); const build = require("./build"); const changelog = require("./changelog"); @@ -158,7 +158,7 @@ async function runUpdate(dirnames) { // @TODO: Root // Update all the package.json and _version.ts - let progress = getProgressBar(colorify("Updating versions", "bold")); + let progress = prompt.getProgressBar(colorify("Updating versions", "bold")); for (let i = 0; i < dirnames.length; i++) { progress(i / dirnames.length); @@ -205,7 +205,7 @@ async function runUpdate(dirnames) { // @TODO: // Update the tarball hash now that _version and package.json may have changed. - progress = getProgressBar(colorify("Updating tarballHash", "bold")); + progress = prompt.getProgressBar(colorify("Updating tarballHash", "bold")); for (let i = 0; i < dirnames.length; i++) { progress(i / dirnames.length); await local.updatePackage(dirnames[i]); diff --git a/admin/npm.js b/admin/npm.js index b507669b4..28deee3e7 100644 --- a/admin/npm.js +++ b/admin/npm.js @@ -9,7 +9,7 @@ const local = require("./local"); const keccak256 = require("../packages/keccak256").keccak256; const fetchJson = require("../packages/web").fetchJson; -const prompt = require("../packages/cli/prompt"); +const { prompt } = require("../packages/cli"); const colorify = require("./log").colorify; const git = require("./git"); diff --git a/package.json b/package.json index 4b2445cee..182fddc5e 100644 --- a/package.json +++ b/package.json @@ -6,15 +6,12 @@ "bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", "build": "tsc --build ./tsconfig.project.json", "clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json", - "_dist_prepare": "npm run clean && npm run bootstrap && npm run build", "_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify", "_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", - "_test_prepare": "npm run _dist_prepare && npm run _dist_tests", "_test_node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js", "test_node": "npm run _test_prepare && npm run _test_node", - "_dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist", "old-test": "npm run _dist_old && npm run test-check", "old-test-check": "if [ \"$RUN_PHANTOMJS\" = \"1\" ]; then npm run-script test-phantomjs; else npm run-script test-node; fi", @@ -22,7 +19,6 @@ "old-test-phantomjs": "cd packages/tests && npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js", "old-test-aion": "npm run dist && npm run test-aion-node", "old-test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js", - "update-versions": "npm run _dist_prepare && node ./admin/cmds/update-versions", "publish-all": "node ./admin/cmds/publish", "build-docs": "flatworm docs.wrm docs" diff --git a/packages/abi/package.json b/packages/abi/package.json index b32ecef7b..de2b0751f 100644 --- a/packages/abi/package.json +++ b/packages/abi/package.json @@ -31,5 +31,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x39e9e020225c070444d3030a0423e986c5c8b25ee3279341641f4b6bf343f4a2" + "tarballHash": "0x48cbad8938a128d8f52b87e30c92a1ad2b28af9aee2d1faf1a4c23d60a14b2d3" } diff --git a/packages/abstract-provider/package.json b/packages/abstract-provider/package.json index 5ded80d7e..e0fbce4da 100644 --- a/packages/abstract-provider/package.json +++ b/packages/abstract-provider/package.json @@ -3,10 +3,6 @@ "version": "5.0.0-beta.131", "description": "An Abstract Class for describing an Ethereum Provider for ethers.", "main": "./lib/index.js", - "browser": { - "net": "./browser-net.js", - "./ipc-provider": "./browser-ipc-provider" - }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -33,5 +29,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x4b955417ad50b4c8fa7d7ac8f3de84a9f7948381e3f79f6e301a1bdfdd95066c" + "tarballHash": "0x478d4364ced856f3b5ee51da258a5ae239b97a5d1a58f25dd25b8e81f692683c" } diff --git a/packages/abstract-signer/package.json b/packages/abstract-signer/package.json index ca2b3e339..c024c1d61 100644 --- a/packages/abstract-signer/package.json +++ b/packages/abstract-signer/package.json @@ -27,5 +27,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xaa4a4086f9fea3265ac7918227914cf63bf4dc082ea2bc4457dc009fafb51437" + "tarballHash": "0xc1853f4ac83975080e51babe4f0613122ce5b1b5d68287c84d44a5663cf5546c" } diff --git a/packages/address/package.json b/packages/address/package.json index 1a297f7dc..b2d27bc0c 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -28,5 +28,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xf52fe7ac31abf75d751e23e06fad681acee39ae9d1153f9c24d5feae7018f22d" + "tarballHash": "0x3f3fd1c8422ddd05719dfb37df8292d27e93ae1ce0d0d48e5cdc263082e35a78" } diff --git a/packages/base64/package.json b/packages/base64/package.json index 926930af2..0132f1ec3 100644 --- a/packages/base64/package.json +++ b/packages/base64/package.json @@ -3,7 +3,7 @@ "version": "5.0.0-beta.126", "description": "Base64 coder.", "main": "./lib/index.js", - "browser": "browser.js", + "browser": "./lib/browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -24,5 +24,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xf6efb1c57508f4e699d90f6423068a95189bc5b750430f294661e2dcf75d919c" + "tarballHash": "0x390db88947a298518774fc7b8d5f9b36191df44152bca2370a890d44d44e731f" } diff --git a/packages/basex/package.json b/packages/basex/package.json index 7267b0b7b..3d3d01649 100644 --- a/packages/basex/package.json +++ b/packages/basex/package.json @@ -24,5 +24,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x07d12f5f71d62ecbc4240de5bc05e6031f4e0e0620e280eba2c18b2e294d4ff5" + "tarballHash": "0x6375a21ec47208aa3a867f26061dbd56afcb7eb51f70c6955b99718fe3ebc32a" } diff --git a/packages/bignumber/lib.esm/index.d.ts b/packages/bignumber/lib.esm/index.d.ts index a80c3ba53..1c8551bc5 100644 --- a/packages/bignumber/lib.esm/index.d.ts +++ b/packages/bignumber/lib.esm/index.d.ts @@ -1,2 +1,2 @@ export { BigNumber, BigNumberish } from "./bignumber"; -export { FixedNumber } from "./fixednumber"; +export { formatFixed, FixedFormat, FixedNumber, parseFixed } from "./fixednumber"; diff --git a/packages/bignumber/lib.esm/index.js b/packages/bignumber/lib.esm/index.js index 7f4c67923..d6fa15319 100644 --- a/packages/bignumber/lib.esm/index.js +++ b/packages/bignumber/lib.esm/index.js @@ -1,2 +1,2 @@ export { BigNumber } from "./bignumber"; -export { FixedNumber } from "./fixednumber"; +export { formatFixed, FixedFormat, FixedNumber, parseFixed } from "./fixednumber"; diff --git a/packages/bignumber/package.json b/packages/bignumber/package.json index 7c9374a4d..86eb1f2e1 100644 --- a/packages/bignumber/package.json +++ b/packages/bignumber/package.json @@ -27,5 +27,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x78dadd02c7c23e71e8bc51a5a21843437363b7ab29d16de0290e25f12d7fe6f6" + "tarballHash": "0x3b0c080f96f262333cb2191f8160e1aef0d93f9af107c1aa0876d007817c9e76" } diff --git a/packages/bytes/package.json b/packages/bytes/package.json index 758e4f1a4..45ba381c6 100644 --- a/packages/bytes/package.json +++ b/packages/bytes/package.json @@ -25,5 +25,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x7092fb4f0431cc7edeabb25e101d0d73a378bbb842c38e48b8eb41031d97d2f2" + "tarballHash": "0x4b7f4f6a34bc4d5c4fe15a01b7c698e8250f828933bb6202248a660d0fb5edfb" } diff --git a/packages/cli/lib.esm/index.d.ts b/packages/cli/lib.esm/index.d.ts new file mode 100644 index 000000000..bbd0b66a0 --- /dev/null +++ b/packages/cli/lib.esm/index.d.ts @@ -0,0 +1,5 @@ +import * as cli from "./cli"; +import * as prompt from "./prompt"; +import * as solc from "./solc"; +import * as typescript from "./typescript"; +export { cli, prompt, solc, typescript, }; diff --git a/packages/cli/lib.esm/index.js b/packages/cli/lib.esm/index.js new file mode 100644 index 000000000..9bedff7cb --- /dev/null +++ b/packages/cli/lib.esm/index.js @@ -0,0 +1,6 @@ +"use strict"; +import * as cli from "./cli"; +import * as prompt from "./prompt"; +import * as solc from "./solc"; +import * as typescript from "./typescript"; +export { cli, prompt, solc, typescript, }; diff --git a/packages/cli/package.json b/packages/cli/package.json index 2c52a22e0..1e56aab5d 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -35,5 +35,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xba8cdd7f8648de30fba61ce68e7592be382a490cb92217765fb926cdd99942b8" + "tarballHash": "0x047aa677370e57a4c356aa7ca5d3e692038f4863413141cd1f325526c59a4096" } diff --git a/packages/constants/package.json b/packages/constants/package.json index 1c77a794e..f60302494 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -23,5 +23,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x3ece9df573db39c560dac46836c5bc16d4c46a504991a726262f5f0ca8b1b2f1" + "tarballHash": "0x29b69bfc747774d3debf9874b27f05d4c8ea232d709ce955d931d18624a7b0d3" } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index b9e5d0271..1da47f92a 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -32,5 +32,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x2b3d95a50f2ca8c9bfc0537b3ba0709961462384296311ea188b3b96e3f58b83" + "tarballHash": "0xd9caa174a4d078052aef924411d3175358bd4539b192b625b3ee3a7a9ba9d653" } diff --git a/packages/errors/package.json b/packages/errors/package.json index 0a9026047..9df7f005b 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -20,5 +20,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x38cdacb3663d11ec01cd55e8b13e4d77c8aa5b754dbaa9424bb4bb3de18071db" + "tarballHash": "0x7acbc055896e553d4aa8a18f61197c58d726ef6f44d01a403c323f28ce41330d" } diff --git a/packages/ethers/dist/ethers.esm.js b/packages/ethers/dist/ethers.esm.js index 708d99563..7ad598a38 100644 --- a/packages/ethers/dist/ethers.esm.js +++ b/packages/ethers/dist/ethers.esm.js @@ -3455,7 +3455,7 @@ var bn = createCommonjsModule(function (module) { }); var bn_1 = bn.BN; -const version = "logger/5.0.0-beta.129"; +const version = "logger/5.0.0-beta.128"; "use strict"; let _permanentCensorErrors = false; @@ -3721,11 +3721,11 @@ Logger.levels = { OFF: "OFF" }; -var module = /*#__PURE__*/Object.freeze({ +var lib_esm = /*#__PURE__*/Object.freeze({ Logger: Logger }); -const version$1 = "bytes/5.0.0-beta.129"; +const version$1 = "bytes/5.0.0-beta.128"; "use strict"; const logger = new Logger(version$1); @@ -4089,7 +4089,7 @@ function joinSignature(signature) { ])); } -var module$1 = /*#__PURE__*/Object.freeze({ +var lib_esm$1 = /*#__PURE__*/Object.freeze({ isBytesLike: isBytesLike, isBytes: isBytes, arrayify: arrayify, @@ -4108,7 +4108,7 @@ var module$1 = /*#__PURE__*/Object.freeze({ joinSignature: joinSignature }); -const version$2 = "bignumber/5.0.0-beta.130"; +const version$2 = "bignumber/5.0.0-beta.129"; "use strict"; const logger$1 = new Logger(version$2); @@ -4612,7 +4612,7 @@ class FixedNumber { } } -const version$3 = "properties/5.0.0-beta.131"; +const version$3 = "properties/5.0.0-beta.130"; "use strict"; const logger$3 = new Logger(version$3); @@ -4713,7 +4713,7 @@ class Description { } } -var module$2 = /*#__PURE__*/Object.freeze({ +var lib_esm$2 = /*#__PURE__*/Object.freeze({ defineReadOnly: defineReadOnly, getStatic: getStatic, resolveProperties: resolveProperties, @@ -4723,7 +4723,7 @@ var module$2 = /*#__PURE__*/Object.freeze({ Description: Description }); -const version$4 = "abi/5.0.0-beta.137"; +const version$4 = "abi/5.0.0-beta.136"; "use strict"; const logger$4 = new Logger(version$4); @@ -6179,7 +6179,7 @@ var index = /*#__PURE__*/Object.freeze({ decode: decode }); -const version$5 = "address/5.0.0-beta.128"; +const version$5 = "address/5.0.0-beta.127"; "use strict"; const logger$6 = new Logger(version$5); @@ -6596,7 +6596,7 @@ class NumberCoder extends Coder { } } -const version$6 = "strings/5.0.0-beta.130"; +const version$6 = "strings/5.0.0-beta.129"; "use strict"; const logger$8 = new Logger(version$6); @@ -7117,7 +7117,7 @@ class AbiCoder { } const defaultAbiCoder = new AbiCoder(); -const version$7 = "hash/5.0.0-beta.128"; +const version$7 = "hash/5.0.0-beta.127"; "use strict"; const logger$a = new Logger(version$7); @@ -7165,7 +7165,7 @@ function hashMessage(message) { ])); } -var module$3 = /*#__PURE__*/Object.freeze({ +var lib_esm$3 = /*#__PURE__*/Object.freeze({ isValidName: isValidName, namehash: namehash, id: id, @@ -7508,7 +7508,7 @@ function getNameCount(fragments) { "use strict"; -const version$8 = "abstract-provider/5.0.0-beta.131"; +const version$8 = "abstract-provider/5.0.0-beta.130"; "use strict"; const logger$c = new Logger(version$8); @@ -7585,7 +7585,7 @@ class Provider { } } -const version$9 = "abstract-signer/5.0.0-beta.132"; +const version$9 = "abstract-signer/5.0.0-beta.131"; "use strict"; const logger$d = new Logger(version$9); @@ -7753,7 +7753,7 @@ class VoidSigner extends Signer { } } -const version$a = "contracts/5.0.0-beta.137"; +const version$a = "contracts/5.0.0-beta.136"; "use strict"; const logger$e = new Logger(version$a); @@ -9727,13 +9727,13 @@ hash.ripemd160 = hash.ripemd.ripemd160; var _version = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "sha2/5.0.0-beta.129"; +exports.version = "sha2/5.0.0-beta.128"; }); var _version$1 = unwrapExports(_version); var _version_1 = _version.version; -var browser = createCommonjsModule(function (module$2, exports) { +var browser = createCommonjsModule(function (module, exports) { "use strict"; var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; @@ -9747,7 +9747,7 @@ var hash = __importStar(hash_1); -var logger = new module.Logger(_version.version); +var logger = new lib_esm.Logger(_version.version); var SupportedAlgorithms; (function (SupportedAlgorithms) { SupportedAlgorithms["sha256"] = "sha256"; @@ -9755,25 +9755,25 @@ var SupportedAlgorithms; })(SupportedAlgorithms = exports.SupportedAlgorithms || (exports.SupportedAlgorithms = {})); ; function ripemd160(data) { - return "0x" + (hash.ripemd160().update(module$1.arrayify(data)).digest("hex")); + return "0x" + (hash.ripemd160().update(lib_esm$1.arrayify(data)).digest("hex")); } exports.ripemd160 = ripemd160; function sha256(data) { - return "0x" + (hash.sha256().update(module$1.arrayify(data)).digest("hex")); + return "0x" + (hash.sha256().update(lib_esm$1.arrayify(data)).digest("hex")); } exports.sha256 = sha256; function sha512(data) { - return "0x" + (hash.sha512().update(module$1.arrayify(data)).digest("hex")); + return "0x" + (hash.sha512().update(lib_esm$1.arrayify(data)).digest("hex")); } exports.sha512 = sha512; function computeHmac(algorithm, key, data) { if (!SupportedAlgorithms[algorithm]) { - logger.throwError("unsupported algorithm " + algorithm, module.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("unsupported algorithm " + algorithm, lib_esm.Logger.errors.UNSUPPORTED_OPERATION, { operation: "hmac", algorithm: algorithm }); } - return "0x" + hash.hmac(hash[algorithm], module$1.arrayify(key)).update(module$1.arrayify(data)).digest("hex"); + return "0x" + hash.hmac(hash[algorithm], lib_esm$1.arrayify(key)).update(lib_esm$1.arrayify(data)).digest("hex"); } exports.computeHmac = computeHmac; }); @@ -9791,8 +9791,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { - password = module$1.arrayify(password); - salt = module$1.arrayify(salt); + password = lib_esm$1.arrayify(password); + salt = lib_esm$1.arrayify(salt); var hLen; var l = 1; var DK = new Uint8Array(keylen); @@ -9808,7 +9808,7 @@ function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { block1[salt.length + 2] = (i >> 8) & 0xff; block1[salt.length + 3] = i & 0xff; //let U = createHmac(password).update(block1).digest(); - var U = module$1.arrayify(browser.computeHmac(hashAlgorithm, password, block1)); + var U = lib_esm$1.arrayify(browser.computeHmac(hashAlgorithm, password, block1)); if (!hLen) { hLen = U.length; T = new Uint8Array(hLen); @@ -9819,16 +9819,16 @@ function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { T.set(U); for (var j = 1; j < iterations; j++) { //U = createHmac(password).update(U).digest(); - U = module$1.arrayify(browser.computeHmac(hashAlgorithm, password, U)); + U = lib_esm$1.arrayify(browser.computeHmac(hashAlgorithm, password, U)); for (var k = 0; k < hLen; k++) T[k] ^= U[k]; } var destPos = (i - 1) * hLen; var len = (i === l ? r : hLen); //T.copy(DK, destPos, 0, len) - DK.set(module$1.arrayify(T).slice(0, len), destPos); + DK.set(lib_esm$1.arrayify(T).slice(0, len), destPos); } - return module$1.hexlify(DK); + return lib_esm$1.hexlify(DK); } exports.pbkdf2 = pbkdf2; }); @@ -12200,7 +12200,7 @@ elliptic.eddsa = eddsa; }); var elliptic_2 = elliptic_1.ec; -const version$c = "signing-key/5.0.0-beta.129"; +const version$c = "signing-key/5.0.0-beta.128"; "use strict"; const logger$f = new Logger(version$c); @@ -12272,7 +12272,7 @@ function computePublicKey(key, compressed) { return logger$f.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); } -const version$d = "transactions/5.0.0-beta.128"; +const version$d = "transactions/5.0.0-beta.127"; "use strict"; const logger$g = new Logger(version$d); @@ -12413,13 +12413,13 @@ function parse(rawTransaction) { var _version$2 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "wordlists/5.0.0-beta.128"; +exports.version = "wordlists/5.0.0-beta.127"; }); var _version$3 = unwrapExports(_version$2); var _version_1$1 = _version$2.version; -var wordlist = createCommonjsModule(function (module$1, exports) { +var wordlist = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // This gets overriddenby gulp during bip39-XX @@ -12428,7 +12428,7 @@ var exportWordlist = false; -var logger = new module.Logger(_version$2.version); +var logger = new lib_esm.Logger(_version$2.version); function check(wordlist) { var words = []; for (var i = 0; i < 2048; i++) { @@ -12438,14 +12438,14 @@ function check(wordlist) { } words.push(word); } - return module$3.id(words.join("\n") + "\n"); + return lib_esm$3.id(words.join("\n") + "\n"); } exports.check = check; var Wordlist = /** @class */ (function () { function Wordlist(locale) { var _newTarget = this.constructor; logger.checkAbstract(_newTarget, Wordlist); - module$2.defineReadOnly(this, "locale", locale); + lib_esm$2.defineReadOnly(this, "locale", locale); } // Subclasses may override this Wordlist.prototype.split = function (mnemonic) { @@ -12465,14 +12465,14 @@ function register(lang, name) { if (exportWordlist) { var g = commonjsGlobal; if (!(g.wordlists)) { - module$2.defineReadOnly(g, "wordlists", {}); + lib_esm$2.defineReadOnly(g, "wordlists", {}); } if (!g.wordlists[name]) { - module$2.defineReadOnly(g.wordlists, name, lang); + lib_esm$2.defineReadOnly(g.wordlists, name, lang); } if (g.ethers && g.ethers.wordlists) { if (!g.ethers.wordlists[name]) { - module$2.defineReadOnly(g.ethers.wordlists, name, lang); + lib_esm$2.defineReadOnly(g.ethers.wordlists, name, lang); } } } @@ -12553,7 +12553,7 @@ var browser$5 = unwrapExports(browser$4); var browser_1$2 = browser$4.Wordlist; var browser_2$1 = browser$4.wordlists; -const version$e = "hdnode/5.0.0-beta.130"; +const version$e = "hdnode/5.0.0-beta.129"; "use strict"; const logger$h = new Logger(version$e); @@ -12835,7 +12835,7 @@ function isValidMnemonic(mnemonic, wordlist) { var _version$4 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "random/5.0.0-beta.128"; +exports.version = "random/5.0.0-beta.127"; }); var _version$5 = unwrapExports(_version$4); @@ -12860,13 +12860,13 @@ exports.shuffled = shuffled; var shuffle$1 = unwrapExports(shuffle); var shuffle_1 = shuffle.shuffled; -var browser$6 = createCommonjsModule(function (module$2, exports) { +var browser$6 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -var logger = new module.Logger(_version$4.version); +var logger = new lib_esm.Logger(_version$4.version); exports.shuffled = shuffle.shuffled; var crypto = commonjsGlobal.crypto || commonjsGlobal.msCrypto; @@ -12874,7 +12874,7 @@ if (!crypto || !crypto.getRandomValues) { logger.warn("WARNING: Missing strong random number source"); crypto = { getRandomValues: function (buffer) { - return logger.throwError("no secure random source avaialble", module.Logger.errors.UNSUPPORTED_OPERATION, { + return logger.throwError("no secure random source avaialble", lib_esm.Logger.errors.UNSUPPORTED_OPERATION, { operation: "crypto.getRandomValues" }); } @@ -12886,7 +12886,7 @@ function randomBytes(length) { } var result = new Uint8Array(length); crypto.getRandomValues(result); - return module$1.arrayify(result); + return lib_esm$1.arrayify(result); } exports.randomBytes = randomBytes; ; @@ -13697,7 +13697,7 @@ var aesJs = createCommonjsModule(function (module, exports) { })(commonjsGlobal); }); -const version$f = "json-wallets/5.0.0-beta.129"; +const version$f = "json-wallets/5.0.0-beta.128"; "use strict"; /* @@ -14851,7 +14851,7 @@ function decryptJsonWallet(json, password, progressCallback) { return Promise.reject(new Error("invalid JSON wallet")); } -const version$g = "wallet/5.0.0-beta.130"; +const version$g = "wallet/5.0.0-beta.129"; "use strict"; const logger$j = new Logger(version$g); @@ -14971,7 +14971,7 @@ function verifyMessage(message, signature) { return recoverAddress(hashMessage(message), signature); } -const version$h = "networks/5.0.0-beta.129"; +const version$h = "networks/5.0.0-beta.128"; "use strict"; const logger$k = new Logger(version$h); @@ -15705,11 +15705,11 @@ function decode(textData) { for (var i = 0; i < textData.length; i++) { data.push(textData.charCodeAt(i)); } - return module$1.arrayify(data); + return lib_esm$1.arrayify(data); } exports.decode = decode; function encode(data) { - data = module$1.arrayify(data); + data = lib_esm$1.arrayify(data); var textData = ""; for (var i = 0; i < data.length; i++) { textData += String.fromCharCode(data[i]); @@ -15730,7 +15730,7 @@ var browser$a = /*#__PURE__*/Object.freeze({ encode: browser_2$3 }); -const version$i = "web/5.0.0-beta.129"; +const version$i = "web/5.0.0-beta.128"; "use strict"; const logger$l = new Logger(version$i); @@ -15927,7 +15927,7 @@ function poll(func, options) { }); } -const version$j = "providers/5.0.0-beta.141"; +const version$j = "providers/5.0.0-beta.140"; "use strict"; const logger$m = new Logger(version$j); @@ -18514,567 +18514,7 @@ function sha256$1(types, values) { return browser_3(pack$1(types, values)); } -var _version$6 = createCommonjsModule(function (module, exports) { -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "bignumber/5.0.0-beta.130"; -}); - -var _version$7 = unwrapExports(_version$6); -var _version_1$3 = _version$6.version; - -var bignumber = createCommonjsModule(function (module$2, exports) { -"use strict"; -var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * BigNumber - * - * A wrapper around the BN.js object. We use the BN.js library - * because it is used by elliptic, so it is required regardles. - * - */ -var BN = __importStar(bn); - - - -var logger = new module.Logger(_version$6.version); -var _constructorGuard = {}; -var MAX_SAFE = 0x1fffffffffffff; -function isBigNumberish(value) { - return (value != null) && (BigNumber.isBigNumber(value) || - (typeof (value) === "number" && (value % 1) === 0) || - (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || - module$1.isHexString(value) || - (typeof (value) === "bigint") || - module$1.isBytes(value)); -} -exports.isBigNumberish = isBigNumberish; -var BigNumber = /** @class */ (function () { - function BigNumber(constructorGuard, hex) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, BigNumber); - if (constructorGuard !== _constructorGuard) { - logger.throwError("cannot call consturtor directly; use BigNumber.from", module.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new (BigNumber)" - }); - } - this._hex = hex; - this._isBigNumber = true; - Object.freeze(this); - } - BigNumber.prototype.fromTwos = function (value) { - return toBigNumber(toBN(this).fromTwos(value)); - }; - BigNumber.prototype.toTwos = function (value) { - return toBigNumber(toBN(this).toTwos(value)); - }; - BigNumber.prototype.abs = function () { - if (this._hex[0] === "-") { - return BigNumber.from(this._hex.substring(1)); - } - return this; - }; - BigNumber.prototype.add = function (other) { - return toBigNumber(toBN(this).add(toBN(other))); - }; - BigNumber.prototype.sub = function (other) { - return toBigNumber(toBN(this).sub(toBN(other))); - }; - BigNumber.prototype.div = function (other) { - var o = BigNumber.from(other); - if (o.isZero()) { - throwFault("division by zero", "div"); - } - return toBigNumber(toBN(this).div(toBN(other))); - }; - BigNumber.prototype.mul = function (other) { - return toBigNumber(toBN(this).mul(toBN(other))); - }; - BigNumber.prototype.mod = function (other) { - return toBigNumber(toBN(this).mod(toBN(other))); - }; - BigNumber.prototype.pow = function (other) { - return toBigNumber(toBN(this).pow(toBN(other))); - }; - BigNumber.prototype.maskn = function (value) { - return toBigNumber(toBN(this).maskn(value)); - }; - BigNumber.prototype.eq = function (other) { - return toBN(this).eq(toBN(other)); - }; - BigNumber.prototype.lt = function (other) { - return toBN(this).lt(toBN(other)); - }; - BigNumber.prototype.lte = function (other) { - return toBN(this).lte(toBN(other)); - }; - BigNumber.prototype.gt = function (other) { - return toBN(this).gt(toBN(other)); - }; - BigNumber.prototype.gte = function (other) { - return toBN(this).gte(toBN(other)); - }; - BigNumber.prototype.isZero = function () { - return toBN(this).isZero(); - }; - BigNumber.prototype.toNumber = function () { - try { - return toBN(this).toNumber(); - } - catch (error) { - throwFault("overflow", "toNumber", this.toString()); - } - return null; - }; - BigNumber.prototype.toString = function () { - // Lots of people expect this, which we do not support, so check - if (arguments.length !== 0) { - logger.throwError("bigNumber.toString does not accept parameters", module.Logger.errors.UNEXPECTED_ARGUMENT, {}); - } - return toBN(this).toString(10); - }; - BigNumber.prototype.toHexString = function () { - return this._hex; - }; - BigNumber.from = function (value) { - if (value instanceof BigNumber) { - return value; - } - if (typeof (value) === "string") { - if (value.match(/-?0x[0-9a-f]+/i)) { - return new BigNumber(_constructorGuard, toHex(value)); - } - if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); - } - return logger.throwArgumentError("invalid BigNumber string", "value", value); - } - if (typeof (value) === "number") { - if (value % 1) { - throwFault("underflow", "BigNumber.from", value); - } - if (value >= MAX_SAFE || value <= -MAX_SAFE) { - throwFault("overflow", "BigNumber.from", value); - } - return BigNumber.from(String(value)); - } - if (typeof (value) === "bigint") { - return BigNumber.from(value.toString()); - } - if (module$1.isBytes(value)) { - return BigNumber.from(module$1.hexlify(value)); - } - if (value._hex && module$1.isHexString(value._hex)) { - return BigNumber.from(value._hex); - } - if (value.toHexString) { - value = value.toHexString(); - if (typeof (value) === "string") { - return BigNumber.from(value); - } - } - return logger.throwArgumentError("invalid BigNumber value", "value", value); - }; - BigNumber.isBigNumber = function (value) { - return !!(value && value._isBigNumber); - }; - return BigNumber; -}()); -exports.BigNumber = BigNumber; -// Normalize the hex string -function toHex(value) { - // For BN, call on the hex string - if (typeof (value) !== "string") { - return toHex(value.toString(16)); - } - // If negative, prepend the negative sign to the normalized positive value - if (value[0] === "-") { - // Strip off the negative sign - value = value.substring(1); - // Cannot have mulitple negative signs (e.g. "--0x04") - if (value[0] === "-") { - logger.throwArgumentError("invalid hex", "value", value); - } - // Call toHex on the positive component - value = toHex(value); - // Do not allow "-0x00" - if (value === "0x00") { - return value; - } - // Negate the value - return "-" + value; - } - // Add a "0x" prefix if missing - if (value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - // Normalize zero - if (value === "0x") { - return "0x00"; - } - // Make the string even length - if (value.length % 2) { - value = "0x0" + value.substring(2); - } - // Trim to smallest even-length string - while (value.length > 4 && value.substring(0, 4) === "0x00") { - value = "0x" + value.substring(4); - } - return value; -} -function toBigNumber(value) { - return BigNumber.from(toHex(value)); -} -function toBN(value) { - var hex = BigNumber.from(value).toHexString(); - if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); - } - return new BN.BN(hex.substring(2), 16); -} -function throwFault(fault, operation, value) { - var params = { fault: fault, operation: operation }; - if (value != null) { - params.value = value; - } - return logger.throwError(fault, module.Logger.errors.NUMERIC_FAULT, params); -} -}); - -var bignumber$1 = unwrapExports(bignumber); -var bignumber_1 = bignumber.isBigNumberish; -var bignumber_2 = bignumber.BigNumber; - -var fixednumber = createCommonjsModule(function (module$2, exports) { -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); - - - -var logger = new module.Logger(_version$6.version); - -var _constructorGuard = {}; -var Zero = bignumber.BigNumber.from(0); -var NegativeOne = bignumber.BigNumber.from(-1); -function throwFault(message, fault, operation, value) { - var params = { fault: fault, operation: operation }; - if (value !== undefined) { - params.value = value; - } - return logger.throwError(message, module.Logger.errors.NUMERIC_FAULT, params); -} -// Constant to pull zeros from for multipliers -var zeros = "0"; -while (zeros.length < 256) { - zeros += zeros; -} -// Returns a string "1" followed by decimal "0"s -function getMultiplier(decimals) { - if (typeof (decimals) !== "number") { - try { - decimals = bignumber.BigNumber.from(decimals).toNumber(); - } - catch (e) { } - } - if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { - return ("1" + zeros.substring(0, decimals)); - } - return logger.throwArgumentError("invalid decimal size", "decimals", decimals); -} -function formatFixed(value, decimals) { - if (decimals == null) { - decimals = 0; - } - var multiplier = getMultiplier(decimals); - // Make sure wei is a big number (convert as necessary) - value = bignumber.BigNumber.from(value); - var negative = value.lt(Zero); - if (negative) { - value = value.mul(NegativeOne); - } - var fraction = value.mod(multiplier).toString(); - while (fraction.length < multiplier.length - 1) { - fraction = "0" + fraction; - } - // Strip training 0 - fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; - var whole = value.div(multiplier).toString(); - value = whole + "." + fraction; - if (negative) { - value = "-" + value; - } - return value; -} -exports.formatFixed = formatFixed; -function parseFixed(value, decimals) { - if (decimals == null) { - decimals = 0; - } - var multiplier = getMultiplier(decimals); - if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { - logger.throwArgumentError("invalid decimal value", "value", value); - } - if (multiplier.length - 1 === 0) { - return bignumber.BigNumber.from(value); - } - // Is it negative? - var negative = (value.substring(0, 1) === "-"); - if (negative) { - value = value.substring(1); - } - if (value === ".") { - logger.throwArgumentError("missing value", "value", value); - } - // Split it into a whole and fractional part - var comps = value.split("."); - if (comps.length > 2) { - logger.throwArgumentError("too many decimal points", "value", value); - } - var whole = comps[0], fraction = comps[1]; - if (!whole) { - whole = "0"; - } - if (!fraction) { - fraction = "0"; - } - // Prevent underflow - if (fraction.length > multiplier.length - 1) { - throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); - } - // Fully pad the string with zeros to get to wei - while (fraction.length < multiplier.length - 1) { - fraction += "0"; - } - var wholeValue = bignumber.BigNumber.from(whole); - var fractionValue = bignumber.BigNumber.from(fraction); - var wei = (wholeValue.mul(multiplier)).add(fractionValue); - if (negative) { - wei = wei.mul(NegativeOne); - } - return wei; -} -exports.parseFixed = parseFixed; -var FixedFormat = /** @class */ (function () { - function FixedFormat(constructorGuard, signed, width, decimals) { - this.signed = signed; - this.width = width; - this.decimals = decimals; - this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); - this._multiplier = getMultiplier(decimals); - Object.freeze(this); - } - FixedFormat.from = function (value) { - if (value instanceof FixedFormat) { - return value; - } - var signed = true; - var width = 128; - var decimals = 18; - if (typeof (value) === "string") { - if (value === "fixed") { - // defaults... - } - else if (value === "ufixed") { - signed = false; - } - else if (value != null) { - var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); - if (!match) { - logger.throwArgumentError("invalid fixed format", "format", value); - } - signed = (match[1] !== "u"); - width = parseInt(match[2]); - decimals = parseInt(match[3]); - } - } - else if (value) { - var check = function (key, type, defaultValue) { - if (value[key] == null) { - return defaultValue; - } - if (typeof (value[key]) !== type) { - logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); - } - return value[key]; - }; - signed = check("signed", "boolean", signed); - width = check("width", "number", width); - decimals = check("decimals", "number", decimals); - } - if (width % 8) { - logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); - } - if (decimals > 80) { - logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); - } - return new FixedFormat(_constructorGuard, signed, width, decimals); - }; - return FixedFormat; -}()); -exports.FixedFormat = FixedFormat; -var FixedNumber = /** @class */ (function () { - function FixedNumber(constructorGuard, hex, value, format) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, FixedNumber); - this.format = format; - this._hex = hex; - this._value = value; - this._isFixedNumber = true; - Object.freeze(this); - } - FixedNumber.prototype._checkFormat = function (other) { - if (this.format.name !== other.format.name) { - logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); - } - }; - FixedNumber.prototype.addUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.subUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.mulUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); - }; - FixedNumber.prototype.divUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); - }; - // @TODO: Support other rounding algorithms - FixedNumber.prototype.round = function (decimals) { - if (decimals == null) { - decimals = 0; - } - if (decimals < 0 || decimals > 80 || (decimals % 1)) { - logger.throwArgumentError("invalid decimal cound", "decimals", decimals); - } - // If we are already in range, we're done - var comps = this.toString().split("."); - if (comps[1].length <= decimals) { - return this; - } - // Bump the value up by the 0.00...0005 - var bump = "0." + zeros.substring(0, decimals) + "5"; - comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); - // Now it is safe to truncate - return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); - }; - FixedNumber.prototype.toString = function () { return this._value; }; - FixedNumber.prototype.toHexString = function (width) { - if (width == null) { - return this._hex; - } - if (width % 8) { - logger.throwArgumentError("invalid byte width", "width", width); - } - var hex = bignumber.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); - return module$1.hexZeroPad(hex, width / 8); - }; - FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; - FixedNumber.prototype.toFormat = function (format) { - return FixedNumber.fromString(this._value, format); - }; - FixedNumber.fromValue = function (value, decimals, format) { - // If decimals looks more like a format, and there is no format, shift the parameters - if (format == null && decimals != null && !bignumber.isBigNumberish(decimals)) { - format = decimals; - decimals = null; - } - if (decimals == null) { - decimals = 0; - } - if (format == null) { - format = "fixed"; - } - return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); - }; - FixedNumber.fromString = function (value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - var numeric = parseFixed(value, fixedFormat.decimals); - if (!fixedFormat.signed && numeric.lt(Zero)) { - throwFault("unsigned value cannot be negative", "overflow", "value", value); - } - var hex = null; - if (fixedFormat.signed) { - hex = numeric.toTwos(fixedFormat.width).toHexString(); - } - else { - hex = numeric.toHexString(); - hex = module$1.hexZeroPad(hex, fixedFormat.width / 8); - } - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber.fromBytes = function (value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - if (module$1.arrayify(value).length > fixedFormat.width / 8) { - throw new Error("overflow"); - } - var numeric = bignumber.BigNumber.from(value); - if (fixedFormat.signed) { - numeric = numeric.fromTwos(fixedFormat.width); - } - var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber.from = function (value, format) { - if (typeof (value) === "string") { - return FixedNumber.fromString(value, format); - } - if (module$1.isBytes(value)) { - return FixedNumber.fromBytes(value, format); - } - try { - return FixedNumber.fromValue(value, 0, format); - } - catch (error) { - // Allow NUMERIC_FAULT to bubble up - if (error.code !== module.Logger.errors.INVALID_ARGUMENT) { - throw error; - } - } - return logger.throwArgumentError("invalid FixedNumber value", "value", value); - }; - FixedNumber.isFixedNumber = function (value) { - return !!(value && value._isFixedNumber); - }; - return FixedNumber; -}()); -exports.FixedNumber = FixedNumber; -}); - -var fixednumber$1 = unwrapExports(fixednumber); -var fixednumber_1 = fixednumber.formatFixed; -var fixednumber_2 = fixednumber.parseFixed; -var fixednumber_3 = fixednumber.FixedFormat; -var fixednumber_4 = fixednumber.FixedNumber; - -const version$k = "units/5.0.0-beta.127"; +const version$k = "units/5.0.0-beta.126"; "use strict"; const logger$y = new Logger(version$k); @@ -19133,7 +18573,7 @@ function formatUnits(value, unitName) { unitName = 3 * index; } } - return fixednumber_1(value, (unitName != null) ? unitName : 18); + return formatFixed(value, (unitName != null) ? unitName : 18); } function parseUnits(value, unitName) { if (typeof (unitName) === "string") { @@ -19142,7 +18582,7 @@ function parseUnits(value, unitName) { unitName = 3 * index; } } - return fixednumber_2(value, (unitName != null) ? unitName : 18); + return parseFixed(value, (unitName != null) ? unitName : 18); } function formatEther(wei) { return formatUnits(wei, 18); @@ -19235,7 +18675,7 @@ var utils$1 = /*#__PURE__*/Object.freeze({ "use strict"; const platform = "node"; -const version$l = "ethers/5.0.0-beta.156"; +const version$l = "ethers/5.0.0-beta.155"; "use strict"; const errors = Logger.errors; @@ -19278,6 +18718,4 @@ var ethers = /*#__PURE__*/Object.freeze({ "use strict"; -window.ethers = ethers; - export { BigNumber, Contract, ContractFactory, FixedNumber, Signer, VoidSigner, Wallet, browser_1$2 as Wordlist, index$1 as constants, errors, ethers, getDefaultProvider, logger$z as logger, platform, providers, utils$1 as utils, version$l as version, browser_2$1 as wordlists }; diff --git a/packages/ethers/dist/ethers.esm.min.js b/packages/ethers/dist/ethers.esm.min.js index e01b66811..3f4a0dec6 100644 --- a/packages/ethers/dist/ethers.esm.min.js +++ b/packages/ethers/dist/ethers.esm.min.js @@ -1 +1 @@ -var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),o=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function u(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,h=0,l=r;l1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var h=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var h=1;h>>26,f=67108863&u,c=Math.min(h,e.length-1),d=Math.max(0,h-t.length+1);d<=c;d++){var p=h-d|0;l+=(s=(i=0|t.words[p])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[h]=0|f,u=0|l}return 0!==u?r.words[h]=0|u:r.length--,r.strip()}o.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?h[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=l[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:h[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return r(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,u="le"===e,h=new t(o),l=this.clone();if(u){for(a=0;!l.isZero();a++)s=l.andln(255),l.iushrn(8),h[a]=s;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],v=8191&g,y=g>>>13,b=0|s[3],w=8191&b,_=b>>>13,E=0|s[4],S=8191&E,A=E>>>13,M=0|s[5],k=8191&M,x=M>>>13,P=0|s[6],N=8191&P,T=P>>>13,I=0|s[7],R=8191&I,B=I>>>13,C=0|s[8],O=8191&C,F=C>>>13,L=0|s[9],D=8191&L,U=L>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,lt=0|a[8],ft=8191<,ct=lt>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(h+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;h=((o=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,o=Math.imul(m,H);var vt=(h+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;h=((o=o+Math.imul(c,G)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(v,j),i=(i=Math.imul(v,H))+Math.imul(y,j)|0,o=Math.imul(y,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,G)|0;var yt=(h+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;h=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(_,j)|0,o=Math.imul(_,H),n=n+Math.imul(v,K)|0,i=(i=i+Math.imul(v,G)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var bt=(h+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;h=((o=o+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(S,j),i=(i=Math.imul(S,H))+Math.imul(A,j)|0,o=Math.imul(A,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,G)|0,n=n+Math.imul(v,V)|0,i=(i=i+Math.imul(v,J)|0)+Math.imul(y,V)|0,o=o+Math.imul(y,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var wt=(h+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;h=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(x,j)|0,o=Math.imul(x,H),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,G)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(v,X)|0,i=(i=i+Math.imul(v,$)|0)+Math.imul(y,X)|0,o=o+Math.imul(y,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,tt)|0;var _t=(h+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;h=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(N,j),i=(i=Math.imul(N,H))+Math.imul(T,j)|0,o=Math.imul(T,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(x,K)|0,o=o+Math.imul(x,G)|0,n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(v,Y)|0,i=(i=i+Math.imul(v,tt)|0)+Math.imul(y,Y)|0,o=o+Math.imul(y,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var Et=(h+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;h=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(B,j)|0,o=Math.imul(B,H),n=n+Math.imul(N,K)|0,i=(i=i+Math.imul(N,G)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(x,V)|0,o=o+Math.imul(x,J)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,tt)|0,n=n+Math.imul(v,rt)|0,i=(i=i+Math.imul(v,nt)|0)+Math.imul(y,rt)|0,o=o+Math.imul(y,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var St=(h+(n=n+Math.imul(f,ut)|0)|0)+((8191&(i=(i=i+Math.imul(f,ht)|0)+Math.imul(c,ut)|0))<<13)|0;h=((o=o+Math.imul(c,ht)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,o=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(B,K)|0,o=o+Math.imul(B,G)|0,n=n+Math.imul(N,V)|0,i=(i=i+Math.imul(N,J)|0)+Math.imul(T,V)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(x,X)|0,o=o+Math.imul(x,$)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,tt)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(_,rt)|0,o=o+Math.imul(_,nt)|0,n=n+Math.imul(v,ot)|0,i=(i=i+Math.imul(v,st)|0)+Math.imul(y,ot)|0,o=o+Math.imul(y,st)|0,n=n+Math.imul(p,ut)|0,i=(i=i+Math.imul(p,ht)|0)+Math.imul(m,ut)|0,o=o+Math.imul(m,ht)|0;var At=(h+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;h=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(D,j),i=(i=Math.imul(D,H))+Math.imul(U,j)|0,o=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,o=o+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(B,V)|0,o=o+Math.imul(B,J)|0,n=n+Math.imul(N,X)|0,i=(i=i+Math.imul(N,$)|0)+Math.imul(T,X)|0,o=o+Math.imul(T,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(x,Y)|0,o=o+Math.imul(x,tt)|0,n=n+Math.imul(S,rt)|0,i=(i=i+Math.imul(S,nt)|0)+Math.imul(A,rt)|0,o=o+Math.imul(A,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(_,ot)|0,o=o+Math.imul(_,st)|0,n=n+Math.imul(v,ut)|0,i=(i=i+Math.imul(v,ht)|0)+Math.imul(y,ut)|0,o=o+Math.imul(y,ht)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,o=o+Math.imul(m,ct)|0;var Mt=(h+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;h=((o=o+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,G))+Math.imul(U,K)|0,o=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(B,X)|0,o=o+Math.imul(B,$)|0,n=n+Math.imul(N,Y)|0,i=(i=i+Math.imul(N,tt)|0)+Math.imul(T,Y)|0,o=o+Math.imul(T,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(x,rt)|0,o=o+Math.imul(x,nt)|0,n=n+Math.imul(S,ot)|0,i=(i=i+Math.imul(S,st)|0)+Math.imul(A,ot)|0,o=o+Math.imul(A,st)|0,n=n+Math.imul(w,ut)|0,i=(i=i+Math.imul(w,ht)|0)+Math.imul(_,ut)|0,o=o+Math.imul(_,ht)|0,n=n+Math.imul(v,ft)|0,i=(i=i+Math.imul(v,ct)|0)+Math.imul(y,ft)|0,o=o+Math.imul(y,ct)|0;var kt=(h+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(D,V),i=(i=Math.imul(D,J))+Math.imul(U,V)|0,o=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(B,Y)|0,o=o+Math.imul(B,tt)|0,n=n+Math.imul(N,rt)|0,i=(i=i+Math.imul(N,nt)|0)+Math.imul(T,rt)|0,o=o+Math.imul(T,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(x,ot)|0,o=o+Math.imul(x,st)|0,n=n+Math.imul(S,ut)|0,i=(i=i+Math.imul(S,ht)|0)+Math.imul(A,ut)|0,o=o+Math.imul(A,ht)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(_,ft)|0,o=o+Math.imul(_,ct)|0;var xt=(h+(n=n+Math.imul(v,pt)|0)|0)+((8191&(i=(i=i+Math.imul(v,mt)|0)+Math.imul(y,pt)|0))<<13)|0;h=((o=o+Math.imul(y,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(D,X),i=(i=Math.imul(D,$))+Math.imul(U,X)|0,o=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(B,rt)|0,o=o+Math.imul(B,nt)|0,n=n+Math.imul(N,ot)|0,i=(i=i+Math.imul(N,st)|0)+Math.imul(T,ot)|0,o=o+Math.imul(T,st)|0,n=n+Math.imul(k,ut)|0,i=(i=i+Math.imul(k,ht)|0)+Math.imul(x,ut)|0,o=o+Math.imul(x,ht)|0,n=n+Math.imul(S,ft)|0,i=(i=i+Math.imul(S,ct)|0)+Math.imul(A,ft)|0,o=o+Math.imul(A,ct)|0;var Pt=(h+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(_,pt)|0))<<13)|0;h=((o=o+Math.imul(_,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(D,Y),i=(i=Math.imul(D,tt))+Math.imul(U,Y)|0,o=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(B,ot)|0,o=o+Math.imul(B,st)|0,n=n+Math.imul(N,ut)|0,i=(i=i+Math.imul(N,ht)|0)+Math.imul(T,ut)|0,o=o+Math.imul(T,ht)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(x,ft)|0,o=o+Math.imul(x,ct)|0;var Nt=(h+(n=n+Math.imul(S,pt)|0)|0)+((8191&(i=(i=i+Math.imul(S,mt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((o=o+Math.imul(A,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(D,rt),i=(i=Math.imul(D,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(O,ot)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(R,ut)|0,i=(i=i+Math.imul(R,ht)|0)+Math.imul(B,ut)|0,o=o+Math.imul(B,ht)|0,n=n+Math.imul(N,ft)|0,i=(i=i+Math.imul(N,ct)|0)+Math.imul(T,ft)|0,o=o+Math.imul(T,ct)|0;var Tt=(h+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(x,pt)|0))<<13)|0;h=((o=o+Math.imul(x,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(D,ot),i=(i=Math.imul(D,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(O,ut)|0,i=(i=i+Math.imul(O,ht)|0)+Math.imul(F,ut)|0,o=o+Math.imul(F,ht)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(B,ft)|0,o=o+Math.imul(B,ct)|0;var It=(h+(n=n+Math.imul(N,pt)|0)|0)+((8191&(i=(i=i+Math.imul(N,mt)|0)+Math.imul(T,pt)|0))<<13)|0;h=((o=o+Math.imul(T,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(D,ut),i=(i=Math.imul(D,ht))+Math.imul(U,ut)|0,o=Math.imul(U,ht),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var Rt=(h+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(B,pt)|0))<<13)|0;h=((o=o+Math.imul(B,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(D,ft),i=(i=Math.imul(D,ct))+Math.imul(U,ft)|0,o=Math.imul(U,ct);var Bt=(h+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;h=((o=o+Math.imul(F,mt)|0)+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863;var Ct=(h+(n=Math.imul(D,pt))|0)+((8191&(i=(i=Math.imul(D,mt))+Math.imul(U,pt)|0))<<13)|0;return h=((o=Math.imul(U,mt))+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,u[0]=gt,u[1]=vt,u[2]=yt,u[3]=bt,u[4]=wt,u[5]=_t,u[6]=Et,u[7]=St,u[8]=At,u[9]=Mt,u[10]=kt,u[11]=xt,u[12]=Pt,u[13]=Nt,u[14]=Tt,u[15]=It,u[16]=Rt,u[17]=Bt,u[18]=Ct,0!==h&&(u[19]=h,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,h=0;h=0&&(0!==l||h>=i);h--){var f=0|this.words[h];this.words[h]=l<<26-o|f>>>o,l=f&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,u=n.length-i.length;if("mod"!==e){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var h=0;h=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},o.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(l),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(f)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),s.isub(u)):(n.isub(e),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:n.iushln(h)}},o.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new E(t)},o.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function v(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function y(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function S(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}v.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},v.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},v.prototype.split=function(t,e){t.iushrn(this.n,0,e)},v.prototype.imulK=function(t){return t.imul(this.k)},n(y,v),y.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},y.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new y;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new _}return g[t]=e,e},E.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new o(2*l*l).toRed(this);0!==this.pow(l,h).cmp(u);)l.redIAdd(u);for(var f=this.pow(l,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var h=e.words[n],l=u-1;l>=0;l--){var f=h>>l&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===l)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new S(t)},n(S,E),S.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},S.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},S.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},S.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},S.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),s=o.BN;const a="logger/5.0.0-beta.129";let u=!1,h=!1;const l={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=l.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=l[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>l[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(h)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach(function(t){o[t]=r[t]}),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(u){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}h=!!t,u=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.129");function v(t){return!!t.toHexString}function y(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return y(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function _(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),y(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),v(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;t_(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),y(n)}function S(t){let e=_(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),y(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function x(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),v(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function P(t){if("string"!=typeof t)t=x(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function N(t,e,r){return"string"!=typeof t?t=x(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function T(t){let e=I(x(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=x(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function B(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=_(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=x(r.slice(0,32)),e.s=x(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=x(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=_(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let o=x(r);null==e.s?e.s=o:e.s!==o&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=_(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=x(r)}}return e}function C(t){return x(E([(t=B(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:_,concat:E,stripZeros:S,zeroPad:A,isHexString:M,hexlify:x,hexDataLength:P,hexDataSlice:N,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=x(t).substring(2)}),e},hexValue:T,hexStripZeros:I,hexZeroPad:R,splitSignature:B,joinSignature:C});const F=new p("bignumber/5.0.0-beta.130"),L={},D=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==L&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(L,z(t)):t.match(/^-?[0-9]+$/)?new U(L,z(new s(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=D||t<=-D)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(x(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new s("-"+e.substring(3),16):new s(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.130"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let o=i[0],s=i[1];for(o||(o="0"),s||(s="0"),s.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");s.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let o=$(n,r.decimals);return new tt(G,i,o,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(_(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),o=$(n,r.decimals);return new tt(G,i,o,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.131");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function ot(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function st(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ut(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ut(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ut(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class ht{constructor(t){for(let e in t)this[e]=ut(t[e]);Object.freeze(this)}}var lt=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:ot,shallowCopy:st,deepCopy:ut,Description:ht});const ft="abi/5.0.0-beta.137",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const vt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),yt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(yt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==vt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===vt.full?", ":",")+")"):e+=this.type,t!==vt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===vt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:Pt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;rbt.fromString(t,e))}class _t{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return _t.isFragment(t)?t:"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){return _t.isFragment(t)?t:"function"===t.type?xt.fromObject(t):"event"===t.type?Et.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return Et.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return xt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class Et extends _t{format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==vt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===vt.full?", ":",")+") ",t!==vt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){if(Et.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new Et(dt,{name:Tt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),Et.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function St(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function At(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends _t{format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===vt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===vt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=St(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),At(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class xt extends kt{format(t){if(t||(t=vt.sighash),vt[t]||ct.throwArgumentError("invalid format type","format",t),t===vt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==vt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===vt.full?", ":",")+") ",t!==vt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?xt.fromString(t):xt.fromObject(t)}static fromObject(t){if(xt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new xt(dt,{type:t.type,name:Tt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=St(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Nt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),At(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return xt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function Pt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Nt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Tt(t){if(!t||!t.match(Nt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Bt{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Ct{constructor(t){rt(this,"wordSize",t||32),this._data=_([]),this._padding=new Uint8Array(t)}get data(){return x(this._data)}get length(){return this._data.length}_writeData(t){return this._data=E([this._data,t]),t.length}writeBytes(t){let e=_(t);return e.length%this.wordSize&&(e=E([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=_(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=E([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",_(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return x(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],h=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},l=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=h(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,s=this.blocks,a=this.byteCount,u=this.blockCount,h=0,l=this.s;h>2]|=t[h]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(s[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=s[u],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(_(r),s=0)}return o&&(t=r[s],o>0&&(u+=i[t>>4&15]+i[15&t]),o>1&&(u+=i[t>>12&15]+i[t>>8&15]),o>2&&(u+=i[t>>20&15]+i[t>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(t);s>8&255,u[t+2]=e>>16&255,u[t+3]=e>>24&255;a%r==0&&_(n)}return o&&(t=a<<2,e=n[s],o>0&&(u[t]=255&e),o>1&&(u[t+1]=e>>8&255),o>2&&(u[t+2]=e>>16&255)),u};var _=function(t){var e,r,n,i,o,a,u,h,l,f,c,d,p,m,g,v,y,b,w,_,E,S,A,M,k,x,P,N,T,I,R,B,C,O,F,L,D,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,ot,st,at,ut,ht,lt;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],u=t[3]^t[13]^t[23]^t[33]^t[43],h=t[4]^t[14]^t[24]^t[34]^t[44],l=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|u>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(u<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(h<<1|l>>>31),r=o^(l<<1|h>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=u^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=h^(d<<1|p>>>31),r=l^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=c^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,N=t[20]<<3|t[21]>>>29,T=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ut=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,v=t[13]<<12|t[12]>>>20,y=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,ht=t[42]<<2|t[43]>>>30,lt=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,L=t[14]<<6|t[15]>>>26,D=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,B=t[45]<<29|t[44]>>>3,C=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,_=t[36]<<21|t[37]>>>11,E=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,x=t[18]<<20|t[19]>>>12,P=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,S=t[48]<<14|t[49]>>>18,A=t[49]<<14|t[48]>>>18,t[0]=m^~v&b,t[1]=g^~y&w,t[10]=M^~x&N,t[11]=k^~P&T,t[20]=O^~L&U,t[21]=F^~D&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=v^~b&_,t[3]=y^~w&E,t[12]=x^~N&I,t[13]=P^~T&R,t[22]=L^~U&j,t[23]=D^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~ot&at,t[43]=it^~st&ut,t[4]=b^~_&S,t[5]=w^~E&A,t[14]=N^~I&B,t[15]=T^~R&C,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=ot^~at&ht,t[45]=st^~ut<,t[6]=_^~S&m,t[7]=E^~A&g,t[16]=I^~B&M,t[17]=R^~C&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~ht&et,t[47]=ut^~lt&rt,t[8]=S^~m&v,t[9]=A^~g&y,t[18]=B^~M&x,t[19]=C^~k&P,t[28]=q^~O&L,t[29]=K^~F&D,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=ht^~et&nt,t[49]=lt^~rt&it,t[0]^=s[n],t[1]^=s[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:x(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:x(t.slice(e+1,e+1+r))}}return{consumed:1,result:x(t[e])}}function qt(t){let e=_(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.128");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=_(Lt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new s(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(N(Lt(zt([e,S(_(t.nonce))])),12))}class Yt extends Bt{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Bt{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Ct(t.wordSize),i=new Ct(t.wordSize),o=[];e.forEach((t,e)=>{let s=r[e];if(t.dynamic){let e=i.length;t.encode(i,s);let r=n.writeUpdatableValue();o.push(t=>{r(t+e)})}else t.encode(n,s)}),o.forEach(t=>{t(n.length)});let s=t.writeBytes(n.data);return s+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let o=null;if(e.dynamic){let r=t.readValue(),s=n.subReader(r.toNumber());o=e.decode(s),i+=s.consumed}else o=e.decode(t);null!=o&&r.push(o)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Bt{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,s=65535}if(n+o>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-o-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Se(t,e=_e.current){e!=_e.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return _(r)}function Ae(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(Ee(t,e))}function xe(t,e=_e.current){return Ee(Se(t,e))}function Pe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Ne(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Te(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(_e||(_e={}));const Ie=Ne("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Be=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Ce=Pe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=Pe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=Pe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Te(t,Be);if(e)return[t+e.s];let r=Ce[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=xe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),_e.NFKC)).forEach(t=>{if(function(t){return!!Te(t,Le)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Te(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends se{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Se(e))}decode(t){return ke(super.decode(t))}}class ze extends Bt{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new oe(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new he(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new ue(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Ct(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(_(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.128"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;t_t.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return N($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?sr(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[xt.fromString(t).format()]}getEvent(t){return M(t)?sr(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[Et.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),x(E([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=_(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===x(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Lt(x(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(x(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))});let s=null!=r?this._abiCoder.decode(n,E(r)):null,a=this._abiCoder.decode(i,e),u=[],h=0,l=0;return t.inputs.forEach((t,e)=>{t.indexed?null==s?u[e]=new ir({_isIndexed:!0,hash:null}):o[e]?u[e]=new ir({_isIndexed:!0,hash:s[l++]}):u[e]=s[l++]:u[e]=a[h++]}),u}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function sr(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.131");class ur extends ht{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class hr{addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}constructor(){ar.checkAbstract(new.target,hr),rt(this,"_isProvider",!0)}static isProvider(t){return!(!t||!t._isProvider)}}const lr=new p("abstract-signer/5.0.0-beta.132"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){lr.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&lr.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=st(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&lr.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{lr.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||lr.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){lr.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{lr.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.137"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function vr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},o=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=st(e.pop())).blockTag&&(o=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(o).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,o).then(r=>{try{let o=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(o=o[0]),o}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ut(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function yr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class _r extends br{constructor(t,e,r,n){let i={address:t},o=e.getEventTopic(r);n?(o!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(yr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class Er extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Sr{constructor(t,e,r){if(pr.checkNew(new.target,Sr),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):hr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=vr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,vr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,vr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,vr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return or.isInterface(t)?t:new or(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=st(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new Er(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new _r(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new _r(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(yr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ut(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=st(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Ar{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?x(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=st(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=x(E([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Sr.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Sr(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Br={inherits:Nr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,o,s,a){var u=0,h=e;return u+=(h=h+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},sum64_5_hi:function(t,e,r,n,i,o,s,a,u,h){var l=0,f=e;return l+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,o,s,a,u,h){return e+n+o+a+h>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Cr(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Cr;Cr.prototype.update=function(t,e){if(t=Br.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Br.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(t){return Lr(t,17)^Lr(t,19)^t>>>10}},Hr=Br.sum32,qr=Br.sum32_4,Kr=Br.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Br.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),xr(t.length<=this.blockSize);for(var e=t.length;e>24&255,l[e.length+1]=f>>16&255,l[e.length+2]=f>>8&255,l[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,l));o||(o=c.length,a=new Uint8Array(o),s=n-((u=Math.ceil(n/o))-1)*o),a.set(c);for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),oi=r(function(t,e){var r=e;r.assert=xr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,u=1;u0||e.cmpn(-i)>0;){var o,s,a,u=t.andln(3)+n&3,h=e.andln(3)+i&3;if(3===u&&(u=-1),3===h&&(h=-1),0==(1&u))o=0;else o=3!==(a=t.andln(7)+n&7)&&5!==a||2!==h?u:-u;if(r[0].push(o),0==(1&h))s=0;else s=3!==(a=e.andln(7)+i&7)&&5!==a||2!==u?h:-h;r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new o(t,"hex","le")}}),si=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=oi.getNAF,ui=oi.getJSF,hi=oi.assert;function li(t,e){this.type=t,this.p=new o(e.p,16),this.red=e.prime?o.red(e.prime):o.mont(this.p),this.zero=new o(0).toRed(this.red),this.one=new o(1).toRed(this.red),this.two=new o(2).toRed(this.red),this.n=e.n&&new o(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=li;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}li.prototype.point=function(){throw new Error("Not implemented")},li.prototype.validate=function(){throw new Error("Not implemented")},li.prototype._fixedNafMul=function(t,e){hi(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=s;e--)a=(a<<1)+n[e];o.push(a)}for(var u=this.jpoint(null,null,null),h=this.jpoint(null,null,null),l=i;l>0;l--){for(s=0;s=0;a--){for(e=0;a>=0&&0===o[a];a--)e++;if(a>=0&&e++,s=s.dblp(e),a<0)break;var u=o[a];hi(0!==u),s="affine"===t.type?u>0?s.mixedAdd(i[u-1>>1]):s.mixedAdd(i[-u-1>>1].neg()):u>0?s.add(i[u-1>>1]):s.add(i[-u-1>>1].neg())}return"affine"===t.type?s.toP():s},li.prototype._wnafMulAdd=function(t,e,r,n,i){for(var o=this._wnafT1,s=this._wnafT2,a=this._wnafT3,u=0,h=0;h=1;h-=2){var f=h-1,c=h;if(1===o[f]&&1===o[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=ui(r[f],r[c]);u=Math.max(m[0].length,u),a[f]=new Array(u),a[c]=new Array(u);for(var g=0;g=0;h--){for(var _=0;h>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),h<0)break;for(g=0;g0?S=s[g][A-1>>1]:A<0&&(S=s[g][-A-1>>1].neg()),b="affine"===S.type?b.mixedAdd(S):b.add(S))}}for(h=0;h=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),h=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:u.add(h).neg()}},pi.prototype.pointFromX=function(t,e){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new o(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Nr(vi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new vi(this,t,e,r)},vi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},vi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},vi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),l=h.redMul(a),f=n.redMul(h),c=u.redSqr().redIAdd(l).redISub(f).redISub(f),d=u.redMul(f.redISub(c)).redISub(o.redMul(l)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},vi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),h=u.redMul(s),l=r.redMul(u),f=a.redSqr().redIAdd(h).redISub(l).redISub(l),c=a.redMul(l.redISub(f)).redISub(i.redMul(h)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},vi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},vi.prototype.inspect=function(){return this.isInfinity()?"":""},vi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var yi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=yi,r.edwards=bi}),_i=r(function(t,e){var r,n=e,i=oi.assert;function o(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Ei(t){if(!(this instanceof Ei))return new Ei(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");xr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Si=Ei;Ei.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},Ei.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var xi=oi.assert;function Pi(t,e){if(t instanceof Pi)return t;this._importDER(t,e)||(xi(t.r&&t.s,"Signature without r or s"),this.r=new o(t.r,16),this.s=new o(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ni=Pi;function Ti(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=e.place;o>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}Pi.prototype._importDER=function(t,e){t=oi.toArray(t,e);var r=new Ti;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var s=Ii(t,r);if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new o(i),this.s=new o(a),this.recoveryParam=null,!0},Pi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Bi(n,e.length),(n=n.concat(e)).push(2),Bi(n,r.length);var i=n.concat(r),o=[48];return Bi(o,i.length),o=o.concat(i),oi.encode(o,t)};var Ci=oi.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Ci(_i.hasOwnProperty(t),"Unknown curve "+t),t=_i[t]),t instanceof _i.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Si({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||si(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new o(2));;){var i=new o(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new o(t,16));for(var i=this.n.byteLength(),s=e.getPrivate().toArray("be",i),a=t.toArray("be",i),u=new Si({hash:this.hash,entropy:s,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),h=this.n.sub(new o(1)),l=0;;l++){var f=n.k?n.k(l):new o(u.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(h)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ni({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new o(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ni(e,"hex")).r,s=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,u=s.invm(this.n),h=u.mul(t).umod(this.n),l=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,r.getPublic(),l)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(h,r.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Ci((3&r)===r,"The recovery param is more than two bits"),e=new Ni(e,n);var i=this.n,s=new o(t),a=e.r,u=e.s,h=1&r,l=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");a=l?this.curve.pointFromX(a.add(this.curve.n),h):this.curve.pointFromX(a,h);var f=e.r.invm(i),c=i.sub(s).mul(f).umod(i),d=u.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ni(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Li={},Di=n(ni),Ui=r(function(t,e){var r=e;r.version=Di.version,r.utils=oi,r.rand=si,r.curve=wi,r.curves=_i,r.ec=Fi,r.eddsa=Li}).ec;const zi=new p("signing-key/5.0.0-beta.129");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",x(t));let e=Hi().keyFromPrivate(_(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(_(this.publicKey)),r=Hi().keyFromPublic(_(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(_(this.privateKey)).sign(_(t),{canonical:!0});return B({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(_(this.privateKey)),r=Hi().keyFromPublic(_(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=B(e),n={r:_(r.r),s:_(r.s)};return"0x"+Hi().recoverPubKey(_(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=_(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?x(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):x(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.128");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(N(Lt(N(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(_(t),e))}function Qi(t,e){ot(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=_(x(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=S(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(x(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(x(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=B(e),o=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),o+=2*t.chainId+8),r.push(x(o)),r.push(S(_(i.r))),r.push(S(_(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(x(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let o=Lt(zt(i));try{r.from=$i(o,{r:x(r.r),s:x(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Lt(t)}return r}var to=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.128"}),eo=(e(to),to.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(to.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var o=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),lt.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||lt.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||lt.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||lt.defineReadOnly(i.ethers.wordlists,r,e))}}})),ro=(e(eo),eo.check,eo.Wordlist,eo.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",s=null;function a(t){if(null==s&&(s=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==eo.check(t)))throw s=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),s[t]},e.prototype.getWordIndex=function(t){return a(this),s.indexOf(t)},e}(eo.Wordlist));r.langEn=u,eo.register(u)})),no=(e(ro),ro.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=eo.Wordlist;var r={en:ro.langEn};e.wordlists=r})),io=(e(no),no.Wordlist),oo=no.wordlists;const so=new p("hdnode/5.0.0-beta.130"),ao=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),uo=Se("Bitcoin seed"),ho=2147483648;function lo(t){return(1<=256)throw new Error("Depth too large!");return co(E([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",x(this.depth),this.parentFingerprint,R(x(this.index),4),this.chainCode,null!=this.privateKey?E(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new go(po,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~ho));let r=new Uint8Array(37);if(t&ho){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(_(this.privateKey),1),e&&(e+="'")}else r.set(_(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=_(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),o=n.slice(32),s=null,a=null;if(this.privateKey)s=fo(U.from(i).add(this.privateKey).mod(ao));else{a=new qi(x(i))._addPoint(this.publicKey)}return new go(po,s,a,this.fingerprint,fo(o),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=ho)throw new Error("invalid path index - "+n);r=r._derive(ho+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invlaid path component - "+n);{let t=parseInt(n);if(t>=ho)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=_(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=_(Yn(Xn.sha512,uo,r));return new go(po,fo(n.slice(0,32)),null,"0x00000000",fo(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=bo(yo(t,r),r),go._fromSeed(vo(t,e),t)}static fromSeed(t){return go._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&co(e.slice(0,78))===t||so.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=x(e.slice(5,9)),i=parseInt(x(e.slice(9,13)).substring(2),16),o=x(e.slice(13,45)),s=e.slice(45,78);switch(x(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new go(po,null,x(s),n,o,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==s[0])break;return new go(po,x(s.slice(1)),null,n,o,i,r,null,null)}return so.throwError("invalid extended key","extendedKey","[REDACTED]")}}function vo(t,e){e||(e="");let r=Se("mnemonic"+e,_e.NFKD);return ei(Se(t,_e.NFKD),r,2048,64,"sha512")}function yo(t,e){e||(e=oo.en),so.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=_(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let o=32*r.length/3,s=lo(r.length/3),a=_(Qn(n.slice(0,o/8)))[0];if((a&=s)!==(n[n.length-1]&s))throw new Error("invalid checksum");return x(n.slice(0,o/8))}function bo(t,e){if((t=_(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=_(Qn(t))[0],o=t.length/4;return i&=lo(o),r[r.length-1]<<=o,r[r.length-1]|=i>>8-o,e||(e=oo.en),e.join(r.map(t=>e.getWord(t)))}var wo=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.128"}),_o=(e(wo),wo.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),Eo=(e(_o),_o.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(wo.version);r.shuffled=_o.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),So=(e(Eo),Eo.shuffled),Ao=Eo.randomBytes,Mo=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function o(t){return new Uint8Array(t)}function s(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,u={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},h=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),l={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],v=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],y=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],S=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=o[e],this._Kd[t-r][e%4]=o[e];for(var s,a=0,u=i;u>16&255]<<24^c[s>>8&255]<<16^c[255&s]<<8^c[s>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[s>>16&255]<<16^c[s>>24&255]<<24;for(e=i/2+1;e>2,d=u%4,this._Ke[h][d]=o[e],this._Kd[t-h][d]=o[e++],u++}for(var h=1;h>24&255]^S[s>>16&255]^A[s>>8&255]^M[255&s]},x.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var s=1;s>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^v[255&n[(i+3)%4]]^this._Ke[s][i];n=r.slice()}var a,u=o(16);for(i=0;i<4;i++)a=this._Ke[e][i],u[4*i]=255&(c[n[i]>>24&255]^a>>24),u[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),u[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return u},x.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var s=1;s>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[s][i];n=r.slice()}var a,u=o(16);for(i=0;i<4;i++)a=this._Kd[e][i],u[4*i]=255&(d[n[i]>>24&255]^a>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return u};var P=function(t){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new x(t)};P.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=o(t.length),r=o(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var B=function(t,e){if(!(this instanceof B))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new x(t)};B.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,v,y=r,b=n,w=i,_=o,E=s,S=a,A=u,M=h;for(p=0;p<16;p++)m=f+4*p,l[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=l[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,v=((d=l[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,l[p]=(g+l[p-7]|0)+(v+l[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&S^~E&A)|0)+(M+(e[p]+l[p]|0)|0)|0,v=((y>>>2|y<<30)^(y>>>13|y<<19)^(y>>>22|y<<10))+(y&b^y&w^b&w)|0,M=A,A=S,S=E,E=_+g|0,_=w,w=b,b=y,y=g+v|0;r=r+y|0,n=n+b|0,i=i+w|0,o=o+_|0,s=s+E|0,a=a+S|0,u=u+A|0,h=h+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,v=t.slice(t.length-d,t.length);for(v.push(128),c=d+1;c>>24&255),v.push(p>>>16&255),v.push(p>>>8&255),v.push(p>>>0&255),v.push(m>>>24&255),v.push(m>>>16&255),v.push(m>>>8&255),v.push(m>>>0&255),f(v),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var o=64+e.length+4,s=new Array(o),a=new Array(64),u=[];for(i=0;i<64;i++)s[i]=54;for(i=0;i=o-4;t--){if(s[t]++,s[t]<=255)return;s[t]=0}}for(;r>=32;)h(),u=u.concat(n(a.concat(n(s)))),r-=32;return r>0&&(h(),u=u.concat(n(a.concat(n(s))).slice(0,r))),u}function o(t,e,r,n,i){var o;for(h(t,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(t,16*o,i,16),a(i,n),h(i,0,t,e+16*o,16);for(o=0;o>>32-e}function a(t,e){h(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=s(e[0]+e[12],7),e[8]^=s(e[4]+e[0],9),e[12]^=s(e[8]+e[4],13),e[0]^=s(e[12]+e[8],18),e[9]^=s(e[5]+e[1],7),e[13]^=s(e[9]+e[5],9),e[1]^=s(e[13]+e[9],13),e[5]^=s(e[1]+e[13],18),e[14]^=s(e[10]+e[6],7),e[2]^=s(e[14]+e[10],9),e[6]^=s(e[2]+e[14],13),e[10]^=s(e[6]+e[2],18),e[3]^=s(e[15]+e[11],7),e[7]^=s(e[3]+e[15],9),e[11]^=s(e[7]+e[3],13),e[15]^=s(e[11]+e[7],18),e[1]^=s(e[0]+e[3],7),e[2]^=s(e[1]+e[0],9),e[3]^=s(e[2]+e[1],13),e[0]^=s(e[3]+e[2],18),e[6]^=s(e[5]+e[4],7),e[7]^=s(e[6]+e[5],9),e[4]^=s(e[7]+e[6],13),e[5]^=s(e[4]+e[7],18),e[11]^=s(e[10]+e[9],7),e[8]^=s(e[11]+e[10],9),e[9]^=s(e[8]+e[11],13),e[10]^=s(e[9]+e[8],18),e[12]^=s(e[15]+e[14],7),e[13]^=s(e[12]+e[15],9),e[14]^=s(e[13]+e[12],13),e[15]^=s(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function u(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,s,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),s=f(s,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/s)throw new Error("N too large");if(s>r/128/a)throw new Error("r too large");if(!l(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!l(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*s),m=new Uint32Array(32*a*s),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(B)};B()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Fo=new Uint8Array(16);Co=function(){return crypto.getRandomValues(Fo),Fo}}if(!Co){var Lo=new Array(16);Co=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Lo[e]=t>>>((3&e)<<3)&255;return Lo}}for(var Do=Co,Uo=[],zo={},jo=0;jo<256;jo++)Uo[jo]=(jo+256).toString(16).substr(1),zo[Uo[jo]]=jo;function Ho(t,e){var r=e||0,n=Uo;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var qo=Do(),Ko=[1|qo[0],qo[1],qo[2],qo[3],qo[4],qo[5]],Go=16383&(qo[6]<<8|qo[7]),Wo=0,Vo=0;function Jo(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Do)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var o=0;o<16;o++)e[n+o]=i[o];return e||Ho(i)}var Zo=Jo;Zo.v1=function(t,e,r){var n=e&&r||0,i=e||[],o=void 0!==(t=t||{}).clockseq?t.clockseq:Go,s=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Vo+1,u=s-Wo+(a-Vo)/1e4;if(u<0&&void 0===t.clockseq&&(o=o+1&16383),(u<0||s>Wo)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Wo=s,Vo=a,Go=o;var h=(1e4*(268435455&(s+=122192928e5))+a)%4294967296;i[n++]=h>>>24&255,i[n++]=h>>>16&255,i[n++]=h>>>8&255,i[n++]=255&h;var l=s/4294967296*1e4&268435455;i[n++]=l>>>8&255,i[n++]=255&l,i[n++]=l>>>24&15|16,i[n++]=l>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var f=t.node||Ko,c=0;c<6;c++)i[n+c]=f[c];return e||Ho(i)},Zo.v4=Jo,Zo.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=zo[t])});i<16;)e[n+i++]=0;return e},Zo.unparse=Ho;var Xo=Zo;class $o extends ht{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function Qo(t,e,r){let n=JSON.parse(t),i=Po(e),o=function(t,e){let r=ko(No(n,"crypto/ciphertext"));if(x(function(t,e){return Lt(E([t,e]))}(t.slice(16,32),r)).substring(2)!==No(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===No(n,"crypto/cipher")){let r=ko(No(n,"crypto/cipherparams/iv")),i=new Mo.Counter(r);return _(new Mo.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),o=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let s=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==s)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:s,privateKey:x(i)};if("0.1"===No(n,"x-ethers/version")){let t=ko(No(n,"x-ethers/mnemonicCiphertext")),r=ko(No(n,"x-ethers/mnemonicCounter")),i=new Mo.Counter(r),s=new Mo.ModeOfOperation.ctr(o,i),u=No(n,"x-ethers/path")||mo,h=bo(_(s.decrypt(t))),l=go.fromMnemonic(h).derivePath(u);if(l.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=l.mnemonic,a.path=l.path}return new $o(a)};return new Promise(function(t,e){let s=No(n,"crypto/kdf");if(s&&"string"==typeof s)if("scrypt"===s.toLowerCase()){let s=ko(No(n,"crypto/kdfparams/salt")),a=parseInt(No(n,"crypto/kdfparams/n")),u=parseInt(No(n,"crypto/kdfparams/r")),h=parseInt(No(n,"crypto/kdfparams/p"));if(!a||!u||!h)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(No(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Oo(i,s,a,u,h,64,function(n,i,s){if(n)n.progress=i,e(n);else if(s){s=_(s);let n=o(s,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===s.toLowerCase()){let r=ko(No(n,"crypto/kdfparams/salt")),s=null,a=No(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)s="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));s="sha512"}let u=parseInt(No(n,"crypto/kdfparams/c")),h=parseInt(No(n,"crypto/kdfparams/dklen"));if(32!==h)return void e(new Error("unsupported key-derivation derived-key length"));let l=_(ei(i,r,u,h,s)),f=o(l,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Yo(t,e,r){if(Ro(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=Po(e);let n=$t(No(r,"ethaddr")),i=ko(No(r,"encseed"));i&&i.length%16==0||To.throwArgumentError("invalid encseed","json",t);let o=_(ei(e,e,2e3,32,"sha256")).slice(0,16),s=i.slice(0,16),a=i.slice(16),u=_(new Mo.ModeOfOperation.cbc(o,s).decrypt(a));u=Mo.padding.pkcs7.strip(u);let h="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&ts.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||mo;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(go.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&ts.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&ts.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!hr.isProvider(e)&&ts.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new es(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Lt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(C(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(go.fromMnemonic(t.mnemonic).derivePath(t.path||mo).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=_(t.privateKey),o=Po(e),s=null,a=t.path;t.mnemonic&&(s=_(yo(t.mnemonic)),a||(a=mo));let u=r.client;u||(u="ethers.js");let h=null;h=r.salt?_(r.salt):Ao(32);let l=null;if(r.iv){if(16!==(l=_(r.iv)).length)throw new Error("invalid iv")}else l=Ao(16);let f=null;if(r.uuid){if(16!==(f=_(r.uuid)).length)throw new Error("invalid uuid")}else f=Ao(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Oo(o,h,c,d,p,64,function(o,m,g){if(o)o.progress=m,r(o);else if(g){let r=(g=_(g)).slice(0,16),o=g.slice(16,32),m=g.slice(32,64),v=new Mo.Counter(l),y=_(new Mo.ModeOfOperation.ctr(r,v).encrypt(i)),b=Lt(E([o,y])),w={address:t.address.substring(2).toLowerCase(),id:Xo.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:x(l).substring(2)},ciphertext:x(y).substring(2),kdf:"scrypt",kdfparams:{salt:x(h).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(s){let t=Ao(16),e=new Mo.Counter(t),r=_(new Mo.ModeOfOperation.ctr(m,e).encrypt(s)),n=new Date,i=n.getUTCFullYear()+"-"+xo(n.getUTCMonth()+1,2)+"-"+xo(n.getUTCDate(),2)+"T"+xo(n.getUTCHours(),2)+"-"+xo(n.getUTCMinutes(),2)+"-"+xo(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:u,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:x(t).substring(2),mnemonicCiphertext:x(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=Ao(16);t||(t={}),t.extraEntropy&&(e=_(N(Lt(E([e,t.extraEntropy])),0,16)));let r=bo(e,t.locale);return es.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Yo(t,e,r).then(t=>new es(t))}static fromMnemonic(t,e,r){return e||(e=mo),new es(go.fromMnemonic(t,null,r).derivePath(e))}}const rs=new p("networks/5.0.0-beta.129");function ns(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function is(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const os={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ns("homestead")},ss={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ns("ropsten")},as={unspecified:{chainId:0,name:"unspecified"},homestead:os,mainnet:os,morden:{chainId:2,name:"morden"},ropsten:ss,testnet:ss,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ns("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ns("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ns("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:is("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:is("https://web3.gastracker.io/morden","classicTestnet")}};function us(t){if(null==t)return null;if("number"==typeof t){for(let e in as){let r=as[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=as[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=as[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&rs.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&rs.throwArgumentError("invalid network chainId","network",t),t)}var hs=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=l(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=h(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=l(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function v(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},v.error=function(){var t=new v(null,{status:0,statusText:""});return t.type="error",t};var y=[301,302,303,307,308];v.redirect=function(t,e){if(-1===y.indexOf(e))throw new RangeError("Invalid status code");return new v(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,o){var s=new m(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new v(n,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",h)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=u,t.Request=m,t.Response=v),e.Headers=u,e.Request=m,e.Response=v,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),ls=(hs.fetch,hs.Headers,hs.Request,hs.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(s=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&ms.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+ds(Se(e))}}}return new Promise(function(t,a){let u=null;s&&(u=setTimeout(()=>{null!=u&&(u=null,a(ms.makeError("timeout",p.errors.TIMEOUT,{timeout:s})))},s));let h=()=>{null!=u&&(clearTimeout(u),u=null)};e&&(o.method="POST",o.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let l={};return Object.keys(n).forEach(t=>{let e=n[t];l[e.key]=e.value}),o.headers=l,hs(i,o).then(t=>t.text().then(e=>(t.ok||ms.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){ms.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){ms.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{h(),t(e)},t=>{h(),a(t)})})}function vs(t,e){return e||(e={}),null==(e=st(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,o=!1,s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{s()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,u=0;!function i(){return t().then(function(t){if(void 0!==t)s()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!o){if(++u>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,u)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){s()&&n(t)})}()})}const ys="providers/5.0.0-beta.141",bs=new p(ys);class ws{constructor(){bs.checkNew(new.target,ws),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:o,blockHash:ws.allowNull(o,null),blockNumber:ws.allowNull(a,null),transactionIndex:ws.allowNull(a,null),confirmations:ws.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:ws.allowNull(e,null),value:r,nonce:a,data:i,r:ws.allowNull(this.uint256),s:ws.allowNull(this.uint256),v:ws.allowNull(a),creates:ws.allowNull(e,null),raw:ws.allowNull(i)},t.transactionRequest={from:ws.allowNull(e),nonce:ws.allowNull(a),gasLimit:ws.allowNull(r),gasPrice:ws.allowNull(r),to:ws.allowNull(e),value:ws.allowNull(r),data:ws.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:ws.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:o,address:e,topics:ws.arrayOf(o),data:i,logIndex:a,blockHash:o},t.receipt={to:ws.allowNull(this.address),from:ws.allowNull(this.address),contractAddress:ws.allowNull(e,null),transactionIndex:a,root:ws.allowNull(o),gasUsed:r,logsBloom:ws.allowNull(i),blockHash:o,transactionHash:o,logs:ws.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ws.allowNull(a,null),cumulativeGasUsed:r,status:ws.allowNull(a)},t.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ws.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:ws.allowNull(ws.arrayOf(o))},t.blockWithTransactions=st(t.block),t.blockWithTransactions.transactions=ws.allowNull(ws.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:ws.allowNull(n,void 0),toBlock:ws.allowNull(n,void 0),blockHash:ws.allowNull(o,void 0),address:ws.allowNull(e,void 0),topics:ws.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:ws.allowNull(a),blockHash:ws.allowNull(o),transactionIndex:a,removed:ws.allowNull(this.boolean.bind(this)),address:e,data:ws.allowFalsish(i,"0x"),topics:ws.arrayOf(o),transactionHash:o,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bs.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(N(t,12));return e===le?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return T(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==P(r)?bs.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),ws.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return ws.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=ws.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return ws.check(this.formats.receiptLog,t)}receipt(t){let e=ws.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return ws.check(this.formats.filter,t)}filterLog(t){return ws.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const _s=new p(ys);function Es(t){return null==t?"null":(32!==P(t)&&_s.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function Ss(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[Es(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return Es(t)}).join("&")}function As(t){if("string"==typeof t){if(32===P(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+Ss(t);if(ur.isForkEvent(t))throw _s.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+Ss(t.topics||[])}throw new Error("invalid event - "+t)}function Ms(){return(new Date).getTime()}class ks{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let xs=null,Ps=1;class Ns extends hr{constructor(t){if(_s.checkNew(new.target,hr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):_s.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==xs&&(xs=new ws),xs}static getNetwork(t){return us(null==t?"homestead":t)}poll(){let t=Ps++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let o=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(o);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Ms();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>x(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>T(t))}).then(t=>x(t))}_wrapTransaction(t,e){if(null!=e&&32!==P(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&_s.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&_s.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>x(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>x(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&_s.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){_s.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return vs(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return vs(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return vs(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>ws.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&_s.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||_s.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=_(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return _s.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ks(As(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=As(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=As(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=As(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=As(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=As(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const Ts=new p(ys);function Is(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Rs(t){return t?t.toLowerCase():t}const Bs={};class Cs extends cr{constructor(t,e,r){if(Ts.checkNew(new.target,Cs),super(),t!==Bs)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):Ts.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Ts.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Os(Bs,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Ts.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=st(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=st(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&Ts.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&Ts.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&Ts.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return Ts.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>vs(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Se(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),x(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Os extends Cs{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fs={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Ls extends Ns{constructor(t,e){if(Ts.checkNew(new.target,Ls),"string"==typeof t&&null===e&&us(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(us(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(us(U.from(e).toNumber()))}).catch(t=>{e(Ts.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Cs(Bs,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ut(r),provider:this}),gs(this.connection,JSON.stringify(r),Is).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Rs(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Rs(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Rs(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Rs(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&Ts.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&Ts.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&Ts.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):Ts.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Rs(e.filter.address)),this.send("eth_getLogs",[e.filter])}return Ts.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=st(Fs);if(e)for(let t in e)e[t]&&(r[t]=!0);ot(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=T(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=x(t[e]))}),n}}const Ds=new p(ys);class Us extends Ls{constructor(t,e){Ds.checkAbstract(new.target,Us),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Ds.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Ds.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return us(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Ds.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zs=new p(ys),js="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Hs=new p(ys);const qs=new p(ys);function Ks(t){let e=[];for(let r in t){if(null==t[r])continue;let n=x(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=T(n)),e.push(r+"="+n)}return e.join("&")}function Gs(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Ws(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vs(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Js extends Ns{constructor(t,e){qs.checkNew(new.target,Js),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),gs(t,null,e||Ws).then(e=>(this.emit("debug",{action:"response",request:t,response:ut(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Gs);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Ws);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Ws);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qs.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qs.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qs.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ks(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ks(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vs(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vs(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let o=this;return i(r+=n,Gs).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?o.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Gs).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),gs(n,null,Gs).then(t=>{this.emit("debug",{action:"response",request:n,response:ut(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zs=new p(ys);function Xs(){return(new Date).getTime()}function $s(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zs.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qs=1;class Ys extends Ns{constructor(t,e,r){Zs.checkNew(new.target,Ys),0===t.length&&Zs.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zs.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zs.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zs.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$s(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($s(t)||Zs.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zs.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xs(),n=So(this.providers).map((n,i)=>{let o=this.weights[i],s=Qs++;return{run:()=>{let i=Xs(),a=i-r;return this.emit("debug",{action:"request",rid:s,backend:{weight:o,start:a,provider:n},request:{method:t,params:ut(e)},provider:this}),Ys.doPerform(n,t,e).then(r=>{let u=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:u,provider:n},request:{method:t,params:ut(e)},response:ut(r)}),{weight:o,result:r}},r=>{let u=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:u,provider:n},request:{method:t,params:ut(e)},error:r}),{weight:o,error:r}})},weight:o}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let o=null,s=0,a={},u=()=>{if(0===n.length)return;let h=n.shift();s+=h.weight,h.run().then(l=>{if(null!==a){if(s-=h.weight,l.error)null==o&&(o=l.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(l.result);null==a[t]&&(a[t]=[]),a[t].push(l);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===s){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===o&&(o=Zs.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(o)}setTimeout(u,0)}}),s{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(ys),ia="84842078b09946638c03157f83405213";const oa=new p(ys),sa="ETHERS_JS_SHARED";const aa=new p(ys);class ua extends Ls{constructor(t,e){aa.checkNew(new.target,ua),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var ha=Object.freeze({Provider:hr,BaseProvider:Ns,FallbackProvider:Ys,AlchemyProvider:class extends Us{static getApiKey(t){return null==t?js:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zs.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Us{static getUrl(t,e){null!=e&&Hs.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Hs.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Js,InfuraProvider:class extends Us{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Ls,NodesmithProvider:class extends Us{static getApiKey(t){return t||sa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:oa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ua,IpcProvider:ra,JsonRpcSigner:Cs,getNetwork:us,Formatter:ws});const la=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?A(r,32):_(r);case"string":return Se(r);case"bytes":return _(r);case"bool":return r=r?"0x01":"0x00",n?A(r,32):_(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),A(r=U.from(r).toTwos(t),t/8)}if(i=e.match(la)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(_(r).byteLength!==t)throw new Error("invalid value for "+e);return n?_((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let o=[];return r.forEach(function(e){o.push(t(n,e,!0))}),E(o)}throw new Error("unknown type - "+e)}(t,e[n]))}),x(E(r))}var ma=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="bignumber/5.0.0-beta.130"}),ga=(e(ma),ma.version,r(function(e,r){var n=t&&t.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e};Object.defineProperty(r,"__esModule",{value:!0});var i=n(o),s=new m.Logger(ma.version),a={};r.isBigNumberish=function(t){return null!=t&&(u.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||O.isHexString(t)||"bigint"==typeof t||O.isBytes(t))};var u=function(){function t(e,r){var n=this.constructor;s.checkNew(n,t),e!==a&&s.throwError("cannot call consturtor directly; use BigNumber.from",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return t.prototype.fromTwos=function(t){return l(f(this).fromTwos(t))},t.prototype.toTwos=function(t){return l(f(this).toTwos(t))},t.prototype.abs=function(){return"-"===this._hex[0]?t.from(this._hex.substring(1)):this},t.prototype.add=function(t){return l(f(this).add(f(t)))},t.prototype.sub=function(t){return l(f(this).sub(f(t)))},t.prototype.div=function(e){return t.from(e).isZero()&&c("division by zero","div"),l(f(this).div(f(e)))},t.prototype.mul=function(t){return l(f(this).mul(f(t)))},t.prototype.mod=function(t){return l(f(this).mod(f(t)))},t.prototype.pow=function(t){return l(f(this).pow(f(t)))},t.prototype.maskn=function(t){return l(f(this).maskn(t))},t.prototype.eq=function(t){return f(this).eq(f(t))},t.prototype.lt=function(t){return f(this).lt(f(t))},t.prototype.lte=function(t){return f(this).lte(f(t))},t.prototype.gt=function(t){return f(this).gt(f(t))},t.prototype.gte=function(t){return f(this).gte(f(t))},t.prototype.isZero=function(){return f(this).isZero()},t.prototype.toNumber=function(){try{return f(this).toNumber()}catch(t){c("overflow","toNumber",this.toString())}return null},t.prototype.toString=function(){return 0!==arguments.length&&s.throwError("bigNumber.toString does not accept parameters",m.Logger.errors.UNEXPECTED_ARGUMENT,{}),f(this).toString(10)},t.prototype.toHexString=function(){return this._hex},t.from=function(e){return e instanceof t?e:"string"==typeof e?e.match(/-?0x[0-9a-f]+/i)?new t(a,h(e)):e.match(/^-?[0-9]+$/)?new t(a,h(new i.BN(e))):s.throwArgumentError("invalid BigNumber string","value",e):"number"==typeof e?(e%1&&c("underflow","BigNumber.from",e),(e>=9007199254740991||e<=-9007199254740991)&&c("overflow","BigNumber.from",e),t.from(String(e))):"bigint"==typeof e?t.from(e.toString()):O.isBytes(e)?t.from(O.hexlify(e)):e._hex&&O.isHexString(e._hex)?t.from(e._hex):e.toHexString&&"string"==typeof(e=e.toHexString())?t.from(e):s.throwArgumentError("invalid BigNumber value","value",e)},t.isBigNumber=function(t){return!(!t||!t._isBigNumber)},t}();function h(t){if("string"!=typeof t)return h(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&s.throwArgumentError("invalid hex","value",t),"0x00"===(t=h(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function l(t){return u.from(h(t))}function f(t){var e=u.from(t).toHexString();return"-"===e[0]?new i.BN("-"+e.substring(3),16):new i.BN(e.substring(2),16)}function c(t,e,r){var n={fault:t,operation:e};return null!=r&&(n.value=r),s.throwError(t,m.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),va=(e(ga),ga.isBigNumberish,ga.BigNumber,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});var r=new m.Logger(ma.version),n={},i=ga.BigNumber.from(0),o=ga.BigNumber.from(-1);function s(t,e,n,i){var o={fault:e,operation:n};return void 0!==i&&(o.value=i),r.throwError(t,m.Logger.errors.NUMERIC_FAULT,o)}for(var a="0";a.length<256;)a+=a;function u(t){if("number"!=typeof t)try{t=ga.BigNumber.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+a.substring(0,t):r.throwArgumentError("invalid decimal size","decimals",t)}function h(t,e){null==e&&(e=0);var r=u(e),n=(t=ga.BigNumber.from(t)).lt(i);n&&(t=t.mul(o));for(var s=t.mod(r).toString();s.length2&&r.throwArgumentError("too many decimal points","value",t);var h=a[0],l=a[1];for(h||(h="0"),l||(l="0"),l.length>n.length-1&&s("fractional component exceeds decimals","underflow","parseFixed");l.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",s),new t(n,i,o,s)},t}();e.FixedFormat=f;var c=function(){function t(e,n,i,o){var s=this.constructor;r.checkNew(s,t),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return t.prototype._checkFormat=function(t){this.format.name!==t.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)},t.prototype.addUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.add(n),this.format.decimals,this.format)},t.prototype.subUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.sub(n),this.format.decimals,this.format)},t.prototype.mulUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},t.prototype.divUnsafe=function(e){this._checkFormat(e);var r=l(this._value,this.format.decimals),n=l(e._value,e.format.decimals);return t.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},t.prototype.round=function(e){null==e&&(e=0),(e<0||e>80||e%1)&&r.throwArgumentError("invalid decimal cound","decimals",e);var n=this.toString().split(".");if(n[1].length<=e)return this;var i="0."+a.substring(0,e)+"5";return n=this.addUnsafe(t.fromString(i,this.format))._value.split("."),t.fromString(n[0]+"."+n[1].substring(0,e))},t.prototype.toString=function(){return this._value},t.prototype.toHexString=function(t){if(null==t)return this._hex;t%8&&r.throwArgumentError("invalid byte width","width",t);var e=ga.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString();return O.hexZeroPad(e,t/8)},t.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},t.prototype.toFormat=function(e){return t.fromString(this._value,e)},t.fromValue=function(e,r,n){return null!=n||null==r||ga.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),t.fromString(h(e,r),f.from(n))},t.fromString=function(e,r){null==r&&(r="fixed");var o=f.from(r),a=l(e,o.decimals);!o.signed&&a.lt(i)&&s("unsigned value cannot be negative","overflow","value",e);var u=null;o.signed?u=a.toTwos(o.width).toHexString():(u=a.toHexString(),u=O.hexZeroPad(u,o.width/8));var c=h(a,o.decimals);return new t(n,u,c,o)},t.fromBytes=function(e,r){null==r&&(r="fixed");var i=f.from(r);if(O.arrayify(e).length>i.width/8)throw new Error("overflow");var o=ga.BigNumber.from(e);i.signed&&(o=o.fromTwos(i.width));var s=o.toTwos((i.signed?0:1)+i.width).toHexString(),a=h(o,i.decimals);return new t(n,s,a,i)},t.from=function(e,n){if("string"==typeof e)return t.fromString(e,n);if(O.isBytes(e))return t.fromBytes(e,n);try{return t.fromValue(e,0,n)}catch(t){if(t.code!==m.Logger.errors.INVALID_ARGUMENT)throw t}return r.throwArgumentError("invalid FixedNumber value","value",e)},t.isFixedNumber=function(t){return!(!t||!t._isFixedNumber)},t}();e.FixedNumber=c})),ya=(e(va),va.formatFixed),ba=va.parseFixed;va.FixedFormat,va.FixedNumber;const wa=new p("units/5.0.0-beta.127"),_a=["wei","kwei","mwei","gwei","szabo","finney","ether"];function Ea(t,e){if("string"==typeof e){let t=_a.indexOf(e);-1!==t&&(e=3*t)}return ya(t,null!=e?e:18)}function Sa(t,e){if("string"==typeof e){let t=_a.indexOf(e);-1!==t&&(e=3*t)}return ba(t,null!=e?e:18)}var Aa=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:_t,EventFragment:Et,FunctionFragment:xt,ParamType:bt,FormatTypes:vt,Logger:p,RLP:Kt,fetchJson:gs,poll:vs,checkProperties:ot,deepCopy:ut,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:st,arrayify:_,concat:E,stripZeros:S,zeroPad:A,defaultPath:mo,HDNode:go,SigningKey:qi,Interface:or,base64:ps,hexlify:x,isHexString:M,hexStripZeros:I,hexValue:T,hexZeroPad:R,hexDataLength:P,hexDataSlice:N,nameprep:De,_toEscapedUtf8String:function(t,e){return'"'+Ee(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Ae(t):Ae(55296+((t-=65536)>>10&1023))+Ae(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Se,toUtf8CodePoints:xe,toUtf8String:ke,formatBytes32String:function(t){let e=Se(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return x(E([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=_(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new s($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return Ea(t,18)},parseEther:function(t){return Sa(t,18)},formatUnits:Ea,parseUnits:Sa,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&wa.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let o=[];for(;r.length;){if(r.length<=3){o.unshift(r);break}{let t=r.length-3;o.unshift(r.substring(t)),r=r.substring(0,t)}}return n+o.join(",")+i},keccak256:Lt,sha256:Qn,randomBytes:Ao,solidityPack:pa,solidityKeccak256:function(t,e){return Lt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:B,joinSignature:C,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Ro(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Bo(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:yo,entropyToMnemonic:bo,isValidMnemonic:function(t,e){try{return yo(t,e),!0}catch(t){}return!1},mnemonicToSeed:vo,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return _e},Indexed:ir});const Ma="node",ka="ethers/5.0.0-beta.156",xa=p.errors,Pa=new p(ka);function Na(t,e){null==t&&(t="homestead");let r=us(t);return r&&r._defaultProvider||Pa.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(ha,e)}var Ta=Object.freeze({version:ka,Signer:cr,Wallet:es,VoidSigner:dr,getDefaultProvider:Na,providers:ha,Contract:Sr,ContractFactory:Ar,BigNumber:U,FixedNumber:tt,constants:ye,errors:xa,logger:Pa,utils:Aa,wordlists:oo,platform:"node",Wordlist:io});window.ethers=Ta;export{U as BigNumber,Sr as Contract,Ar as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,es as Wallet,io as Wordlist,ye as constants,xa as errors,Ta as ethers,Na as getDefaultProvider,Pa as logger,Ma as platform,ha as providers,Aa as utils,ka as version,oo as wordlists}; +var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),o=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,l=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var l=1;l>>26,f=67108863&h,c=Math.min(l,e.length-1),d=Math.max(0,l-t.length+1);d<=c;d++){var p=l-d|0;u+=(s=(i=0|t.words[p])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[l]=0|f,h=0|u}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}o.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?l[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=u[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:l[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return r(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,l=new t(o),u=this.clone();if(h){for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),l[a]=s;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,b=0|s[3],w=8191&b,E=b>>>13,_=0|s[4],A=8191&_,S=_>>>13,M=0|s[5],k=8191&M,P=M>>>13,x=0|s[6],T=8191&x,N=x>>>13,I=0|s[7],R=8191&I,C=I>>>13,B=0|s[8],O=8191&B,F=B>>>13,D=0|s[9],L=8191&D,U=D>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,lt=at>>>13,ut=0|a[8],ft=8191&ut,ct=ut>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;l=((o=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,o=Math.imul(m,H);var yt=(l+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;l=((o=o+Math.imul(c,G)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,H))+Math.imul(v,j)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,G)|0;var vt=(l+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;l=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(E,j)|0,o=Math.imul(E,H),n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var bt=(l+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;l=((o=o+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,H))+Math.imul(S,j)|0,o=Math.imul(S,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,K)|0,o=o+Math.imul(E,G)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var wt=(l+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;l=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(P,j)|0,o=Math.imul(P,H),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,K)|0,o=o+Math.imul(S,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,tt)|0;var Et=(l+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;l=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(T,j),i=(i=Math.imul(T,H))+Math.imul(N,j)|0,o=Math.imul(N,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,G)|0,n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(S,V)|0,o=o+Math.imul(S,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var _t=(l+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;l=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(C,j)|0,o=Math.imul(C,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(N,K)|0,o=o+Math.imul(N,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(S,X)|0,o=o+Math.imul(S,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var At=(l+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(c,ht)|0))<<13)|0;l=((o=o+Math.imul(c,lt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,o=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,$)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,lt)|0;var St=(l+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;l=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,H))+Math.imul(U,j)|0,o=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,o=o+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,o=o+Math.imul(m,ct)|0;var Mt=(l+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((o=o+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,G))+Math.imul(U,K)|0,o=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,lt)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var kt=(l+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,J))+Math.imul(U,V)|0,o=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(N,rt)|0,o=o+Math.imul(N,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,o=o+Math.imul(S,lt)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Pt=(l+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((o=o+Math.imul(v,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,$))+Math.imul(U,X)|0,o=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(S,ft)|0,o=o+Math.imul(S,ct)|0;var xt=(l+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((o=o+Math.imul(E,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,tt))+Math.imul(U,Y)|0,o=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(N,ht)|0,o=o+Math.imul(N,lt)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Tt=(l+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((o=o+Math.imul(S,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(O,ot)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(N,ft)|0,o=o+Math.imul(N,ct)|0;var Nt=(l+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((o=o+Math.imul(P,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,lt)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,ct)|0;var It=(l+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((o=o+Math.imul(N,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var Rt=(l+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(C,pt)|0))<<13)|0;l=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul(U,ft)|0,o=Math.imul(U,ct);var Ct=(l+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;l=((o=o+Math.imul(F,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(l+(n=Math.imul(L,pt))|0)+((8191&(i=(i=Math.imul(L,mt))+Math.imul(U,pt)|0))<<13)|0;return l=((o=Math.imul(U,mt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Et,h[6]=_t,h[7]=At,h[8]=St,h[9]=Mt,h[10]=kt,h[11]=Pt,h[12]=xt,h[13]=Tt,h[14]=Nt,h[15]=It,h[16]=Rt,h[17]=Ct,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,l=0;l=0&&(0!==u||l>=i);l--){var f=0|this.words[l];this.words[l]=u<<26-o|f>>>o,u=f&a}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,h=n.length-i.length;if("mod"!==e){(a=new o(null)).length=h+1,a.words=new Array(a.length);for(var l=0;l=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},o.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),h=new o(1),l=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++l;for(var u=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(u),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(u),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),s.isub(h)):(n.isub(e),a.isub(i),h.isub(s))}return{a:a,b:h,gcd:n.iushln(l)}},o.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var l=0,u=1;0==(e.words[0]&u)&&l<26;++l,u<<=1);if(l>0)for(e.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new _(t)},o.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),h=a.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new o(2*u*u).toRed(this);0!==this.pow(u,l).cmp(h);)u.redIAdd(h);for(var f=this.pow(u,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var l=e.words[n],u=h-1;u>=0;u--){var f=l>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}h=26}return i},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new A(t)},n(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),s=o.BN;const a="logger/5.0.0-beta.128";let h=!1,l=!1;const u={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=u.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=u[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>u[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(l)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach(function(t){o[t]=r[t]}),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(h){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}l=!!t,h=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.128");function y(t){return!!t.toHexString}function v(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return v(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function E(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),v(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;tE(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),v(n)}function A(t){let e=E(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),v(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function P(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function x(t){if("string"!=typeof t)t=P(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function T(t,e,r){return"string"!=typeof t?t=P(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function N(t){let e=I(P(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=P(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function C(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=E(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=P(r.slice(0,32)),e.s=P(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=P(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=E(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let o=P(r);null==e.s?e.s=o:e.s!==o&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=E(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=P(r)}}return e}function B(t){return P(_([(t=C(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:E,concat:_,stripZeros:A,zeroPad:S,isHexString:M,hexlify:P,hexDataLength:x,hexDataSlice:T,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=P(t).substring(2)}),e},hexValue:N,hexStripZeros:I,hexZeroPad:R,splitSignature:C,joinSignature:B});const F=new p("bignumber/5.0.0-beta.129"),D={},L=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==D&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(D,z(t)):t.match(/^-?[0-9]+$/)?new U(D,z(new s(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=L||t<=-L)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(P(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new s("-"+e.substring(3),16):new s(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.129"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let o=i[0],s=i[1];for(o||(o="0"),s||(s="0"),s.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");s.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let o=$(n,r.decimals);return new tt(G,i,o,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(E(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),o=$(n,r.decimals);return new tt(G,i,o,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.130");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function ot(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function st(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ht(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ht(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ht(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class lt{constructor(t){for(let e in t)this[e]=ht(t[e]);Object.freeze(this)}}var ut=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:ot,shallowCopy:st,deepCopy:ht,Description:lt});const ft="abi/5.0.0-beta.136",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const yt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(vt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==yt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===yt.full?", ":",")+")"):e+=this.type,t!==yt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===yt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:xt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;rbt.fromString(t,e))}class Et{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return Et.isFragment(t)?t:"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){return Et.isFragment(t)?t:"function"===t.type?Pt.fromObject(t):"event"===t.type?_t.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return _t.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return Pt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class _t extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){if(_t.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new _t(dt,{name:Nt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),_t.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function At(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function St(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===yt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=At(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),St(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Pt extends kt{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Pt.fromString(t):Pt.fromObject(t)}static fromObject(t){if(Pt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new Pt(dt,{type:t.type,name:Nt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=At(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Tt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),St(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return Pt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function xt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Tt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Nt(t){if(!t||!t.match(Tt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Ct{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Bt{constructor(t){rt(this,"wordSize",t||32),this._data=E([]),this._padding=new Uint8Array(t)}get data(){return P(this._data)}get length(){return this._data.length}_writeData(t){return this._data=_([this._data,t]),t.length}writeBytes(t){let e=E(t);return e.length%this.wordSize&&(e=_([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=E(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=_([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",E(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return P(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],h=["hex","buffer","arrayBuffer","array"],l=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},u=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=l(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,s=this.blocks,a=this.byteCount,h=this.blockCount,l=0,u=this.s;l>2]|=t[l]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(s[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=s[h],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(E(r),s=0)}return o&&(t=r[s],o>0&&(h+=i[t>>4&15]+i[15&t]),o>1&&(h+=i[t>>12&15]+i[t>>8&15]),o>2&&(h+=i[t>>20&15]+i[t>>16&15])),h},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);s>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&E(n)}return o&&(t=a<<2,e=n[s],o>0&&(h[t]=255&e),o>1&&(h[t+1]=e>>8&255),o>2&&(h[t+2]=e>>16&255)),h};var E=function(t){var e,r,n,i,o,a,h,l,u,f,c,d,p,m,g,y,v,b,w,E,_,A,S,M,k,P,x,T,N,I,R,C,B,O,F,D,L,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,ot,st,at,ht,lt,ut;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],h=t[3]^t[13]^t[23]^t[33]^t[43],l=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|h>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(h<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(l<<1|u>>>31),r=o^(u<<1|l>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=h^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=l^(d<<1|p>>>31),r=u^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=c^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,T=t[20]<<3|t[21]>>>29,N=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,lt=t[42]<<2|t[43]>>>30,ut=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,L=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,B=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,E=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,P=t[18]<<20|t[19]>>>12,x=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,A=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=m^~y&b,t[1]=g^~v&w,t[10]=M^~P&T,t[11]=k^~x&N,t[20]=O^~D&U,t[21]=F^~L&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=y^~b&E,t[3]=v^~w&_,t[12]=P^~T&I,t[13]=x^~N&R,t[22]=D^~U&j,t[23]=L^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~ot&at,t[43]=it^~st&ht,t[4]=b^~E&A,t[5]=w^~_&S,t[14]=T^~I&C,t[15]=N^~R&B,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=ot^~at<,t[45]=st^~ht&ut,t[6]=E^~A&m,t[7]=_^~S&g,t[16]=I^~C&M,t[17]=R^~B&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~lt&et,t[47]=ht^~ut&rt,t[8]=A^~m&y,t[9]=S^~g&v,t[18]=C^~M&P,t[19]=B^~k&x,t[28]=q^~O&D,t[29]=K^~F&L,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=lt^~et&nt,t[49]=ut^~rt&it,t[0]^=s[n],t[1]^=s[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:P(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:P(t.slice(e+1,e+1+r))}}return{consumed:1,result:P(t[e])}}function qt(t){let e=E(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.127");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=E(Dt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new s(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(T(Dt(zt([e,A(E(t.nonce))])),12))}class Yt extends Ct{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Ct{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Bt(t.wordSize),i=new Bt(t.wordSize),o=[];e.forEach((t,e)=>{let s=r[e];if(t.dynamic){let e=i.length;t.encode(i,s);let r=n.writeUpdatableValue();o.push(t=>{r(t+e)})}else t.encode(n,s)}),o.forEach(t=>{t(n.length)});let s=t.writeBytes(n.data);return s+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let o=null;if(e.dynamic){let r=t.readValue(),s=n.subReader(r.toNumber());o=e.decode(s),i+=s.consumed}else o=e.decode(t);null!=o&&r.push(o)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Ct{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,s=65535}if(n+o>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-o-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Ae(t,e=Ee.current){e!=Ee.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return E(r)}function Se(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(_e(t,e))}function Pe(t,e=Ee.current){return _e(Ae(t,e))}function xe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Te(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Ne(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ee||(Ee={}));const Ie=Te("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Ce=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Be=xe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=xe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=xe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ne(t,Ce);if(e)return[t+e.s];let r=Be[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=Pe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),Ee.NFKC)).forEach(t=>{if(function(t){return!!Ne(t,De)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Ne(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends se{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Ae(e))}decode(t){return ke(super.decode(t))}}class ze extends Ct{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new oe(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new le(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new he(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Bt(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(E(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.127"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;tEt.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return T($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?sr(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[Pt.fromString(t).format()]}getEvent(t){return M(t)?sr(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[_t.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),P(_([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=E(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===P(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Dt(P(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(P(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))});let s=null!=r?this._abiCoder.decode(n,_(r)):null,a=this._abiCoder.decode(i,e),h=[],l=0,u=0;return t.inputs.forEach((t,e)=>{t.indexed?null==s?h[e]=new ir({_isIndexed:!0,hash:null}):o[e]?h[e]=new ir({_isIndexed:!0,hash:s[u++]}):h[e]=s[u++]:h[e]=a[l++]}),h}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function sr(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.130");class hr extends lt{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class lr{addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}constructor(){ar.checkAbstract(new.target,lr),rt(this,"_isProvider",!0)}static isProvider(t){return!(!t||!t._isProvider)}}const ur=new p("abstract-signer/5.0.0-beta.131"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){ur.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&ur.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=st(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&ur.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{ur.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||ur.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){ur.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ur.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.136"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function yr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},o=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=st(e.pop())).blockTag&&(o=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(o).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,o).then(r=>{try{let o=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(o=o[0]),o}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ht(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function vr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class Er extends br{constructor(t,e,r,n){let i={address:t},o=e.getEventTopic(r);n?(o!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(vr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class _r extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Ar{constructor(t,e,r){if(pr.checkNew(new.target,Ar),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):lr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=yr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,yr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,yr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,yr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return or.isInterface(t)?t:new or(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=st(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new _r(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new Er(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new Er(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(vr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ht(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=st(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Sr{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?P(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=st(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=P(_([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Ar.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Ar(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Cr={inherits:Tr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,o,s,a){var h=0,l=e;return h+=(l=l+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},sum64_5_hi:function(t,e,r,n,i,o,s,a,h,l){var u=0,f=e;return u+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,o,s,a,h,l){return e+n+o+a+l>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Br(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Br;Br.prototype.update=function(t,e){if(t=Cr.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Cr.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(t){return Dr(t,17)^Dr(t,19)^t>>>10}},Hr=Cr.sum32,qr=Cr.sum32_4,Kr=Cr.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Cr.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),Pr(t.length<=this.blockSize);for(var e=t.length;e>24&255,u[e.length+1]=f>>16&255,u[e.length+2]=f>>8&255,u[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,u));o||(o=c.length,a=new Uint8Array(o),s=n-((h=Math.ceil(n/o))-1)*o),a.set(c);for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),oi=r(function(t,e){var r=e;r.assert=Pr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,h=1;h0||e.cmpn(-i)>0;){var o,s,a,h=t.andln(3)+n&3,l=e.andln(3)+i&3;if(3===h&&(h=-1),3===l&&(l=-1),0==(1&h))o=0;else o=3!==(a=t.andln(7)+n&7)&&5!==a||2!==l?h:-h;if(r[0].push(o),0==(1&l))s=0;else s=3!==(a=e.andln(7)+i&7)&&5!==a||2!==h?l:-l;r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new o(t,"hex","le")}}),si=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=oi.getNAF,hi=oi.getJSF,li=oi.assert;function ui(t,e){this.type=t,this.p=new o(e.p,16),this.red=e.prime?o.red(e.prime):o.mont(this.p),this.zero=new o(0).toRed(this.red),this.one=new o(1).toRed(this.red),this.two=new o(2).toRed(this.red),this.n=e.n&&new o(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=ui;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}ui.prototype.point=function(){throw new Error("Not implemented")},ui.prototype.validate=function(){throw new Error("Not implemented")},ui.prototype._fixedNafMul=function(t,e){li(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=s;e--)a=(a<<1)+n[e];o.push(a)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),u=i;u>0;u--){for(s=0;s=0;a--){for(e=0;a>=0&&0===o[a];a--)e++;if(a>=0&&e++,s=s.dblp(e),a<0)break;var h=o[a];li(0!==h),s="affine"===t.type?h>0?s.mixedAdd(i[h-1>>1]):s.mixedAdd(i[-h-1>>1].neg()):h>0?s.add(i[h-1>>1]):s.add(i[-h-1>>1].neg())}return"affine"===t.type?s.toP():s},ui.prototype._wnafMulAdd=function(t,e,r,n,i){for(var o=this._wnafT1,s=this._wnafT2,a=this._wnafT3,h=0,l=0;l=1;l-=2){var f=l-1,c=l;if(1===o[f]&&1===o[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=hi(r[f],r[c]);h=Math.max(m[0].length,h),a[f]=new Array(h),a[c]=new Array(h);for(var g=0;g=0;l--){for(var E=0;l>=0;){var _=!0;for(g=0;g=0&&E++,b=b.dblp(E),l<0)break;for(g=0;g0?A=s[g][S-1>>1]:S<0&&(A=s[g][-S-1>>1].neg()),b="affine"===A.type?b.mixedAdd(A):b.add(A))}}for(l=0;l=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),h=i.mul(r.b),l=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:h.add(l).neg()}},pi.prototype.pointFromX=function(t,e){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new o(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Tr(yi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new yi(this,t,e,r)},yi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},yi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},yi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=o.redSub(s);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),f=n.redMul(l),c=h.redSqr().redIAdd(u).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(o.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},yi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),l=h.redMul(s),u=r.redMul(h),f=a.redSqr().redIAdd(l).redISub(u).redISub(u),c=a.redMul(u.redISub(f)).redISub(i.redMul(l)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},yi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},yi.prototype.inspect=function(){return this.isInfinity()?"":""},yi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var vi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=vi,r.edwards=bi}),Ei=r(function(t,e){var r,n=e,i=oi.assert;function o(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");Pr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Ai=_i;_i.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},_i.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Pi=oi.assert;function xi(t,e){if(t instanceof xi)return t;this._importDER(t,e)||(Pi(t.r&&t.s,"Signature without r or s"),this.r=new o(t.r,16),this.s=new o(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ti=xi;function Ni(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=e.place;o>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xi.prototype._importDER=function(t,e){t=oi.toArray(t,e);var r=new Ni;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var s=Ii(t,r);if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new o(i),this.s=new o(a),this.recoveryParam=null,!0},xi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Ci(n,e.length),(n=n.concat(e)).push(2),Ci(n,r.length);var i=n.concat(r),o=[48];return Ci(o,i.length),o=o.concat(i),oi.encode(o,t)};var Bi=oi.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Bi(Ei.hasOwnProperty(t),"Unknown curve "+t),t=Ei[t]),t instanceof Ei.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ai({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||si(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new o(2));;){var i=new o(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new o(t,16));for(var i=this.n.byteLength(),s=e.getPrivate().toArray("be",i),a=t.toArray("be",i),h=new Ai({hash:this.hash,entropy:s,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new o(1)),u=0;;u++){var f=n.k?n.k(u):new o(h.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(l)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ti({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new o(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ti(e,"hex")).r,s=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,h=s.invm(this.n),l=h.mul(t).umod(this.n),u=h.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(l,r.getPublic(),u)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(l,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Bi((3&r)===r,"The recovery param is more than two bits"),e=new Ti(e,n);var i=this.n,s=new o(t),a=e.r,h=e.s,l=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var f=e.r.invm(i),c=i.sub(s).mul(f).umod(i),d=h.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ti(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Di={},Li=n(ni),Ui=r(function(t,e){var r=e;r.version=Li.version,r.utils=oi,r.rand=si,r.curve=wi,r.curves=Ei,r.ec=Fi,r.eddsa=Di}).ec;const zi=new p("signing-key/5.0.0-beta.128");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",P(t));let e=Hi().keyFromPrivate(E(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(E(this.publicKey)),r=Hi().keyFromPublic(E(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(E(this.privateKey)).sign(E(t),{canonical:!0});return C({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(E(this.privateKey)),r=Hi().keyFromPublic(E(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=C(e),n={r:E(r.r),s:E(r.s)};return"0x"+Hi().recoverPubKey(E(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=E(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?P(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):P(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.127");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(T(Dt(T(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(E(t),e))}function Qi(t,e){ot(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=E(P(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=A(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(P(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(P(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=C(e),o=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),o+=2*t.chainId+8),r.push(P(o)),r.push(A(E(i.r))),r.push(A(E(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(P(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let o=Dt(zt(i));try{r.from=$i(o,{r:P(r.r),s:P(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Dt(t)}return r}var to=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.127"}),eo=(e(to),to.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(to.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var o=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),ut.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||ut.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||ut.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||ut.defineReadOnly(i.ethers.wordlists,r,e))}}})),ro=(e(eo),eo.check,eo.Wordlist,eo.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",s=null;function a(t){if(null==s&&(s=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==eo.check(t)))throw s=null,new Error("BIP39 Wordlist for en (English) FAILED")}var h=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),s[t]},e.prototype.getWordIndex=function(t){return a(this),s.indexOf(t)},e}(eo.Wordlist));r.langEn=h,eo.register(h)})),no=(e(ro),ro.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=eo.Wordlist;var r={en:ro.langEn};e.wordlists=r})),io=(e(no),no.Wordlist),oo=no.wordlists;const so=new p("hdnode/5.0.0-beta.129"),ao=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ho=Ae("Bitcoin seed"),lo=2147483648;function uo(t){return(1<=256)throw new Error("Depth too large!");return co(_([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",P(this.depth),this.parentFingerprint,R(P(this.index),4),this.chainCode,null!=this.privateKey?_(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new go(po,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~lo));let r=new Uint8Array(37);if(t&lo){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(E(this.privateKey),1),e&&(e+="'")}else r.set(E(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=E(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),o=n.slice(32),s=null,a=null;if(this.privateKey)s=fo(U.from(i).add(this.privateKey).mod(ao));else{a=new qi(P(i))._addPoint(this.publicKey)}return new go(po,s,a,this.fingerprint,fo(o),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=lo)throw new Error("invalid path index - "+n);r=r._derive(lo+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invlaid path component - "+n);{let t=parseInt(n);if(t>=lo)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=E(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=E(Yn(Xn.sha512,ho,r));return new go(po,fo(n.slice(0,32)),null,"0x00000000",fo(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=bo(vo(t,r),r),go._fromSeed(yo(t,e),t)}static fromSeed(t){return go._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&co(e.slice(0,78))===t||so.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=P(e.slice(5,9)),i=parseInt(P(e.slice(9,13)).substring(2),16),o=P(e.slice(13,45)),s=e.slice(45,78);switch(P(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new go(po,null,P(s),n,o,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==s[0])break;return new go(po,P(s.slice(1)),null,n,o,i,r,null,null)}return so.throwError("invalid extended key","extendedKey","[REDACTED]")}}function yo(t,e){e||(e="");let r=Ae("mnemonic"+e,Ee.NFKD);return ei(Ae(t,Ee.NFKD),r,2048,64,"sha512")}function vo(t,e){e||(e=oo.en),so.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=E(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let o=32*r.length/3,s=uo(r.length/3),a=E(Qn(n.slice(0,o/8)))[0];if((a&=s)!==(n[n.length-1]&s))throw new Error("invalid checksum");return P(n.slice(0,o/8))}function bo(t,e){if((t=E(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=E(Qn(t))[0],o=t.length/4;return i&=uo(o),r[r.length-1]<<=o,r[r.length-1]|=i>>8-o,e||(e=oo.en),e.join(r.map(t=>e.getWord(t)))}var wo=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.127"}),Eo=(e(wo),wo.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),_o=(e(Eo),Eo.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(wo.version);r.shuffled=Eo.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),Ao=(e(_o),_o.shuffled),So=_o.randomBytes,Mo=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function o(t){return new Uint8Array(t)}function s(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,h={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},l=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),u={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],_=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],A=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=o[e],this._Kd[t-r][e%4]=o[e];for(var s,a=0,h=i;h>16&255]<<24^c[s>>8&255]<<16^c[255&s]<<8^c[s>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[s>>16&255]<<16^c[s>>24&255]<<24;for(e=i/2+1;e>2,d=h%4,this._Ke[l][d]=o[e],this._Kd[t-l][d]=o[e++],h++}for(var l=1;l>24&255]^A[s>>16&255]^S[s>>8&255]^M[255&s]},P.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var s=1;s>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[s][i];n=r.slice()}var a,h=o(16);for(i=0;i<4;i++)a=this._Ke[e][i],h[4*i]=255&(c[n[i]>>24&255]^a>>24),h[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),h[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return h},P.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var s=1;s>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^E[255&n[(i+1)%4]]^this._Kd[s][i];n=r.slice()}var a,h=o(16);for(i=0;i<4;i++)a=this._Kd[e][i],h[4*i]=255&(d[n[i]>>24&255]^a>>24),h[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),h[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return h};var x=function(t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new P(t)};x.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=o(t.length),r=o(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var C=function(t,e){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new P(t)};C.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,E=o,_=s,A=a,S=h,M=l;for(p=0;p<16;p++)m=f+4*p,u[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=u[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=u[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,u[p]=(g+u[p-7]|0)+(y+u[p-16]|0)|0;for(p=0;p<64;p++)g=(((_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&A^~_&S)|0)+(M+(e[p]+u[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,M=S,S=A,A=_,_=E+g|0,E=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+E|0,s=s+_|0,a=a+A|0,h=h+S|0,l=l+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,y=t.slice(t.length-d,t.length);for(y.push(128),c=d+1;c>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255,l>>>24&255,l>>>16&255,l>>>8&255,l>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var o=64+e.length+4,s=new Array(o),a=new Array(64),h=[];for(i=0;i<64;i++)s[i]=54;for(i=0;i=o-4;t--){if(s[t]++,s[t]<=255)return;s[t]=0}}for(;r>=32;)l(),h=h.concat(n(a.concat(n(s)))),r-=32;return r>0&&(l(),h=h.concat(n(a.concat(n(s))).slice(0,r))),h}function o(t,e,r,n,i){var o;for(l(t,16*(2*r-1),i,0,16),o=0;o<2*r;o++)h(t,16*o,i,16),a(i,n),l(i,0,t,e+16*o,16);for(o=0;o>>32-e}function a(t,e){l(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=s(e[0]+e[12],7),e[8]^=s(e[4]+e[0],9),e[12]^=s(e[8]+e[4],13),e[0]^=s(e[12]+e[8],18),e[9]^=s(e[5]+e[1],7),e[13]^=s(e[9]+e[5],9),e[1]^=s(e[13]+e[9],13),e[5]^=s(e[1]+e[13],18),e[14]^=s(e[10]+e[6],7),e[2]^=s(e[14]+e[10],9),e[6]^=s(e[2]+e[14],13),e[10]^=s(e[6]+e[2],18),e[3]^=s(e[15]+e[11],7),e[7]^=s(e[3]+e[15],9),e[11]^=s(e[7]+e[3],13),e[15]^=s(e[11]+e[7],18),e[1]^=s(e[0]+e[3],7),e[2]^=s(e[1]+e[0],9),e[3]^=s(e[2]+e[1],13),e[0]^=s(e[3]+e[2],18),e[6]^=s(e[5]+e[4],7),e[7]^=s(e[6]+e[5],9),e[4]^=s(e[7]+e[6],13),e[5]^=s(e[4]+e[7],18),e[11]^=s(e[10]+e[9],7),e[8]^=s(e[11]+e[10],9),e[9]^=s(e[8]+e[11],13),e[10]^=s(e[9]+e[8],18),e[12]^=s(e[15]+e[14],7),e[13]^=s(e[12]+e[15],9),e[14]^=s(e[13]+e[12],13),e[15]^=s(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function h(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,s,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),s=f(s,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/s)throw new Error("N too large");if(s>r/128/a)throw new Error("r too large");if(!u(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!u(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*s),m=new Uint32Array(32*a*s),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(C)};C()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Fo=new Uint8Array(16);Bo=function(){return crypto.getRandomValues(Fo),Fo}}if(!Bo){var Do=new Array(16);Bo=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Do[e]=t>>>((3&e)<<3)&255;return Do}}for(var Lo=Bo,Uo=[],zo={},jo=0;jo<256;jo++)Uo[jo]=(jo+256).toString(16).substr(1),zo[Uo[jo]]=jo;function Ho(t,e){var r=e||0,n=Uo;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var qo=Lo(),Ko=[1|qo[0],qo[1],qo[2],qo[3],qo[4],qo[5]],Go=16383&(qo[6]<<8|qo[7]),Wo=0,Vo=0;function Jo(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Lo)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var o=0;o<16;o++)e[n+o]=i[o];return e||Ho(i)}var Zo=Jo;Zo.v1=function(t,e,r){var n=e&&r||0,i=e||[],o=void 0!==(t=t||{}).clockseq?t.clockseq:Go,s=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Vo+1,h=s-Wo+(a-Vo)/1e4;if(h<0&&void 0===t.clockseq&&(o=o+1&16383),(h<0||s>Wo)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Wo=s,Vo=a,Go=o;var l=(1e4*(268435455&(s+=122192928e5))+a)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var u=s/4294967296*1e4&268435455;i[n++]=u>>>8&255,i[n++]=255&u,i[n++]=u>>>24&15|16,i[n++]=u>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var f=t.node||Ko,c=0;c<6;c++)i[n+c]=f[c];return e||Ho(i)},Zo.v4=Jo,Zo.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=zo[t])});i<16;)e[n+i++]=0;return e},Zo.unparse=Ho;var Xo=Zo;class $o extends lt{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function Qo(t,e,r){let n=JSON.parse(t),i=xo(e),o=function(t,e){let r=ko(To(n,"crypto/ciphertext"));if(P(function(t,e){return Dt(_([t,e]))}(t.slice(16,32),r)).substring(2)!==To(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===To(n,"crypto/cipher")){let r=ko(To(n,"crypto/cipherparams/iv")),i=new Mo.Counter(r);return E(new Mo.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),o=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let s=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==s)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:s,privateKey:P(i)};if("0.1"===To(n,"x-ethers/version")){let t=ko(To(n,"x-ethers/mnemonicCiphertext")),r=ko(To(n,"x-ethers/mnemonicCounter")),i=new Mo.Counter(r),s=new Mo.ModeOfOperation.ctr(o,i),h=To(n,"x-ethers/path")||mo,l=bo(E(s.decrypt(t))),u=go.fromMnemonic(l).derivePath(h);if(u.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=u.mnemonic,a.path=u.path}return new $o(a)};return new Promise(function(t,e){let s=To(n,"crypto/kdf");if(s&&"string"==typeof s)if("scrypt"===s.toLowerCase()){let s=ko(To(n,"crypto/kdfparams/salt")),a=parseInt(To(n,"crypto/kdfparams/n")),h=parseInt(To(n,"crypto/kdfparams/r")),l=parseInt(To(n,"crypto/kdfparams/p"));if(!a||!h||!l)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(To(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Oo(i,s,a,h,l,64,function(n,i,s){if(n)n.progress=i,e(n);else if(s){s=E(s);let n=o(s,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===s.toLowerCase()){let r=ko(To(n,"crypto/kdfparams/salt")),s=null,a=To(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)s="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));s="sha512"}let h=parseInt(To(n,"crypto/kdfparams/c")),l=parseInt(To(n,"crypto/kdfparams/dklen"));if(32!==l)return void e(new Error("unsupported key-derivation derived-key length"));let u=E(ei(i,r,h,l,s)),f=o(u,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Yo(t,e,r){if(Ro(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=xo(e);let n=$t(To(r,"ethaddr")),i=ko(To(r,"encseed"));i&&i.length%16==0||No.throwArgumentError("invalid encseed","json",t);let o=E(ei(e,e,2e3,32,"sha256")).slice(0,16),s=i.slice(0,16),a=i.slice(16),h=E(new Mo.ModeOfOperation.cbc(o,s).decrypt(a));h=Mo.padding.pkcs7.strip(h);let l="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&ts.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||mo;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(go.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&ts.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&ts.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!lr.isProvider(e)&&ts.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new es(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Dt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(B(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(go.fromMnemonic(t.mnemonic).derivePath(t.path||mo).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=E(t.privateKey),o=xo(e),s=null,a=t.path;t.mnemonic&&(s=E(vo(t.mnemonic)),a||(a=mo));let h=r.client;h||(h="ethers.js");let l=null;l=r.salt?E(r.salt):So(32);let u=null;if(r.iv){if(16!==(u=E(r.iv)).length)throw new Error("invalid iv")}else u=So(16);let f=null;if(r.uuid){if(16!==(f=E(r.uuid)).length)throw new Error("invalid uuid")}else f=So(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Oo(o,l,c,d,p,64,function(o,m,g){if(o)o.progress=m,r(o);else if(g){let r=(g=E(g)).slice(0,16),o=g.slice(16,32),m=g.slice(32,64),y=new Mo.Counter(u),v=E(new Mo.ModeOfOperation.ctr(r,y).encrypt(i)),b=Dt(_([o,v])),w={address:t.address.substring(2).toLowerCase(),id:Xo.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:P(u).substring(2)},ciphertext:P(v).substring(2),kdf:"scrypt",kdfparams:{salt:P(l).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(s){let t=So(16),e=new Mo.Counter(t),r=E(new Mo.ModeOfOperation.ctr(m,e).encrypt(s)),n=new Date,i=n.getUTCFullYear()+"-"+Po(n.getUTCMonth()+1,2)+"-"+Po(n.getUTCDate(),2)+"T"+Po(n.getUTCHours(),2)+"-"+Po(n.getUTCMinutes(),2)+"-"+Po(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:h,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:P(t).substring(2),mnemonicCiphertext:P(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=So(16);t||(t={}),t.extraEntropy&&(e=E(T(Dt(_([e,t.extraEntropy])),0,16)));let r=bo(e,t.locale);return es.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Yo(t,e,r).then(t=>new es(t))}static fromMnemonic(t,e,r){return e||(e=mo),new es(go.fromMnemonic(t,null,r).derivePath(e))}}const rs=new p("networks/5.0.0-beta.128");function ns(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function is(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const os={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ns("homestead")},ss={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ns("ropsten")},as={unspecified:{chainId:0,name:"unspecified"},homestead:os,mainnet:os,morden:{chainId:2,name:"morden"},ropsten:ss,testnet:ss,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ns("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ns("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ns("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:is("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:is("https://web3.gastracker.io/morden","classicTestnet")}};function hs(t){if(null==t)return null;if("number"==typeof t){for(let e in as){let r=as[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=as[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=as[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&rs.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&rs.throwArgumentError("invalid network chainId","network",t),t)}var ls=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function y(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];y.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,o){var s=new m(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function l(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new y(n,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",l),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",l)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=h,t.Request=m,t.Response=y),e.Headers=h,e.Request=m,e.Response=y,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),us=(ls.fetch,ls.Headers,ls.Request,ls.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(s=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&ms.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+ds(Ae(e))}}}return new Promise(function(t,a){let h=null;s&&(h=setTimeout(()=>{null!=h&&(h=null,a(ms.makeError("timeout",p.errors.TIMEOUT,{timeout:s})))},s));let l=()=>{null!=h&&(clearTimeout(h),h=null)};e&&(o.method="POST",o.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let u={};return Object.keys(n).forEach(t=>{let e=n[t];u[e.key]=e.value}),o.headers=u,ls(i,o).then(t=>t.text().then(e=>(t.ok||ms.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){ms.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){ms.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{l(),t(e)},t=>{l(),a(t)})})}function ys(t,e){return e||(e={}),null==(e=st(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,o=!1,s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{s()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,h=0;!function i(){return t().then(function(t){if(void 0!==t)s()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!o){if(++h>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){s()&&n(t)})}()})}const vs="providers/5.0.0-beta.140",bs=new p(vs);class ws{constructor(){bs.checkNew(new.target,ws),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:o,blockHash:ws.allowNull(o,null),blockNumber:ws.allowNull(a,null),transactionIndex:ws.allowNull(a,null),confirmations:ws.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:ws.allowNull(e,null),value:r,nonce:a,data:i,r:ws.allowNull(this.uint256),s:ws.allowNull(this.uint256),v:ws.allowNull(a),creates:ws.allowNull(e,null),raw:ws.allowNull(i)},t.transactionRequest={from:ws.allowNull(e),nonce:ws.allowNull(a),gasLimit:ws.allowNull(r),gasPrice:ws.allowNull(r),to:ws.allowNull(e),value:ws.allowNull(r),data:ws.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:ws.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:o,address:e,topics:ws.arrayOf(o),data:i,logIndex:a,blockHash:o},t.receipt={to:ws.allowNull(this.address),from:ws.allowNull(this.address),contractAddress:ws.allowNull(e,null),transactionIndex:a,root:ws.allowNull(o),gasUsed:r,logsBloom:ws.allowNull(i),blockHash:o,transactionHash:o,logs:ws.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ws.allowNull(a,null),cumulativeGasUsed:r,status:ws.allowNull(a)},t.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ws.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:ws.allowNull(ws.arrayOf(o))},t.blockWithTransactions=st(t.block),t.blockWithTransactions.transactions=ws.allowNull(ws.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:ws.allowNull(n,void 0),toBlock:ws.allowNull(n,void 0),blockHash:ws.allowNull(o,void 0),address:ws.allowNull(e,void 0),topics:ws.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:ws.allowNull(a),blockHash:ws.allowNull(o),transactionIndex:a,removed:ws.allowNull(this.boolean.bind(this)),address:e,data:ws.allowFalsish(i,"0x"),topics:ws.arrayOf(o),transactionHash:o,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bs.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(T(t,12));return e===ue?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return N(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==x(r)?bs.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),ws.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return ws.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=ws.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return ws.check(this.formats.receiptLog,t)}receipt(t){let e=ws.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return ws.check(this.formats.filter,t)}filterLog(t){return ws.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const Es=new p(vs);function _s(t){return null==t?"null":(32!==x(t)&&Es.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function As(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[_s(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return _s(t)}).join("&")}function Ss(t){if("string"==typeof t){if(32===x(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+As(t);if(hr.isForkEvent(t))throw Es.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+As(t.topics||[])}throw new Error("invalid event - "+t)}function Ms(){return(new Date).getTime()}class ks{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let Ps=null,xs=1;class Ts extends lr{constructor(t){if(Es.checkNew(new.target,lr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):Es.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==Ps&&(Ps=new ws),Ps}static getNetwork(t){return hs(null==t?"homestead":t)}poll(){let t=xs++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let o=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(o);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Ms();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>N(t))}).then(t=>P(t))}_wrapTransaction(t,e){if(null!=e&&32!==x(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&Es.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&Es.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>P(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&Es.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){Es.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return ys(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return ys(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return ys(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>ws.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&Es.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||Es.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=E(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return Es.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ks(Ss(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=Ss(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=Ss(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=Ss(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=Ss(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=Ss(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const Ns=new p(vs);function Is(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Rs(t){return t?t.toLowerCase():t}const Cs={};class Bs extends cr{constructor(t,e,r){if(Ns.checkNew(new.target,Bs),super(),t!==Cs)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):Ns.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Ns.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Os(Cs,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Ns.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=st(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=st(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&Ns.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&Ns.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&Ns.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return Ns.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>ys(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Ae(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),P(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Os extends Bs{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fs={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Ds extends Ts{constructor(t,e){if(Ns.checkNew(new.target,Ds),"string"==typeof t&&null===e&&hs(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(hs(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(hs(U.from(e).toNumber()))}).catch(t=>{e(Ns.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Bs(Cs,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ht(r),provider:this}),gs(this.connection,JSON.stringify(r),Is).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Rs(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Rs(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Rs(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Rs(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&Ns.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&Ns.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&Ns.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):Ns.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Rs(e.filter.address)),this.send("eth_getLogs",[e.filter])}return Ns.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=st(Fs);if(e)for(let t in e)e[t]&&(r[t]=!0);ot(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=N(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=P(t[e]))}),n}}const Ls=new p(vs);class Us extends Ds{constructor(t,e){Ls.checkAbstract(new.target,Us),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Ls.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Ls.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return hs(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Ls.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zs=new p(vs),js="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Hs=new p(vs);const qs=new p(vs);function Ks(t){let e=[];for(let r in t){if(null==t[r])continue;let n=P(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=N(n)),e.push(r+"="+n)}return e.join("&")}function Gs(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Ws(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vs(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Js extends Ts{constructor(t,e){qs.checkNew(new.target,Js),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),gs(t,null,e||Ws).then(e=>(this.emit("debug",{action:"response",request:t,response:ht(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Gs);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Ws);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Ws);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qs.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qs.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qs.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ks(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ks(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vs(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vs(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let o=this;return i(r+=n,Gs).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?o.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Gs).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),gs(n,null,Gs).then(t=>{this.emit("debug",{action:"response",request:n,response:ht(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zs=new p(vs);function Xs(){return(new Date).getTime()}function $s(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zs.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qs=1;class Ys extends Ts{constructor(t,e,r){Zs.checkNew(new.target,Ys),0===t.length&&Zs.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zs.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zs.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zs.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$s(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($s(t)||Zs.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zs.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xs(),n=Ao(this.providers).map((n,i)=>{let o=this.weights[i],s=Qs++;return{run:()=>{let i=Xs(),a=i-r;return this.emit("debug",{action:"request",rid:s,backend:{weight:o,start:a,provider:n},request:{method:t,params:ht(e)},provider:this}),Ys.doPerform(n,t,e).then(r=>{let h=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},response:ht(r)}),{weight:o,result:r}},r=>{let h=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},error:r}),{weight:o,error:r}})},weight:o}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let o=null,s=0,a={},h=()=>{if(0===n.length)return;let l=n.shift();s+=l.weight,l.run().then(u=>{if(null!==a){if(s-=l.weight,u.error)null==o&&(o=u.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(u.result);null==a[t]&&(a[t]=[]),a[t].push(u);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===s){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===o&&(o=Zs.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(o)}setTimeout(h,0)}}),s{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(vs),ia="84842078b09946638c03157f83405213";const oa=new p(vs),sa="ETHERS_JS_SHARED";const aa=new p(vs);class ha extends Ds{constructor(t,e){aa.checkNew(new.target,ha),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var la=Object.freeze({Provider:lr,BaseProvider:Ts,FallbackProvider:Ys,AlchemyProvider:class extends Us{static getApiKey(t){return null==t?js:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zs.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Us{static getUrl(t,e){null!=e&&Hs.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Hs.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Js,InfuraProvider:class extends Us{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Ds,NodesmithProvider:class extends Us{static getApiKey(t){return t||sa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:oa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ha,IpcProvider:ra,JsonRpcSigner:Bs,getNetwork:hs,Formatter:ws});const ua=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?S(r,32):E(r);case"string":return Ae(r);case"bytes":return E(r);case"bool":return r=r?"0x01":"0x00",n?S(r,32):E(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),S(r=U.from(r).toTwos(t),t/8)}if(i=e.match(ua)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(E(r).byteLength!==t)throw new Error("invalid value for "+e);return n?E((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let o=[];return r.forEach(function(e){o.push(t(n,e,!0))}),_(o)}throw new Error("unknown type - "+e)}(t,e[n]))}),P(_(r))}const ma=new p("units/5.0.0-beta.126"),ga=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ya(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return $(t,null!=e?e:18)}function va(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return Q(t,null!=e?e:18)}var ba=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:Et,EventFragment:_t,FunctionFragment:Pt,ParamType:bt,FormatTypes:yt,Logger:p,RLP:Kt,fetchJson:gs,poll:ys,checkProperties:ot,deepCopy:ht,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:st,arrayify:E,concat:_,stripZeros:A,zeroPad:S,defaultPath:mo,HDNode:go,SigningKey:qi,Interface:or,base64:ps,hexlify:P,isHexString:M,hexStripZeros:I,hexValue:N,hexZeroPad:R,hexDataLength:x,hexDataSlice:T,nameprep:Le,_toEscapedUtf8String:function(t,e){return'"'+_e(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Se(t):Se(55296+((t-=65536)>>10&1023))+Se(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Ae,toUtf8CodePoints:Pe,toUtf8String:ke,formatBytes32String:function(t){let e=Ae(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return P(_([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=E(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new s($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return ya(t,18)},parseEther:function(t){return va(t,18)},formatUnits:ya,parseUnits:va,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&ma.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let o=[];for(;r.length;){if(r.length<=3){o.unshift(r);break}{let t=r.length-3;o.unshift(r.substring(t)),r=r.substring(0,t)}}return n+o.join(",")+i},keccak256:Dt,sha256:Qn,randomBytes:So,solidityPack:pa,solidityKeccak256:function(t,e){return Dt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:C,joinSignature:B,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Ro(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Co(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:vo,entropyToMnemonic:bo,isValidMnemonic:function(t,e){try{return vo(t,e),!0}catch(t){}return!1},mnemonicToSeed:yo,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return Ee},Indexed:ir});const wa="node",Ea="ethers/5.0.0-beta.155",_a=p.errors,Aa=new p(Ea);function Sa(t,e){null==t&&(t="homestead");let r=hs(t);return r&&r._defaultProvider||Aa.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(la,e)}var Ma=Object.freeze({version:Ea,Signer:cr,Wallet:es,VoidSigner:dr,getDefaultProvider:Sa,providers:la,Contract:Ar,ContractFactory:Sr,BigNumber:U,FixedNumber:tt,constants:ve,errors:_a,logger:Aa,utils:ba,wordlists:oo,platform:"node",Wordlist:io});export{U as BigNumber,Ar as Contract,Sr as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,es as Wallet,io as Wordlist,ve as constants,_a as errors,Ma as ethers,Sa as getDefaultProvider,Aa as logger,wa as platform,la as providers,ba as utils,Ea as version,oo as wordlists}; diff --git a/packages/ethers/dist/ethers.js b/packages/ethers/dist/ethers.js deleted file mode 100644 index b8d1af626..000000000 --- a/packages/ethers/dist/ethers.js +++ /dev/null @@ -1,19944 +0,0 @@ -(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethers = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i 255) { - return false; - } - } - - return true; - } - - function coerceArray(arg, copy) { - - // ArrayBuffer view - if (arg.buffer && ArrayBuffer.isView(arg) && arg.name === 'Uint8Array') { - - if (copy) { - if (arg.slice) { - arg = arg.slice(); - } else { - arg = Array.prototype.slice.call(arg); - } - } - - return arg; - } - - // It's an array; check it is a valid representation of a byte - if (Array.isArray(arg)) { - if (!checkInts(arg)) { - throw new Error('Array contains invalid value: ' + arg); - } - - return new Uint8Array(arg); - } - - // Something else, but behaves like an array (maybe a Buffer? Arguments?) - if (checkInt(arg.length) && checkInts(arg)) { - return new Uint8Array(arg); - } - - throw new Error('unsupported array-like object'); - } - - function createArray(length) { - return new Uint8Array(length); - } - - function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) { - if (sourceStart != null || sourceEnd != null) { - if (sourceArray.slice) { - sourceArray = sourceArray.slice(sourceStart, sourceEnd); - } else { - sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd); - } - } - targetArray.set(sourceArray, targetStart); - } - - - - var convertUtf8 = (function() { - function toBytes(text) { - var result = [], i = 0; - text = encodeURI(text); - while (i < text.length) { - var c = text.charCodeAt(i++); - - // if it is a % sign, encode the following 2 bytes as a hex value - if (c === 37) { - result.push(parseInt(text.substr(i, 2), 16)) - i += 2; - - // otherwise, just the actual byte - } else { - result.push(c) - } - } - - return coerceArray(result); - } - - function fromBytes(bytes) { - var result = [], i = 0; - - while (i < bytes.length) { - var c = bytes[i]; - - if (c < 128) { - result.push(String.fromCharCode(c)); - i++; - } else if (c > 191 && c < 224) { - result.push(String.fromCharCode(((c & 0x1f) << 6) | (bytes[i + 1] & 0x3f))); - i += 2; - } else { - result.push(String.fromCharCode(((c & 0x0f) << 12) | ((bytes[i + 1] & 0x3f) << 6) | (bytes[i + 2] & 0x3f))); - i += 3; - } - } - - return result.join(''); - } - - return { - toBytes: toBytes, - fromBytes: fromBytes, - } - })(); - - var convertHex = (function() { - function toBytes(text) { - var result = []; - for (var i = 0; i < text.length; i += 2) { - result.push(parseInt(text.substr(i, 2), 16)); - } - - return result; - } - - // http://ixti.net/development/javascript/2011/11/11/base64-encodedecode-of-utf8-in-browser-with-js.html - var Hex = '0123456789abcdef'; - - function fromBytes(bytes) { - var result = []; - for (var i = 0; i < bytes.length; i++) { - var v = bytes[i]; - result.push(Hex[(v & 0xf0) >> 4] + Hex[v & 0x0f]); - } - return result.join(''); - } - - return { - toBytes: toBytes, - fromBytes: fromBytes, - } - })(); - - - // Number of rounds by keysize - var numberOfRounds = {16: 10, 24: 12, 32: 14} - - // Round constant words - var rcon = [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91]; - - // S-box and Inverse S-box (S is for Substitution) - var S = [0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16]; - var Si =[0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb, 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb, 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e, 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25, 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92, 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84, 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06, 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b, 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73, 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e, 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b, 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4, 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f, 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef, 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61, 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d]; - - // Transformations for encryption - var T1 = [0xc66363a5, 0xf87c7c84, 0xee777799, 0xf67b7b8d, 0xfff2f20d, 0xd66b6bbd, 0xde6f6fb1, 0x91c5c554, 0x60303050, 0x02010103, 0xce6767a9, 0x562b2b7d, 0xe7fefe19, 0xb5d7d762, 0x4dababe6, 0xec76769a, 0x8fcaca45, 0x1f82829d, 0x89c9c940, 0xfa7d7d87, 0xeffafa15, 0xb25959eb, 0x8e4747c9, 0xfbf0f00b, 0x41adadec, 0xb3d4d467, 0x5fa2a2fd, 0x45afafea, 0x239c9cbf, 0x53a4a4f7, 0xe4727296, 0x9bc0c05b, 0x75b7b7c2, 0xe1fdfd1c, 0x3d9393ae, 0x4c26266a, 0x6c36365a, 0x7e3f3f41, 0xf5f7f702, 0x83cccc4f, 0x6834345c, 0x51a5a5f4, 0xd1e5e534, 0xf9f1f108, 0xe2717193, 0xabd8d873, 0x62313153, 0x2a15153f, 0x0804040c, 0x95c7c752, 0x46232365, 0x9dc3c35e, 0x30181828, 0x379696a1, 0x0a05050f, 0x2f9a9ab5, 0x0e070709, 0x24121236, 0x1b80809b, 0xdfe2e23d, 0xcdebeb26, 0x4e272769, 0x7fb2b2cd, 0xea75759f, 0x1209091b, 0x1d83839e, 0x582c2c74, 0x341a1a2e, 0x361b1b2d, 0xdc6e6eb2, 0xb45a5aee, 0x5ba0a0fb, 0xa45252f6, 0x763b3b4d, 0xb7d6d661, 0x7db3b3ce, 0x5229297b, 0xdde3e33e, 0x5e2f2f71, 0x13848497, 0xa65353f5, 0xb9d1d168, 0x00000000, 0xc1eded2c, 0x40202060, 0xe3fcfc1f, 0x79b1b1c8, 0xb65b5bed, 0xd46a6abe, 0x8dcbcb46, 0x67bebed9, 0x7239394b, 0x944a4ade, 0x984c4cd4, 0xb05858e8, 0x85cfcf4a, 0xbbd0d06b, 0xc5efef2a, 0x4faaaae5, 0xedfbfb16, 0x864343c5, 0x9a4d4dd7, 0x66333355, 0x11858594, 0x8a4545cf, 0xe9f9f910, 0x04020206, 0xfe7f7f81, 0xa05050f0, 0x783c3c44, 0x259f9fba, 0x4ba8a8e3, 0xa25151f3, 0x5da3a3fe, 0x804040c0, 0x058f8f8a, 0x3f9292ad, 0x219d9dbc, 0x70383848, 0xf1f5f504, 0x63bcbcdf, 0x77b6b6c1, 0xafdada75, 0x42212163, 0x20101030, 0xe5ffff1a, 0xfdf3f30e, 0xbfd2d26d, 0x81cdcd4c, 0x180c0c14, 0x26131335, 0xc3ecec2f, 0xbe5f5fe1, 0x359797a2, 0x884444cc, 0x2e171739, 0x93c4c457, 0x55a7a7f2, 0xfc7e7e82, 0x7a3d3d47, 0xc86464ac, 0xba5d5de7, 0x3219192b, 0xe6737395, 0xc06060a0, 0x19818198, 0x9e4f4fd1, 0xa3dcdc7f, 0x44222266, 0x542a2a7e, 0x3b9090ab, 0x0b888883, 0x8c4646ca, 0xc7eeee29, 0x6bb8b8d3, 0x2814143c, 0xa7dede79, 0xbc5e5ee2, 0x160b0b1d, 0xaddbdb76, 0xdbe0e03b, 0x64323256, 0x743a3a4e, 0x140a0a1e, 0x924949db, 0x0c06060a, 0x4824246c, 0xb85c5ce4, 0x9fc2c25d, 0xbdd3d36e, 0x43acacef, 0xc46262a6, 0x399191a8, 0x319595a4, 0xd3e4e437, 0xf279798b, 0xd5e7e732, 0x8bc8c843, 0x6e373759, 0xda6d6db7, 0x018d8d8c, 0xb1d5d564, 0x9c4e4ed2, 0x49a9a9e0, 0xd86c6cb4, 0xac5656fa, 0xf3f4f407, 0xcfeaea25, 0xca6565af, 0xf47a7a8e, 0x47aeaee9, 0x10080818, 0x6fbabad5, 0xf0787888, 0x4a25256f, 0x5c2e2e72, 0x381c1c24, 0x57a6a6f1, 0x73b4b4c7, 0x97c6c651, 0xcbe8e823, 0xa1dddd7c, 0xe874749c, 0x3e1f1f21, 0x964b4bdd, 0x61bdbddc, 0x0d8b8b86, 0x0f8a8a85, 0xe0707090, 0x7c3e3e42, 0x71b5b5c4, 0xcc6666aa, 0x904848d8, 0x06030305, 0xf7f6f601, 0x1c0e0e12, 0xc26161a3, 0x6a35355f, 0xae5757f9, 0x69b9b9d0, 0x17868691, 0x99c1c158, 0x3a1d1d27, 0x279e9eb9, 0xd9e1e138, 0xebf8f813, 0x2b9898b3, 0x22111133, 0xd26969bb, 0xa9d9d970, 0x078e8e89, 0x339494a7, 0x2d9b9bb6, 0x3c1e1e22, 0x15878792, 0xc9e9e920, 0x87cece49, 0xaa5555ff, 0x50282878, 0xa5dfdf7a, 0x038c8c8f, 0x59a1a1f8, 0x09898980, 0x1a0d0d17, 0x65bfbfda, 0xd7e6e631, 0x844242c6, 0xd06868b8, 0x824141c3, 0x299999b0, 0x5a2d2d77, 0x1e0f0f11, 0x7bb0b0cb, 0xa85454fc, 0x6dbbbbd6, 0x2c16163a]; - var T2 = [0xa5c66363, 0x84f87c7c, 0x99ee7777, 0x8df67b7b, 0x0dfff2f2, 0xbdd66b6b, 0xb1de6f6f, 0x5491c5c5, 0x50603030, 0x03020101, 0xa9ce6767, 0x7d562b2b, 0x19e7fefe, 0x62b5d7d7, 0xe64dabab, 0x9aec7676, 0x458fcaca, 0x9d1f8282, 0x4089c9c9, 0x87fa7d7d, 0x15effafa, 0xebb25959, 0xc98e4747, 0x0bfbf0f0, 0xec41adad, 0x67b3d4d4, 0xfd5fa2a2, 0xea45afaf, 0xbf239c9c, 0xf753a4a4, 0x96e47272, 0x5b9bc0c0, 0xc275b7b7, 0x1ce1fdfd, 0xae3d9393, 0x6a4c2626, 0x5a6c3636, 0x417e3f3f, 0x02f5f7f7, 0x4f83cccc, 0x5c683434, 0xf451a5a5, 0x34d1e5e5, 0x08f9f1f1, 0x93e27171, 0x73abd8d8, 0x53623131, 0x3f2a1515, 0x0c080404, 0x5295c7c7, 0x65462323, 0x5e9dc3c3, 0x28301818, 0xa1379696, 0x0f0a0505, 0xb52f9a9a, 0x090e0707, 0x36241212, 0x9b1b8080, 0x3ddfe2e2, 0x26cdebeb, 0x694e2727, 0xcd7fb2b2, 0x9fea7575, 0x1b120909, 0x9e1d8383, 0x74582c2c, 0x2e341a1a, 0x2d361b1b, 0xb2dc6e6e, 0xeeb45a5a, 0xfb5ba0a0, 0xf6a45252, 0x4d763b3b, 0x61b7d6d6, 0xce7db3b3, 0x7b522929, 0x3edde3e3, 0x715e2f2f, 0x97138484, 0xf5a65353, 0x68b9d1d1, 0x00000000, 0x2cc1eded, 0x60402020, 0x1fe3fcfc, 0xc879b1b1, 0xedb65b5b, 0xbed46a6a, 0x468dcbcb, 0xd967bebe, 0x4b723939, 0xde944a4a, 0xd4984c4c, 0xe8b05858, 0x4a85cfcf, 0x6bbbd0d0, 0x2ac5efef, 0xe54faaaa, 0x16edfbfb, 0xc5864343, 0xd79a4d4d, 0x55663333, 0x94118585, 0xcf8a4545, 0x10e9f9f9, 0x06040202, 0x81fe7f7f, 0xf0a05050, 0x44783c3c, 0xba259f9f, 0xe34ba8a8, 0xf3a25151, 0xfe5da3a3, 0xc0804040, 0x8a058f8f, 0xad3f9292, 0xbc219d9d, 0x48703838, 0x04f1f5f5, 0xdf63bcbc, 0xc177b6b6, 0x75afdada, 0x63422121, 0x30201010, 0x1ae5ffff, 0x0efdf3f3, 0x6dbfd2d2, 0x4c81cdcd, 0x14180c0c, 0x35261313, 0x2fc3ecec, 0xe1be5f5f, 0xa2359797, 0xcc884444, 0x392e1717, 0x5793c4c4, 0xf255a7a7, 0x82fc7e7e, 0x477a3d3d, 0xacc86464, 0xe7ba5d5d, 0x2b321919, 0x95e67373, 0xa0c06060, 0x98198181, 0xd19e4f4f, 0x7fa3dcdc, 0x66442222, 0x7e542a2a, 0xab3b9090, 0x830b8888, 0xca8c4646, 0x29c7eeee, 0xd36bb8b8, 0x3c281414, 0x79a7dede, 0xe2bc5e5e, 0x1d160b0b, 0x76addbdb, 0x3bdbe0e0, 0x56643232, 0x4e743a3a, 0x1e140a0a, 0xdb924949, 0x0a0c0606, 0x6c482424, 0xe4b85c5c, 0x5d9fc2c2, 0x6ebdd3d3, 0xef43acac, 0xa6c46262, 0xa8399191, 0xa4319595, 0x37d3e4e4, 0x8bf27979, 0x32d5e7e7, 0x438bc8c8, 0x596e3737, 0xb7da6d6d, 0x8c018d8d, 0x64b1d5d5, 0xd29c4e4e, 0xe049a9a9, 0xb4d86c6c, 0xfaac5656, 0x07f3f4f4, 0x25cfeaea, 0xafca6565, 0x8ef47a7a, 0xe947aeae, 0x18100808, 0xd56fbaba, 0x88f07878, 0x6f4a2525, 0x725c2e2e, 0x24381c1c, 0xf157a6a6, 0xc773b4b4, 0x5197c6c6, 0x23cbe8e8, 0x7ca1dddd, 0x9ce87474, 0x213e1f1f, 0xdd964b4b, 0xdc61bdbd, 0x860d8b8b, 0x850f8a8a, 0x90e07070, 0x427c3e3e, 0xc471b5b5, 0xaacc6666, 0xd8904848, 0x05060303, 0x01f7f6f6, 0x121c0e0e, 0xa3c26161, 0x5f6a3535, 0xf9ae5757, 0xd069b9b9, 0x91178686, 0x5899c1c1, 0x273a1d1d, 0xb9279e9e, 0x38d9e1e1, 0x13ebf8f8, 0xb32b9898, 0x33221111, 0xbbd26969, 0x70a9d9d9, 0x89078e8e, 0xa7339494, 0xb62d9b9b, 0x223c1e1e, 0x92158787, 0x20c9e9e9, 0x4987cece, 0xffaa5555, 0x78502828, 0x7aa5dfdf, 0x8f038c8c, 0xf859a1a1, 0x80098989, 0x171a0d0d, 0xda65bfbf, 0x31d7e6e6, 0xc6844242, 0xb8d06868, 0xc3824141, 0xb0299999, 0x775a2d2d, 0x111e0f0f, 0xcb7bb0b0, 0xfca85454, 0xd66dbbbb, 0x3a2c1616]; - var T3 = [0x63a5c663, 0x7c84f87c, 0x7799ee77, 0x7b8df67b, 0xf20dfff2, 0x6bbdd66b, 0x6fb1de6f, 0xc55491c5, 0x30506030, 0x01030201, 0x67a9ce67, 0x2b7d562b, 0xfe19e7fe, 0xd762b5d7, 0xabe64dab, 0x769aec76, 0xca458fca, 0x829d1f82, 0xc94089c9, 0x7d87fa7d, 0xfa15effa, 0x59ebb259, 0x47c98e47, 0xf00bfbf0, 0xadec41ad, 0xd467b3d4, 0xa2fd5fa2, 0xafea45af, 0x9cbf239c, 0xa4f753a4, 0x7296e472, 0xc05b9bc0, 0xb7c275b7, 0xfd1ce1fd, 0x93ae3d93, 0x266a4c26, 0x365a6c36, 0x3f417e3f, 0xf702f5f7, 0xcc4f83cc, 0x345c6834, 0xa5f451a5, 0xe534d1e5, 0xf108f9f1, 0x7193e271, 0xd873abd8, 0x31536231, 0x153f2a15, 0x040c0804, 0xc75295c7, 0x23654623, 0xc35e9dc3, 0x18283018, 0x96a13796, 0x050f0a05, 0x9ab52f9a, 0x07090e07, 0x12362412, 0x809b1b80, 0xe23ddfe2, 0xeb26cdeb, 0x27694e27, 0xb2cd7fb2, 0x759fea75, 0x091b1209, 0x839e1d83, 0x2c74582c, 0x1a2e341a, 0x1b2d361b, 0x6eb2dc6e, 0x5aeeb45a, 0xa0fb5ba0, 0x52f6a452, 0x3b4d763b, 0xd661b7d6, 0xb3ce7db3, 0x297b5229, 0xe33edde3, 0x2f715e2f, 0x84971384, 0x53f5a653, 0xd168b9d1, 0x00000000, 0xed2cc1ed, 0x20604020, 0xfc1fe3fc, 0xb1c879b1, 0x5bedb65b, 0x6abed46a, 0xcb468dcb, 0xbed967be, 0x394b7239, 0x4ade944a, 0x4cd4984c, 0x58e8b058, 0xcf4a85cf, 0xd06bbbd0, 0xef2ac5ef, 0xaae54faa, 0xfb16edfb, 0x43c58643, 0x4dd79a4d, 0x33556633, 0x85941185, 0x45cf8a45, 0xf910e9f9, 0x02060402, 0x7f81fe7f, 0x50f0a050, 0x3c44783c, 0x9fba259f, 0xa8e34ba8, 0x51f3a251, 0xa3fe5da3, 0x40c08040, 0x8f8a058f, 0x92ad3f92, 0x9dbc219d, 0x38487038, 0xf504f1f5, 0xbcdf63bc, 0xb6c177b6, 0xda75afda, 0x21634221, 0x10302010, 0xff1ae5ff, 0xf30efdf3, 0xd26dbfd2, 0xcd4c81cd, 0x0c14180c, 0x13352613, 0xec2fc3ec, 0x5fe1be5f, 0x97a23597, 0x44cc8844, 0x17392e17, 0xc45793c4, 0xa7f255a7, 0x7e82fc7e, 0x3d477a3d, 0x64acc864, 0x5de7ba5d, 0x192b3219, 0x7395e673, 0x60a0c060, 0x81981981, 0x4fd19e4f, 0xdc7fa3dc, 0x22664422, 0x2a7e542a, 0x90ab3b90, 0x88830b88, 0x46ca8c46, 0xee29c7ee, 0xb8d36bb8, 0x143c2814, 0xde79a7de, 0x5ee2bc5e, 0x0b1d160b, 0xdb76addb, 0xe03bdbe0, 0x32566432, 0x3a4e743a, 0x0a1e140a, 0x49db9249, 0x060a0c06, 0x246c4824, 0x5ce4b85c, 0xc25d9fc2, 0xd36ebdd3, 0xacef43ac, 0x62a6c462, 0x91a83991, 0x95a43195, 0xe437d3e4, 0x798bf279, 0xe732d5e7, 0xc8438bc8, 0x37596e37, 0x6db7da6d, 0x8d8c018d, 0xd564b1d5, 0x4ed29c4e, 0xa9e049a9, 0x6cb4d86c, 0x56faac56, 0xf407f3f4, 0xea25cfea, 0x65afca65, 0x7a8ef47a, 0xaee947ae, 0x08181008, 0xbad56fba, 0x7888f078, 0x256f4a25, 0x2e725c2e, 0x1c24381c, 0xa6f157a6, 0xb4c773b4, 0xc65197c6, 0xe823cbe8, 0xdd7ca1dd, 0x749ce874, 0x1f213e1f, 0x4bdd964b, 0xbddc61bd, 0x8b860d8b, 0x8a850f8a, 0x7090e070, 0x3e427c3e, 0xb5c471b5, 0x66aacc66, 0x48d89048, 0x03050603, 0xf601f7f6, 0x0e121c0e, 0x61a3c261, 0x355f6a35, 0x57f9ae57, 0xb9d069b9, 0x86911786, 0xc15899c1, 0x1d273a1d, 0x9eb9279e, 0xe138d9e1, 0xf813ebf8, 0x98b32b98, 0x11332211, 0x69bbd269, 0xd970a9d9, 0x8e89078e, 0x94a73394, 0x9bb62d9b, 0x1e223c1e, 0x87921587, 0xe920c9e9, 0xce4987ce, 0x55ffaa55, 0x28785028, 0xdf7aa5df, 0x8c8f038c, 0xa1f859a1, 0x89800989, 0x0d171a0d, 0xbfda65bf, 0xe631d7e6, 0x42c68442, 0x68b8d068, 0x41c38241, 0x99b02999, 0x2d775a2d, 0x0f111e0f, 0xb0cb7bb0, 0x54fca854, 0xbbd66dbb, 0x163a2c16]; - var T4 = [0x6363a5c6, 0x7c7c84f8, 0x777799ee, 0x7b7b8df6, 0xf2f20dff, 0x6b6bbdd6, 0x6f6fb1de, 0xc5c55491, 0x30305060, 0x01010302, 0x6767a9ce, 0x2b2b7d56, 0xfefe19e7, 0xd7d762b5, 0xababe64d, 0x76769aec, 0xcaca458f, 0x82829d1f, 0xc9c94089, 0x7d7d87fa, 0xfafa15ef, 0x5959ebb2, 0x4747c98e, 0xf0f00bfb, 0xadadec41, 0xd4d467b3, 0xa2a2fd5f, 0xafafea45, 0x9c9cbf23, 0xa4a4f753, 0x727296e4, 0xc0c05b9b, 0xb7b7c275, 0xfdfd1ce1, 0x9393ae3d, 0x26266a4c, 0x36365a6c, 0x3f3f417e, 0xf7f702f5, 0xcccc4f83, 0x34345c68, 0xa5a5f451, 0xe5e534d1, 0xf1f108f9, 0x717193e2, 0xd8d873ab, 0x31315362, 0x15153f2a, 0x04040c08, 0xc7c75295, 0x23236546, 0xc3c35e9d, 0x18182830, 0x9696a137, 0x05050f0a, 0x9a9ab52f, 0x0707090e, 0x12123624, 0x80809b1b, 0xe2e23ddf, 0xebeb26cd, 0x2727694e, 0xb2b2cd7f, 0x75759fea, 0x09091b12, 0x83839e1d, 0x2c2c7458, 0x1a1a2e34, 0x1b1b2d36, 0x6e6eb2dc, 0x5a5aeeb4, 0xa0a0fb5b, 0x5252f6a4, 0x3b3b4d76, 0xd6d661b7, 0xb3b3ce7d, 0x29297b52, 0xe3e33edd, 0x2f2f715e, 0x84849713, 0x5353f5a6, 0xd1d168b9, 0x00000000, 0xeded2cc1, 0x20206040, 0xfcfc1fe3, 0xb1b1c879, 0x5b5bedb6, 0x6a6abed4, 0xcbcb468d, 0xbebed967, 0x39394b72, 0x4a4ade94, 0x4c4cd498, 0x5858e8b0, 0xcfcf4a85, 0xd0d06bbb, 0xefef2ac5, 0xaaaae54f, 0xfbfb16ed, 0x4343c586, 0x4d4dd79a, 0x33335566, 0x85859411, 0x4545cf8a, 0xf9f910e9, 0x02020604, 0x7f7f81fe, 0x5050f0a0, 0x3c3c4478, 0x9f9fba25, 0xa8a8e34b, 0x5151f3a2, 0xa3a3fe5d, 0x4040c080, 0x8f8f8a05, 0x9292ad3f, 0x9d9dbc21, 0x38384870, 0xf5f504f1, 0xbcbcdf63, 0xb6b6c177, 0xdada75af, 0x21216342, 0x10103020, 0xffff1ae5, 0xf3f30efd, 0xd2d26dbf, 0xcdcd4c81, 0x0c0c1418, 0x13133526, 0xecec2fc3, 0x5f5fe1be, 0x9797a235, 0x4444cc88, 0x1717392e, 0xc4c45793, 0xa7a7f255, 0x7e7e82fc, 0x3d3d477a, 0x6464acc8, 0x5d5de7ba, 0x19192b32, 0x737395e6, 0x6060a0c0, 0x81819819, 0x4f4fd19e, 0xdcdc7fa3, 0x22226644, 0x2a2a7e54, 0x9090ab3b, 0x8888830b, 0x4646ca8c, 0xeeee29c7, 0xb8b8d36b, 0x14143c28, 0xdede79a7, 0x5e5ee2bc, 0x0b0b1d16, 0xdbdb76ad, 0xe0e03bdb, 0x32325664, 0x3a3a4e74, 0x0a0a1e14, 0x4949db92, 0x06060a0c, 0x24246c48, 0x5c5ce4b8, 0xc2c25d9f, 0xd3d36ebd, 0xacacef43, 0x6262a6c4, 0x9191a839, 0x9595a431, 0xe4e437d3, 0x79798bf2, 0xe7e732d5, 0xc8c8438b, 0x3737596e, 0x6d6db7da, 0x8d8d8c01, 0xd5d564b1, 0x4e4ed29c, 0xa9a9e049, 0x6c6cb4d8, 0x5656faac, 0xf4f407f3, 0xeaea25cf, 0x6565afca, 0x7a7a8ef4, 0xaeaee947, 0x08081810, 0xbabad56f, 0x787888f0, 0x25256f4a, 0x2e2e725c, 0x1c1c2438, 0xa6a6f157, 0xb4b4c773, 0xc6c65197, 0xe8e823cb, 0xdddd7ca1, 0x74749ce8, 0x1f1f213e, 0x4b4bdd96, 0xbdbddc61, 0x8b8b860d, 0x8a8a850f, 0x707090e0, 0x3e3e427c, 0xb5b5c471, 0x6666aacc, 0x4848d890, 0x03030506, 0xf6f601f7, 0x0e0e121c, 0x6161a3c2, 0x35355f6a, 0x5757f9ae, 0xb9b9d069, 0x86869117, 0xc1c15899, 0x1d1d273a, 0x9e9eb927, 0xe1e138d9, 0xf8f813eb, 0x9898b32b, 0x11113322, 0x6969bbd2, 0xd9d970a9, 0x8e8e8907, 0x9494a733, 0x9b9bb62d, 0x1e1e223c, 0x87879215, 0xe9e920c9, 0xcece4987, 0x5555ffaa, 0x28287850, 0xdfdf7aa5, 0x8c8c8f03, 0xa1a1f859, 0x89898009, 0x0d0d171a, 0xbfbfda65, 0xe6e631d7, 0x4242c684, 0x6868b8d0, 0x4141c382, 0x9999b029, 0x2d2d775a, 0x0f0f111e, 0xb0b0cb7b, 0x5454fca8, 0xbbbbd66d, 0x16163a2c]; - - // Transformations for decryption - var T5 = [0x51f4a750, 0x7e416553, 0x1a17a4c3, 0x3a275e96, 0x3bab6bcb, 0x1f9d45f1, 0xacfa58ab, 0x4be30393, 0x2030fa55, 0xad766df6, 0x88cc7691, 0xf5024c25, 0x4fe5d7fc, 0xc52acbd7, 0x26354480, 0xb562a38f, 0xdeb15a49, 0x25ba1b67, 0x45ea0e98, 0x5dfec0e1, 0xc32f7502, 0x814cf012, 0x8d4697a3, 0x6bd3f9c6, 0x038f5fe7, 0x15929c95, 0xbf6d7aeb, 0x955259da, 0xd4be832d, 0x587421d3, 0x49e06929, 0x8ec9c844, 0x75c2896a, 0xf48e7978, 0x99583e6b, 0x27b971dd, 0xbee14fb6, 0xf088ad17, 0xc920ac66, 0x7dce3ab4, 0x63df4a18, 0xe51a3182, 0x97513360, 0x62537f45, 0xb16477e0, 0xbb6bae84, 0xfe81a01c, 0xf9082b94, 0x70486858, 0x8f45fd19, 0x94de6c87, 0x527bf8b7, 0xab73d323, 0x724b02e2, 0xe31f8f57, 0x6655ab2a, 0xb2eb2807, 0x2fb5c203, 0x86c57b9a, 0xd33708a5, 0x302887f2, 0x23bfa5b2, 0x02036aba, 0xed16825c, 0x8acf1c2b, 0xa779b492, 0xf307f2f0, 0x4e69e2a1, 0x65daf4cd, 0x0605bed5, 0xd134621f, 0xc4a6fe8a, 0x342e539d, 0xa2f355a0, 0x058ae132, 0xa4f6eb75, 0x0b83ec39, 0x4060efaa, 0x5e719f06, 0xbd6e1051, 0x3e218af9, 0x96dd063d, 0xdd3e05ae, 0x4de6bd46, 0x91548db5, 0x71c45d05, 0x0406d46f, 0x605015ff, 0x1998fb24, 0xd6bde997, 0x894043cc, 0x67d99e77, 0xb0e842bd, 0x07898b88, 0xe7195b38, 0x79c8eedb, 0xa17c0a47, 0x7c420fe9, 0xf8841ec9, 0x00000000, 0x09808683, 0x322bed48, 0x1e1170ac, 0x6c5a724e, 0xfd0efffb, 0x0f853856, 0x3daed51e, 0x362d3927, 0x0a0fd964, 0x685ca621, 0x9b5b54d1, 0x24362e3a, 0x0c0a67b1, 0x9357e70f, 0xb4ee96d2, 0x1b9b919e, 0x80c0c54f, 0x61dc20a2, 0x5a774b69, 0x1c121a16, 0xe293ba0a, 0xc0a02ae5, 0x3c22e043, 0x121b171d, 0x0e090d0b, 0xf28bc7ad, 0x2db6a8b9, 0x141ea9c8, 0x57f11985, 0xaf75074c, 0xee99ddbb, 0xa37f60fd, 0xf701269f, 0x5c72f5bc, 0x44663bc5, 0x5bfb7e34, 0x8b432976, 0xcb23c6dc, 0xb6edfc68, 0xb8e4f163, 0xd731dcca, 0x42638510, 0x13972240, 0x84c61120, 0x854a247d, 0xd2bb3df8, 0xaef93211, 0xc729a16d, 0x1d9e2f4b, 0xdcb230f3, 0x0d8652ec, 0x77c1e3d0, 0x2bb3166c, 0xa970b999, 0x119448fa, 0x47e96422, 0xa8fc8cc4, 0xa0f03f1a, 0x567d2cd8, 0x223390ef, 0x87494ec7, 0xd938d1c1, 0x8ccaa2fe, 0x98d40b36, 0xa6f581cf, 0xa57ade28, 0xdab78e26, 0x3fadbfa4, 0x2c3a9de4, 0x5078920d, 0x6a5fcc9b, 0x547e4662, 0xf68d13c2, 0x90d8b8e8, 0x2e39f75e, 0x82c3aff5, 0x9f5d80be, 0x69d0937c, 0x6fd52da9, 0xcf2512b3, 0xc8ac993b, 0x10187da7, 0xe89c636e, 0xdb3bbb7b, 0xcd267809, 0x6e5918f4, 0xec9ab701, 0x834f9aa8, 0xe6956e65, 0xaaffe67e, 0x21bccf08, 0xef15e8e6, 0xbae79bd9, 0x4a6f36ce, 0xea9f09d4, 0x29b07cd6, 0x31a4b2af, 0x2a3f2331, 0xc6a59430, 0x35a266c0, 0x744ebc37, 0xfc82caa6, 0xe090d0b0, 0x33a7d815, 0xf104984a, 0x41ecdaf7, 0x7fcd500e, 0x1791f62f, 0x764dd68d, 0x43efb04d, 0xccaa4d54, 0xe49604df, 0x9ed1b5e3, 0x4c6a881b, 0xc12c1fb8, 0x4665517f, 0x9d5eea04, 0x018c355d, 0xfa877473, 0xfb0b412e, 0xb3671d5a, 0x92dbd252, 0xe9105633, 0x6dd64713, 0x9ad7618c, 0x37a10c7a, 0x59f8148e, 0xeb133c89, 0xcea927ee, 0xb761c935, 0xe11ce5ed, 0x7a47b13c, 0x9cd2df59, 0x55f2733f, 0x1814ce79, 0x73c737bf, 0x53f7cdea, 0x5ffdaa5b, 0xdf3d6f14, 0x7844db86, 0xcaaff381, 0xb968c43e, 0x3824342c, 0xc2a3405f, 0x161dc372, 0xbce2250c, 0x283c498b, 0xff0d9541, 0x39a80171, 0x080cb3de, 0xd8b4e49c, 0x6456c190, 0x7bcb8461, 0xd532b670, 0x486c5c74, 0xd0b85742]; - var T6 = [0x5051f4a7, 0x537e4165, 0xc31a17a4, 0x963a275e, 0xcb3bab6b, 0xf11f9d45, 0xabacfa58, 0x934be303, 0x552030fa, 0xf6ad766d, 0x9188cc76, 0x25f5024c, 0xfc4fe5d7, 0xd7c52acb, 0x80263544, 0x8fb562a3, 0x49deb15a, 0x6725ba1b, 0x9845ea0e, 0xe15dfec0, 0x02c32f75, 0x12814cf0, 0xa38d4697, 0xc66bd3f9, 0xe7038f5f, 0x9515929c, 0xebbf6d7a, 0xda955259, 0x2dd4be83, 0xd3587421, 0x2949e069, 0x448ec9c8, 0x6a75c289, 0x78f48e79, 0x6b99583e, 0xdd27b971, 0xb6bee14f, 0x17f088ad, 0x66c920ac, 0xb47dce3a, 0x1863df4a, 0x82e51a31, 0x60975133, 0x4562537f, 0xe0b16477, 0x84bb6bae, 0x1cfe81a0, 0x94f9082b, 0x58704868, 0x198f45fd, 0x8794de6c, 0xb7527bf8, 0x23ab73d3, 0xe2724b02, 0x57e31f8f, 0x2a6655ab, 0x07b2eb28, 0x032fb5c2, 0x9a86c57b, 0xa5d33708, 0xf2302887, 0xb223bfa5, 0xba02036a, 0x5ced1682, 0x2b8acf1c, 0x92a779b4, 0xf0f307f2, 0xa14e69e2, 0xcd65daf4, 0xd50605be, 0x1fd13462, 0x8ac4a6fe, 0x9d342e53, 0xa0a2f355, 0x32058ae1, 0x75a4f6eb, 0x390b83ec, 0xaa4060ef, 0x065e719f, 0x51bd6e10, 0xf93e218a, 0x3d96dd06, 0xaedd3e05, 0x464de6bd, 0xb591548d, 0x0571c45d, 0x6f0406d4, 0xff605015, 0x241998fb, 0x97d6bde9, 0xcc894043, 0x7767d99e, 0xbdb0e842, 0x8807898b, 0x38e7195b, 0xdb79c8ee, 0x47a17c0a, 0xe97c420f, 0xc9f8841e, 0x00000000, 0x83098086, 0x48322bed, 0xac1e1170, 0x4e6c5a72, 0xfbfd0eff, 0x560f8538, 0x1e3daed5, 0x27362d39, 0x640a0fd9, 0x21685ca6, 0xd19b5b54, 0x3a24362e, 0xb10c0a67, 0x0f9357e7, 0xd2b4ee96, 0x9e1b9b91, 0x4f80c0c5, 0xa261dc20, 0x695a774b, 0x161c121a, 0x0ae293ba, 0xe5c0a02a, 0x433c22e0, 0x1d121b17, 0x0b0e090d, 0xadf28bc7, 0xb92db6a8, 0xc8141ea9, 0x8557f119, 0x4caf7507, 0xbbee99dd, 0xfda37f60, 0x9ff70126, 0xbc5c72f5, 0xc544663b, 0x345bfb7e, 0x768b4329, 0xdccb23c6, 0x68b6edfc, 0x63b8e4f1, 0xcad731dc, 0x10426385, 0x40139722, 0x2084c611, 0x7d854a24, 0xf8d2bb3d, 0x11aef932, 0x6dc729a1, 0x4b1d9e2f, 0xf3dcb230, 0xec0d8652, 0xd077c1e3, 0x6c2bb316, 0x99a970b9, 0xfa119448, 0x2247e964, 0xc4a8fc8c, 0x1aa0f03f, 0xd8567d2c, 0xef223390, 0xc787494e, 0xc1d938d1, 0xfe8ccaa2, 0x3698d40b, 0xcfa6f581, 0x28a57ade, 0x26dab78e, 0xa43fadbf, 0xe42c3a9d, 0x0d507892, 0x9b6a5fcc, 0x62547e46, 0xc2f68d13, 0xe890d8b8, 0x5e2e39f7, 0xf582c3af, 0xbe9f5d80, 0x7c69d093, 0xa96fd52d, 0xb3cf2512, 0x3bc8ac99, 0xa710187d, 0x6ee89c63, 0x7bdb3bbb, 0x09cd2678, 0xf46e5918, 0x01ec9ab7, 0xa8834f9a, 0x65e6956e, 0x7eaaffe6, 0x0821bccf, 0xe6ef15e8, 0xd9bae79b, 0xce4a6f36, 0xd4ea9f09, 0xd629b07c, 0xaf31a4b2, 0x312a3f23, 0x30c6a594, 0xc035a266, 0x37744ebc, 0xa6fc82ca, 0xb0e090d0, 0x1533a7d8, 0x4af10498, 0xf741ecda, 0x0e7fcd50, 0x2f1791f6, 0x8d764dd6, 0x4d43efb0, 0x54ccaa4d, 0xdfe49604, 0xe39ed1b5, 0x1b4c6a88, 0xb8c12c1f, 0x7f466551, 0x049d5eea, 0x5d018c35, 0x73fa8774, 0x2efb0b41, 0x5ab3671d, 0x5292dbd2, 0x33e91056, 0x136dd647, 0x8c9ad761, 0x7a37a10c, 0x8e59f814, 0x89eb133c, 0xeecea927, 0x35b761c9, 0xede11ce5, 0x3c7a47b1, 0x599cd2df, 0x3f55f273, 0x791814ce, 0xbf73c737, 0xea53f7cd, 0x5b5ffdaa, 0x14df3d6f, 0x867844db, 0x81caaff3, 0x3eb968c4, 0x2c382434, 0x5fc2a340, 0x72161dc3, 0x0cbce225, 0x8b283c49, 0x41ff0d95, 0x7139a801, 0xde080cb3, 0x9cd8b4e4, 0x906456c1, 0x617bcb84, 0x70d532b6, 0x74486c5c, 0x42d0b857]; - var T7 = [0xa75051f4, 0x65537e41, 0xa4c31a17, 0x5e963a27, 0x6bcb3bab, 0x45f11f9d, 0x58abacfa, 0x03934be3, 0xfa552030, 0x6df6ad76, 0x769188cc, 0x4c25f502, 0xd7fc4fe5, 0xcbd7c52a, 0x44802635, 0xa38fb562, 0x5a49deb1, 0x1b6725ba, 0x0e9845ea, 0xc0e15dfe, 0x7502c32f, 0xf012814c, 0x97a38d46, 0xf9c66bd3, 0x5fe7038f, 0x9c951592, 0x7aebbf6d, 0x59da9552, 0x832dd4be, 0x21d35874, 0x692949e0, 0xc8448ec9, 0x896a75c2, 0x7978f48e, 0x3e6b9958, 0x71dd27b9, 0x4fb6bee1, 0xad17f088, 0xac66c920, 0x3ab47dce, 0x4a1863df, 0x3182e51a, 0x33609751, 0x7f456253, 0x77e0b164, 0xae84bb6b, 0xa01cfe81, 0x2b94f908, 0x68587048, 0xfd198f45, 0x6c8794de, 0xf8b7527b, 0xd323ab73, 0x02e2724b, 0x8f57e31f, 0xab2a6655, 0x2807b2eb, 0xc2032fb5, 0x7b9a86c5, 0x08a5d337, 0x87f23028, 0xa5b223bf, 0x6aba0203, 0x825ced16, 0x1c2b8acf, 0xb492a779, 0xf2f0f307, 0xe2a14e69, 0xf4cd65da, 0xbed50605, 0x621fd134, 0xfe8ac4a6, 0x539d342e, 0x55a0a2f3, 0xe132058a, 0xeb75a4f6, 0xec390b83, 0xefaa4060, 0x9f065e71, 0x1051bd6e, 0x8af93e21, 0x063d96dd, 0x05aedd3e, 0xbd464de6, 0x8db59154, 0x5d0571c4, 0xd46f0406, 0x15ff6050, 0xfb241998, 0xe997d6bd, 0x43cc8940, 0x9e7767d9, 0x42bdb0e8, 0x8b880789, 0x5b38e719, 0xeedb79c8, 0x0a47a17c, 0x0fe97c42, 0x1ec9f884, 0x00000000, 0x86830980, 0xed48322b, 0x70ac1e11, 0x724e6c5a, 0xfffbfd0e, 0x38560f85, 0xd51e3dae, 0x3927362d, 0xd9640a0f, 0xa621685c, 0x54d19b5b, 0x2e3a2436, 0x67b10c0a, 0xe70f9357, 0x96d2b4ee, 0x919e1b9b, 0xc54f80c0, 0x20a261dc, 0x4b695a77, 0x1a161c12, 0xba0ae293, 0x2ae5c0a0, 0xe0433c22, 0x171d121b, 0x0d0b0e09, 0xc7adf28b, 0xa8b92db6, 0xa9c8141e, 0x198557f1, 0x074caf75, 0xddbbee99, 0x60fda37f, 0x269ff701, 0xf5bc5c72, 0x3bc54466, 0x7e345bfb, 0x29768b43, 0xc6dccb23, 0xfc68b6ed, 0xf163b8e4, 0xdccad731, 0x85104263, 0x22401397, 0x112084c6, 0x247d854a, 0x3df8d2bb, 0x3211aef9, 0xa16dc729, 0x2f4b1d9e, 0x30f3dcb2, 0x52ec0d86, 0xe3d077c1, 0x166c2bb3, 0xb999a970, 0x48fa1194, 0x642247e9, 0x8cc4a8fc, 0x3f1aa0f0, 0x2cd8567d, 0x90ef2233, 0x4ec78749, 0xd1c1d938, 0xa2fe8cca, 0x0b3698d4, 0x81cfa6f5, 0xde28a57a, 0x8e26dab7, 0xbfa43fad, 0x9de42c3a, 0x920d5078, 0xcc9b6a5f, 0x4662547e, 0x13c2f68d, 0xb8e890d8, 0xf75e2e39, 0xaff582c3, 0x80be9f5d, 0x937c69d0, 0x2da96fd5, 0x12b3cf25, 0x993bc8ac, 0x7da71018, 0x636ee89c, 0xbb7bdb3b, 0x7809cd26, 0x18f46e59, 0xb701ec9a, 0x9aa8834f, 0x6e65e695, 0xe67eaaff, 0xcf0821bc, 0xe8e6ef15, 0x9bd9bae7, 0x36ce4a6f, 0x09d4ea9f, 0x7cd629b0, 0xb2af31a4, 0x23312a3f, 0x9430c6a5, 0x66c035a2, 0xbc37744e, 0xcaa6fc82, 0xd0b0e090, 0xd81533a7, 0x984af104, 0xdaf741ec, 0x500e7fcd, 0xf62f1791, 0xd68d764d, 0xb04d43ef, 0x4d54ccaa, 0x04dfe496, 0xb5e39ed1, 0x881b4c6a, 0x1fb8c12c, 0x517f4665, 0xea049d5e, 0x355d018c, 0x7473fa87, 0x412efb0b, 0x1d5ab367, 0xd25292db, 0x5633e910, 0x47136dd6, 0x618c9ad7, 0x0c7a37a1, 0x148e59f8, 0x3c89eb13, 0x27eecea9, 0xc935b761, 0xe5ede11c, 0xb13c7a47, 0xdf599cd2, 0x733f55f2, 0xce791814, 0x37bf73c7, 0xcdea53f7, 0xaa5b5ffd, 0x6f14df3d, 0xdb867844, 0xf381caaf, 0xc43eb968, 0x342c3824, 0x405fc2a3, 0xc372161d, 0x250cbce2, 0x498b283c, 0x9541ff0d, 0x017139a8, 0xb3de080c, 0xe49cd8b4, 0xc1906456, 0x84617bcb, 0xb670d532, 0x5c74486c, 0x5742d0b8]; - var T8 = [0xf4a75051, 0x4165537e, 0x17a4c31a, 0x275e963a, 0xab6bcb3b, 0x9d45f11f, 0xfa58abac, 0xe303934b, 0x30fa5520, 0x766df6ad, 0xcc769188, 0x024c25f5, 0xe5d7fc4f, 0x2acbd7c5, 0x35448026, 0x62a38fb5, 0xb15a49de, 0xba1b6725, 0xea0e9845, 0xfec0e15d, 0x2f7502c3, 0x4cf01281, 0x4697a38d, 0xd3f9c66b, 0x8f5fe703, 0x929c9515, 0x6d7aebbf, 0x5259da95, 0xbe832dd4, 0x7421d358, 0xe0692949, 0xc9c8448e, 0xc2896a75, 0x8e7978f4, 0x583e6b99, 0xb971dd27, 0xe14fb6be, 0x88ad17f0, 0x20ac66c9, 0xce3ab47d, 0xdf4a1863, 0x1a3182e5, 0x51336097, 0x537f4562, 0x6477e0b1, 0x6bae84bb, 0x81a01cfe, 0x082b94f9, 0x48685870, 0x45fd198f, 0xde6c8794, 0x7bf8b752, 0x73d323ab, 0x4b02e272, 0x1f8f57e3, 0x55ab2a66, 0xeb2807b2, 0xb5c2032f, 0xc57b9a86, 0x3708a5d3, 0x2887f230, 0xbfa5b223, 0x036aba02, 0x16825ced, 0xcf1c2b8a, 0x79b492a7, 0x07f2f0f3, 0x69e2a14e, 0xdaf4cd65, 0x05bed506, 0x34621fd1, 0xa6fe8ac4, 0x2e539d34, 0xf355a0a2, 0x8ae13205, 0xf6eb75a4, 0x83ec390b, 0x60efaa40, 0x719f065e, 0x6e1051bd, 0x218af93e, 0xdd063d96, 0x3e05aedd, 0xe6bd464d, 0x548db591, 0xc45d0571, 0x06d46f04, 0x5015ff60, 0x98fb2419, 0xbde997d6, 0x4043cc89, 0xd99e7767, 0xe842bdb0, 0x898b8807, 0x195b38e7, 0xc8eedb79, 0x7c0a47a1, 0x420fe97c, 0x841ec9f8, 0x00000000, 0x80868309, 0x2bed4832, 0x1170ac1e, 0x5a724e6c, 0x0efffbfd, 0x8538560f, 0xaed51e3d, 0x2d392736, 0x0fd9640a, 0x5ca62168, 0x5b54d19b, 0x362e3a24, 0x0a67b10c, 0x57e70f93, 0xee96d2b4, 0x9b919e1b, 0xc0c54f80, 0xdc20a261, 0x774b695a, 0x121a161c, 0x93ba0ae2, 0xa02ae5c0, 0x22e0433c, 0x1b171d12, 0x090d0b0e, 0x8bc7adf2, 0xb6a8b92d, 0x1ea9c814, 0xf1198557, 0x75074caf, 0x99ddbbee, 0x7f60fda3, 0x01269ff7, 0x72f5bc5c, 0x663bc544, 0xfb7e345b, 0x4329768b, 0x23c6dccb, 0xedfc68b6, 0xe4f163b8, 0x31dccad7, 0x63851042, 0x97224013, 0xc6112084, 0x4a247d85, 0xbb3df8d2, 0xf93211ae, 0x29a16dc7, 0x9e2f4b1d, 0xb230f3dc, 0x8652ec0d, 0xc1e3d077, 0xb3166c2b, 0x70b999a9, 0x9448fa11, 0xe9642247, 0xfc8cc4a8, 0xf03f1aa0, 0x7d2cd856, 0x3390ef22, 0x494ec787, 0x38d1c1d9, 0xcaa2fe8c, 0xd40b3698, 0xf581cfa6, 0x7ade28a5, 0xb78e26da, 0xadbfa43f, 0x3a9de42c, 0x78920d50, 0x5fcc9b6a, 0x7e466254, 0x8d13c2f6, 0xd8b8e890, 0x39f75e2e, 0xc3aff582, 0x5d80be9f, 0xd0937c69, 0xd52da96f, 0x2512b3cf, 0xac993bc8, 0x187da710, 0x9c636ee8, 0x3bbb7bdb, 0x267809cd, 0x5918f46e, 0x9ab701ec, 0x4f9aa883, 0x956e65e6, 0xffe67eaa, 0xbccf0821, 0x15e8e6ef, 0xe79bd9ba, 0x6f36ce4a, 0x9f09d4ea, 0xb07cd629, 0xa4b2af31, 0x3f23312a, 0xa59430c6, 0xa266c035, 0x4ebc3774, 0x82caa6fc, 0x90d0b0e0, 0xa7d81533, 0x04984af1, 0xecdaf741, 0xcd500e7f, 0x91f62f17, 0x4dd68d76, 0xefb04d43, 0xaa4d54cc, 0x9604dfe4, 0xd1b5e39e, 0x6a881b4c, 0x2c1fb8c1, 0x65517f46, 0x5eea049d, 0x8c355d01, 0x877473fa, 0x0b412efb, 0x671d5ab3, 0xdbd25292, 0x105633e9, 0xd647136d, 0xd7618c9a, 0xa10c7a37, 0xf8148e59, 0x133c89eb, 0xa927eece, 0x61c935b7, 0x1ce5ede1, 0x47b13c7a, 0xd2df599c, 0xf2733f55, 0x14ce7918, 0xc737bf73, 0xf7cdea53, 0xfdaa5b5f, 0x3d6f14df, 0x44db8678, 0xaff381ca, 0x68c43eb9, 0x24342c38, 0xa3405fc2, 0x1dc37216, 0xe2250cbc, 0x3c498b28, 0x0d9541ff, 0xa8017139, 0x0cb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0]; - - // Transformations for decryption key expansion - var U1 = [0x00000000, 0x0e090d0b, 0x1c121a16, 0x121b171d, 0x3824342c, 0x362d3927, 0x24362e3a, 0x2a3f2331, 0x70486858, 0x7e416553, 0x6c5a724e, 0x62537f45, 0x486c5c74, 0x4665517f, 0x547e4662, 0x5a774b69, 0xe090d0b0, 0xee99ddbb, 0xfc82caa6, 0xf28bc7ad, 0xd8b4e49c, 0xd6bde997, 0xc4a6fe8a, 0xcaaff381, 0x90d8b8e8, 0x9ed1b5e3, 0x8ccaa2fe, 0x82c3aff5, 0xa8fc8cc4, 0xa6f581cf, 0xb4ee96d2, 0xbae79bd9, 0xdb3bbb7b, 0xd532b670, 0xc729a16d, 0xc920ac66, 0xe31f8f57, 0xed16825c, 0xff0d9541, 0xf104984a, 0xab73d323, 0xa57ade28, 0xb761c935, 0xb968c43e, 0x9357e70f, 0x9d5eea04, 0x8f45fd19, 0x814cf012, 0x3bab6bcb, 0x35a266c0, 0x27b971dd, 0x29b07cd6, 0x038f5fe7, 0x0d8652ec, 0x1f9d45f1, 0x119448fa, 0x4be30393, 0x45ea0e98, 0x57f11985, 0x59f8148e, 0x73c737bf, 0x7dce3ab4, 0x6fd52da9, 0x61dc20a2, 0xad766df6, 0xa37f60fd, 0xb16477e0, 0xbf6d7aeb, 0x955259da, 0x9b5b54d1, 0x894043cc, 0x87494ec7, 0xdd3e05ae, 0xd33708a5, 0xc12c1fb8, 0xcf2512b3, 0xe51a3182, 0xeb133c89, 0xf9082b94, 0xf701269f, 0x4de6bd46, 0x43efb04d, 0x51f4a750, 0x5ffdaa5b, 0x75c2896a, 0x7bcb8461, 0x69d0937c, 0x67d99e77, 0x3daed51e, 0x33a7d815, 0x21bccf08, 0x2fb5c203, 0x058ae132, 0x0b83ec39, 0x1998fb24, 0x1791f62f, 0x764dd68d, 0x7844db86, 0x6a5fcc9b, 0x6456c190, 0x4e69e2a1, 0x4060efaa, 0x527bf8b7, 0x5c72f5bc, 0x0605bed5, 0x080cb3de, 0x1a17a4c3, 0x141ea9c8, 0x3e218af9, 0x302887f2, 0x223390ef, 0x2c3a9de4, 0x96dd063d, 0x98d40b36, 0x8acf1c2b, 0x84c61120, 0xaef93211, 0xa0f03f1a, 0xb2eb2807, 0xbce2250c, 0xe6956e65, 0xe89c636e, 0xfa877473, 0xf48e7978, 0xdeb15a49, 0xd0b85742, 0xc2a3405f, 0xccaa4d54, 0x41ecdaf7, 0x4fe5d7fc, 0x5dfec0e1, 0x53f7cdea, 0x79c8eedb, 0x77c1e3d0, 0x65daf4cd, 0x6bd3f9c6, 0x31a4b2af, 0x3fadbfa4, 0x2db6a8b9, 0x23bfa5b2, 0x09808683, 0x07898b88, 0x15929c95, 0x1b9b919e, 0xa17c0a47, 0xaf75074c, 0xbd6e1051, 0xb3671d5a, 0x99583e6b, 0x97513360, 0x854a247d, 0x8b432976, 0xd134621f, 0xdf3d6f14, 0xcd267809, 0xc32f7502, 0xe9105633, 0xe7195b38, 0xf5024c25, 0xfb0b412e, 0x9ad7618c, 0x94de6c87, 0x86c57b9a, 0x88cc7691, 0xa2f355a0, 0xacfa58ab, 0xbee14fb6, 0xb0e842bd, 0xea9f09d4, 0xe49604df, 0xf68d13c2, 0xf8841ec9, 0xd2bb3df8, 0xdcb230f3, 0xcea927ee, 0xc0a02ae5, 0x7a47b13c, 0x744ebc37, 0x6655ab2a, 0x685ca621, 0x42638510, 0x4c6a881b, 0x5e719f06, 0x5078920d, 0x0a0fd964, 0x0406d46f, 0x161dc372, 0x1814ce79, 0x322bed48, 0x3c22e043, 0x2e39f75e, 0x2030fa55, 0xec9ab701, 0xe293ba0a, 0xf088ad17, 0xfe81a01c, 0xd4be832d, 0xdab78e26, 0xc8ac993b, 0xc6a59430, 0x9cd2df59, 0x92dbd252, 0x80c0c54f, 0x8ec9c844, 0xa4f6eb75, 0xaaffe67e, 0xb8e4f163, 0xb6edfc68, 0x0c0a67b1, 0x02036aba, 0x10187da7, 0x1e1170ac, 0x342e539d, 0x3a275e96, 0x283c498b, 0x26354480, 0x7c420fe9, 0x724b02e2, 0x605015ff, 0x6e5918f4, 0x44663bc5, 0x4a6f36ce, 0x587421d3, 0x567d2cd8, 0x37a10c7a, 0x39a80171, 0x2bb3166c, 0x25ba1b67, 0x0f853856, 0x018c355d, 0x13972240, 0x1d9e2f4b, 0x47e96422, 0x49e06929, 0x5bfb7e34, 0x55f2733f, 0x7fcd500e, 0x71c45d05, 0x63df4a18, 0x6dd64713, 0xd731dcca, 0xd938d1c1, 0xcb23c6dc, 0xc52acbd7, 0xef15e8e6, 0xe11ce5ed, 0xf307f2f0, 0xfd0efffb, 0xa779b492, 0xa970b999, 0xbb6bae84, 0xb562a38f, 0x9f5d80be, 0x91548db5, 0x834f9aa8, 0x8d4697a3]; - var U2 = [0x00000000, 0x0b0e090d, 0x161c121a, 0x1d121b17, 0x2c382434, 0x27362d39, 0x3a24362e, 0x312a3f23, 0x58704868, 0x537e4165, 0x4e6c5a72, 0x4562537f, 0x74486c5c, 0x7f466551, 0x62547e46, 0x695a774b, 0xb0e090d0, 0xbbee99dd, 0xa6fc82ca, 0xadf28bc7, 0x9cd8b4e4, 0x97d6bde9, 0x8ac4a6fe, 0x81caaff3, 0xe890d8b8, 0xe39ed1b5, 0xfe8ccaa2, 0xf582c3af, 0xc4a8fc8c, 0xcfa6f581, 0xd2b4ee96, 0xd9bae79b, 0x7bdb3bbb, 0x70d532b6, 0x6dc729a1, 0x66c920ac, 0x57e31f8f, 0x5ced1682, 0x41ff0d95, 0x4af10498, 0x23ab73d3, 0x28a57ade, 0x35b761c9, 0x3eb968c4, 0x0f9357e7, 0x049d5eea, 0x198f45fd, 0x12814cf0, 0xcb3bab6b, 0xc035a266, 0xdd27b971, 0xd629b07c, 0xe7038f5f, 0xec0d8652, 0xf11f9d45, 0xfa119448, 0x934be303, 0x9845ea0e, 0x8557f119, 0x8e59f814, 0xbf73c737, 0xb47dce3a, 0xa96fd52d, 0xa261dc20, 0xf6ad766d, 0xfda37f60, 0xe0b16477, 0xebbf6d7a, 0xda955259, 0xd19b5b54, 0xcc894043, 0xc787494e, 0xaedd3e05, 0xa5d33708, 0xb8c12c1f, 0xb3cf2512, 0x82e51a31, 0x89eb133c, 0x94f9082b, 0x9ff70126, 0x464de6bd, 0x4d43efb0, 0x5051f4a7, 0x5b5ffdaa, 0x6a75c289, 0x617bcb84, 0x7c69d093, 0x7767d99e, 0x1e3daed5, 0x1533a7d8, 0x0821bccf, 0x032fb5c2, 0x32058ae1, 0x390b83ec, 0x241998fb, 0x2f1791f6, 0x8d764dd6, 0x867844db, 0x9b6a5fcc, 0x906456c1, 0xa14e69e2, 0xaa4060ef, 0xb7527bf8, 0xbc5c72f5, 0xd50605be, 0xde080cb3, 0xc31a17a4, 0xc8141ea9, 0xf93e218a, 0xf2302887, 0xef223390, 0xe42c3a9d, 0x3d96dd06, 0x3698d40b, 0x2b8acf1c, 0x2084c611, 0x11aef932, 0x1aa0f03f, 0x07b2eb28, 0x0cbce225, 0x65e6956e, 0x6ee89c63, 0x73fa8774, 0x78f48e79, 0x49deb15a, 0x42d0b857, 0x5fc2a340, 0x54ccaa4d, 0xf741ecda, 0xfc4fe5d7, 0xe15dfec0, 0xea53f7cd, 0xdb79c8ee, 0xd077c1e3, 0xcd65daf4, 0xc66bd3f9, 0xaf31a4b2, 0xa43fadbf, 0xb92db6a8, 0xb223bfa5, 0x83098086, 0x8807898b, 0x9515929c, 0x9e1b9b91, 0x47a17c0a, 0x4caf7507, 0x51bd6e10, 0x5ab3671d, 0x6b99583e, 0x60975133, 0x7d854a24, 0x768b4329, 0x1fd13462, 0x14df3d6f, 0x09cd2678, 0x02c32f75, 0x33e91056, 0x38e7195b, 0x25f5024c, 0x2efb0b41, 0x8c9ad761, 0x8794de6c, 0x9a86c57b, 0x9188cc76, 0xa0a2f355, 0xabacfa58, 0xb6bee14f, 0xbdb0e842, 0xd4ea9f09, 0xdfe49604, 0xc2f68d13, 0xc9f8841e, 0xf8d2bb3d, 0xf3dcb230, 0xeecea927, 0xe5c0a02a, 0x3c7a47b1, 0x37744ebc, 0x2a6655ab, 0x21685ca6, 0x10426385, 0x1b4c6a88, 0x065e719f, 0x0d507892, 0x640a0fd9, 0x6f0406d4, 0x72161dc3, 0x791814ce, 0x48322bed, 0x433c22e0, 0x5e2e39f7, 0x552030fa, 0x01ec9ab7, 0x0ae293ba, 0x17f088ad, 0x1cfe81a0, 0x2dd4be83, 0x26dab78e, 0x3bc8ac99, 0x30c6a594, 0x599cd2df, 0x5292dbd2, 0x4f80c0c5, 0x448ec9c8, 0x75a4f6eb, 0x7eaaffe6, 0x63b8e4f1, 0x68b6edfc, 0xb10c0a67, 0xba02036a, 0xa710187d, 0xac1e1170, 0x9d342e53, 0x963a275e, 0x8b283c49, 0x80263544, 0xe97c420f, 0xe2724b02, 0xff605015, 0xf46e5918, 0xc544663b, 0xce4a6f36, 0xd3587421, 0xd8567d2c, 0x7a37a10c, 0x7139a801, 0x6c2bb316, 0x6725ba1b, 0x560f8538, 0x5d018c35, 0x40139722, 0x4b1d9e2f, 0x2247e964, 0x2949e069, 0x345bfb7e, 0x3f55f273, 0x0e7fcd50, 0x0571c45d, 0x1863df4a, 0x136dd647, 0xcad731dc, 0xc1d938d1, 0xdccb23c6, 0xd7c52acb, 0xe6ef15e8, 0xede11ce5, 0xf0f307f2, 0xfbfd0eff, 0x92a779b4, 0x99a970b9, 0x84bb6bae, 0x8fb562a3, 0xbe9f5d80, 0xb591548d, 0xa8834f9a, 0xa38d4697]; - var U3 = [0x00000000, 0x0d0b0e09, 0x1a161c12, 0x171d121b, 0x342c3824, 0x3927362d, 0x2e3a2436, 0x23312a3f, 0x68587048, 0x65537e41, 0x724e6c5a, 0x7f456253, 0x5c74486c, 0x517f4665, 0x4662547e, 0x4b695a77, 0xd0b0e090, 0xddbbee99, 0xcaa6fc82, 0xc7adf28b, 0xe49cd8b4, 0xe997d6bd, 0xfe8ac4a6, 0xf381caaf, 0xb8e890d8, 0xb5e39ed1, 0xa2fe8cca, 0xaff582c3, 0x8cc4a8fc, 0x81cfa6f5, 0x96d2b4ee, 0x9bd9bae7, 0xbb7bdb3b, 0xb670d532, 0xa16dc729, 0xac66c920, 0x8f57e31f, 0x825ced16, 0x9541ff0d, 0x984af104, 0xd323ab73, 0xde28a57a, 0xc935b761, 0xc43eb968, 0xe70f9357, 0xea049d5e, 0xfd198f45, 0xf012814c, 0x6bcb3bab, 0x66c035a2, 0x71dd27b9, 0x7cd629b0, 0x5fe7038f, 0x52ec0d86, 0x45f11f9d, 0x48fa1194, 0x03934be3, 0x0e9845ea, 0x198557f1, 0x148e59f8, 0x37bf73c7, 0x3ab47dce, 0x2da96fd5, 0x20a261dc, 0x6df6ad76, 0x60fda37f, 0x77e0b164, 0x7aebbf6d, 0x59da9552, 0x54d19b5b, 0x43cc8940, 0x4ec78749, 0x05aedd3e, 0x08a5d337, 0x1fb8c12c, 0x12b3cf25, 0x3182e51a, 0x3c89eb13, 0x2b94f908, 0x269ff701, 0xbd464de6, 0xb04d43ef, 0xa75051f4, 0xaa5b5ffd, 0x896a75c2, 0x84617bcb, 0x937c69d0, 0x9e7767d9, 0xd51e3dae, 0xd81533a7, 0xcf0821bc, 0xc2032fb5, 0xe132058a, 0xec390b83, 0xfb241998, 0xf62f1791, 0xd68d764d, 0xdb867844, 0xcc9b6a5f, 0xc1906456, 0xe2a14e69, 0xefaa4060, 0xf8b7527b, 0xf5bc5c72, 0xbed50605, 0xb3de080c, 0xa4c31a17, 0xa9c8141e, 0x8af93e21, 0x87f23028, 0x90ef2233, 0x9de42c3a, 0x063d96dd, 0x0b3698d4, 0x1c2b8acf, 0x112084c6, 0x3211aef9, 0x3f1aa0f0, 0x2807b2eb, 0x250cbce2, 0x6e65e695, 0x636ee89c, 0x7473fa87, 0x7978f48e, 0x5a49deb1, 0x5742d0b8, 0x405fc2a3, 0x4d54ccaa, 0xdaf741ec, 0xd7fc4fe5, 0xc0e15dfe, 0xcdea53f7, 0xeedb79c8, 0xe3d077c1, 0xf4cd65da, 0xf9c66bd3, 0xb2af31a4, 0xbfa43fad, 0xa8b92db6, 0xa5b223bf, 0x86830980, 0x8b880789, 0x9c951592, 0x919e1b9b, 0x0a47a17c, 0x074caf75, 0x1051bd6e, 0x1d5ab367, 0x3e6b9958, 0x33609751, 0x247d854a, 0x29768b43, 0x621fd134, 0x6f14df3d, 0x7809cd26, 0x7502c32f, 0x5633e910, 0x5b38e719, 0x4c25f502, 0x412efb0b, 0x618c9ad7, 0x6c8794de, 0x7b9a86c5, 0x769188cc, 0x55a0a2f3, 0x58abacfa, 0x4fb6bee1, 0x42bdb0e8, 0x09d4ea9f, 0x04dfe496, 0x13c2f68d, 0x1ec9f884, 0x3df8d2bb, 0x30f3dcb2, 0x27eecea9, 0x2ae5c0a0, 0xb13c7a47, 0xbc37744e, 0xab2a6655, 0xa621685c, 0x85104263, 0x881b4c6a, 0x9f065e71, 0x920d5078, 0xd9640a0f, 0xd46f0406, 0xc372161d, 0xce791814, 0xed48322b, 0xe0433c22, 0xf75e2e39, 0xfa552030, 0xb701ec9a, 0xba0ae293, 0xad17f088, 0xa01cfe81, 0x832dd4be, 0x8e26dab7, 0x993bc8ac, 0x9430c6a5, 0xdf599cd2, 0xd25292db, 0xc54f80c0, 0xc8448ec9, 0xeb75a4f6, 0xe67eaaff, 0xf163b8e4, 0xfc68b6ed, 0x67b10c0a, 0x6aba0203, 0x7da71018, 0x70ac1e11, 0x539d342e, 0x5e963a27, 0x498b283c, 0x44802635, 0x0fe97c42, 0x02e2724b, 0x15ff6050, 0x18f46e59, 0x3bc54466, 0x36ce4a6f, 0x21d35874, 0x2cd8567d, 0x0c7a37a1, 0x017139a8, 0x166c2bb3, 0x1b6725ba, 0x38560f85, 0x355d018c, 0x22401397, 0x2f4b1d9e, 0x642247e9, 0x692949e0, 0x7e345bfb, 0x733f55f2, 0x500e7fcd, 0x5d0571c4, 0x4a1863df, 0x47136dd6, 0xdccad731, 0xd1c1d938, 0xc6dccb23, 0xcbd7c52a, 0xe8e6ef15, 0xe5ede11c, 0xf2f0f307, 0xfffbfd0e, 0xb492a779, 0xb999a970, 0xae84bb6b, 0xa38fb562, 0x80be9f5d, 0x8db59154, 0x9aa8834f, 0x97a38d46]; - var U4 = [0x00000000, 0x090d0b0e, 0x121a161c, 0x1b171d12, 0x24342c38, 0x2d392736, 0x362e3a24, 0x3f23312a, 0x48685870, 0x4165537e, 0x5a724e6c, 0x537f4562, 0x6c5c7448, 0x65517f46, 0x7e466254, 0x774b695a, 0x90d0b0e0, 0x99ddbbee, 0x82caa6fc, 0x8bc7adf2, 0xb4e49cd8, 0xbde997d6, 0xa6fe8ac4, 0xaff381ca, 0xd8b8e890, 0xd1b5e39e, 0xcaa2fe8c, 0xc3aff582, 0xfc8cc4a8, 0xf581cfa6, 0xee96d2b4, 0xe79bd9ba, 0x3bbb7bdb, 0x32b670d5, 0x29a16dc7, 0x20ac66c9, 0x1f8f57e3, 0x16825ced, 0x0d9541ff, 0x04984af1, 0x73d323ab, 0x7ade28a5, 0x61c935b7, 0x68c43eb9, 0x57e70f93, 0x5eea049d, 0x45fd198f, 0x4cf01281, 0xab6bcb3b, 0xa266c035, 0xb971dd27, 0xb07cd629, 0x8f5fe703, 0x8652ec0d, 0x9d45f11f, 0x9448fa11, 0xe303934b, 0xea0e9845, 0xf1198557, 0xf8148e59, 0xc737bf73, 0xce3ab47d, 0xd52da96f, 0xdc20a261, 0x766df6ad, 0x7f60fda3, 0x6477e0b1, 0x6d7aebbf, 0x5259da95, 0x5b54d19b, 0x4043cc89, 0x494ec787, 0x3e05aedd, 0x3708a5d3, 0x2c1fb8c1, 0x2512b3cf, 0x1a3182e5, 0x133c89eb, 0x082b94f9, 0x01269ff7, 0xe6bd464d, 0xefb04d43, 0xf4a75051, 0xfdaa5b5f, 0xc2896a75, 0xcb84617b, 0xd0937c69, 0xd99e7767, 0xaed51e3d, 0xa7d81533, 0xbccf0821, 0xb5c2032f, 0x8ae13205, 0x83ec390b, 0x98fb2419, 0x91f62f17, 0x4dd68d76, 0x44db8678, 0x5fcc9b6a, 0x56c19064, 0x69e2a14e, 0x60efaa40, 0x7bf8b752, 0x72f5bc5c, 0x05bed506, 0x0cb3de08, 0x17a4c31a, 0x1ea9c814, 0x218af93e, 0x2887f230, 0x3390ef22, 0x3a9de42c, 0xdd063d96, 0xd40b3698, 0xcf1c2b8a, 0xc6112084, 0xf93211ae, 0xf03f1aa0, 0xeb2807b2, 0xe2250cbc, 0x956e65e6, 0x9c636ee8, 0x877473fa, 0x8e7978f4, 0xb15a49de, 0xb85742d0, 0xa3405fc2, 0xaa4d54cc, 0xecdaf741, 0xe5d7fc4f, 0xfec0e15d, 0xf7cdea53, 0xc8eedb79, 0xc1e3d077, 0xdaf4cd65, 0xd3f9c66b, 0xa4b2af31, 0xadbfa43f, 0xb6a8b92d, 0xbfa5b223, 0x80868309, 0x898b8807, 0x929c9515, 0x9b919e1b, 0x7c0a47a1, 0x75074caf, 0x6e1051bd, 0x671d5ab3, 0x583e6b99, 0x51336097, 0x4a247d85, 0x4329768b, 0x34621fd1, 0x3d6f14df, 0x267809cd, 0x2f7502c3, 0x105633e9, 0x195b38e7, 0x024c25f5, 0x0b412efb, 0xd7618c9a, 0xde6c8794, 0xc57b9a86, 0xcc769188, 0xf355a0a2, 0xfa58abac, 0xe14fb6be, 0xe842bdb0, 0x9f09d4ea, 0x9604dfe4, 0x8d13c2f6, 0x841ec9f8, 0xbb3df8d2, 0xb230f3dc, 0xa927eece, 0xa02ae5c0, 0x47b13c7a, 0x4ebc3774, 0x55ab2a66, 0x5ca62168, 0x63851042, 0x6a881b4c, 0x719f065e, 0x78920d50, 0x0fd9640a, 0x06d46f04, 0x1dc37216, 0x14ce7918, 0x2bed4832, 0x22e0433c, 0x39f75e2e, 0x30fa5520, 0x9ab701ec, 0x93ba0ae2, 0x88ad17f0, 0x81a01cfe, 0xbe832dd4, 0xb78e26da, 0xac993bc8, 0xa59430c6, 0xd2df599c, 0xdbd25292, 0xc0c54f80, 0xc9c8448e, 0xf6eb75a4, 0xffe67eaa, 0xe4f163b8, 0xedfc68b6, 0x0a67b10c, 0x036aba02, 0x187da710, 0x1170ac1e, 0x2e539d34, 0x275e963a, 0x3c498b28, 0x35448026, 0x420fe97c, 0x4b02e272, 0x5015ff60, 0x5918f46e, 0x663bc544, 0x6f36ce4a, 0x7421d358, 0x7d2cd856, 0xa10c7a37, 0xa8017139, 0xb3166c2b, 0xba1b6725, 0x8538560f, 0x8c355d01, 0x97224013, 0x9e2f4b1d, 0xe9642247, 0xe0692949, 0xfb7e345b, 0xf2733f55, 0xcd500e7f, 0xc45d0571, 0xdf4a1863, 0xd647136d, 0x31dccad7, 0x38d1c1d9, 0x23c6dccb, 0x2acbd7c5, 0x15e8e6ef, 0x1ce5ede1, 0x07f2f0f3, 0x0efffbfd, 0x79b492a7, 0x70b999a9, 0x6bae84bb, 0x62a38fb5, 0x5d80be9f, 0x548db591, 0x4f9aa883, 0x4697a38d]; - - function convertToInt32(bytes) { - var result = []; - for (var i = 0; i < bytes.length; i += 4) { - result.push( - (bytes[i ] << 24) | - (bytes[i + 1] << 16) | - (bytes[i + 2] << 8) | - bytes[i + 3] - ); - } - return result; - } - - var AES = function(key) { - if (!(this instanceof AES)) { - throw Error('AES must be instanitated with `new`'); - } - - Object.defineProperty(this, 'key', { - value: coerceArray(key, true) - }); - - this._prepare(); - } - - - AES.prototype._prepare = function() { - - var rounds = numberOfRounds[this.key.length]; - if (rounds == null) { - throw new Error('invalid key size (must be 16, 24 or 32 bytes)'); - } - - // encryption round keys - this._Ke = []; - - // decryption round keys - this._Kd = []; - - for (var i = 0; i <= rounds; i++) { - this._Ke.push([0, 0, 0, 0]); - this._Kd.push([0, 0, 0, 0]); - } - - var roundKeyCount = (rounds + 1) * 4; - var KC = this.key.length / 4; - - // convert the key into ints - var tk = convertToInt32(this.key); - - // copy values into round key arrays - var index; - for (var i = 0; i < KC; i++) { - index = i >> 2; - this._Ke[index][i % 4] = tk[i]; - this._Kd[rounds - index][i % 4] = tk[i]; - } - - // key expansion (fips-197 section 5.2) - var rconpointer = 0; - var t = KC, tt; - while (t < roundKeyCount) { - tt = tk[KC - 1]; - tk[0] ^= ((S[(tt >> 16) & 0xFF] << 24) ^ - (S[(tt >> 8) & 0xFF] << 16) ^ - (S[ tt & 0xFF] << 8) ^ - S[(tt >> 24) & 0xFF] ^ - (rcon[rconpointer] << 24)); - rconpointer += 1; - - // key expansion (for non-256 bit) - if (KC != 8) { - for (var i = 1; i < KC; i++) { - tk[i] ^= tk[i - 1]; - } - - // key expansion for 256-bit keys is "slightly different" (fips-197) - } else { - for (var i = 1; i < (KC / 2); i++) { - tk[i] ^= tk[i - 1]; - } - tt = tk[(KC / 2) - 1]; - - tk[KC / 2] ^= (S[ tt & 0xFF] ^ - (S[(tt >> 8) & 0xFF] << 8) ^ - (S[(tt >> 16) & 0xFF] << 16) ^ - (S[(tt >> 24) & 0xFF] << 24)); - - for (var i = (KC / 2) + 1; i < KC; i++) { - tk[i] ^= tk[i - 1]; - } - } - - // copy values into round key arrays - var i = 0, r, c; - while (i < KC && t < roundKeyCount) { - r = t >> 2; - c = t % 4; - this._Ke[r][c] = tk[i]; - this._Kd[rounds - r][c] = tk[i++]; - t++; - } - } - - // inverse-cipher-ify the decryption round key (fips-197 section 5.3) - for (var r = 1; r < rounds; r++) { - for (var c = 0; c < 4; c++) { - tt = this._Kd[r][c]; - this._Kd[r][c] = (U1[(tt >> 24) & 0xFF] ^ - U2[(tt >> 16) & 0xFF] ^ - U3[(tt >> 8) & 0xFF] ^ - U4[ tt & 0xFF]); - } - } - } - - AES.prototype.encrypt = function(plaintext) { - if (plaintext.length != 16) { - throw new Error('invalid plaintext size (must be 16 bytes)'); - } - - var rounds = this._Ke.length - 1; - var a = [0, 0, 0, 0]; - - // convert plaintext to (ints ^ key) - var t = convertToInt32(plaintext); - for (var i = 0; i < 4; i++) { - t[i] ^= this._Ke[0][i]; - } - - // apply round transforms - for (var r = 1; r < rounds; r++) { - for (var i = 0; i < 4; i++) { - a[i] = (T1[(t[ i ] >> 24) & 0xff] ^ - T2[(t[(i + 1) % 4] >> 16) & 0xff] ^ - T3[(t[(i + 2) % 4] >> 8) & 0xff] ^ - T4[ t[(i + 3) % 4] & 0xff] ^ - this._Ke[r][i]); - } - t = a.slice(); - } - - // the last round is special - var result = createArray(16), tt; - for (var i = 0; i < 4; i++) { - tt = this._Ke[rounds][i]; - result[4 * i ] = (S[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; - result[4 * i + 1] = (S[(t[(i + 1) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; - result[4 * i + 2] = (S[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; - result[4 * i + 3] = (S[ t[(i + 3) % 4] & 0xff] ^ tt ) & 0xff; - } - - return result; - } - - AES.prototype.decrypt = function(ciphertext) { - if (ciphertext.length != 16) { - throw new Error('invalid ciphertext size (must be 16 bytes)'); - } - - var rounds = this._Kd.length - 1; - var a = [0, 0, 0, 0]; - - // convert plaintext to (ints ^ key) - var t = convertToInt32(ciphertext); - for (var i = 0; i < 4; i++) { - t[i] ^= this._Kd[0][i]; - } - - // apply round transforms - for (var r = 1; r < rounds; r++) { - for (var i = 0; i < 4; i++) { - a[i] = (T5[(t[ i ] >> 24) & 0xff] ^ - T6[(t[(i + 3) % 4] >> 16) & 0xff] ^ - T7[(t[(i + 2) % 4] >> 8) & 0xff] ^ - T8[ t[(i + 1) % 4] & 0xff] ^ - this._Kd[r][i]); - } - t = a.slice(); - } - - // the last round is special - var result = createArray(16), tt; - for (var i = 0; i < 4; i++) { - tt = this._Kd[rounds][i]; - result[4 * i ] = (Si[(t[ i ] >> 24) & 0xff] ^ (tt >> 24)) & 0xff; - result[4 * i + 1] = (Si[(t[(i + 3) % 4] >> 16) & 0xff] ^ (tt >> 16)) & 0xff; - result[4 * i + 2] = (Si[(t[(i + 2) % 4] >> 8) & 0xff] ^ (tt >> 8)) & 0xff; - result[4 * i + 3] = (Si[ t[(i + 1) % 4] & 0xff] ^ tt ) & 0xff; - } - - return result; - } - - - /** - * Mode Of Operation - Electonic Codebook (ECB) - */ - var ModeOfOperationECB = function(key) { - if (!(this instanceof ModeOfOperationECB)) { - throw Error('AES must be instanitated with `new`'); - } - - this.description = "Electronic Code Block"; - this.name = "ecb"; - - this._aes = new AES(key); - } - - ModeOfOperationECB.prototype.encrypt = function(plaintext) { - plaintext = coerceArray(plaintext); - - if ((plaintext.length % 16) !== 0) { - throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); - } - - var ciphertext = createArray(plaintext.length); - var block = createArray(16); - - for (var i = 0; i < plaintext.length; i += 16) { - copyArray(plaintext, block, 0, i, i + 16); - block = this._aes.encrypt(block); - copyArray(block, ciphertext, i); - } - - return ciphertext; - } - - ModeOfOperationECB.prototype.decrypt = function(ciphertext) { - ciphertext = coerceArray(ciphertext); - - if ((ciphertext.length % 16) !== 0) { - throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); - } - - var plaintext = createArray(ciphertext.length); - var block = createArray(16); - - for (var i = 0; i < ciphertext.length; i += 16) { - copyArray(ciphertext, block, 0, i, i + 16); - block = this._aes.decrypt(block); - copyArray(block, plaintext, i); - } - - return plaintext; - } - - - /** - * Mode Of Operation - Cipher Block Chaining (CBC) - */ - var ModeOfOperationCBC = function(key, iv) { - if (!(this instanceof ModeOfOperationCBC)) { - throw Error('AES must be instanitated with `new`'); - } - - this.description = "Cipher Block Chaining"; - this.name = "cbc"; - - if (!iv) { - iv = createArray(16); - - } else if (iv.length != 16) { - throw new Error('invalid initialation vector size (must be 16 bytes)'); - } - - this._lastCipherblock = coerceArray(iv, true); - - this._aes = new AES(key); - } - - ModeOfOperationCBC.prototype.encrypt = function(plaintext) { - plaintext = coerceArray(plaintext); - - if ((plaintext.length % 16) !== 0) { - throw new Error('invalid plaintext size (must be multiple of 16 bytes)'); - } - - var ciphertext = createArray(plaintext.length); - var block = createArray(16); - - for (var i = 0; i < plaintext.length; i += 16) { - copyArray(plaintext, block, 0, i, i + 16); - - for (var j = 0; j < 16; j++) { - block[j] ^= this._lastCipherblock[j]; - } - - this._lastCipherblock = this._aes.encrypt(block); - copyArray(this._lastCipherblock, ciphertext, i); - } - - return ciphertext; - } - - ModeOfOperationCBC.prototype.decrypt = function(ciphertext) { - ciphertext = coerceArray(ciphertext); - - if ((ciphertext.length % 16) !== 0) { - throw new Error('invalid ciphertext size (must be multiple of 16 bytes)'); - } - - var plaintext = createArray(ciphertext.length); - var block = createArray(16); - - for (var i = 0; i < ciphertext.length; i += 16) { - copyArray(ciphertext, block, 0, i, i + 16); - block = this._aes.decrypt(block); - - for (var j = 0; j < 16; j++) { - plaintext[i + j] = block[j] ^ this._lastCipherblock[j]; - } - - copyArray(ciphertext, this._lastCipherblock, 0, i, i + 16); - } - - return plaintext; - } - - - /** - * Mode Of Operation - Cipher Feedback (CFB) - */ - var ModeOfOperationCFB = function(key, iv, segmentSize) { - if (!(this instanceof ModeOfOperationCFB)) { - throw Error('AES must be instanitated with `new`'); - } - - this.description = "Cipher Feedback"; - this.name = "cfb"; - - if (!iv) { - iv = createArray(16); - - } else if (iv.length != 16) { - throw new Error('invalid initialation vector size (must be 16 size)'); - } - - if (!segmentSize) { segmentSize = 1; } - - this.segmentSize = segmentSize; - - this._shiftRegister = coerceArray(iv, true); - - this._aes = new AES(key); - } - - ModeOfOperationCFB.prototype.encrypt = function(plaintext) { - if ((plaintext.length % this.segmentSize) != 0) { - throw new Error('invalid plaintext size (must be segmentSize bytes)'); - } - - var encrypted = coerceArray(plaintext, true); - - var xorSegment; - for (var i = 0; i < encrypted.length; i += this.segmentSize) { - xorSegment = this._aes.encrypt(this._shiftRegister); - for (var j = 0; j < this.segmentSize; j++) { - encrypted[i + j] ^= xorSegment[j]; - } - - // Shift the register - copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); - copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); - } - - return encrypted; - } - - ModeOfOperationCFB.prototype.decrypt = function(ciphertext) { - if ((ciphertext.length % this.segmentSize) != 0) { - throw new Error('invalid ciphertext size (must be segmentSize bytes)'); - } - - var plaintext = coerceArray(ciphertext, true); - - var xorSegment; - for (var i = 0; i < plaintext.length; i += this.segmentSize) { - xorSegment = this._aes.encrypt(this._shiftRegister); - - for (var j = 0; j < this.segmentSize; j++) { - plaintext[i + j] ^= xorSegment[j]; - } - - // Shift the register - copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize); - copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i, i + this.segmentSize); - } - - return plaintext; - } - - /** - * Mode Of Operation - Output Feedback (OFB) - */ - var ModeOfOperationOFB = function(key, iv) { - if (!(this instanceof ModeOfOperationOFB)) { - throw Error('AES must be instanitated with `new`'); - } - - this.description = "Output Feedback"; - this.name = "ofb"; - - if (!iv) { - iv = createArray(16); - - } else if (iv.length != 16) { - throw new Error('invalid initialation vector size (must be 16 bytes)'); - } - - this._lastPrecipher = coerceArray(iv, true); - this._lastPrecipherIndex = 16; - - this._aes = new AES(key); - } - - ModeOfOperationOFB.prototype.encrypt = function(plaintext) { - var encrypted = coerceArray(plaintext, true); - - for (var i = 0; i < encrypted.length; i++) { - if (this._lastPrecipherIndex === 16) { - this._lastPrecipher = this._aes.encrypt(this._lastPrecipher); - this._lastPrecipherIndex = 0; - } - encrypted[i] ^= this._lastPrecipher[this._lastPrecipherIndex++]; - } - - return encrypted; - } - - // Decryption is symetric - ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt; - - - /** - * Counter object for CTR common mode of operation - */ - var Counter = function(initialValue) { - if (!(this instanceof Counter)) { - throw Error('Counter must be instanitated with `new`'); - } - - // We allow 0, but anything false-ish uses the default 1 - if (initialValue !== 0 && !initialValue) { initialValue = 1; } - - if (typeof(initialValue) === 'number') { - this._counter = createArray(16); - this.setValue(initialValue); - - } else { - this.setBytes(initialValue); - } - } - - Counter.prototype.setValue = function(value) { - if (typeof(value) !== 'number' || parseInt(value) != value) { - throw new Error('invalid counter value (must be an integer)'); - } - - for (var index = 15; index >= 0; --index) { - this._counter[index] = value % 256; - value = value >> 8; - } - } - - Counter.prototype.setBytes = function(bytes) { - bytes = coerceArray(bytes, true); - - if (bytes.length != 16) { - throw new Error('invalid counter bytes size (must be 16 bytes)'); - } - - this._counter = bytes; - }; - - Counter.prototype.increment = function() { - for (var i = 15; i >= 0; i--) { - if (this._counter[i] === 255) { - this._counter[i] = 0; - } else { - this._counter[i]++; - break; - } - } - } - - - /** - * Mode Of Operation - Counter (CTR) - */ - var ModeOfOperationCTR = function(key, counter) { - if (!(this instanceof ModeOfOperationCTR)) { - throw Error('AES must be instanitated with `new`'); - } - - this.description = "Counter"; - this.name = "ctr"; - - if (!(counter instanceof Counter)) { - counter = new Counter(counter) - } - - this._counter = counter; - - this._remainingCounter = null; - this._remainingCounterIndex = 16; - - this._aes = new AES(key); - } - - ModeOfOperationCTR.prototype.encrypt = function(plaintext) { - var encrypted = coerceArray(plaintext, true); - - for (var i = 0; i < encrypted.length; i++) { - if (this._remainingCounterIndex === 16) { - this._remainingCounter = this._aes.encrypt(this._counter._counter); - this._remainingCounterIndex = 0; - this._counter.increment(); - } - encrypted[i] ^= this._remainingCounter[this._remainingCounterIndex++]; - } - - return encrypted; - } - - // Decryption is symetric - ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt; - - - /////////////////////// - // Padding - - // See:https://tools.ietf.org/html/rfc2315 - function pkcs7pad(data) { - data = coerceArray(data, true); - var padder = 16 - (data.length % 16); - var result = createArray(data.length + padder); - copyArray(data, result); - for (var i = data.length; i < result.length; i++) { - result[i] = padder; - } - return result; - } - - function pkcs7strip(data) { - data = coerceArray(data, true); - if (data.length < 16) { throw new Error('PKCS#7 invalid length'); } - - var padder = data[data.length - 1]; - if (padder > 16) { throw new Error('PKCS#7 padding byte out of range'); } - - var length = data.length - padder; - for (var i = 0; i < padder; i++) { - if (data[length + i] !== padder) { - throw new Error('PKCS#7 invalid padding byte'); - } - } - - var result = createArray(length); - copyArray(data, result, 0, 0, length); - return result; - } - - /////////////////////// - // Exporting - - - // The block cipher - var aesjs = { - AES: AES, - Counter: Counter, - - ModeOfOperation: { - ecb: ModeOfOperationECB, - cbc: ModeOfOperationCBC, - cfb: ModeOfOperationCFB, - ofb: ModeOfOperationOFB, - ctr: ModeOfOperationCTR - }, - - utils: { - hex: convertHex, - utf8: convertUtf8 - }, - - padding: { - pkcs7: { - pad: pkcs7pad, - strip: pkcs7strip - } - }, - - _arrayTest: { - coerceArray: coerceArray, - createArray: createArray, - copyArray: copyArray, - } - }; - - - // node.js - if (typeof exports !== 'undefined') { - module.exports = aesjs - - // RequireJS/AMD - // http://www.requirejs.org/docs/api.html - // https://github.com/amdjs/amdjs-api/wiki/AMD - } else if (typeof(define) === 'function' && define.amd) { - define(aesjs); - - // Web Browsers - } else { - - // If there was an existing library at "aesjs" make sure it's still available - if (root.aesjs) { - aesjs._aesjs = root.aesjs; - } - - root.aesjs = aesjs; - } - - -})(this); - -},{}],2:[function(require,module,exports){ -(function (module, exports) { - 'use strict'; - - // Utils - function assert (val, msg) { - if (!val) throw new Error(msg || 'Assertion failed'); - } - - // Could use `inherits` module, but don't want to move from single file - // architecture yet. - function inherits (ctor, superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - - // BN - - function BN (number, base, endian) { - if (BN.isBN(number)) { - return number; - } - - this.negative = 0; - this.words = null; - this.length = 0; - - // Reduction context - this.red = null; - - if (number !== null) { - if (base === 'le' || base === 'be') { - endian = base; - base = 10; - } - - this._init(number || 0, base || 10, endian || 'be'); - } - } - if (typeof module === 'object') { - module.exports = BN; - } else { - exports.BN = BN; - } - - BN.BN = BN; - BN.wordSize = 26; - - var Buffer; - try { - Buffer = require('buffer').Buffer; - } catch (e) { - } - - BN.isBN = function isBN (num) { - if (num instanceof BN) { - return true; - } - - return num !== null && typeof num === 'object' && - num.constructor.wordSize === BN.wordSize && Array.isArray(num.words); - }; - - BN.max = function max (left, right) { - if (left.cmp(right) > 0) return left; - return right; - }; - - BN.min = function min (left, right) { - if (left.cmp(right) < 0) return left; - return right; - }; - - BN.prototype._init = function init (number, base, endian) { - if (typeof number === 'number') { - return this._initNumber(number, base, endian); - } - - if (typeof number === 'object') { - return this._initArray(number, base, endian); - } - - if (base === 'hex') { - base = 16; - } - assert(base === (base | 0) && base >= 2 && base <= 36); - - number = number.toString().replace(/\s+/g, ''); - var start = 0; - if (number[0] === '-') { - start++; - } - - if (base === 16) { - this._parseHex(number, start); - } else { - this._parseBase(number, base, start); - } - - if (number[0] === '-') { - this.negative = 1; - } - - this.strip(); - - if (endian !== 'le') return; - - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initNumber = function _initNumber (number, base, endian) { - if (number < 0) { - this.negative = 1; - number = -number; - } - if (number < 0x4000000) { - this.words = [ number & 0x3ffffff ]; - this.length = 1; - } else if (number < 0x10000000000000) { - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff - ]; - this.length = 2; - } else { - assert(number < 0x20000000000000); // 2 ^ 53 (unsafe) - this.words = [ - number & 0x3ffffff, - (number / 0x4000000) & 0x3ffffff, - 1 - ]; - this.length = 3; - } - - if (endian !== 'le') return; - - // Reverse the bytes - this._initArray(this.toArray(), base, endian); - }; - - BN.prototype._initArray = function _initArray (number, base, endian) { - // Perhaps a Uint8Array - assert(typeof number.length === 'number'); - if (number.length <= 0) { - this.words = [ 0 ]; - this.length = 1; - return this; - } - - this.length = Math.ceil(number.length / 3); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - var off = 0; - if (endian === 'be') { - for (i = number.length - 1, j = 0; i >= 0; i -= 3) { - w = number[i] | (number[i - 1] << 8) | (number[i - 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } else if (endian === 'le') { - for (i = 0, j = 0; i < number.length; i += 3) { - w = number[i] | (number[i + 1] << 8) | (number[i + 2] << 16); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] = (w >>> (26 - off)) & 0x3ffffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - } - return this.strip(); - }; - - function parseHex (str, start, end) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r <<= 4; - - // 'a' - 'f' - if (c >= 49 && c <= 54) { - r |= c - 49 + 0xa; - - // 'A' - 'F' - } else if (c >= 17 && c <= 22) { - r |= c - 17 + 0xa; - - // '0' - '9' - } else { - r |= c & 0xf; - } - } - return r; - } - - BN.prototype._parseHex = function _parseHex (number, start) { - // Create possibly bigger array to ensure that it fits the number - this.length = Math.ceil((number.length - start) / 6); - this.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - this.words[i] = 0; - } - - var j, w; - // Scan 24-bit chunks and add them to the number - var off = 0; - for (i = number.length - 6, j = 0; i >= start; i -= 6) { - w = parseHex(number, i, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - // NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - off += 24; - if (off >= 26) { - off -= 26; - j++; - } - } - if (i + 6 !== start) { - w = parseHex(number, start, i + 6); - this.words[j] |= (w << off) & 0x3ffffff; - this.words[j + 1] |= w >>> (26 - off) & 0x3fffff; - } - this.strip(); - }; - - function parseBase (str, start, end, mul) { - var r = 0; - var len = Math.min(str.length, end); - for (var i = start; i < len; i++) { - var c = str.charCodeAt(i) - 48; - - r *= mul; - - // 'a' - if (c >= 49) { - r += c - 49 + 0xa; - - // 'A' - } else if (c >= 17) { - r += c - 17 + 0xa; - - // '0' - '9' - } else { - r += c; - } - } - return r; - } - - BN.prototype._parseBase = function _parseBase (number, base, start) { - // Initialize as zero - this.words = [ 0 ]; - this.length = 1; - - // Find length of limb in base - for (var limbLen = 0, limbPow = 1; limbPow <= 0x3ffffff; limbPow *= base) { - limbLen++; - } - limbLen--; - limbPow = (limbPow / base) | 0; - - var total = number.length - start; - var mod = total % limbLen; - var end = Math.min(total, total - mod) + start; - - var word = 0; - for (var i = start; i < end; i += limbLen) { - word = parseBase(number, i, i + limbLen, base); - - this.imuln(limbPow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - - if (mod !== 0) { - var pow = 1; - word = parseBase(number, i, number.length, base); - - for (i = 0; i < mod; i++) { - pow *= base; - } - - this.imuln(pow); - if (this.words[0] + word < 0x4000000) { - this.words[0] += word; - } else { - this._iaddn(word); - } - } - }; - - BN.prototype.copy = function copy (dest) { - dest.words = new Array(this.length); - for (var i = 0; i < this.length; i++) { - dest.words[i] = this.words[i]; - } - dest.length = this.length; - dest.negative = this.negative; - dest.red = this.red; - }; - - BN.prototype.clone = function clone () { - var r = new BN(null); - this.copy(r); - return r; - }; - - BN.prototype._expand = function _expand (size) { - while (this.length < size) { - this.words[this.length++] = 0; - } - return this; - }; - - // Remove leading `0` from `this` - BN.prototype.strip = function strip () { - while (this.length > 1 && this.words[this.length - 1] === 0) { - this.length--; - } - return this._normSign(); - }; - - BN.prototype._normSign = function _normSign () { - // -0 = 0 - if (this.length === 1 && this.words[0] === 0) { - this.negative = 0; - } - return this; - }; - - BN.prototype.inspect = function inspect () { - return (this.red ? ''; - }; - - /* - - var zeros = []; - var groupSizes = []; - var groupBases = []; - - var s = ''; - var i = -1; - while (++i < BN.wordSize) { - zeros[i] = s; - s += '0'; - } - groupSizes[0] = 0; - groupSizes[1] = 0; - groupBases[0] = 0; - groupBases[1] = 0; - var base = 2 - 1; - while (++base < 36 + 1) { - var groupSize = 0; - var groupBase = 1; - while (groupBase < (1 << BN.wordSize) / base) { - groupBase *= base; - groupSize += 1; - } - groupSizes[base] = groupSize; - groupBases[base] = groupBase; - } - - */ - - var zeros = [ - '', - '0', - '00', - '000', - '0000', - '00000', - '000000', - '0000000', - '00000000', - '000000000', - '0000000000', - '00000000000', - '000000000000', - '0000000000000', - '00000000000000', - '000000000000000', - '0000000000000000', - '00000000000000000', - '000000000000000000', - '0000000000000000000', - '00000000000000000000', - '000000000000000000000', - '0000000000000000000000', - '00000000000000000000000', - '000000000000000000000000', - '0000000000000000000000000' - ]; - - var groupSizes = [ - 0, 0, - 25, 16, 12, 11, 10, 9, 8, - 8, 7, 7, 7, 7, 6, 6, - 6, 6, 6, 6, 6, 5, 5, - 5, 5, 5, 5, 5, 5, 5, - 5, 5, 5, 5, 5, 5, 5 - ]; - - var groupBases = [ - 0, 0, - 33554432, 43046721, 16777216, 48828125, 60466176, 40353607, 16777216, - 43046721, 10000000, 19487171, 35831808, 62748517, 7529536, 11390625, - 16777216, 24137569, 34012224, 47045881, 64000000, 4084101, 5153632, - 6436343, 7962624, 9765625, 11881376, 14348907, 17210368, 20511149, - 24300000, 28629151, 33554432, 39135393, 45435424, 52521875, 60466176 - ]; - - BN.prototype.toString = function toString (base, padding) { - base = base || 10; - padding = padding | 0 || 1; - - var out; - if (base === 16 || base === 'hex') { - out = ''; - var off = 0; - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = this.words[i]; - var word = (((w << off) | carry) & 0xffffff).toString(16); - carry = (w >>> (24 - off)) & 0xffffff; - if (carry !== 0 || i !== this.length - 1) { - out = zeros[6 - word.length] + word + out; - } else { - out = word + out; - } - off += 2; - if (off >= 26) { - off -= 26; - i--; - } - } - if (carry !== 0) { - out = carry.toString(16) + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - if (base === (base | 0) && base >= 2 && base <= 36) { - // var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base)); - var groupSize = groupSizes[base]; - // var groupBase = Math.pow(base, groupSize); - var groupBase = groupBases[base]; - out = ''; - var c = this.clone(); - c.negative = 0; - while (!c.isZero()) { - var r = c.modn(groupBase).toString(base); - c = c.idivn(groupBase); - - if (!c.isZero()) { - out = zeros[groupSize - r.length] + r + out; - } else { - out = r + out; - } - } - if (this.isZero()) { - out = '0' + out; - } - while (out.length % padding !== 0) { - out = '0' + out; - } - if (this.negative !== 0) { - out = '-' + out; - } - return out; - } - - assert(false, 'Base should be between 2 and 36'); - }; - - BN.prototype.toNumber = function toNumber () { - var ret = this.words[0]; - if (this.length === 2) { - ret += this.words[1] * 0x4000000; - } else if (this.length === 3 && this.words[2] === 0x01) { - // NOTE: at this stage it is known that the top bit is set - ret += 0x10000000000000 + (this.words[1] * 0x4000000); - } else if (this.length > 2) { - assert(false, 'Number can only safely store up to 53 bits'); - } - return (this.negative !== 0) ? -ret : ret; - }; - - BN.prototype.toJSON = function toJSON () { - return this.toString(16); - }; - - BN.prototype.toBuffer = function toBuffer (endian, length) { - assert(typeof Buffer !== 'undefined'); - return this.toArrayLike(Buffer, endian, length); - }; - - BN.prototype.toArray = function toArray (endian, length) { - return this.toArrayLike(Array, endian, length); - }; - - BN.prototype.toArrayLike = function toArrayLike (ArrayType, endian, length) { - var byteLength = this.byteLength(); - var reqLength = length || Math.max(1, byteLength); - assert(byteLength <= reqLength, 'byte array longer than desired length'); - assert(reqLength > 0, 'Requested array length <= 0'); - - this.strip(); - var littleEndian = endian === 'le'; - var res = new ArrayType(reqLength); - - var b, i; - var q = this.clone(); - if (!littleEndian) { - // Assume big-endian - for (i = 0; i < reqLength - byteLength; i++) { - res[i] = 0; - } - - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[reqLength - i - 1] = b; - } - } else { - for (i = 0; !q.isZero(); i++) { - b = q.andln(0xff); - q.iushrn(8); - - res[i] = b; - } - - for (; i < reqLength; i++) { - res[i] = 0; - } - } - - return res; - }; - - if (Math.clz32) { - BN.prototype._countBits = function _countBits (w) { - return 32 - Math.clz32(w); - }; - } else { - BN.prototype._countBits = function _countBits (w) { - var t = w; - var r = 0; - if (t >= 0x1000) { - r += 13; - t >>>= 13; - } - if (t >= 0x40) { - r += 7; - t >>>= 7; - } - if (t >= 0x8) { - r += 4; - t >>>= 4; - } - if (t >= 0x02) { - r += 2; - t >>>= 2; - } - return r + t; - }; - } - - BN.prototype._zeroBits = function _zeroBits (w) { - // Short-cut - if (w === 0) return 26; - - var t = w; - var r = 0; - if ((t & 0x1fff) === 0) { - r += 13; - t >>>= 13; - } - if ((t & 0x7f) === 0) { - r += 7; - t >>>= 7; - } - if ((t & 0xf) === 0) { - r += 4; - t >>>= 4; - } - if ((t & 0x3) === 0) { - r += 2; - t >>>= 2; - } - if ((t & 0x1) === 0) { - r++; - } - return r; - }; - - // Return number of used bits in a BN - BN.prototype.bitLength = function bitLength () { - var w = this.words[this.length - 1]; - var hi = this._countBits(w); - return (this.length - 1) * 26 + hi; - }; - - function toBitArray (num) { - var w = new Array(num.bitLength()); - - for (var bit = 0; bit < w.length; bit++) { - var off = (bit / 26) | 0; - var wbit = bit % 26; - - w[bit] = (num.words[off] & (1 << wbit)) >>> wbit; - } - - return w; - } - - // Number of trailing zero bits - BN.prototype.zeroBits = function zeroBits () { - if (this.isZero()) return 0; - - var r = 0; - for (var i = 0; i < this.length; i++) { - var b = this._zeroBits(this.words[i]); - r += b; - if (b !== 26) break; - } - return r; - }; - - BN.prototype.byteLength = function byteLength () { - return Math.ceil(this.bitLength() / 8); - }; - - BN.prototype.toTwos = function toTwos (width) { - if (this.negative !== 0) { - return this.abs().inotn(width).iaddn(1); - } - return this.clone(); - }; - - BN.prototype.fromTwos = function fromTwos (width) { - if (this.testn(width - 1)) { - return this.notn(width).iaddn(1).ineg(); - } - return this.clone(); - }; - - BN.prototype.isNeg = function isNeg () { - return this.negative !== 0; - }; - - // Return negative clone of `this` - BN.prototype.neg = function neg () { - return this.clone().ineg(); - }; - - BN.prototype.ineg = function ineg () { - if (!this.isZero()) { - this.negative ^= 1; - } - - return this; - }; - - // Or `num` with `this` in-place - BN.prototype.iuor = function iuor (num) { - while (this.length < num.length) { - this.words[this.length++] = 0; - } - - for (var i = 0; i < num.length; i++) { - this.words[i] = this.words[i] | num.words[i]; - } - - return this.strip(); - }; - - BN.prototype.ior = function ior (num) { - assert((this.negative | num.negative) === 0); - return this.iuor(num); - }; - - // Or `num` with `this` - BN.prototype.or = function or (num) { - if (this.length > num.length) return this.clone().ior(num); - return num.clone().ior(this); - }; - - BN.prototype.uor = function uor (num) { - if (this.length > num.length) return this.clone().iuor(num); - return num.clone().iuor(this); - }; - - // And `num` with `this` in-place - BN.prototype.iuand = function iuand (num) { - // b = min-length(num, this) - var b; - if (this.length > num.length) { - b = num; - } else { - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = this.words[i] & num.words[i]; - } - - this.length = b.length; - - return this.strip(); - }; - - BN.prototype.iand = function iand (num) { - assert((this.negative | num.negative) === 0); - return this.iuand(num); - }; - - // And `num` with `this` - BN.prototype.and = function and (num) { - if (this.length > num.length) return this.clone().iand(num); - return num.clone().iand(this); - }; - - BN.prototype.uand = function uand (num) { - if (this.length > num.length) return this.clone().iuand(num); - return num.clone().iuand(this); - }; - - // Xor `num` with `this` in-place - BN.prototype.iuxor = function iuxor (num) { - // a.length > b.length - var a; - var b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - for (var i = 0; i < b.length; i++) { - this.words[i] = a.words[i] ^ b.words[i]; - } - - if (this !== a) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = a.length; - - return this.strip(); - }; - - BN.prototype.ixor = function ixor (num) { - assert((this.negative | num.negative) === 0); - return this.iuxor(num); - }; - - // Xor `num` with `this` - BN.prototype.xor = function xor (num) { - if (this.length > num.length) return this.clone().ixor(num); - return num.clone().ixor(this); - }; - - BN.prototype.uxor = function uxor (num) { - if (this.length > num.length) return this.clone().iuxor(num); - return num.clone().iuxor(this); - }; - - // Not ``this`` with ``width`` bitwidth - BN.prototype.inotn = function inotn (width) { - assert(typeof width === 'number' && width >= 0); - - var bytesNeeded = Math.ceil(width / 26) | 0; - var bitsLeft = width % 26; - - // Extend the buffer with leading zeroes - this._expand(bytesNeeded); - - if (bitsLeft > 0) { - bytesNeeded--; - } - - // Handle complete words - for (var i = 0; i < bytesNeeded; i++) { - this.words[i] = ~this.words[i] & 0x3ffffff; - } - - // Handle the residue - if (bitsLeft > 0) { - this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft)); - } - - // And remove leading zeroes - return this.strip(); - }; - - BN.prototype.notn = function notn (width) { - return this.clone().inotn(width); - }; - - // Set `bit` of `this` - BN.prototype.setn = function setn (bit, val) { - assert(typeof bit === 'number' && bit >= 0); - - var off = (bit / 26) | 0; - var wbit = bit % 26; - - this._expand(off + 1); - - if (val) { - this.words[off] = this.words[off] | (1 << wbit); - } else { - this.words[off] = this.words[off] & ~(1 << wbit); - } - - return this.strip(); - }; - - // Add `num` to `this` in-place - BN.prototype.iadd = function iadd (num) { - var r; - - // negative + positive - if (this.negative !== 0 && num.negative === 0) { - this.negative = 0; - r = this.isub(num); - this.negative ^= 1; - return this._normSign(); - - // positive + negative - } else if (this.negative === 0 && num.negative !== 0) { - num.negative = 0; - r = this.isub(num); - num.negative = 1; - return r._normSign(); - } - - // a.length > b.length - var a, b; - if (this.length > num.length) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) + (b.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - this.words[i] = r & 0x3ffffff; - carry = r >>> 26; - } - - this.length = a.length; - if (carry !== 0) { - this.words[this.length] = carry; - this.length++; - // Copy the rest of the words - } else if (a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - return this; - }; - - // Add `num` to `this` - BN.prototype.add = function add (num) { - var res; - if (num.negative !== 0 && this.negative === 0) { - num.negative = 0; - res = this.sub(num); - num.negative ^= 1; - return res; - } else if (num.negative === 0 && this.negative !== 0) { - this.negative = 0; - res = num.sub(this); - this.negative = 1; - return res; - } - - if (this.length > num.length) return this.clone().iadd(num); - - return num.clone().iadd(this); - }; - - // Subtract `num` from `this` in-place - BN.prototype.isub = function isub (num) { - // this - (-num) = this + num - if (num.negative !== 0) { - num.negative = 0; - var r = this.iadd(num); - num.negative = 1; - return r._normSign(); - - // -this - num = -(this + num) - } else if (this.negative !== 0) { - this.negative = 0; - this.iadd(num); - this.negative = 1; - return this._normSign(); - } - - // At this point both numbers are positive - var cmp = this.cmp(num); - - // Optimization - zeroify - if (cmp === 0) { - this.negative = 0; - this.length = 1; - this.words[0] = 0; - return this; - } - - // a > b - var a, b; - if (cmp > 0) { - a = this; - b = num; - } else { - a = num; - b = this; - } - - var carry = 0; - for (var i = 0; i < b.length; i++) { - r = (a.words[i] | 0) - (b.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - for (; carry !== 0 && i < a.length; i++) { - r = (a.words[i] | 0) + carry; - carry = r >> 26; - this.words[i] = r & 0x3ffffff; - } - - // Copy rest of the words - if (carry === 0 && i < a.length && a !== this) { - for (; i < a.length; i++) { - this.words[i] = a.words[i]; - } - } - - this.length = Math.max(this.length, i); - - if (a !== this) { - this.negative = 1; - } - - return this.strip(); - }; - - // Subtract `num` from `this` - BN.prototype.sub = function sub (num) { - return this.clone().isub(num); - }; - - function smallMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - var len = (self.length + num.length) | 0; - out.length = len; - len = (len - 1) | 0; - - // Peel one iteration (compiler can't do it, because of code complexity) - var a = self.words[0] | 0; - var b = num.words[0] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - var carry = (r / 0x4000000) | 0; - out.words[0] = lo; - - for (var k = 1; k < len; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = carry >>> 26; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = (k - j) | 0; - a = self.words[i] | 0; - b = num.words[j] | 0; - r = a * b + rword; - ncarry += (r / 0x4000000) | 0; - rword = r & 0x3ffffff; - } - out.words[k] = rword | 0; - carry = ncarry | 0; - } - if (carry !== 0) { - out.words[k] = carry | 0; - } else { - out.length--; - } - - return out.strip(); - } - - // TODO(indutny): it may be reasonable to omit it for users who don't need - // to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit - // multiplication (like elliptic secp256k1). - var comb10MulTo = function comb10MulTo (self, num, out) { - var a = self.words; - var b = num.words; - var o = out.words; - var c = 0; - var lo; - var mid; - var hi; - var a0 = a[0] | 0; - var al0 = a0 & 0x1fff; - var ah0 = a0 >>> 13; - var a1 = a[1] | 0; - var al1 = a1 & 0x1fff; - var ah1 = a1 >>> 13; - var a2 = a[2] | 0; - var al2 = a2 & 0x1fff; - var ah2 = a2 >>> 13; - var a3 = a[3] | 0; - var al3 = a3 & 0x1fff; - var ah3 = a3 >>> 13; - var a4 = a[4] | 0; - var al4 = a4 & 0x1fff; - var ah4 = a4 >>> 13; - var a5 = a[5] | 0; - var al5 = a5 & 0x1fff; - var ah5 = a5 >>> 13; - var a6 = a[6] | 0; - var al6 = a6 & 0x1fff; - var ah6 = a6 >>> 13; - var a7 = a[7] | 0; - var al7 = a7 & 0x1fff; - var ah7 = a7 >>> 13; - var a8 = a[8] | 0; - var al8 = a8 & 0x1fff; - var ah8 = a8 >>> 13; - var a9 = a[9] | 0; - var al9 = a9 & 0x1fff; - var ah9 = a9 >>> 13; - var b0 = b[0] | 0; - var bl0 = b0 & 0x1fff; - var bh0 = b0 >>> 13; - var b1 = b[1] | 0; - var bl1 = b1 & 0x1fff; - var bh1 = b1 >>> 13; - var b2 = b[2] | 0; - var bl2 = b2 & 0x1fff; - var bh2 = b2 >>> 13; - var b3 = b[3] | 0; - var bl3 = b3 & 0x1fff; - var bh3 = b3 >>> 13; - var b4 = b[4] | 0; - var bl4 = b4 & 0x1fff; - var bh4 = b4 >>> 13; - var b5 = b[5] | 0; - var bl5 = b5 & 0x1fff; - var bh5 = b5 >>> 13; - var b6 = b[6] | 0; - var bl6 = b6 & 0x1fff; - var bh6 = b6 >>> 13; - var b7 = b[7] | 0; - var bl7 = b7 & 0x1fff; - var bh7 = b7 >>> 13; - var b8 = b[8] | 0; - var bl8 = b8 & 0x1fff; - var bh8 = b8 >>> 13; - var b9 = b[9] | 0; - var bl9 = b9 & 0x1fff; - var bh9 = b9 >>> 13; - - out.negative = self.negative ^ num.negative; - out.length = 19; - /* k = 0 */ - lo = Math.imul(al0, bl0); - mid = Math.imul(al0, bh0); - mid = (mid + Math.imul(ah0, bl0)) | 0; - hi = Math.imul(ah0, bh0); - var w0 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w0 >>> 26)) | 0; - w0 &= 0x3ffffff; - /* k = 1 */ - lo = Math.imul(al1, bl0); - mid = Math.imul(al1, bh0); - mid = (mid + Math.imul(ah1, bl0)) | 0; - hi = Math.imul(ah1, bh0); - lo = (lo + Math.imul(al0, bl1)) | 0; - mid = (mid + Math.imul(al0, bh1)) | 0; - mid = (mid + Math.imul(ah0, bl1)) | 0; - hi = (hi + Math.imul(ah0, bh1)) | 0; - var w1 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w1 >>> 26)) | 0; - w1 &= 0x3ffffff; - /* k = 2 */ - lo = Math.imul(al2, bl0); - mid = Math.imul(al2, bh0); - mid = (mid + Math.imul(ah2, bl0)) | 0; - hi = Math.imul(ah2, bh0); - lo = (lo + Math.imul(al1, bl1)) | 0; - mid = (mid + Math.imul(al1, bh1)) | 0; - mid = (mid + Math.imul(ah1, bl1)) | 0; - hi = (hi + Math.imul(ah1, bh1)) | 0; - lo = (lo + Math.imul(al0, bl2)) | 0; - mid = (mid + Math.imul(al0, bh2)) | 0; - mid = (mid + Math.imul(ah0, bl2)) | 0; - hi = (hi + Math.imul(ah0, bh2)) | 0; - var w2 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w2 >>> 26)) | 0; - w2 &= 0x3ffffff; - /* k = 3 */ - lo = Math.imul(al3, bl0); - mid = Math.imul(al3, bh0); - mid = (mid + Math.imul(ah3, bl0)) | 0; - hi = Math.imul(ah3, bh0); - lo = (lo + Math.imul(al2, bl1)) | 0; - mid = (mid + Math.imul(al2, bh1)) | 0; - mid = (mid + Math.imul(ah2, bl1)) | 0; - hi = (hi + Math.imul(ah2, bh1)) | 0; - lo = (lo + Math.imul(al1, bl2)) | 0; - mid = (mid + Math.imul(al1, bh2)) | 0; - mid = (mid + Math.imul(ah1, bl2)) | 0; - hi = (hi + Math.imul(ah1, bh2)) | 0; - lo = (lo + Math.imul(al0, bl3)) | 0; - mid = (mid + Math.imul(al0, bh3)) | 0; - mid = (mid + Math.imul(ah0, bl3)) | 0; - hi = (hi + Math.imul(ah0, bh3)) | 0; - var w3 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w3 >>> 26)) | 0; - w3 &= 0x3ffffff; - /* k = 4 */ - lo = Math.imul(al4, bl0); - mid = Math.imul(al4, bh0); - mid = (mid + Math.imul(ah4, bl0)) | 0; - hi = Math.imul(ah4, bh0); - lo = (lo + Math.imul(al3, bl1)) | 0; - mid = (mid + Math.imul(al3, bh1)) | 0; - mid = (mid + Math.imul(ah3, bl1)) | 0; - hi = (hi + Math.imul(ah3, bh1)) | 0; - lo = (lo + Math.imul(al2, bl2)) | 0; - mid = (mid + Math.imul(al2, bh2)) | 0; - mid = (mid + Math.imul(ah2, bl2)) | 0; - hi = (hi + Math.imul(ah2, bh2)) | 0; - lo = (lo + Math.imul(al1, bl3)) | 0; - mid = (mid + Math.imul(al1, bh3)) | 0; - mid = (mid + Math.imul(ah1, bl3)) | 0; - hi = (hi + Math.imul(ah1, bh3)) | 0; - lo = (lo + Math.imul(al0, bl4)) | 0; - mid = (mid + Math.imul(al0, bh4)) | 0; - mid = (mid + Math.imul(ah0, bl4)) | 0; - hi = (hi + Math.imul(ah0, bh4)) | 0; - var w4 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w4 >>> 26)) | 0; - w4 &= 0x3ffffff; - /* k = 5 */ - lo = Math.imul(al5, bl0); - mid = Math.imul(al5, bh0); - mid = (mid + Math.imul(ah5, bl0)) | 0; - hi = Math.imul(ah5, bh0); - lo = (lo + Math.imul(al4, bl1)) | 0; - mid = (mid + Math.imul(al4, bh1)) | 0; - mid = (mid + Math.imul(ah4, bl1)) | 0; - hi = (hi + Math.imul(ah4, bh1)) | 0; - lo = (lo + Math.imul(al3, bl2)) | 0; - mid = (mid + Math.imul(al3, bh2)) | 0; - mid = (mid + Math.imul(ah3, bl2)) | 0; - hi = (hi + Math.imul(ah3, bh2)) | 0; - lo = (lo + Math.imul(al2, bl3)) | 0; - mid = (mid + Math.imul(al2, bh3)) | 0; - mid = (mid + Math.imul(ah2, bl3)) | 0; - hi = (hi + Math.imul(ah2, bh3)) | 0; - lo = (lo + Math.imul(al1, bl4)) | 0; - mid = (mid + Math.imul(al1, bh4)) | 0; - mid = (mid + Math.imul(ah1, bl4)) | 0; - hi = (hi + Math.imul(ah1, bh4)) | 0; - lo = (lo + Math.imul(al0, bl5)) | 0; - mid = (mid + Math.imul(al0, bh5)) | 0; - mid = (mid + Math.imul(ah0, bl5)) | 0; - hi = (hi + Math.imul(ah0, bh5)) | 0; - var w5 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w5 >>> 26)) | 0; - w5 &= 0x3ffffff; - /* k = 6 */ - lo = Math.imul(al6, bl0); - mid = Math.imul(al6, bh0); - mid = (mid + Math.imul(ah6, bl0)) | 0; - hi = Math.imul(ah6, bh0); - lo = (lo + Math.imul(al5, bl1)) | 0; - mid = (mid + Math.imul(al5, bh1)) | 0; - mid = (mid + Math.imul(ah5, bl1)) | 0; - hi = (hi + Math.imul(ah5, bh1)) | 0; - lo = (lo + Math.imul(al4, bl2)) | 0; - mid = (mid + Math.imul(al4, bh2)) | 0; - mid = (mid + Math.imul(ah4, bl2)) | 0; - hi = (hi + Math.imul(ah4, bh2)) | 0; - lo = (lo + Math.imul(al3, bl3)) | 0; - mid = (mid + Math.imul(al3, bh3)) | 0; - mid = (mid + Math.imul(ah3, bl3)) | 0; - hi = (hi + Math.imul(ah3, bh3)) | 0; - lo = (lo + Math.imul(al2, bl4)) | 0; - mid = (mid + Math.imul(al2, bh4)) | 0; - mid = (mid + Math.imul(ah2, bl4)) | 0; - hi = (hi + Math.imul(ah2, bh4)) | 0; - lo = (lo + Math.imul(al1, bl5)) | 0; - mid = (mid + Math.imul(al1, bh5)) | 0; - mid = (mid + Math.imul(ah1, bl5)) | 0; - hi = (hi + Math.imul(ah1, bh5)) | 0; - lo = (lo + Math.imul(al0, bl6)) | 0; - mid = (mid + Math.imul(al0, bh6)) | 0; - mid = (mid + Math.imul(ah0, bl6)) | 0; - hi = (hi + Math.imul(ah0, bh6)) | 0; - var w6 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w6 >>> 26)) | 0; - w6 &= 0x3ffffff; - /* k = 7 */ - lo = Math.imul(al7, bl0); - mid = Math.imul(al7, bh0); - mid = (mid + Math.imul(ah7, bl0)) | 0; - hi = Math.imul(ah7, bh0); - lo = (lo + Math.imul(al6, bl1)) | 0; - mid = (mid + Math.imul(al6, bh1)) | 0; - mid = (mid + Math.imul(ah6, bl1)) | 0; - hi = (hi + Math.imul(ah6, bh1)) | 0; - lo = (lo + Math.imul(al5, bl2)) | 0; - mid = (mid + Math.imul(al5, bh2)) | 0; - mid = (mid + Math.imul(ah5, bl2)) | 0; - hi = (hi + Math.imul(ah5, bh2)) | 0; - lo = (lo + Math.imul(al4, bl3)) | 0; - mid = (mid + Math.imul(al4, bh3)) | 0; - mid = (mid + Math.imul(ah4, bl3)) | 0; - hi = (hi + Math.imul(ah4, bh3)) | 0; - lo = (lo + Math.imul(al3, bl4)) | 0; - mid = (mid + Math.imul(al3, bh4)) | 0; - mid = (mid + Math.imul(ah3, bl4)) | 0; - hi = (hi + Math.imul(ah3, bh4)) | 0; - lo = (lo + Math.imul(al2, bl5)) | 0; - mid = (mid + Math.imul(al2, bh5)) | 0; - mid = (mid + Math.imul(ah2, bl5)) | 0; - hi = (hi + Math.imul(ah2, bh5)) | 0; - lo = (lo + Math.imul(al1, bl6)) | 0; - mid = (mid + Math.imul(al1, bh6)) | 0; - mid = (mid + Math.imul(ah1, bl6)) | 0; - hi = (hi + Math.imul(ah1, bh6)) | 0; - lo = (lo + Math.imul(al0, bl7)) | 0; - mid = (mid + Math.imul(al0, bh7)) | 0; - mid = (mid + Math.imul(ah0, bl7)) | 0; - hi = (hi + Math.imul(ah0, bh7)) | 0; - var w7 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w7 >>> 26)) | 0; - w7 &= 0x3ffffff; - /* k = 8 */ - lo = Math.imul(al8, bl0); - mid = Math.imul(al8, bh0); - mid = (mid + Math.imul(ah8, bl0)) | 0; - hi = Math.imul(ah8, bh0); - lo = (lo + Math.imul(al7, bl1)) | 0; - mid = (mid + Math.imul(al7, bh1)) | 0; - mid = (mid + Math.imul(ah7, bl1)) | 0; - hi = (hi + Math.imul(ah7, bh1)) | 0; - lo = (lo + Math.imul(al6, bl2)) | 0; - mid = (mid + Math.imul(al6, bh2)) | 0; - mid = (mid + Math.imul(ah6, bl2)) | 0; - hi = (hi + Math.imul(ah6, bh2)) | 0; - lo = (lo + Math.imul(al5, bl3)) | 0; - mid = (mid + Math.imul(al5, bh3)) | 0; - mid = (mid + Math.imul(ah5, bl3)) | 0; - hi = (hi + Math.imul(ah5, bh3)) | 0; - lo = (lo + Math.imul(al4, bl4)) | 0; - mid = (mid + Math.imul(al4, bh4)) | 0; - mid = (mid + Math.imul(ah4, bl4)) | 0; - hi = (hi + Math.imul(ah4, bh4)) | 0; - lo = (lo + Math.imul(al3, bl5)) | 0; - mid = (mid + Math.imul(al3, bh5)) | 0; - mid = (mid + Math.imul(ah3, bl5)) | 0; - hi = (hi + Math.imul(ah3, bh5)) | 0; - lo = (lo + Math.imul(al2, bl6)) | 0; - mid = (mid + Math.imul(al2, bh6)) | 0; - mid = (mid + Math.imul(ah2, bl6)) | 0; - hi = (hi + Math.imul(ah2, bh6)) | 0; - lo = (lo + Math.imul(al1, bl7)) | 0; - mid = (mid + Math.imul(al1, bh7)) | 0; - mid = (mid + Math.imul(ah1, bl7)) | 0; - hi = (hi + Math.imul(ah1, bh7)) | 0; - lo = (lo + Math.imul(al0, bl8)) | 0; - mid = (mid + Math.imul(al0, bh8)) | 0; - mid = (mid + Math.imul(ah0, bl8)) | 0; - hi = (hi + Math.imul(ah0, bh8)) | 0; - var w8 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w8 >>> 26)) | 0; - w8 &= 0x3ffffff; - /* k = 9 */ - lo = Math.imul(al9, bl0); - mid = Math.imul(al9, bh0); - mid = (mid + Math.imul(ah9, bl0)) | 0; - hi = Math.imul(ah9, bh0); - lo = (lo + Math.imul(al8, bl1)) | 0; - mid = (mid + Math.imul(al8, bh1)) | 0; - mid = (mid + Math.imul(ah8, bl1)) | 0; - hi = (hi + Math.imul(ah8, bh1)) | 0; - lo = (lo + Math.imul(al7, bl2)) | 0; - mid = (mid + Math.imul(al7, bh2)) | 0; - mid = (mid + Math.imul(ah7, bl2)) | 0; - hi = (hi + Math.imul(ah7, bh2)) | 0; - lo = (lo + Math.imul(al6, bl3)) | 0; - mid = (mid + Math.imul(al6, bh3)) | 0; - mid = (mid + Math.imul(ah6, bl3)) | 0; - hi = (hi + Math.imul(ah6, bh3)) | 0; - lo = (lo + Math.imul(al5, bl4)) | 0; - mid = (mid + Math.imul(al5, bh4)) | 0; - mid = (mid + Math.imul(ah5, bl4)) | 0; - hi = (hi + Math.imul(ah5, bh4)) | 0; - lo = (lo + Math.imul(al4, bl5)) | 0; - mid = (mid + Math.imul(al4, bh5)) | 0; - mid = (mid + Math.imul(ah4, bl5)) | 0; - hi = (hi + Math.imul(ah4, bh5)) | 0; - lo = (lo + Math.imul(al3, bl6)) | 0; - mid = (mid + Math.imul(al3, bh6)) | 0; - mid = (mid + Math.imul(ah3, bl6)) | 0; - hi = (hi + Math.imul(ah3, bh6)) | 0; - lo = (lo + Math.imul(al2, bl7)) | 0; - mid = (mid + Math.imul(al2, bh7)) | 0; - mid = (mid + Math.imul(ah2, bl7)) | 0; - hi = (hi + Math.imul(ah2, bh7)) | 0; - lo = (lo + Math.imul(al1, bl8)) | 0; - mid = (mid + Math.imul(al1, bh8)) | 0; - mid = (mid + Math.imul(ah1, bl8)) | 0; - hi = (hi + Math.imul(ah1, bh8)) | 0; - lo = (lo + Math.imul(al0, bl9)) | 0; - mid = (mid + Math.imul(al0, bh9)) | 0; - mid = (mid + Math.imul(ah0, bl9)) | 0; - hi = (hi + Math.imul(ah0, bh9)) | 0; - var w9 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w9 >>> 26)) | 0; - w9 &= 0x3ffffff; - /* k = 10 */ - lo = Math.imul(al9, bl1); - mid = Math.imul(al9, bh1); - mid = (mid + Math.imul(ah9, bl1)) | 0; - hi = Math.imul(ah9, bh1); - lo = (lo + Math.imul(al8, bl2)) | 0; - mid = (mid + Math.imul(al8, bh2)) | 0; - mid = (mid + Math.imul(ah8, bl2)) | 0; - hi = (hi + Math.imul(ah8, bh2)) | 0; - lo = (lo + Math.imul(al7, bl3)) | 0; - mid = (mid + Math.imul(al7, bh3)) | 0; - mid = (mid + Math.imul(ah7, bl3)) | 0; - hi = (hi + Math.imul(ah7, bh3)) | 0; - lo = (lo + Math.imul(al6, bl4)) | 0; - mid = (mid + Math.imul(al6, bh4)) | 0; - mid = (mid + Math.imul(ah6, bl4)) | 0; - hi = (hi + Math.imul(ah6, bh4)) | 0; - lo = (lo + Math.imul(al5, bl5)) | 0; - mid = (mid + Math.imul(al5, bh5)) | 0; - mid = (mid + Math.imul(ah5, bl5)) | 0; - hi = (hi + Math.imul(ah5, bh5)) | 0; - lo = (lo + Math.imul(al4, bl6)) | 0; - mid = (mid + Math.imul(al4, bh6)) | 0; - mid = (mid + Math.imul(ah4, bl6)) | 0; - hi = (hi + Math.imul(ah4, bh6)) | 0; - lo = (lo + Math.imul(al3, bl7)) | 0; - mid = (mid + Math.imul(al3, bh7)) | 0; - mid = (mid + Math.imul(ah3, bl7)) | 0; - hi = (hi + Math.imul(ah3, bh7)) | 0; - lo = (lo + Math.imul(al2, bl8)) | 0; - mid = (mid + Math.imul(al2, bh8)) | 0; - mid = (mid + Math.imul(ah2, bl8)) | 0; - hi = (hi + Math.imul(ah2, bh8)) | 0; - lo = (lo + Math.imul(al1, bl9)) | 0; - mid = (mid + Math.imul(al1, bh9)) | 0; - mid = (mid + Math.imul(ah1, bl9)) | 0; - hi = (hi + Math.imul(ah1, bh9)) | 0; - var w10 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w10 >>> 26)) | 0; - w10 &= 0x3ffffff; - /* k = 11 */ - lo = Math.imul(al9, bl2); - mid = Math.imul(al9, bh2); - mid = (mid + Math.imul(ah9, bl2)) | 0; - hi = Math.imul(ah9, bh2); - lo = (lo + Math.imul(al8, bl3)) | 0; - mid = (mid + Math.imul(al8, bh3)) | 0; - mid = (mid + Math.imul(ah8, bl3)) | 0; - hi = (hi + Math.imul(ah8, bh3)) | 0; - lo = (lo + Math.imul(al7, bl4)) | 0; - mid = (mid + Math.imul(al7, bh4)) | 0; - mid = (mid + Math.imul(ah7, bl4)) | 0; - hi = (hi + Math.imul(ah7, bh4)) | 0; - lo = (lo + Math.imul(al6, bl5)) | 0; - mid = (mid + Math.imul(al6, bh5)) | 0; - mid = (mid + Math.imul(ah6, bl5)) | 0; - hi = (hi + Math.imul(ah6, bh5)) | 0; - lo = (lo + Math.imul(al5, bl6)) | 0; - mid = (mid + Math.imul(al5, bh6)) | 0; - mid = (mid + Math.imul(ah5, bl6)) | 0; - hi = (hi + Math.imul(ah5, bh6)) | 0; - lo = (lo + Math.imul(al4, bl7)) | 0; - mid = (mid + Math.imul(al4, bh7)) | 0; - mid = (mid + Math.imul(ah4, bl7)) | 0; - hi = (hi + Math.imul(ah4, bh7)) | 0; - lo = (lo + Math.imul(al3, bl8)) | 0; - mid = (mid + Math.imul(al3, bh8)) | 0; - mid = (mid + Math.imul(ah3, bl8)) | 0; - hi = (hi + Math.imul(ah3, bh8)) | 0; - lo = (lo + Math.imul(al2, bl9)) | 0; - mid = (mid + Math.imul(al2, bh9)) | 0; - mid = (mid + Math.imul(ah2, bl9)) | 0; - hi = (hi + Math.imul(ah2, bh9)) | 0; - var w11 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w11 >>> 26)) | 0; - w11 &= 0x3ffffff; - /* k = 12 */ - lo = Math.imul(al9, bl3); - mid = Math.imul(al9, bh3); - mid = (mid + Math.imul(ah9, bl3)) | 0; - hi = Math.imul(ah9, bh3); - lo = (lo + Math.imul(al8, bl4)) | 0; - mid = (mid + Math.imul(al8, bh4)) | 0; - mid = (mid + Math.imul(ah8, bl4)) | 0; - hi = (hi + Math.imul(ah8, bh4)) | 0; - lo = (lo + Math.imul(al7, bl5)) | 0; - mid = (mid + Math.imul(al7, bh5)) | 0; - mid = (mid + Math.imul(ah7, bl5)) | 0; - hi = (hi + Math.imul(ah7, bh5)) | 0; - lo = (lo + Math.imul(al6, bl6)) | 0; - mid = (mid + Math.imul(al6, bh6)) | 0; - mid = (mid + Math.imul(ah6, bl6)) | 0; - hi = (hi + Math.imul(ah6, bh6)) | 0; - lo = (lo + Math.imul(al5, bl7)) | 0; - mid = (mid + Math.imul(al5, bh7)) | 0; - mid = (mid + Math.imul(ah5, bl7)) | 0; - hi = (hi + Math.imul(ah5, bh7)) | 0; - lo = (lo + Math.imul(al4, bl8)) | 0; - mid = (mid + Math.imul(al4, bh8)) | 0; - mid = (mid + Math.imul(ah4, bl8)) | 0; - hi = (hi + Math.imul(ah4, bh8)) | 0; - lo = (lo + Math.imul(al3, bl9)) | 0; - mid = (mid + Math.imul(al3, bh9)) | 0; - mid = (mid + Math.imul(ah3, bl9)) | 0; - hi = (hi + Math.imul(ah3, bh9)) | 0; - var w12 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w12 >>> 26)) | 0; - w12 &= 0x3ffffff; - /* k = 13 */ - lo = Math.imul(al9, bl4); - mid = Math.imul(al9, bh4); - mid = (mid + Math.imul(ah9, bl4)) | 0; - hi = Math.imul(ah9, bh4); - lo = (lo + Math.imul(al8, bl5)) | 0; - mid = (mid + Math.imul(al8, bh5)) | 0; - mid = (mid + Math.imul(ah8, bl5)) | 0; - hi = (hi + Math.imul(ah8, bh5)) | 0; - lo = (lo + Math.imul(al7, bl6)) | 0; - mid = (mid + Math.imul(al7, bh6)) | 0; - mid = (mid + Math.imul(ah7, bl6)) | 0; - hi = (hi + Math.imul(ah7, bh6)) | 0; - lo = (lo + Math.imul(al6, bl7)) | 0; - mid = (mid + Math.imul(al6, bh7)) | 0; - mid = (mid + Math.imul(ah6, bl7)) | 0; - hi = (hi + Math.imul(ah6, bh7)) | 0; - lo = (lo + Math.imul(al5, bl8)) | 0; - mid = (mid + Math.imul(al5, bh8)) | 0; - mid = (mid + Math.imul(ah5, bl8)) | 0; - hi = (hi + Math.imul(ah5, bh8)) | 0; - lo = (lo + Math.imul(al4, bl9)) | 0; - mid = (mid + Math.imul(al4, bh9)) | 0; - mid = (mid + Math.imul(ah4, bl9)) | 0; - hi = (hi + Math.imul(ah4, bh9)) | 0; - var w13 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w13 >>> 26)) | 0; - w13 &= 0x3ffffff; - /* k = 14 */ - lo = Math.imul(al9, bl5); - mid = Math.imul(al9, bh5); - mid = (mid + Math.imul(ah9, bl5)) | 0; - hi = Math.imul(ah9, bh5); - lo = (lo + Math.imul(al8, bl6)) | 0; - mid = (mid + Math.imul(al8, bh6)) | 0; - mid = (mid + Math.imul(ah8, bl6)) | 0; - hi = (hi + Math.imul(ah8, bh6)) | 0; - lo = (lo + Math.imul(al7, bl7)) | 0; - mid = (mid + Math.imul(al7, bh7)) | 0; - mid = (mid + Math.imul(ah7, bl7)) | 0; - hi = (hi + Math.imul(ah7, bh7)) | 0; - lo = (lo + Math.imul(al6, bl8)) | 0; - mid = (mid + Math.imul(al6, bh8)) | 0; - mid = (mid + Math.imul(ah6, bl8)) | 0; - hi = (hi + Math.imul(ah6, bh8)) | 0; - lo = (lo + Math.imul(al5, bl9)) | 0; - mid = (mid + Math.imul(al5, bh9)) | 0; - mid = (mid + Math.imul(ah5, bl9)) | 0; - hi = (hi + Math.imul(ah5, bh9)) | 0; - var w14 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w14 >>> 26)) | 0; - w14 &= 0x3ffffff; - /* k = 15 */ - lo = Math.imul(al9, bl6); - mid = Math.imul(al9, bh6); - mid = (mid + Math.imul(ah9, bl6)) | 0; - hi = Math.imul(ah9, bh6); - lo = (lo + Math.imul(al8, bl7)) | 0; - mid = (mid + Math.imul(al8, bh7)) | 0; - mid = (mid + Math.imul(ah8, bl7)) | 0; - hi = (hi + Math.imul(ah8, bh7)) | 0; - lo = (lo + Math.imul(al7, bl8)) | 0; - mid = (mid + Math.imul(al7, bh8)) | 0; - mid = (mid + Math.imul(ah7, bl8)) | 0; - hi = (hi + Math.imul(ah7, bh8)) | 0; - lo = (lo + Math.imul(al6, bl9)) | 0; - mid = (mid + Math.imul(al6, bh9)) | 0; - mid = (mid + Math.imul(ah6, bl9)) | 0; - hi = (hi + Math.imul(ah6, bh9)) | 0; - var w15 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w15 >>> 26)) | 0; - w15 &= 0x3ffffff; - /* k = 16 */ - lo = Math.imul(al9, bl7); - mid = Math.imul(al9, bh7); - mid = (mid + Math.imul(ah9, bl7)) | 0; - hi = Math.imul(ah9, bh7); - lo = (lo + Math.imul(al8, bl8)) | 0; - mid = (mid + Math.imul(al8, bh8)) | 0; - mid = (mid + Math.imul(ah8, bl8)) | 0; - hi = (hi + Math.imul(ah8, bh8)) | 0; - lo = (lo + Math.imul(al7, bl9)) | 0; - mid = (mid + Math.imul(al7, bh9)) | 0; - mid = (mid + Math.imul(ah7, bl9)) | 0; - hi = (hi + Math.imul(ah7, bh9)) | 0; - var w16 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w16 >>> 26)) | 0; - w16 &= 0x3ffffff; - /* k = 17 */ - lo = Math.imul(al9, bl8); - mid = Math.imul(al9, bh8); - mid = (mid + Math.imul(ah9, bl8)) | 0; - hi = Math.imul(ah9, bh8); - lo = (lo + Math.imul(al8, bl9)) | 0; - mid = (mid + Math.imul(al8, bh9)) | 0; - mid = (mid + Math.imul(ah8, bl9)) | 0; - hi = (hi + Math.imul(ah8, bh9)) | 0; - var w17 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w17 >>> 26)) | 0; - w17 &= 0x3ffffff; - /* k = 18 */ - lo = Math.imul(al9, bl9); - mid = Math.imul(al9, bh9); - mid = (mid + Math.imul(ah9, bl9)) | 0; - hi = Math.imul(ah9, bh9); - var w18 = (((c + lo) | 0) + ((mid & 0x1fff) << 13)) | 0; - c = (((hi + (mid >>> 13)) | 0) + (w18 >>> 26)) | 0; - w18 &= 0x3ffffff; - o[0] = w0; - o[1] = w1; - o[2] = w2; - o[3] = w3; - o[4] = w4; - o[5] = w5; - o[6] = w6; - o[7] = w7; - o[8] = w8; - o[9] = w9; - o[10] = w10; - o[11] = w11; - o[12] = w12; - o[13] = w13; - o[14] = w14; - o[15] = w15; - o[16] = w16; - o[17] = w17; - o[18] = w18; - if (c !== 0) { - o[19] = c; - out.length++; - } - return out; - }; - - // Polyfill comb - if (!Math.imul) { - comb10MulTo = smallMulTo; - } - - function bigMulTo (self, num, out) { - out.negative = num.negative ^ self.negative; - out.length = self.length + num.length; - - var carry = 0; - var hncarry = 0; - for (var k = 0; k < out.length - 1; k++) { - // Sum all words with the same `i + j = k` and accumulate `ncarry`, - // note that ncarry could be >= 0x3ffffff - var ncarry = hncarry; - hncarry = 0; - var rword = carry & 0x3ffffff; - var maxJ = Math.min(k, num.length - 1); - for (var j = Math.max(0, k - self.length + 1); j <= maxJ; j++) { - var i = k - j; - var a = self.words[i] | 0; - var b = num.words[j] | 0; - var r = a * b; - - var lo = r & 0x3ffffff; - ncarry = (ncarry + ((r / 0x4000000) | 0)) | 0; - lo = (lo + rword) | 0; - rword = lo & 0x3ffffff; - ncarry = (ncarry + (lo >>> 26)) | 0; - - hncarry += ncarry >>> 26; - ncarry &= 0x3ffffff; - } - out.words[k] = rword; - carry = ncarry; - ncarry = hncarry; - } - if (carry !== 0) { - out.words[k] = carry; - } else { - out.length--; - } - - return out.strip(); - } - - function jumboMulTo (self, num, out) { - var fftm = new FFTM(); - return fftm.mulp(self, num, out); - } - - BN.prototype.mulTo = function mulTo (num, out) { - var res; - var len = this.length + num.length; - if (this.length === 10 && num.length === 10) { - res = comb10MulTo(this, num, out); - } else if (len < 63) { - res = smallMulTo(this, num, out); - } else if (len < 1024) { - res = bigMulTo(this, num, out); - } else { - res = jumboMulTo(this, num, out); - } - - return res; - }; - - // Cooley-Tukey algorithm for FFT - // slightly revisited to rely on looping instead of recursion - - function FFTM (x, y) { - this.x = x; - this.y = y; - } - - FFTM.prototype.makeRBT = function makeRBT (N) { - var t = new Array(N); - var l = BN.prototype._countBits(N) - 1; - for (var i = 0; i < N; i++) { - t[i] = this.revBin(i, l, N); - } - - return t; - }; - - // Returns binary-reversed representation of `x` - FFTM.prototype.revBin = function revBin (x, l, N) { - if (x === 0 || x === N - 1) return x; - - var rb = 0; - for (var i = 0; i < l; i++) { - rb |= (x & 1) << (l - i - 1); - x >>= 1; - } - - return rb; - }; - - // Performs "tweedling" phase, therefore 'emulating' - // behaviour of the recursive algorithm - FFTM.prototype.permute = function permute (rbt, rws, iws, rtws, itws, N) { - for (var i = 0; i < N; i++) { - rtws[i] = rws[rbt[i]]; - itws[i] = iws[rbt[i]]; - } - }; - - FFTM.prototype.transform = function transform (rws, iws, rtws, itws, N, rbt) { - this.permute(rbt, rws, iws, rtws, itws, N); - - for (var s = 1; s < N; s <<= 1) { - var l = s << 1; - - var rtwdf = Math.cos(2 * Math.PI / l); - var itwdf = Math.sin(2 * Math.PI / l); - - for (var p = 0; p < N; p += l) { - var rtwdf_ = rtwdf; - var itwdf_ = itwdf; - - for (var j = 0; j < s; j++) { - var re = rtws[p + j]; - var ie = itws[p + j]; - - var ro = rtws[p + j + s]; - var io = itws[p + j + s]; - - var rx = rtwdf_ * ro - itwdf_ * io; - - io = rtwdf_ * io + itwdf_ * ro; - ro = rx; - - rtws[p + j] = re + ro; - itws[p + j] = ie + io; - - rtws[p + j + s] = re - ro; - itws[p + j + s] = ie - io; - - /* jshint maxdepth : false */ - if (j !== l) { - rx = rtwdf * rtwdf_ - itwdf * itwdf_; - - itwdf_ = rtwdf * itwdf_ + itwdf * rtwdf_; - rtwdf_ = rx; - } - } - } - } - }; - - FFTM.prototype.guessLen13b = function guessLen13b (n, m) { - var N = Math.max(m, n) | 1; - var odd = N & 1; - var i = 0; - for (N = N / 2 | 0; N; N = N >>> 1) { - i++; - } - - return 1 << i + 1 + odd; - }; - - FFTM.prototype.conjugate = function conjugate (rws, iws, N) { - if (N <= 1) return; - - for (var i = 0; i < N / 2; i++) { - var t = rws[i]; - - rws[i] = rws[N - i - 1]; - rws[N - i - 1] = t; - - t = iws[i]; - - iws[i] = -iws[N - i - 1]; - iws[N - i - 1] = -t; - } - }; - - FFTM.prototype.normalize13b = function normalize13b (ws, N) { - var carry = 0; - for (var i = 0; i < N / 2; i++) { - var w = Math.round(ws[2 * i + 1] / N) * 0x2000 + - Math.round(ws[2 * i] / N) + - carry; - - ws[i] = w & 0x3ffffff; - - if (w < 0x4000000) { - carry = 0; - } else { - carry = w / 0x4000000 | 0; - } - } - - return ws; - }; - - FFTM.prototype.convert13b = function convert13b (ws, len, rws, N) { - var carry = 0; - for (var i = 0; i < len; i++) { - carry = carry + (ws[i] | 0); - - rws[2 * i] = carry & 0x1fff; carry = carry >>> 13; - rws[2 * i + 1] = carry & 0x1fff; carry = carry >>> 13; - } - - // Pad with zeroes - for (i = 2 * len; i < N; ++i) { - rws[i] = 0; - } - - assert(carry === 0); - assert((carry & ~0x1fff) === 0); - }; - - FFTM.prototype.stub = function stub (N) { - var ph = new Array(N); - for (var i = 0; i < N; i++) { - ph[i] = 0; - } - - return ph; - }; - - FFTM.prototype.mulp = function mulp (x, y, out) { - var N = 2 * this.guessLen13b(x.length, y.length); - - var rbt = this.makeRBT(N); - - var _ = this.stub(N); - - var rws = new Array(N); - var rwst = new Array(N); - var iwst = new Array(N); - - var nrws = new Array(N); - var nrwst = new Array(N); - var niwst = new Array(N); - - var rmws = out.words; - rmws.length = N; - - this.convert13b(x.words, x.length, rws, N); - this.convert13b(y.words, y.length, nrws, N); - - this.transform(rws, _, rwst, iwst, N, rbt); - this.transform(nrws, _, nrwst, niwst, N, rbt); - - for (var i = 0; i < N; i++) { - var rx = rwst[i] * nrwst[i] - iwst[i] * niwst[i]; - iwst[i] = rwst[i] * niwst[i] + iwst[i] * nrwst[i]; - rwst[i] = rx; - } - - this.conjugate(rwst, iwst, N); - this.transform(rwst, iwst, rmws, _, N, rbt); - this.conjugate(rmws, _, N); - this.normalize13b(rmws, N); - - out.negative = x.negative ^ y.negative; - out.length = x.length + y.length; - return out.strip(); - }; - - // Multiply `this` by `num` - BN.prototype.mul = function mul (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return this.mulTo(num, out); - }; - - // Multiply employing FFT - BN.prototype.mulf = function mulf (num) { - var out = new BN(null); - out.words = new Array(this.length + num.length); - return jumboMulTo(this, num, out); - }; - - // In-place Multiplication - BN.prototype.imul = function imul (num) { - return this.clone().mulTo(num, this); - }; - - BN.prototype.imuln = function imuln (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - - // Carry - var carry = 0; - for (var i = 0; i < this.length; i++) { - var w = (this.words[i] | 0) * num; - var lo = (w & 0x3ffffff) + (carry & 0x3ffffff); - carry >>= 26; - carry += (w / 0x4000000) | 0; - // NOTE: lo is 27bit maximum - carry += lo >>> 26; - this.words[i] = lo & 0x3ffffff; - } - - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - - return this; - }; - - BN.prototype.muln = function muln (num) { - return this.clone().imuln(num); - }; - - // `this` * `this` - BN.prototype.sqr = function sqr () { - return this.mul(this); - }; - - // `this` * `this` in-place - BN.prototype.isqr = function isqr () { - return this.imul(this.clone()); - }; - - // Math.pow(`this`, `num`) - BN.prototype.pow = function pow (num) { - var w = toBitArray(num); - if (w.length === 0) return new BN(1); - - // Skip leading zeroes - var res = this; - for (var i = 0; i < w.length; i++, res = res.sqr()) { - if (w[i] !== 0) break; - } - - if (++i < w.length) { - for (var q = res.sqr(); i < w.length; i++, q = q.sqr()) { - if (w[i] === 0) continue; - - res = res.mul(q); - } - } - - return res; - }; - - // Shift-left in-place - BN.prototype.iushln = function iushln (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - var carryMask = (0x3ffffff >>> (26 - r)) << (26 - r); - var i; - - if (r !== 0) { - var carry = 0; - - for (i = 0; i < this.length; i++) { - var newCarry = this.words[i] & carryMask; - var c = ((this.words[i] | 0) - newCarry) << r; - this.words[i] = c | carry; - carry = newCarry >>> (26 - r); - } - - if (carry) { - this.words[i] = carry; - this.length++; - } - } - - if (s !== 0) { - for (i = this.length - 1; i >= 0; i--) { - this.words[i + s] = this.words[i]; - } - - for (i = 0; i < s; i++) { - this.words[i] = 0; - } - - this.length += s; - } - - return this.strip(); - }; - - BN.prototype.ishln = function ishln (bits) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushln(bits); - }; - - // Shift-right in-place - // NOTE: `hint` is a lowest bit before trailing zeroes - // NOTE: if `extended` is present - it will be filled with destroyed bits - BN.prototype.iushrn = function iushrn (bits, hint, extended) { - assert(typeof bits === 'number' && bits >= 0); - var h; - if (hint) { - h = (hint - (hint % 26)) / 26; - } else { - h = 0; - } - - var r = bits % 26; - var s = Math.min((bits - r) / 26, this.length); - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - var maskedWords = extended; - - h -= s; - h = Math.max(0, h); - - // Extended mode, copy masked part - if (maskedWords) { - for (var i = 0; i < s; i++) { - maskedWords.words[i] = this.words[i]; - } - maskedWords.length = s; - } - - if (s === 0) { - // No-op, we should not move anything at all - } else if (this.length > s) { - this.length -= s; - for (i = 0; i < this.length; i++) { - this.words[i] = this.words[i + s]; - } - } else { - this.words[0] = 0; - this.length = 1; - } - - var carry = 0; - for (i = this.length - 1; i >= 0 && (carry !== 0 || i >= h); i--) { - var word = this.words[i] | 0; - this.words[i] = (carry << (26 - r)) | (word >>> r); - carry = word & mask; - } - - // Push carried bits as a mask - if (maskedWords && carry !== 0) { - maskedWords.words[maskedWords.length++] = carry; - } - - if (this.length === 0) { - this.words[0] = 0; - this.length = 1; - } - - return this.strip(); - }; - - BN.prototype.ishrn = function ishrn (bits, hint, extended) { - // TODO(indutny): implement me - assert(this.negative === 0); - return this.iushrn(bits, hint, extended); - }; - - // Shift-left - BN.prototype.shln = function shln (bits) { - return this.clone().ishln(bits); - }; - - BN.prototype.ushln = function ushln (bits) { - return this.clone().iushln(bits); - }; - - // Shift-right - BN.prototype.shrn = function shrn (bits) { - return this.clone().ishrn(bits); - }; - - BN.prototype.ushrn = function ushrn (bits) { - return this.clone().iushrn(bits); - }; - - // Test if n bit is set - BN.prototype.testn = function testn (bit) { - assert(typeof bit === 'number' && bit >= 0); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) return false; - - // Check bit and return - var w = this.words[s]; - - return !!(w & q); - }; - - // Return only lowers bits of number (in-place) - BN.prototype.imaskn = function imaskn (bits) { - assert(typeof bits === 'number' && bits >= 0); - var r = bits % 26; - var s = (bits - r) / 26; - - assert(this.negative === 0, 'imaskn works only with positive numbers'); - - if (this.length <= s) { - return this; - } - - if (r !== 0) { - s++; - } - this.length = Math.min(s, this.length); - - if (r !== 0) { - var mask = 0x3ffffff ^ ((0x3ffffff >>> r) << r); - this.words[this.length - 1] &= mask; - } - - return this.strip(); - }; - - // Return only lowers bits of number - BN.prototype.maskn = function maskn (bits) { - return this.clone().imaskn(bits); - }; - - // Add plain number `num` to `this` - BN.prototype.iaddn = function iaddn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.isubn(-num); - - // Possible sign change - if (this.negative !== 0) { - if (this.length === 1 && (this.words[0] | 0) < num) { - this.words[0] = num - (this.words[0] | 0); - this.negative = 0; - return this; - } - - this.negative = 0; - this.isubn(num); - this.negative = 1; - return this; - } - - // Add without checks - return this._iaddn(num); - }; - - BN.prototype._iaddn = function _iaddn (num) { - this.words[0] += num; - - // Carry - for (var i = 0; i < this.length && this.words[i] >= 0x4000000; i++) { - this.words[i] -= 0x4000000; - if (i === this.length - 1) { - this.words[i + 1] = 1; - } else { - this.words[i + 1]++; - } - } - this.length = Math.max(this.length, i + 1); - - return this; - }; - - // Subtract plain number `num` from `this` - BN.prototype.isubn = function isubn (num) { - assert(typeof num === 'number'); - assert(num < 0x4000000); - if (num < 0) return this.iaddn(-num); - - if (this.negative !== 0) { - this.negative = 0; - this.iaddn(num); - this.negative = 1; - return this; - } - - this.words[0] -= num; - - if (this.length === 1 && this.words[0] < 0) { - this.words[0] = -this.words[0]; - this.negative = 1; - } else { - // Carry - for (var i = 0; i < this.length && this.words[i] < 0; i++) { - this.words[i] += 0x4000000; - this.words[i + 1] -= 1; - } - } - - return this.strip(); - }; - - BN.prototype.addn = function addn (num) { - return this.clone().iaddn(num); - }; - - BN.prototype.subn = function subn (num) { - return this.clone().isubn(num); - }; - - BN.prototype.iabs = function iabs () { - this.negative = 0; - - return this; - }; - - BN.prototype.abs = function abs () { - return this.clone().iabs(); - }; - - BN.prototype._ishlnsubmul = function _ishlnsubmul (num, mul, shift) { - var len = num.length + shift; - var i; - - this._expand(len); - - var w; - var carry = 0; - for (i = 0; i < num.length; i++) { - w = (this.words[i + shift] | 0) + carry; - var right = (num.words[i] | 0) * mul; - w -= right & 0x3ffffff; - carry = (w >> 26) - ((right / 0x4000000) | 0); - this.words[i + shift] = w & 0x3ffffff; - } - for (; i < this.length - shift; i++) { - w = (this.words[i + shift] | 0) + carry; - carry = w >> 26; - this.words[i + shift] = w & 0x3ffffff; - } - - if (carry === 0) return this.strip(); - - // Subtraction overflow - assert(carry === -1); - carry = 0; - for (i = 0; i < this.length; i++) { - w = -(this.words[i] | 0) + carry; - carry = w >> 26; - this.words[i] = w & 0x3ffffff; - } - this.negative = 1; - - return this.strip(); - }; - - BN.prototype._wordDiv = function _wordDiv (num, mode) { - var shift = this.length - num.length; - - var a = this.clone(); - var b = num; - - // Normalize - var bhi = b.words[b.length - 1] | 0; - var bhiBits = this._countBits(bhi); - shift = 26 - bhiBits; - if (shift !== 0) { - b = b.ushln(shift); - a.iushln(shift); - bhi = b.words[b.length - 1] | 0; - } - - // Initialize quotient - var m = a.length - b.length; - var q; - - if (mode !== 'mod') { - q = new BN(null); - q.length = m + 1; - q.words = new Array(q.length); - for (var i = 0; i < q.length; i++) { - q.words[i] = 0; - } - } - - var diff = a.clone()._ishlnsubmul(b, 1, m); - if (diff.negative === 0) { - a = diff; - if (q) { - q.words[m] = 1; - } - } - - for (var j = m - 1; j >= 0; j--) { - var qj = (a.words[b.length + j] | 0) * 0x4000000 + - (a.words[b.length + j - 1] | 0); - - // NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max - // (0x7ffffff) - qj = Math.min((qj / bhi) | 0, 0x3ffffff); - - a._ishlnsubmul(b, qj, j); - while (a.negative !== 0) { - qj--; - a.negative = 0; - a._ishlnsubmul(b, 1, j); - if (!a.isZero()) { - a.negative ^= 1; - } - } - if (q) { - q.words[j] = qj; - } - } - if (q) { - q.strip(); - } - a.strip(); - - // Denormalize - if (mode !== 'div' && shift !== 0) { - a.iushrn(shift); - } - - return { - div: q || null, - mod: a - }; - }; - - // NOTE: 1) `mode` can be set to `mod` to request mod only, - // to `div` to request div only, or be absent to - // request both div & mod - // 2) `positive` is true if unsigned mod is requested - BN.prototype.divmod = function divmod (num, mode, positive) { - assert(!num.isZero()); - - if (this.isZero()) { - return { - div: new BN(0), - mod: new BN(0) - }; - } - - var div, mod, res; - if (this.negative !== 0 && num.negative === 0) { - res = this.neg().divmod(num, mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.iadd(num); - } - } - - return { - div: div, - mod: mod - }; - } - - if (this.negative === 0 && num.negative !== 0) { - res = this.divmod(num.neg(), mode); - - if (mode !== 'mod') { - div = res.div.neg(); - } - - return { - div: div, - mod: res.mod - }; - } - - if ((this.negative & num.negative) !== 0) { - res = this.neg().divmod(num.neg(), mode); - - if (mode !== 'div') { - mod = res.mod.neg(); - if (positive && mod.negative !== 0) { - mod.isub(num); - } - } - - return { - div: res.div, - mod: mod - }; - } - - // Both numbers are positive at this point - - // Strip both numbers to approximate shift value - if (num.length > this.length || this.cmp(num) < 0) { - return { - div: new BN(0), - mod: this - }; - } - - // Very short reduction - if (num.length === 1) { - if (mode === 'div') { - return { - div: this.divn(num.words[0]), - mod: null - }; - } - - if (mode === 'mod') { - return { - div: null, - mod: new BN(this.modn(num.words[0])) - }; - } - - return { - div: this.divn(num.words[0]), - mod: new BN(this.modn(num.words[0])) - }; - } - - return this._wordDiv(num, mode); - }; - - // Find `this` / `num` - BN.prototype.div = function div (num) { - return this.divmod(num, 'div', false).div; - }; - - // Find `this` % `num` - BN.prototype.mod = function mod (num) { - return this.divmod(num, 'mod', false).mod; - }; - - BN.prototype.umod = function umod (num) { - return this.divmod(num, 'mod', true).mod; - }; - - // Find Round(`this` / `num`) - BN.prototype.divRound = function divRound (num) { - var dm = this.divmod(num); - - // Fast case - exact division - if (dm.mod.isZero()) return dm.div; - - var mod = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod; - - var half = num.ushrn(1); - var r2 = num.andln(1); - var cmp = mod.cmp(half); - - // Round down - if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div; - - // Round up - return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1); - }; - - BN.prototype.modn = function modn (num) { - assert(num <= 0x3ffffff); - var p = (1 << 26) % num; - - var acc = 0; - for (var i = this.length - 1; i >= 0; i--) { - acc = (p * acc + (this.words[i] | 0)) % num; - } - - return acc; - }; - - // In-place division by number - BN.prototype.idivn = function idivn (num) { - assert(num <= 0x3ffffff); - - var carry = 0; - for (var i = this.length - 1; i >= 0; i--) { - var w = (this.words[i] | 0) + carry * 0x4000000; - this.words[i] = (w / num) | 0; - carry = w % num; - } - - return this.strip(); - }; - - BN.prototype.divn = function divn (num) { - return this.clone().idivn(num); - }; - - BN.prototype.egcd = function egcd (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var x = this; - var y = p.clone(); - - if (x.negative !== 0) { - x = x.umod(p); - } else { - x = x.clone(); - } - - // A * x + B * y = x - var A = new BN(1); - var B = new BN(0); - - // C * x + D * y = y - var C = new BN(0); - var D = new BN(1); - - var g = 0; - - while (x.isEven() && y.isEven()) { - x.iushrn(1); - y.iushrn(1); - ++g; - } - - var yp = y.clone(); - var xp = x.clone(); - - while (!x.isZero()) { - for (var i = 0, im = 1; (x.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - x.iushrn(i); - while (i-- > 0) { - if (A.isOdd() || B.isOdd()) { - A.iadd(yp); - B.isub(xp); - } - - A.iushrn(1); - B.iushrn(1); - } - } - - for (var j = 0, jm = 1; (y.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - y.iushrn(j); - while (j-- > 0) { - if (C.isOdd() || D.isOdd()) { - C.iadd(yp); - D.isub(xp); - } - - C.iushrn(1); - D.iushrn(1); - } - } - - if (x.cmp(y) >= 0) { - x.isub(y); - A.isub(C); - B.isub(D); - } else { - y.isub(x); - C.isub(A); - D.isub(B); - } - } - - return { - a: C, - b: D, - gcd: y.iushln(g) - }; - }; - - // This is reduced incarnation of the binary EEA - // above, designated to invert members of the - // _prime_ fields F(p) at a maximal speed - BN.prototype._invmp = function _invmp (p) { - assert(p.negative === 0); - assert(!p.isZero()); - - var a = this; - var b = p.clone(); - - if (a.negative !== 0) { - a = a.umod(p); - } else { - a = a.clone(); - } - - var x1 = new BN(1); - var x2 = new BN(0); - - var delta = b.clone(); - - while (a.cmpn(1) > 0 && b.cmpn(1) > 0) { - for (var i = 0, im = 1; (a.words[0] & im) === 0 && i < 26; ++i, im <<= 1); - if (i > 0) { - a.iushrn(i); - while (i-- > 0) { - if (x1.isOdd()) { - x1.iadd(delta); - } - - x1.iushrn(1); - } - } - - for (var j = 0, jm = 1; (b.words[0] & jm) === 0 && j < 26; ++j, jm <<= 1); - if (j > 0) { - b.iushrn(j); - while (j-- > 0) { - if (x2.isOdd()) { - x2.iadd(delta); - } - - x2.iushrn(1); - } - } - - if (a.cmp(b) >= 0) { - a.isub(b); - x1.isub(x2); - } else { - b.isub(a); - x2.isub(x1); - } - } - - var res; - if (a.cmpn(1) === 0) { - res = x1; - } else { - res = x2; - } - - if (res.cmpn(0) < 0) { - res.iadd(p); - } - - return res; - }; - - BN.prototype.gcd = function gcd (num) { - if (this.isZero()) return num.abs(); - if (num.isZero()) return this.abs(); - - var a = this.clone(); - var b = num.clone(); - a.negative = 0; - b.negative = 0; - - // Remove common factor of two - for (var shift = 0; a.isEven() && b.isEven(); shift++) { - a.iushrn(1); - b.iushrn(1); - } - - do { - while (a.isEven()) { - a.iushrn(1); - } - while (b.isEven()) { - b.iushrn(1); - } - - var r = a.cmp(b); - if (r < 0) { - // Swap `a` and `b` to make `a` always bigger than `b` - var t = a; - a = b; - b = t; - } else if (r === 0 || b.cmpn(1) === 0) { - break; - } - - a.isub(b); - } while (true); - - return b.iushln(shift); - }; - - // Invert number in the field F(num) - BN.prototype.invm = function invm (num) { - return this.egcd(num).a.umod(num); - }; - - BN.prototype.isEven = function isEven () { - return (this.words[0] & 1) === 0; - }; - - BN.prototype.isOdd = function isOdd () { - return (this.words[0] & 1) === 1; - }; - - // And first word and num - BN.prototype.andln = function andln (num) { - return this.words[0] & num; - }; - - // Increment at the bit position in-line - BN.prototype.bincn = function bincn (bit) { - assert(typeof bit === 'number'); - var r = bit % 26; - var s = (bit - r) / 26; - var q = 1 << r; - - // Fast case: bit is much higher than all existing words - if (this.length <= s) { - this._expand(s + 1); - this.words[s] |= q; - return this; - } - - // Add bit and propagate, if needed - var carry = q; - for (var i = s; carry !== 0 && i < this.length; i++) { - var w = this.words[i] | 0; - w += carry; - carry = w >>> 26; - w &= 0x3ffffff; - this.words[i] = w; - } - if (carry !== 0) { - this.words[i] = carry; - this.length++; - } - return this; - }; - - BN.prototype.isZero = function isZero () { - return this.length === 1 && this.words[0] === 0; - }; - - BN.prototype.cmpn = function cmpn (num) { - var negative = num < 0; - - if (this.negative !== 0 && !negative) return -1; - if (this.negative === 0 && negative) return 1; - - this.strip(); - - var res; - if (this.length > 1) { - res = 1; - } else { - if (negative) { - num = -num; - } - - assert(num <= 0x3ffffff, 'Number is too big'); - - var w = this.words[0] | 0; - res = w === num ? 0 : w < num ? -1 : 1; - } - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Compare two numbers and return: - // 1 - if `this` > `num` - // 0 - if `this` == `num` - // -1 - if `this` < `num` - BN.prototype.cmp = function cmp (num) { - if (this.negative !== 0 && num.negative === 0) return -1; - if (this.negative === 0 && num.negative !== 0) return 1; - - var res = this.ucmp(num); - if (this.negative !== 0) return -res | 0; - return res; - }; - - // Unsigned comparison - BN.prototype.ucmp = function ucmp (num) { - // At this point both numbers have the same sign - if (this.length > num.length) return 1; - if (this.length < num.length) return -1; - - var res = 0; - for (var i = this.length - 1; i >= 0; i--) { - var a = this.words[i] | 0; - var b = num.words[i] | 0; - - if (a === b) continue; - if (a < b) { - res = -1; - } else if (a > b) { - res = 1; - } - break; - } - return res; - }; - - BN.prototype.gtn = function gtn (num) { - return this.cmpn(num) === 1; - }; - - BN.prototype.gt = function gt (num) { - return this.cmp(num) === 1; - }; - - BN.prototype.gten = function gten (num) { - return this.cmpn(num) >= 0; - }; - - BN.prototype.gte = function gte (num) { - return this.cmp(num) >= 0; - }; - - BN.prototype.ltn = function ltn (num) { - return this.cmpn(num) === -1; - }; - - BN.prototype.lt = function lt (num) { - return this.cmp(num) === -1; - }; - - BN.prototype.lten = function lten (num) { - return this.cmpn(num) <= 0; - }; - - BN.prototype.lte = function lte (num) { - return this.cmp(num) <= 0; - }; - - BN.prototype.eqn = function eqn (num) { - return this.cmpn(num) === 0; - }; - - BN.prototype.eq = function eq (num) { - return this.cmp(num) === 0; - }; - - // - // A reduce context, could be using montgomery or something better, depending - // on the `m` itself. - // - BN.red = function red (num) { - return new Red(num); - }; - - BN.prototype.toRed = function toRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - assert(this.negative === 0, 'red works only with positives'); - return ctx.convertTo(this)._forceRed(ctx); - }; - - BN.prototype.fromRed = function fromRed () { - assert(this.red, 'fromRed works only with numbers in reduction context'); - return this.red.convertFrom(this); - }; - - BN.prototype._forceRed = function _forceRed (ctx) { - this.red = ctx; - return this; - }; - - BN.prototype.forceRed = function forceRed (ctx) { - assert(!this.red, 'Already a number in reduction context'); - return this._forceRed(ctx); - }; - - BN.prototype.redAdd = function redAdd (num) { - assert(this.red, 'redAdd works only with red numbers'); - return this.red.add(this, num); - }; - - BN.prototype.redIAdd = function redIAdd (num) { - assert(this.red, 'redIAdd works only with red numbers'); - return this.red.iadd(this, num); - }; - - BN.prototype.redSub = function redSub (num) { - assert(this.red, 'redSub works only with red numbers'); - return this.red.sub(this, num); - }; - - BN.prototype.redISub = function redISub (num) { - assert(this.red, 'redISub works only with red numbers'); - return this.red.isub(this, num); - }; - - BN.prototype.redShl = function redShl (num) { - assert(this.red, 'redShl works only with red numbers'); - return this.red.shl(this, num); - }; - - BN.prototype.redMul = function redMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.mul(this, num); - }; - - BN.prototype.redIMul = function redIMul (num) { - assert(this.red, 'redMul works only with red numbers'); - this.red._verify2(this, num); - return this.red.imul(this, num); - }; - - BN.prototype.redSqr = function redSqr () { - assert(this.red, 'redSqr works only with red numbers'); - this.red._verify1(this); - return this.red.sqr(this); - }; - - BN.prototype.redISqr = function redISqr () { - assert(this.red, 'redISqr works only with red numbers'); - this.red._verify1(this); - return this.red.isqr(this); - }; - - // Square root over p - BN.prototype.redSqrt = function redSqrt () { - assert(this.red, 'redSqrt works only with red numbers'); - this.red._verify1(this); - return this.red.sqrt(this); - }; - - BN.prototype.redInvm = function redInvm () { - assert(this.red, 'redInvm works only with red numbers'); - this.red._verify1(this); - return this.red.invm(this); - }; - - // Return negative clone of `this` % `red modulo` - BN.prototype.redNeg = function redNeg () { - assert(this.red, 'redNeg works only with red numbers'); - this.red._verify1(this); - return this.red.neg(this); - }; - - BN.prototype.redPow = function redPow (num) { - assert(this.red && !num.red, 'redPow(normalNum)'); - this.red._verify1(this); - return this.red.pow(this, num); - }; - - // Prime numbers with efficient reduction - var primes = { - k256: null, - p224: null, - p192: null, - p25519: null - }; - - // Pseudo-Mersenne prime - function MPrime (name, p) { - // P = 2 ^ N - K - this.name = name; - this.p = new BN(p, 16); - this.n = this.p.bitLength(); - this.k = new BN(1).iushln(this.n).isub(this.p); - - this.tmp = this._tmp(); - } - - MPrime.prototype._tmp = function _tmp () { - var tmp = new BN(null); - tmp.words = new Array(Math.ceil(this.n / 13)); - return tmp; - }; - - MPrime.prototype.ireduce = function ireduce (num) { - // Assumes that `num` is less than `P^2` - // num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P) - var r = num; - var rlen; - - do { - this.split(r, this.tmp); - r = this.imulK(r); - r = r.iadd(this.tmp); - rlen = r.bitLength(); - } while (rlen > this.n); - - var cmp = rlen < this.n ? -1 : r.ucmp(this.p); - if (cmp === 0) { - r.words[0] = 0; - r.length = 1; - } else if (cmp > 0) { - r.isub(this.p); - } else { - r.strip(); - } - - return r; - }; - - MPrime.prototype.split = function split (input, out) { - input.iushrn(this.n, 0, out); - }; - - MPrime.prototype.imulK = function imulK (num) { - return num.imul(this.k); - }; - - function K256 () { - MPrime.call( - this, - 'k256', - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f'); - } - inherits(K256, MPrime); - - K256.prototype.split = function split (input, output) { - // 256 = 9 * 26 + 22 - var mask = 0x3fffff; - - var outLen = Math.min(input.length, 9); - for (var i = 0; i < outLen; i++) { - output.words[i] = input.words[i]; - } - output.length = outLen; - - if (input.length <= 9) { - input.words[0] = 0; - input.length = 1; - return; - } - - // Shift by 9 limbs - var prev = input.words[9]; - output.words[output.length++] = prev & mask; - - for (i = 10; i < input.length; i++) { - var next = input.words[i] | 0; - input.words[i - 10] = ((next & mask) << 4) | (prev >>> 22); - prev = next; - } - prev >>>= 22; - input.words[i - 10] = prev; - if (prev === 0 && input.length > 10) { - input.length -= 10; - } else { - input.length -= 9; - } - }; - - K256.prototype.imulK = function imulK (num) { - // K = 0x1000003d1 = [ 0x40, 0x3d1 ] - num.words[num.length] = 0; - num.words[num.length + 1] = 0; - num.length += 2; - - // bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390 - var lo = 0; - for (var i = 0; i < num.length; i++) { - var w = num.words[i] | 0; - lo += w * 0x3d1; - num.words[i] = lo & 0x3ffffff; - lo = w * 0x40 + ((lo / 0x4000000) | 0); - } - - // Fast length reduction - if (num.words[num.length - 1] === 0) { - num.length--; - if (num.words[num.length - 1] === 0) { - num.length--; - } - } - return num; - }; - - function P224 () { - MPrime.call( - this, - 'p224', - 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001'); - } - inherits(P224, MPrime); - - function P192 () { - MPrime.call( - this, - 'p192', - 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff'); - } - inherits(P192, MPrime); - - function P25519 () { - // 2 ^ 255 - 19 - MPrime.call( - this, - '25519', - '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed'); - } - inherits(P25519, MPrime); - - P25519.prototype.imulK = function imulK (num) { - // K = 0x13 - var carry = 0; - for (var i = 0; i < num.length; i++) { - var hi = (num.words[i] | 0) * 0x13 + carry; - var lo = hi & 0x3ffffff; - hi >>>= 26; - - num.words[i] = lo; - carry = hi; - } - if (carry !== 0) { - num.words[num.length++] = carry; - } - return num; - }; - - // Exported mostly for testing purposes, use plain name instead - BN._prime = function prime (name) { - // Cached version of prime - if (primes[name]) return primes[name]; - - var prime; - if (name === 'k256') { - prime = new K256(); - } else if (name === 'p224') { - prime = new P224(); - } else if (name === 'p192') { - prime = new P192(); - } else if (name === 'p25519') { - prime = new P25519(); - } else { - throw new Error('Unknown prime ' + name); - } - primes[name] = prime; - - return prime; - }; - - // - // Base reduction engine - // - function Red (m) { - if (typeof m === 'string') { - var prime = BN._prime(m); - this.m = prime.p; - this.prime = prime; - } else { - assert(m.gtn(1), 'modulus must be greater than 1'); - this.m = m; - this.prime = null; - } - } - - Red.prototype._verify1 = function _verify1 (a) { - assert(a.negative === 0, 'red works only with positives'); - assert(a.red, 'red works only with red numbers'); - }; - - Red.prototype._verify2 = function _verify2 (a, b) { - assert((a.negative | b.negative) === 0, 'red works only with positives'); - assert(a.red && a.red === b.red, - 'red works only with red numbers'); - }; - - Red.prototype.imod = function imod (a) { - if (this.prime) return this.prime.ireduce(a)._forceRed(this); - return a.umod(this.m)._forceRed(this); - }; - - Red.prototype.neg = function neg (a) { - if (a.isZero()) { - return a.clone(); - } - - return this.m.sub(a)._forceRed(this); - }; - - Red.prototype.add = function add (a, b) { - this._verify2(a, b); - - var res = a.add(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.iadd = function iadd (a, b) { - this._verify2(a, b); - - var res = a.iadd(b); - if (res.cmp(this.m) >= 0) { - res.isub(this.m); - } - return res; - }; - - Red.prototype.sub = function sub (a, b) { - this._verify2(a, b); - - var res = a.sub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res._forceRed(this); - }; - - Red.prototype.isub = function isub (a, b) { - this._verify2(a, b); - - var res = a.isub(b); - if (res.cmpn(0) < 0) { - res.iadd(this.m); - } - return res; - }; - - Red.prototype.shl = function shl (a, num) { - this._verify1(a); - return this.imod(a.ushln(num)); - }; - - Red.prototype.imul = function imul (a, b) { - this._verify2(a, b); - return this.imod(a.imul(b)); - }; - - Red.prototype.mul = function mul (a, b) { - this._verify2(a, b); - return this.imod(a.mul(b)); - }; - - Red.prototype.isqr = function isqr (a) { - return this.imul(a, a.clone()); - }; - - Red.prototype.sqr = function sqr (a) { - return this.mul(a, a); - }; - - Red.prototype.sqrt = function sqrt (a) { - if (a.isZero()) return a.clone(); - - var mod3 = this.m.andln(3); - assert(mod3 % 2 === 1); - - // Fast case - if (mod3 === 3) { - var pow = this.m.add(new BN(1)).iushrn(2); - return this.pow(a, pow); - } - - // Tonelli-Shanks algorithm (Totally unoptimized and slow) - // - // Find Q and S, that Q * 2 ^ S = (P - 1) - var q = this.m.subn(1); - var s = 0; - while (!q.isZero() && q.andln(1) === 0) { - s++; - q.iushrn(1); - } - assert(!q.isZero()); - - var one = new BN(1).toRed(this); - var nOne = one.redNeg(); - - // Find quadratic non-residue - // NOTE: Max is such because of generalized Riemann hypothesis. - var lpow = this.m.subn(1).iushrn(1); - var z = this.m.bitLength(); - z = new BN(2 * z * z).toRed(this); - - while (this.pow(z, lpow).cmp(nOne) !== 0) { - z.redIAdd(nOne); - } - - var c = this.pow(z, q); - var r = this.pow(a, q.addn(1).iushrn(1)); - var t = this.pow(a, q); - var m = s; - while (t.cmp(one) !== 0) { - var tmp = t; - for (var i = 0; tmp.cmp(one) !== 0; i++) { - tmp = tmp.redSqr(); - } - assert(i < m); - var b = this.pow(c, new BN(1).iushln(m - i - 1)); - - r = r.redMul(b); - c = b.redSqr(); - t = t.redMul(c); - m = i; - } - - return r; - }; - - Red.prototype.invm = function invm (a) { - var inv = a._invmp(this.m); - if (inv.negative !== 0) { - inv.negative = 0; - return this.imod(inv).redNeg(); - } else { - return this.imod(inv); - } - }; - - Red.prototype.pow = function pow (a, num) { - if (num.isZero()) return new BN(1).toRed(this); - if (num.cmpn(1) === 0) return a.clone(); - - var windowSize = 4; - var wnd = new Array(1 << windowSize); - wnd[0] = new BN(1).toRed(this); - wnd[1] = a; - for (var i = 2; i < wnd.length; i++) { - wnd[i] = this.mul(wnd[i - 1], a); - } - - var res = wnd[0]; - var current = 0; - var currentLen = 0; - var start = num.bitLength() % 26; - if (start === 0) { - start = 26; - } - - for (i = num.length - 1; i >= 0; i--) { - var word = num.words[i]; - for (var j = start - 1; j >= 0; j--) { - var bit = (word >> j) & 1; - if (res !== wnd[0]) { - res = this.sqr(res); - } - - if (bit === 0 && current === 0) { - currentLen = 0; - continue; - } - - current <<= 1; - current |= bit; - currentLen++; - if (currentLen !== windowSize && (i !== 0 || j !== 0)) continue; - - res = this.mul(res, wnd[current]); - currentLen = 0; - current = 0; - } - start = 26; - } - - return res; - }; - - Red.prototype.convertTo = function convertTo (num) { - var r = num.umod(this.m); - - return r === num ? r.clone() : r; - }; - - Red.prototype.convertFrom = function convertFrom (num) { - var res = num.clone(); - res.red = null; - return res; - }; - - // - // Montgomery method engine - // - - BN.mont = function mont (num) { - return new Mont(num); - }; - - function Mont (m) { - Red.call(this, m); - - this.shift = this.m.bitLength(); - if (this.shift % 26 !== 0) { - this.shift += 26 - (this.shift % 26); - } - - this.r = new BN(1).iushln(this.shift); - this.r2 = this.imod(this.r.sqr()); - this.rinv = this.r._invmp(this.m); - - this.minv = this.rinv.mul(this.r).isubn(1).div(this.m); - this.minv = this.minv.umod(this.r); - this.minv = this.r.sub(this.minv); - } - inherits(Mont, Red); - - Mont.prototype.convertTo = function convertTo (num) { - return this.imod(num.ushln(this.shift)); - }; - - Mont.prototype.convertFrom = function convertFrom (num) { - var r = this.imod(num.mul(this.rinv)); - r.red = null; - return r; - }; - - Mont.prototype.imul = function imul (a, b) { - if (a.isZero() || b.isZero()) { - a.words[0] = 0; - a.length = 1; - return a; - } - - var t = a.imul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.mul = function mul (a, b) { - if (a.isZero() || b.isZero()) return new BN(0)._forceRed(this); - - var t = a.mul(b); - var c = t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m); - var u = t.isub(c).iushrn(this.shift); - var res = u; - if (u.cmp(this.m) >= 0) { - res = u.isub(this.m); - } else if (u.cmpn(0) < 0) { - res = u.iadd(this.m); - } - - return res._forceRed(this); - }; - - Mont.prototype.invm = function invm (a) { - // (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R - var res = this.imod(a._invmp(this.m).mul(this.r2)); - return res._forceRed(this); - }; -})(typeof module === 'undefined' || module, this); - -},{"buffer":4}],3:[function(require,module,exports){ -(function (global){ -module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; } -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],4:[function(require,module,exports){ - -},{}],5:[function(require,module,exports){ -var __self__ = (function (root) { -function F() { -this.fetch = false; -this.DOMException = root.DOMException -} -F.prototype = root; -return new F(); -})(typeof self !== 'undefined' ? self : this); -(function(self) { - -var irrelevant = (function (exports) { - var support = { - searchParams: 'URLSearchParams' in self, - iterable: 'Symbol' in self && 'iterator' in Symbol, - blob: - 'FileReader' in self && - 'Blob' in self && - (function() { - try { - new Blob(); - return true - } catch (e) { - return false - } - })(), - formData: 'FormData' in self, - arrayBuffer: 'ArrayBuffer' in self - }; - - function isDataView(obj) { - return obj && DataView.prototype.isPrototypeOf(obj) - } - - if (support.arrayBuffer) { - var viewClasses = [ - '[object Int8Array]', - '[object Uint8Array]', - '[object Uint8ClampedArray]', - '[object Int16Array]', - '[object Uint16Array]', - '[object Int32Array]', - '[object Uint32Array]', - '[object Float32Array]', - '[object Float64Array]' - ]; - - var isArrayBufferView = - ArrayBuffer.isView || - function(obj) { - return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 - }; - } - - function normalizeName(name) { - if (typeof name !== 'string') { - name = String(name); - } - if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(name)) { - throw new TypeError('Invalid character in header field name') - } - return name.toLowerCase() - } - - function normalizeValue(value) { - if (typeof value !== 'string') { - value = String(value); - } - return value - } - - // Build a destructive iterator for the value list - function iteratorFor(items) { - var iterator = { - next: function() { - var value = items.shift(); - return {done: value === undefined, value: value} - } - }; - - if (support.iterable) { - iterator[Symbol.iterator] = function() { - return iterator - }; - } - - return iterator - } - - function Headers(headers) { - this.map = {}; - - if (headers instanceof Headers) { - headers.forEach(function(value, name) { - this.append(name, value); - }, this); - } else if (Array.isArray(headers)) { - headers.forEach(function(header) { - this.append(header[0], header[1]); - }, this); - } else if (headers) { - Object.getOwnPropertyNames(headers).forEach(function(name) { - this.append(name, headers[name]); - }, this); - } - } - - Headers.prototype.append = function(name, value) { - name = normalizeName(name); - value = normalizeValue(value); - var oldValue = this.map[name]; - this.map[name] = oldValue ? oldValue + ', ' + value : value; - }; - - Headers.prototype['delete'] = function(name) { - delete this.map[normalizeName(name)]; - }; - - Headers.prototype.get = function(name) { - name = normalizeName(name); - return this.has(name) ? this.map[name] : null - }; - - Headers.prototype.has = function(name) { - return this.map.hasOwnProperty(normalizeName(name)) - }; - - Headers.prototype.set = function(name, value) { - this.map[normalizeName(name)] = normalizeValue(value); - }; - - Headers.prototype.forEach = function(callback, thisArg) { - for (var name in this.map) { - if (this.map.hasOwnProperty(name)) { - callback.call(thisArg, this.map[name], name, this); - } - } - }; - - Headers.prototype.keys = function() { - var items = []; - this.forEach(function(value, name) { - items.push(name); - }); - return iteratorFor(items) - }; - - Headers.prototype.values = function() { - var items = []; - this.forEach(function(value) { - items.push(value); - }); - return iteratorFor(items) - }; - - Headers.prototype.entries = function() { - var items = []; - this.forEach(function(value, name) { - items.push([name, value]); - }); - return iteratorFor(items) - }; - - if (support.iterable) { - Headers.prototype[Symbol.iterator] = Headers.prototype.entries; - } - - function consumed(body) { - if (body.bodyUsed) { - return Promise.reject(new TypeError('Already read')) - } - body.bodyUsed = true; - } - - function fileReaderReady(reader) { - return new Promise(function(resolve, reject) { - reader.onload = function() { - resolve(reader.result); - }; - reader.onerror = function() { - reject(reader.error); - }; - }) - } - - function readBlobAsArrayBuffer(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsArrayBuffer(blob); - return promise - } - - function readBlobAsText(blob) { - var reader = new FileReader(); - var promise = fileReaderReady(reader); - reader.readAsText(blob); - return promise - } - - function readArrayBufferAsText(buf) { - var view = new Uint8Array(buf); - var chars = new Array(view.length); - - for (var i = 0; i < view.length; i++) { - chars[i] = String.fromCharCode(view[i]); - } - return chars.join('') - } - - function bufferClone(buf) { - if (buf.slice) { - return buf.slice(0) - } else { - var view = new Uint8Array(buf.byteLength); - view.set(new Uint8Array(buf)); - return view.buffer - } - } - - function Body() { - this.bodyUsed = false; - - this._initBody = function(body) { - this._bodyInit = body; - if (!body) { - this._bodyText = ''; - } else if (typeof body === 'string') { - this._bodyText = body; - } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { - this._bodyBlob = body; - } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { - this._bodyFormData = body; - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this._bodyText = body.toString(); - } else if (support.arrayBuffer && support.blob && isDataView(body)) { - this._bodyArrayBuffer = bufferClone(body.buffer); - // IE 10-11 can't handle a DataView body. - this._bodyInit = new Blob([this._bodyArrayBuffer]); - } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { - this._bodyArrayBuffer = bufferClone(body); - } else { - this._bodyText = body = Object.prototype.toString.call(body); - } - - if (!this.headers.get('content-type')) { - if (typeof body === 'string') { - this.headers.set('content-type', 'text/plain;charset=UTF-8'); - } else if (this._bodyBlob && this._bodyBlob.type) { - this.headers.set('content-type', this._bodyBlob.type); - } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { - this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); - } - } - }; - - if (support.blob) { - this.blob = function() { - var rejected = consumed(this); - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return Promise.resolve(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(new Blob([this._bodyArrayBuffer])) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as blob') - } else { - return Promise.resolve(new Blob([this._bodyText])) - } - }; - - this.arrayBuffer = function() { - if (this._bodyArrayBuffer) { - return consumed(this) || Promise.resolve(this._bodyArrayBuffer) - } else { - return this.blob().then(readBlobAsArrayBuffer) - } - }; - } - - this.text = function() { - var rejected = consumed(this); - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return readBlobAsText(this._bodyBlob) - } else if (this._bodyArrayBuffer) { - return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as text') - } else { - return Promise.resolve(this._bodyText) - } - }; - - if (support.formData) { - this.formData = function() { - return this.text().then(decode) - }; - } - - this.json = function() { - return this.text().then(JSON.parse) - }; - - return this - } - - // HTTP methods whose capitalization should be normalized - var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; - - function normalizeMethod(method) { - var upcased = method.toUpperCase(); - return methods.indexOf(upcased) > -1 ? upcased : method - } - - function Request(input, options) { - options = options || {}; - var body = options.body; - - if (input instanceof Request) { - if (input.bodyUsed) { - throw new TypeError('Already read') - } - this.url = input.url; - this.credentials = input.credentials; - if (!options.headers) { - this.headers = new Headers(input.headers); - } - this.method = input.method; - this.mode = input.mode; - this.signal = input.signal; - if (!body && input._bodyInit != null) { - body = input._bodyInit; - input.bodyUsed = true; - } - } else { - this.url = String(input); - } - - this.credentials = options.credentials || this.credentials || 'same-origin'; - if (options.headers || !this.headers) { - this.headers = new Headers(options.headers); - } - this.method = normalizeMethod(options.method || this.method || 'GET'); - this.mode = options.mode || this.mode || null; - this.signal = options.signal || this.signal; - this.referrer = null; - - if ((this.method === 'GET' || this.method === 'HEAD') && body) { - throw new TypeError('Body not allowed for GET or HEAD requests') - } - this._initBody(body); - } - - Request.prototype.clone = function() { - return new Request(this, {body: this._bodyInit}) - }; - - function decode(body) { - var form = new FormData(); - body - .trim() - .split('&') - .forEach(function(bytes) { - if (bytes) { - var split = bytes.split('='); - var name = split.shift().replace(/\+/g, ' '); - var value = split.join('=').replace(/\+/g, ' '); - form.append(decodeURIComponent(name), decodeURIComponent(value)); - } - }); - return form - } - - function parseHeaders(rawHeaders) { - var headers = new Headers(); - // Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space - // https://tools.ietf.org/html/rfc7230#section-3.2 - var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); - preProcessedHeaders.split(/\r?\n/).forEach(function(line) { - var parts = line.split(':'); - var key = parts.shift().trim(); - if (key) { - var value = parts.join(':').trim(); - headers.append(key, value); - } - }); - return headers - } - - Body.call(Request.prototype); - - function Response(bodyInit, options) { - if (!options) { - options = {}; - } - - this.type = 'default'; - this.status = options.status === undefined ? 200 : options.status; - this.ok = this.status >= 200 && this.status < 300; - this.statusText = 'statusText' in options ? options.statusText : 'OK'; - this.headers = new Headers(options.headers); - this.url = options.url || ''; - this._initBody(bodyInit); - } - - Body.call(Response.prototype); - - Response.prototype.clone = function() { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }) - }; - - Response.error = function() { - var response = new Response(null, {status: 0, statusText: ''}); - response.type = 'error'; - return response - }; - - var redirectStatuses = [301, 302, 303, 307, 308]; - - Response.redirect = function(url, status) { - if (redirectStatuses.indexOf(status) === -1) { - throw new RangeError('Invalid status code') - } - - return new Response(null, {status: status, headers: {location: url}}) - }; - - exports.DOMException = self.DOMException; - try { - new exports.DOMException(); - } catch (err) { - exports.DOMException = function(message, name) { - this.message = message; - this.name = name; - var error = Error(message); - this.stack = error.stack; - }; - exports.DOMException.prototype = Object.create(Error.prototype); - exports.DOMException.prototype.constructor = exports.DOMException; - } - - function fetch(input, init) { - return new Promise(function(resolve, reject) { - var request = new Request(input, init); - - if (request.signal && request.signal.aborted) { - return reject(new exports.DOMException('Aborted', 'AbortError')) - } - - var xhr = new XMLHttpRequest(); - - function abortXhr() { - xhr.abort(); - } - - xhr.onload = function() { - var options = { - status: xhr.status, - statusText: xhr.statusText, - headers: parseHeaders(xhr.getAllResponseHeaders() || '') - }; - options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); - var body = 'response' in xhr ? xhr.response : xhr.responseText; - resolve(new Response(body, options)); - }; - - xhr.onerror = function() { - reject(new TypeError('Network request failed')); - }; - - xhr.ontimeout = function() { - reject(new TypeError('Network request failed')); - }; - - xhr.onabort = function() { - reject(new exports.DOMException('Aborted', 'AbortError')); - }; - - xhr.open(request.method, request.url, true); - - if (request.credentials === 'include') { - xhr.withCredentials = true; - } else if (request.credentials === 'omit') { - xhr.withCredentials = false; - } - - if ('responseType' in xhr && support.blob) { - xhr.responseType = 'blob'; - } - - request.headers.forEach(function(value, name) { - xhr.setRequestHeader(name, value); - }); - - if (request.signal) { - request.signal.addEventListener('abort', abortXhr); - - xhr.onreadystatechange = function() { - // DONE (success or failure) - if (xhr.readyState === 4) { - request.signal.removeEventListener('abort', abortXhr); - } - }; - } - - xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); - }) - } - - fetch.polyfill = true; - - if (!self.fetch) { - self.fetch = fetch; - self.Headers = Headers; - self.Request = Request; - self.Response = Response; - } - - exports.Headers = Headers; - exports.Request = Request; - exports.Response = Response; - exports.fetch = fetch; - - return exports; - -}({})); -})(__self__); -delete __self__.fetch.polyfill -exports = __self__.fetch // To enable: import fetch from 'cross-fetch' -exports.default = __self__.fetch // For TypeScript consumers without esModuleInterop. -exports.fetch = __self__.fetch // To enable: import {fetch} from 'cross-fetch' -exports.Headers = __self__.Headers -exports.Request = __self__.Request -exports.Response = __self__.Response -module.exports = exports - -},{}],6:[function(require,module,exports){ -'use strict'; - -var elliptic = exports; - -elliptic.version = require('../package.json').version; -elliptic.utils = require('./elliptic/utils'); -elliptic.rand = require('brorand'); -elliptic.hmacDRBG = require('./elliptic/hmac-drbg'); -elliptic.curve = require('./elliptic/curve'); -elliptic.curves = require('./elliptic/curves'); - -// Protocols -elliptic.ec = require('./elliptic/ec'); -elliptic.eddsa = require('./elliptic/eddsa'); - -},{"../package.json":20,"./elliptic/curve":9,"./elliptic/curves":12,"./elliptic/ec":13,"./elliptic/eddsa":16,"./elliptic/hmac-drbg":17,"./elliptic/utils":19,"brorand":3}],7:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var getNAF = utils.getNAF; -var getJSF = utils.getJSF; -var assert = utils.assert; - -function BaseCurve(type, conf) { - this.type = type; - this.p = new BN(conf.p, 16); - - // Use Montgomery, when there is no fast reduction for the prime - this.red = conf.prime ? BN.red(conf.prime) : BN.mont(this.p); - - // Useful for many curves - this.zero = new BN(0).toRed(this.red); - this.one = new BN(1).toRed(this.red); - this.two = new BN(2).toRed(this.red); - - // Curve configuration, optional - this.n = conf.n && new BN(conf.n, 16); - this.g = conf.g && this.pointFromJSON(conf.g, conf.gRed); - - // Temporary arrays - this._wnafT1 = new Array(4); - this._wnafT2 = new Array(4); - this._wnafT3 = new Array(4); - this._wnafT4 = new Array(4); - - // Generalized Greg Maxwell's trick - var adjustCount = this.n && this.p.div(this.n); - if (!adjustCount || adjustCount.cmpn(100) > 0) { - this.redN = null; - } else { - this._maxwellTrick = true; - this.redN = this.n.toRed(this.red); - } -} -module.exports = BaseCurve; - -BaseCurve.prototype.point = function point() { - throw new Error('Not implemented'); -}; - -BaseCurve.prototype.validate = function validate() { - throw new Error('Not implemented'); -}; - -BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) { - assert(p.precomputed); - var doubles = p._getDoubles(); - - var naf = getNAF(k, 1); - var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1); - I /= 3; - - // Translate into more windowed form - var repr = []; - for (var j = 0; j < naf.length; j += doubles.step) { - var nafW = 0; - for (var k = j + doubles.step - 1; k >= j; k--) - nafW = (nafW << 1) + naf[k]; - repr.push(nafW); - } - - var a = this.jpoint(null, null, null); - var b = this.jpoint(null, null, null); - for (var i = I; i > 0; i--) { - for (var j = 0; j < repr.length; j++) { - var nafW = repr[j]; - if (nafW === i) - b = b.mixedAdd(doubles.points[j]); - else if (nafW === -i) - b = b.mixedAdd(doubles.points[j].neg()); - } - a = a.add(b); - } - return a.toP(); -}; - -BaseCurve.prototype._wnafMul = function _wnafMul(p, k) { - var w = 4; - - // Precompute window - var nafPoints = p._getNAFPoints(w); - w = nafPoints.wnd; - var wnd = nafPoints.points; - - // Get NAF form - var naf = getNAF(k, w); - - // Add `this`*(N+1) for every w-NAF index - var acc = this.jpoint(null, null, null); - for (var i = naf.length - 1; i >= 0; i--) { - // Count zeroes - for (var k = 0; i >= 0 && naf[i] === 0; i--) - k++; - if (i >= 0) - k++; - acc = acc.dblp(k); - - if (i < 0) - break; - var z = naf[i]; - assert(z !== 0); - if (p.type === 'affine') { - // J +- P - if (z > 0) - acc = acc.mixedAdd(wnd[(z - 1) >> 1]); - else - acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg()); - } else { - // J +- J - if (z > 0) - acc = acc.add(wnd[(z - 1) >> 1]); - else - acc = acc.add(wnd[(-z - 1) >> 1].neg()); - } - } - return p.type === 'affine' ? acc.toP() : acc; -}; - -BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW, - points, - coeffs, - len, - jacobianResult) { - var wndWidth = this._wnafT1; - var wnd = this._wnafT2; - var naf = this._wnafT3; - - // Fill all arrays - var max = 0; - for (var i = 0; i < len; i++) { - var p = points[i]; - var nafPoints = p._getNAFPoints(defW); - wndWidth[i] = nafPoints.wnd; - wnd[i] = nafPoints.points; - } - - // Comb small window NAFs - for (var i = len - 1; i >= 1; i -= 2) { - var a = i - 1; - var b = i; - if (wndWidth[a] !== 1 || wndWidth[b] !== 1) { - naf[a] = getNAF(coeffs[a], wndWidth[a]); - naf[b] = getNAF(coeffs[b], wndWidth[b]); - max = Math.max(naf[a].length, max); - max = Math.max(naf[b].length, max); - continue; - } - - var comb = [ - points[a], /* 1 */ - null, /* 3 */ - null, /* 5 */ - points[b] /* 7 */ - ]; - - // Try to avoid Projective points, if possible - if (points[a].y.cmp(points[b].y) === 0) { - comb[1] = points[a].add(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } else if (points[a].y.cmp(points[b].y.redNeg()) === 0) { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].add(points[b].neg()); - } else { - comb[1] = points[a].toJ().mixedAdd(points[b]); - comb[2] = points[a].toJ().mixedAdd(points[b].neg()); - } - - var index = [ - -3, /* -1 -1 */ - -1, /* -1 0 */ - -5, /* -1 1 */ - -7, /* 0 -1 */ - 0, /* 0 0 */ - 7, /* 0 1 */ - 5, /* 1 -1 */ - 1, /* 1 0 */ - 3 /* 1 1 */ - ]; - - var jsf = getJSF(coeffs[a], coeffs[b]); - max = Math.max(jsf[0].length, max); - naf[a] = new Array(max); - naf[b] = new Array(max); - for (var j = 0; j < max; j++) { - var ja = jsf[0][j] | 0; - var jb = jsf[1][j] | 0; - - naf[a][j] = index[(ja + 1) * 3 + (jb + 1)]; - naf[b][j] = 0; - wnd[a] = comb; - } - } - - var acc = this.jpoint(null, null, null); - var tmp = this._wnafT4; - for (var i = max; i >= 0; i--) { - var k = 0; - - while (i >= 0) { - var zero = true; - for (var j = 0; j < len; j++) { - tmp[j] = naf[j][i] | 0; - if (tmp[j] !== 0) - zero = false; - } - if (!zero) - break; - k++; - i--; - } - if (i >= 0) - k++; - acc = acc.dblp(k); - if (i < 0) - break; - - for (var j = 0; j < len; j++) { - var z = tmp[j]; - var p; - if (z === 0) - continue; - else if (z > 0) - p = wnd[j][(z - 1) >> 1]; - else if (z < 0) - p = wnd[j][(-z - 1) >> 1].neg(); - - if (p.type === 'affine') - acc = acc.mixedAdd(p); - else - acc = acc.add(p); - } - } - // Zeroify references - for (var i = 0; i < len; i++) - wnd[i] = null; - - if (jacobianResult) - return acc; - else - return acc.toP(); -}; - -function BasePoint(curve, type) { - this.curve = curve; - this.type = type; - this.precomputed = null; -} -BaseCurve.BasePoint = BasePoint; - -BasePoint.prototype.eq = function eq(/*other*/) { - throw new Error('Not implemented'); -}; - -BasePoint.prototype.validate = function validate() { - return this.curve.validate(this); -}; - -BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) { - bytes = utils.toArray(bytes, enc); - - var len = this.p.byteLength(); - - // uncompressed, hybrid-odd, hybrid-even - if ((bytes[0] === 0x04 || bytes[0] === 0x06 || bytes[0] === 0x07) && - bytes.length - 1 === 2 * len) { - if (bytes[0] === 0x06) - assert(bytes[bytes.length - 1] % 2 === 0); - else if (bytes[0] === 0x07) - assert(bytes[bytes.length - 1] % 2 === 1); - - var res = this.point(bytes.slice(1, 1 + len), - bytes.slice(1 + len, 1 + 2 * len)); - - return res; - } else if ((bytes[0] === 0x02 || bytes[0] === 0x03) && - bytes.length - 1 === len) { - return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03); - } - throw new Error('Unknown point format'); -}; - -BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) { - return this.encode(enc, true); -}; - -BasePoint.prototype._encode = function _encode(compact) { - var len = this.curve.p.byteLength(); - var x = this.getX().toArray('be', len); - - if (compact) - return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x); - - return [ 0x04 ].concat(x, this.getY().toArray('be', len)) ; -}; - -BasePoint.prototype.encode = function encode(enc, compact) { - return utils.encode(this._encode(compact), enc); -}; - -BasePoint.prototype.precompute = function precompute(power) { - if (this.precomputed) - return this; - - var precomputed = { - doubles: null, - naf: null, - beta: null - }; - precomputed.naf = this._getNAFPoints(8); - precomputed.doubles = this._getDoubles(4, power); - precomputed.beta = this._getBeta(); - this.precomputed = precomputed; - - return this; -}; - -BasePoint.prototype._hasDoubles = function _hasDoubles(k) { - if (!this.precomputed) - return false; - - var doubles = this.precomputed.doubles; - if (!doubles) - return false; - - return doubles.points.length >= Math.ceil((k.bitLength() + 1) / doubles.step); -}; - -BasePoint.prototype._getDoubles = function _getDoubles(step, power) { - if (this.precomputed && this.precomputed.doubles) - return this.precomputed.doubles; - - var doubles = [ this ]; - var acc = this; - for (var i = 0; i < power; i += step) { - for (var j = 0; j < step; j++) - acc = acc.dbl(); - doubles.push(acc); - } - return { - step: step, - points: doubles - }; -}; - -BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) { - if (this.precomputed && this.precomputed.naf) - return this.precomputed.naf; - - var res = [ this ]; - var max = (1 << wnd) - 1; - var dbl = max === 1 ? null : this.dbl(); - for (var i = 1; i < max; i++) - res[i] = res[i - 1].add(dbl); - return { - wnd: wnd, - points: res - }; -}; - -BasePoint.prototype._getBeta = function _getBeta() { - return null; -}; - -BasePoint.prototype.dblp = function dblp(k) { - var r = this; - for (var i = 0; i < k; i++) - r = r.dbl(); - return r; -}; - -},{"../../elliptic":6,"bn.js":2}],8:[function(require,module,exports){ -module.exports = {}; -},{}],9:[function(require,module,exports){ -'use strict'; - -var curve = exports; - -curve.base = require('./base'); -curve.short = require('./short'); -curve.mont = require('./mont'); -curve.edwards = require('./edwards'); - -},{"./base":7,"./edwards":8,"./mont":10,"./short":11}],10:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],11:[function(require,module,exports){ -'use strict'; - -var curve = require('../curve'); -var elliptic = require('../../elliptic'); -var BN = require('bn.js'); -var inherits = require('inherits'); -var Base = curve.base; - -var assert = elliptic.utils.assert; - -function ShortCurve(conf) { - Base.call(this, 'short', conf); - - this.a = new BN(conf.a, 16).toRed(this.red); - this.b = new BN(conf.b, 16).toRed(this.red); - this.tinv = this.two.redInvm(); - - this.zeroA = this.a.fromRed().cmpn(0) === 0; - this.threeA = this.a.fromRed().sub(this.p).cmpn(-3) === 0; - - // If the curve is endomorphic, precalculate beta and lambda - this.endo = this._getEndomorphism(conf); - this._endoWnafT1 = new Array(4); - this._endoWnafT2 = new Array(4); -} -inherits(ShortCurve, Base); -module.exports = ShortCurve; - -ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) { - // No efficient endomorphism - if (!this.zeroA || !this.g || !this.n || this.p.modn(3) !== 1) - return; - - // Compute beta and lambda, that lambda * P = (beta * Px; Py) - var beta; - var lambda; - if (conf.beta) { - beta = new BN(conf.beta, 16).toRed(this.red); - } else { - var betas = this._getEndoRoots(this.p); - // Choose the smallest beta - beta = betas[0].cmp(betas[1]) < 0 ? betas[0] : betas[1]; - beta = beta.toRed(this.red); - } - if (conf.lambda) { - lambda = new BN(conf.lambda, 16); - } else { - // Choose the lambda that is matching selected beta - var lambdas = this._getEndoRoots(this.n); - if (this.g.mul(lambdas[0]).x.cmp(this.g.x.redMul(beta)) === 0) { - lambda = lambdas[0]; - } else { - lambda = lambdas[1]; - assert(this.g.mul(lambda).x.cmp(this.g.x.redMul(beta)) === 0); - } - } - - // Get basis vectors, used for balanced length-two representation - var basis; - if (conf.basis) { - basis = conf.basis.map(function(vec) { - return { - a: new BN(vec.a, 16), - b: new BN(vec.b, 16) - }; - }); - } else { - basis = this._getEndoBasis(lambda); - } - - return { - beta: beta, - lambda: lambda, - basis: basis - }; -}; - -ShortCurve.prototype._getEndoRoots = function _getEndoRoots(num) { - // Find roots of for x^2 + x + 1 in F - // Root = (-1 +- Sqrt(-3)) / 2 - // - var red = num === this.p ? this.red : BN.mont(num); - var tinv = new BN(2).toRed(red).redInvm(); - var ntinv = tinv.redNeg(); - - var s = new BN(3).toRed(red).redNeg().redSqrt().redMul(tinv); - - var l1 = ntinv.redAdd(s).fromRed(); - var l2 = ntinv.redSub(s).fromRed(); - return [ l1, l2 ]; -}; - -ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) { - // aprxSqrt >= sqrt(this.n) - var aprxSqrt = this.n.ushrn(Math.floor(this.n.bitLength() / 2)); - - // 3.74 - // Run EGCD, until r(L + 1) < aprxSqrt - var u = lambda; - var v = this.n.clone(); - var x1 = new BN(1); - var y1 = new BN(0); - var x2 = new BN(0); - var y2 = new BN(1); - - // NOTE: all vectors are roots of: a + b * lambda = 0 (mod n) - var a0; - var b0; - // First vector - var a1; - var b1; - // Second vector - var a2; - var b2; - - var prevR; - var i = 0; - var r; - var x; - while (u.cmpn(0) !== 0) { - var q = v.div(u); - r = v.sub(q.mul(u)); - x = x2.sub(q.mul(x1)); - var y = y2.sub(q.mul(y1)); - - if (!a1 && r.cmp(aprxSqrt) < 0) { - a0 = prevR.neg(); - b0 = x1; - a1 = r.neg(); - b1 = x; - } else if (a1 && ++i === 2) { - break; - } - prevR = r; - - v = u; - u = r; - x2 = x1; - x1 = x; - y2 = y1; - y1 = y; - } - a2 = r.neg(); - b2 = x; - - var len1 = a1.sqr().add(b1.sqr()); - var len2 = a2.sqr().add(b2.sqr()); - if (len2.cmp(len1) >= 0) { - a2 = a0; - b2 = b0; - } - - // Normalize signs - if (a1.negative) { - a1 = a1.neg(); - b1 = b1.neg(); - } - if (a2.negative) { - a2 = a2.neg(); - b2 = b2.neg(); - } - - return [ - { a: a1, b: b1 }, - { a: a2, b: b2 } - ]; -}; - -ShortCurve.prototype._endoSplit = function _endoSplit(k) { - var basis = this.endo.basis; - var v1 = basis[0]; - var v2 = basis[1]; - - var c1 = v2.b.mul(k).divRound(this.n); - var c2 = v1.b.neg().mul(k).divRound(this.n); - - var p1 = c1.mul(v1.a); - var p2 = c2.mul(v2.a); - var q1 = c1.mul(v1.b); - var q2 = c2.mul(v2.b); - - // Calculate answer - var k1 = k.sub(p1).sub(p2); - var k2 = q1.add(q2).neg(); - return { k1: k1, k2: k2 }; -}; - -ShortCurve.prototype.pointFromX = function pointFromX(x, odd) { - x = new BN(x, 16); - if (!x.red) - x = x.toRed(this.red); - - var y2 = x.redSqr().redMul(x).redIAdd(x.redMul(this.a)).redIAdd(this.b); - var y = y2.redSqrt(); - if (y.redSqr().redSub(y2).cmp(this.zero) !== 0) - throw new Error('invalid point'); - - // XXX Is there any way to tell if the number is odd without converting it - // to non-red form? - var isOdd = y.fromRed().isOdd(); - if (odd && !isOdd || !odd && isOdd) - y = y.redNeg(); - - return this.point(x, y); -}; - -ShortCurve.prototype.validate = function validate(point) { - if (point.inf) - return true; - - var x = point.x; - var y = point.y; - - var ax = this.a.redMul(x); - var rhs = x.redSqr().redMul(x).redIAdd(ax).redIAdd(this.b); - return y.redSqr().redISub(rhs).cmpn(0) === 0; -}; - -ShortCurve.prototype._endoWnafMulAdd = - function _endoWnafMulAdd(points, coeffs, jacobianResult) { - var npoints = this._endoWnafT1; - var ncoeffs = this._endoWnafT2; - for (var i = 0; i < points.length; i++) { - var split = this._endoSplit(coeffs[i]); - var p = points[i]; - var beta = p._getBeta(); - - if (split.k1.negative) { - split.k1.ineg(); - p = p.neg(true); - } - if (split.k2.negative) { - split.k2.ineg(); - beta = beta.neg(true); - } - - npoints[i * 2] = p; - npoints[i * 2 + 1] = beta; - ncoeffs[i * 2] = split.k1; - ncoeffs[i * 2 + 1] = split.k2; - } - var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult); - - // Clean-up references to points and coefficients - for (var j = 0; j < i * 2; j++) { - npoints[j] = null; - ncoeffs[j] = null; - } - return res; -}; - -function Point(curve, x, y, isRed) { - Base.BasePoint.call(this, curve, 'affine'); - if (x === null && y === null) { - this.x = null; - this.y = null; - this.inf = true; - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - // Force redgomery representation when loading from JSON - if (isRed) { - this.x.forceRed(this.curve.red); - this.y.forceRed(this.curve.red); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - this.inf = false; - } -} -inherits(Point, Base.BasePoint); - -ShortCurve.prototype.point = function point(x, y, isRed) { - return new Point(this, x, y, isRed); -}; - -ShortCurve.prototype.pointFromJSON = function pointFromJSON(obj, red) { - return Point.fromJSON(this, obj, red); -}; - -Point.prototype._getBeta = function _getBeta() { - if (!this.curve.endo) - return; - - var pre = this.precomputed; - if (pre && pre.beta) - return pre.beta; - - var beta = this.curve.point(this.x.redMul(this.curve.endo.beta), this.y); - if (pre) { - var curve = this.curve; - var endoMul = function(p) { - return curve.point(p.x.redMul(curve.endo.beta), p.y); - }; - pre.beta = beta; - beta.precomputed = { - beta: null, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(endoMul) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(endoMul) - } - }; - } - return beta; -}; - -Point.prototype.toJSON = function toJSON() { - if (!this.precomputed) - return [ this.x, this.y ]; - - return [ this.x, this.y, this.precomputed && { - doubles: this.precomputed.doubles && { - step: this.precomputed.doubles.step, - points: this.precomputed.doubles.points.slice(1) - }, - naf: this.precomputed.naf && { - wnd: this.precomputed.naf.wnd, - points: this.precomputed.naf.points.slice(1) - } - } ]; -}; - -Point.fromJSON = function fromJSON(curve, obj, red) { - if (typeof obj === 'string') - obj = JSON.parse(obj); - var res = curve.point(obj[0], obj[1], red); - if (!obj[2]) - return res; - - function obj2point(obj) { - return curve.point(obj[0], obj[1], red); - } - - var pre = obj[2]; - res.precomputed = { - beta: null, - doubles: pre.doubles && { - step: pre.doubles.step, - points: [ res ].concat(pre.doubles.points.map(obj2point)) - }, - naf: pre.naf && { - wnd: pre.naf.wnd, - points: [ res ].concat(pre.naf.points.map(obj2point)) - } - }; - return res; -}; - -Point.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -Point.prototype.isInfinity = function isInfinity() { - return this.inf; -}; - -Point.prototype.add = function add(p) { - // O + P = P - if (this.inf) - return p; - - // P + O = P - if (p.inf) - return this; - - // P + P = 2P - if (this.eq(p)) - return this.dbl(); - - // P + (-P) = O - if (this.neg().eq(p)) - return this.curve.point(null, null); - - // P + Q = O - if (this.x.cmp(p.x) === 0) - return this.curve.point(null, null); - - var c = this.y.redSub(p.y); - if (c.cmpn(0) !== 0) - c = c.redMul(this.x.redSub(p.x).redInvm()); - var nx = c.redSqr().redISub(this.x).redISub(p.x); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; - -Point.prototype.dbl = function dbl() { - if (this.inf) - return this; - - // 2P = O - var ys1 = this.y.redAdd(this.y); - if (ys1.cmpn(0) === 0) - return this.curve.point(null, null); - - var a = this.curve.a; - - var x2 = this.x.redSqr(); - var dyinv = ys1.redInvm(); - var c = x2.redAdd(x2).redIAdd(x2).redIAdd(a).redMul(dyinv); - - var nx = c.redSqr().redISub(this.x.redAdd(this.x)); - var ny = c.redMul(this.x.redSub(nx)).redISub(this.y); - return this.curve.point(nx, ny); -}; - -Point.prototype.getX = function getX() { - return this.x.fromRed(); -}; - -Point.prototype.getY = function getY() { - return this.y.fromRed(); -}; - -Point.prototype.mul = function mul(k) { - k = new BN(k, 16); - - if (this._hasDoubles(k)) - return this.curve._fixedNafMul(this, k); - else if (this.curve.endo) - return this.curve._endoWnafMulAdd([ this ], [ k ]); - else - return this.curve._wnafMul(this, k); -}; - -Point.prototype.mulAdd = function mulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2); -}; - -Point.prototype.jmulAdd = function jmulAdd(k1, p2, k2) { - var points = [ this, p2 ]; - var coeffs = [ k1, k2 ]; - if (this.curve.endo) - return this.curve._endoWnafMulAdd(points, coeffs, true); - else - return this.curve._wnafMulAdd(1, points, coeffs, 2, true); -}; - -Point.prototype.eq = function eq(p) { - return this === p || - this.inf === p.inf && - (this.inf || this.x.cmp(p.x) === 0 && this.y.cmp(p.y) === 0); -}; - -Point.prototype.neg = function neg(_precompute) { - if (this.inf) - return this; - - var res = this.curve.point(this.x, this.y.redNeg()); - if (_precompute && this.precomputed) { - var pre = this.precomputed; - var negate = function(p) { - return p.neg(); - }; - res.precomputed = { - naf: pre.naf && { - wnd: pre.naf.wnd, - points: pre.naf.points.map(negate) - }, - doubles: pre.doubles && { - step: pre.doubles.step, - points: pre.doubles.points.map(negate) - } - }; - } - return res; -}; - -Point.prototype.toJ = function toJ() { - if (this.inf) - return this.curve.jpoint(null, null, null); - - var res = this.curve.jpoint(this.x, this.y, this.curve.one); - return res; -}; - -function JPoint(curve, x, y, z) { - Base.BasePoint.call(this, curve, 'jacobian'); - if (x === null && y === null && z === null) { - this.x = this.curve.one; - this.y = this.curve.one; - this.z = new BN(0); - } else { - this.x = new BN(x, 16); - this.y = new BN(y, 16); - this.z = new BN(z, 16); - } - if (!this.x.red) - this.x = this.x.toRed(this.curve.red); - if (!this.y.red) - this.y = this.y.toRed(this.curve.red); - if (!this.z.red) - this.z = this.z.toRed(this.curve.red); - - this.zOne = this.z === this.curve.one; -} -inherits(JPoint, Base.BasePoint); - -ShortCurve.prototype.jpoint = function jpoint(x, y, z) { - return new JPoint(this, x, y, z); -}; - -JPoint.prototype.toP = function toP() { - if (this.isInfinity()) - return this.curve.point(null, null); - - var zinv = this.z.redInvm(); - var zinv2 = zinv.redSqr(); - var ax = this.x.redMul(zinv2); - var ay = this.y.redMul(zinv2).redMul(zinv); - - return this.curve.point(ax, ay); -}; - -JPoint.prototype.neg = function neg() { - return this.curve.jpoint(this.x, this.y.redNeg(), this.z); -}; - -JPoint.prototype.add = function add(p) { - // O + P = P - if (this.isInfinity()) - return p; - - // P + O = P - if (p.isInfinity()) - return this; - - // 12M + 4S + 7A - var pz2 = p.z.redSqr(); - var z2 = this.z.redSqr(); - var u1 = this.x.redMul(pz2); - var u2 = p.x.redMul(z2); - var s1 = this.y.redMul(pz2.redMul(p.z)); - var s2 = p.y.redMul(z2.redMul(this.z)); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } - - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); - - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(p.z).redMul(h); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.mixedAdd = function mixedAdd(p) { - // O + P = P - if (this.isInfinity()) - return p.toJ(); - - // P + O = P - if (p.isInfinity()) - return this; - - // 8M + 3S + 7A - var z2 = this.z.redSqr(); - var u1 = this.x; - var u2 = p.x.redMul(z2); - var s1 = this.y; - var s2 = p.y.redMul(z2).redMul(this.z); - - var h = u1.redSub(u2); - var r = s1.redSub(s2); - if (h.cmpn(0) === 0) { - if (r.cmpn(0) !== 0) - return this.curve.jpoint(null, null, null); - else - return this.dbl(); - } - - var h2 = h.redSqr(); - var h3 = h2.redMul(h); - var v = u1.redMul(h2); - - var nx = r.redSqr().redIAdd(h3).redISub(v).redISub(v); - var ny = r.redMul(v.redISub(nx)).redISub(s1.redMul(h3)); - var nz = this.z.redMul(h); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.dblp = function dblp(pow) { - if (pow === 0) - return this; - if (this.isInfinity()) - return this; - if (!pow) - return this.dbl(); - - if (this.curve.zeroA || this.curve.threeA) { - var r = this; - for (var i = 0; i < pow; i++) - r = r.dbl(); - return r; - } - - // 1M + 2S + 1A + N * (4S + 5M + 8A) - // N = 1 => 6M + 6S + 9A - var a = this.curve.a; - var tinv = this.curve.tinv; - - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); - - // Reuse results - var jyd = jy.redAdd(jy); - for (var i = 0; i < pow; i++) { - var jx2 = jx.redSqr(); - var jyd2 = jyd.redSqr(); - var jyd4 = jyd2.redSqr(); - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - - var t1 = jx.redMul(jyd2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - var dny = c.redMul(t2); - dny = dny.redIAdd(dny).redISub(jyd4); - var nz = jyd.redMul(jz); - if (i + 1 < pow) - jz4 = jz4.redMul(jyd4); - - jx = nx; - jz = nz; - jyd = dny; - } - - return this.curve.jpoint(jx, jyd.redMul(tinv), jz); -}; - -JPoint.prototype.dbl = function dbl() { - if (this.isInfinity()) - return this; - - if (this.curve.zeroA) - return this._zeroDbl(); - else if (this.curve.threeA) - return this._threeDbl(); - else - return this._dbl(); -}; - -JPoint.prototype._zeroDbl = function _zeroDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 14A - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // T = M ^ 2 - 2*S - var t = m.redSqr().redISub(s).redISub(s); - - // 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2*Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html - // #doubling-dbl-2009-l - // 2M + 5S + 13A - - // A = X1^2 - var a = this.x.redSqr(); - // B = Y1^2 - var b = this.y.redSqr(); - // C = B^2 - var c = b.redSqr(); - // D = 2 * ((X1 + B)^2 - A - C) - var d = this.x.redAdd(b).redSqr().redISub(a).redISub(c); - d = d.redIAdd(d); - // E = 3 * A - var e = a.redAdd(a).redIAdd(a); - // F = E^2 - var f = e.redSqr(); - - // 8 * C - var c8 = c.redIAdd(c); - c8 = c8.redIAdd(c8); - c8 = c8.redIAdd(c8); - - // X3 = F - 2 * D - nx = f.redISub(d).redISub(d); - // Y3 = E * (D - X3) - 8 * C - ny = e.redMul(d.redISub(nx)).redISub(c8); - // Z3 = 2 * Y1 * Z1 - nz = this.y.redMul(this.z); - nz = nz.redIAdd(nz); - } - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype._threeDbl = function _threeDbl() { - var nx; - var ny; - var nz; - // Z = 1 - if (this.zOne) { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html - // #doubling-mdbl-2007-bl - // 1M + 5S + 15A - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // S = 2 * ((X1 + YY)^2 - XX - YYYY) - var s = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - s = s.redIAdd(s); - // M = 3 * XX + a - var m = xx.redAdd(xx).redIAdd(xx).redIAdd(this.curve.a); - // T = M^2 - 2 * S - var t = m.redSqr().redISub(s).redISub(s); - // X3 = T - nx = t; - // Y3 = M * (S - T) - 8 * YYYY - var yyyy8 = yyyy.redIAdd(yyyy); - yyyy8 = yyyy8.redIAdd(yyyy8); - yyyy8 = yyyy8.redIAdd(yyyy8); - ny = m.redMul(s.redISub(t)).redISub(yyyy8); - // Z3 = 2 * Y1 - nz = this.y.redAdd(this.y); - } else { - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-3.html#doubling-dbl-2001-b - // 3M + 5S - - // delta = Z1^2 - var delta = this.z.redSqr(); - // gamma = Y1^2 - var gamma = this.y.redSqr(); - // beta = X1 * gamma - var beta = this.x.redMul(gamma); - // alpha = 3 * (X1 - delta) * (X1 + delta) - var alpha = this.x.redSub(delta).redMul(this.x.redAdd(delta)); - alpha = alpha.redAdd(alpha).redIAdd(alpha); - // X3 = alpha^2 - 8 * beta - var beta4 = beta.redIAdd(beta); - beta4 = beta4.redIAdd(beta4); - var beta8 = beta4.redAdd(beta4); - nx = alpha.redSqr().redISub(beta8); - // Z3 = (Y1 + Z1)^2 - gamma - delta - nz = this.y.redAdd(this.z).redSqr().redISub(gamma).redISub(delta); - // Y3 = alpha * (4 * beta - X3) - 8 * gamma^2 - var ggamma8 = gamma.redSqr(); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ggamma8 = ggamma8.redIAdd(ggamma8); - ny = alpha.redMul(beta4.redISub(nx)).redISub(ggamma8); - } - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype._dbl = function _dbl() { - var a = this.curve.a; - - // 4M + 6S + 10A - var jx = this.x; - var jy = this.y; - var jz = this.z; - var jz4 = jz.redSqr().redSqr(); - - var jx2 = jx.redSqr(); - var jy2 = jy.redSqr(); - - var c = jx2.redAdd(jx2).redIAdd(jx2).redIAdd(a.redMul(jz4)); - - var jxd4 = jx.redAdd(jx); - jxd4 = jxd4.redIAdd(jxd4); - var t1 = jxd4.redMul(jy2); - var nx = c.redSqr().redISub(t1.redAdd(t1)); - var t2 = t1.redISub(nx); - - var jyd8 = jy2.redSqr(); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - jyd8 = jyd8.redIAdd(jyd8); - var ny = c.redMul(t2).redISub(jyd8); - var nz = jy.redAdd(jy).redMul(jz); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.trpl = function trpl() { - if (!this.curve.zeroA) - return this.dbl().add(this); - - // hyperelliptic.org/EFD/g1p/auto-shortw-jacobian-0.html#tripling-tpl-2007-bl - // 5M + 10S + ... - - // XX = X1^2 - var xx = this.x.redSqr(); - // YY = Y1^2 - var yy = this.y.redSqr(); - // ZZ = Z1^2 - var zz = this.z.redSqr(); - // YYYY = YY^2 - var yyyy = yy.redSqr(); - // M = 3 * XX + a * ZZ2; a = 0 - var m = xx.redAdd(xx).redIAdd(xx); - // MM = M^2 - var mm = m.redSqr(); - // E = 6 * ((X1 + YY)^2 - XX - YYYY) - MM - var e = this.x.redAdd(yy).redSqr().redISub(xx).redISub(yyyy); - e = e.redIAdd(e); - e = e.redAdd(e).redIAdd(e); - e = e.redISub(mm); - // EE = E^2 - var ee = e.redSqr(); - // T = 16*YYYY - var t = yyyy.redIAdd(yyyy); - t = t.redIAdd(t); - t = t.redIAdd(t); - t = t.redIAdd(t); - // U = (M + E)^2 - MM - EE - T - var u = m.redIAdd(e).redSqr().redISub(mm).redISub(ee).redISub(t); - // X3 = 4 * (X1 * EE - 4 * YY * U) - var yyu4 = yy.redMul(u); - yyu4 = yyu4.redIAdd(yyu4); - yyu4 = yyu4.redIAdd(yyu4); - var nx = this.x.redMul(ee).redISub(yyu4); - nx = nx.redIAdd(nx); - nx = nx.redIAdd(nx); - // Y3 = 8 * Y1 * (U * (T - U) - E * EE) - var ny = this.y.redMul(u.redMul(t.redISub(u)).redISub(e.redMul(ee))); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - ny = ny.redIAdd(ny); - // Z3 = (Z1 + E)^2 - ZZ - EE - var nz = this.z.redAdd(e).redSqr().redISub(zz).redISub(ee); - - return this.curve.jpoint(nx, ny, nz); -}; - -JPoint.prototype.mul = function mul(k, kbase) { - k = new BN(k, kbase); - - return this.curve._wnafMul(this, k); -}; - -JPoint.prototype.eq = function eq(p) { - if (p.type === 'affine') - return this.eq(p.toJ()); - - if (this === p) - return true; - - // x1 * z2^2 == x2 * z1^2 - var z2 = this.z.redSqr(); - var pz2 = p.z.redSqr(); - if (this.x.redMul(pz2).redISub(p.x.redMul(z2)).cmpn(0) !== 0) - return false; - - // y1 * z2^3 == y2 * z1^3 - var z3 = z2.redMul(this.z); - var pz3 = pz2.redMul(p.z); - return this.y.redMul(pz3).redISub(p.y.redMul(z3)).cmpn(0) === 0; -}; - -JPoint.prototype.eqXToP = function eqXToP(x) { - var zs = this.z.redSqr(); - var rx = x.toRed(this.curve.red).redMul(zs); - if (this.x.cmp(rx) === 0) - return true; - - var xc = x.clone(); - var t = this.curve.redN.redMul(zs); - for (;;) { - xc.iadd(this.curve.n); - if (xc.cmp(this.curve.p) >= 0) - return false; - - rx.redIAdd(t); - if (this.x.cmp(rx) === 0) - return true; - } - return false; -}; - -JPoint.prototype.inspect = function inspect() { - if (this.isInfinity()) - return ''; - return ''; -}; - -JPoint.prototype.isInfinity = function isInfinity() { - // XXX This code assumes that zero is always zero in red - return this.z.cmpn(0) === 0; -}; - -},{"../../elliptic":6,"../curve":9,"bn.js":2,"inherits":33}],12:[function(require,module,exports){ -'use strict'; - -var curves = exports; - -var hash = require('hash.js'); -var elliptic = require('../elliptic'); - -var assert = elliptic.utils.assert; - -function PresetCurve(options) { - if (options.type === 'short') - this.curve = new elliptic.curve.short(options); - else if (options.type === 'edwards') - this.curve = new elliptic.curve.edwards(options); - else - this.curve = new elliptic.curve.mont(options); - this.g = this.curve.g; - this.n = this.curve.n; - this.hash = options.hash; - - assert(this.g.validate(), 'Invalid curve'); - assert(this.g.mul(this.n).isInfinity(), 'Invalid curve, G*N != O'); -} -curves.PresetCurve = PresetCurve; - -function defineCurve(name, options) { - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - get: function() { - var curve = new PresetCurve(options); - Object.defineProperty(curves, name, { - configurable: true, - enumerable: true, - value: curve - }); - return curve; - } - }); -} - -defineCurve('p192', { - type: 'short', - prime: 'p192', - p: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', - b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', - n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash.sha256, - gRed: false, - g: [ - '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', - '07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811' - ] -}); - -defineCurve('p224', { - type: 'short', - prime: 'p224', - p: 'ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001', - a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', - b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', - n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash.sha256, - gRed: false, - g: [ - 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', - 'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34' - ] -}); - -defineCurve('p256', { - type: 'short', - prime: null, - p: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff', - a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', - b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', - n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash.sha256, - gRed: false, - g: [ - '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', - '4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5' - ] -}); - -defineCurve('p384', { - type: 'short', - prime: null, - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 ffffffff', - a: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'fffffffe ffffffff 00000000 00000000 fffffffc', - b: 'b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f ' + - '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', - n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + - 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash.sha384, - gRed: false, - g: [ - 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + - '5502f25d bf55296c 3a545e38 72760ab7', - '3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' + - '0a60b1ce 1d7e819d 7a431d7c 90ea0e5f' - ] -}); - -defineCurve('p521', { - type: 'short', - prime: null, - p: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff', - a: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff ffffffff ffffffff fffffffc', - b: '00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b ' + - '99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd ' + - '3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00', - n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + - 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + - 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash.sha512, - gRed: false, - g: [ - '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + - '053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 ' + - 'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66', - '00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' + - '579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' + - '3fad0761 353c7086 a272c240 88be9476 9fd16650' - ] -}); - -defineCurve('curve25519', { - type: 'mont', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '76d06', - b: '1', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '9' - ] -}); - -defineCurve('ed25519', { - type: 'edwards', - prime: 'p25519', - p: '7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed', - a: '-1', - c: '1', - // -121665 * (121666^(-1)) (mod P) - d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', - n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash.sha256, - gRed: false, - g: [ - '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', - - // 4/5 - '6666666666666666666666666666666666666666666666666666666666666658' - ] -}); - -var pre; -try { - pre = require('./precomputed/secp256k1'); -} catch (e) { - pre = undefined; -} - -defineCurve('secp256k1', { - type: 'short', - prime: 'k256', - p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f', - a: '0', - b: '7', - n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', - h: '1', - hash: hash.sha256, - - // Precomputed endomorphism - beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', - lambda: '5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72', - basis: [ - { - a: '3086d221a7d46bcde86c90e49284eb15', - b: '-e4437ed6010e88286f547fa90abfe4c3' - }, - { - a: '114ca50f7a8e2f3f657c1108d9d44cfd8', - b: '3086d221a7d46bcde86c90e49284eb15' - } - ], - - gRed: false, - g: [ - '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798', - '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8', - pre - ] -}); - -},{"../elliptic":6,"./precomputed/secp256k1":18,"hash.js":21}],13:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -var KeyPair = require('./key'); -var Signature = require('./signature'); - -function EC(options) { - if (!(this instanceof EC)) - return new EC(options); - - // Shortcut `elliptic.ec(curve-name)` - if (typeof options === 'string') { - assert(elliptic.curves.hasOwnProperty(options), 'Unknown curve ' + options); - - options = elliptic.curves[options]; - } - - // Shortcut for `elliptic.ec(elliptic.curves.curveName)` - if (options instanceof elliptic.curves.PresetCurve) - options = { curve: options }; - - this.curve = options.curve.curve; - this.n = this.curve.n; - this.nh = this.n.ushrn(1); - this.g = this.curve.g; - - // Point on curve - this.g = options.curve.g; - this.g.precompute(options.curve.n.bitLength() + 1); - - // Hash for function for DRBG - this.hash = options.hash || options.curve.hash; -} -module.exports = EC; - -EC.prototype.keyPair = function keyPair(options) { - return new KeyPair(this, options); -}; - -EC.prototype.keyFromPrivate = function keyFromPrivate(priv, enc) { - return KeyPair.fromPrivate(this, priv, enc); -}; - -EC.prototype.keyFromPublic = function keyFromPublic(pub, enc) { - return KeyPair.fromPublic(this, pub, enc); -}; - -EC.prototype.genKeyPair = function genKeyPair(options) { - if (!options) - options = {}; - - // Instantiate Hmac_DRBG - var drbg = new elliptic.hmacDRBG({ - hash: this.hash, - pers: options.pers, - entropy: options.entropy || elliptic.rand(this.hash.hmacStrength), - nonce: this.n.toArray() - }); - - var bytes = this.n.byteLength(); - var ns2 = this.n.sub(new BN(2)); - do { - var priv = new BN(drbg.generate(bytes)); - if (priv.cmp(ns2) > 0) - continue; - - priv.iaddn(1); - return this.keyFromPrivate(priv); - } while (true); -}; - -EC.prototype._truncateToN = function truncateToN(msg, truncOnly) { - var delta = msg.byteLength() * 8 - this.n.bitLength(); - if (delta > 0) - msg = msg.ushrn(delta); - if (!truncOnly && msg.cmp(this.n) >= 0) - return msg.sub(this.n); - else - return msg; -}; - -EC.prototype.sign = function sign(msg, key, enc, options) { - if (typeof enc === 'object') { - options = enc; - enc = null; - } - if (!options) - options = {}; - - key = this.keyFromPrivate(key, enc); - msg = this._truncateToN(new BN(msg, 16)); - - // Zero-extend key to provide enough entropy - var bytes = this.n.byteLength(); - var bkey = key.getPrivate().toArray('be', bytes); - - // Zero-extend nonce to have the same byte size as N - var nonce = msg.toArray('be', bytes); - - // Instantiate Hmac_DRBG - var drbg = new elliptic.hmacDRBG({ - hash: this.hash, - entropy: bkey, - nonce: nonce, - pers: options.pers, - persEnc: options.persEnc - }); - - // Number of bytes to generate - var ns1 = this.n.sub(new BN(1)); - - for (var iter = 0; true; iter++) { - var k = options.k ? - options.k(iter) : - new BN(drbg.generate(this.n.byteLength())); - k = this._truncateToN(k, true); - if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0) - continue; - - var kp = this.g.mul(k); - if (kp.isInfinity()) - continue; - - var kpX = kp.getX(); - var r = kpX.umod(this.n); - if (r.cmpn(0) === 0) - continue; - - var s = k.invm(this.n).mul(r.mul(key.getPrivate()).iadd(msg)); - s = s.umod(this.n); - if (s.cmpn(0) === 0) - continue; - - var recoveryParam = (kp.getY().isOdd() ? 1 : 0) | - (kpX.cmp(r) !== 0 ? 2 : 0); - - // Use complement of `s`, if it is > `n / 2` - if (options.canonical && s.cmp(this.nh) > 0) { - s = this.n.sub(s); - recoveryParam ^= 1; - } - - return new Signature({ r: r, s: s, recoveryParam: recoveryParam }); - } -}; - -EC.prototype.verify = function verify(msg, signature, key, enc) { - msg = this._truncateToN(new BN(msg, 16)); - key = this.keyFromPublic(key, enc); - signature = new Signature(signature, 'hex'); - - // Perform primitive values validation - var r = signature.r; - var s = signature.s; - if (r.cmpn(1) < 0 || r.cmp(this.n) >= 0) - return false; - if (s.cmpn(1) < 0 || s.cmp(this.n) >= 0) - return false; - - // Validate signature - var sinv = s.invm(this.n); - var u1 = sinv.mul(msg).umod(this.n); - var u2 = sinv.mul(r).umod(this.n); - - if (!this.curve._maxwellTrick) { - var p = this.g.mulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; - - return p.getX().umod(this.n).cmp(r) === 0; - } - - // NOTE: Greg Maxwell's trick, inspired by: - // https://git.io/vad3K - - var p = this.g.jmulAdd(u1, key.getPublic(), u2); - if (p.isInfinity()) - return false; - - // Compare `p.x` of Jacobian point with `r`, - // this will do `p.x == r * p.z^2` instead of multiplying `p.x` by the - // inverse of `p.z^2` - return p.eqXToP(r); -}; - -EC.prototype.recoverPubKey = function(msg, signature, j, enc) { - assert((3 & j) === j, 'The recovery param is more than two bits'); - signature = new Signature(signature, enc); - - var n = this.n; - var e = new BN(msg); - var r = signature.r; - var s = signature.s; - - // A set LSB signifies that the y-coordinate is odd - var isYOdd = j & 1; - var isSecondKey = j >> 1; - if (r.cmp(this.curve.p.umod(this.curve.n)) >= 0 && isSecondKey) - throw new Error('Unable to find sencond key candinate'); - - // 1.1. Let x = r + jn. - if (isSecondKey) - r = this.curve.pointFromX(r.add(this.curve.n), isYOdd); - else - r = this.curve.pointFromX(r, isYOdd); - - var rInv = signature.r.invm(n); - var s1 = n.sub(e).mul(rInv).umod(n); - var s2 = s.mul(rInv).umod(n); - - // 1.6.1 Compute Q = r^-1 (sR - eG) - // Q = r^-1 (sR + -eG) - return this.g.mulAdd(s1, r, s2); -}; - -EC.prototype.getKeyRecoveryParam = function(e, signature, Q, enc) { - signature = new Signature(signature, enc); - if (signature.recoveryParam !== null) - return signature.recoveryParam; - - for (var i = 0; i < 4; i++) { - var Qprime; - try { - Qprime = this.recoverPubKey(e, signature, i); - } catch (e) { - continue; - } - - if (Qprime.eq(Q)) - return i; - } - throw new Error('Unable to find valid recovery factor'); -}; - -},{"../../elliptic":6,"./key":14,"./signature":15,"bn.js":2}],14:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -function KeyPair(ec, options) { - this.ec = ec; - this.priv = null; - this.pub = null; - - // KeyPair(ec, { priv: ..., pub: ... }) - if (options.priv) - this._importPrivate(options.priv, options.privEnc); - if (options.pub) - this._importPublic(options.pub, options.pubEnc); -} -module.exports = KeyPair; - -KeyPair.fromPublic = function fromPublic(ec, pub, enc) { - if (pub instanceof KeyPair) - return pub; - - return new KeyPair(ec, { - pub: pub, - pubEnc: enc - }); -}; - -KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) { - if (priv instanceof KeyPair) - return priv; - - return new KeyPair(ec, { - priv: priv, - privEnc: enc - }); -}; - -KeyPair.prototype.validate = function validate() { - var pub = this.getPublic(); - - if (pub.isInfinity()) - return { result: false, reason: 'Invalid public key' }; - if (!pub.validate()) - return { result: false, reason: 'Public key is not a point' }; - if (!pub.mul(this.ec.curve.n).isInfinity()) - return { result: false, reason: 'Public key * N != O' }; - - return { result: true, reason: null }; -}; - -KeyPair.prototype.getPublic = function getPublic(compact, enc) { - // compact is optional argument - if (typeof compact === 'string') { - enc = compact; - compact = null; - } - - if (!this.pub) - this.pub = this.ec.g.mul(this.priv); - - if (!enc) - return this.pub; - - return this.pub.encode(enc, compact); -}; - -KeyPair.prototype.getPrivate = function getPrivate(enc) { - if (enc === 'hex') - return this.priv.toString(16, 2); - else - return this.priv; -}; - -KeyPair.prototype._importPrivate = function _importPrivate(key, enc) { - this.priv = new BN(key, enc || 16); - - // Ensure that the priv won't be bigger than n, otherwise we may fail - // in fixed multiplication method - this.priv = this.priv.umod(this.ec.curve.n); -}; - -KeyPair.prototype._importPublic = function _importPublic(key, enc) { - if (key.x || key.y) { - // Montgomery points only have an `x` coordinate. - // Weierstrass/Edwards points on the other hand have both `x` and - // `y` coordinates. - if (this.ec.curve.type === 'mont') { - assert(key.x, 'Need x coordinate'); - } else if (this.ec.curve.type === 'short' || - this.ec.curve.type === 'edwards') { - assert(key.x && key.y, 'Need both x and y coordinate'); - } - this.pub = this.ec.curve.point(key.x, key.y); - return; - } - this.pub = this.ec.curve.decodePoint(key, enc); -}; - -// ECDH -KeyPair.prototype.derive = function derive(pub) { - return pub.mul(this.priv).getX(); -}; - -// ECDSA -KeyPair.prototype.sign = function sign(msg, enc, options) { - return this.ec.sign(msg, this, enc, options); -}; - -KeyPair.prototype.verify = function verify(msg, signature) { - return this.ec.verify(msg, signature, this); -}; - -KeyPair.prototype.inspect = function inspect() { - return ''; -}; - -},{"../../elliptic":6,"bn.js":2}],15:[function(require,module,exports){ -'use strict'; - -var BN = require('bn.js'); - -var elliptic = require('../../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -function Signature(options, enc) { - if (options instanceof Signature) - return options; - - if (this._importDER(options, enc)) - return; - - assert(options.r && options.s, 'Signature without r or s'); - this.r = new BN(options.r, 16); - this.s = new BN(options.s, 16); - if (options.recoveryParam === undefined) - this.recoveryParam = null; - else - this.recoveryParam = options.recoveryParam; -} -module.exports = Signature; - -function Position() { - this.place = 0; -} - -function getLength(buf, p) { - var initial = buf[p.place++]; - if (!(initial & 0x80)) { - return initial; - } - var octetLen = initial & 0xf; - var val = 0; - for (var i = 0, off = p.place; i < octetLen; i++, off++) { - val <<= 8; - val |= buf[off]; - } - p.place = off; - return val; -} - -function rmPadding(buf) { - var i = 0; - var len = buf.length - 1; - while (!buf[i] && !(buf[i + 1] & 0x80) && i < len) { - i++; - } - if (i === 0) { - return buf; - } - return buf.slice(i); -} - -Signature.prototype._importDER = function _importDER(data, enc) { - data = utils.toArray(data, enc); - var p = new Position(); - if (data[p.place++] !== 0x30) { - return false; - } - var len = getLength(data, p); - if ((len + p.place) !== data.length) { - return false; - } - if (data[p.place++] !== 0x02) { - return false; - } - var rlen = getLength(data, p); - var r = data.slice(p.place, rlen + p.place); - p.place += rlen; - if (data[p.place++] !== 0x02) { - return false; - } - var slen = getLength(data, p); - if (data.length !== slen + p.place) { - return false; - } - var s = data.slice(p.place, slen + p.place); - if (r[0] === 0 && (r[1] & 0x80)) { - r = r.slice(1); - } - if (s[0] === 0 && (s[1] & 0x80)) { - s = s.slice(1); - } - - this.r = new BN(r); - this.s = new BN(s); - this.recoveryParam = null; - - return true; -}; - -function constructLength(arr, len) { - if (len < 0x80) { - arr.push(len); - return; - } - var octets = 1 + (Math.log(len) / Math.LN2 >>> 3); - arr.push(octets | 0x80); - while (--octets) { - arr.push((len >>> (octets << 3)) & 0xff); - } - arr.push(len); -} - -Signature.prototype.toDER = function toDER(enc) { - var r = this.r.toArray(); - var s = this.s.toArray(); - - // Pad values - if (r[0] & 0x80) - r = [ 0 ].concat(r); - // Pad values - if (s[0] & 0x80) - s = [ 0 ].concat(s); - - r = rmPadding(r); - s = rmPadding(s); - - while (!s[0] && !(s[1] & 0x80)) { - s = s.slice(1); - } - var arr = [ 0x02 ]; - constructLength(arr, r.length); - arr = arr.concat(r); - arr.push(0x02); - constructLength(arr, s.length); - var backHalf = arr.concat(s); - var res = [ 0x30 ]; - constructLength(res, backHalf.length); - res = res.concat(backHalf); - return utils.encode(res, enc); -}; - -},{"../../elliptic":6,"bn.js":2}],16:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],17:[function(require,module,exports){ -'use strict'; - -var hash = require('hash.js'); -var elliptic = require('../elliptic'); -var utils = elliptic.utils; -var assert = utils.assert; - -function HmacDRBG(options) { - if (!(this instanceof HmacDRBG)) - return new HmacDRBG(options); - this.hash = options.hash; - this.predResist = !!options.predResist; - - this.outLen = this.hash.outSize; - this.minEntropy = options.minEntropy || this.hash.hmacStrength; - - this.reseed = null; - this.reseedInterval = null; - this.K = null; - this.V = null; - - var entropy = utils.toArray(options.entropy, options.entropyEnc); - var nonce = utils.toArray(options.nonce, options.nonceEnc); - var pers = utils.toArray(options.pers, options.persEnc); - assert(entropy.length >= (this.minEntropy / 8), - 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - this._init(entropy, nonce, pers); -} -module.exports = HmacDRBG; - -HmacDRBG.prototype._init = function init(entropy, nonce, pers) { - var seed = entropy.concat(nonce).concat(pers); - - this.K = new Array(this.outLen / 8); - this.V = new Array(this.outLen / 8); - for (var i = 0; i < this.V.length; i++) { - this.K[i] = 0x00; - this.V[i] = 0x01; - } - - this._update(seed); - this.reseed = 1; - this.reseedInterval = 0x1000000000000; // 2^48 -}; - -HmacDRBG.prototype._hmac = function hmac() { - return new hash.hmac(this.hash, this.K); -}; - -HmacDRBG.prototype._update = function update(seed) { - var kmac = this._hmac() - .update(this.V) - .update([ 0x00 ]); - if (seed) - kmac = kmac.update(seed); - this.K = kmac.digest(); - this.V = this._hmac().update(this.V).digest(); - if (!seed) - return; - - this.K = this._hmac() - .update(this.V) - .update([ 0x01 ]) - .update(seed) - .digest(); - this.V = this._hmac().update(this.V).digest(); -}; - -HmacDRBG.prototype.reseed = function reseed(entropy, entropyEnc, add, addEnc) { - // Optional entropy enc - if (typeof entropyEnc !== 'string') { - addEnc = add; - add = entropyEnc; - entropyEnc = null; - } - - entropy = utils.toBuffer(entropy, entropyEnc); - add = utils.toBuffer(add, addEnc); - - assert(entropy.length >= (this.minEntropy / 8), - 'Not enough entropy. Minimum is: ' + this.minEntropy + ' bits'); - - this._update(entropy.concat(add || [])); - this.reseed = 1; -}; - -HmacDRBG.prototype.generate = function generate(len, enc, add, addEnc) { - if (this.reseed > this.reseedInterval) - throw new Error('Reseed is required'); - - // Optional encoding - if (typeof enc !== 'string') { - addEnc = add; - add = enc; - enc = null; - } - - // Optional additional data - if (add) { - add = utils.toArray(add, addEnc); - this._update(add); - } - - var temp = []; - while (temp.length < len) { - this.V = this._hmac().update(this.V).digest(); - temp = temp.concat(this.V); - } - - var res = temp.slice(0, len); - this._update(add); - this.reseed++; - return utils.encode(res, enc); -}; - -},{"../elliptic":6,"hash.js":21}],18:[function(require,module,exports){ -module.exports = undefined; -},{}],19:[function(require,module,exports){ -'use strict'; - -var utils = exports; -var BN = require('bn.js'); - -utils.assert = function assert(val, msg) { - if (!val) - throw new Error(msg || 'Assertion failed'); -}; - -function toArray(msg, enc) { - if (Array.isArray(msg)) - return msg.slice(); - if (!msg) - return []; - var res = []; - if (typeof msg !== 'string') { - for (var i = 0; i < msg.length; i++) - res[i] = msg[i] | 0; - return res; - } - if (!enc) { - for (var i = 0; i < msg.length; i++) { - var c = msg.charCodeAt(i); - var hi = c >> 8; - var lo = c & 0xff; - if (hi) - res.push(hi, lo); - else - res.push(lo); - } - } else if (enc === 'hex') { - msg = msg.replace(/[^a-z0-9]+/ig, ''); - if (msg.length % 2 !== 0) - msg = '0' + msg; - for (var i = 0; i < msg.length; i += 2) - res.push(parseInt(msg[i] + msg[i + 1], 16)); - } - return res; -} -utils.toArray = toArray; - -function zero2(word) { - if (word.length === 1) - return '0' + word; - else - return word; -} -utils.zero2 = zero2; - -function toHex(msg) { - var res = ''; - for (var i = 0; i < msg.length; i++) - res += zero2(msg[i].toString(16)); - return res; -} -utils.toHex = toHex; - -utils.encode = function encode(arr, enc) { - if (enc === 'hex') - return toHex(arr); - else - return arr; -}; - -// Represent num in a w-NAF form -function getNAF(num, w) { - var naf = []; - var ws = 1 << (w + 1); - var k = num.clone(); - while (k.cmpn(1) >= 0) { - var z; - if (k.isOdd()) { - var mod = k.andln(ws - 1); - if (mod > (ws >> 1) - 1) - z = (ws >> 1) - mod; - else - z = mod; - k.isubn(z); - } else { - z = 0; - } - naf.push(z); - - // Optimization, shift by word if possible - var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1; - for (var i = 1; i < shift; i++) - naf.push(0); - k.iushrn(shift); - } - - return naf; -} -utils.getNAF = getNAF; - -// Represent k1, k2 in a Joint Sparse Form -function getJSF(k1, k2) { - var jsf = [ - [], - [] - ]; - - k1 = k1.clone(); - k2 = k2.clone(); - var d1 = 0; - var d2 = 0; - while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) { - - // First phase - var m14 = (k1.andln(3) + d1) & 3; - var m24 = (k2.andln(3) + d2) & 3; - if (m14 === 3) - m14 = -1; - if (m24 === 3) - m24 = -1; - var u1; - if ((m14 & 1) === 0) { - u1 = 0; - } else { - var m8 = (k1.andln(7) + d1) & 7; - if ((m8 === 3 || m8 === 5) && m24 === 2) - u1 = -m14; - else - u1 = m14; - } - jsf[0].push(u1); - - var u2; - if ((m24 & 1) === 0) { - u2 = 0; - } else { - var m8 = (k2.andln(7) + d2) & 7; - if ((m8 === 3 || m8 === 5) && m14 === 2) - u2 = -m24; - else - u2 = m24; - } - jsf[1].push(u2); - - // Second phase - if (2 * d1 === u1 + 1) - d1 = 1 - d1; - if (2 * d2 === u2 + 1) - d2 = 1 - d2; - k1.iushrn(1); - k2.iushrn(1); - } - - return jsf; -} -utils.getJSF = getJSF; - -function cachedProperty(obj, name, computer) { - var key = '_' + name; - obj.prototype[name] = function cachedProperty() { - return this[key] !== undefined ? this[key] : - this[key] = computer.call(this); - }; -} -utils.cachedProperty = cachedProperty; - -function parseBytes(bytes) { - return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') : - bytes; -} -utils.parseBytes = parseBytes; - -function intFromLE(bytes) { - return new BN(bytes, 'hex', 'le'); -} -utils.intFromLE = intFromLE; - - -},{"bn.js":2}],20:[function(require,module,exports){ -module.exports={"version":"6.3.3"} -},{}],21:[function(require,module,exports){ -var hash = exports; - -hash.utils = require('./hash/utils'); -hash.common = require('./hash/common'); -hash.sha = require('./hash/sha'); -hash.ripemd = require('./hash/ripemd'); -hash.hmac = require('./hash/hmac'); - -// Proxy hash functions to the main object -hash.sha1 = hash.sha.sha1; -hash.sha256 = hash.sha.sha256; -hash.sha224 = hash.sha.sha224; -hash.sha384 = hash.sha.sha384; -hash.sha512 = hash.sha.sha512; -hash.ripemd160 = hash.ripemd.ripemd160; - -},{"./hash/common":22,"./hash/hmac":23,"./hash/ripemd":24,"./hash/sha":25,"./hash/utils":32}],22:[function(require,module,exports){ -'use strict'; - -var utils = require('./utils'); -var assert = require('minimalistic-assert'); - -function BlockHash() { - this.pending = null; - this.pendingTotal = 0; - this.blockSize = this.constructor.blockSize; - this.outSize = this.constructor.outSize; - this.hmacStrength = this.constructor.hmacStrength; - this.padLength = this.constructor.padLength / 8; - this.endian = 'big'; - - this._delta8 = this.blockSize / 8; - this._delta32 = this.blockSize / 32; -} -exports.BlockHash = BlockHash; - -BlockHash.prototype.update = function update(msg, enc) { - // Convert message to array, pad it, and join into 32bit blocks - msg = utils.toArray(msg, enc); - if (!this.pending) - this.pending = msg; - else - this.pending = this.pending.concat(msg); - this.pendingTotal += msg.length; - - // Enough data, try updating - if (this.pending.length >= this._delta8) { - msg = this.pending; - - // Process pending data in blocks - var r = msg.length % this._delta8; - this.pending = msg.slice(msg.length - r, msg.length); - if (this.pending.length === 0) - this.pending = null; - - msg = utils.join32(msg, 0, msg.length - r, this.endian); - for (var i = 0; i < msg.length; i += this._delta32) - this._update(msg, i, i + this._delta32); - } - - return this; -}; - -BlockHash.prototype.digest = function digest(enc) { - this.update(this._pad()); - assert(this.pending === null); - - return this._digest(enc); -}; - -BlockHash.prototype._pad = function pad() { - var len = this.pendingTotal; - var bytes = this._delta8; - var k = bytes - ((len + this.padLength) % bytes); - var res = new Array(k + this.padLength); - res[0] = 0x80; - for (var i = 1; i < k; i++) - res[i] = 0; - - // Append length - len <<= 3; - if (this.endian === 'big') { - for (var t = 8; t < this.padLength; t++) - res[i++] = 0; - - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = (len >>> 24) & 0xff; - res[i++] = (len >>> 16) & 0xff; - res[i++] = (len >>> 8) & 0xff; - res[i++] = len & 0xff; - } else { - res[i++] = len & 0xff; - res[i++] = (len >>> 8) & 0xff; - res[i++] = (len >>> 16) & 0xff; - res[i++] = (len >>> 24) & 0xff; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - res[i++] = 0; - - for (t = 8; t < this.padLength; t++) - res[i++] = 0; - } - - return res; -}; - -},{"./utils":32,"minimalistic-assert":35}],23:[function(require,module,exports){ -'use strict'; - -var utils = require('./utils'); -var assert = require('minimalistic-assert'); - -function Hmac(hash, key, enc) { - if (!(this instanceof Hmac)) - return new Hmac(hash, key, enc); - this.Hash = hash; - this.blockSize = hash.blockSize / 8; - this.outSize = hash.outSize / 8; - this.inner = null; - this.outer = null; - - this._init(utils.toArray(key, enc)); -} -module.exports = Hmac; - -Hmac.prototype._init = function init(key) { - // Shorten key, if needed - if (key.length > this.blockSize) - key = new this.Hash().update(key).digest(); - assert(key.length <= this.blockSize); - - // Add padding to key - for (var i = key.length; i < this.blockSize; i++) - key.push(0); - - for (i = 0; i < key.length; i++) - key[i] ^= 0x36; - this.inner = new this.Hash().update(key); - - // 0x36 ^ 0x5c = 0x6a - for (i = 0; i < key.length; i++) - key[i] ^= 0x6a; - this.outer = new this.Hash().update(key); -}; - -Hmac.prototype.update = function update(msg, enc) { - this.inner.update(msg, enc); - return this; -}; - -Hmac.prototype.digest = function digest(enc) { - this.outer.update(this.inner.digest()); - return this.outer.digest(enc); -}; - -},{"./utils":32,"minimalistic-assert":35}],24:[function(require,module,exports){ -'use strict'; - -var utils = require('./utils'); -var common = require('./common'); - -var rotl32 = utils.rotl32; -var sum32 = utils.sum32; -var sum32_3 = utils.sum32_3; -var sum32_4 = utils.sum32_4; -var BlockHash = common.BlockHash; - -function RIPEMD160() { - if (!(this instanceof RIPEMD160)) - return new RIPEMD160(); - - BlockHash.call(this); - - this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ]; - this.endian = 'little'; -} -utils.inherits(RIPEMD160, BlockHash); -exports.ripemd160 = RIPEMD160; - -RIPEMD160.blockSize = 512; -RIPEMD160.outSize = 160; -RIPEMD160.hmacStrength = 192; -RIPEMD160.padLength = 64; - -RIPEMD160.prototype._update = function update(msg, start) { - var A = this.h[0]; - var B = this.h[1]; - var C = this.h[2]; - var D = this.h[3]; - var E = this.h[4]; - var Ah = A; - var Bh = B; - var Ch = C; - var Dh = D; - var Eh = E; - for (var j = 0; j < 80; j++) { - var T = sum32( - rotl32( - sum32_4(A, f(j, B, C, D), msg[r[j] + start], K(j)), - s[j]), - E); - A = E; - E = D; - D = rotl32(C, 10); - C = B; - B = T; - T = sum32( - rotl32( - sum32_4(Ah, f(79 - j, Bh, Ch, Dh), msg[rh[j] + start], Kh(j)), - sh[j]), - Eh); - Ah = Eh; - Eh = Dh; - Dh = rotl32(Ch, 10); - Ch = Bh; - Bh = T; - } - T = sum32_3(this.h[1], C, Dh); - this.h[1] = sum32_3(this.h[2], D, Eh); - this.h[2] = sum32_3(this.h[3], E, Ah); - this.h[3] = sum32_3(this.h[4], A, Bh); - this.h[4] = sum32_3(this.h[0], B, Ch); - this.h[0] = T; -}; - -RIPEMD160.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'little'); - else - return utils.split32(this.h, 'little'); -}; - -function f(j, x, y, z) { - if (j <= 15) - return x ^ y ^ z; - else if (j <= 31) - return (x & y) | ((~x) & z); - else if (j <= 47) - return (x | (~y)) ^ z; - else if (j <= 63) - return (x & z) | (y & (~z)); - else - return x ^ (y | (~z)); -} - -function K(j) { - if (j <= 15) - return 0x00000000; - else if (j <= 31) - return 0x5a827999; - else if (j <= 47) - return 0x6ed9eba1; - else if (j <= 63) - return 0x8f1bbcdc; - else - return 0xa953fd4e; -} - -function Kh(j) { - if (j <= 15) - return 0x50a28be6; - else if (j <= 31) - return 0x5c4dd124; - else if (j <= 47) - return 0x6d703ef3; - else if (j <= 63) - return 0x7a6d76e9; - else - return 0x00000000; -} - -var r = [ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, - 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, - 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, - 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13 -]; - -var rh = [ - 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, - 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, - 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, - 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, - 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11 -]; - -var s = [ - 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, - 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, - 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, - 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, - 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 -]; - -var sh = [ - 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, - 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, - 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, - 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, - 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 -]; - -},{"./common":22,"./utils":32}],25:[function(require,module,exports){ -'use strict'; - -exports.sha1 = require('./sha/1'); -exports.sha224 = require('./sha/224'); -exports.sha256 = require('./sha/256'); -exports.sha384 = require('./sha/384'); -exports.sha512 = require('./sha/512'); - -},{"./sha/1":26,"./sha/224":27,"./sha/256":28,"./sha/384":29,"./sha/512":30}],26:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],27:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],28:[function(require,module,exports){ -'use strict'; - -var utils = require('../utils'); -var common = require('../common'); -var shaCommon = require('./common'); -var assert = require('minimalistic-assert'); - -var sum32 = utils.sum32; -var sum32_4 = utils.sum32_4; -var sum32_5 = utils.sum32_5; -var ch32 = shaCommon.ch32; -var maj32 = shaCommon.maj32; -var s0_256 = shaCommon.s0_256; -var s1_256 = shaCommon.s1_256; -var g0_256 = shaCommon.g0_256; -var g1_256 = shaCommon.g1_256; - -var BlockHash = common.BlockHash; - -var sha256_K = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, - 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, - 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, - 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, - 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, - 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, - 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, - 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, - 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, - 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, - 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, - 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, - 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 -]; - -function SHA256() { - if (!(this instanceof SHA256)) - return new SHA256(); - - BlockHash.call(this); - this.h = [ - 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, - 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 - ]; - this.k = sha256_K; - this.W = new Array(64); -} -utils.inherits(SHA256, BlockHash); -module.exports = SHA256; - -SHA256.blockSize = 512; -SHA256.outSize = 256; -SHA256.hmacStrength = 192; -SHA256.padLength = 64; - -SHA256.prototype._update = function _update(msg, start) { - var W = this.W; - - for (var i = 0; i < 16; i++) - W[i] = msg[start + i]; - for (; i < W.length; i++) - W[i] = sum32_4(g1_256(W[i - 2]), W[i - 7], g0_256(W[i - 15]), W[i - 16]); - - var a = this.h[0]; - var b = this.h[1]; - var c = this.h[2]; - var d = this.h[3]; - var e = this.h[4]; - var f = this.h[5]; - var g = this.h[6]; - var h = this.h[7]; - - assert(this.k.length === W.length); - for (i = 0; i < W.length; i++) { - var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]); - var T2 = sum32(s0_256(a), maj32(a, b, c)); - h = g; - g = f; - f = e; - e = sum32(d, T1); - d = c; - c = b; - b = a; - a = sum32(T1, T2); - } - - this.h[0] = sum32(this.h[0], a); - this.h[1] = sum32(this.h[1], b); - this.h[2] = sum32(this.h[2], c); - this.h[3] = sum32(this.h[3], d); - this.h[4] = sum32(this.h[4], e); - this.h[5] = sum32(this.h[5], f); - this.h[6] = sum32(this.h[6], g); - this.h[7] = sum32(this.h[7], h); -}; - -SHA256.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'big'); - else - return utils.split32(this.h, 'big'); -}; - -},{"../common":22,"../utils":32,"./common":31,"minimalistic-assert":35}],29:[function(require,module,exports){ -arguments[4][8][0].apply(exports,arguments) -},{"dup":8}],30:[function(require,module,exports){ -'use strict'; - -var utils = require('../utils'); -var common = require('../common'); -var assert = require('minimalistic-assert'); - -var rotr64_hi = utils.rotr64_hi; -var rotr64_lo = utils.rotr64_lo; -var shr64_hi = utils.shr64_hi; -var shr64_lo = utils.shr64_lo; -var sum64 = utils.sum64; -var sum64_hi = utils.sum64_hi; -var sum64_lo = utils.sum64_lo; -var sum64_4_hi = utils.sum64_4_hi; -var sum64_4_lo = utils.sum64_4_lo; -var sum64_5_hi = utils.sum64_5_hi; -var sum64_5_lo = utils.sum64_5_lo; - -var BlockHash = common.BlockHash; - -var sha512_K = [ - 0x428a2f98, 0xd728ae22, 0x71374491, 0x23ef65cd, - 0xb5c0fbcf, 0xec4d3b2f, 0xe9b5dba5, 0x8189dbbc, - 0x3956c25b, 0xf348b538, 0x59f111f1, 0xb605d019, - 0x923f82a4, 0xaf194f9b, 0xab1c5ed5, 0xda6d8118, - 0xd807aa98, 0xa3030242, 0x12835b01, 0x45706fbe, - 0x243185be, 0x4ee4b28c, 0x550c7dc3, 0xd5ffb4e2, - 0x72be5d74, 0xf27b896f, 0x80deb1fe, 0x3b1696b1, - 0x9bdc06a7, 0x25c71235, 0xc19bf174, 0xcf692694, - 0xe49b69c1, 0x9ef14ad2, 0xefbe4786, 0x384f25e3, - 0x0fc19dc6, 0x8b8cd5b5, 0x240ca1cc, 0x77ac9c65, - 0x2de92c6f, 0x592b0275, 0x4a7484aa, 0x6ea6e483, - 0x5cb0a9dc, 0xbd41fbd4, 0x76f988da, 0x831153b5, - 0x983e5152, 0xee66dfab, 0xa831c66d, 0x2db43210, - 0xb00327c8, 0x98fb213f, 0xbf597fc7, 0xbeef0ee4, - 0xc6e00bf3, 0x3da88fc2, 0xd5a79147, 0x930aa725, - 0x06ca6351, 0xe003826f, 0x14292967, 0x0a0e6e70, - 0x27b70a85, 0x46d22ffc, 0x2e1b2138, 0x5c26c926, - 0x4d2c6dfc, 0x5ac42aed, 0x53380d13, 0x9d95b3df, - 0x650a7354, 0x8baf63de, 0x766a0abb, 0x3c77b2a8, - 0x81c2c92e, 0x47edaee6, 0x92722c85, 0x1482353b, - 0xa2bfe8a1, 0x4cf10364, 0xa81a664b, 0xbc423001, - 0xc24b8b70, 0xd0f89791, 0xc76c51a3, 0x0654be30, - 0xd192e819, 0xd6ef5218, 0xd6990624, 0x5565a910, - 0xf40e3585, 0x5771202a, 0x106aa070, 0x32bbd1b8, - 0x19a4c116, 0xb8d2d0c8, 0x1e376c08, 0x5141ab53, - 0x2748774c, 0xdf8eeb99, 0x34b0bcb5, 0xe19b48a8, - 0x391c0cb3, 0xc5c95a63, 0x4ed8aa4a, 0xe3418acb, - 0x5b9cca4f, 0x7763e373, 0x682e6ff3, 0xd6b2b8a3, - 0x748f82ee, 0x5defb2fc, 0x78a5636f, 0x43172f60, - 0x84c87814, 0xa1f0ab72, 0x8cc70208, 0x1a6439ec, - 0x90befffa, 0x23631e28, 0xa4506ceb, 0xde82bde9, - 0xbef9a3f7, 0xb2c67915, 0xc67178f2, 0xe372532b, - 0xca273ece, 0xea26619c, 0xd186b8c7, 0x21c0c207, - 0xeada7dd6, 0xcde0eb1e, 0xf57d4f7f, 0xee6ed178, - 0x06f067aa, 0x72176fba, 0x0a637dc5, 0xa2c898a6, - 0x113f9804, 0xbef90dae, 0x1b710b35, 0x131c471b, - 0x28db77f5, 0x23047d84, 0x32caab7b, 0x40c72493, - 0x3c9ebe0a, 0x15c9bebc, 0x431d67c4, 0x9c100d4c, - 0x4cc5d4be, 0xcb3e42b6, 0x597f299c, 0xfc657e2a, - 0x5fcb6fab, 0x3ad6faec, 0x6c44198c, 0x4a475817 -]; - -function SHA512() { - if (!(this instanceof SHA512)) - return new SHA512(); - - BlockHash.call(this); - this.h = [ - 0x6a09e667, 0xf3bcc908, - 0xbb67ae85, 0x84caa73b, - 0x3c6ef372, 0xfe94f82b, - 0xa54ff53a, 0x5f1d36f1, - 0x510e527f, 0xade682d1, - 0x9b05688c, 0x2b3e6c1f, - 0x1f83d9ab, 0xfb41bd6b, - 0x5be0cd19, 0x137e2179 ]; - this.k = sha512_K; - this.W = new Array(160); -} -utils.inherits(SHA512, BlockHash); -module.exports = SHA512; - -SHA512.blockSize = 1024; -SHA512.outSize = 512; -SHA512.hmacStrength = 192; -SHA512.padLength = 128; - -SHA512.prototype._prepareBlock = function _prepareBlock(msg, start) { - var W = this.W; - - // 32 x 32bit words - for (var i = 0; i < 32; i++) - W[i] = msg[start + i]; - for (; i < W.length; i += 2) { - var c0_hi = g1_512_hi(W[i - 4], W[i - 3]); // i - 2 - var c0_lo = g1_512_lo(W[i - 4], W[i - 3]); - var c1_hi = W[i - 14]; // i - 7 - var c1_lo = W[i - 13]; - var c2_hi = g0_512_hi(W[i - 30], W[i - 29]); // i - 15 - var c2_lo = g0_512_lo(W[i - 30], W[i - 29]); - var c3_hi = W[i - 32]; // i - 16 - var c3_lo = W[i - 31]; - - W[i] = sum64_4_hi( - c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo); - W[i + 1] = sum64_4_lo( - c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo); - } -}; - -SHA512.prototype._update = function _update(msg, start) { - this._prepareBlock(msg, start); - - var W = this.W; - - var ah = this.h[0]; - var al = this.h[1]; - var bh = this.h[2]; - var bl = this.h[3]; - var ch = this.h[4]; - var cl = this.h[5]; - var dh = this.h[6]; - var dl = this.h[7]; - var eh = this.h[8]; - var el = this.h[9]; - var fh = this.h[10]; - var fl = this.h[11]; - var gh = this.h[12]; - var gl = this.h[13]; - var hh = this.h[14]; - var hl = this.h[15]; - - assert(this.k.length === W.length); - for (var i = 0; i < W.length; i += 2) { - var c0_hi = hh; - var c0_lo = hl; - var c1_hi = s1_512_hi(eh, el); - var c1_lo = s1_512_lo(eh, el); - var c2_hi = ch64_hi(eh, el, fh, fl, gh, gl); - var c2_lo = ch64_lo(eh, el, fh, fl, gh, gl); - var c3_hi = this.k[i]; - var c3_lo = this.k[i + 1]; - var c4_hi = W[i]; - var c4_lo = W[i + 1]; - - var T1_hi = sum64_5_hi( - c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo, - c4_hi, c4_lo); - var T1_lo = sum64_5_lo( - c0_hi, c0_lo, - c1_hi, c1_lo, - c2_hi, c2_lo, - c3_hi, c3_lo, - c4_hi, c4_lo); - - c0_hi = s0_512_hi(ah, al); - c0_lo = s0_512_lo(ah, al); - c1_hi = maj64_hi(ah, al, bh, bl, ch, cl); - c1_lo = maj64_lo(ah, al, bh, bl, ch, cl); - - var T2_hi = sum64_hi(c0_hi, c0_lo, c1_hi, c1_lo); - var T2_lo = sum64_lo(c0_hi, c0_lo, c1_hi, c1_lo); - - hh = gh; - hl = gl; - - gh = fh; - gl = fl; - - fh = eh; - fl = el; - - eh = sum64_hi(dh, dl, T1_hi, T1_lo); - el = sum64_lo(dl, dl, T1_hi, T1_lo); - - dh = ch; - dl = cl; - - ch = bh; - cl = bl; - - bh = ah; - bl = al; - - ah = sum64_hi(T1_hi, T1_lo, T2_hi, T2_lo); - al = sum64_lo(T1_hi, T1_lo, T2_hi, T2_lo); - } - - sum64(this.h, 0, ah, al); - sum64(this.h, 2, bh, bl); - sum64(this.h, 4, ch, cl); - sum64(this.h, 6, dh, dl); - sum64(this.h, 8, eh, el); - sum64(this.h, 10, fh, fl); - sum64(this.h, 12, gh, gl); - sum64(this.h, 14, hh, hl); -}; - -SHA512.prototype._digest = function digest(enc) { - if (enc === 'hex') - return utils.toHex32(this.h, 'big'); - else - return utils.split32(this.h, 'big'); -}; - -function ch64_hi(xh, xl, yh, yl, zh) { - var r = (xh & yh) ^ ((~xh) & zh); - if (r < 0) - r += 0x100000000; - return r; -} - -function ch64_lo(xh, xl, yh, yl, zh, zl) { - var r = (xl & yl) ^ ((~xl) & zl); - if (r < 0) - r += 0x100000000; - return r; -} - -function maj64_hi(xh, xl, yh, yl, zh) { - var r = (xh & yh) ^ (xh & zh) ^ (yh & zh); - if (r < 0) - r += 0x100000000; - return r; -} - -function maj64_lo(xh, xl, yh, yl, zh, zl) { - var r = (xl & yl) ^ (xl & zl) ^ (yl & zl); - if (r < 0) - r += 0x100000000; - return r; -} - -function s0_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 28); - var c1_hi = rotr64_hi(xl, xh, 2); // 34 - var c2_hi = rotr64_hi(xl, xh, 7); // 39 - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function s0_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 28); - var c1_lo = rotr64_lo(xl, xh, 2); // 34 - var c2_lo = rotr64_lo(xl, xh, 7); // 39 - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -function s1_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 14); - var c1_hi = rotr64_hi(xh, xl, 18); - var c2_hi = rotr64_hi(xl, xh, 9); // 41 - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function s1_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 14); - var c1_lo = rotr64_lo(xh, xl, 18); - var c2_lo = rotr64_lo(xl, xh, 9); // 41 - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -function g0_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 1); - var c1_hi = rotr64_hi(xh, xl, 8); - var c2_hi = shr64_hi(xh, xl, 7); - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function g0_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 1); - var c1_lo = rotr64_lo(xh, xl, 8); - var c2_lo = shr64_lo(xh, xl, 7); - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -function g1_512_hi(xh, xl) { - var c0_hi = rotr64_hi(xh, xl, 19); - var c1_hi = rotr64_hi(xl, xh, 29); // 61 - var c2_hi = shr64_hi(xh, xl, 6); - - var r = c0_hi ^ c1_hi ^ c2_hi; - if (r < 0) - r += 0x100000000; - return r; -} - -function g1_512_lo(xh, xl) { - var c0_lo = rotr64_lo(xh, xl, 19); - var c1_lo = rotr64_lo(xl, xh, 29); // 61 - var c2_lo = shr64_lo(xh, xl, 6); - - var r = c0_lo ^ c1_lo ^ c2_lo; - if (r < 0) - r += 0x100000000; - return r; -} - -},{"../common":22,"../utils":32,"minimalistic-assert":35}],31:[function(require,module,exports){ -'use strict'; - -var utils = require('../utils'); -var rotr32 = utils.rotr32; - -function ft_1(s, x, y, z) { - if (s === 0) - return ch32(x, y, z); - if (s === 1 || s === 3) - return p32(x, y, z); - if (s === 2) - return maj32(x, y, z); -} -exports.ft_1 = ft_1; - -function ch32(x, y, z) { - return (x & y) ^ ((~x) & z); -} -exports.ch32 = ch32; - -function maj32(x, y, z) { - return (x & y) ^ (x & z) ^ (y & z); -} -exports.maj32 = maj32; - -function p32(x, y, z) { - return x ^ y ^ z; -} -exports.p32 = p32; - -function s0_256(x) { - return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22); -} -exports.s0_256 = s0_256; - -function s1_256(x) { - return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25); -} -exports.s1_256 = s1_256; - -function g0_256(x) { - return rotr32(x, 7) ^ rotr32(x, 18) ^ (x >>> 3); -} -exports.g0_256 = g0_256; - -function g1_256(x) { - return rotr32(x, 17) ^ rotr32(x, 19) ^ (x >>> 10); -} -exports.g1_256 = g1_256; - -},{"../utils":32}],32:[function(require,module,exports){ -'use strict'; - -var assert = require('minimalistic-assert'); -var inherits = require('inherits'); - -exports.inherits = inherits; - -function toArray(msg, enc) { - if (Array.isArray(msg)) - return msg.slice(); - if (!msg) - return []; - var res = []; - if (typeof msg === 'string') { - if (!enc) { - for (var i = 0; i < msg.length; i++) { - var c = msg.charCodeAt(i); - var hi = c >> 8; - var lo = c & 0xff; - if (hi) - res.push(hi, lo); - else - res.push(lo); - } - } else if (enc === 'hex') { - msg = msg.replace(/[^a-z0-9]+/ig, ''); - if (msg.length % 2 !== 0) - msg = '0' + msg; - for (i = 0; i < msg.length; i += 2) - res.push(parseInt(msg[i] + msg[i + 1], 16)); - } - } else { - for (i = 0; i < msg.length; i++) - res[i] = msg[i] | 0; - } - return res; -} -exports.toArray = toArray; - -function toHex(msg) { - var res = ''; - for (var i = 0; i < msg.length; i++) - res += zero2(msg[i].toString(16)); - return res; -} -exports.toHex = toHex; - -function htonl(w) { - var res = (w >>> 24) | - ((w >>> 8) & 0xff00) | - ((w << 8) & 0xff0000) | - ((w & 0xff) << 24); - return res >>> 0; -} -exports.htonl = htonl; - -function toHex32(msg, endian) { - var res = ''; - for (var i = 0; i < msg.length; i++) { - var w = msg[i]; - if (endian === 'little') - w = htonl(w); - res += zero8(w.toString(16)); - } - return res; -} -exports.toHex32 = toHex32; - -function zero2(word) { - if (word.length === 1) - return '0' + word; - else - return word; -} -exports.zero2 = zero2; - -function zero8(word) { - if (word.length === 7) - return '0' + word; - else if (word.length === 6) - return '00' + word; - else if (word.length === 5) - return '000' + word; - else if (word.length === 4) - return '0000' + word; - else if (word.length === 3) - return '00000' + word; - else if (word.length === 2) - return '000000' + word; - else if (word.length === 1) - return '0000000' + word; - else - return word; -} -exports.zero8 = zero8; - -function join32(msg, start, end, endian) { - var len = end - start; - assert(len % 4 === 0); - var res = new Array(len / 4); - for (var i = 0, k = start; i < res.length; i++, k += 4) { - var w; - if (endian === 'big') - w = (msg[k] << 24) | (msg[k + 1] << 16) | (msg[k + 2] << 8) | msg[k + 3]; - else - w = (msg[k + 3] << 24) | (msg[k + 2] << 16) | (msg[k + 1] << 8) | msg[k]; - res[i] = w >>> 0; - } - return res; -} -exports.join32 = join32; - -function split32(msg, endian) { - var res = new Array(msg.length * 4); - for (var i = 0, k = 0; i < msg.length; i++, k += 4) { - var m = msg[i]; - if (endian === 'big') { - res[k] = m >>> 24; - res[k + 1] = (m >>> 16) & 0xff; - res[k + 2] = (m >>> 8) & 0xff; - res[k + 3] = m & 0xff; - } else { - res[k + 3] = m >>> 24; - res[k + 2] = (m >>> 16) & 0xff; - res[k + 1] = (m >>> 8) & 0xff; - res[k] = m & 0xff; - } - } - return res; -} -exports.split32 = split32; - -function rotr32(w, b) { - return (w >>> b) | (w << (32 - b)); -} -exports.rotr32 = rotr32; - -function rotl32(w, b) { - return (w << b) | (w >>> (32 - b)); -} -exports.rotl32 = rotl32; - -function sum32(a, b) { - return (a + b) >>> 0; -} -exports.sum32 = sum32; - -function sum32_3(a, b, c) { - return (a + b + c) >>> 0; -} -exports.sum32_3 = sum32_3; - -function sum32_4(a, b, c, d) { - return (a + b + c + d) >>> 0; -} -exports.sum32_4 = sum32_4; - -function sum32_5(a, b, c, d, e) { - return (a + b + c + d + e) >>> 0; -} -exports.sum32_5 = sum32_5; - -function sum64(buf, pos, ah, al) { - var bh = buf[pos]; - var bl = buf[pos + 1]; - - var lo = (al + bl) >>> 0; - var hi = (lo < al ? 1 : 0) + ah + bh; - buf[pos] = hi >>> 0; - buf[pos + 1] = lo; -} -exports.sum64 = sum64; - -function sum64_hi(ah, al, bh, bl) { - var lo = (al + bl) >>> 0; - var hi = (lo < al ? 1 : 0) + ah + bh; - return hi >>> 0; -} -exports.sum64_hi = sum64_hi; - -function sum64_lo(ah, al, bh, bl) { - var lo = al + bl; - return lo >>> 0; -} -exports.sum64_lo = sum64_lo; - -function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) { - var carry = 0; - var lo = al; - lo = (lo + bl) >>> 0; - carry += lo < al ? 1 : 0; - lo = (lo + cl) >>> 0; - carry += lo < cl ? 1 : 0; - lo = (lo + dl) >>> 0; - carry += lo < dl ? 1 : 0; - - var hi = ah + bh + ch + dh + carry; - return hi >>> 0; -} -exports.sum64_4_hi = sum64_4_hi; - -function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) { - var lo = al + bl + cl + dl; - return lo >>> 0; -} -exports.sum64_4_lo = sum64_4_lo; - -function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { - var carry = 0; - var lo = al; - lo = (lo + bl) >>> 0; - carry += lo < al ? 1 : 0; - lo = (lo + cl) >>> 0; - carry += lo < cl ? 1 : 0; - lo = (lo + dl) >>> 0; - carry += lo < dl ? 1 : 0; - lo = (lo + el) >>> 0; - carry += lo < el ? 1 : 0; - - var hi = ah + bh + ch + dh + eh + carry; - return hi >>> 0; -} -exports.sum64_5_hi = sum64_5_hi; - -function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) { - var lo = al + bl + cl + dl + el; - - return lo >>> 0; -} -exports.sum64_5_lo = sum64_5_lo; - -function rotr64_hi(ah, al, num) { - var r = (al << (32 - num)) | (ah >>> num); - return r >>> 0; -} -exports.rotr64_hi = rotr64_hi; - -function rotr64_lo(ah, al, num) { - var r = (ah << (32 - num)) | (al >>> num); - return r >>> 0; -} -exports.rotr64_lo = rotr64_lo; - -function shr64_hi(ah, al, num) { - return ah >>> num; -} -exports.shr64_hi = shr64_hi; - -function shr64_lo(ah, al, num) { - var r = (ah << (32 - num)) | (al >>> num); - return r >>> 0; -} -exports.shr64_lo = shr64_lo; - -},{"inherits":33,"minimalistic-assert":35}],33:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }) - } - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } - } -} - -},{}],34:[function(require,module,exports){ -(function (process,global){ -/** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.5.7 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2016 - * @license MIT - */ -/*jslint bitwise: true */ -(function () { - 'use strict'; - - var root = typeof window === 'object' ? window : {}; - var NODE_JS = !root.JS_SHA3_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node; - if (NODE_JS) { - root = global; - } - var COMMON_JS = !root.JS_SHA3_NO_COMMON_JS && typeof module === 'object' && module.exports; - var HEX_CHARS = '0123456789abcdef'.split(''); - var SHAKE_PADDING = [31, 7936, 2031616, 520093696]; - var KECCAK_PADDING = [1, 256, 65536, 16777216]; - var PADDING = [6, 1536, 393216, 100663296]; - var SHIFT = [0, 8, 16, 24]; - var RC = [1, 0, 32898, 0, 32906, 2147483648, 2147516416, 2147483648, 32907, 0, 2147483649, - 0, 2147516545, 2147483648, 32777, 2147483648, 138, 0, 136, 0, 2147516425, 0, - 2147483658, 0, 2147516555, 0, 139, 2147483648, 32905, 2147483648, 32771, - 2147483648, 32770, 2147483648, 128, 2147483648, 32778, 0, 2147483658, 2147483648, - 2147516545, 2147483648, 32896, 2147483648, 2147483649, 0, 2147516424, 2147483648]; - var BITS = [224, 256, 384, 512]; - var SHAKE_BITS = [128, 256]; - var OUTPUT_TYPES = ['hex', 'buffer', 'arrayBuffer', 'array']; - - var createOutputMethod = function (bits, padding, outputType) { - return function (message) { - return new Keccak(bits, padding, bits).update(message)[outputType](); - }; - }; - - var createShakeOutputMethod = function (bits, padding, outputType) { - return function (message, outputBits) { - return new Keccak(bits, padding, outputBits).update(message)[outputType](); - }; - }; - - var createMethod = function (bits, padding) { - var method = createOutputMethod(bits, padding, 'hex'); - method.create = function () { - return new Keccak(bits, padding, bits); - }; - method.update = function (message) { - return method.create().update(message); - }; - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createOutputMethod(bits, padding, type); - } - return method; - }; - - var createShakeMethod = function (bits, padding) { - var method = createShakeOutputMethod(bits, padding, 'hex'); - method.create = function (outputBits) { - return new Keccak(bits, padding, outputBits); - }; - method.update = function (message, outputBits) { - return method.create(outputBits).update(message); - }; - for (var i = 0; i < OUTPUT_TYPES.length; ++i) { - var type = OUTPUT_TYPES[i]; - method[type] = createShakeOutputMethod(bits, padding, type); - } - return method; - }; - - var algorithms = [ - {name: 'keccak', padding: KECCAK_PADDING, bits: BITS, createMethod: createMethod}, - {name: 'sha3', padding: PADDING, bits: BITS, createMethod: createMethod}, - {name: 'shake', padding: SHAKE_PADDING, bits: SHAKE_BITS, createMethod: createShakeMethod} - ]; - - var methods = {}, methodNames = []; - - for (var i = 0; i < algorithms.length; ++i) { - var algorithm = algorithms[i]; - var bits = algorithm.bits; - for (var j = 0; j < bits.length; ++j) { - var methodName = algorithm.name +'_' + bits[j]; - methodNames.push(methodName); - methods[methodName] = algorithm.createMethod(bits[j], algorithm.padding); - } - } - - function Keccak(bits, padding, outputBits) { - this.blocks = []; - this.s = []; - this.padding = padding; - this.outputBits = outputBits; - this.reset = true; - this.block = 0; - this.start = 0; - this.blockCount = (1600 - (bits << 1)) >> 5; - this.byteCount = this.blockCount << 2; - this.outputBlocks = outputBits >> 5; - this.extraBytes = (outputBits & 31) >> 3; - - for (var i = 0; i < 50; ++i) { - this.s[i] = 0; - } - } - - Keccak.prototype.update = function (message) { - var notString = typeof message !== 'string'; - if (notString && message.constructor === ArrayBuffer) { - message = new Uint8Array(message); - } - var length = message.length, blocks = this.blocks, byteCount = this.byteCount, - blockCount = this.blockCount, index = 0, s = this.s, i, code; - - while (index < length) { - if (this.reset) { - this.reset = false; - blocks[0] = this.block; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - if (notString) { - for (i = this.start; index < length && i < byteCount; ++index) { - blocks[i >> 2] |= message[index] << SHIFT[i++ & 3]; - } - } else { - for (i = this.start; index < length && i < byteCount; ++index) { - code = message.charCodeAt(index); - if (code < 0x80) { - blocks[i >> 2] |= code << SHIFT[i++ & 3]; - } else if (code < 0x800) { - blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else if (code < 0xd800 || code >= 0xe000) { - blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } else { - code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff)); - blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3]; - blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3]; - } - } - } - this.lastByteIndex = i; - if (i >= byteCount) { - this.start = i - byteCount; - this.block = blocks[blockCount]; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - this.reset = true; - } else { - this.start = i; - } - } - return this; - }; - - Keccak.prototype.finalize = function () { - var blocks = this.blocks, i = this.lastByteIndex, blockCount = this.blockCount, s = this.s; - blocks[i >> 2] |= this.padding[i & 3]; - if (this.lastByteIndex === this.byteCount) { - blocks[0] = blocks[blockCount]; - for (i = 1; i < blockCount + 1; ++i) { - blocks[i] = 0; - } - } - blocks[blockCount - 1] |= 0x80000000; - for (i = 0; i < blockCount; ++i) { - s[i] ^= blocks[i]; - } - f(s); - }; - - Keccak.prototype.toString = Keccak.prototype.hex = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var hex = '', block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - block = s[i]; - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F] + - HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F] + - HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F] + - HEX_CHARS[(block >> 28) & 0x0F] + HEX_CHARS[(block >> 24) & 0x0F]; - } - if (j % blockCount === 0) { - f(s); - i = 0; - } - } - if (extraBytes) { - block = s[i]; - if (extraBytes > 0) { - hex += HEX_CHARS[(block >> 4) & 0x0F] + HEX_CHARS[block & 0x0F]; - } - if (extraBytes > 1) { - hex += HEX_CHARS[(block >> 12) & 0x0F] + HEX_CHARS[(block >> 8) & 0x0F]; - } - if (extraBytes > 2) { - hex += HEX_CHARS[(block >> 20) & 0x0F] + HEX_CHARS[(block >> 16) & 0x0F]; - } - } - return hex; - }; - - Keccak.prototype.arrayBuffer = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var bytes = this.outputBits >> 3; - var buffer; - if (extraBytes) { - buffer = new ArrayBuffer((outputBlocks + 1) << 2); - } else { - buffer = new ArrayBuffer(bytes); - } - var array = new Uint32Array(buffer); - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - array[j] = s[i]; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - array[i] = s[i]; - buffer = buffer.slice(0, bytes); - } - return buffer; - }; - - Keccak.prototype.buffer = Keccak.prototype.arrayBuffer; - - Keccak.prototype.digest = Keccak.prototype.array = function () { - this.finalize(); - - var blockCount = this.blockCount, s = this.s, outputBlocks = this.outputBlocks, - extraBytes = this.extraBytes, i = 0, j = 0; - var array = [], offset, block; - while (j < outputBlocks) { - for (i = 0; i < blockCount && j < outputBlocks; ++i, ++j) { - offset = j << 2; - block = s[i]; - array[offset] = block & 0xFF; - array[offset + 1] = (block >> 8) & 0xFF; - array[offset + 2] = (block >> 16) & 0xFF; - array[offset + 3] = (block >> 24) & 0xFF; - } - if (j % blockCount === 0) { - f(s); - } - } - if (extraBytes) { - offset = j << 2; - block = s[i]; - if (extraBytes > 0) { - array[offset] = block & 0xFF; - } - if (extraBytes > 1) { - array[offset + 1] = (block >> 8) & 0xFF; - } - if (extraBytes > 2) { - array[offset + 2] = (block >> 16) & 0xFF; - } - } - return array; - }; - - var f = function (s) { - var h, l, n, c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, - b0, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, b16, b17, - b18, b19, b20, b21, b22, b23, b24, b25, b26, b27, b28, b29, b30, b31, b32, b33, - b34, b35, b36, b37, b38, b39, b40, b41, b42, b43, b44, b45, b46, b47, b48, b49; - for (n = 0; n < 48; n += 2) { - c0 = s[0] ^ s[10] ^ s[20] ^ s[30] ^ s[40]; - c1 = s[1] ^ s[11] ^ s[21] ^ s[31] ^ s[41]; - c2 = s[2] ^ s[12] ^ s[22] ^ s[32] ^ s[42]; - c3 = s[3] ^ s[13] ^ s[23] ^ s[33] ^ s[43]; - c4 = s[4] ^ s[14] ^ s[24] ^ s[34] ^ s[44]; - c5 = s[5] ^ s[15] ^ s[25] ^ s[35] ^ s[45]; - c6 = s[6] ^ s[16] ^ s[26] ^ s[36] ^ s[46]; - c7 = s[7] ^ s[17] ^ s[27] ^ s[37] ^ s[47]; - c8 = s[8] ^ s[18] ^ s[28] ^ s[38] ^ s[48]; - c9 = s[9] ^ s[19] ^ s[29] ^ s[39] ^ s[49]; - - h = c8 ^ ((c2 << 1) | (c3 >>> 31)); - l = c9 ^ ((c3 << 1) | (c2 >>> 31)); - s[0] ^= h; - s[1] ^= l; - s[10] ^= h; - s[11] ^= l; - s[20] ^= h; - s[21] ^= l; - s[30] ^= h; - s[31] ^= l; - s[40] ^= h; - s[41] ^= l; - h = c0 ^ ((c4 << 1) | (c5 >>> 31)); - l = c1 ^ ((c5 << 1) | (c4 >>> 31)); - s[2] ^= h; - s[3] ^= l; - s[12] ^= h; - s[13] ^= l; - s[22] ^= h; - s[23] ^= l; - s[32] ^= h; - s[33] ^= l; - s[42] ^= h; - s[43] ^= l; - h = c2 ^ ((c6 << 1) | (c7 >>> 31)); - l = c3 ^ ((c7 << 1) | (c6 >>> 31)); - s[4] ^= h; - s[5] ^= l; - s[14] ^= h; - s[15] ^= l; - s[24] ^= h; - s[25] ^= l; - s[34] ^= h; - s[35] ^= l; - s[44] ^= h; - s[45] ^= l; - h = c4 ^ ((c8 << 1) | (c9 >>> 31)); - l = c5 ^ ((c9 << 1) | (c8 >>> 31)); - s[6] ^= h; - s[7] ^= l; - s[16] ^= h; - s[17] ^= l; - s[26] ^= h; - s[27] ^= l; - s[36] ^= h; - s[37] ^= l; - s[46] ^= h; - s[47] ^= l; - h = c6 ^ ((c0 << 1) | (c1 >>> 31)); - l = c7 ^ ((c1 << 1) | (c0 >>> 31)); - s[8] ^= h; - s[9] ^= l; - s[18] ^= h; - s[19] ^= l; - s[28] ^= h; - s[29] ^= l; - s[38] ^= h; - s[39] ^= l; - s[48] ^= h; - s[49] ^= l; - - b0 = s[0]; - b1 = s[1]; - b32 = (s[11] << 4) | (s[10] >>> 28); - b33 = (s[10] << 4) | (s[11] >>> 28); - b14 = (s[20] << 3) | (s[21] >>> 29); - b15 = (s[21] << 3) | (s[20] >>> 29); - b46 = (s[31] << 9) | (s[30] >>> 23); - b47 = (s[30] << 9) | (s[31] >>> 23); - b28 = (s[40] << 18) | (s[41] >>> 14); - b29 = (s[41] << 18) | (s[40] >>> 14); - b20 = (s[2] << 1) | (s[3] >>> 31); - b21 = (s[3] << 1) | (s[2] >>> 31); - b2 = (s[13] << 12) | (s[12] >>> 20); - b3 = (s[12] << 12) | (s[13] >>> 20); - b34 = (s[22] << 10) | (s[23] >>> 22); - b35 = (s[23] << 10) | (s[22] >>> 22); - b16 = (s[33] << 13) | (s[32] >>> 19); - b17 = (s[32] << 13) | (s[33] >>> 19); - b48 = (s[42] << 2) | (s[43] >>> 30); - b49 = (s[43] << 2) | (s[42] >>> 30); - b40 = (s[5] << 30) | (s[4] >>> 2); - b41 = (s[4] << 30) | (s[5] >>> 2); - b22 = (s[14] << 6) | (s[15] >>> 26); - b23 = (s[15] << 6) | (s[14] >>> 26); - b4 = (s[25] << 11) | (s[24] >>> 21); - b5 = (s[24] << 11) | (s[25] >>> 21); - b36 = (s[34] << 15) | (s[35] >>> 17); - b37 = (s[35] << 15) | (s[34] >>> 17); - b18 = (s[45] << 29) | (s[44] >>> 3); - b19 = (s[44] << 29) | (s[45] >>> 3); - b10 = (s[6] << 28) | (s[7] >>> 4); - b11 = (s[7] << 28) | (s[6] >>> 4); - b42 = (s[17] << 23) | (s[16] >>> 9); - b43 = (s[16] << 23) | (s[17] >>> 9); - b24 = (s[26] << 25) | (s[27] >>> 7); - b25 = (s[27] << 25) | (s[26] >>> 7); - b6 = (s[36] << 21) | (s[37] >>> 11); - b7 = (s[37] << 21) | (s[36] >>> 11); - b38 = (s[47] << 24) | (s[46] >>> 8); - b39 = (s[46] << 24) | (s[47] >>> 8); - b30 = (s[8] << 27) | (s[9] >>> 5); - b31 = (s[9] << 27) | (s[8] >>> 5); - b12 = (s[18] << 20) | (s[19] >>> 12); - b13 = (s[19] << 20) | (s[18] >>> 12); - b44 = (s[29] << 7) | (s[28] >>> 25); - b45 = (s[28] << 7) | (s[29] >>> 25); - b26 = (s[38] << 8) | (s[39] >>> 24); - b27 = (s[39] << 8) | (s[38] >>> 24); - b8 = (s[48] << 14) | (s[49] >>> 18); - b9 = (s[49] << 14) | (s[48] >>> 18); - - s[0] = b0 ^ (~b2 & b4); - s[1] = b1 ^ (~b3 & b5); - s[10] = b10 ^ (~b12 & b14); - s[11] = b11 ^ (~b13 & b15); - s[20] = b20 ^ (~b22 & b24); - s[21] = b21 ^ (~b23 & b25); - s[30] = b30 ^ (~b32 & b34); - s[31] = b31 ^ (~b33 & b35); - s[40] = b40 ^ (~b42 & b44); - s[41] = b41 ^ (~b43 & b45); - s[2] = b2 ^ (~b4 & b6); - s[3] = b3 ^ (~b5 & b7); - s[12] = b12 ^ (~b14 & b16); - s[13] = b13 ^ (~b15 & b17); - s[22] = b22 ^ (~b24 & b26); - s[23] = b23 ^ (~b25 & b27); - s[32] = b32 ^ (~b34 & b36); - s[33] = b33 ^ (~b35 & b37); - s[42] = b42 ^ (~b44 & b46); - s[43] = b43 ^ (~b45 & b47); - s[4] = b4 ^ (~b6 & b8); - s[5] = b5 ^ (~b7 & b9); - s[14] = b14 ^ (~b16 & b18); - s[15] = b15 ^ (~b17 & b19); - s[24] = b24 ^ (~b26 & b28); - s[25] = b25 ^ (~b27 & b29); - s[34] = b34 ^ (~b36 & b38); - s[35] = b35 ^ (~b37 & b39); - s[44] = b44 ^ (~b46 & b48); - s[45] = b45 ^ (~b47 & b49); - s[6] = b6 ^ (~b8 & b0); - s[7] = b7 ^ (~b9 & b1); - s[16] = b16 ^ (~b18 & b10); - s[17] = b17 ^ (~b19 & b11); - s[26] = b26 ^ (~b28 & b20); - s[27] = b27 ^ (~b29 & b21); - s[36] = b36 ^ (~b38 & b30); - s[37] = b37 ^ (~b39 & b31); - s[46] = b46 ^ (~b48 & b40); - s[47] = b47 ^ (~b49 & b41); - s[8] = b8 ^ (~b0 & b2); - s[9] = b9 ^ (~b1 & b3); - s[18] = b18 ^ (~b10 & b12); - s[19] = b19 ^ (~b11 & b13); - s[28] = b28 ^ (~b20 & b22); - s[29] = b29 ^ (~b21 & b23); - s[38] = b38 ^ (~b30 & b32); - s[39] = b39 ^ (~b31 & b33); - s[48] = b48 ^ (~b40 & b42); - s[49] = b49 ^ (~b41 & b43); - - s[0] ^= RC[n]; - s[1] ^= RC[n + 1]; - } - }; - - if (COMMON_JS) { - module.exports = methods; - } else { - for (var i = 0; i < methodNames.length; ++i) { - root[methodNames[i]] = methods[methodNames[i]]; - } - } -})(); - -}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":36}],35:[function(require,module,exports){ -module.exports = assert; - -function assert(val, msg) { - if (!val) - throw new Error(msg || 'Assertion failed'); -} - -assert.equal = function assertEqual(l, r, msg) { - if (l != r) - throw new Error(msg || ('Assertion failed: ' + l + ' != ' + r)); -}; - -},{}],36:[function(require,module,exports){ -module.exports = { browser: true }; -},{}],37:[function(require,module,exports){ -(function (setImmediate){ -"use strict"; - -(function(root) { - var MAX_VALUE = 0x7fffffff; - - // The SHA256 and PBKDF2 implementation are from scrypt-async-js: - // See: https://github.com/dchest/scrypt-async-js - function SHA256(m) { - var K = [ - 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, - 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, - 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, - 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, - 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, - 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, - 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, - 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, - 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, - 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, - 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, - 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, - 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 - ]; - - var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a; - var h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19; - var w = new Array(64); - - function blocks(p) { - var off = 0, len = p.length; - while (len >= 64) { - var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, u, i, j, t1, t2; - - for (i = 0; i < 16; i++) { - j = off + i*4; - w[i] = ((p[j] & 0xff)<<24) | ((p[j+1] & 0xff)<<16) | - ((p[j+2] & 0xff)<<8) | (p[j+3] & 0xff); - } - - for (i = 16; i < 64; i++) { - u = w[i-2]; - t1 = ((u>>>17) | (u<<(32-17))) ^ ((u>>>19) | (u<<(32-19))) ^ (u>>>10); - - u = w[i-15]; - t2 = ((u>>>7) | (u<<(32-7))) ^ ((u>>>18) | (u<<(32-18))) ^ (u>>>3); - - w[i] = (((t1 + w[i-7]) | 0) + ((t2 + w[i-16]) | 0)) | 0; - } - - for (i = 0; i < 64; i++) { - t1 = ((((((e>>>6) | (e<<(32-6))) ^ ((e>>>11) | (e<<(32-11))) ^ - ((e>>>25) | (e<<(32-25)))) + ((e & f) ^ (~e & g))) | 0) + - ((h + ((K[i] + w[i]) | 0)) | 0)) | 0; - - t2 = ((((a>>>2) | (a<<(32-2))) ^ ((a>>>13) | (a<<(32-13))) ^ - ((a>>>22) | (a<<(32-22)))) + ((a & b) ^ (a & c) ^ (b & c))) | 0; - - h = g; - g = f; - f = e; - e = (d + t1) | 0; - d = c; - c = b; - b = a; - a = (t1 + t2) | 0; - } - - h0 = (h0 + a) | 0; - h1 = (h1 + b) | 0; - h2 = (h2 + c) | 0; - h3 = (h3 + d) | 0; - h4 = (h4 + e) | 0; - h5 = (h5 + f) | 0; - h6 = (h6 + g) | 0; - h7 = (h7 + h) | 0; - - off += 64; - len -= 64; - } - } - - blocks(m); - - var i, bytesLeft = m.length % 64, - bitLenHi = (m.length / 0x20000000) | 0, - bitLenLo = m.length << 3, - numZeros = (bytesLeft < 56) ? 56 : 120, - p = m.slice(m.length - bytesLeft, m.length); - - p.push(0x80); - for (i = bytesLeft + 1; i < numZeros; i++) { p.push(0); } - p.push((bitLenHi>>>24) & 0xff); - p.push((bitLenHi>>>16) & 0xff); - p.push((bitLenHi>>>8) & 0xff); - p.push((bitLenHi>>>0) & 0xff); - p.push((bitLenLo>>>24) & 0xff); - p.push((bitLenLo>>>16) & 0xff); - p.push((bitLenLo>>>8) & 0xff); - p.push((bitLenLo>>>0) & 0xff); - - blocks(p); - - return [ - (h0>>>24) & 0xff, (h0>>>16) & 0xff, (h0>>>8) & 0xff, (h0>>>0) & 0xff, - (h1>>>24) & 0xff, (h1>>>16) & 0xff, (h1>>>8) & 0xff, (h1>>>0) & 0xff, - (h2>>>24) & 0xff, (h2>>>16) & 0xff, (h2>>>8) & 0xff, (h2>>>0) & 0xff, - (h3>>>24) & 0xff, (h3>>>16) & 0xff, (h3>>>8) & 0xff, (h3>>>0) & 0xff, - (h4>>>24) & 0xff, (h4>>>16) & 0xff, (h4>>>8) & 0xff, (h4>>>0) & 0xff, - (h5>>>24) & 0xff, (h5>>>16) & 0xff, (h5>>>8) & 0xff, (h5>>>0) & 0xff, - (h6>>>24) & 0xff, (h6>>>16) & 0xff, (h6>>>8) & 0xff, (h6>>>0) & 0xff, - (h7>>>24) & 0xff, (h7>>>16) & 0xff, (h7>>>8) & 0xff, (h7>>>0) & 0xff - ]; - } - - function PBKDF2_HMAC_SHA256_OneIter(password, salt, dkLen) { - // compress password if it's longer than hash block length - password = password.length <= 64 ? password : SHA256(password); - - var i; - var innerLen = 64 + salt.length + 4; - var inner = new Array(innerLen); - var outerKey = new Array(64); - var dk = []; - - // inner = (password ^ ipad) || salt || counter - for (i = 0; i < 64; i++) inner[i] = 0x36; - for (i = 0; i < password.length; i++) inner[i] ^= password[i]; - for (i = 0; i < salt.length; i++) inner[64+i] = salt[i]; - for (i = innerLen - 4; i < innerLen; i++) inner[i] = 0; - - // outerKey = password ^ opad - for (i = 0; i < 64; i++) outerKey[i] = 0x5c; - for (i = 0; i < password.length; i++) outerKey[i] ^= password[i]; - - // increments counter inside inner - function incrementCounter() { - for (var i = innerLen-1; i >= innerLen-4; i--) { - inner[i]++; - if (inner[i] <= 0xff) return; - inner[i] = 0; - } - } - - // output blocks = SHA256(outerKey || SHA256(inner)) ... - while (dkLen >= 32) { - incrementCounter(); - dk = dk.concat(SHA256(outerKey.concat(SHA256(inner)))); - dkLen -= 32; - } - if (dkLen > 0) { - incrementCounter(); - dk = dk.concat(SHA256(outerKey.concat(SHA256(inner))).slice(0, dkLen)); - } - - return dk; - } - - // The following is an adaptation of scryptsy - // See: https://www.npmjs.com/package/scryptsy - function blockmix_salsa8(BY, Yi, r, x, _X) { - var i; - - arraycopy(BY, (2 * r - 1) * 16, _X, 0, 16); - for (i = 0; i < 2 * r; i++) { - blockxor(BY, i * 16, _X, 16); - salsa20_8(_X, x); - arraycopy(_X, 0, BY, Yi + (i * 16), 16); - } - - for (i = 0; i < r; i++) { - arraycopy(BY, Yi + (i * 2) * 16, BY, (i * 16), 16); - } - - for (i = 0; i < r; i++) { - arraycopy(BY, Yi + (i * 2 + 1) * 16, BY, (i + r) * 16, 16); - } - } - - function R(a, b) { - return (a << b) | (a >>> (32 - b)); - } - - function salsa20_8(B, x) { - arraycopy(B, 0, x, 0, 16); - - for (var i = 8; i > 0; i -= 2) { - x[ 4] ^= R(x[ 0] + x[12], 7); - x[ 8] ^= R(x[ 4] + x[ 0], 9); - x[12] ^= R(x[ 8] + x[ 4], 13); - x[ 0] ^= R(x[12] + x[ 8], 18); - x[ 9] ^= R(x[ 5] + x[ 1], 7); - x[13] ^= R(x[ 9] + x[ 5], 9); - x[ 1] ^= R(x[13] + x[ 9], 13); - x[ 5] ^= R(x[ 1] + x[13], 18); - x[14] ^= R(x[10] + x[ 6], 7); - x[ 2] ^= R(x[14] + x[10], 9); - x[ 6] ^= R(x[ 2] + x[14], 13); - x[10] ^= R(x[ 6] + x[ 2], 18); - x[ 3] ^= R(x[15] + x[11], 7); - x[ 7] ^= R(x[ 3] + x[15], 9); - x[11] ^= R(x[ 7] + x[ 3], 13); - x[15] ^= R(x[11] + x[ 7], 18); - x[ 1] ^= R(x[ 0] + x[ 3], 7); - x[ 2] ^= R(x[ 1] + x[ 0], 9); - x[ 3] ^= R(x[ 2] + x[ 1], 13); - x[ 0] ^= R(x[ 3] + x[ 2], 18); - x[ 6] ^= R(x[ 5] + x[ 4], 7); - x[ 7] ^= R(x[ 6] + x[ 5], 9); - x[ 4] ^= R(x[ 7] + x[ 6], 13); - x[ 5] ^= R(x[ 4] + x[ 7], 18); - x[11] ^= R(x[10] + x[ 9], 7); - x[ 8] ^= R(x[11] + x[10], 9); - x[ 9] ^= R(x[ 8] + x[11], 13); - x[10] ^= R(x[ 9] + x[ 8], 18); - x[12] ^= R(x[15] + x[14], 7); - x[13] ^= R(x[12] + x[15], 9); - x[14] ^= R(x[13] + x[12], 13); - x[15] ^= R(x[14] + x[13], 18); - } - - for (i = 0; i < 16; ++i) { - B[i] += x[i]; - } - } - - // naive approach... going back to loop unrolling may yield additional performance - function blockxor(S, Si, D, len) { - for (var i = 0; i < len; i++) { - D[i] ^= S[Si + i] - } - } - - function arraycopy(src, srcPos, dest, destPos, length) { - while (length--) { - dest[destPos++] = src[srcPos++]; - } - } - - function checkBufferish(o) { - if (!o || typeof(o.length) !== 'number') { - return false; - } - for (var i = 0; i < o.length; i++) { - if (typeof(o[i]) !== 'number') { return false; } - - var v = parseInt(o[i]); - if (v != o[i] || v < 0 || v >= 256) { - return false; - } - } - return true; - } - - function ensureInteger(value, name) { - var intValue = parseInt(value); - if (value != intValue) { throw new Error('invalid ' + name); } - return intValue; - } - - // N = Cpu cost, r = Memory cost, p = parallelization cost - // callback(error, progress, key) - function scrypt(password, salt, N, r, p, dkLen, callback) { - - if (!callback) { throw new Error('missing callback'); } - - N = ensureInteger(N, 'N'); - r = ensureInteger(r, 'r'); - p = ensureInteger(p, 'p'); - - dkLen = ensureInteger(dkLen, 'dkLen'); - - if (N === 0 || (N & (N - 1)) !== 0) { throw new Error('N must be power of 2'); } - - if (N > MAX_VALUE / 128 / r) { throw new Error('N too large'); } - if (r > MAX_VALUE / 128 / p) { throw new Error('r too large'); } - - if (!checkBufferish(password)) { - throw new Error('password must be an array or buffer'); - } - password = Array.prototype.slice.call(password); - - if (!checkBufferish(salt)) { - throw new Error('salt must be an array or buffer'); - } - salt = Array.prototype.slice.call(salt); - - var b = PBKDF2_HMAC_SHA256_OneIter(password, salt, p * 128 * r); - var B = new Uint32Array(p * 32 * r) - for (var i = 0; i < B.length; i++) { - var j = i * 4; - B[i] = ((b[j + 3] & 0xff) << 24) | - ((b[j + 2] & 0xff) << 16) | - ((b[j + 1] & 0xff) << 8) | - ((b[j + 0] & 0xff) << 0); - } - - var XY = new Uint32Array(64 * r); - var V = new Uint32Array(32 * r * N); - - var Yi = 32 * r; - - // scratch space - var x = new Uint32Array(16); // salsa20_8 - var _X = new Uint32Array(16); // blockmix_salsa8 - - var totalOps = p * N * 2; - var currentOp = 0; - var lastPercent10 = null; - - // Set this to true to abandon the scrypt on the next step - var stop = false; - - // State information - var state = 0; - var i0 = 0, i1; - var Bi; - - // How many blockmix_salsa8 can we do per step? - var limit = parseInt(1000 / r); - - // Trick from scrypt-async; if there is a setImmediate shim in place, use it - var nextTick = (typeof(setImmediate) !== 'undefined') ? setImmediate : setTimeout; - - // This is really all I changed; making scryptsy a state machine so we occasionally - // stop and give other evnts on the evnt loop a chance to run. ~RicMoo - var incrementalSMix = function() { - if (stop) { - return callback(new Error('cancelled'), currentOp / totalOps); - } - - switch (state) { - case 0: - // for (var i = 0; i < p; i++)... - Bi = i0 * 32 * r; - - arraycopy(B, Bi, XY, 0, Yi); // ROMix - 1 - - state = 1; // Move to ROMix 2 - i1 = 0; - - // Fall through - - case 1: - - // Run up to 1000 steps of the first inner smix loop - var steps = N - i1; - if (steps > limit) { steps = limit; } - for (var i = 0; i < steps; i++) { // ROMix - 2 - arraycopy(XY, 0, V, (i1 + i) * Yi, Yi) // ROMix - 3 - blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 4 - } - - // for (var i = 0; i < N; i++) - i1 += steps; - currentOp += steps; - - // Call the callback with the progress (optionally stopping us) - var percent10 = parseInt(1000 * currentOp / totalOps); - if (percent10 !== lastPercent10) { - stop = callback(null, currentOp / totalOps); - if (stop) { break; } - lastPercent10 = percent10; - } - - if (i1 < N) { - break; - } - - i1 = 0; // Move to ROMix 6 - state = 2; - - // Fall through - - case 2: - - // Run up to 1000 steps of the second inner smix loop - var steps = N - i1; - if (steps > limit) { steps = limit; } - for (var i = 0; i < steps; i++) { // ROMix - 6 - var offset = (2 * r - 1) * 16; // ROMix - 7 - var j = XY[offset] & (N - 1); - blockxor(V, j * Yi, XY, Yi); // ROMix - 8 (inner) - blockmix_salsa8(XY, Yi, r, x, _X); // ROMix - 9 (outer) - } - - // for (var i = 0; i < N; i++)... - i1 += steps; - currentOp += steps; - - // Call the callback with the progress (optionally stopping us) - var percent10 = parseInt(1000 * currentOp / totalOps); - if (percent10 !== lastPercent10) { - stop = callback(null, currentOp / totalOps); - if (stop) { break; } - lastPercent10 = percent10; - } - - if (i1 < N) { - break; - } - - arraycopy(XY, 0, B, Bi, Yi); // ROMix - 10 - - // for (var i = 0; i < p; i++)... - i0++; - if (i0 < p) { - state = 0; - break; - } - - b = []; - for (var i = 0; i < B.length; i++) { - b.push((B[i] >> 0) & 0xff); - b.push((B[i] >> 8) & 0xff); - b.push((B[i] >> 16) & 0xff); - b.push((B[i] >> 24) & 0xff); - } - - var derivedKey = PBKDF2_HMAC_SHA256_OneIter(password, b, dkLen); - - // Done; don't break (which would reschedule) - return callback(null, 1.0, derivedKey); - } - - // Schedule the next steps - nextTick(incrementalSMix); - } - - // Bootstrap the incremental smix - incrementalSMix(); - } - - // node.js - if (typeof(exports) !== 'undefined') { - module.exports = scrypt; - - // RequireJS/AMD - // http://www.requirejs.org/docs/api.html - // https://github.com/amdjs/amdjs-api/wiki/AMD - } else if (typeof(define) === 'function' && define.amd) { - define(scrypt); - - // Web Browsers - } else if (root) { - - // If there was an existing library "scrypt", make sure it is still available - if (root.scrypt) { - root._scrypt = root.scrypt; - } - - root.scrypt = scrypt; - } - -})(this); - -}).call(this,require("timers").setImmediate) -},{"timers":38}],38:[function(require,module,exports){ -(function (global){ -module.exports = { setImmediate: global.setImmediate }; -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],39:[function(require,module,exports){ -(function (global){ - -var rng; - -if (global.crypto && crypto.getRandomValues) { - // WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto - // Moderately fast, high quality - var _rnds8 = new Uint8Array(16); - rng = function whatwgRNG() { - crypto.getRandomValues(_rnds8); - return _rnds8; - }; -} - -if (!rng) { - // Math.random()-based (RNG) - // - // If all else fails, use Math.random(). It's fast, but is of unspecified - // quality. - var _rnds = new Array(16); - rng = function() { - for (var i = 0, r; i < 16; i++) { - if ((i & 0x03) === 0) r = Math.random() * 0x100000000; - _rnds[i] = r >>> ((i & 0x03) << 3) & 0xff; - } - - return _rnds; - }; -} - -module.exports = rng; - - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{}],40:[function(require,module,exports){ -// uuid.js -// -// Copyright (c) 2010-2012 Robert Kieffer -// MIT License - http://opensource.org/licenses/mit-license.php - -// Unique ID creation requires a high quality random # generator. We feature -// detect to determine the best RNG source, normalizing to a function that -// returns 128-bits of randomness, since that's what's usually required -var _rng = require('./rng'); - -// Maps for number <-> hex string conversion -var _byteToHex = []; -var _hexToByte = {}; -for (var i = 0; i < 256; i++) { - _byteToHex[i] = (i + 0x100).toString(16).substr(1); - _hexToByte[_byteToHex[i]] = i; -} - -// **`parse()` - Parse a UUID into it's component bytes** -function parse(s, buf, offset) { - var i = (buf && offset) || 0, ii = 0; - - buf = buf || []; - s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) { - if (ii < 16) { // Don't overflow! - buf[i + ii++] = _hexToByte[oct]; - } - }); - - // Zero out remaining bytes if string was short - while (ii < 16) { - buf[i + ii++] = 0; - } - - return buf; -} - -// **`unparse()` - Convert UUID byte array (ala parse()) into a string** -function unparse(buf, offset) { - var i = offset || 0, bth = _byteToHex; - return bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + '-' + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]] + - bth[buf[i++]] + bth[buf[i++]]; -} - -// **`v1()` - Generate time-based UUID** -// -// Inspired by https://github.com/LiosK/UUID.js -// and http://docs.python.org/library/uuid.html - -// random #'s we need to init node and clockseq -var _seedBytes = _rng(); - -// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1) -var _nodeId = [ - _seedBytes[0] | 0x01, - _seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5] -]; - -// Per 4.2.2, randomize (14 bit) clockseq -var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff; - -// Previous uuid creation time -var _lastMSecs = 0, _lastNSecs = 0; - -// See https://github.com/broofa/node-uuid for API details -function v1(options, buf, offset) { - var i = buf && offset || 0; - var b = buf || []; - - options = options || {}; - - var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; - - // UUID timestamps are 100 nano-second units since the Gregorian epoch, - // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so - // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs' - // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00. - var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); - - // Per 4.2.1.2, use count of uuid's generated during the current clock - // cycle to simulate higher resolution clock - var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; - - // Time since last uuid creation (in msecs) - var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000; - - // Per 4.2.1.2, Bump clockseq on clock regression - if (dt < 0 && options.clockseq === undefined) { - clockseq = clockseq + 1 & 0x3fff; - } - - // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new - // time interval - if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) { - nsecs = 0; - } - - // Per 4.2.1.2 Throw error if too many uuids are requested - if (nsecs >= 10000) { - throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec'); - } - - _lastMSecs = msecs; - _lastNSecs = nsecs; - _clockseq = clockseq; - - // Per 4.1.4 - Convert from unix epoch to Gregorian epoch - msecs += 12219292800000; - - // `time_low` - var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; - b[i++] = tl >>> 24 & 0xff; - b[i++] = tl >>> 16 & 0xff; - b[i++] = tl >>> 8 & 0xff; - b[i++] = tl & 0xff; - - // `time_mid` - var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff; - b[i++] = tmh >>> 8 & 0xff; - b[i++] = tmh & 0xff; - - // `time_high_and_version` - b[i++] = tmh >>> 24 & 0xf | 0x10; // include version - b[i++] = tmh >>> 16 & 0xff; - - // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant) - b[i++] = clockseq >>> 8 | 0x80; - - // `clock_seq_low` - b[i++] = clockseq & 0xff; - - // `node` - var node = options.node || _nodeId; - for (var n = 0; n < 6; n++) { - b[i + n] = node[n]; - } - - return buf ? buf : unparse(b); -} - -// **`v4()` - Generate random UUID** - -// See https://github.com/broofa/node-uuid for API details -function v4(options, buf, offset) { - // Deprecated - 'format' argument, as supported in v1.2 - var i = buf && offset || 0; - - if (typeof(options) == 'string') { - buf = options == 'binary' ? new Array(16) : null; - options = null; - } - options = options || {}; - - var rnds = options.random || (options.rng || _rng)(); - - // Per 4.4, set bits for version and `clock_seq_hi_and_reserved` - rnds[6] = (rnds[6] & 0x0f) | 0x40; - rnds[8] = (rnds[8] & 0x3f) | 0x80; - - // Copy bytes to buffer, if provided - if (buf) { - for (var ii = 0; ii < 16; ii++) { - buf[i + ii] = rnds[ii]; - } - } - - return buf || unparse(rnds); -} - -// Export public API -var uuid = v4; -uuid.v1 = v1; -uuid.v4 = v4; -uuid.parse = parse; -uuid.unparse = unparse; - -module.exports = uuid; - -},{"./rng":39}],41:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "abi/5.0.0-beta.136"; - -},{}],42:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI -var bytes_1 = require("@ethersproject/bytes"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var abstract_coder_1 = require("./coders/abstract-coder"); -var address_1 = require("./coders/address"); -var array_1 = require("./coders/array"); -var boolean_1 = require("./coders/boolean"); -var bytes_2 = require("./coders/bytes"); -var fixed_bytes_1 = require("./coders/fixed-bytes"); -var null_1 = require("./coders/null"); -var number_1 = require("./coders/number"); -var string_1 = require("./coders/string"); -var tuple_1 = require("./coders/tuple"); -var fragments_1 = require("./fragments"); -var paramTypeBytes = new RegExp(/^bytes([0-9]*)$/); -var paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/); -var AbiCoder = /** @class */ (function () { - function AbiCoder(coerceFunc) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, AbiCoder); - properties_1.defineReadOnly(this, "coerceFunc", coerceFunc || null); - } - AbiCoder.prototype._getCoder = function (param) { - var _this = this; - switch (param.baseType) { - case "address": - return new address_1.AddressCoder(param.name); - case "bool": - return new boolean_1.BooleanCoder(param.name); - case "string": - return new string_1.StringCoder(param.name); - case "bytes": - return new bytes_2.BytesCoder(param.name); - case "array": - return new array_1.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); - case "tuple": - return new tuple_1.TupleCoder((param.components || []).map(function (component) { - return _this._getCoder(component); - }), param.name); - case "": - return new null_1.NullCoder(param.name); - } - // u?int[0-9]* - var match = param.type.match(paramTypeNumber); - if (match) { - var size = parseInt(match[2] || "256"); - if (size === 0 || size > 256 || (size % 8) !== 0) { - logger.throwArgumentError("invalid " + match[1] + " bit length", "param", param); - } - return new number_1.NumberCoder(size / 8, (match[1] === "int"), param.name); - } - // bytes[0-9]+ - match = param.type.match(paramTypeBytes); - if (match) { - var size = parseInt(match[1]); - if (size === 0 || size > 32) { - logger.throwArgumentError("invalid bytes length", "param", param); - } - return new fixed_bytes_1.FixedBytesCoder(size, param.name); - } - return logger.throwError("invalid type", "type", param.type); - }; - AbiCoder.prototype._getWordSize = function () { return 32; }; - AbiCoder.prototype._getReader = function (data) { - return new abstract_coder_1.Reader(data, this._getWordSize(), this.coerceFunc); - }; - AbiCoder.prototype._getWriter = function () { - return new abstract_coder_1.Writer(this._getWordSize()); - }; - AbiCoder.prototype.encode = function (types, values) { - var _this = this; - if (types.length !== values.length) { - logger.throwError("types/values length mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { - count: { types: types.length, values: values.length }, - value: { types: types, values: values } - }); - } - var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); }); - var coder = (new tuple_1.TupleCoder(coders, "_")); - var writer = this._getWriter(); - coder.encode(writer, values); - return writer.data; - }; - AbiCoder.prototype.decode = function (types, data) { - var _this = this; - var coders = types.map(function (type) { return _this._getCoder(fragments_1.ParamType.from(type)); }); - var coder = new tuple_1.TupleCoder(coders, "_"); - return coder.decode(this._getReader(bytes_1.arrayify(data))); - }; - return AbiCoder; -}()); -exports.AbiCoder = AbiCoder; -exports.defaultAbiCoder = new AbiCoder(); - -},{"./_version":41,"./coders/abstract-coder":43,"./coders/address":44,"./coders/array":46,"./coders/boolean":47,"./coders/bytes":48,"./coders/fixed-bytes":49,"./coders/null":50,"./coders/number":51,"./coders/string":52,"./coders/tuple":53,"./fragments":54,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96}],43:[function(require,module,exports){ -"use trict"; -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var bignumber_1 = require("@ethersproject/bignumber"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("../_version"); -var logger = new logger_1.Logger(_version_1.version); -var Coder = /** @class */ (function () { - function Coder(name, type, localName, dynamic) { - this.name = name; - this.type = type; - this.localName = localName; - this.dynamic = dynamic; - } - Coder.prototype._throwError = function (message, value) { - logger.throwArgumentError(message, this.localName, value); - }; - return Coder; -}()); -exports.Coder = Coder; -var Writer = /** @class */ (function () { - function Writer(wordSize) { - properties_1.defineReadOnly(this, "wordSize", wordSize || 32); - this._data = bytes_1.arrayify([]); - this._padding = new Uint8Array(wordSize); - } - Object.defineProperty(Writer.prototype, "data", { - get: function () { return bytes_1.hexlify(this._data); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Writer.prototype, "length", { - get: function () { return this._data.length; }, - enumerable: true, - configurable: true - }); - Writer.prototype._writeData = function (data) { - this._data = bytes_1.concat([this._data, data]); - return data.length; - }; - // Arrayish items; padded on the right to wordSize - Writer.prototype.writeBytes = function (value) { - var bytes = bytes_1.arrayify(value); - if (bytes.length % this.wordSize) { - bytes = bytes_1.concat([bytes, this._padding.slice(bytes.length % this.wordSize)]); - } - return this._writeData(bytes); - }; - Writer.prototype._getValue = function (value) { - var bytes = bytes_1.arrayify(bignumber_1.BigNumber.from(value)); - if (bytes.length > this.wordSize) { - logger.throwError("value out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { - length: this.wordSize, - offset: bytes.length - }); - } - if (bytes.length % this.wordSize) { - bytes = bytes_1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]); - } - return bytes; - }; - // BigNumberish items; padded on the left to wordSize - Writer.prototype.writeValue = function (value) { - return this._writeData(this._getValue(value)); - }; - Writer.prototype.writeUpdatableValue = function () { - var _this = this; - var offset = this.length; - this.writeValue(0); - return function (value) { - _this._data.set(_this._getValue(value), offset); - }; - }; - return Writer; -}()); -exports.Writer = Writer; -var Reader = /** @class */ (function () { - function Reader(data, wordSize, coerceFunc) { - properties_1.defineReadOnly(this, "_data", bytes_1.arrayify(data)); - properties_1.defineReadOnly(this, "wordSize", wordSize || 32); - properties_1.defineReadOnly(this, "_coerceFunc", coerceFunc); - this._offset = 0; - } - Object.defineProperty(Reader.prototype, "data", { - get: function () { return bytes_1.hexlify(this._data); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Reader.prototype, "consumed", { - get: function () { return this._offset; }, - enumerable: true, - configurable: true - }); - // The default Coerce function - Reader.coerce = function (name, value) { - var match = name.match("^u?int([0-9]+)$"); - if (match && parseInt(match[1]) <= 48) { - value = value.toNumber(); - } - return value; - }; - Reader.prototype.coerce = function (name, value) { - if (this._coerceFunc) { - return this._coerceFunc(name, value); - } - return Reader.coerce(name, value); - }; - Reader.prototype._peekBytes = function (offset, length) { - var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; - if (this._offset + alignedLength > this._data.length) { - logger.throwError("data out-of-bounds", logger_1.Logger.errors.BUFFER_OVERRUN, { - length: this._data.length, - offset: this._offset + alignedLength - }); - } - return this._data.slice(this._offset, this._offset + alignedLength); - }; - Reader.prototype.subReader = function (offset) { - return new Reader(this._data.slice(this._offset + offset), this.wordSize, this._coerceFunc); - }; - Reader.prototype.readBytes = function (length) { - var bytes = this._peekBytes(0, length); - this._offset += bytes.length; - // @TODO: Make sure the length..end bytes are all 0? - return bytes.slice(0, length); - }; - Reader.prototype.readValue = function () { - return bignumber_1.BigNumber.from(this.readBytes(this.wordSize)); - }; - return Reader; -}()); -exports.Reader = Reader; - -},{"../_version":41,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96}],44:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var address_1 = require("@ethersproject/address"); -var bytes_1 = require("@ethersproject/bytes"); -var abstract_coder_1 = require("./abstract-coder"); -var AddressCoder = /** @class */ (function (_super) { - __extends(AddressCoder, _super); - function AddressCoder(localName) { - return _super.call(this, "address", "address", localName, false) || this; - } - AddressCoder.prototype.encode = function (writer, value) { - try { - address_1.getAddress(value); - } - catch (error) { - this._throwError(error.message, value); - } - return writer.writeValue(value); - }; - AddressCoder.prototype.decode = function (reader) { - return address_1.getAddress(bytes_1.hexZeroPad(reader.readValue().toHexString(), 20)); - }; - return AddressCoder; -}(abstract_coder_1.Coder)); -exports.AddressCoder = AddressCoder; - -},{"./abstract-coder":43,"@ethersproject/address":62,"@ethersproject/bytes":70}],45:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_coder_1 = require("./abstract-coder"); -// Clones the functionality of an existing Coder, but without a localName -var AnonymousCoder = /** @class */ (function (_super) { - __extends(AnonymousCoder, _super); - function AnonymousCoder(coder) { - var _this = _super.call(this, coder.name, coder.type, undefined, coder.dynamic) || this; - _this.coder = coder; - return _this; - } - AnonymousCoder.prototype.encode = function (writer, value) { - return this.coder.encode(writer, value); - }; - AnonymousCoder.prototype.decode = function (reader) { - return this.coder.decode(reader); - }; - return AnonymousCoder; -}(abstract_coder_1.Coder)); -exports.AnonymousCoder = AnonymousCoder; - -},{"./abstract-coder":43}],46:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("../_version"); -var logger = new logger_1.Logger(_version_1.version); -var abstract_coder_1 = require("./abstract-coder"); -var anonymous_1 = require("./anonymous"); -function pack(writer, coders, values) { - if (Array.isArray(values)) { - // do nothing - } - else if (values && typeof (values) === "object") { - var arrayValues_1 = []; - coders.forEach(function (coder) { - arrayValues_1.push(values[coder.localName]); - }); - values = arrayValues_1; - } - else { - logger.throwArgumentError("invalid tuple value", "tuple", values); - } - if (coders.length !== values.length) { - logger.throwArgumentError("types/value length mismatch", "tuple", values); - } - var staticWriter = new abstract_coder_1.Writer(writer.wordSize); - var dynamicWriter = new abstract_coder_1.Writer(writer.wordSize); - var updateFuncs = []; - coders.forEach(function (coder, index) { - var value = values[index]; - if (coder.dynamic) { - // Get current dynamic offset (for the future pointer) - var dynamicOffset_1 = dynamicWriter.length; - // Encode the dynamic value into the dynamicWriter - coder.encode(dynamicWriter, value); - // Prepare to populate the correct offset once we are done - var updateFunc_1 = staticWriter.writeUpdatableValue(); - updateFuncs.push(function (baseOffset) { - updateFunc_1(baseOffset + dynamicOffset_1); - }); - } - else { - coder.encode(staticWriter, value); - } - }); - // Backfill all the dynamic offsets, now that we know the static length - updateFuncs.forEach(function (func) { func(staticWriter.length); }); - var length = writer.writeBytes(staticWriter.data); - length += writer.writeBytes(dynamicWriter.data); - return length; -} -exports.pack = pack; -function unpack(reader, coders) { - var values = []; - // A reader anchored to this base - var baseReader = reader.subReader(0); - // The amount of dynamic data read; to consume later to synchronize - var dynamicLength = 0; - coders.forEach(function (coder) { - var value = null; - if (coder.dynamic) { - var offset = reader.readValue(); - var offsetReader = baseReader.subReader(offset.toNumber()); - value = coder.decode(offsetReader); - dynamicLength += offsetReader.consumed; - } - else { - value = coder.decode(reader); - } - if (value != undefined) { - values.push(value); - } - }); - // @TODO: get rid of this an see if it still works? - // Consume the dynamic components in the main reader - reader.readBytes(dynamicLength); - // Add any named parameters (i.e. tuples) - coders.forEach(function (coder, index) { - var name = coder.localName; - if (!name) { - return; - } - if (name === "length") { - name = "_length"; - } - if (values[name] != null) { - return; - } - values[name] = values[index]; - }); - return values; -} -exports.unpack = unpack; -var ArrayCoder = /** @class */ (function (_super) { - __extends(ArrayCoder, _super); - function ArrayCoder(coder, length, localName) { - var _this = this; - var type = (coder.type + "[" + (length >= 0 ? length : "") + "]"); - var dynamic = (length === -1 || coder.dynamic); - _this = _super.call(this, "array", type, localName, dynamic) || this; - _this.coder = coder; - _this.length = length; - return _this; - } - ArrayCoder.prototype.encode = function (writer, value) { - if (!Array.isArray(value)) { - this._throwError("expected array value", value); - } - var count = this.length; - //let result = new Uint8Array(0); - if (count === -1) { - count = value.length; - writer.writeValue(value.length); - } - logger.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); - var coders = []; - for (var i = 0; i < value.length; i++) { - coders.push(this.coder); - } - return pack(writer, coders, value); - }; - ArrayCoder.prototype.decode = function (reader) { - var count = this.length; - if (count === -1) { - count = reader.readValue().toNumber(); - } - var coders = []; - for (var i = 0; i < count; i++) { - coders.push(new anonymous_1.AnonymousCoder(this.coder)); - } - return reader.coerce(this.name, unpack(reader, coders)); - }; - return ArrayCoder; -}(abstract_coder_1.Coder)); -exports.ArrayCoder = ArrayCoder; - -},{"../_version":41,"./abstract-coder":43,"./anonymous":45,"@ethersproject/logger":91}],47:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_coder_1 = require("./abstract-coder"); -var BooleanCoder = /** @class */ (function (_super) { - __extends(BooleanCoder, _super); - function BooleanCoder(localName) { - return _super.call(this, "bool", "bool", localName, false) || this; - } - BooleanCoder.prototype.encode = function (writer, value) { - return writer.writeValue(value ? 1 : 0); - }; - BooleanCoder.prototype.decode = function (reader) { - return reader.coerce(this.type, !reader.readValue().isZero()); - }; - return BooleanCoder; -}(abstract_coder_1.Coder)); -exports.BooleanCoder = BooleanCoder; - -},{"./abstract-coder":43}],48:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var abstract_coder_1 = require("./abstract-coder"); -var DynamicBytesCoder = /** @class */ (function (_super) { - __extends(DynamicBytesCoder, _super); - function DynamicBytesCoder(type, localName) { - return _super.call(this, type, type, localName, true) || this; - } - DynamicBytesCoder.prototype.encode = function (writer, value) { - value = bytes_1.arrayify(value); - var length = writer.writeValue(value.length); - length += writer.writeBytes(value); - return length; - }; - DynamicBytesCoder.prototype.decode = function (reader) { - return reader.readBytes(reader.readValue().toNumber()); - }; - return DynamicBytesCoder; -}(abstract_coder_1.Coder)); -exports.DynamicBytesCoder = DynamicBytesCoder; -var BytesCoder = /** @class */ (function (_super) { - __extends(BytesCoder, _super); - function BytesCoder(localName) { - return _super.call(this, "bytes", localName) || this; - } - BytesCoder.prototype.decode = function (reader) { - return reader.coerce(this.name, bytes_1.hexlify(_super.prototype.decode.call(this, reader))); - }; - return BytesCoder; -}(DynamicBytesCoder)); -exports.BytesCoder = BytesCoder; - -},{"./abstract-coder":43,"@ethersproject/bytes":70}],49:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var abstract_coder_1 = require("./abstract-coder"); -// @TODO: Merge this with bytes -var FixedBytesCoder = /** @class */ (function (_super) { - __extends(FixedBytesCoder, _super); - function FixedBytesCoder(size, localName) { - var _this = this; - var name = "bytes" + String(size); - _this = _super.call(this, name, name, localName, false) || this; - _this.size = size; - return _this; - } - FixedBytesCoder.prototype.encode = function (writer, value) { - var data = bytes_1.arrayify(value); - if (data.length !== this.size) { - this._throwError("incorrect data length", value); - } - return writer.writeBytes(data); - }; - FixedBytesCoder.prototype.decode = function (reader) { - return reader.coerce(this.name, bytes_1.hexlify(reader.readBytes(this.size))); - }; - return FixedBytesCoder; -}(abstract_coder_1.Coder)); -exports.FixedBytesCoder = FixedBytesCoder; - -},{"./abstract-coder":43,"@ethersproject/bytes":70}],50:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_coder_1 = require("./abstract-coder"); -var NullCoder = /** @class */ (function (_super) { - __extends(NullCoder, _super); - function NullCoder(localName) { - return _super.call(this, "null", "", localName, false) || this; - } - NullCoder.prototype.encode = function (writer, value) { - if (value != null) { - this._throwError("not null", value); - } - return writer.writeBytes([]); - }; - NullCoder.prototype.decode = function (reader) { - reader.readBytes(0); - return reader.coerce(this.name, null); - }; - return NullCoder; -}(abstract_coder_1.Coder)); -exports.NullCoder = NullCoder; - -},{"./abstract-coder":43}],51:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var bignumber_1 = require("@ethersproject/bignumber"); -var constants_1 = require("@ethersproject/constants"); -var abstract_coder_1 = require("./abstract-coder"); -var NumberCoder = /** @class */ (function (_super) { - __extends(NumberCoder, _super); - function NumberCoder(size, signed, localName) { - var _this = this; - var name = ((signed ? "int" : "uint") + (size * 8)); - _this = _super.call(this, name, name, localName, false) || this; - _this.size = size; - _this.signed = signed; - return _this; - } - NumberCoder.prototype.encode = function (writer, value) { - var v = bignumber_1.BigNumber.from(value); - // Check bounds are safe for encoding - var maxUintValue = constants_1.MaxUint256.maskn(writer.wordSize * 8); - if (this.signed) { - var bounds = maxUintValue.maskn(this.size * 8 - 1); - if (v.gt(bounds) || v.lt(bounds.add(constants_1.One).mul(constants_1.NegativeOne))) { - this._throwError("value out-of-bounds", value); - } - } - else if (v.lt(constants_1.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { - this._throwError("value out-of-bounds", value); - } - v = v.toTwos(this.size * 8).maskn(this.size * 8); - if (this.signed) { - v = v.fromTwos(this.size * 8).toTwos(8 * writer.wordSize); - } - return writer.writeValue(v); - }; - NumberCoder.prototype.decode = function (reader) { - var value = reader.readValue().maskn(this.size * 8); - if (this.signed) { - value = value.fromTwos(this.size * 8); - } - return reader.coerce(this.name, value); - }; - return NumberCoder; -}(abstract_coder_1.Coder)); -exports.NumberCoder = NumberCoder; - -},{"./abstract-coder":43,"@ethersproject/bignumber":68,"@ethersproject/constants":71}],52:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var strings_1 = require("@ethersproject/strings"); -var bytes_1 = require("./bytes"); -var StringCoder = /** @class */ (function (_super) { - __extends(StringCoder, _super); - function StringCoder(localName) { - return _super.call(this, "string", localName) || this; - } - StringCoder.prototype.encode = function (writer, value) { - return _super.prototype.encode.call(this, writer, strings_1.toUtf8Bytes(value)); - }; - StringCoder.prototype.decode = function (reader) { - return strings_1.toUtf8String(_super.prototype.decode.call(this, reader)); - }; - return StringCoder; -}(bytes_1.DynamicBytesCoder)); -exports.StringCoder = StringCoder; - -},{"./bytes":48,"@ethersproject/strings":123}],53:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_coder_1 = require("./abstract-coder"); -var array_1 = require("./array"); -var TupleCoder = /** @class */ (function (_super) { - __extends(TupleCoder, _super); - function TupleCoder(coders, localName) { - var _this = this; - var dynamic = false; - var types = []; - coders.forEach(function (coder) { - if (coder.dynamic) { - dynamic = true; - } - types.push(coder.type); - }); - var type = ("tuple(" + types.join(",") + ")"); - _this = _super.call(this, "tuple", type, localName, dynamic) || this; - _this.coders = coders; - return _this; - } - TupleCoder.prototype.encode = function (writer, value) { - return array_1.pack(writer, this.coders, value); - }; - TupleCoder.prototype.decode = function (reader) { - return reader.coerce(this.name, array_1.unpack(reader, this.coders)); - }; - return TupleCoder; -}(abstract_coder_1.Coder)); -exports.TupleCoder = TupleCoder; - -},{"./abstract-coder":43,"./array":46}],54:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var bignumber_1 = require("@ethersproject/bignumber"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -; -var _constructorGuard = {}; -var ModifiersBytes = { calldata: true, memory: true, storage: true }; -function checkModifier(type, name) { - if (type === "bytes" || type === "string") { - if (ModifiersBytes[name]) { - return true; - } - } - else if (type === "address") { - if (name === "payable") { - return true; - } - } - if (ModifiersBytes[name] || name === "payable") { - logger.throwArgumentError("invalid modifier", "name", name); - } - return false; -} -// @TODO: Make sure that children of an indexed tuple are marked with a null indexed -function parseParamType(param, allowIndexed) { - var originalParam = param; - function throwError(i) { - throw new Error("unexpected character '" + originalParam[i] + "' at position " + i + " in '" + originalParam + "'"); - } - param = param.replace(/\s/g, " "); - function newNode(parent) { - var node = { type: "", name: "", parent: parent, state: { allowType: true } }; - if (allowIndexed) { - node.indexed = false; - } - return node; - } - var parent = { type: "", name: "", state: { allowType: true } }; - var node = parent; - for (var i = 0; i < param.length; i++) { - var c = param[i]; - switch (c) { - case "(": - if (!node.state.allowParams) { - throwError(i); - } - node.state.allowType = false; - node.type = verifyType(node.type); - node.components = [newNode(node)]; - node = node.components[0]; - break; - case ")": - delete node.state; - if (node.name === "indexed") { - if (!allowIndexed) { - throwError(i); - } - node.indexed = true; - node.name = ""; - } - if (checkModifier(node.type, node.name)) { - node.name = ""; - } - node.type = verifyType(node.type); - var child = node; - node = node.parent; - if (!node) { - throwError(i); - } - delete child.parent; - node.state.allowParams = false; - node.state.allowName = true; - node.state.allowArray = true; - break; - case ",": - delete node.state; - if (node.name === "indexed") { - if (!allowIndexed) { - throwError(i); - } - node.indexed = true; - node.name = ""; - } - if (checkModifier(node.type, node.name)) { - node.name = ""; - } - node.type = verifyType(node.type); - var sibling = newNode(node.parent); - //{ type: "", name: "", parent: node.parent, state: { allowType: true } }; - node.parent.components.push(sibling); - delete node.parent; - node = sibling; - break; - // Hit a space... - case " ": - // If reading type, the type is done and may read a param or name - if (node.state.allowType) { - if (node.type !== "") { - node.type = verifyType(node.type); - delete node.state.allowType; - node.state.allowName = true; - node.state.allowParams = true; - } - } - // If reading name, the name is done - if (node.state.allowName) { - if (node.name !== "") { - if (node.name === "indexed") { - if (!allowIndexed) { - throwError(i); - } - if (node.indexed) { - throwError(i); - } - node.indexed = true; - node.name = ""; - } - else if (checkModifier(node.type, node.name)) { - node.name = ""; - } - else { - node.state.allowName = false; - } - } - } - break; - case "[": - if (!node.state.allowArray) { - throwError(i); - } - node.type += c; - node.state.allowArray = false; - node.state.allowName = false; - node.state.readArray = true; - break; - case "]": - if (!node.state.readArray) { - throwError(i); - } - node.type += c; - node.state.readArray = false; - node.state.allowArray = true; - node.state.allowName = true; - break; - default: - if (node.state.allowType) { - node.type += c; - node.state.allowParams = true; - node.state.allowArray = true; - } - else if (node.state.allowName) { - node.name += c; - delete node.state.allowArray; - } - else if (node.state.readArray) { - node.type += c; - } - else { - throwError(i); - } - } - } - if (node.parent) { - throw new Error("unexpected eof"); - } - delete parent.state; - if (node.name === "indexed") { - if (!allowIndexed) { - throwError(originalParam.length - 7); - } - if (node.indexed) { - throwError(originalParam.length - 7); - } - node.indexed = true; - node.name = ""; - } - else if (checkModifier(node.type, node.name)) { - node.name = ""; - } - parent.type = verifyType(parent.type); - return parent; -} -function populate(object, params) { - for (var key in params) { - properties_1.defineReadOnly(object, key, params[key]); - } -} -exports.FormatTypes = Object.freeze({ - // Bare formatting, as is needed for computing a sighash of an event or function - sighash: "sighash", - // Human-Readable with Minimal spacing and without names (compact human-readable) - minimal: "minimal", - // Human-Readble with nice spacing, including all names - full: "full", - // JSON-format a la Solidity - json: "json" -}); -var paramTypeArray = new RegExp(/^(.*)\[([0-9]*)\]$/); -var ParamType = /** @class */ (function () { - function ParamType(constructorGuard, params) { - if (constructorGuard !== _constructorGuard) { - throw new Error("use fromString"); - } - populate(this, params); - var match = this.type.match(paramTypeArray); - if (match) { - populate(this, { - arrayLength: parseInt(match[2] || "-1"), - arrayChildren: ParamType.fromObject({ - type: match[1], - components: this.components - }), - baseType: "array" - }); - } - else { - populate(this, { - arrayLength: null, - arrayChildren: null, - baseType: ((this.components != null) ? "tuple" : this.type) - }); - } - this._isParamType = true; - Object.freeze(this); - } - // Format the parameter fragment - // - sighash: "(uint256,address)" - // - minimal: "tuple(uint256,address) indexed" - // - full: "tuple(uint256 foo, addres bar) indexed baz" - ParamType.prototype.format = function (format) { - if (!format) { - format = exports.FormatTypes.sighash; - } - if (!exports.FormatTypes[format]) { - logger.throwArgumentError("invalid format type", "format", format); - } - if (format === exports.FormatTypes.json) { - var result_1 = { - type: ((this.baseType === "tuple") ? "tuple" : this.type), - name: (this.name || undefined) - }; - if (typeof (this.indexed) === "boolean") { - result_1.indexed = this.indexed; - } - if (this.components) { - result_1.components = this.components.map(function (comp) { return JSON.parse(comp.format(format)); }); - } - return JSON.stringify(result_1); - } - var result = ""; - // Array - if (this.baseType === "array") { - result += this.arrayChildren.format(format); - result += "[" + (this.arrayLength < 0 ? "" : String(this.arrayLength)) + "]"; - } - else { - if (this.baseType === "tuple") { - if (format !== exports.FormatTypes.sighash) { - result += this.type; - } - result += "(" + this.components.map(function (comp) { return comp.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ")"; - } - else { - result += this.type; - } - } - if (format !== exports.FormatTypes.sighash) { - if (this.indexed === true) { - result += " indexed"; - } - if (format === exports.FormatTypes.full && this.name) { - result += " " + this.name; - } - } - return result; - }; - ParamType.from = function (value, allowIndexed) { - if (typeof (value) === "string") { - return ParamType.fromString(value, allowIndexed); - } - return ParamType.fromObject(value); - }; - ParamType.fromObject = function (value) { - if (ParamType.isParamType(value)) { - return value; - } - return new ParamType(_constructorGuard, { - name: (value.name || null), - type: verifyType(value.type), - indexed: ((value.indexed == null) ? null : !!value.indexed), - components: (value.components ? value.components.map(ParamType.fromObject) : null) - }); - }; - ParamType.fromString = function (value, allowIndexed) { - function ParamTypify(node) { - return ParamType.fromObject({ - name: node.name, - type: node.type, - indexed: node.indexed, - components: node.components - }); - } - return ParamTypify(parseParamType(value, !!allowIndexed)); - }; - ParamType.isParamType = function (value) { - return !!(value != null && value._isParamType); - }; - return ParamType; -}()); -exports.ParamType = ParamType; -; -function parseParams(value, allowIndex) { - return splitNesting(value).map(function (param) { return ParamType.fromString(param, allowIndex); }); -} -var Fragment = /** @class */ (function () { - function Fragment(constructorGuard, params) { - if (constructorGuard !== _constructorGuard) { - throw new Error("use a static from method"); - } - populate(this, params); - this._isFragment = true; - Object.freeze(this); - } - Fragment.from = function (value) { - if (Fragment.isFragment(value)) { - return value; - } - if (typeof (value) === "string") { - return Fragment.fromString(value); - } - return Fragment.fromObject(value); - }; - Fragment.fromObject = function (value) { - if (Fragment.isFragment(value)) { - return value; - } - if (value.type === "function") { - return FunctionFragment.fromObject(value); - } - else if (value.type === "event") { - return EventFragment.fromObject(value); - } - else if (value.type === "constructor") { - return ConstructorFragment.fromObject(value); - } - else if (value.type === "fallback") { - // @TODO: - return null; - } - return logger.throwArgumentError("invalid fragment object", "value", value); - }; - Fragment.fromString = function (value) { - // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space - value = value.replace(/\s/g, " "); - value = value.replace(/\(/g, " (").replace(/\)/g, ") ").replace(/\s+/g, " "); - value = value.trim(); - if (value.split(" ")[0] === "event") { - return EventFragment.fromString(value.substring(5).trim()); - } - else if (value.split(" ")[0] === "function") { - return FunctionFragment.fromString(value.substring(8).trim()); - } - else if (value.split("(")[0].trim() === "constructor") { - return ConstructorFragment.fromString(value.trim()); - } - throw new Error("unknown fragment"); - }; - Fragment.isFragment = function (value) { - return !!(value && value._isFragment); - }; - return Fragment; -}()); -exports.Fragment = Fragment; -var EventFragment = /** @class */ (function (_super) { - __extends(EventFragment, _super); - function EventFragment() { - return _super !== null && _super.apply(this, arguments) || this; - } - EventFragment.prototype.format = function (format) { - if (!format) { - format = exports.FormatTypes.sighash; - } - if (!exports.FormatTypes[format]) { - logger.throwArgumentError("invalid format type", "format", format); - } - if (format === exports.FormatTypes.json) { - return JSON.stringify({ - type: "event", - anonymous: this.anonymous, - name: this.name, - inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }) - }); - } - var result = ""; - if (format !== exports.FormatTypes.sighash) { - result += "event "; - } - result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") "; - if (format !== exports.FormatTypes.sighash) { - if (this.anonymous) { - result += "anonymous "; - } - } - return result.trim(); - }; - EventFragment.from = function (value) { - if (typeof (value) === "string") { - return EventFragment.fromString(value); - } - return EventFragment.fromObject(value); - }; - EventFragment.fromObject = function (value) { - if (EventFragment.isEventFragment(value)) { - return value; - } - if (value.type !== "event") { - throw new Error("invalid event object - " + value.type); - } - return new EventFragment(_constructorGuard, { - name: verifyIdentifier(value.name), - anonymous: value.anonymous, - inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), - type: "event" - }); - }; - EventFragment.fromString = function (value) { - var match = value.match(regexParen); - if (!match) { - throw new Error("invalid event: " + value); - } - var anonymous = false; - match[3].split(" ").forEach(function (modifier) { - switch (modifier.trim()) { - case "anonymous": - anonymous = true; - break; - case "": - break; - default: - logger.warn("unknown modifier: " + modifier); - } - }); - return EventFragment.fromObject({ - name: match[1].trim(), - anonymous: anonymous, - inputs: parseParams(match[2], true), - type: "event" - }); - }; - EventFragment.isEventFragment = function (value) { - return (value && value._isFragment && value.type === "event"); - }; - return EventFragment; -}(Fragment)); -exports.EventFragment = EventFragment; -function parseGas(value, params) { - params.gas = null; - var comps = value.split("@"); - if (comps.length !== 1) { - if (comps.length > 2) { - throw new Error("invalid signature"); - } - if (!comps[1].match(/^[0-9]+$/)) { - throw new Error("invalid signature gas"); - } - params.gas = bignumber_1.BigNumber.from(comps[1]); - return comps[0]; - } - return value; -} -function parseModifiers(value, params) { - params.constant = false; - params.payable = false; - params.stateMutability = "nonpayable"; - value.split(" ").forEach(function (modifier) { - switch (modifier.trim()) { - case "constant": - params.constant = true; - break; - case "payable": - params.payable = true; - params.stateMutability = "payable"; - break; - case "pure": - params.constant = true; - params.stateMutability = "pure"; - break; - case "view": - params.constant = true; - params.stateMutability = "view"; - break; - case "external": - case "public": - case "": - break; - default: - console.log("unknown modifier: " + modifier); - } - }); -} -function verifyState(value) { - var result = { - constant: false, - payable: true, - stateMutability: "payable" - }; - if (value.stateMutability != null) { - result.stateMutability = value.stateMutability; - result.constant = (result.stateMutability === "view" || result.stateMutability === "pure"); - if (value.constant != null) { - if ((!!value.constant) !== result.constant) { - throw new Error("cannot have constant function with mutability " + result.stateMutability); - } - } - result.payable = (result.stateMutability === "payable"); - if (value.payable != null) { - if ((!!value.payable) !== result.payable) { - throw new Error("cannot have payable function with mutability " + result.stateMutability); - } - } - } - else if (value.payable != null) { - result.payable = !!value.payable; - result.stateMutability = (result.payable ? "payable" : "nonpayable"); - result.constant = !result.payable; - if (value.constant != null && (value.constant !== result.constant)) { - throw new Error("cannot have constant payable function"); - } - } - else if (value.constant != null) { - result.constant = !!value.constant; - result.payable = !result.constant; - result.stateMutability = (result.constant ? "view" : "payable"); - } - return result; -} -var ConstructorFragment = /** @class */ (function (_super) { - __extends(ConstructorFragment, _super); - function ConstructorFragment() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstructorFragment.prototype.format = function (format) { - if (!format) { - format = exports.FormatTypes.sighash; - } - if (!exports.FormatTypes[format]) { - logger.throwArgumentError("invalid format type", "format", format); - } - if (format === exports.FormatTypes.json) { - return JSON.stringify({ - type: "constructor", - stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), - payble: this.payable, - gas: (this.gas ? this.gas.toNumber() : undefined), - inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }) - }); - } - if (format === exports.FormatTypes.sighash) { - logger.throwError("cannot format a constructor for sighash", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "format(sighash)" - }); - } - var result = "constructor(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") "; - if (this.stateMutability && this.stateMutability !== "nonpayable") { - result += this.stateMutability + " "; - } - return result.trim(); - }; - ConstructorFragment.from = function (value) { - if (typeof (value) === "string") { - return ConstructorFragment.fromString(value); - } - return ConstructorFragment.fromObject(value); - }; - ConstructorFragment.fromObject = function (value) { - if (ConstructorFragment.isConstructorFragment(value)) { - return value; - } - if (value.type !== "constructor") { - throw new Error("invalid constructor object - " + value.type); - } - var state = verifyState(value); - if (state.constant) { - throw new Error("constructor cannot be constant"); - } - return new ConstructorFragment(_constructorGuard, { - type: value.type, - inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), - payable: state.payable, - gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null) - }); - }; - ConstructorFragment.fromString = function (value) { - var params = { type: "constructor" }; - value = parseGas(value, params); - var parens = value.match(regexParen); - if (!parens) { - throw new Error("invalid constructor: " + value); - } - if (parens[1].trim() !== "constructor") { - throw new Error("invalid constructor"); - } - params.inputs = parseParams(parens[2].trim(), false); - parseModifiers(parens[3].trim(), params); - return ConstructorFragment.fromObject(params); - }; - ConstructorFragment.isConstructorFragment = function (value) { - return (value && value._isFragment && value.type === "constructor"); - }; - return ConstructorFragment; -}(Fragment)); -exports.ConstructorFragment = ConstructorFragment; -var FunctionFragment = /** @class */ (function (_super) { - __extends(FunctionFragment, _super); - function FunctionFragment() { - return _super !== null && _super.apply(this, arguments) || this; - } - FunctionFragment.prototype.format = function (format) { - if (!format) { - format = exports.FormatTypes.sighash; - } - if (!exports.FormatTypes[format]) { - logger.throwArgumentError("invalid format type", "format", format); - } - if (format === exports.FormatTypes.json) { - return JSON.stringify({ - type: "function", - name: this.name, - constant: this.constant, - stateMutability: ((this.stateMutability !== "nonpayable") ? this.stateMutability : undefined), - payble: this.payable, - gas: (this.gas ? this.gas.toNumber() : undefined), - inputs: this.inputs.map(function (input) { return JSON.parse(input.format(format)); }), - ouputs: this.outputs.map(function (output) { return JSON.parse(output.format(format)); }), - }); - } - var result = ""; - if (format !== exports.FormatTypes.sighash) { - result += "function "; - } - result += this.name + "(" + this.inputs.map(function (input) { return input.format(format); }).join((format === exports.FormatTypes.full) ? ", " : ",") + ") "; - if (format !== exports.FormatTypes.sighash) { - if (this.stateMutability) { - if (this.stateMutability !== "nonpayable") { - result += (this.stateMutability + " "); - } - } - else if (this.constant) { - result += "view "; - } - if (this.outputs && this.outputs.length) { - result += "returns (" + this.outputs.map(function (output) { return output.format(format); }).join(", ") + ") "; - } - if (this.gas != null) { - result += "@" + this.gas.toString() + " "; - } - } - return result.trim(); - }; - FunctionFragment.from = function (value) { - if (typeof (value) === "string") { - return FunctionFragment.fromString(value); - } - return FunctionFragment.fromObject(value); - }; - FunctionFragment.fromObject = function (value) { - if (FunctionFragment.isFunctionFragment(value)) { - return value; - } - if (value.type !== "function") { - throw new Error("invalid function object - " + value.type); - } - var state = verifyState(value); - return new FunctionFragment(_constructorGuard, { - type: value.type, - name: verifyIdentifier(value.name), - constant: state.constant, - inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), - outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []), - payable: state.payable, - stateMutability: state.stateMutability, - gas: (value.gas ? bignumber_1.BigNumber.from(value.gas) : null) - }); - }; - FunctionFragment.fromString = function (value) { - var params = { type: "function" }; - value = parseGas(value, params); - var comps = value.split(" returns "); - if (comps.length > 2) { - throw new Error("invalid function"); - } - var parens = comps[0].match(regexParen); - if (!parens) { - throw new Error("invalid signature"); - } - params.name = parens[1].trim(); - if (!params.name.match(regexIdentifier)) { - throw new Error("invalid identifier: '" + params.name + "'"); - } - params.inputs = parseParams(parens[2], false); - parseModifiers(parens[3].trim(), params); - // We have outputs - if (comps.length > 1) { - var returns = comps[1].match(regexParen); - if (returns[1].trim() != "" || returns[3].trim() != "") { - throw new Error("unexpected tokens"); - } - params.outputs = parseParams(returns[2], false); - } - else { - params.outputs = []; - } - return FunctionFragment.fromObject(params); - }; - FunctionFragment.isFunctionFragment = function (value) { - return (value && value._isFragment && value.type === "function"); - }; - return FunctionFragment; -}(ConstructorFragment)); -exports.FunctionFragment = FunctionFragment; -//export class ErrorFragment extends Fragment { -//} -//export class StructFragment extends Fragment { -//} -function verifyType(type) { - // These need to be transformed to their full description - if (type.match(/^uint($|[^1-9])/)) { - type = "uint256" + type.substring(4); - } - else if (type.match(/^int($|[^1-9])/)) { - type = "int256" + type.substring(3); - } - // @TODO: more verification - return type; -} -var regexIdentifier = new RegExp("^[A-Za-z_][A-Za-z0-9_]*$"); -function verifyIdentifier(value) { - if (!value || !value.match(regexIdentifier)) { - throw new Error("invalid identifier: '" + value + "'"); - } - return value; -} -var regexParen = new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$"); -function splitNesting(value) { - value = value.trim(); - var result = []; - var accum = ""; - var depth = 0; - for (var offset = 0; offset < value.length; offset++) { - var c = value[offset]; - if (c === "," && depth === 0) { - result.push(accum); - accum = ""; - } - else { - accum += c; - if (c === "(") { - depth++; - } - else if (c === ")") { - depth--; - if (depth === -1) { - throw new Error("unbalanced parenthsis"); - } - } - } - } - if (accum) { - result.push(accum); - } - return result; -} - -},{"./_version":41,"@ethersproject/bignumber":68,"@ethersproject/logger":91,"@ethersproject/properties":96}],55:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var fragments_1 = require("./fragments"); -exports.ConstructorFragment = fragments_1.ConstructorFragment; -exports.EventFragment = fragments_1.EventFragment; -exports.FormatTypes = fragments_1.FormatTypes; -exports.Fragment = fragments_1.Fragment; -exports.FunctionFragment = fragments_1.FunctionFragment; -exports.ParamType = fragments_1.ParamType; -var abi_coder_1 = require("./abi-coder"); -exports.AbiCoder = abi_coder_1.AbiCoder; -exports.defaultAbiCoder = abi_coder_1.defaultAbiCoder; -var interface_1 = require("./interface"); -exports.Indexed = interface_1.Indexed; -exports.Interface = interface_1.Interface; - -},{"./abi-coder":42,"./fragments":54,"./interface":56}],56:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var address_1 = require("@ethersproject/address"); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var hash_1 = require("@ethersproject/hash"); -var keccak256_1 = require("@ethersproject/keccak256"); -var properties_1 = require("@ethersproject/properties"); -var abi_coder_1 = require("./abi-coder"); -var fragments_1 = require("./fragments"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var LogDescription = /** @class */ (function (_super) { - __extends(LogDescription, _super); - function LogDescription() { - return _super !== null && _super.apply(this, arguments) || this; - } - return LogDescription; -}(properties_1.Description)); -exports.LogDescription = LogDescription; -var TransactionDescription = /** @class */ (function (_super) { - __extends(TransactionDescription, _super); - function TransactionDescription() { - return _super !== null && _super.apply(this, arguments) || this; - } - return TransactionDescription; -}(properties_1.Description)); -exports.TransactionDescription = TransactionDescription; -var Indexed = /** @class */ (function (_super) { - __extends(Indexed, _super); - function Indexed() { - return _super !== null && _super.apply(this, arguments) || this; - } - Indexed.isIndexed = function (value) { - return !!(value && value._isIndexed); - }; - return Indexed; -}(properties_1.Description)); -exports.Indexed = Indexed; -var Result = /** @class */ (function () { - function Result() { - } - return Result; -}()); -exports.Result = Result; -var Interface = /** @class */ (function () { - function Interface(fragments) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, Interface); - var abi = []; - if (typeof (fragments) === "string") { - abi = JSON.parse(fragments); - } - else { - abi = fragments; - } - properties_1.defineReadOnly(this, "fragments", abi.map(function (fragment) { - return fragments_1.Fragment.from(fragment); - }).filter(function (fragment) { return (fragment != null); })); - properties_1.defineReadOnly(this, "_abiCoder", properties_1.getStatic((_newTarget), "getAbiCoder")()); - properties_1.defineReadOnly(this, "functions", {}); - properties_1.defineReadOnly(this, "errors", {}); - properties_1.defineReadOnly(this, "events", {}); - properties_1.defineReadOnly(this, "structs", {}); - // Add all fragments by their signature - this.fragments.forEach(function (fragment) { - var bucket = null; - switch (fragment.type) { - case "constructor": - if (_this.deploy) { - logger.warn("duplicate definition - constructor"); - return; - } - properties_1.defineReadOnly(_this, "deploy", fragment); - return; - case "function": - bucket = _this.functions; - break; - case "event": - bucket = _this.events; - break; - default: - return; - } - var signature = fragment.format(); - if (bucket[signature]) { - logger.warn("duplicate definition - " + signature); - return; - } - bucket[signature] = fragment; - }); - // Add any fragments with a unique name by its name (sans signature parameters) - [this.events, this.functions].forEach(function (bucket) { - var count = getNameCount(bucket); - Object.keys(bucket).forEach(function (signature) { - var fragment = bucket[signature]; - if (count[fragment.name] !== 1) { - logger.warn("duplicate definition - " + fragment.name); - return; - } - bucket[fragment.name] = fragment; - }); - }); - // If we do not have a constructor use the default "constructor() payable" - if (!this.deploy) { - properties_1.defineReadOnly(this, "deploy", fragments_1.ConstructorFragment.from({ type: "constructor" })); - } - properties_1.defineReadOnly(this, "_isInterface", true); - } - Interface.getAbiCoder = function () { - return abi_coder_1.defaultAbiCoder; - }; - Interface.getAddress = function (address) { - return address_1.getAddress(address); - }; - Interface.prototype._sighashify = function (functionFragment) { - return bytes_1.hexDataSlice(hash_1.id(functionFragment.format()), 0, 4); - }; - Interface.prototype._topicify = function (eventFragment) { - return hash_1.id(eventFragment.format()); - }; - Interface.prototype.getFunction = function (nameOrSignatureOrSighash) { - if (bytes_1.isHexString(nameOrSignatureOrSighash)) { - return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); - } - // It is a bare name, look up the function (will return null if ambiguous) - if (nameOrSignatureOrSighash.indexOf("(") === -1) { - return (this.functions[nameOrSignatureOrSighash.trim()] || null); - } - // Normlize the signature and lookup the function - return this.functions[fragments_1.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; - }; - Interface.prototype.getEvent = function (nameOrSignatureOrTopic) { - if (bytes_1.isHexString(nameOrSignatureOrTopic)) { - return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); - } - // It is a bare name, look up the function (will return null if ambiguous) - if (nameOrSignatureOrTopic.indexOf("(") === -1) { - return this.events[nameOrSignatureOrTopic]; - } - return this.events[fragments_1.EventFragment.fromString(nameOrSignatureOrTopic).format()]; - }; - Interface.prototype.getSighash = function (functionFragment) { - if (typeof (functionFragment) === "string") { - functionFragment = this.getFunction(functionFragment); - } - return this._sighashify(functionFragment); - }; - Interface.prototype.getEventTopic = function (eventFragment) { - if (typeof (eventFragment) === "string") { - eventFragment = this.getEvent(eventFragment); - } - return this._topicify(eventFragment); - }; - Interface.prototype._encodeParams = function (params, values) { - return this._abiCoder.encode(params, values); - }; - Interface.prototype.encodeDeploy = function (values) { - return this._encodeParams(this.deploy.inputs, values || []); - }; - Interface.prototype.encodeFunctionData = function (functionFragment, values) { - if (typeof (functionFragment) === "string") { - functionFragment = this.getFunction(functionFragment); - } - return bytes_1.hexlify(bytes_1.concat([ - this.getSighash(functionFragment), - this._encodeParams(functionFragment.inputs, values || []) - ])); - }; - Interface.prototype.decodeFunctionResult = function (functionFragment, data) { - if (typeof (functionFragment) === "string") { - functionFragment = this.getFunction(functionFragment); - } - var bytes = bytes_1.arrayify(data); - var reason = null; - var errorSignature = null; - switch (bytes.length % this._abiCoder._getWordSize()) { - case 0: - try { - return this._abiCoder.decode(functionFragment.outputs, bytes); - } - catch (error) { } - break; - case 4: - if (bytes_1.hexlify(bytes.slice(0, 4)) === "0x08c379a0") { - errorSignature = "Error(string)"; - reason = this._abiCoder.decode(["string"], bytes.slice(4)); - } - break; - } - return logger.throwError("call revert exception", logger_1.Logger.errors.CALL_EXCEPTION, { - method: functionFragment.format(), - errorSignature: errorSignature, - errorArgs: [reason], - reason: reason - }); - }; - Interface.prototype.encodeFilterTopics = function (eventFragment, values) { - var _this = this; - if (typeof (eventFragment) === "string") { - eventFragment = this.getEvent(eventFragment); - } - if (values.length > eventFragment.inputs.length) { - logger.throwError("too many arguments for " + eventFragment.format(), logger_1.Logger.errors.UNEXPECTED_ARGUMENT, { - argument: "values", - value: values - }); - } - var topics = []; - if (!eventFragment.anonymous) { - topics.push(this.getEventTopic(eventFragment)); - } - values.forEach(function (value, index) { - var param = eventFragment.inputs[index]; - if (!param.indexed) { - if (value != null) { - logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); - } - return; - } - if (value == null) { - topics.push(null); - } - else if (param.type === "string") { - topics.push(hash_1.id(value)); - } - else if (param.type === "bytes") { - topics.push(keccak256_1.keccak256(bytes_1.hexlify(value))); - } - else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { - logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); - } - else { - // Check addresses are valid - if (param.type === "address") { - _this._abiCoder.encode(["address"], [value]); - } - topics.push(bytes_1.hexZeroPad(bytes_1.hexlify(value), 32)); - } - }); - // Trim off trailing nulls - while (topics.length && topics[topics.length - 1] === null) { - topics.pop(); - } - return topics; - }; - Interface.prototype.decodeEventLog = function (eventFragment, data, topics) { - if (typeof (eventFragment) === "string") { - eventFragment = this.getEvent(eventFragment); - } - if (topics != null && !eventFragment.anonymous) { - var topicHash = this.getEventTopic(eventFragment); - if (!bytes_1.isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { - logger.throwError("fragment/topic mismatch", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); - } - topics = topics.slice(1); - } - var indexed = []; - var nonIndexed = []; - var dynamic = []; - eventFragment.inputs.forEach(function (param, index) { - if (param.indexed) { - if (param.type === "string" || param.type === "bytes" || param.baseType === "tuple" || param.baseType === "array") { - indexed.push(fragments_1.ParamType.fromObject({ type: "bytes32", name: param.name })); - dynamic.push(true); - } - else { - indexed.push(param); - dynamic.push(false); - } - } - else { - nonIndexed.push(param); - dynamic.push(false); - } - }); - var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, bytes_1.concat(topics)) : null; - var resultNonIndexed = this._abiCoder.decode(nonIndexed, data); - var result = []; - var nonIndexedIndex = 0, indexedIndex = 0; - eventFragment.inputs.forEach(function (param, index) { - if (param.indexed) { - if (resultIndexed == null) { - result[index] = new Indexed({ _isIndexed: true, hash: null }); - } - else if (dynamic[index]) { - result[index] = new Indexed({ _isIndexed: true, hash: resultIndexed[indexedIndex++] }); - } - else { - result[index] = resultIndexed[indexedIndex++]; - } - } - else { - result[index] = resultNonIndexed[nonIndexedIndex++]; - } - //if (param.name && result[param.name] == null) { result[param.name] = result[index]; } - }); - return result; - }; - Interface.prototype.parseTransaction = function (tx) { - var fragment = this.getFunction(tx.data.substring(0, 10).toLowerCase()); - if (!fragment) { - return null; - } - return new TransactionDescription({ - args: this._abiCoder.decode(fragment.inputs, "0x" + tx.data.substring(10)), - functionFragment: fragment, - name: fragment.name, - signature: fragment.format(), - sighash: this.getSighash(fragment), - value: bignumber_1.BigNumber.from(tx.value || "0"), - }); - }; - Interface.prototype.parseLog = function (log) { - var fragment = this.getEvent(log.topics[0]); - if (!fragment || fragment.anonymous) { - return null; - } - // @TODO: If anonymous, and the only method, and the input count matches, should we parse? - return new LogDescription({ - eventFragment: fragment, - name: fragment.name, - signature: fragment.format(), - topic: this.getEventTopic(fragment), - values: this.decodeEventLog(fragment, log.data, log.topics) - }); - }; - /* - static from(value: Array | string | Interface) { - if (Interface.isInterface(value)) { - return value; - } - if (typeof(value) === "string") { - return new Interface(JSON.parse(value)); - } - return new Interface(value); - } - */ - Interface.isInterface = function (value) { - return !!(value && value._isInterface); - }; - return Interface; -}()); -exports.Interface = Interface; -function getFragment(hash, calcFunc, items) { - for (var signature in items) { - if (signature.indexOf("(") === -1) { - continue; - } - var fragment = items[signature]; - if (calcFunc(fragment) === hash) { - return fragment; - } - } - return null; -} -function getNameCount(fragments) { - var unique = {}; - // Count each name - for (var signature in fragments) { - var name_1 = fragments[signature].name; - if (!unique[name_1]) { - unique[name_1] = 0; - } - unique[name_1]++; - } - return unique; -} - -},{"./_version":41,"./abi-coder":42,"./fragments":54,"@ethersproject/address":62,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/hash":80,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96}],57:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "abstract-provider/5.0.0-beta.130"; - -},{}],58:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -; -; -//export type CallTransactionable = { -// call(transaction: TransactionRequest): Promise; -//}; -var ForkEvent = /** @class */ (function (_super) { - __extends(ForkEvent, _super); - function ForkEvent() { - return _super !== null && _super.apply(this, arguments) || this; - } - ForkEvent.isForkEvent = function (value) { - return !!(value && value._isForkEvent); - }; - return ForkEvent; -}(properties_1.Description)); -exports.ForkEvent = ForkEvent; -var BlockForkEvent = /** @class */ (function (_super) { - __extends(BlockForkEvent, _super); - function BlockForkEvent(blockhash, expiry) { - var _this = this; - if (!bytes_1.isHexString(blockhash, 32)) { - logger.throwArgumentError("invalid blockhash", "blockhash", blockhash); - } - _this = _super.call(this, { - _isForkEvent: true, - _isBlockForkEvent: true, - expiry: (expiry || 0), - blockHash: blockhash - }) || this; - return _this; - } - return BlockForkEvent; -}(ForkEvent)); -exports.BlockForkEvent = BlockForkEvent; -var TransactionForkEvent = /** @class */ (function (_super) { - __extends(TransactionForkEvent, _super); - function TransactionForkEvent(hash, expiry) { - var _this = this; - if (!bytes_1.isHexString(hash, 32)) { - logger.throwArgumentError("invalid transaction hash", "hash", hash); - } - _this = _super.call(this, { - _isForkEvent: true, - _isTransactionForkEvent: true, - expiry: (expiry || 0), - hash: hash - }) || this; - return _this; - } - return TransactionForkEvent; -}(ForkEvent)); -exports.TransactionForkEvent = TransactionForkEvent; -var TransactionOrderForkEvent = /** @class */ (function (_super) { - __extends(TransactionOrderForkEvent, _super); - function TransactionOrderForkEvent(beforeHash, afterHash, expiry) { - var _this = this; - if (!bytes_1.isHexString(beforeHash, 32)) { - logger.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); - } - if (!bytes_1.isHexString(afterHash, 32)) { - logger.throwArgumentError("invalid transaction hash", "afterHash", afterHash); - } - _this = _super.call(this, { - _isForkEvent: true, - _isTransactionOrderForkEvent: true, - expiry: (expiry || 0), - beforeHash: beforeHash, - afterHash: afterHash - }) || this; - return _this; - } - return TransactionOrderForkEvent; -}(ForkEvent)); -exports.TransactionOrderForkEvent = TransactionOrderForkEvent; -/////////////////////////////// -// Exported Abstracts -var Provider = /** @class */ (function () { - function Provider() { - var _newTarget = this.constructor; - logger.checkAbstract(_newTarget, Provider); - properties_1.defineReadOnly(this, "_isProvider", true); - } - // Alias for "on" - Provider.prototype.addListener = function (eventName, listener) { - return this.on(eventName, listener); - }; - // Alias for "off" - Provider.prototype.removeListener = function (eventName, listener) { - return this.off(eventName, listener); - }; - Provider.isProvider = function (value) { - return !!(value && value._isProvider); - }; - return Provider; -}()); -exports.Provider = Provider; - -},{"./_version":57,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96}],59:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "abstract-signer/5.0.0-beta.131"; - -},{}],60:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var allowedTransactionKeys = [ - "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" -]; -// Sub-Class Notes: -// - A Signer MUST always make sure, that if present, the "from" field -// matches the Signer, before sending or signing a transaction -// - A Signer SHOULD always wrap private information (such as a private -// key or mnemonic) in a function, so that console.log does not leak -// the data -var Signer = /** @class */ (function () { - /////////////////// - // Sub-classes MUST call super - function Signer() { - var _newTarget = this.constructor; - logger.checkAbstract(_newTarget, Signer); - properties_1.defineReadOnly(this, "_isSigner", true); - } - /////////////////// - // Sub-classes MAY override these - Signer.prototype.getBalance = function (blockTag) { - this._checkProvider("getBalance"); - return this.provider.getBalance(this.getAddress(), blockTag); - }; - Signer.prototype.getTransactionCount = function (blockTag) { - this._checkProvider("getTransactionCount"); - return this.provider.getTransactionCount(this.getAddress(), blockTag); - }; - // Populates "from" if unspecified, and estimates the gas for the transation - Signer.prototype.estimateGas = function (transaction) { - var _this = this; - this._checkProvider("estimateGas"); - return properties_1.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { - return _this.provider.estimateGas(tx); - }); - }; - // Populates "from" if unspecified, and calls with the transation - Signer.prototype.call = function (transaction, blockTag) { - var _this = this; - this._checkProvider("call"); - return properties_1.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { - return _this.provider.call(tx); - }); - }; - // Populates all fields in a transaction, signs it and sends it to the network - Signer.prototype.sendTransaction = function (transaction) { - var _this = this; - this._checkProvider("sendTransaction"); - return this.populateTransaction(transaction).then(function (tx) { - return _this.signTransaction(tx).then(function (signedTx) { - return _this.provider.sendTransaction(signedTx); - }); - }); - }; - Signer.prototype.getChainId = function () { - this._checkProvider("getChainId"); - return this.provider.getNetwork().then(function (network) { return network.chainId; }); - }; - Signer.prototype.getGasPrice = function () { - this._checkProvider("getGasPrice"); - return this.provider.getGasPrice(); - }; - Signer.prototype.resolveName = function (name) { - this._checkProvider("resolveName"); - return this.provider.resolveName(name); - }; - // Checks a transaction does not contain invalid keys and if - // no "from" is provided, populates it. - // - does NOT require a provider - // - adds "from" is not present - // - returns a COPY (safe to mutate the result) - // By default called from: (overriding these prevents it) - // - call - // - estimateGas - // - populateTransaction (and therefor sendTransaction) - Signer.prototype.checkTransaction = function (transaction) { - for (var key in transaction) { - if (allowedTransactionKeys.indexOf(key) === -1) { - logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); - } - } - var tx = properties_1.shallowCopy(transaction); - if (tx.from == null) { - tx.from = this.getAddress(); - } - return tx; - }; - // Populates ALL keys for a transaction and checks that "from" matches - // this Signer. Should be used by sendTransaction but NOT by signTransaction. - // By default called from: (overriding these prevents it) - // - sendTransaction - Signer.prototype.populateTransaction = function (transaction) { - var _this = this; - return properties_1.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { - if (tx.to != null) { - tx.to = Promise.resolve(tx.to).then(function (to) { return _this.resolveName(to); }); - } - if (tx.gasPrice == null) { - tx.gasPrice = _this.getGasPrice(); - } - if (tx.nonce == null) { - tx.nonce = _this.getTransactionCount("pending"); - } - // Make sure any provided address matches this signer - if (tx.from == null) { - tx.from = _this.getAddress(); - } - else { - tx.from = Promise.all([ - _this.getAddress(), - _this.provider.resolveName(tx.from) - ]).then(function (results) { - if (results[0] !== results[1]) { - logger.throwArgumentError("from address mismatch", "transaction", transaction); - } - return results[0]; - }); - } - if (tx.gasLimit == null) { - tx.gasLimit = _this.estimateGas(tx).catch(function (error) { - logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger_1.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { - tx: tx - }); - }); - } - if (tx.chainId == null) { - tx.chainId = _this.getChainId(); - } - return properties_1.resolveProperties(tx); - }); - }; - /////////////////// - // Sub-classes SHOULD leave these alone - Signer.prototype._checkProvider = function (operation) { - if (!this.provider) { - logger.throwError("missing provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: (operation || "_checkProvider") - }); - } - }; - Signer.isSigner = function (value) { - return !!(value && value._isSigner); - }; - return Signer; -}()); -exports.Signer = Signer; -var VoidSigner = /** @class */ (function (_super) { - __extends(VoidSigner, _super); - function VoidSigner(address, provider) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, VoidSigner); - _this = _super.call(this) || this; - properties_1.defineReadOnly(_this, "address", address); - properties_1.defineReadOnly(_this, "provider", provider || null); - return _this; - } - VoidSigner.prototype.getAddress = function () { - return Promise.resolve(this.address); - }; - VoidSigner.prototype._fail = function (message, operation) { - return Promise.resolve().then(function () { - logger.throwError(message, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); - }); - }; - VoidSigner.prototype.signMessage = function (message) { - return this._fail("VoidSigner cannot sign messages", "signMessage"); - }; - VoidSigner.prototype.signTransaction = function (transaction) { - return this._fail("VoidSigner cannot sign transactions", "signTransaction"); - }; - VoidSigner.prototype.connect = function (provider) { - return new VoidSigner(this.address, provider); - }; - return VoidSigner; -}(Signer)); -exports.VoidSigner = VoidSigner; - -},{"./_version":59,"@ethersproject/logger":91,"@ethersproject/properties":96}],61:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "address/5.0.0-beta.127"; - -},{}],62:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -// We use this for base 36 maths -var BN = __importStar(require("bn.js")); -var bytes_1 = require("@ethersproject/bytes"); -var keccak256_1 = require("@ethersproject/keccak256"); -var rlp_1 = require("@ethersproject/rlp"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -function getChecksumAddress(address) { - if (!bytes_1.isHexString(address, 20)) { - logger.throwArgumentError("invalid address", "address", address); - } - address = address.toLowerCase(); - var chars = address.substring(2).split(""); - var hashed = new Uint8Array(40); - for (var i = 0; i < 40; i++) { - hashed[i] = chars[i].charCodeAt(0); - } - hashed = bytes_1.arrayify(keccak256_1.keccak256(hashed)); - for (var i = 0; i < 40; i += 2) { - if ((hashed[i >> 1] >> 4) >= 8) { - chars[i] = chars[i].toUpperCase(); - } - if ((hashed[i >> 1] & 0x0f) >= 8) { - chars[i + 1] = chars[i + 1].toUpperCase(); - } - } - return "0x" + chars.join(""); -} -// Shims for environments that are missing some required constants and functions -var MAX_SAFE_INTEGER = 0x1fffffffffffff; -function log10(x) { - if (Math.log10) { - return Math.log10(x); - } - return Math.log(x) / Math.LN10; -} -// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number -// Create lookup table -var ibanLookup = {}; -for (var i = 0; i < 10; i++) { - ibanLookup[String(i)] = String(i); -} -for (var i = 0; i < 26; i++) { - ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); -} -// How many decimal digits can we process? (for 64-bit float, this is 15) -var safeDigits = Math.floor(log10(MAX_SAFE_INTEGER)); -function ibanChecksum(address) { - address = address.toUpperCase(); - address = address.substring(4) + address.substring(0, 2) + "00"; - var expanded = ""; - address.split("").forEach(function (c) { - expanded += ibanLookup[c]; - }); - // Javascript can handle integers safely up to 15 (decimal) digits - while (expanded.length >= safeDigits) { - var block = expanded.substring(0, safeDigits); - expanded = parseInt(block, 10) % 97 + expanded.substring(block.length); - } - var checksum = String(98 - (parseInt(expanded, 10) % 97)); - while (checksum.length < 2) { - checksum = "0" + checksum; - } - return checksum; -} -; -function getAddress(address) { - var result = null; - if (typeof (address) !== "string") { - logger.throwArgumentError("invalid address", "address", address); - } - if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { - // Missing the 0x prefix - if (address.substring(0, 2) !== "0x") { - address = "0x" + address; - } - result = getChecksumAddress(address); - // It is a checksummed address with a bad checksum - if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { - logger.throwArgumentError("bad address checksum", "address", address); - } - // Maybe ICAP? (we only support direct mode) - } - else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { - // It is an ICAP address with a bad checksum - if (address.substring(2, 4) !== ibanChecksum(address)) { - logger.throwArgumentError("bad icap checksum", "address", address); - } - result = (new BN.BN(address.substring(4), 36)).toString(16); - while (result.length < 40) { - result = "0" + result; - } - result = getChecksumAddress("0x" + result); - } - else { - logger.throwArgumentError("invalid address", "address", address); - } - return result; -} -exports.getAddress = getAddress; -function isAddress(address) { - try { - getAddress(address); - return true; - } - catch (error) { } - return false; -} -exports.isAddress = isAddress; -function getIcapAddress(address) { - var base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); - while (base36.length < 30) { - base36 = "0" + base36; - } - return "XE" + ibanChecksum("XE00" + base36) + base36; -} -exports.getIcapAddress = getIcapAddress; -// http://ethereum.stackexchange.com/questions/760/how-is-the-address-of-an-ethereum-contract-computed -function getContractAddress(transaction) { - var from = null; - try { - from = getAddress(transaction.from); - } - catch (error) { - logger.throwArgumentError("missing from address", "transaction", transaction); - } - var nonce = bytes_1.stripZeros(bytes_1.arrayify(transaction.nonce)); - return getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(rlp_1.encode([from, nonce])), 12)); -} -exports.getContractAddress = getContractAddress; - -},{"./_version":61,"@ethersproject/bytes":70,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/rlp":114,"bn.js":2}],63:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -function decode(textData) { - textData = atob(textData); - var data = []; - for (var i = 0; i < textData.length; i++) { - data.push(textData.charCodeAt(i)); - } - return bytes_1.arrayify(data); -} -exports.decode = decode; -function encode(data) { - data = bytes_1.arrayify(data); - var textData = ""; - for (var i = 0; i < data.length; i++) { - textData += String.fromCharCode(data[i]); - } - return btoa(textData); -} -exports.encode = encode; - -},{"@ethersproject/bytes":70}],64:[function(require,module,exports){ -"use strict"; -/** - * var basex = require("base-x"); - * - * This implementation is heavily based on base-x. The main reason to - * deviate was to prevent the dependency of Buffer. - * - * Contributors: - * - * base-x encoding - * Forked from https://github.com/cryptocoinjs/bs58 - * Originally written by Mike Hearn for BitcoinJ - * Copyright (c) 2011 Google Inc - * Ported to JavaScript by Stefan Thomas - * Merged Buffer refactorings from base58-native by Stephen Pair - * Copyright (c) 2013 BitPay Inc - * - * The MIT License (MIT) - * - * Copyright base-x contributors (c) 2016 - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - */ -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var properties_1 = require("@ethersproject/properties"); -var BaseX = /** @class */ (function () { - function BaseX(alphabet) { - properties_1.defineReadOnly(this, "alphabet", alphabet); - properties_1.defineReadOnly(this, "base", alphabet.length); - properties_1.defineReadOnly(this, "_alphabetMap", {}); - properties_1.defineReadOnly(this, "_leader", alphabet.charAt(0)); - // pre-compute lookup table - for (var i = 0; i < alphabet.length; i++) { - this._alphabetMap[alphabet.charAt(i)] = i; - } - } - BaseX.prototype.encode = function (value) { - var source = bytes_1.arrayify(value); - if (source.length === 0) { - return ""; - } - var digits = [0]; - for (var i = 0; i < source.length; ++i) { - var carry = source[i]; - for (var j = 0; j < digits.length; ++j) { - carry += digits[j] << 8; - digits[j] = carry % this.base; - carry = (carry / this.base) | 0; - } - while (carry > 0) { - digits.push(carry % this.base); - carry = (carry / this.base) | 0; - } - } - var string = ""; - // deal with leading zeros - for (var k = 0; source[k] === 0 && k < source.length - 1; ++k) { - string += this._leader; - } - // convert digits to a string - for (var q = digits.length - 1; q >= 0; --q) { - string += this.alphabet[digits[q]]; - } - return string; - }; - BaseX.prototype.decode = function (value) { - if (typeof (value) !== "string") { - throw new TypeError("Expected String"); - } - var bytes = []; - if (value.length === 0) { - return new Uint8Array(bytes); - } - bytes.push(0); - for (var i = 0; i < value.length; i++) { - var byte = this._alphabetMap[value[i]]; - if (byte === undefined) { - throw new Error("Non-base" + this.base + " character"); - } - var carry = byte; - for (var j = 0; j < bytes.length; ++j) { - carry += bytes[j] * this.base; - bytes[j] = carry & 0xff; - carry >>= 8; - } - while (carry > 0) { - bytes.push(carry & 0xff); - carry >>= 8; - } - } - // deal with leading zeros - for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) { - bytes.push(0); - } - return bytes_1.arrayify(new Uint8Array(bytes.reverse())); - }; - return BaseX; -}()); -exports.BaseX = BaseX; -var Base32 = new BaseX("abcdefghijklmnopqrstuvwxyz234567"); -exports.Base32 = Base32; -var Base58 = new BaseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"); -exports.Base58 = Base58; -//console.log(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj")) -//console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) - -},{"@ethersproject/bytes":70,"@ethersproject/properties":96}],65:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "bignumber/5.0.0-beta.129"; - -},{}],66:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -/** - * BigNumber - * - * A wrapper around the BN.js object. We use the BN.js library - * because it is used by elliptic, so it is required regardles. - * - */ -var BN = __importStar(require("bn.js")); -var bytes_1 = require("@ethersproject/bytes"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var _constructorGuard = {}; -var MAX_SAFE = 0x1fffffffffffff; -function isBigNumberish(value) { - return (value != null) && (BigNumber.isBigNumber(value) || - (typeof (value) === "number" && (value % 1) === 0) || - (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || - bytes_1.isHexString(value) || - (typeof (value) === "bigint") || - bytes_1.isBytes(value)); -} -exports.isBigNumberish = isBigNumberish; -var BigNumber = /** @class */ (function () { - function BigNumber(constructorGuard, hex) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, BigNumber); - if (constructorGuard !== _constructorGuard) { - logger.throwError("cannot call consturtor directly; use BigNumber.from", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "new (BigNumber)" - }); - } - this._hex = hex; - this._isBigNumber = true; - Object.freeze(this); - } - BigNumber.prototype.fromTwos = function (value) { - return toBigNumber(toBN(this).fromTwos(value)); - }; - BigNumber.prototype.toTwos = function (value) { - return toBigNumber(toBN(this).toTwos(value)); - }; - BigNumber.prototype.abs = function () { - if (this._hex[0] === "-") { - return BigNumber.from(this._hex.substring(1)); - } - return this; - }; - BigNumber.prototype.add = function (other) { - return toBigNumber(toBN(this).add(toBN(other))); - }; - BigNumber.prototype.sub = function (other) { - return toBigNumber(toBN(this).sub(toBN(other))); - }; - BigNumber.prototype.div = function (other) { - var o = BigNumber.from(other); - if (o.isZero()) { - throwFault("division by zero", "div"); - } - return toBigNumber(toBN(this).div(toBN(other))); - }; - BigNumber.prototype.mul = function (other) { - return toBigNumber(toBN(this).mul(toBN(other))); - }; - BigNumber.prototype.mod = function (other) { - return toBigNumber(toBN(this).mod(toBN(other))); - }; - BigNumber.prototype.pow = function (other) { - return toBigNumber(toBN(this).pow(toBN(other))); - }; - BigNumber.prototype.maskn = function (value) { - return toBigNumber(toBN(this).maskn(value)); - }; - BigNumber.prototype.eq = function (other) { - return toBN(this).eq(toBN(other)); - }; - BigNumber.prototype.lt = function (other) { - return toBN(this).lt(toBN(other)); - }; - BigNumber.prototype.lte = function (other) { - return toBN(this).lte(toBN(other)); - }; - BigNumber.prototype.gt = function (other) { - return toBN(this).gt(toBN(other)); - }; - BigNumber.prototype.gte = function (other) { - return toBN(this).gte(toBN(other)); - }; - BigNumber.prototype.isZero = function () { - return toBN(this).isZero(); - }; - BigNumber.prototype.toNumber = function () { - try { - return toBN(this).toNumber(); - } - catch (error) { - throwFault("overflow", "toNumber", this.toString()); - } - return null; - }; - BigNumber.prototype.toString = function () { - // Lots of people expect this, which we do not support, so check - if (arguments.length !== 0) { - logger.throwError("bigNumber.toString does not accept parameters", logger_1.Logger.errors.UNEXPECTED_ARGUMENT, {}); - } - return toBN(this).toString(10); - }; - BigNumber.prototype.toHexString = function () { - return this._hex; - }; - BigNumber.from = function (value) { - if (value instanceof BigNumber) { - return value; - } - if (typeof (value) === "string") { - if (value.match(/-?0x[0-9a-f]+/i)) { - return new BigNumber(_constructorGuard, toHex(value)); - } - if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); - } - return logger.throwArgumentError("invalid BigNumber string", "value", value); - } - if (typeof (value) === "number") { - if (value % 1) { - throwFault("underflow", "BigNumber.from", value); - } - if (value >= MAX_SAFE || value <= -MAX_SAFE) { - throwFault("overflow", "BigNumber.from", value); - } - return BigNumber.from(String(value)); - } - if (typeof (value) === "bigint") { - return BigNumber.from(value.toString()); - } - if (bytes_1.isBytes(value)) { - return BigNumber.from(bytes_1.hexlify(value)); - } - if (value._hex && bytes_1.isHexString(value._hex)) { - return BigNumber.from(value._hex); - } - if (value.toHexString) { - value = value.toHexString(); - if (typeof (value) === "string") { - return BigNumber.from(value); - } - } - return logger.throwArgumentError("invalid BigNumber value", "value", value); - }; - BigNumber.isBigNumber = function (value) { - return !!(value && value._isBigNumber); - }; - return BigNumber; -}()); -exports.BigNumber = BigNumber; -// Normalize the hex string -function toHex(value) { - // For BN, call on the hex string - if (typeof (value) !== "string") { - return toHex(value.toString(16)); - } - // If negative, prepend the negative sign to the normalized positive value - if (value[0] === "-") { - // Strip off the negative sign - value = value.substring(1); - // Cannot have mulitple negative signs (e.g. "--0x04") - if (value[0] === "-") { - logger.throwArgumentError("invalid hex", "value", value); - } - // Call toHex on the positive component - value = toHex(value); - // Do not allow "-0x00" - if (value === "0x00") { - return value; - } - // Negate the value - return "-" + value; - } - // Add a "0x" prefix if missing - if (value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - // Normalize zero - if (value === "0x") { - return "0x00"; - } - // Make the string even length - if (value.length % 2) { - value = "0x0" + value.substring(2); - } - // Trim to smallest even-length string - while (value.length > 4 && value.substring(0, 4) === "0x00") { - value = "0x" + value.substring(4); - } - return value; -} -function toBigNumber(value) { - return BigNumber.from(toHex(value)); -} -function toBN(value) { - var hex = BigNumber.from(value).toHexString(); - if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); - } - return new BN.BN(hex.substring(2), 16); -} -function throwFault(fault, operation, value) { - var params = { fault: fault, operation: operation }; - if (value != null) { - params.value = value; - } - return logger.throwError(fault, logger_1.Logger.errors.NUMERIC_FAULT, params); -} - -},{"./_version":65,"@ethersproject/bytes":70,"@ethersproject/logger":91,"bn.js":2}],67:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var bignumber_1 = require("./bignumber"); -var _constructorGuard = {}; -var Zero = bignumber_1.BigNumber.from(0); -var NegativeOne = bignumber_1.BigNumber.from(-1); -function throwFault(message, fault, operation, value) { - var params = { fault: fault, operation: operation }; - if (value !== undefined) { - params.value = value; - } - return logger.throwError(message, logger_1.Logger.errors.NUMERIC_FAULT, params); -} -// Constant to pull zeros from for multipliers -var zeros = "0"; -while (zeros.length < 256) { - zeros += zeros; -} -// Returns a string "1" followed by decimal "0"s -function getMultiplier(decimals) { - if (typeof (decimals) !== "number") { - try { - decimals = bignumber_1.BigNumber.from(decimals).toNumber(); - } - catch (e) { } - } - if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { - return ("1" + zeros.substring(0, decimals)); - } - return logger.throwArgumentError("invalid decimal size", "decimals", decimals); -} -function formatFixed(value, decimals) { - if (decimals == null) { - decimals = 0; - } - var multiplier = getMultiplier(decimals); - // Make sure wei is a big number (convert as necessary) - value = bignumber_1.BigNumber.from(value); - var negative = value.lt(Zero); - if (negative) { - value = value.mul(NegativeOne); - } - var fraction = value.mod(multiplier).toString(); - while (fraction.length < multiplier.length - 1) { - fraction = "0" + fraction; - } - // Strip training 0 - fraction = fraction.match(/^([0-9]*[1-9]|0)(0*)/)[1]; - var whole = value.div(multiplier).toString(); - value = whole + "." + fraction; - if (negative) { - value = "-" + value; - } - return value; -} -exports.formatFixed = formatFixed; -function parseFixed(value, decimals) { - if (decimals == null) { - decimals = 0; - } - var multiplier = getMultiplier(decimals); - if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { - logger.throwArgumentError("invalid decimal value", "value", value); - } - if (multiplier.length - 1 === 0) { - return bignumber_1.BigNumber.from(value); - } - // Is it negative? - var negative = (value.substring(0, 1) === "-"); - if (negative) { - value = value.substring(1); - } - if (value === ".") { - logger.throwArgumentError("missing value", "value", value); - } - // Split it into a whole and fractional part - var comps = value.split("."); - if (comps.length > 2) { - logger.throwArgumentError("too many decimal points", "value", value); - } - var whole = comps[0], fraction = comps[1]; - if (!whole) { - whole = "0"; - } - if (!fraction) { - fraction = "0"; - } - // Prevent underflow - if (fraction.length > multiplier.length - 1) { - throwFault("fractional component exceeds decimals", "underflow", "parseFixed"); - } - // Fully pad the string with zeros to get to wei - while (fraction.length < multiplier.length - 1) { - fraction += "0"; - } - var wholeValue = bignumber_1.BigNumber.from(whole); - var fractionValue = bignumber_1.BigNumber.from(fraction); - var wei = (wholeValue.mul(multiplier)).add(fractionValue); - if (negative) { - wei = wei.mul(NegativeOne); - } - return wei; -} -exports.parseFixed = parseFixed; -var FixedFormat = /** @class */ (function () { - function FixedFormat(constructorGuard, signed, width, decimals) { - this.signed = signed; - this.width = width; - this.decimals = decimals; - this.name = (signed ? "" : "u") + "fixed" + String(width) + "x" + String(decimals); - this._multiplier = getMultiplier(decimals); - Object.freeze(this); - } - FixedFormat.from = function (value) { - if (value instanceof FixedFormat) { - return value; - } - var signed = true; - var width = 128; - var decimals = 18; - if (typeof (value) === "string") { - if (value === "fixed") { - // defaults... - } - else if (value === "ufixed") { - signed = false; - } - else if (value != null) { - var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); - if (!match) { - logger.throwArgumentError("invalid fixed format", "format", value); - } - signed = (match[1] !== "u"); - width = parseInt(match[2]); - decimals = parseInt(match[3]); - } - } - else if (value) { - var check = function (key, type, defaultValue) { - if (value[key] == null) { - return defaultValue; - } - if (typeof (value[key]) !== type) { - logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); - } - return value[key]; - }; - signed = check("signed", "boolean", signed); - width = check("width", "number", width); - decimals = check("decimals", "number", decimals); - } - if (width % 8) { - logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); - } - if (decimals > 80) { - logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); - } - return new FixedFormat(_constructorGuard, signed, width, decimals); - }; - return FixedFormat; -}()); -exports.FixedFormat = FixedFormat; -var FixedNumber = /** @class */ (function () { - function FixedNumber(constructorGuard, hex, value, format) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, FixedNumber); - this.format = format; - this._hex = hex; - this._value = value; - this._isFixedNumber = true; - Object.freeze(this); - } - FixedNumber.prototype._checkFormat = function (other) { - if (this.format.name !== other.format.name) { - logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); - } - }; - FixedNumber.prototype.addUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.add(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.subUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.sub(b), this.format.decimals, this.format); - }; - FixedNumber.prototype.mulUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.mul(b).div(this.format._multiplier), this.format.decimals, this.format); - }; - FixedNumber.prototype.divUnsafe = function (other) { - this._checkFormat(other); - var a = parseFixed(this._value, this.format.decimals); - var b = parseFixed(other._value, other.format.decimals); - return FixedNumber.fromValue(a.mul(this.format._multiplier).div(b), this.format.decimals, this.format); - }; - // @TODO: Support other rounding algorithms - FixedNumber.prototype.round = function (decimals) { - if (decimals == null) { - decimals = 0; - } - if (decimals < 0 || decimals > 80 || (decimals % 1)) { - logger.throwArgumentError("invalid decimal cound", "decimals", decimals); - } - // If we are already in range, we're done - var comps = this.toString().split("."); - if (comps[1].length <= decimals) { - return this; - } - // Bump the value up by the 0.00...0005 - var bump = "0." + zeros.substring(0, decimals) + "5"; - comps = this.addUnsafe(FixedNumber.fromString(bump, this.format))._value.split("."); - // Now it is safe to truncate - return FixedNumber.fromString(comps[0] + "." + comps[1].substring(0, decimals)); - }; - FixedNumber.prototype.toString = function () { return this._value; }; - FixedNumber.prototype.toHexString = function (width) { - if (width == null) { - return this._hex; - } - if (width % 8) { - logger.throwArgumentError("invalid byte width", "width", width); - } - var hex = bignumber_1.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); - return bytes_1.hexZeroPad(hex, width / 8); - }; - FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; - FixedNumber.prototype.toFormat = function (format) { - return FixedNumber.fromString(this._value, format); - }; - FixedNumber.fromValue = function (value, decimals, format) { - // If decimals looks more like a format, and there is no format, shift the parameters - if (format == null && decimals != null && !bignumber_1.isBigNumberish(decimals)) { - format = decimals; - decimals = null; - } - if (decimals == null) { - decimals = 0; - } - if (format == null) { - format = "fixed"; - } - return FixedNumber.fromString(formatFixed(value, decimals), FixedFormat.from(format)); - }; - FixedNumber.fromString = function (value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - var numeric = parseFixed(value, fixedFormat.decimals); - if (!fixedFormat.signed && numeric.lt(Zero)) { - throwFault("unsigned value cannot be negative", "overflow", "value", value); - } - var hex = null; - if (fixedFormat.signed) { - hex = numeric.toTwos(fixedFormat.width).toHexString(); - } - else { - hex = numeric.toHexString(); - hex = bytes_1.hexZeroPad(hex, fixedFormat.width / 8); - } - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber.fromBytes = function (value, format) { - if (format == null) { - format = "fixed"; - } - var fixedFormat = FixedFormat.from(format); - if (bytes_1.arrayify(value).length > fixedFormat.width / 8) { - throw new Error("overflow"); - } - var numeric = bignumber_1.BigNumber.from(value); - if (fixedFormat.signed) { - numeric = numeric.fromTwos(fixedFormat.width); - } - var hex = numeric.toTwos((fixedFormat.signed ? 0 : 1) + fixedFormat.width).toHexString(); - var decimal = formatFixed(numeric, fixedFormat.decimals); - return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); - }; - FixedNumber.from = function (value, format) { - if (typeof (value) === "string") { - return FixedNumber.fromString(value, format); - } - if (bytes_1.isBytes(value)) { - return FixedNumber.fromBytes(value, format); - } - try { - return FixedNumber.fromValue(value, 0, format); - } - catch (error) { - // Allow NUMERIC_FAULT to bubble up - if (error.code !== logger_1.Logger.errors.INVALID_ARGUMENT) { - throw error; - } - } - return logger.throwArgumentError("invalid FixedNumber value", "value", value); - }; - FixedNumber.isFixedNumber = function (value) { - return !!(value && value._isFixedNumber); - }; - return FixedNumber; -}()); -exports.FixedNumber = FixedNumber; - -},{"./_version":65,"./bignumber":66,"@ethersproject/bytes":70,"@ethersproject/logger":91}],68:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bignumber_1 = require("./bignumber"); -exports.BigNumber = bignumber_1.BigNumber; -var fixednumber_1 = require("./fixednumber"); -exports.FixedNumber = fixednumber_1.FixedNumber; - -},{"./bignumber":66,"./fixednumber":67}],69:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "bytes/5.0.0-beta.128"; - -},{}],70:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -/////////////////////////////// -function isHexable(value) { - return !!(value.toHexString); -} -function addSlice(array) { - if (array.slice) { - return array; - } - array.slice = function () { - var args = Array.prototype.slice.call(arguments); - return addSlice(new Uint8Array(Array.prototype.slice.apply(array, args))); - }; - return array; -} -function isBytesLike(value) { - return ((isHexString(value) && !(value.length % 2)) || isBytes(value)); -} -exports.isBytesLike = isBytesLike; -function isBytes(value) { - if (value == null) { - return false; - } - if (value.constructor === Uint8Array) { - return true; - } - if (typeof (value) === "string") { - return false; - } - if (value.length == null) { - return false; - } - for (var i = 0; i < value.length; i++) { - var v = value[i]; - if (v < 0 || v >= 256 || (v % 1)) { - return false; - } - } - return true; -} -exports.isBytes = isBytes; -function arrayify(value, options) { - if (!options) { - options = {}; - } - if (typeof (value) === "number") { - logger.checkSafeUint53(value, "invalid arrayify value"); - var result = []; - while (value) { - result.unshift(value & 0xff); - value /= 256; - } - if (result.length === 0) { - result.push(0); - } - return addSlice(new Uint8Array(result)); - } - if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - if (isHexable(value)) { - value = value.toHexString(); - } - if (isHexString(value)) { - var hex = value.substring(2); - if (!options.allowOddLength && hex.length % 2) { - logger.throwArgumentError("hex data is odd-length", "value", value); - } - var result = []; - for (var i = 0; i < hex.length; i += 2) { - result.push(parseInt(hex.substring(i, i + 2), 16)); - } - return addSlice(new Uint8Array(result)); - } - if (isBytes(value)) { - return addSlice(new Uint8Array(value)); - } - return logger.throwArgumentError("invalid arrayify value", "value", value); -} -exports.arrayify = arrayify; -function concat(items) { - var objects = items.map(function (item) { return arrayify(item); }); - var length = objects.reduce(function (accum, item) { return (accum + item.length); }, 0); - var result = new Uint8Array(length); - objects.reduce(function (offset, object) { - result.set(object, offset); - return offset + object.length; - }, 0); - return addSlice(result); -} -exports.concat = concat; -function stripZeros(value) { - var result = arrayify(value); - if (result.length === 0) { - return result; - } - // Find the first non-zero entry - var start = 0; - while (start < result.length && result[start] === 0) { - start++; - } - // If we started with zeros, strip them - if (start) { - result = result.slice(start); - } - return result; -} -exports.stripZeros = stripZeros; -function zeroPad(value, length) { - value = arrayify(value); - if (value.length > length) { - logger.throwArgumentError("value out of range", "value", arguments[0]); - } - var result = new Uint8Array(length); - result.set(value, length - value.length); - return addSlice(result); -} -exports.zeroPad = zeroPad; -function isHexString(value, length) { - if (typeof (value) !== "string" || !value.match(/^0x[0-9A-Fa-f]*$/)) { - return false; - } - if (length && value.length !== 2 + 2 * length) { - return false; - } - return true; -} -exports.isHexString = isHexString; -var HexCharacters = "0123456789abcdef"; -function hexlify(value, options) { - if (!options) { - options = {}; - } - if (typeof (value) === "number") { - logger.checkSafeUint53(value, "invalid hexlify value"); - var hex = ""; - while (value) { - hex = HexCharacters[value & 0x0f] + hex; - value = Math.floor(value / 16); - } - if (hex.length) { - if (hex.length % 2) { - hex = "0" + hex; - } - return "0x" + hex; - } - return "0x00"; - } - if (options.allowMissingPrefix && typeof (value) === "string" && value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - if (isHexable(value)) { - return value.toHexString(); - } - if (isHexString(value)) { - if (!options.allowOddLength && value.length % 2) { - logger.throwArgumentError("hex data is odd-length", "value", value); - } - return value.toLowerCase(); - } - if (isBytes(value)) { - var result = "0x"; - for (var i = 0; i < value.length; i++) { - var v = value[i]; - result += HexCharacters[(v & 0xf0) >> 4] + HexCharacters[v & 0x0f]; - } - return result; - } - return logger.throwArgumentError("invalid hexlify value", "value", value); -} -exports.hexlify = hexlify; -/* -function unoddify(value: BytesLike | Hexable | number): BytesLike | Hexable | number { - if (typeof(value) === "string" && value.length % 2 && value.substring(0, 2) === "0x") { - return "0x0" + value.substring(2); - } - return value; -} -*/ -function hexDataLength(data) { - if (typeof (data) !== "string") { - data = hexlify(data); - } - else if (!isHexString(data) || (data.length % 2)) { - return null; - } - return (data.length - 2) / 2; -} -exports.hexDataLength = hexDataLength; -function hexDataSlice(data, offset, endOffset) { - if (typeof (data) !== "string") { - data = hexlify(data); - } - else if (!isHexString(data) || (data.length % 2)) { - logger.throwArgumentError("invalid hexData", "value", data); - } - offset = 2 + 2 * offset; - if (endOffset != null) { - return "0x" + data.substring(offset, 2 + 2 * endOffset); - } - return "0x" + data.substring(offset); -} -exports.hexDataSlice = hexDataSlice; -function hexConcat(items) { - var result = "0x"; - items.forEach(function (item) { - result += hexlify(item).substring(2); - }); - return result; -} -exports.hexConcat = hexConcat; -function hexValue(value) { - var trimmed = hexStripZeros(hexlify(value, { allowOddLength: true })); - if (trimmed === "0x") { - return "0x0"; - } - return trimmed; -} -exports.hexValue = hexValue; -function hexStripZeros(value) { - if (typeof (value) !== "string") { - value = hexlify(value); - } - if (!isHexString(value)) { - logger.throwArgumentError("invalid hex string", "value", value); - } - value = value.substring(2); - var offset = 0; - while (offset < value.length && value[offset] === "0") { - offset++; - } - return "0x" + value.substring(offset); -} -exports.hexStripZeros = hexStripZeros; -function hexZeroPad(value, length) { - if (typeof (value) !== "string") { - value = hexlify(value); - } - else if (!isHexString(value)) { - logger.throwArgumentError("invalid hex string", "value", value); - } - if (value.length > 2 * length + 2) { - logger.throwArgumentError("value out of range", "value", arguments[1]); - } - while (value.length < 2 * length + 2) { - value = "0x0" + value.substring(2); - } - return value; -} -exports.hexZeroPad = hexZeroPad; -function splitSignature(signature) { - var result = { - r: "0x", - s: "0x", - _vs: "0x", - recoveryParam: 0, - v: 0 - }; - if (isBytesLike(signature)) { - var bytes = arrayify(signature); - if (bytes.length !== 65) { - logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); - } - // Get the r and s - result.r = hexlify(bytes.slice(0, 32)); - result.s = hexlify(bytes.slice(32, 64)); - // Reduce v to the canonical 27 or 28 - result.v = bytes[64]; - if (result.v !== 27 && result.v !== 28) { - result.v = 27 + (result.v % 2); - } - // Compute recoveryParam from v - result.recoveryParam = (result.v - 27); - // Compute _vs from recoveryParam and s - if (result.recoveryParam) { - bytes[32] |= 0x80; - } - result._vs = hexlify(bytes.slice(32, 64)); - } - else { - result.r = signature.r; - result.s = signature.s; - result.v = signature.v; - result.recoveryParam = signature.recoveryParam; - result._vs = signature._vs; - // Normalize v into a canonical 27 or 28 - if (result.v != null && !(result.v == 27 || result.v == 28)) { - result.v = 27 + (result.v % 2); - } - // Populate a missing v or recoveryParam if possible - if (result.recoveryParam == null && result.v != null) { - result.recoveryParam = 1 - (result.v % 2); - } - else if (result.recoveryParam != null && result.v == null) { - result.v = 27 + result.recoveryParam; - } - else if (result.recoveryParam != null && result.v != null) { - if (result.v !== 27 + result.recoveryParam) { - logger.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); - } - } - // Make sure r and s are padded properly - if (result.r != null) { - result.r = hexZeroPad(result.r, 32); - } - if (result.s != null) { - result.s = hexZeroPad(result.s, 32); - } - // If the _vs is available, use it to populate missing s, v and recoveryParam - // and verify non-missing s, v and recoveryParam - if (result._vs != null) { - result._vs = hexZeroPad(result._vs, 32); - if (result._vs.length > 66) { - logger.throwArgumentError("signature _vs overflow", "signature", signature); - } - var vs = arrayify(result._vs); - var recoveryParam = ((vs[0] >= 128) ? 1 : 0); - var v = 27 + result.recoveryParam; - // Use _vs to compute s - vs[0] &= 0x7f; - var s = hexlify(vs); - // Check _vs aggress with other parameters - if (result.s == null) { - result.s = s; - } - else if (result.s !== s) { - logger.throwArgumentError("signature v mismatch _vs", "signature", signature); - } - if (result.v == null) { - result.v = v; - } - else if (result.v !== v) { - logger.throwArgumentError("signature v mismatch _vs", "signature", signature); - } - if (recoveryParam == null) { - result.recoveryParam = recoveryParam; - } - else if (result.recoveryParam !== recoveryParam) { - logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); - } - } - // After all populating, both v and recoveryParam are still missing... - if (result.v == null && result.recoveryParam == null) { - logger.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); - } - // Check for canonical v - if (result.v !== 27 && result.v !== 28) { - logger.throwArgumentError("signature v not canonical", "signature", signature); - } - // Check that r and s are in range - if (result.r.length > 66 || result.s.length > 66) { - logger.throwArgumentError("signature overflow r or s", "signature", signature); - } - if (result._vs == null) { - var vs = arrayify(result.s); - if (vs[0] >= 128) { - logger.throwArgumentError("signature s out of range", "signature", signature); - } - if (result.recoveryParam) { - vs[0] |= 0x80; - } - result._vs = hexlify(vs); - } - } - return result; -} -exports.splitSignature = splitSignature; -function joinSignature(signature) { - signature = splitSignature(signature); - return hexlify(concat([ - signature.r, - signature.s, - (signature.recoveryParam ? "0x1c" : "0x1b") - ])); -} -exports.joinSignature = joinSignature; - -},{"./_version":69,"@ethersproject/logger":91}],71:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bignumber_1 = require("@ethersproject/bignumber"); -var AddressZero = "0x0000000000000000000000000000000000000000"; -exports.AddressZero = AddressZero; -var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000"; -exports.HashZero = HashZero; -// NFKD (decomposed) -//const EtherSymbol = "\uD835\uDF63"; -// NFKC (composed) -var EtherSymbol = "\u039e"; -exports.EtherSymbol = EtherSymbol; -var NegativeOne = bignumber_1.BigNumber.from(-1); -exports.NegativeOne = NegativeOne; -var Zero = bignumber_1.BigNumber.from(0); -exports.Zero = Zero; -var One = bignumber_1.BigNumber.from(1); -exports.One = One; -var Two = bignumber_1.BigNumber.from(2); -exports.Two = Two; -var WeiPerEther = bignumber_1.BigNumber.from("1000000000000000000"); -exports.WeiPerEther = WeiPerEther; -var MaxUint256 = bignumber_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); -exports.MaxUint256 = MaxUint256; - -},{"@ethersproject/bignumber":68}],72:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "contracts/5.0.0-beta.136"; - -},{}],73:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abi_1 = require("@ethersproject/abi"); -var abstract_provider_1 = require("@ethersproject/abstract-provider"); -var abstract_signer_1 = require("@ethersproject/abstract-signer"); -var address_1 = require("@ethersproject/address"); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var constants_1 = require("@ethersproject/constants"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -/////////////////////////////// -var allowedTransactionKeys = { - chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true -}; -// Recursively replaces ENS names with promises to resolve the name and resolves all properties -function resolveAddresses(signerOrProvider, value, paramType) { - if (Array.isArray(paramType)) { - return Promise.all(paramType.map(function (paramType, index) { - return resolveAddresses(signerOrProvider, ((Array.isArray(value)) ? value[index] : value[paramType.name]), paramType); - })); - } - if (paramType.type === "address") { - return signerOrProvider.resolveName(value); - } - if (paramType.type === "tuple") { - return resolveAddresses(signerOrProvider, value, paramType.components); - } - if (paramType.baseType === "array") { - if (!Array.isArray(value)) { - throw new Error("invalid value for array"); - } - return Promise.all(value.map(function (v) { return resolveAddresses(signerOrProvider, v, paramType.arrayChildren); })); - } - return Promise.resolve(value); -} -function runMethod(contract, functionName, options) { - var method = contract.interface.functions[functionName]; - return function () { - var _this = this; - var params = []; - for (var _i = 0; _i < arguments.length; _i++) { - params[_i] = arguments[_i]; - } - var tx = {}; - var blockTag = null; - // If 1 extra parameter was passed in, it contains overrides - if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === "object") { - tx = properties_1.shallowCopy(params.pop()); - if (tx.blockTag != null) { - blockTag = tx.blockTag; - } - delete tx.blockTag; - // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") - for (var key in tx) { - if (!allowedTransactionKeys[key]) { - logger.throwError(("unknown transaxction override - " + key), "overrides", tx); - } - } - } - logger.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); - // Check overrides make sense - ["data", "to"].forEach(function (key) { - if (tx[key] != null) { - logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); - } - }); - // If the contract was just deployed, wait until it is minded - if (contract.deployTransaction != null) { - tx.to = contract._deployed(blockTag).then(function () { - return contract.addressPromise; - }); - } - else { - tx.to = contract.addressPromise; - } - return resolveAddresses(contract.signer || contract.provider, params, method.inputs).then(function (params) { - tx.data = contract.interface.encodeFunctionData(method, params); - if (method.constant || options.callStatic) { - // Call (constant functions) always cost 0 ether - if (options.estimate) { - return Promise.resolve(constants_1.Zero); - } - if (!contract.provider && !contract.signer) { - logger.throwError("call (constant functions) require a provider or signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" }); - } - // Check overrides make sense - ["gasLimit", "gasPrice", "value"].forEach(function (key) { - if (tx[key] != null) { - throw new Error("call cannot override " + key); - } - }); - if (options.transaction) { - return properties_1.resolveProperties(tx); - } - return (contract.signer || contract.provider).call(tx, blockTag).then(function (value) { - try { - var result = contract.interface.decodeFunctionResult(method, value); - if (method.outputs.length === 1) { - result = result[0]; - } - return result; - } - catch (error) { - if (error.code === logger_1.Logger.errors.CALL_EXCEPTION) { - error.address = contract.address; - error.args = params; - error.transaction = tx; - } - throw error; - } - }); - } - // Only computing the transaction estimate - if (options.estimate) { - if (!contract.provider && !contract.signer) { - logger.throwError("estimate require a provider or signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); - } - return (contract.signer || contract.provider).estimateGas(tx); - } - if (tx.gasLimit == null && method.gas != null) { - tx.gasLimit = bignumber_1.BigNumber.from(method.gas).add(21000); - } - if (tx.value != null && !method.payable) { - logger.throwArgumentError("contract method is not payable", "sendTransaction:" + method.format(), tx); - } - if (options.transaction) { - return properties_1.resolveProperties(tx); - } - if (!contract.signer) { - logger.throwError("sending a transaction require a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); - } - return contract.signer.sendTransaction(tx).then(function (tx) { - var wait = tx.wait.bind(tx); - tx.wait = function (confirmations) { - return wait(confirmations).then(function (receipt) { - receipt.events = receipt.logs.map(function (log) { - var event = properties_1.deepCopy(log); - var parsed = contract.interface.parseLog(log); - if (parsed) { - event.values = parsed.values; - event.decode = function (data, topics) { - return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); - }; - event.event = parsed.name; - event.eventSignature = parsed.signature; - } - event.removeListener = function () { return contract.provider; }; - event.getBlock = function () { - return contract.provider.getBlock(receipt.blockHash); - }; - event.getTransaction = function () { - return contract.provider.getTransaction(receipt.transactionHash); - }; - event.getTransactionReceipt = function () { - return Promise.resolve(receipt); - }; - return event; - }); - return receipt; - }); - }; - return tx; - }); - }); - }; -} -function getEventTag(filter) { - if (filter.address && (filter.topics == null || filter.topics.length === 0)) { - return "*"; - } - return (filter.address || "*") + "@" + (filter.topics ? filter.topics.join(":") : ""); -} -var RunningEvent = /** @class */ (function () { - function RunningEvent(tag, filter) { - properties_1.defineReadOnly(this, "tag", tag); - properties_1.defineReadOnly(this, "filter", filter); - this._listeners = []; - } - RunningEvent.prototype.addListener = function (listener, once) { - this._listeners.push({ listener: listener, once: once }); - }; - RunningEvent.prototype.removeListener = function (listener) { - var done = false; - this._listeners = this._listeners.filter(function (item) { - if (done || item.listener !== listener) { - return true; - } - done = true; - return false; - }); - }; - RunningEvent.prototype.removeAllListeners = function () { - this._listeners = []; - }; - RunningEvent.prototype.listeners = function () { - return this._listeners.map(function (i) { return i.listener; }); - }; - RunningEvent.prototype.listenerCount = function () { - return this._listeners.length; - }; - RunningEvent.prototype.run = function (args) { - var _this = this; - var listenerCount = this.listenerCount(); - this._listeners = this._listeners.filter(function (item) { - var argsCopy = args.slice(); - // Call the callback in the next event loop - setTimeout(function () { - item.listener.apply(_this, argsCopy); - }, 0); - // Reschedule it if it not "once" - return !(item.once); - }); - return listenerCount; - }; - RunningEvent.prototype.prepareEvent = function (event) { - }; - return RunningEvent; -}()); -var ErrorRunningEvent = /** @class */ (function (_super) { - __extends(ErrorRunningEvent, _super); - function ErrorRunningEvent() { - return _super.call(this, "error", null) || this; - } - return ErrorRunningEvent; -}(RunningEvent)); -var FragmentRunningEvent = /** @class */ (function (_super) { - __extends(FragmentRunningEvent, _super); - function FragmentRunningEvent(address, contractInterface, fragment, topics) { - var _this = this; - var filter = { - address: address - }; - var topic = contractInterface.getEventTopic(fragment); - if (topics) { - if (topic !== topics[0]) { - logger.throwArgumentError("topic mismatch", "topics", topics); - } - filter.topics = topics.slice(); - } - else { - filter.topics = [topic]; - } - _this = _super.call(this, getEventTag(filter), filter) || this; - properties_1.defineReadOnly(_this, "address", address); - properties_1.defineReadOnly(_this, "interface", contractInterface); - properties_1.defineReadOnly(_this, "fragment", fragment); - return _this; - } - FragmentRunningEvent.prototype.prepareEvent = function (event) { - var _this = this; - _super.prototype.prepareEvent.call(this, event); - event.event = this.fragment.name; - event.eventSignature = this.fragment.format(); - event.decode = function (data, topics) { - return _this.interface.decodeEventLog(_this.fragment, data, topics); - }; - event.values = this.interface.decodeEventLog(this.fragment, event.data, event.topics); - }; - return FragmentRunningEvent; -}(RunningEvent)); -var WildcardRunningEvent = /** @class */ (function (_super) { - __extends(WildcardRunningEvent, _super); - function WildcardRunningEvent(address, contractInterface) { - var _this = _super.call(this, "*", { address: address }) || this; - properties_1.defineReadOnly(_this, "address", address); - properties_1.defineReadOnly(_this, "interface", contractInterface); - return _this; - } - WildcardRunningEvent.prototype.prepareEvent = function (event) { - var _this = this; - _super.prototype.prepareEvent.call(this, event); - var parsed = this.interface.parseLog(event); - if (parsed) { - event.event = parsed.name; - event.eventSignature = parsed.signature; - event.decode = function (data, topics) { - return _this.interface.decodeEventLog(parsed.eventFragment, data, topics); - }; - event.values = parsed.values; - } - }; - return WildcardRunningEvent; -}(RunningEvent)); -var Contract = /** @class */ (function () { - function Contract(addressOrName, contractInterface, signerOrProvider) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, Contract); - // @TODO: Maybe still check the addressOrName looks like a valid address or name? - //address = getAddress(address); - properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface)); - if (abstract_signer_1.Signer.isSigner(signerOrProvider)) { - properties_1.defineReadOnly(this, "provider", signerOrProvider.provider || null); - properties_1.defineReadOnly(this, "signer", signerOrProvider); - } - else if (abstract_provider_1.Provider.isProvider(signerOrProvider)) { - properties_1.defineReadOnly(this, "provider", signerOrProvider); - properties_1.defineReadOnly(this, "signer", null); - } - else { - logger.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); - } - properties_1.defineReadOnly(this, "callStatic", {}); - properties_1.defineReadOnly(this, "estimate", {}); - properties_1.defineReadOnly(this, "functions", {}); - properties_1.defineReadOnly(this, "populateTransaction", {}); - properties_1.defineReadOnly(this, "filters", {}); - Object.keys(this.interface.events).forEach(function (eventName) { - var event = _this.interface.events[eventName]; - properties_1.defineReadOnly(_this.filters, eventName, function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return { - address: _this.address, - topics: _this.interface.encodeFilterTopics(event, args) - }; - }); - }); - properties_1.defineReadOnly(this, "_runningEvents", {}); - properties_1.defineReadOnly(this, "_wrappedEmits", {}); - properties_1.defineReadOnly(this, "address", addressOrName); - if (this.provider) { - properties_1.defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then(function (address) { - if (address == null) { - throw new Error("name not found"); - } - return address; - }).catch(function (error) { - console.log("ERROR: Cannot find Contract - " + addressOrName); - throw error; - })); - } - else { - try { - properties_1.defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); - } - catch (error) { - // Without a provider, we cannot use ENS names - logger.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); - } - } - Object.keys(this.interface.functions).forEach(function (name) { - var run = runMethod(_this, name, {}); - if (_this[name] == null) { - properties_1.defineReadOnly(_this, name, run); - } - if (_this.functions[name] == null) { - properties_1.defineReadOnly(_this.functions, name, run); - } - if (_this.callStatic[name] == null) { - properties_1.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true })); - } - if (_this.populateTransaction[name] == null) { - properties_1.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true })); - } - if (_this.estimate[name] == null) { - properties_1.defineReadOnly(_this.estimate, name, runMethod(_this, name, { estimate: true })); - } - }); - } - Contract.getContractAddress = function (transaction) { - return address_1.getContractAddress(transaction); - }; - Contract.getInterface = function (contractInterface) { - if (abi_1.Interface.isInterface(contractInterface)) { - return contractInterface; - } - return new abi_1.Interface(contractInterface); - }; - // @TODO: Allow timeout? - Contract.prototype.deployed = function () { - return this._deployed(); - }; - Contract.prototype._deployed = function (blockTag) { - var _this = this; - if (!this._deployedPromise) { - // If we were just deployed, we know the transaction we should occur in - if (this.deployTransaction) { - this._deployedPromise = this.deployTransaction.wait().then(function () { - return _this; - }); - } - else { - // @TODO: Once we allow a timeout to be passed in, we will wait - // up to that many blocks for getCode - // Otherwise, poll for our code to be deployed - this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) { - if (code === "0x") { - logger.throwError("contract not deployed", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - contractAddress: _this.address, - operation: "getDeployed" - }); - } - return _this; - }); - } - } - return this._deployedPromise; - }; - // @TODO: - // estimateFallback(overrides?: TransactionRequest): Promise - // @TODO: - // estimateDeploy(bytecode: string, ...args): Promise - Contract.prototype.fallback = function (overrides) { - var _this = this; - if (!this.signer) { - logger.throwError("sending a transaction require a signer", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); - } - var tx = properties_1.shallowCopy(overrides || {}); - ["from", "to"].forEach(function (key) { - if (tx[key] == null) { - return; - } - logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); - }); - tx.to = this.addressPromise; - return this.deployed().then(function () { - return _this.signer.sendTransaction(tx); - }); - }; - // Reconnect to a different signer or provider - Contract.prototype.connect = function (signerOrProvider) { - if (typeof (signerOrProvider) === "string") { - signerOrProvider = new abstract_signer_1.VoidSigner(signerOrProvider, this.provider); - } - var contract = new (this.constructor)(this.address, this.interface, signerOrProvider); - if (this.deployTransaction) { - properties_1.defineReadOnly(contract, "deployTransaction", this.deployTransaction); - } - return contract; - }; - // Re-attach to a different on-chain instance of this contract - Contract.prototype.attach = function (addressOrName) { - return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider); - }; - Contract.isIndexed = function (value) { - return abi_1.Indexed.isIndexed(value); - }; - Contract.prototype._normalizeRunningEvent = function (runningEvent) { - // Already have an instance of this event running; we can re-use it - if (this._runningEvents[runningEvent.tag]) { - return this._runningEvents[runningEvent.tag]; - } - return runningEvent; - }; - Contract.prototype._getRunningEvent = function (eventName) { - if (typeof (eventName) === "string") { - // Listen for "error" events (if your contract has an error event, include - // the full signature to bypass this special event keyword) - if (eventName === "error") { - return this._normalizeRunningEvent(new ErrorRunningEvent()); - } - // Listen for any event - if (eventName === "*") { - return this._normalizeRunningEvent(new WildcardRunningEvent(this.address, this.interface)); - } - var fragment = this.interface.getEvent(eventName); - if (!fragment) { - logger.throwArgumentError("unknown event - " + eventName, "eventName", eventName); - } - return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); - } - var filter = { - address: this.address - }; - // Find the matching event in the ABI; if none, we still allow filtering - // since it may be a filter for an otherwise unknown event - if (eventName.topics) { - if (eventName.topics[0]) { - var fragment = this.interface.getEvent(eventName.topics[0]); - if (fragment) { - return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment, eventName.topics)); - } - } - filter.topics = eventName.topics; - } - return this._normalizeRunningEvent(new RunningEvent(getEventTag(filter), filter)); - }; - Contract.prototype._checkRunningEvents = function (runningEvent) { - if (runningEvent.listenerCount() === 0) { - delete this._runningEvents[runningEvent.tag]; - } - // If we have a poller for this, remove it - var emit = this._wrappedEmits[runningEvent.tag]; - if (emit) { - this.provider.off(runningEvent.filter, emit); - delete this._wrappedEmits[runningEvent.tag]; - } - }; - Contract.prototype._wrapEvent = function (runningEvent, log, listener) { - var _this = this; - var event = properties_1.deepCopy(log); - try { - runningEvent.prepareEvent(event); - } - catch (error) { - this.emit("error", error); - throw error; - } - event.removeListener = function () { - if (!listener) { - return; - } - runningEvent.removeListener(listener); - _this._checkRunningEvents(runningEvent); - }; - event.getBlock = function () { return _this.provider.getBlock(log.blockHash); }; - event.getTransaction = function () { return _this.provider.getTransaction(log.transactionHash); }; - event.getTransactionReceipt = function () { return _this.provider.getTransactionReceipt(log.transactionHash); }; - return event; - }; - Contract.prototype._addEventListener = function (runningEvent, listener, once) { - var _this = this; - if (!this.provider) { - logger.throwError("events require a provider or a signer with a provider", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); - } - runningEvent.addListener(listener, once); - // Track this running event and its listeners (may already be there; but no hard in updating) - this._runningEvents[runningEvent.tag] = runningEvent; - // If we are not polling the provider, start - if (!this._wrappedEmits[runningEvent.tag]) { - var wrappedEmit = function (log) { - var event = _this._wrapEvent(runningEvent, log, listener); - var values = (event.values || []); - values.push(event); - _this.emit.apply(_this, [runningEvent.filter].concat(values)); - }; - this._wrappedEmits[runningEvent.tag] = wrappedEmit; - // Special events, like "error" do not have a filter - if (runningEvent.filter != null) { - this.provider.on(runningEvent.filter, wrappedEmit); - } - } - }; - Contract.prototype.queryFilter = function (event, fromBlockOrBlockhash, toBlock) { - var _this = this; - var runningEvent = this._getRunningEvent(event); - var filter = properties_1.shallowCopy(runningEvent.filter); - if (typeof (fromBlockOrBlockhash) === "string" && bytes_1.isHexString(fromBlockOrBlockhash, 32)) { - if (toBlock != null) { - logger.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); - } - filter.blockhash = fromBlockOrBlockhash; - } - else { - filter.fromBlock = ((fromBlockOrBlockhash != null) ? fromBlockOrBlockhash : 0); - filter.toBlock = ((toBlock != null) ? toBlock : "latest"); - } - return this.provider.getLogs(filter).then(function (logs) { - return logs.map(function (log) { return _this._wrapEvent(runningEvent, log, null); }); - }); - }; - Contract.prototype.on = function (event, listener) { - this._addEventListener(this._getRunningEvent(event), listener, false); - return this; - }; - Contract.prototype.once = function (event, listener) { - this._addEventListener(this._getRunningEvent(event), listener, true); - return this; - }; - Contract.prototype.emit = function (eventName) { - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - if (!this.provider) { - return false; - } - var runningEvent = this._getRunningEvent(eventName); - var result = (runningEvent.run(args) > 0); - // May have drained all the "once" events; check for living events - this._checkRunningEvents(runningEvent); - return result; - }; - Contract.prototype.listenerCount = function (eventName) { - if (!this.provider) { - return 0; - } - return this._getRunningEvent(eventName).listenerCount(); - }; - Contract.prototype.listeners = function (eventName) { - if (!this.provider) { - return []; - } - if (eventName == null) { - var result_1 = []; - for (var tag in this._runningEvents) { - this._runningEvents[tag].listeners().forEach(function (listener) { - result_1.push(listener); - }); - } - return result_1; - } - return this._getRunningEvent(eventName).listeners(); - }; - Contract.prototype.removeAllListeners = function (eventName) { - if (!this.provider) { - return this; - } - if (eventName == null) { - for (var tag in this._runningEvents) { - var runningEvent_1 = this._runningEvents[tag]; - runningEvent_1.removeAllListeners(); - this._checkRunningEvents(runningEvent_1); - } - return this; - } - // Delete any listeners - var runningEvent = this._getRunningEvent(eventName); - runningEvent.removeAllListeners(); - this._checkRunningEvents(runningEvent); - return this; - }; - Contract.prototype.off = function (eventName, listener) { - if (!this.provider) { - return this; - } - var runningEvent = this._getRunningEvent(eventName); - runningEvent.removeListener(listener); - this._checkRunningEvents(runningEvent); - return this; - }; - Contract.prototype.removeListener = function (eventName, listener) { - return this.off(eventName, listener); - }; - return Contract; -}()); -exports.Contract = Contract; -var ContractFactory = /** @class */ (function () { - function ContractFactory(contractInterface, bytecode, signer) { - var _newTarget = this.constructor; - var bytecodeHex = null; - if (typeof (bytecode) === "string") { - bytecodeHex = bytecode; - } - else if (bytes_1.isBytes(bytecode)) { - bytecodeHex = bytes_1.hexlify(bytecode); - } - else if (bytecode && typeof (bytecode.object) === "string") { - // Allow the bytecode object from the Solidity compiler - bytecodeHex = bytecode.object; - } - else { - // Crash in the next verification step - bytecodeHex = "!"; - } - // Make sure it is 0x prefixed - if (bytecodeHex.substring(0, 2) !== "0x") { - bytecodeHex = "0x" + bytecodeHex; - } - // Make sure the final result is valid bytecode - if (!bytes_1.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { - logger.throwArgumentError("invalid bytecode", "bytecode", bytecode); - } - // If we have a signer, make sure it is valid - if (signer && !abstract_signer_1.Signer.isSigner(signer)) { - logger.throwArgumentError("invalid signer", "signer", signer); - } - properties_1.defineReadOnly(this, "bytecode", bytecodeHex); - properties_1.defineReadOnly(this, "interface", properties_1.getStatic((_newTarget), "getInterface")(contractInterface)); - properties_1.defineReadOnly(this, "signer", signer || null); - } - ContractFactory.prototype.getDeployTransaction = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - var tx = {}; - // If we have 1 additional argument, we allow transaction overrides - if (args.length === this.interface.deploy.inputs.length + 1) { - tx = properties_1.shallowCopy(args.pop()); - for (var key in tx) { - if (!allowedTransactionKeys[key]) { - throw new Error("unknown transaction override " + key); - } - } - } - // Do not allow these to be overridden in a deployment transaction - ["data", "from", "to"].forEach(function (key) { - if (tx[key] == null) { - return; - } - logger.throwError("cannot override " + key, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); - }); - // Make sure the call matches the constructor signature - logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); - // Set the data to the bytecode + the encoded constructor arguments - tx.data = bytes_1.hexlify(bytes_1.concat([ - this.bytecode, - this.interface.encodeDeploy(args) - ])); - return tx; - }; - ContractFactory.prototype.deploy = function () { - var _this = this; - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - return resolveAddresses(this.signer, args, this.interface.deploy.inputs).then(function (args) { - // Get the deployment transaction (with optional overrides) - var tx = _this.getDeployTransaction.apply(_this, args); - // Send the deployment transaction - return _this.signer.sendTransaction(tx).then(function (tx) { - var address = (_this.constructor).getContractAddress(tx); - var contract = (_this.constructor).getContract(address, _this.interface, _this.signer); - properties_1.defineReadOnly(contract, "deployTransaction", tx); - return contract; - }); - }); - }; - ContractFactory.prototype.attach = function (address) { - return (this.constructor).getContract(address, this.interface, this.signer); - }; - ContractFactory.prototype.connect = function (signer) { - return new (this.constructor)(this.interface, this.bytecode, signer); - }; - ContractFactory.fromSolidity = function (compilerOutput, signer) { - if (compilerOutput == null) { - logger.throwError("missing compiler output", logger_1.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); - } - if (typeof (compilerOutput) === "string") { - compilerOutput = JSON.parse(compilerOutput); - } - var abi = compilerOutput.abi; - var bytecode = null; - if (compilerOutput.bytecode) { - bytecode = compilerOutput.bytecode; - } - else if (compilerOutput.evm && compilerOutput.evm.bytecode) { - bytecode = compilerOutput.evm.bytecode; - } - return new this(abi, bytecode, signer); - }; - ContractFactory.getInterface = function (contractInterface) { - return Contract.getInterface(contractInterface); - }; - ContractFactory.getContractAddress = function (tx) { - return address_1.getContractAddress(tx); - }; - ContractFactory.getContract = function (address, contractInterface, signer) { - return new Contract(address, contractInterface, signer); - }; - return ContractFactory; -}()); -exports.ContractFactory = ContractFactory; - -},{"./_version":72,"@ethersproject/abi":55,"@ethersproject/abstract-provider":58,"@ethersproject/abstract-signer":60,"@ethersproject/address":62,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/constants":71,"@ethersproject/logger":91,"@ethersproject/properties":96}],74:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "ethers/5.0.0-beta.155"; - -},{}],75:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var contracts_1 = require("@ethersproject/contracts"); -exports.Contract = contracts_1.Contract; -exports.ContractFactory = contracts_1.ContractFactory; -var bignumber_1 = require("@ethersproject/bignumber"); -exports.BigNumber = bignumber_1.BigNumber; -exports.FixedNumber = bignumber_1.FixedNumber; -var abstract_signer_1 = require("@ethersproject/abstract-signer"); -exports.Signer = abstract_signer_1.Signer; -exports.VoidSigner = abstract_signer_1.VoidSigner; -var wallet_1 = require("@ethersproject/wallet"); -exports.Wallet = wallet_1.Wallet; -var constants = __importStar(require("@ethersproject/constants")); -exports.constants = constants; -var providers = __importStar(require("@ethersproject/providers")); -exports.providers = providers; -var wordlists_1 = require("@ethersproject/wordlists"); -exports.Wordlist = wordlists_1.Wordlist; -exports.wordlists = wordlists_1.wordlists; -var utils = __importStar(require("./utils")); -exports.utils = utils; -var logger_1 = require("@ethersproject/logger"); -var errors = logger_1.Logger.errors; -exports.errors = errors; -//////////////////////// -// Compile-Time Constants -// This is empty in node, and used by browserify to inject extra goodies -var platform_1 = require("./platform"); -exports.platform = platform_1.platform; -// This is generated by "npm run dist" -var _version_1 = require("./_version"); -exports.version = _version_1.version; -var logger = new logger_1.Logger(_version_1.version); -exports.logger = logger; -//////////////////////// -// Helper Functions -function getDefaultProvider(network, options) { - if (network == null) { - network = "homestead"; - } - var n = providers.getNetwork(network); - if (!n || !n._defaultProvider) { - logger.throwError("unsupported getDefaultProvider network", logger_1.Logger.errors.NETWORK_ERROR, { - operation: "getDefaultProvider", - network: network - }); - } - return n._defaultProvider(providers, options); -} -exports.getDefaultProvider = getDefaultProvider; - -},{"./_version":74,"./platform":77,"./utils":78,"@ethersproject/abstract-signer":60,"@ethersproject/bignumber":68,"@ethersproject/constants":71,"@ethersproject/contracts":73,"@ethersproject/logger":91,"@ethersproject/providers":105,"@ethersproject/wallet":130,"@ethersproject/wordlists":134}],76:[function(require,module,exports){ -"use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var ethers = __importStar(require("./ethers")); -exports.ethers = ethers; -__export(require("./ethers")); - -},{"./ethers":75}],77:[function(require,module,exports){ -"use strict"; - -exports.platform = "browser" -},{}],78:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var abi_1 = require("@ethersproject/abi"); -exports.AbiCoder = abi_1.AbiCoder; -exports.defaultAbiCoder = abi_1.defaultAbiCoder; -exports.EventFragment = abi_1.EventFragment; -exports.FormatTypes = abi_1.FormatTypes; -exports.Fragment = abi_1.Fragment; -exports.FunctionFragment = abi_1.FunctionFragment; -exports.Indexed = abi_1.Indexed; -exports.Interface = abi_1.Interface; -exports.ParamType = abi_1.ParamType; -var address_1 = require("@ethersproject/address"); -exports.getAddress = address_1.getAddress; -exports.getContractAddress = address_1.getContractAddress; -exports.getIcapAddress = address_1.getIcapAddress; -exports.isAddress = address_1.isAddress; -var base64 = __importStar(require("@ethersproject/base64")); -exports.base64 = base64; -var bytes_1 = require("@ethersproject/bytes"); -exports.arrayify = bytes_1.arrayify; -exports.concat = bytes_1.concat; -exports.hexDataSlice = bytes_1.hexDataSlice; -exports.hexDataLength = bytes_1.hexDataLength; -exports.hexlify = bytes_1.hexlify; -exports.hexStripZeros = bytes_1.hexStripZeros; -exports.hexValue = bytes_1.hexValue; -exports.hexZeroPad = bytes_1.hexZeroPad; -exports.isHexString = bytes_1.isHexString; -exports.joinSignature = bytes_1.joinSignature; -exports.zeroPad = bytes_1.zeroPad; -exports.splitSignature = bytes_1.splitSignature; -exports.stripZeros = bytes_1.stripZeros; -var hash_1 = require("@ethersproject/hash"); -exports.hashMessage = hash_1.hashMessage; -exports.id = hash_1.id; -exports.isValidName = hash_1.isValidName; -exports.namehash = hash_1.namehash; -var hdnode_1 = require("@ethersproject/hdnode"); -exports.defaultPath = hdnode_1.defaultPath; -exports.entropyToMnemonic = hdnode_1.entropyToMnemonic; -exports.HDNode = hdnode_1.HDNode; -exports.isValidMnemonic = hdnode_1.isValidMnemonic; -exports.mnemonicToEntropy = hdnode_1.mnemonicToEntropy; -exports.mnemonicToSeed = hdnode_1.mnemonicToSeed; -var json_wallets_1 = require("@ethersproject/json-wallets"); -exports.getJsonWalletAddress = json_wallets_1.getJsonWalletAddress; -var keccak256_1 = require("@ethersproject/keccak256"); -exports.keccak256 = keccak256_1.keccak256; -var logger_1 = require("@ethersproject/logger"); -exports.Logger = logger_1.Logger; -var sha2_1 = require("@ethersproject/sha2"); -exports.sha256 = sha2_1.sha256; -var solidity_1 = require("@ethersproject/solidity"); -exports.solidityKeccak256 = solidity_1.keccak256; -exports.solidityPack = solidity_1.pack; -exports.soliditySha256 = solidity_1.sha256; -var random_1 = require("@ethersproject/random"); -exports.randomBytes = random_1.randomBytes; -var properties_1 = require("@ethersproject/properties"); -exports.checkProperties = properties_1.checkProperties; -exports.deepCopy = properties_1.deepCopy; -exports.defineReadOnly = properties_1.defineReadOnly; -exports.getStatic = properties_1.getStatic; -exports.resolveProperties = properties_1.resolveProperties; -exports.shallowCopy = properties_1.shallowCopy; -var RLP = __importStar(require("@ethersproject/rlp")); -exports.RLP = RLP; -var signing_key_1 = require("@ethersproject/signing-key"); -exports.computePublicKey = signing_key_1.computePublicKey; -exports.recoverPublicKey = signing_key_1.recoverPublicKey; -exports.SigningKey = signing_key_1.SigningKey; -var strings_1 = require("@ethersproject/strings"); -exports.formatBytes32String = strings_1.formatBytes32String; -exports.nameprep = strings_1.nameprep; -exports.parseBytes32String = strings_1.parseBytes32String; -exports._toEscapedUtf8String = strings_1._toEscapedUtf8String; -exports.toUtf8Bytes = strings_1.toUtf8Bytes; -exports.toUtf8CodePoints = strings_1.toUtf8CodePoints; -exports.toUtf8String = strings_1.toUtf8String; -var transactions_1 = require("@ethersproject/transactions"); -exports.computeAddress = transactions_1.computeAddress; -exports.parseTransaction = transactions_1.parse; -exports.recoverAddress = transactions_1.recoverAddress; -exports.serializeTransaction = transactions_1.serialize; -var units_1 = require("@ethersproject/units"); -exports.commify = units_1.commify; -exports.formatEther = units_1.formatEther; -exports.parseEther = units_1.parseEther; -exports.formatUnits = units_1.formatUnits; -exports.parseUnits = units_1.parseUnits; -var wallet_1 = require("@ethersproject/wallet"); -exports.verifyMessage = wallet_1.verifyMessage; -var web_1 = require("@ethersproject/web"); -exports.fetchJson = web_1.fetchJson; -exports.poll = web_1.poll; -//////////////////////// -// Enums -var sha2_2 = require("@ethersproject/sha2"); -exports.SupportedAlgorithms = sha2_2.SupportedAlgorithms; -var strings_2 = require("@ethersproject/strings"); -exports.UnicodeNormalizationForm = strings_2.UnicodeNormalizationForm; - -},{"@ethersproject/abi":55,"@ethersproject/address":62,"@ethersproject/base64":63,"@ethersproject/bytes":70,"@ethersproject/hash":80,"@ethersproject/hdnode":82,"@ethersproject/json-wallets":85,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/random":112,"@ethersproject/rlp":114,"@ethersproject/sha2":116,"@ethersproject/signing-key":118,"@ethersproject/solidity":119,"@ethersproject/strings":123,"@ethersproject/transactions":126,"@ethersproject/units":128,"@ethersproject/wallet":130,"@ethersproject/web":132}],79:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "hash/5.0.0-beta.127"; - -},{}],80:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var strings_1 = require("@ethersproject/strings"); -var keccak256_1 = require("@ethersproject/keccak256"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -/////////////////////////////// -var Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); -var Partition = new RegExp("^((.*)\\.)?([^.]+)$"); -function isValidName(name) { - try { - var comps = name.split("."); - for (var i = 0; i < comps.length; i++) { - if (strings_1.nameprep(comps[i]).length === 0) { - throw new Error("empty"); - } - } - return true; - } - catch (error) { } - return false; -} -exports.isValidName = isValidName; -function namehash(name) { - if (typeof (name) !== "string") { - logger.throwArgumentError("invalid address - " + String(name), "name", name); - } - var result = Zeros; - while (name.length) { - var partition = name.match(Partition); - var label = strings_1.toUtf8Bytes(strings_1.nameprep(partition[3])); - result = keccak256_1.keccak256(bytes_1.concat([result, keccak256_1.keccak256(label)])); - name = partition[2] || ""; - } - return bytes_1.hexlify(result); -} -exports.namehash = namehash; -function id(text) { - return keccak256_1.keccak256(strings_1.toUtf8Bytes(text)); -} -exports.id = id; -exports.messagePrefix = "\x19Ethereum Signed Message:\n"; -function hashMessage(message) { - if (typeof (message) === "string") { - message = strings_1.toUtf8Bytes(message); - } - return keccak256_1.keccak256(bytes_1.concat([ - strings_1.toUtf8Bytes(exports.messagePrefix), - strings_1.toUtf8Bytes(String(message.length)), - message - ])); -} -exports.hashMessage = hashMessage; - -},{"./_version":79,"@ethersproject/bytes":70,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/strings":123}],81:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "hdnode/5.0.0-beta.129"; - -},{}],82:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var basex_1 = require("@ethersproject/basex"); -var bytes_1 = require("@ethersproject/bytes"); -var bignumber_1 = require("@ethersproject/bignumber"); -var strings_1 = require("@ethersproject/strings"); -var pbkdf2_1 = require("@ethersproject/pbkdf2"); -var properties_1 = require("@ethersproject/properties"); -var signing_key_1 = require("@ethersproject/signing-key"); -var sha2_1 = require("@ethersproject/sha2"); -var transactions_1 = require("@ethersproject/transactions"); -var wordlists_1 = require("@ethersproject/wordlists"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var N = bignumber_1.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); -// "Bitcoin seed" -var MasterSecret = strings_1.toUtf8Bytes("Bitcoin seed"); -var HardenedBit = 0x80000000; -// Returns a byte with the MSB bits set -function getUpperMask(bits) { - return ((1 << bits) - 1) << (8 - bits); -} -// Returns a byte with the LSB bits set -function getLowerMask(bits) { - return (1 << bits) - 1; -} -function bytes32(value) { - return bytes_1.hexZeroPad(bytes_1.hexlify(value), 32); -} -function base58check(data) { - var checksum = bytes_1.hexDataSlice(sha2_1.sha256(sha2_1.sha256(data)), 0, 4); - return basex_1.Base58.encode(bytes_1.concat([data, checksum])); -} -var _constructorGuard = {}; -exports.defaultPath = "m/44'/60'/0'/0/0"; -var HDNode = /** @class */ (function () { - /** - * This constructor should not be called directly. - * - * Please use: - * - fromMnemonic - * - fromSeed - */ - function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, HDNode); - if (constructorGuard !== _constructorGuard) { - throw new Error("HDNode constructor cannot be called directly"); - } - if (privateKey) { - var signingKey = new signing_key_1.SigningKey(privateKey); - properties_1.defineReadOnly(this, "privateKey", signingKey.privateKey); - properties_1.defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); - } - else { - properties_1.defineReadOnly(this, "privateKey", null); - properties_1.defineReadOnly(this, "publicKey", bytes_1.hexlify(publicKey)); - } - properties_1.defineReadOnly(this, "parentFingerprint", parentFingerprint); - properties_1.defineReadOnly(this, "fingerprint", bytes_1.hexDataSlice(sha2_1.ripemd160(sha2_1.sha256(this.publicKey)), 0, 4)); - properties_1.defineReadOnly(this, "address", transactions_1.computeAddress(this.publicKey)); - properties_1.defineReadOnly(this, "chainCode", chainCode); - properties_1.defineReadOnly(this, "index", index); - properties_1.defineReadOnly(this, "depth", depth); - properties_1.defineReadOnly(this, "mnemonic", mnemonic); - properties_1.defineReadOnly(this, "path", path); - } - Object.defineProperty(HDNode.prototype, "extendedKey", { - get: function () { - // We only support the mainnet values for now, but if anyone needs - // testnet values, let me know. I believe current senitment is that - // we should always use mainnet, and use BIP-44 to derive the network - // - Mainnet: public=0x0488B21E, private=0x0488ADE4 - // - Testnet: public=0x043587CF, private=0x04358394 - if (this.depth >= 256) { - throw new Error("Depth too large!"); - } - return base58check(bytes_1.concat([ - ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"), - bytes_1.hexlify(this.depth), - this.parentFingerprint, - bytes_1.hexZeroPad(bytes_1.hexlify(this.index), 4), - this.chainCode, - ((this.privateKey != null) ? bytes_1.concat(["0x00", this.privateKey]) : this.publicKey), - ])); - }, - enumerable: true, - configurable: true - }); - HDNode.prototype.neuter = function () { - return new HDNode(_constructorGuard, null, this.publicKey, this.parentFingerprint, this.chainCode, this.index, this.depth, null, this.path); - }; - HDNode.prototype._derive = function (index) { - if (index > 0xffffffff) { - throw new Error("invalid index - " + String(index)); - } - // Base path - var path = this.path; - if (path) { - path += "/" + (index & ~HardenedBit); - } - var data = new Uint8Array(37); - if (index & HardenedBit) { - if (!this.privateKey) { - throw new Error("cannot derive child of neutered node"); - } - // Data = 0x00 || ser_256(k_par) - data.set(bytes_1.arrayify(this.privateKey), 1); - // Hardened path - if (path) { - path += "'"; - } - } - else { - // Data = ser_p(point(k_par)) - data.set(bytes_1.arrayify(this.publicKey)); - } - // Data += ser_32(i) - for (var i = 24; i >= 0; i -= 8) { - data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); - } - var I = bytes_1.arrayify(sha2_1.computeHmac(sha2_1.SupportedAlgorithms.sha512, this.chainCode, data)); - var IL = I.slice(0, 32); - var IR = I.slice(32); - // The private key - var ki = null; - // The public key - var Ki = null; - if (this.privateKey) { - ki = bytes32(bignumber_1.BigNumber.from(IL).add(this.privateKey).mod(N)); - } - else { - var ek = new signing_key_1.SigningKey(bytes_1.hexlify(IL)); - Ki = ek._addPoint(this.publicKey); - } - return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); - }; - HDNode.prototype.derivePath = function (path) { - var components = path.split("/"); - if (components.length === 0 || (components[0] === "m" && this.depth !== 0)) { - throw new Error("invalid path - " + path); - } - if (components[0] === "m") { - components.shift(); - } - var result = this; - for (var i = 0; i < components.length; i++) { - var component = components[i]; - if (component.match(/^[0-9]+'$/)) { - var index = parseInt(component.substring(0, component.length - 1)); - if (index >= HardenedBit) { - throw new Error("invalid path index - " + component); - } - result = result._derive(HardenedBit + index); - } - else if (component.match(/^[0-9]+$/)) { - var index = parseInt(component); - if (index >= HardenedBit) { - throw new Error("invalid path index - " + component); - } - result = result._derive(index); - } - else { - throw new Error("invlaid path component - " + component); - } - } - return result; - }; - HDNode._fromSeed = function (seed, mnemonic) { - var seedArray = bytes_1.arrayify(seed); - if (seedArray.length < 16 || seedArray.length > 64) { - throw new Error("invalid seed"); - } - var I = bytes_1.arrayify(sha2_1.computeHmac(sha2_1.SupportedAlgorithms.sha512, MasterSecret, seedArray)); - return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); - }; - HDNode.fromMnemonic = function (mnemonic, password, wordlist) { - // Normalize the case and spacing in the mnemonic (throws if the mnemonic is invalid) - mnemonic = entropyToMnemonic(mnemonicToEntropy(mnemonic, wordlist), wordlist); - return HDNode._fromSeed(mnemonicToSeed(mnemonic, password), mnemonic); - }; - HDNode.fromSeed = function (seed) { - return HDNode._fromSeed(seed, null); - }; - HDNode.fromExtendedKey = function (extendedKey) { - var bytes = basex_1.Base58.decode(extendedKey); - if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { - logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); - } - var depth = bytes[4]; - var parentFingerprint = bytes_1.hexlify(bytes.slice(5, 9)); - var index = parseInt(bytes_1.hexlify(bytes.slice(9, 13)).substring(2), 16); - var chainCode = bytes_1.hexlify(bytes.slice(13, 45)); - var key = bytes.slice(45, 78); - switch (bytes_1.hexlify(bytes.slice(0, 4))) { - // Public Key - case "0x0488b21e": - case "0x043587cf": - return new HDNode(_constructorGuard, null, bytes_1.hexlify(key), parentFingerprint, chainCode, index, depth, null, null); - // Private Key - case "0x0488ade4": - case "0x04358394 ": - if (key[0] !== 0) { - break; - } - return new HDNode(_constructorGuard, bytes_1.hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); - } - return logger.throwError("invalid extended key", "extendedKey", "[REDACTED]"); - }; - return HDNode; -}()); -exports.HDNode = HDNode; -function mnemonicToSeed(mnemonic, password) { - if (!password) { - password = ""; - } - var salt = strings_1.toUtf8Bytes("mnemonic" + password, strings_1.UnicodeNormalizationForm.NFKD); - return pbkdf2_1.pbkdf2(strings_1.toUtf8Bytes(mnemonic, strings_1.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); -} -exports.mnemonicToSeed = mnemonicToSeed; -function mnemonicToEntropy(mnemonic, wordlist) { - if (!wordlist) { - wordlist = wordlists_1.wordlists["en"]; - } - logger.checkNormalize(); - var words = wordlist.split(mnemonic); - if ((words.length % 3) !== 0) { - throw new Error("invalid mnemonic"); - } - var entropy = bytes_1.arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); - var offset = 0; - for (var i = 0; i < words.length; i++) { - var index = wordlist.getWordIndex(words[i].normalize("NFKD")); - if (index === -1) { - throw new Error("invalid mnemonic"); - } - for (var bit = 0; bit < 11; bit++) { - if (index & (1 << (10 - bit))) { - entropy[offset >> 3] |= (1 << (7 - (offset % 8))); - } - offset++; - } - } - var entropyBits = 32 * words.length / 3; - var checksumBits = words.length / 3; - var checksumMask = getUpperMask(checksumBits); - var checksum = bytes_1.arrayify(sha2_1.sha256(entropy.slice(0, entropyBits / 8)))[0]; - checksum &= checksumMask; - if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { - throw new Error("invalid checksum"); - } - return bytes_1.hexlify(entropy.slice(0, entropyBits / 8)); -} -exports.mnemonicToEntropy = mnemonicToEntropy; -function entropyToMnemonic(entropy, wordlist) { - entropy = bytes_1.arrayify(entropy); - if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { - throw new Error("invalid entropy"); - } - var indices = [0]; - var remainingBits = 11; - for (var i = 0; i < entropy.length; i++) { - // Consume the whole byte (with still more to go) - if (remainingBits > 8) { - indices[indices.length - 1] <<= 8; - indices[indices.length - 1] |= entropy[i]; - remainingBits -= 8; - // This byte will complete an 11-bit index - } - else { - indices[indices.length - 1] <<= remainingBits; - indices[indices.length - 1] |= entropy[i] >> (8 - remainingBits); - // Start the next word - indices.push(entropy[i] & getLowerMask(8 - remainingBits)); - remainingBits += 3; - } - } - // Compute the checksum bits - var checksum = bytes_1.arrayify(sha2_1.sha256(entropy))[0]; - var checksumBits = entropy.length / 4; - checksum &= getUpperMask(checksumBits); - // Shift the checksum into the word indices - indices[indices.length - 1] <<= checksumBits; - indices[indices.length - 1] |= (checksum >> (8 - checksumBits)); - if (!wordlist) { - wordlist = wordlists_1.wordlists["en"]; - } - return wordlist.join(indices.map(function (index) { return wordlist.getWord(index); })); -} -exports.entropyToMnemonic = entropyToMnemonic; -function isValidMnemonic(mnemonic, wordlist) { - try { - mnemonicToEntropy(mnemonic, wordlist); - return true; - } - catch (error) { } - return false; -} -exports.isValidMnemonic = isValidMnemonic; - -},{"./_version":81,"@ethersproject/basex":64,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/pbkdf2":94,"@ethersproject/properties":96,"@ethersproject/sha2":116,"@ethersproject/signing-key":118,"@ethersproject/strings":123,"@ethersproject/transactions":126,"@ethersproject/wordlists":134}],83:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "json-wallets/5.0.0-beta.128"; - -},{}],84:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var aes_js_1 = __importDefault(require("aes-js")); -var address_1 = require("@ethersproject/address"); -var bytes_1 = require("@ethersproject/bytes"); -var keccak256_1 = require("@ethersproject/keccak256"); -var pbkdf2_1 = require("@ethersproject/pbkdf2"); -var strings_1 = require("@ethersproject/strings"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var utils_1 = require("./utils"); -var CrowdsaleAccount = /** @class */ (function (_super) { - __extends(CrowdsaleAccount, _super); - function CrowdsaleAccount() { - return _super !== null && _super.apply(this, arguments) || this; - } - CrowdsaleAccount.prototype.isCrowdsaleAccount = function (value) { - return !!(value && value._isCrowdsaleAccount); - }; - return CrowdsaleAccount; -}(properties_1.Description)); -exports.CrowdsaleAccount = CrowdsaleAccount; -// See: https://github.com/ethereum/pyethsaletool -function decrypt(json, password) { - var data = JSON.parse(json); - password = utils_1.getPassword(password); - // Ethereum Address - var ethaddr = address_1.getAddress(utils_1.searchPath(data, "ethaddr")); - // Encrypted Seed - var encseed = utils_1.looseArrayify(utils_1.searchPath(data, "encseed")); - if (!encseed || (encseed.length % 16) !== 0) { - logger.throwArgumentError("invalid encseed", "json", json); - } - var key = bytes_1.arrayify(pbkdf2_1.pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); - var iv = encseed.slice(0, 16); - var encryptedSeed = encseed.slice(16); - // Decrypt the seed - var aesCbc = new aes_js_1.default.ModeOfOperation.cbc(key, iv); - var seed = bytes_1.arrayify(aesCbc.decrypt(encryptedSeed)); - seed = aes_js_1.default.padding.pkcs7.strip(seed); - // This wallet format is weird... Convert the binary encoded hex to a string. - var seedHex = ""; - for (var i = 0; i < seed.length; i++) { - seedHex += String.fromCharCode(seed[i]); - } - var seedHexBytes = strings_1.toUtf8Bytes(seedHex); - var privateKey = keccak256_1.keccak256(seedHexBytes); - return new CrowdsaleAccount({ - _isCrowdsaleAccount: true, - address: ethaddr, - privateKey: privateKey - }); -} -exports.decrypt = decrypt; - -},{"./_version":83,"./utils":88,"@ethersproject/address":62,"@ethersproject/bytes":70,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/pbkdf2":94,"@ethersproject/properties":96,"@ethersproject/strings":123,"aes-js":1}],85:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var crowdsale_1 = require("./crowdsale"); -exports.decryptCrowdsale = crowdsale_1.decrypt; -var inspect_1 = require("./inspect"); -exports.getJsonWalletAddress = inspect_1.getJsonWalletAddress; -exports.isCrowdsaleWallet = inspect_1.isCrowdsaleWallet; -exports.isKeystoreWallet = inspect_1.isKeystoreWallet; -var keystore_1 = require("./keystore"); -exports.decryptKeystore = keystore_1.decrypt; -exports.encryptKeystore = keystore_1.encrypt; -function decryptJsonWallet(json, password, progressCallback) { - if (inspect_1.isCrowdsaleWallet(json)) { - if (progressCallback) { - progressCallback(0); - } - var account = crowdsale_1.decrypt(json, password); - if (progressCallback) { - progressCallback(1); - } - return Promise.resolve(account); - } - if (inspect_1.isKeystoreWallet(json)) { - return keystore_1.decrypt(json, password, progressCallback); - } - return Promise.reject(new Error("invalid JSON wallet")); -} -exports.decryptJsonWallet = decryptJsonWallet; - -},{"./crowdsale":84,"./inspect":86,"./keystore":87}],86:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var address_1 = require("@ethersproject/address"); -function isCrowdsaleWallet(json) { - var data = null; - try { - data = JSON.parse(json); - } - catch (error) { - return false; - } - return (data.encseed && data.ethaddr); -} -exports.isCrowdsaleWallet = isCrowdsaleWallet; -function isKeystoreWallet(json) { - var data = null; - try { - data = JSON.parse(json); - } - catch (error) { - return false; - } - if (!data.version || parseInt(data.version) !== data.version || parseInt(data.version) !== 3) { - return false; - } - // @TODO: Put more checks to make sure it has kdf, iv and all that good stuff - return true; -} -exports.isKeystoreWallet = isKeystoreWallet; -//export function isJsonWallet(json: string): boolean { -// return (isSecretStorageWallet(json) || isCrowdsaleWallet(json)); -//} -function getJsonWalletAddress(json) { - if (isCrowdsaleWallet(json)) { - try { - return address_1.getAddress(JSON.parse(json).ethaddr); - } - catch (error) { - return null; - } - } - if (isKeystoreWallet(json)) { - try { - return address_1.getAddress(JSON.parse(json).address); - } - catch (error) { - return null; - } - } - return null; -} -exports.getJsonWalletAddress = getJsonWalletAddress; - -},{"@ethersproject/address":62}],87:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var aes_js_1 = __importDefault(require("aes-js")); -var scrypt_js_1 = __importDefault(require("scrypt-js")); -var uuid_1 = __importDefault(require("uuid")); -var address_1 = require("@ethersproject/address"); -var bytes_1 = require("@ethersproject/bytes"); -var hdnode_1 = require("@ethersproject/hdnode"); -var keccak256_1 = require("@ethersproject/keccak256"); -var pbkdf2_1 = require("@ethersproject/pbkdf2"); -var random_1 = require("@ethersproject/random"); -var properties_1 = require("@ethersproject/properties"); -var transactions_1 = require("@ethersproject/transactions"); -var utils_1 = require("./utils"); -// Exported Types -var KeystoreAccount = /** @class */ (function (_super) { - __extends(KeystoreAccount, _super); - function KeystoreAccount() { - return _super !== null && _super.apply(this, arguments) || this; - } - KeystoreAccount.prototype.isKeystoreAccount = function (value) { - return !!(value && value._isKeystoreAccount); - }; - return KeystoreAccount; -}(properties_1.Description)); -exports.KeystoreAccount = KeystoreAccount; -function decrypt(json, password, progressCallback) { - var data = JSON.parse(json); - var passwordBytes = utils_1.getPassword(password); - var decrypt = function (key, ciphertext) { - var cipher = utils_1.searchPath(data, "crypto/cipher"); - if (cipher === "aes-128-ctr") { - var iv = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/cipherparams/iv")); - var counter = new aes_js_1.default.Counter(iv); - var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter); - return bytes_1.arrayify(aesCtr.decrypt(ciphertext)); - } - return null; - }; - var computeMAC = function (derivedHalf, ciphertext) { - return keccak256_1.keccak256(bytes_1.concat([derivedHalf, ciphertext])); - }; - var getAccount = function (key, reject) { - var ciphertext = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/ciphertext")); - var computedMAC = bytes_1.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); - if (computedMAC !== utils_1.searchPath(data, "crypto/mac").toLowerCase()) { - reject(new Error("invalid password")); - return null; - } - var privateKey = decrypt(key.slice(0, 16), ciphertext); - var mnemonicKey = key.slice(32, 64); - if (!privateKey) { - reject(new Error("unsupported cipher")); - return null; - } - var address = transactions_1.computeAddress(privateKey); - if (data.address) { - var check = data.address.toLowerCase(); - if (check.substring(0, 2) !== "0x") { - check = "0x" + check; - } - try { - if (address_1.getAddress(check) !== address) { - reject(new Error("address mismatch")); - return null; - } - } - catch (e) { } - } - var account = { - _isKeystoreAccount: true, - address: address, - privateKey: bytes_1.hexlify(privateKey) - }; - // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase - if (utils_1.searchPath(data, "x-ethers/version") === "0.1") { - var mnemonicCiphertext = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCiphertext")); - var mnemonicIv = utils_1.looseArrayify(utils_1.searchPath(data, "x-ethers/mnemonicCounter")); - var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); - var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); - var path = utils_1.searchPath(data, "x-ethers/path") || hdnode_1.defaultPath; - var entropy = bytes_1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); - var mnemonic = hdnode_1.entropyToMnemonic(entropy); - var node = hdnode_1.HDNode.fromMnemonic(mnemonic).derivePath(path); - if (node.privateKey != account.privateKey) { - reject(new Error("mnemonic mismatch")); - return null; - } - account.mnemonic = node.mnemonic; - account.path = node.path; - } - return new KeystoreAccount(account); - }; - return new Promise(function (resolve, reject) { - var kdf = utils_1.searchPath(data, "crypto/kdf"); - if (kdf && typeof (kdf) === "string") { - if (kdf.toLowerCase() === "scrypt") { - var salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt")); - var N = parseInt(utils_1.searchPath(data, "crypto/kdfparams/n")); - var r = parseInt(utils_1.searchPath(data, "crypto/kdfparams/r")); - var p = parseInt(utils_1.searchPath(data, "crypto/kdfparams/p")); - if (!N || !r || !p) { - reject(new Error("unsupported key-derivation function parameters")); - return; - } - // Make sure N is a power of 2 - if ((N & (N - 1)) !== 0) { - reject(new Error("unsupported key-derivation function parameter value for N")); - return; - } - var dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen")); - if (dkLen !== 32) { - reject(new Error("unsupported key-derivation derived-key length")); - return; - } - if (progressCallback) { - progressCallback(0); - } - scrypt_js_1.default(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { - if (error) { - error.progress = progress; - reject(error); - } - else if (key) { - key = bytes_1.arrayify(key); - var account = getAccount(key, reject); - if (!account) { - return; - } - if (progressCallback) { - progressCallback(1); - } - resolve(account); - } - else if (progressCallback) { - return progressCallback(progress); - } - }); - } - else if (kdf.toLowerCase() === "pbkdf2") { - var salt = utils_1.looseArrayify(utils_1.searchPath(data, "crypto/kdfparams/salt")); - var prfFunc = null; - var prf = utils_1.searchPath(data, "crypto/kdfparams/prf"); - if (prf === "hmac-sha256") { - prfFunc = "sha256"; - } - else if (prf === "hmac-sha512") { - prfFunc = "sha512"; - } - else { - reject(new Error("unsupported prf")); - return; - } - var c = parseInt(utils_1.searchPath(data, "crypto/kdfparams/c")); - var dkLen = parseInt(utils_1.searchPath(data, "crypto/kdfparams/dklen")); - if (dkLen !== 32) { - reject(new Error("unsupported key-derivation derived-key length")); - return; - } - var key = bytes_1.arrayify(pbkdf2_1.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); - var account = getAccount(key, reject); - if (!account) { - return; - } - resolve(account); - } - else { - reject(new Error("unsupported key-derivation function")); - } - } - else { - reject(new Error("unsupported key-derivation function")); - } - }); -} -exports.decrypt = decrypt; -function encrypt(account, password, options, progressCallback) { - try { - if (address_1.getAddress(account.address) !== transactions_1.computeAddress(account.privateKey)) { - throw new Error("address/privateKey mismatch"); - } - if (account.mnemonic != null) { - var node = hdnode_1.HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || hdnode_1.defaultPath); - if (node.privateKey != account.privateKey) { - throw new Error("mnemonic mismatch"); - } - } - else if (account.path != null) { - throw new Error("cannot specify path without mnemonic"); - } - } - catch (e) { - return Promise.reject(e); - } - // the options are optional, so adjust the call as needed - if (typeof (options) === "function" && !progressCallback) { - progressCallback = options; - options = {}; - } - if (!options) { - options = {}; - } - var privateKey = bytes_1.arrayify(account.privateKey); - var passwordBytes = utils_1.getPassword(password); - var entropy = null; - var path = account.path; - if (account.mnemonic) { - entropy = bytes_1.arrayify(hdnode_1.mnemonicToEntropy(account.mnemonic)); - if (!path) { - path = hdnode_1.defaultPath; - } - } - var client = options.client; - if (!client) { - client = "ethers.js"; - } - // Check/generate the salt - var salt = null; - if (options.salt) { - salt = bytes_1.arrayify(options.salt); - } - else { - salt = random_1.randomBytes(32); - ; - } - // Override initialization vector - var iv = null; - if (options.iv) { - iv = bytes_1.arrayify(options.iv); - if (iv.length !== 16) { - throw new Error("invalid iv"); - } - } - else { - iv = random_1.randomBytes(16); - } - // Override the uuid - var uuidRandom = null; - if (options.uuid) { - uuidRandom = bytes_1.arrayify(options.uuid); - if (uuidRandom.length !== 16) { - throw new Error("invalid uuid"); - } - } - else { - uuidRandom = random_1.randomBytes(16); - } - // Override the scrypt password-based key derivation function parameters - var N = (1 << 17), r = 8, p = 1; - if (options.scrypt) { - if (options.scrypt.N) { - N = options.scrypt.N; - } - if (options.scrypt.r) { - r = options.scrypt.r; - } - if (options.scrypt.p) { - p = options.scrypt.p; - } - } - return new Promise(function (resolve, reject) { - if (progressCallback) { - progressCallback(0); - } - // We take 64 bytes: - // - 32 bytes As normal for the Web3 secret storage (derivedKey, macPrefix) - // - 32 bytes AES key to encrypt mnemonic with (required here to be Ethers Wallet) - scrypt_js_1.default(passwordBytes, salt, N, r, p, 64, function (error, progress, key) { - if (error) { - error.progress = progress; - reject(error); - } - else if (key) { - key = bytes_1.arrayify(key); - // This will be used to encrypt the wallet (as per Web3 secret storage) - var derivedKey = key.slice(0, 16); - var macPrefix = key.slice(16, 32); - // This will be used to encrypt the mnemonic phrase (if any) - var mnemonicKey = key.slice(32, 64); - // Encrypt the private key - var counter = new aes_js_1.default.Counter(iv); - var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(derivedKey, counter); - var ciphertext = bytes_1.arrayify(aesCtr.encrypt(privateKey)); - // Compute the message authentication code, used to check the password - var mac = keccak256_1.keccak256(bytes_1.concat([macPrefix, ciphertext])); - // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition - var data = { - address: account.address.substring(2).toLowerCase(), - id: uuid_1.default.v4({ random: uuidRandom }), - version: 3, - Crypto: { - cipher: "aes-128-ctr", - cipherparams: { - iv: bytes_1.hexlify(iv).substring(2), - }, - ciphertext: bytes_1.hexlify(ciphertext).substring(2), - kdf: "scrypt", - kdfparams: { - salt: bytes_1.hexlify(salt).substring(2), - n: N, - dklen: 32, - p: p, - r: r - }, - mac: mac.substring(2) - } - }; - // If we have a mnemonic, encrypt it into the JSON wallet - if (entropy) { - var mnemonicIv = random_1.randomBytes(16); - var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); - var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); - var mnemonicCiphertext = bytes_1.arrayify(mnemonicAesCtr.encrypt(entropy)); - var now = new Date(); - var timestamp = (now.getUTCFullYear() + "-" + - utils_1.zpad(now.getUTCMonth() + 1, 2) + "-" + - utils_1.zpad(now.getUTCDate(), 2) + "T" + - utils_1.zpad(now.getUTCHours(), 2) + "-" + - utils_1.zpad(now.getUTCMinutes(), 2) + "-" + - utils_1.zpad(now.getUTCSeconds(), 2) + ".0Z"); - data["x-ethers"] = { - client: client, - gethFilename: ("UTC--" + timestamp + "--" + data.address), - mnemonicCounter: bytes_1.hexlify(mnemonicIv).substring(2), - mnemonicCiphertext: bytes_1.hexlify(mnemonicCiphertext).substring(2), - path: path, - version: "0.1" - }; - } - if (progressCallback) { - progressCallback(1); - } - resolve(JSON.stringify(data)); - } - else if (progressCallback) { - return progressCallback(progress); - } - }); - }); -} -exports.encrypt = encrypt; - -},{"./utils":88,"@ethersproject/address":62,"@ethersproject/bytes":70,"@ethersproject/hdnode":82,"@ethersproject/keccak256":89,"@ethersproject/pbkdf2":94,"@ethersproject/properties":96,"@ethersproject/random":112,"@ethersproject/transactions":126,"aes-js":1,"scrypt-js":37,"uuid":40}],88:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -//import { Description } from "@ethersproject/properties"; -var strings_1 = require("@ethersproject/strings"); -/* -export class Account extends Description implements ExternallyOwnedAccount { - readonly address: string; - readonly privateKey: string; - readonly mnemonic?: string; - readonly path?: string; - -// static isAccount(value: any): value is Account { -// return Description._isType(value); -// } -} -//defineReadOnly(Account, "name", "Account"); -*/ -function looseArrayify(hexString) { - if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') { - hexString = '0x' + hexString; - } - return bytes_1.arrayify(hexString); -} -exports.looseArrayify = looseArrayify; -function zpad(value, length) { - value = String(value); - while (value.length < length) { - value = '0' + value; - } - return value; -} -exports.zpad = zpad; -function getPassword(password) { - if (typeof (password) === 'string') { - return strings_1.toUtf8Bytes(password, strings_1.UnicodeNormalizationForm.NFKC); - } - return bytes_1.arrayify(password); -} -exports.getPassword = getPassword; -function searchPath(object, path) { - var currentChild = object; - var comps = path.toLowerCase().split('/'); - for (var i = 0; i < comps.length; i++) { - // Search for a child object with a case-insensitive matching key - var matchingChild = null; - for (var key in currentChild) { - if (key.toLowerCase() === comps[i]) { - matchingChild = currentChild[key]; - break; - } - } - // Didn't find one. :'( - if (matchingChild === null) { - return null; - } - // Now check this child... - currentChild = matchingChild; - } - return currentChild; -} -exports.searchPath = searchPath; - -},{"@ethersproject/bytes":70,"@ethersproject/strings":123}],89:[function(require,module,exports){ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var js_sha3_1 = __importDefault(require("js-sha3")); -var bytes_1 = require("@ethersproject/bytes"); -function keccak256(data) { - return '0x' + js_sha3_1.default.keccak_256(bytes_1.arrayify(data)); -} -exports.keccak256 = keccak256; - -},{"@ethersproject/bytes":70,"js-sha3":34}],90:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "logger/5.0.0-beta.128"; - -},{}],91:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var _permanentCensorErrors = false; -var _censorErrors = false; -var LogLevels = { debug: 1, "default": 2, info: 2, warn: 3, error: 4, off: 5 }; -var LogLevel = LogLevels["default"]; -var _version_1 = require("./_version"); -var _globalLogger = null; -function _checkNormalize() { - try { - var missing_1 = []; - // Make sure all forms of normalization are supported - ["NFD", "NFC", "NFKD", "NFKC"].forEach(function (form) { - try { - if ("test".normalize(form) !== "test") { - throw new Error("bad normalize"); - } - ; - } - catch (error) { - missing_1.push(form); - } - }); - if (missing_1.length) { - throw new Error("missing " + missing_1.join(", ")); - } - if (String.fromCharCode(0xe9).normalize("NFD") !== String.fromCharCode(0x65, 0x0301)) { - throw new Error("broken implementation"); - } - } - catch (error) { - return error.message; - } - return null; -} -var _normalizeError = _checkNormalize(); -var Logger = /** @class */ (function () { - function Logger(version) { - Object.defineProperty(this, "version", { - enumerable: true, - value: version, - writable: false - }); - } - Logger.prototype.setLogLevel = function (logLevel) { - var level = LogLevels[logLevel]; - if (level == null) { - this.warn("invliad log level - " + logLevel); - return; - } - LogLevel = level; - }; - Logger.prototype._log = function (logLevel, args) { - if (LogLevel > LogLevels[logLevel]) { - return; - } - console.log.apply(console, args); - }; - Logger.prototype.debug = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger.levels.DEBUG, args); - }; - Logger.prototype.info = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger.levels.INFO, args); - }; - Logger.prototype.warn = function () { - var args = []; - for (var _i = 0; _i < arguments.length; _i++) { - args[_i] = arguments[_i]; - } - this._log(Logger.levels.WARNING, args); - }; - Logger.prototype.makeError = function (message, code, params) { - if (_censorErrors) { - return new Error("unknown error"); - } - if (!code) { - code = Logger.errors.UNKNOWN_ERROR; - } - if (!params) { - params = {}; - } - var messageDetails = []; - Object.keys(params).forEach(function (key) { - try { - messageDetails.push(key + "=" + JSON.stringify(params[key])); - } - catch (error) { - messageDetails.push(key + "=" + JSON.stringify(params[key].toString())); - } - }); - messageDetails.push("version=" + this.version); - var reason = message; - if (messageDetails.length) { - message += " (" + messageDetails.join(", ") + ")"; - } - // @TODO: Any?? - var error = new Error(message); - error.reason = reason; - error.code = code; - Object.keys(params).forEach(function (key) { - error[key] = params[key]; - }); - return error; - }; - Logger.prototype.throwError = function (message, code, params) { - throw this.makeError(message, code, params); - }; - Logger.prototype.throwArgumentError = function (message, name, value) { - return this.throwError(message, Logger.errors.INVALID_ARGUMENT, { - argument: name, - value: value - }); - }; - Logger.prototype.checkNormalize = function (message) { - if (message == null) { - message = "platform missing String.prototype.normalize"; - } - if (_normalizeError) { - this.throwError("platform missing String.prototype.normalize", Logger.errors.UNSUPPORTED_OPERATION, { - operation: "String.prototype.normalize", form: _normalizeError - }); - } - }; - Logger.prototype.checkSafeUint53 = function (value, message) { - if (typeof (value) !== "number") { - return; - } - if (message == null) { - message = "value not safe"; - } - if (value < 0 || value >= 0x1fffffffffffff) { - this.throwError(message, Logger.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "out-of-safe-range", - value: value - }); - } - if (value % 1) { - this.throwError(message, Logger.errors.NUMERIC_FAULT, { - operation: "checkSafeInteger", - fault: "non-integer", - value: value - }); - } - }; - Logger.prototype.checkArgumentCount = function (count, expectedCount, message) { - if (message) { - message = ": " + message; - } - else { - message = ""; - } - if (count < expectedCount) { - this.throwError("missing argument" + message, Logger.errors.MISSING_ARGUMENT, { - count: count, - expectedCount: expectedCount - }); - } - if (count > expectedCount) { - this.throwError("too many arguments" + message, Logger.errors.UNEXPECTED_ARGUMENT, { - count: count, - expectedCount: expectedCount - }); - } - }; - Logger.prototype.checkNew = function (target, kind) { - if (target === Object || target == null) { - this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); - } - }; - Logger.prototype.checkAbstract = function (target, kind) { - if (target === kind) { - this.throwError("cannot instantiate abstract class " + JSON.stringify(kind.name) + " directly; use a sub-class", Logger.errors.UNSUPPORTED_OPERATION, { name: target.name, operation: "new" }); - } - else if (target === Object || target == null) { - this.throwError("missing new", Logger.errors.MISSING_NEW, { name: kind.name }); - } - }; - Logger.globalLogger = function () { - if (!_globalLogger) { - _globalLogger = new Logger(_version_1.version); - } - return _globalLogger; - }; - Logger.setCensorship = function (censorship, permanent) { - if (_permanentCensorErrors) { - if (!censorship) { - return; - } - this.globalLogger().throwError("error censorship permanent", Logger.errors.UNSUPPORTED_OPERATION, { - operation: "setCensorship" - }); - } - _censorErrors = !!censorship; - _permanentCensorErrors = !!permanent; - }; - Logger.errors = { - /////////////////// - // Generic Errors - // Unknown Error - UNKNOWN_ERROR: "UNKNOWN_ERROR", - // Not Implemented - NOT_IMPLEMENTED: "NOT_IMPLEMENTED", - // Unsupported Operation - // - operation - UNSUPPORTED_OPERATION: "UNSUPPORTED_OPERATION", - // Network Error (i.e. Ethereum Network, such as an invalid chain ID) - NETWORK_ERROR: "NETWORK_ERROR", - // Some sort of bad response from the server - SERVER_ERROR: "SERVER_ERROR", - // Timeout - TIMEOUT: "TIMEOUT", - /////////////////// - // Operational Errors - // Buffer Overrun - BUFFER_OVERRUN: "BUFFER_OVERRUN", - // Numeric Fault - // - operation: the operation being executed - // - fault: the reason this faulted - NUMERIC_FAULT: "NUMERIC_FAULT", - /////////////////// - // Argument Errors - // Missing new operator to an object - // - name: The name of the class - MISSING_NEW: "MISSING_NEW", - // Invalid argument (e.g. value is incompatible with type) to a function: - // - argument: The argument name that was invalid - // - value: The value of the argument - INVALID_ARGUMENT: "INVALID_ARGUMENT", - // Missing argument to a function: - // - count: The number of arguments received - // - expectedCount: The number of arguments expected - MISSING_ARGUMENT: "MISSING_ARGUMENT", - // Too many arguments - // - count: The number of arguments received - // - expectedCount: The number of arguments expected - UNEXPECTED_ARGUMENT: "UNEXPECTED_ARGUMENT", - /////////////////// - // Blockchain Errors - // Call exception - // - transaction: the transaction - // - address?: the contract address - // - args?: The arguments passed into the function - // - method?: The Solidity method signature - // - errorSignature?: The EIP848 error signature - // - errorArgs?: The EIP848 error parameters - // - reason: The reason (only for EIP848 "Error(string)") - CALL_EXCEPTION: "CALL_EXCEPTION", - // Insufficien funds (< value + gasLimit * gasPrice) - // - transaction: the transaction attempted - INSUFFICIENT_FUNDS: "INSUFFICIENT_FUNDS", - // Nonce has already been used - // - transaction: the transaction attempted - NONCE_EXPIRED: "NONCE_EXPIRED", - // The replacement fee for the transaction is too low - // - transaction: the transaction attempted - REPLACEMENT_UNDERPRICED: "REPLACEMENT_UNDERPRICED", - // The gas limit could not be estimated - // - transaction: the transaction passed to estimateGas - UNPREDICTABLE_GAS_LIMIT: "UNPREDICTABLE_GAS_LIMIT", - }; - Logger.levels = { - DEBUG: "DEBUG", - INFO: "INFO", - WARNING: "WARNING", - ERROR: "ERROR", - OFF: "OFF" - }; - return Logger; -}()); -exports.Logger = Logger; - -},{"./_version":90}],92:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "networks/5.0.0-beta.128"; - -},{}],93:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -function ethDefaultProvider(network) { - return function (providers, options) { - if (options == null) { - options = {}; - } - var providerList = []; - if (providers.InfuraProvider) { - try { - providerList.push(new providers.InfuraProvider(network, options.infura)); - } - catch (error) { } - } - if (providers.EtherscanProvider) { - try { - providerList.push(new providers.EtherscanProvider(network, options.etherscan)); - } - catch (error) { } - } - if (providers.NodesmithProvider) { - try { - providerList.push(new providers.NodesmithProvider(network, options.nodesmith)); - } - catch (error) { } - } - if (providers.AlchemyProvider) { - try { - providerList.push(new providers.AlchemyProvider(network, options.alchemy)); - } - catch (error) { } - } - if (providers.CloudflareProvider) { - try { - providerList.push(new providers.CloudflareProvider(network)); - } - catch (error) { } - } - if (providerList.length === 0) { - return null; - } - if (providers.FallbackProvider) { - return new providers.FallbackProvider(providerList); - ; - } - return providerList[0]; - }; -} -function etcDefaultProvider(url, network) { - return function (providers, options) { - if (providers.JsonRpcProvider) { - return new providers.JsonRpcProvider(url, network); - } - return null; - }; -} -var homestead = { - chainId: 1, - ensAddress: "0x314159265dd8dbb310642f98f50c066173c1259b", - name: "homestead", - _defaultProvider: ethDefaultProvider("homestead") -}; -var ropsten = { - chainId: 3, - ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", - name: "ropsten", - _defaultProvider: ethDefaultProvider("ropsten") -}; -var networks = { - unspecified: { - chainId: 0, - name: "unspecified" - }, - homestead: homestead, - mainnet: homestead, - morden: { - chainId: 2, - name: "morden" - }, - ropsten: ropsten, - testnet: ropsten, - rinkeby: { - chainId: 4, - ensAddress: "0xe7410170f87102DF0055eB195163A03B7F2Bff4A", - name: "rinkeby", - _defaultProvider: ethDefaultProvider("rinkeby") - }, - kovan: { - chainId: 42, - name: "kovan", - _defaultProvider: ethDefaultProvider("kovan") - }, - goerli: { - chainId: 5, - ensAddress: "0x112234455c3a32fd11230c42e7bccd4a84e02010", - name: "goerli", - _defaultProvider: ethDefaultProvider("goerli") - }, - classic: { - chainId: 61, - name: "classic", - _defaultProvider: etcDefaultProvider("https://web3.gastracker.io", "classic") - }, - classicTestnet: { - chainId: 62, - name: "classicTestnet", - _defaultProvider: etcDefaultProvider("https://web3.gastracker.io/morden", "classicTestnet") - } -}; -/** - * getNetwork - * - * Converts a named common networks or chain ID (network ID) to a Network - * and verifies a network is a valid Network.. - */ -function getNetwork(network) { - // No network (null) - if (network == null) { - return null; - } - if (typeof (network) === "number") { - for (var name_1 in networks) { - var standard_1 = networks[name_1]; - if (standard_1.chainId === network) { - return { - name: standard_1.name, - chainId: standard_1.chainId, - ensAddress: (standard_1.ensAddress || null), - _defaultProvider: (standard_1._defaultProvider || null) - }; - } - } - return { - chainId: network, - name: "unknown" - }; - } - if (typeof (network) === "string") { - var standard_2 = networks[network]; - if (standard_2 == null) { - return null; - } - return { - name: standard_2.name, - chainId: standard_2.chainId, - ensAddress: standard_2.ensAddress, - _defaultProvider: (standard_2._defaultProvider || null) - }; - } - var standard = networks[network.name]; - // Not a standard network; check that it is a valid network in general - if (!standard) { - if (typeof (network.chainId) !== "number") { - logger.throwArgumentError("invalid network chainId", "network", network); - } - return network; - } - // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) - if (network.chainId !== 0 && network.chainId !== standard.chainId) { - logger.throwArgumentError("network chainId mismatch", "network", network); - } - // Standard Network (allow overriding the ENS address) - return { - name: network.name, - chainId: standard.chainId, - ensAddress: (network.ensAddress || standard.ensAddress || null), - _defaultProvider: (network._defaultProvider || standard._defaultProvider || null) - }; -} -exports.getNetwork = getNetwork; - -},{"./_version":92,"@ethersproject/logger":91}],94:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var sha2_1 = require("@ethersproject/sha2"); -function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { - password = bytes_1.arrayify(password); - salt = bytes_1.arrayify(salt); - var hLen; - var l = 1; - var DK = new Uint8Array(keylen); - var block1 = new Uint8Array(salt.length + 4); - block1.set(salt); - //salt.copy(block1, 0, 0, salt.length) - var r; - var T; - for (var i = 1; i <= l; i++) { - //block1.writeUInt32BE(i, salt.length) - block1[salt.length] = (i >> 24) & 0xff; - block1[salt.length + 1] = (i >> 16) & 0xff; - block1[salt.length + 2] = (i >> 8) & 0xff; - block1[salt.length + 3] = i & 0xff; - //let U = createHmac(password).update(block1).digest(); - var U = bytes_1.arrayify(sha2_1.computeHmac(hashAlgorithm, password, block1)); - if (!hLen) { - hLen = U.length; - T = new Uint8Array(hLen); - l = Math.ceil(keylen / hLen); - r = keylen - (l - 1) * hLen; - } - //U.copy(T, 0, 0, hLen) - T.set(U); - for (var j = 1; j < iterations; j++) { - //U = createHmac(password).update(U).digest(); - U = bytes_1.arrayify(sha2_1.computeHmac(hashAlgorithm, password, U)); - for (var k = 0; k < hLen; k++) - T[k] ^= U[k]; - } - var destPos = (i - 1) * hLen; - var len = (i === l ? r : hLen); - //T.copy(DK, destPos, 0, len) - DK.set(bytes_1.arrayify(T).slice(0, len), destPos); - } - return bytes_1.hexlify(DK); -} -exports.pbkdf2 = pbkdf2; - -},{"@ethersproject/bytes":70,"@ethersproject/sha2":116}],95:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "properties/5.0.0-beta.130"; - -},{}],96:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -function defineReadOnly(object, name, value) { - Object.defineProperty(object, name, { - enumerable: true, - value: value, - writable: false, - }); -} -exports.defineReadOnly = defineReadOnly; -// Crawl up the constructor chain to find a static method -function getStatic(ctor, key) { - for (var i = 0; i < 32; i++) { - if (ctor[key]) { - return ctor[key]; - } - if (!ctor.prototype || typeof (ctor.prototype) !== "object") { - break; - } - ctor = Object.getPrototypeOf(ctor.prototype).constructor; - } - return null; -} -exports.getStatic = getStatic; -function resolveProperties(object) { - var promises = Object.keys(object).map(function (key) { - var value = object[key]; - if (!(value instanceof Promise)) { - return Promise.resolve({ key: key, value: value }); - } - return value.then(function (value) { - return { key: key, value: value }; - }); - }); - return Promise.all(promises).then(function (results) { - var result = {}; - return results.reduce(function (accum, result) { - accum[result.key] = result.value; - return accum; - }, result); - }); -} -exports.resolveProperties = resolveProperties; -function checkProperties(object, properties) { - if (!object || typeof (object) !== "object") { - logger.throwArgumentError("invalid object", "object", object); - } - Object.keys(object).forEach(function (key) { - if (!properties[key]) { - logger.throwArgumentError("invalid object key - " + key, "transaction:" + key, object); - } - }); -} -exports.checkProperties = checkProperties; -function shallowCopy(object) { - var result = {}; - for (var key in object) { - result[key] = object[key]; - } - return result; -} -exports.shallowCopy = shallowCopy; -var opaque = { bigint: true, boolean: true, number: true, string: true }; -// Returns a new copy of object, such that no properties may be replaced. -// New properties may be added only to objects. -function deepCopy(object) { - // Opaque objects are not mutable, so safe to copy by assignment - if (object === undefined || object === null || opaque[typeof (object)]) { - return object; - } - // Arrays are mutable, so we need to create a copy - if (Array.isArray(object)) { - return Object.freeze(object.map(function (item) { return deepCopy(item); })); - } - if (typeof (object) === "object") { - // Immutable objects are safe to just use - if (Object.isFrozen(object)) { - return object; - } - var result = {}; - for (var key in object) { - var value = object[key]; - if (value === undefined) { - continue; - } - defineReadOnly(result, key, deepCopy(value)); - } - return result; - } - // The function type is also immutable, so safe to copy by assignment - if (typeof (object) === "function") { - return object; - } - throw new Error("Cannot deepCopy " + typeof (object)); -} -exports.deepCopy = deepCopy; -var Description = /** @class */ (function () { - function Description(info) { - for (var key in info) { - this[key] = deepCopy(info[key]); - } - Object.freeze(this); - } - return Description; -}()); -exports.Description = Description; - -},{"./_version":95,"@ethersproject/logger":91}],97:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "providers/5.0.0-beta.140"; - -},{}],98:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); -// This key was provided to ethers.js by Alchemy to be used by the -// default provider, but it is recommended that for your own -// production environments, that you acquire your own API key at: -// https://dashboard.alchemyapi.io -var defaultApiKey = "_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC"; -var AlchemyProvider = /** @class */ (function (_super) { - __extends(AlchemyProvider, _super); - function AlchemyProvider() { - return _super !== null && _super.apply(this, arguments) || this; - } - AlchemyProvider.getApiKey = function (apiKey) { - if (apiKey == null) { - return defaultApiKey; - } - return apiKey; - }; - AlchemyProvider.getUrl = function (network, apiKey) { - var host = null; - switch (network.name) { - case "homestead": - host = "eth-mainnet.alchemyapi.io/jsonrpc/"; - break; - case "ropsten": - host = "eth-ropsten.alchemyapi.io/jsonrpc/"; - break; - case "rinkeby": - host = "eth-rinkeby.alchemyapi.io/jsonrpc/"; - break; - case "kovan": - host = "eth-kovan.alchemyapi.io/jsonrpc/"; - break; - default: - logger.throwArgumentError("unsupported network", "network", arguments[0]); - } - return ("https:/" + "/" + host + apiKey); - }; - return AlchemyProvider; -}(url_json_rpc_provider_1.UrlJsonRpcProvider)); -exports.AlchemyProvider = AlchemyProvider; - -},{"./_version":97,"./url-json-rpc-provider":109,"@ethersproject/logger":91}],99:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_provider_1 = require("@ethersproject/abstract-provider"); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var hash_1 = require("@ethersproject/hash"); -var networks_1 = require("@ethersproject/networks"); -var properties_1 = require("@ethersproject/properties"); -var strings_1 = require("@ethersproject/strings"); -var web_1 = require("@ethersproject/web"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var formatter_1 = require("./formatter"); -////////////////////////////// -// Event Serializeing -function checkTopic(topic) { - if (topic == null) { - return "null"; - } - if (bytes_1.hexDataLength(topic) !== 32) { - logger.throwArgumentError("invalid topic", "topic", topic); - } - return topic.toLowerCase(); -} -function serializeTopics(topics) { - // Remove trailing null AND-topics; they are redundant - topics = topics.slice(); - while (topics[topics.length - 1] == null) { - topics.pop(); - } - return topics.map(function (topic) { - if (Array.isArray(topic)) { - // Only track unique OR-topics - var unique_1 = {}; - topic.forEach(function (topic) { - unique_1[checkTopic(topic)] = true; - }); - // The order of OR-topics does not matter - var sorted = Object.keys(unique_1); - sorted.sort(); - return sorted.join("|"); - } - else { - return checkTopic(topic); - } - }).join("&"); -} -function deserializeTopics(data) { - return data.split(/&/g).map(function (topic) { - return topic.split("|").map(function (topic) { - return ((topic === "null") ? null : topic); - }); - }); -} -function getEventTag(eventName) { - if (typeof (eventName) === "string") { - eventName = eventName.toLowerCase(); - if (bytes_1.hexDataLength(eventName) === 32) { - return "tx:" + eventName; - } - if (eventName.indexOf(":") === -1) { - return eventName; - } - } - else if (Array.isArray(eventName)) { - return "filter:*:" + serializeTopics(eventName); - } - else if (abstract_provider_1.ForkEvent.isForkEvent(eventName)) { - logger.warn("not implemented"); - throw new Error("not implemented"); - } - else if (eventName && typeof (eventName) === "object") { - return "filter:" + (eventName.address || "*") + ":" + serializeTopics(eventName.topics || []); - } - throw new Error("invalid event - " + eventName); -} -////////////////////////////// -// Helper Object -function getTime() { - return (new Date()).getTime(); -} -////////////////////////////// -// Provider Object -/** - * EventType - * - "block" - * - "pending" - * - "error" - * - filter - * - topics array - * - transaction hash - */ -var Event = /** @class */ (function () { - function Event(tag, listener, once) { - properties_1.defineReadOnly(this, "tag", tag); - properties_1.defineReadOnly(this, "listener", listener); - properties_1.defineReadOnly(this, "once", once); - } - Event.prototype.pollable = function () { - return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); - }; - return Event; -}()); -var defaultFormatter = null; -var nextPollId = 1; -var BaseProvider = /** @class */ (function (_super) { - __extends(BaseProvider, _super); - function BaseProvider(network) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, abstract_provider_1.Provider); - _this = _super.call(this) || this; - _this.formatter = _newTarget.getFormatter(); - if (network instanceof Promise) { - properties_1.defineReadOnly(_this, "ready", network.then(function (network) { - properties_1.defineReadOnly(_this, "_network", network); - return network; - })); - // Squash any "unhandled promise" errors; that do not need to be handled - _this.ready.catch(function (error) { }); - } - else { - var knownNetwork = properties_1.getStatic((_newTarget), "getNetwork")(network); - if (knownNetwork) { - properties_1.defineReadOnly(_this, "_network", knownNetwork); - properties_1.defineReadOnly(_this, "ready", Promise.resolve(_this._network)); - } - else { - logger.throwArgumentError("invalid network", "network", network); - } - } - _this._lastBlockNumber = -2; - // Events being listened to - _this._events = []; - _this._pollingInterval = 4000; - _this._emitted = { block: -2 }; - _this._fastQueryDate = 0; - return _this; - } - BaseProvider.getFormatter = function () { - if (defaultFormatter == null) { - defaultFormatter = new formatter_1.Formatter(); - } - return defaultFormatter; - }; - BaseProvider.getNetwork = function (network) { - return networks_1.getNetwork((network == null) ? "homestead" : network); - }; - BaseProvider.prototype.poll = function () { - var _this = this; - var pollId = nextPollId++; - this.emit("willPoll", pollId); - // Track all running promises, so we can trigger a post-poll once they are complete - var runners = []; - this.getBlockNumber().then(function (blockNumber) { - _this._setFastBlockNumber(blockNumber); - // If the block has not changed, meh. - if (blockNumber === _this._lastBlockNumber) { - return; - } - // First polling cycle, trigger a "block" events - if (_this._emitted.block === -2) { - _this._emitted.block = blockNumber - 1; - } - // Notify all listener for each block that has passed - for (var i = _this._emitted.block + 1; i <= blockNumber; i++) { - _this.emit("block", i); - } - // The emitted block was updated, check for obsolete events - if (_this._emitted.block !== blockNumber) { - _this._emitted.block = blockNumber; - Object.keys(_this._emitted).forEach(function (key) { - // The block event does not expire - if (key === "block") { - return; - } - // The block we were at when we emitted this event - var eventBlockNumber = _this._emitted[key]; - // We cannot garbage collect pending transactions or blocks here - // They should be garbage collected by the Provider when setting - // "pending" events - if (eventBlockNumber === "pending") { - return; - } - // Evict any transaction hashes or block hashes over 12 blocks - // old, since they should not return null anyways - if (blockNumber - eventBlockNumber > 12) { - delete _this._emitted[key]; - } - }); - } - // First polling cycle - if (_this._lastBlockNumber === -2) { - _this._lastBlockNumber = blockNumber - 1; - } - // Find all transaction hashes we are waiting on - _this._events.forEach(function (event) { - var comps = event.tag.split(":"); - switch (comps[0]) { - case "tx": { - var hash_2 = comps[1]; - var runner = _this.getTransactionReceipt(hash_2).then(function (receipt) { - if (!receipt || receipt.blockNumber == null) { - return null; - } - _this._emitted["t:" + hash_2] = receipt.blockNumber; - _this.emit(hash_2, receipt); - return null; - }).catch(function (error) { _this.emit("error", error); }); - runners.push(runner); - break; - } - case "filter": { - var topics = deserializeTopics(comps[2]); - var filter_1 = { - address: comps[1], - fromBlock: _this._lastBlockNumber + 1, - toBlock: blockNumber, - topics: topics - }; - if (!filter_1.address) { - delete filter_1.address; - } - var runner = _this.getLogs(filter_1).then(function (logs) { - if (logs.length === 0) { - return; - } - logs.forEach(function (log) { - _this._emitted["b:" + log.blockHash] = log.blockNumber; - _this._emitted["t:" + log.transactionHash] = log.blockNumber; - _this.emit(filter_1, log); - }); - return null; - }).catch(function (error) { _this.emit("error", error); }); - runners.push(runner); - break; - } - } - }); - _this._lastBlockNumber = blockNumber; - return null; - }).catch(function (error) { }); - Promise.all(runners).then(function () { - _this.emit("didPoll", pollId); - }); - }; - BaseProvider.prototype.resetEventsBlock = function (blockNumber) { - this._lastBlockNumber = blockNumber - 1; - if (this.polling) { - this.poll(); - } - }; - Object.defineProperty(BaseProvider.prototype, "network", { - get: function () { - return this._network; - }, - enumerable: true, - configurable: true - }); - BaseProvider.prototype.getNetwork = function () { - return this.ready; - }; - Object.defineProperty(BaseProvider.prototype, "blockNumber", { - get: function () { - return this._fastBlockNumber; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseProvider.prototype, "polling", { - get: function () { - return (this._poller != null); - }, - set: function (value) { - var _this = this; - setTimeout(function () { - if (value && !_this._poller) { - _this._poller = setInterval(_this.poll.bind(_this), _this.pollingInterval); - } - else if (!value && _this._poller) { - clearInterval(_this._poller); - _this._poller = null; - } - }, 0); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseProvider.prototype, "pollingInterval", { - get: function () { - return this._pollingInterval; - }, - set: function (value) { - var _this = this; - if (typeof (value) !== "number" || value <= 0 || parseInt(String(value)) != value) { - throw new Error("invalid polling interval"); - } - this._pollingInterval = value; - if (this._poller) { - clearInterval(this._poller); - this._poller = setInterval(function () { _this.poll(); }, this._pollingInterval); - } - }, - enumerable: true, - configurable: true - }); - BaseProvider.prototype._getFastBlockNumber = function () { - var _this = this; - var now = getTime(); - // Stale block number, request a newer value - if ((now - this._fastQueryDate) > 2 * this._pollingInterval) { - this._fastQueryDate = now; - this._fastBlockNumberPromise = this.getBlockNumber().then(function (blockNumber) { - if (_this._fastBlockNumber == null || blockNumber > _this._fastBlockNumber) { - _this._fastBlockNumber = blockNumber; - } - return _this._fastBlockNumber; - }); - } - return this._fastBlockNumberPromise; - }; - BaseProvider.prototype._setFastBlockNumber = function (blockNumber) { - // Older block, maybe a stale request - if (this._fastBlockNumber != null && blockNumber < this._fastBlockNumber) { - return; - } - // Update the time we updated the blocknumber - this._fastQueryDate = getTime(); - // Newer block number, use it - if (this._fastBlockNumber == null || blockNumber > this._fastBlockNumber) { - this._fastBlockNumber = blockNumber; - this._fastBlockNumberPromise = Promise.resolve(blockNumber); - } - }; - // @TODO: Add .poller which must be an event emitter with a 'start', 'stop' and 'block' event; - // this will be used once we move to the WebSocket or other alternatives to polling - BaseProvider.prototype.waitForTransaction = function (transactionHash, confirmations) { - var _this = this; - if (confirmations == null) { - confirmations = 1; - } - if (confirmations === 0) { - return this.getTransactionReceipt(transactionHash); - } - return new Promise(function (resolve) { - var handler = function (receipt) { - if (receipt.confirmations < confirmations) { - return; - } - _this.removeListener(transactionHash, handler); - resolve(receipt); - }; - _this.on(transactionHash, handler); - }); - }; - BaseProvider.prototype._runPerform = function (method, params) { - var _this = this; - return this.ready.then(function () { - // Execute all the functions now that we are "ready" - Object.keys(params).forEach(function (key) { - params[key] = params[key](); - }); - return properties_1.resolveProperties(params).then(function (params) { - return _this.perform(method, params); - }); - }); - }; - BaseProvider.prototype.getBlockNumber = function () { - var _this = this; - return this._runPerform("getBlockNumber", {}).then(function (result) { - var value = parseInt(result); - if (value != result) { - throw new Error("invalid response - getBlockNumber"); - } - _this._setFastBlockNumber(value); - return value; - }); - }; - BaseProvider.prototype.getGasPrice = function () { - return this._runPerform("getGasPrice", {}).then(function (result) { - return bignumber_1.BigNumber.from(result); - }); - }; - BaseProvider.prototype.getBalance = function (addressOrName, blockTag) { - var _this = this; - return this._runPerform("getBalance", { - address: function () { return _this._getAddress(addressOrName); }, - blockTag: function () { return _this._getBlockTag(blockTag); } - }).then(function (result) { - return bignumber_1.BigNumber.from(result); - }); - }; - BaseProvider.prototype.getTransactionCount = function (addressOrName, blockTag) { - var _this = this; - return this._runPerform("getTransactionCount", { - address: function () { return _this._getAddress(addressOrName); }, - blockTag: function () { return _this._getBlockTag(blockTag); } - }).then(function (result) { - return bignumber_1.BigNumber.from(result).toNumber(); - }); - }; - BaseProvider.prototype.getCode = function (addressOrName, blockTag) { - var _this = this; - return this._runPerform("getCode", { - address: function () { return _this._getAddress(addressOrName); }, - blockTag: function () { return _this._getBlockTag(blockTag); } - }).then(function (result) { - return bytes_1.hexlify(result); - }); - }; - BaseProvider.prototype.getStorageAt = function (addressOrName, position, blockTag) { - var _this = this; - return this._runPerform("getStorageAt", { - address: function () { return _this._getAddress(addressOrName); }, - blockTag: function () { return _this._getBlockTag(blockTag); }, - position: function () { return Promise.resolve(position).then(function (p) { return bytes_1.hexValue(p); }); } - }).then(function (result) { - return bytes_1.hexlify(result); - }); - }; - // This should be called by any subclass wrapping a TransactionResponse - BaseProvider.prototype._wrapTransaction = function (tx, hash) { - var _this = this; - if (hash != null && bytes_1.hexDataLength(hash) !== 32) { - throw new Error("invalid response - sendTransaction"); - } - var result = tx; - // Check the hash we expect is the same as the hash the server reported - if (hash != null && tx.hash !== hash) { - logger.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger_1.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); - } - // @TODO: (confirmations? number, timeout? number) - result.wait = function (confirmations) { - // We know this transaction *must* exist (whether it gets mined is - // another story), so setting an emitted value forces us to - // wait even if the node returns null for the receipt - if (confirmations !== 0) { - _this._emitted["t:" + tx.hash] = "pending"; - } - return _this.waitForTransaction(tx.hash, confirmations).then(function (receipt) { - if (receipt == null && confirmations === 0) { - return null; - } - // No longer pending, allow the polling loop to garbage collect this - _this._emitted["t:" + tx.hash] = receipt.blockNumber; - if (receipt.status === 0) { - logger.throwError("transaction failed", logger_1.Logger.errors.CALL_EXCEPTION, { - transactionHash: tx.hash, - transaction: tx, - receipt: receipt - }); - } - return receipt; - }); - }; - return result; - }; - BaseProvider.prototype.sendTransaction = function (signedTransaction) { - var _this = this; - return this._runPerform("sendTransaction", { - signedTransaction: function () { return Promise.resolve(signedTransaction).then(function (t) { return bytes_1.hexlify(t); }); } - }).then(function (result) { - return _this._wrapTransaction(_this.formatter.transaction(signedTransaction), result); - }, function (error) { - error.transaction = _this.formatter.transaction(signedTransaction); - if (error.transaction.hash) { - error.transactionHash = error.transaction.hash; - } - throw error; - }); - }; - BaseProvider.prototype._getTransactionRequest = function (transaction) { - var _this = this; - return Promise.resolve(transaction).then(function (t) { - var tx = {}; - ["from", "to"].forEach(function (key) { - if (t[key] == null) { - return; - } - tx[key] = Promise.resolve(t[key]).then(function (a) { return (a ? _this._getAddress(a) : null); }); - }); - ["data", "gasLimit", "gasPrice", "value"].forEach(function (key) { - if (t[key] == null) { - return; - } - tx[key] = t[key]; - }); - return properties_1.resolveProperties(tx).then(function (t) { return _this.formatter.transactionRequest(t); }); - }); - }; - BaseProvider.prototype._getFilter = function (filter) { - var _this = this; - return Promise.resolve(filter).then(function (f) { - var filter = {}; - if (f.address != null) { - filter.address = _this._getAddress(f.address); - } - if (f.topics) { - filter.topics = f.topics; - } - if (f.blockHash != null) { - filter.blockHash = f.blockHash; - } - ["fromBlock", "toBlock"].forEach(function (key) { - if (f[key] == null) { - return; - } - filter[key] = _this._getBlockTag(f[key]); - }); - return properties_1.resolveProperties(filter).then(function (f) { return _this.formatter.filter(f); }); - }); - }; - BaseProvider.prototype.call = function (transaction, blockTag) { - var _this = this; - return this._runPerform("call", { - transaction: function () { return _this._getTransactionRequest(transaction); }, - blockTag: function () { return _this._getBlockTag(blockTag); } - }).then(function (result) { - return bytes_1.hexlify(result); - }); - }; - BaseProvider.prototype.estimateGas = function (transaction) { - var _this = this; - return this._runPerform("estimateGas", { - transaction: function () { return _this._getTransactionRequest(transaction); } - }).then(function (result) { - return bignumber_1.BigNumber.from(result); - }); - }; - BaseProvider.prototype._getAddress = function (addressOrName) { - return this.resolveName(addressOrName).then(function (address) { - if (address == null) { - logger.throwError("ENS name not configured", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "resolveName(" + JSON.stringify(addressOrName) + ")" - }); - } - return address; - }); - }; - BaseProvider.prototype._getBlock = function (blockHashOrBlockTag, includeTransactions) { - var _this = this; - return this.ready.then(function () { - return _this._getBlockTag(blockHashOrBlockTag).then(function (blockHashOrBlockTag) { - var params = { - includeTransactions: !!includeTransactions - }; - // Exactly one of blockHash or blockTag will be set - var blockHash = null; - var blockTag = null; - // If blockTag is a number (not "latest", etc), this is the block number - var blockNumber = -128; - if (bytes_1.isHexString(blockHashOrBlockTag, 32)) { - params.blockHash = blockHashOrBlockTag; - } - else { - try { - params.blockTag = _this.formatter.blockTag(blockHashOrBlockTag); - if (bytes_1.isHexString(params.blockTag)) { - blockNumber = parseInt(params.blockTag.substring(2), 16); - } - } - catch (error) { - logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); - } - } - return web_1.poll(function () { - return _this.perform("getBlock", params).then(function (block) { - // Block was not found - if (block == null) { - // For blockhashes, if we didn't say it existed, that blockhash may - // not exist. If we did see it though, perhaps from a log, we know - // it exists, and this node is just not caught up yet. - if (blockHash) { - if (_this._emitted["b:" + blockHash] == null) { - return null; - } - } - // For block tags, if we are asking for a future block, we return null - if (blockTag) { - if (blockNumber > _this._emitted.block) { - return null; - } - } - // Retry on the next block - return undefined; - } - // Add transactions - if (includeTransactions) { - return _this.formatter.blockWithTransactions(block); - } - return _this.formatter.block(block); - }); - }, { onceBlock: _this }); - }); - }); - }; - BaseProvider.prototype.getBlock = function (blockHashOrBlockTag) { - return (this._getBlock(blockHashOrBlockTag, false)); - }; - BaseProvider.prototype.getBlockWithTransactions = function (blockHashOrBlockTag) { - return (this._getBlock(blockHashOrBlockTag, true)); - }; - BaseProvider.prototype.getTransaction = function (transactionHash) { - var _this = this; - return this.ready.then(function () { - return properties_1.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { - var transactionHash = _a.transactionHash; - var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; - return web_1.poll(function () { - return _this.perform("getTransaction", params).then(function (result) { - if (result == null) { - if (_this._emitted["t:" + transactionHash] == null) { - return null; - } - return undefined; - } - var tx = _this.formatter.transactionResponse(result); - if (tx.blockNumber == null) { - tx.confirmations = 0; - } - else if (tx.confirmations == null) { - return _this._getFastBlockNumber().then(function (blockNumber) { - // Add the confirmations using the fast block number (pessimistic) - var confirmations = (blockNumber - tx.blockNumber) + 1; - if (confirmations <= 0) { - confirmations = 1; - } - tx.confirmations = confirmations; - return _this._wrapTransaction(tx); - }); - } - return _this._wrapTransaction(tx); - }); - }, { onceBlock: _this }); - }); - }); - }; - BaseProvider.prototype.getTransactionReceipt = function (transactionHash) { - var _this = this; - return this.ready.then(function () { - return properties_1.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { - var transactionHash = _a.transactionHash; - var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; - return web_1.poll(function () { - return _this.perform("getTransactionReceipt", params).then(function (result) { - if (result == null) { - if (_this._emitted["t:" + transactionHash] == null) { - return null; - } - return undefined; - } - // "geth-etc" returns receipts before they are ready - if (result.blockHash == null) { - return undefined; - } - var receipt = _this.formatter.receipt(result); - if (receipt.blockNumber == null) { - receipt.confirmations = 0; - } - else if (receipt.confirmations == null) { - return _this._getFastBlockNumber().then(function (blockNumber) { - // Add the confirmations using the fast block number (pessimistic) - var confirmations = (blockNumber - receipt.blockNumber) + 1; - if (confirmations <= 0) { - confirmations = 1; - } - receipt.confirmations = confirmations; - return receipt; - }); - } - return receipt; - }); - }, { onceBlock: _this }); - }); - }); - }; - BaseProvider.prototype.getLogs = function (filter) { - var _this = this; - return this._runPerform("getLogs", { - filter: function () { return _this._getFilter(filter); } - }).then(function (result) { - return formatter_1.Formatter.arrayOf(_this.formatter.filterLog.bind(_this.formatter))(result); - }); - }; - BaseProvider.prototype.getEtherPrice = function () { - return this._runPerform("getEtherPrice", {}).then(function (result) { - return result; - }); - }; - BaseProvider.prototype._getBlockTag = function (blockTag) { - var _this = this; - if (blockTag instanceof Promise) { - return blockTag.then(function (b) { return _this._getBlockTag(b); }); - } - if (typeof (blockTag) === "number" && blockTag < 0) { - if (blockTag % 1) { - logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag); - } - return this._getFastBlockNumber().then(function (bn) { - bn += blockTag; - if (bn < 0) { - bn = 0; - } - return _this.formatter.blockTag(bn); - }); - } - return Promise.resolve(this.formatter.blockTag(blockTag)); - }; - BaseProvider.prototype._getResolver = function (name) { - var _this = this; - // Get the resolver from the blockchain - return this.getNetwork().then(function (network) { - // No ENS... - if (!network.ensAddress) { - logger.throwError("network does support ENS", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); - } - // keccak256("resolver(bytes32)") - var data = "0x0178b8bf" + hash_1.namehash(name).substring(2); - var transaction = { to: network.ensAddress, data: data }; - return _this.call(transaction).then(function (data) { - return _this.formatter.callAddress(data); - }); - }); - }; - BaseProvider.prototype.resolveName = function (name) { - var _this = this; - // If it is a promise, resolve it then recurse - if (name instanceof Promise) { - return name.then(function (addressOrName) { return _this.resolveName(addressOrName); }); - } - // If it is already an address, nothing to resolve - try { - return Promise.resolve(this.formatter.address(name)); - } - catch (error) { } - // Get the addr from the resovler - return this._getResolver(name).then(function (resolverAddress) { - if (!resolverAddress) { - return null; - } - // keccak256("addr(bytes32)") - var data = "0x3b3b57de" + hash_1.namehash(name).substring(2); - var transaction = { to: resolverAddress, data: data }; - return _this.call(transaction).then(function (data) { - return _this.formatter.callAddress(data); - }); - }); - }; - BaseProvider.prototype.lookupAddress = function (address) { - var _this = this; - if (address instanceof Promise) { - return address.then(function (address) { return _this.lookupAddress(address); }); - } - address = this.formatter.address(address); - var name = address.substring(2) + ".addr.reverse"; - return this._getResolver(name).then(function (resolverAddress) { - if (!resolverAddress) { - return null; - } - // keccak("name(bytes32)") - var data = "0x691f3431" + hash_1.namehash(name).substring(2); - return _this.call({ to: resolverAddress, data: data }).then(function (data) { - var bytes = bytes_1.arrayify(data); - // Strip off the dynamic string pointer (0x20) - if (bytes.length < 32 || !bignumber_1.BigNumber.from(bytes.slice(0, 32)).eq(32)) { - return null; - } - bytes = bytes.slice(32); - if (bytes.length < 32) { - return null; - } - var length = bignumber_1.BigNumber.from(bytes.slice(0, 32)).toNumber(); - bytes = bytes.slice(32); - if (length > bytes.length) { - return null; - } - var name = strings_1.toUtf8String(bytes.slice(0, length)); - // Make sure the reverse record matches the foward record - return _this.resolveName(name).then(function (addr) { - if (addr != address) { - return null; - } - return name; - }); - }); - }); - }; - BaseProvider.prototype.perform = function (method, params) { - return logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); - }; - BaseProvider.prototype._startPending = function () { - console.log("WARNING: this provider does not support pending events"); - }; - BaseProvider.prototype._stopPending = function () { - }; - // Returns true if there are events that still require polling - BaseProvider.prototype._checkPolling = function () { - this.polling = (this._events.filter(function (e) { return e.pollable(); }).length > 0); - }; - BaseProvider.prototype._addEventListener = function (eventName, listener, once) { - this._events.push(new Event(getEventTag(eventName), listener, once)); - if (eventName === "pending") { - this._startPending(); - } - // Do we still now have any events that require polling? - this._checkPolling(); - return this; - }; - BaseProvider.prototype.on = function (eventName, listener) { - return this._addEventListener(eventName, listener, false); - }; - BaseProvider.prototype.once = function (eventName, listener) { - return this._addEventListener(eventName, listener, true); - }; - BaseProvider.prototype.emit = function (eventName) { - var _this = this; - var args = []; - for (var _i = 1; _i < arguments.length; _i++) { - args[_i - 1] = arguments[_i]; - } - var result = false; - var eventTag = getEventTag(eventName); - this._events = this._events.filter(function (event) { - if (event.tag !== eventTag) { - return true; - } - setTimeout(function () { - event.listener.apply(_this, args); - }, 0); - result = true; - return !(event.once); - }); - // Do we still have any events that require polling? ("once" events remove themselves) - this._checkPolling(); - return result; - }; - BaseProvider.prototype.listenerCount = function (eventName) { - if (!eventName) { - return this._events.length; - } - var eventTag = getEventTag(eventName); - return this._events.filter(function (event) { - return (event.tag === eventTag); - }).length; - }; - BaseProvider.prototype.listeners = function (eventName) { - if (eventName == null) { - return this._events.map(function (event) { return event.listener; }); - } - var eventTag = getEventTag(eventName); - return this._events - .filter(function (event) { return (event.tag === eventTag); }) - .map(function (event) { return event.listener; }); - }; - BaseProvider.prototype.off = function (eventName, listener) { - if (listener == null) { - return this.removeAllListeners(eventName); - } - var found = false; - var eventTag = getEventTag(eventName); - this._events = this._events.filter(function (event) { - if (event.tag !== eventTag || event.listener != listener) { - return true; - } - if (found) { - return true; - } - found = true; - return false; - }); - if (eventName === "pending" && this.listenerCount("pending") === 0) { - this._stopPending(); - } - // Do we still have any events that require polling? - this._checkPolling(); - return this; - }; - BaseProvider.prototype.removeAllListeners = function (eventName) { - if (eventName == null) { - this._events = []; - this._stopPending(); - } - else { - var eventTag_1 = getEventTag(eventName); - this._events = this._events.filter(function (event) { - return (event.tag !== eventTag_1); - }); - if (eventName === "pending") { - this._stopPending(); - } - } - // Do we still have any events that require polling? - this._checkPolling(); - return this; - }; - return BaseProvider; -}(abstract_provider_1.Provider)); -exports.BaseProvider = BaseProvider; - -},{"./_version":97,"./formatter":104,"@ethersproject/abstract-provider":58,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/hash":80,"@ethersproject/logger":91,"@ethersproject/networks":93,"@ethersproject/properties":96,"@ethersproject/strings":123,"@ethersproject/web":132}],100:[function(require,module,exports){ -"use strict"; -module.exports.IpcProvider = null; - -},{}],101:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var CloudflareProvider = /** @class */ (function (_super) { - __extends(CloudflareProvider, _super); - function CloudflareProvider() { - return _super !== null && _super.apply(this, arguments) || this; - } - CloudflareProvider.getUrl = function (network, apiKey) { - if (apiKey != null) { - logger.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); - } - var host = null; - switch (network.name) { - case "homestead": - host = "https://cloudflare-eth.com/"; - break; - default: - logger.throwArgumentError("unsupported network", "network", arguments[0]); - } - return host; - }; - return CloudflareProvider; -}(url_json_rpc_provider_1.UrlJsonRpcProvider)); -exports.CloudflareProvider = CloudflareProvider; - -},{"./_version":97,"./url-json-rpc-provider":109,"@ethersproject/logger":91}],102:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var properties_1 = require("@ethersproject/properties"); -var web_1 = require("@ethersproject/web"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var base_provider_1 = require("./base-provider"); -// The transaction has already been sanitized by the calls in Provider -function getTransactionString(transaction) { - var result = []; - for (var key in transaction) { - if (transaction[key] == null) { - continue; - } - var value = bytes_1.hexlify(transaction[key]); - if ({ gasLimit: true, gasPrice: true, nonce: true, value: true }[key]) { - value = bytes_1.hexValue(value); - } - result.push(key + "=" + value); - } - return result.join("&"); -} -function getResult(result) { - // getLogs, getHistory have weird success responses - if (result.status == 0 && (result.message === "No records found" || result.message === "No transactions found")) { - return result.result; - } - if (result.status != 1 || result.message != "OK") { - // @TODO: not any - var error = new Error("invalid response"); - error.result = JSON.stringify(result); - throw error; - } - return result.result; -} -function getJsonResult(result) { - if (result.jsonrpc != "2.0") { - // @TODO: not any - var error = new Error("invalid response"); - error.result = JSON.stringify(result); - throw error; - } - if (result.error) { - // @TODO: not any - var error = new Error(result.error.message || "unknown error"); - if (result.error.code) { - error.code = result.error.code; - } - if (result.error.data) { - error.data = result.error.data; - } - throw error; - } - return result.result; -} -// The blockTag was normalized as a string by the Provider pre-perform operations -function checkLogTag(blockTag) { - if (blockTag === "pending") { - throw new Error("pending not supported"); - } - if (blockTag === "latest") { - return blockTag; - } - return parseInt(blockTag.substring(2), 16); -} -var EtherscanProvider = /** @class */ (function (_super) { - __extends(EtherscanProvider, _super); - function EtherscanProvider(network, apiKey) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, EtherscanProvider); - _this = _super.call(this, network) || this; - var name = "invalid"; - if (_this.network) { - name = _this.network.name; - } - var baseUrl = null; - switch (name) { - case "homestead": - baseUrl = "https://api.etherscan.io"; - break; - case "ropsten": - baseUrl = "https://api-ropsten.etherscan.io"; - break; - case "rinkeby": - baseUrl = "https://api-rinkeby.etherscan.io"; - break; - case "kovan": - baseUrl = "https://api-kovan.etherscan.io"; - break; - case "goerli": - baseUrl = "https://api-goerli.etherscan.io"; - break; - default: - throw new Error("unsupported network"); - } - properties_1.defineReadOnly(_this, "baseUrl", baseUrl); - properties_1.defineReadOnly(_this, "apiKey", apiKey); - return _this; - } - EtherscanProvider.prototype.perform = function (method, params) { - var _this = this; - var url = this.baseUrl; - var apiKey = ""; - if (this.apiKey) { - apiKey += "&apikey=" + this.apiKey; - } - var get = function (url, procFunc) { - _this.emit("debug", { - action: "request", - request: url, - provider: _this - }); - return web_1.fetchJson(url, null, procFunc || getJsonResult).then(function (result) { - _this.emit("debug", { - action: "response", - request: url, - response: properties_1.deepCopy(result), - provider: _this - }); - return result; - }); - }; - switch (method) { - case "getBlockNumber": - url += "/api?module=proxy&action=eth_blockNumber" + apiKey; - return get(url); - case "getGasPrice": - url += "/api?module=proxy&action=eth_gasPrice" + apiKey; - return get(url); - case "getBalance": - // Returns base-10 result - url += "/api?module=account&action=balance&address=" + params.address; - url += "&tag=" + params.blockTag + apiKey; - return get(url, getResult); - case "getTransactionCount": - url += "/api?module=proxy&action=eth_getTransactionCount&address=" + params.address; - url += "&tag=" + params.blockTag + apiKey; - return get(url); - case "getCode": - url += "/api?module=proxy&action=eth_getCode&address=" + params.address; - url += "&tag=" + params.blockTag + apiKey; - return get(url, getJsonResult); - case "getStorageAt": - url += "/api?module=proxy&action=eth_getStorageAt&address=" + params.address; - url += "&position=" + params.position; - url += "&tag=" + params.blockTag + apiKey; - return get(url, getJsonResult); - case "sendTransaction": - url += "/api?module=proxy&action=eth_sendRawTransaction&hex=" + params.signedTransaction; - url += apiKey; - return get(url).catch(function (error) { - if (error.responseText) { - // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" - if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { - logger.throwError("insufficient funds", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {}); - } - // "Transaction with the same hash was already imported." - if (error.responseText.indexOf("same hash was already imported") >= 0) { - logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {}); - } - // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." - if (error.responseText.indexOf("another transaction with same nonce") >= 0) { - logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {}); - } - } - throw error; - }); - case "getBlock": - if (params.blockTag) { - url += "/api?module=proxy&action=eth_getBlockByNumber&tag=" + params.blockTag; - if (params.includeTransactions) { - url += "&boolean=true"; - } - else { - url += "&boolean=false"; - } - url += apiKey; - return get(url); - } - throw new Error("getBlock by blockHash not implmeneted"); - case "getTransaction": - url += "/api?module=proxy&action=eth_getTransactionByHash&txhash=" + params.transactionHash; - url += apiKey; - return get(url); - case "getTransactionReceipt": - url += "/api?module=proxy&action=eth_getTransactionReceipt&txhash=" + params.transactionHash; - url += apiKey; - return get(url); - case "call": { - var transaction = getTransactionString(params.transaction); - if (transaction) { - transaction = "&" + transaction; - } - url += "/api?module=proxy&action=eth_call" + transaction; - //url += "&tag=" + params.blockTag + apiKey; - if (params.blockTag !== "latest") { - throw new Error("EtherscanProvider does not support blockTag for call"); - } - url += apiKey; - return get(url); - } - case "estimateGas": { - var transaction = getTransactionString(params.transaction); - if (transaction) { - transaction = "&" + transaction; - } - url += "/api?module=proxy&action=eth_estimateGas&" + transaction; - url += apiKey; - return get(url); - } - case "getLogs": - url += "/api?module=logs&action=getLogs"; - try { - if (params.filter.fromBlock) { - url += "&fromBlock=" + checkLogTag(params.filter.fromBlock); - } - if (params.filter.toBlock) { - url += "&toBlock=" + checkLogTag(params.filter.toBlock); - } - if (params.filter.address) { - url += "&address=" + params.filter.address; - } - // @TODO: We can handle slightly more complicated logs using the logs API - if (params.filter.topics && params.filter.topics.length > 0) { - if (params.filter.topics.length > 1) { - throw new Error("unsupported topic format"); - } - var topic0 = params.filter.topics[0]; - if (typeof (topic0) !== "string" || topic0.length !== 66) { - throw new Error("unsupported topic0 format"); - } - url += "&topic0=" + topic0; - } - } - catch (error) { - return Promise.reject(error); - } - url += apiKey; - var self_1 = this; - return get(url, getResult).then(function (logs) { - var txs = {}; - var seq = Promise.resolve(); - logs.forEach(function (log) { - seq = seq.then(function () { - if (log.blockHash != null) { - return null; - } - log.blockHash = txs[log.transactionHash]; - if (log.blockHash == null) { - return self_1.getTransaction(log.transactionHash).then(function (tx) { - txs[log.transactionHash] = tx.blockHash; - log.blockHash = tx.blockHash; - return null; - }); - } - return null; - }); - }); - return seq.then(function () { - return logs; - }); - }); - case "getEtherPrice": - if (this.network.name !== "homestead") { - return Promise.resolve(0.0); - } - url += "/api?module=stats&action=ethprice"; - url += apiKey; - return get(url, getResult).then(function (result) { - return parseFloat(result.ethusd); - }); - default: - break; - } - return _super.prototype.perform.call(this, method, params); - }; - // @TODO: Allow startBlock and endBlock to be Promises - EtherscanProvider.prototype.getHistory = function (addressOrName, startBlock, endBlock) { - var _this = this; - var url = this.baseUrl; - var apiKey = ""; - if (this.apiKey) { - apiKey += "&apikey=" + this.apiKey; - } - if (startBlock == null) { - startBlock = 0; - } - if (endBlock == null) { - endBlock = 99999999; - } - return this.resolveName(addressOrName).then(function (address) { - url += "/api?module=account&action=txlist&address=" + address; - url += "&startblock=" + startBlock; - url += "&endblock=" + endBlock; - url += "&sort=asc" + apiKey; - _this.emit("debug", { - action: "request", - request: url, - provider: _this - }); - return web_1.fetchJson(url, null, getResult).then(function (result) { - _this.emit("debug", { - action: "response", - request: url, - response: properties_1.deepCopy(result), - provider: _this - }); - var output = []; - result.forEach(function (tx) { - ["contractAddress", "to"].forEach(function (key) { - if (tx[key] == "") { - delete tx[key]; - } - }); - if (tx.creates == null && tx.contractAddress != null) { - tx.creates = tx.contractAddress; - } - var item = _this.formatter.transactionResponse(tx); - if (tx.timeStamp) { - item.timestamp = parseInt(tx.timeStamp); - } - output.push(item); - }); - return output; - }); - }); - }; - return EtherscanProvider; -}(base_provider_1.BaseProvider)); -exports.EtherscanProvider = EtherscanProvider; - -},{"./_version":97,"./base-provider":99,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/web":132}],103:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var random_1 = require("@ethersproject/random"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var base_provider_1 = require("./base-provider"); -function now() { return (new Date()).getTime(); } -// Returns: -// - true is all networks match -// - false if any network is null -// - throws if any 2 networks do not match -function checkNetworks(networks) { - var result = true; - var check = null; - networks.forEach(function (network) { - // Null - if (network == null) { - result = false; - return; - } - // Have nothing to compre to yet - if (check == null) { - check = network; - return; - } - // Matches! - if (check.name === network.name && - check.chainId === network.chainId && - ((check.ensAddress === network.ensAddress) || - (check.ensAddress == null && network.ensAddress == null))) { - return; - } - logger.throwArgumentError("provider mismatch", "networks", networks); - }); - return result; -} -function serialize(result) { - if (Array.isArray(result)) { - return JSON.stringify(result.map(function (r) { return serialize(r); })); - } - else if (result === null) { - return "null"; - } - else if (typeof (result) === "object") { - var keys = Object.keys(result); - keys.sort(); - return "{" + keys.map(function (key) { - var value = result[key]; - if (typeof (value) === "function") { - value = "function{}"; - } - else { - value = serialize(value); - } - return JSON.stringify(key) + "=" + serialize(value); - }).join(",") + "}"; - } - return JSON.stringify(result); -} -var nextRid = 1; -var FallbackProvider = /** @class */ (function (_super) { - __extends(FallbackProvider, _super); - function FallbackProvider(providers, quorum, weights) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, FallbackProvider); - if (providers.length === 0) { - logger.throwArgumentError("missing providers", "providers", providers); - } - if (weights != null && weights.length !== providers.length) { - logger.throwArgumentError("too many weights", "weights", weights); - } - else if (!weights) { - weights = providers.map(function (p) { return 1; }); - } - else { - weights.forEach(function (w) { - if (w % 1 || w > 512 || w < 1) { - logger.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); - } - }); - } - var total = weights.reduce(function (accum, w) { return (accum + w); }); - if (quorum == null) { - quorum = total / 2; - } - else { - if (quorum > total) { - logger.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); - } - } - // All networks are ready, we can know the network for certain - var ready = checkNetworks(providers.map(function (p) { return p.network; })); - if (ready) { - _this = _super.call(this, providers[0].network) || this; - } - else { - // The network won't be known until all child providers know - var ready_1 = Promise.all(providers.map(function (p) { return p.getNetwork(); })).then(function (networks) { - if (!checkNetworks(networks)) { - logger.throwError("getNetwork returned null", logger_1.Logger.errors.UNKNOWN_ERROR); - } - return networks[0]; - }); - _this = _super.call(this, ready_1) || this; - } - // Preserve a copy, so we do not get mutated - properties_1.defineReadOnly(_this, "providers", Object.freeze(providers.slice())); - properties_1.defineReadOnly(_this, "quorum", quorum); - properties_1.defineReadOnly(_this, "weights", Object.freeze(weights.slice())); - return _this; - } - FallbackProvider.doPerform = function (provider, method, params) { - switch (method) { - case "getBlockNumber": - case "getGasPrice": - case "getEtherPrice": - return provider[method](); - case "getBalance": - case "getTransactionCount": - case "getCode": - return provider[method](params.address, params.blockTag || "latest"); - case "getStorageAt": - return provider.getStorageAt(params.address, params.position, params.blockTag || "latest"); - case "sendTransaction": - return provider.sendTransaction(params.signedTransaction).then(function (result) { - return result.hash; - }); - case "getBlock": - return provider[(params.includeTransactions ? "getBlockWithTransactions" : "getBlock")](params.blockTag || params.blockHash); - case "call": - case "estimateGas": - return provider[method](params.transaction); - case "getTransaction": - case "getTransactionReceipt": - return provider[method](params.transactionHash); - case "getLogs": - return provider.getLogs(params.filter); - } - return logger.throwError("unknown method error", logger_1.Logger.errors.UNKNOWN_ERROR, { - method: method, - params: params - }); - }; - FallbackProvider.prototype.perform = function (method, params) { - var _this = this; - var T0 = now(); - var runners = (random_1.shuffled(this.providers)).map(function (provider, i) { - var weight = _this.weights[i]; - var rid = nextRid++; - return { - run: function () { - var t0 = now(); - var start = t0 - T0; - _this.emit("debug", { - action: "request", - rid: rid, - backend: { weight: weight, start: start, provider: provider }, - request: { method: method, params: properties_1.deepCopy(params) }, - provider: _this - }); - return FallbackProvider.doPerform(provider, method, params).then(function (result) { - var duration = now() - t0; - _this.emit("debug", { - action: "response", - rid: rid, - backend: { weight: weight, start: start, duration: duration, provider: provider }, - request: { method: method, params: properties_1.deepCopy(params) }, - response: properties_1.deepCopy(result) - }); - return { weight: weight, result: result }; - }, function (error) { - var duration = now() - t0; - _this.emit("debug", { - action: "response", - rid: rid, - backend: { weight: weight, start: start, duration: duration, provider: provider }, - request: { method: method, params: properties_1.deepCopy(params) }, - error: error - }); - return { weight: weight, error: error }; - }); - }, - weight: weight - }; - }); - // Broadcast transactions to all backends, any that succeed is good enough - if (method === "sendTransaction") { - return Promise.all(runners.map(function (r) { return r.run(); })).then(function (results) { - for (var i = 0; i < results.length; i++) { - var result = results[i]; - if (result.result) { - return result.result; - } - } - return Promise.reject(results[0].error); - }); - } - // Otherwise query backends (randomly) until we have a quorum agreement - // on the correct result - return new Promise(function (resolve, reject) { - var firstError = null; - // How much weight is inflight - var inflightWeight = 0; - // All results, indexed by the serialized response. - var results = {}; - var next = function () { - if (runners.length === 0) { - return; - } - var runner = runners.shift(); - inflightWeight += runner.weight; - runner.run().then(function (result) { - if (results === null) { - return; - } - inflightWeight -= runner.weight; - if (result.error) { - if (firstError == null) { - firstError = result.error; - } - } - else { - var unique = serialize(result.result); - if (results[unique] == null) { - results[unique] = []; - } - results[unique].push(result); - // Do any results meet our quroum? - for (var u in results) { - var weight = results[u].reduce(function (accum, r) { return (accum + r.weight); }, 0); - if (weight >= _this.quorum) { - var result_1 = results[u][0].result; - _this.emit("debug", "quorum", -1, { weight: weight, result: result_1 }); - resolve(result_1); - results = null; - return; - } - } - } - // Out of options; give up - if (runners.length === 0 && inflightWeight === 0) { - // @TODO: this might need some more thinking... Maybe only if half - // of the results contain non-error? - if (method === "getGasPrice") { - var values_1 = []; - Object.keys(results).forEach(function (key) { - results[key].forEach(function (result) { - if (!result.result) { - return; - } - values_1.push(result.result); - }); - }); - values_1.sort(function (a, b) { - if (a.lt(b)) { - return -1; - } - if (a.gt(b)) { - return 1; - } - return 0; - }); - var index = parseInt(String(values_1.length / 2)); - if (values_1.length % 2) { - resolve(values_1[index]); - return; - } - resolve(values_1[index - 1].add(values_1[index]).div(2)); - return; - } - if (firstError === null) { - firstError = logger.makeError("failed to meet quorum", logger_1.Logger.errors.SERVER_ERROR, { - results: Object.keys(results).map(function (u) { - return { - method: method, - params: params, - result: u, - weight: results[u].reduce(function (accum, r) { return (accum + r.weight); }, 0) - }; - }) - }); - } - reject(firstError); - return; - } - // Queue up the next round - setTimeout(next, 0); - }); - // Fire off requests until we could possibly meet quorum - if (inflightWeight < _this.quorum) { - setTimeout(next, 0); - return; - } - }; - // bootstrap firing requests - next(); - }); - }; - return FallbackProvider; -}(base_provider_1.BaseProvider)); -exports.FallbackProvider = FallbackProvider; - -},{"./_version":97,"./base-provider":99,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/random":112}],104:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var address_1 = require("@ethersproject/address"); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var constants_1 = require("@ethersproject/constants"); -var properties_1 = require("@ethersproject/properties"); -var transactions_1 = require("@ethersproject/transactions"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var Formatter = /** @class */ (function () { - function Formatter() { - var _newTarget = this.constructor; - logger.checkNew(_newTarget, Formatter); - this.formats = this.getDefaultFormats(); - } - Formatter.prototype.getDefaultFormats = function () { - var _this = this; - var formats = ({}); - var address = this.address.bind(this); - var bigNumber = this.bigNumber.bind(this); - var blockTag = this.blockTag.bind(this); - var data = this.data.bind(this); - var hash = this.hash.bind(this); - var hex = this.hex.bind(this); - var number = this.number.bind(this); - var strictData = function (v) { return _this.data(v, true); }; - formats.transaction = { - hash: hash, - blockHash: Formatter.allowNull(hash, null), - blockNumber: Formatter.allowNull(number, null), - transactionIndex: Formatter.allowNull(number, null), - confirmations: Formatter.allowNull(number, null), - from: address, - gasPrice: bigNumber, - gasLimit: bigNumber, - to: Formatter.allowNull(address, null), - value: bigNumber, - nonce: number, - data: data, - r: Formatter.allowNull(this.uint256), - s: Formatter.allowNull(this.uint256), - v: Formatter.allowNull(number), - creates: Formatter.allowNull(address, null), - raw: Formatter.allowNull(data), - }; - formats.transactionRequest = { - from: Formatter.allowNull(address), - nonce: Formatter.allowNull(number), - gasLimit: Formatter.allowNull(bigNumber), - gasPrice: Formatter.allowNull(bigNumber), - to: Formatter.allowNull(address), - value: Formatter.allowNull(bigNumber), - data: Formatter.allowNull(strictData), - }; - formats.receiptLog = { - transactionLogIndex: Formatter.allowNull(number), - transactionIndex: number, - blockNumber: number, - transactionHash: hash, - address: address, - topics: Formatter.arrayOf(hash), - data: data, - logIndex: number, - blockHash: hash, - }; - formats.receipt = { - to: Formatter.allowNull(this.address), - from: Formatter.allowNull(this.address), - contractAddress: Formatter.allowNull(address, null), - transactionIndex: number, - root: Formatter.allowNull(hash), - gasUsed: bigNumber, - logsBloom: Formatter.allowNull(data), - blockHash: hash, - transactionHash: hash, - logs: Formatter.arrayOf(this.receiptLog.bind(this)), - blockNumber: number, - confirmations: Formatter.allowNull(number, null), - cumulativeGasUsed: bigNumber, - status: Formatter.allowNull(number) - }; - formats.block = { - hash: hash, - parentHash: hash, - number: number, - timestamp: number, - nonce: Formatter.allowNull(hex), - difficulty: this.difficulty.bind(this), - gasLimit: bigNumber, - gasUsed: bigNumber, - miner: address, - extraData: data, - transactions: Formatter.allowNull(Formatter.arrayOf(hash)), - }; - formats.blockWithTransactions = properties_1.shallowCopy(formats.block); - formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); - formats.filter = { - fromBlock: Formatter.allowNull(blockTag, undefined), - toBlock: Formatter.allowNull(blockTag, undefined), - blockHash: Formatter.allowNull(hash, undefined), - address: Formatter.allowNull(address, undefined), - topics: Formatter.allowNull(this.topics.bind(this), undefined), - }; - formats.filterLog = { - blockNumber: Formatter.allowNull(number), - blockHash: Formatter.allowNull(hash), - transactionIndex: number, - removed: Formatter.allowNull(this.boolean.bind(this)), - address: address, - data: Formatter.allowFalsish(data, "0x"), - topics: Formatter.arrayOf(hash), - transactionHash: hash, - logIndex: number, - }; - return formats; - }; - // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number - // Strict! Used on input. - Formatter.prototype.number = function (number) { - return bignumber_1.BigNumber.from(number).toNumber(); - }; - // Strict! Used on input. - Formatter.prototype.bigNumber = function (value) { - return bignumber_1.BigNumber.from(value); - }; - // Requires a boolean, "true" or "false"; returns a boolean - Formatter.prototype.boolean = function (value) { - if (typeof (value) === "boolean") { - return value; - } - if (typeof (value) === "string") { - value = value.toLowerCase(); - if (value === "true") { - return true; - } - if (value === "false") { - return false; - } - } - throw new Error("invaid boolean - " + value); - }; - Formatter.prototype.hex = function (value, strict) { - if (typeof (value) === "string") { - if (!strict && value.substring(0, 2) !== "0x") { - value = "0x" + value; - } - if (bytes_1.isHexString(value)) { - return value.toLowerCase(); - } - } - return logger.throwArgumentError("invalid hash", "value", value); - }; - Formatter.prototype.data = function (value, strict) { - var result = this.hex(value, strict); - if ((result.length % 2) !== 0) { - throw new Error("invalid data; odd-length - " + value); - } - return result; - }; - // Requires an address - // Strict! Used on input. - Formatter.prototype.address = function (value) { - return address_1.getAddress(value); - }; - Formatter.prototype.callAddress = function (value) { - if (!bytes_1.isHexString(value, 32)) { - return null; - } - var address = address_1.getAddress(bytes_1.hexDataSlice(value, 12)); - return (address === constants_1.AddressZero) ? null : address; - }; - Formatter.prototype.contractAddress = function (value) { - return address_1.getContractAddress(value); - }; - // Strict! Used on input. - Formatter.prototype.blockTag = function (blockTag) { - if (blockTag == null) { - return "latest"; - } - if (blockTag === "earliest") { - return "0x0"; - } - if (blockTag === "latest" || blockTag === "pending") { - return blockTag; - } - if (typeof (blockTag) === "number" || bytes_1.isHexString(blockTag)) { - return bytes_1.hexValue(blockTag); - } - throw new Error("invalid blockTag"); - }; - // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. - Formatter.prototype.hash = function (value, strict) { - var result = this.hex(value, strict); - if (bytes_1.hexDataLength(result) !== 32) { - return logger.throwArgumentError("invalid hash", "value", value); - } - return result; - }; - // Returns the difficulty as a number, or if too large (i.e. PoA network) null - Formatter.prototype.difficulty = function (value) { - var v = bignumber_1.BigNumber.from(value); - try { - return v.toNumber(); - } - catch (error) { } - return null; - }; - Formatter.prototype.uint256 = function (value) { - if (!bytes_1.isHexString(value)) { - throw new Error("invalid uint256"); - } - return bytes_1.hexZeroPad(value, 32); - }; - Formatter.prototype._block = function (value, format) { - if (value.author != null && value.miner == null) { - value.miner = value.author; - } - return Formatter.check(format, value); - }; - Formatter.prototype.block = function (value) { - return this._block(value, this.formats.block); - }; - Formatter.prototype.blockWithTransactions = function (value) { - return this._block(value, this.formats.blockWithTransactions); - }; - // Strict! Used on input. - Formatter.prototype.transactionRequest = function (value) { - return Formatter.check(this.formats.transactionRequest, value); - }; - Formatter.prototype.transactionResponse = function (transaction) { - // Rename gas to gasLimit - if (transaction.gas != null && transaction.gasLimit == null) { - transaction.gasLimit = transaction.gas; - } - // Some clients (TestRPC) do strange things like return 0x0 for the - // 0 address; correct this to be a real address - if (transaction.to && bignumber_1.BigNumber.from(transaction.to).isZero()) { - transaction.to = "0x0000000000000000000000000000000000000000"; - } - // Rename input to data - if (transaction.input != null && transaction.data == null) { - transaction.data = transaction.input; - } - // If to and creates are empty, populate the creates from the transaction - if (transaction.to == null && transaction.creates == null) { - transaction.creates = this.contractAddress(transaction); - } - // @TODO: use transaction.serialize? Have to add support for including v, r, and s... - /* - if (!transaction.raw) { - - // Very loose providers (e.g. TestRPC) do not provide a signature or raw - if (transaction.v && transaction.r && transaction.s) { - let raw = [ - stripZeros(hexlify(transaction.nonce)), - stripZeros(hexlify(transaction.gasPrice)), - stripZeros(hexlify(transaction.gasLimit)), - (transaction.to || "0x"), - stripZeros(hexlify(transaction.value || "0x")), - hexlify(transaction.data || "0x"), - stripZeros(hexlify(transaction.v || "0x")), - stripZeros(hexlify(transaction.r)), - stripZeros(hexlify(transaction.s)), - ]; - - transaction.raw = rlpEncode(raw); - } - } - */ - var result = Formatter.check(this.formats.transaction, transaction); - var networkId = transaction.networkId; - // geth-etc returns chainId - if (transaction.chainId != null && networkId == null && result.v == null) { - networkId = transaction.chainId; - } - if (bytes_1.isHexString(networkId)) { - networkId = bignumber_1.BigNumber.from(networkId).toNumber(); - } - if (typeof (networkId) !== "number" && result.v != null) { - networkId = (result.v - 35) / 2; - if (networkId < 0) { - networkId = 0; - } - networkId = parseInt(networkId); - } - if (typeof (networkId) !== "number") { - networkId = 0; - } - result.networkId = networkId; - // 0x0000... should actually be null - if (result.blockHash && result.blockHash.replace(/0/g, "") === "x") { - result.blockHash = null; - } - return result; - }; - Formatter.prototype.transaction = function (value) { - return transactions_1.parse(value); - }; - Formatter.prototype.receiptLog = function (value) { - return Formatter.check(this.formats.receiptLog, value); - }; - Formatter.prototype.receipt = function (value) { - //let status = transactionReceipt.status; - //let root = transactionReceipt.root; - var result = Formatter.check(this.formats.receipt, value); - result.logs.forEach(function (entry, index) { - if (entry.transactionLogIndex == null) { - entry.transactionLogIndex = index; - } - }); - if (value.status != null) { - result.byzantium = true; - } - return result; - }; - Formatter.prototype.topics = function (value) { - var _this = this; - if (Array.isArray(value)) { - return value.map(function (v) { return _this.topics(v); }); - } - else if (value != null) { - return this.hash(value, true); - } - return null; - }; - Formatter.prototype.filter = function (value) { - return Formatter.check(this.formats.filter, value); - }; - Formatter.prototype.filterLog = function (value) { - return Formatter.check(this.formats.filterLog, value); - }; - Formatter.check = function (format, object) { - var result = {}; - for (var key in format) { - try { - var value = format[key](object[key]); - if (value !== undefined) { - result[key] = value; - } - } - catch (error) { - error.checkKey = key; - error.checkValue = object[key]; - throw error; - } - } - return result; - }; - // if value is null-ish, nullValue is returned - Formatter.allowNull = function (format, nullValue) { - return (function (value) { - if (value == null) { - return nullValue; - } - return format(value); - }); - }; - // If value is false-ish, replaceValue is returned - Formatter.allowFalsish = function (format, replaceValue) { - return (function (value) { - if (!value) { - return replaceValue; - } - return format(value); - }); - }; - // Requires an Array satisfying check - Formatter.arrayOf = function (format) { - return (function (array) { - if (!Array.isArray(array)) { - throw new Error("not an array"); - } - var result = []; - array.forEach(function (value) { - result.push(format(value)); - }); - return result; - }); - }; - return Formatter; -}()); -exports.Formatter = Formatter; - -},{"./_version":97,"@ethersproject/address":62,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/constants":71,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/transactions":126}],105:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_provider_1 = require("@ethersproject/abstract-provider"); -exports.Provider = abstract_provider_1.Provider; -var networks_1 = require("@ethersproject/networks"); -exports.getNetwork = networks_1.getNetwork; -var base_provider_1 = require("./base-provider"); -exports.BaseProvider = base_provider_1.BaseProvider; -var alchemy_provider_1 = require("./alchemy-provider"); -exports.AlchemyProvider = alchemy_provider_1.AlchemyProvider; -var cloudflare_provider_1 = require("./cloudflare-provider"); -exports.CloudflareProvider = cloudflare_provider_1.CloudflareProvider; -var etherscan_provider_1 = require("./etherscan-provider"); -exports.EtherscanProvider = etherscan_provider_1.EtherscanProvider; -var fallback_provider_1 = require("./fallback-provider"); -exports.FallbackProvider = fallback_provider_1.FallbackProvider; -var ipc_provider_1 = require("./ipc-provider"); -exports.IpcProvider = ipc_provider_1.IpcProvider; -var infura_provider_1 = require("./infura-provider"); -exports.InfuraProvider = infura_provider_1.InfuraProvider; -var json_rpc_provider_1 = require("./json-rpc-provider"); -exports.JsonRpcProvider = json_rpc_provider_1.JsonRpcProvider; -exports.JsonRpcSigner = json_rpc_provider_1.JsonRpcSigner; -var nodesmith_provider_1 = require("./nodesmith-provider"); -exports.NodesmithProvider = nodesmith_provider_1.NodesmithProvider; -var web3_provider_1 = require("./web3-provider"); -exports.Web3Provider = web3_provider_1.Web3Provider; -var formatter_1 = require("./formatter"); -exports.Formatter = formatter_1.Formatter; - -},{"./alchemy-provider":98,"./base-provider":99,"./cloudflare-provider":101,"./etherscan-provider":102,"./fallback-provider":103,"./formatter":104,"./infura-provider":106,"./ipc-provider":100,"./json-rpc-provider":107,"./nodesmith-provider":108,"./web3-provider":110,"@ethersproject/abstract-provider":58,"@ethersproject/networks":93}],106:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); -var defaultProjectId = "84842078b09946638c03157f83405213"; -var InfuraProvider = /** @class */ (function (_super) { - __extends(InfuraProvider, _super); - function InfuraProvider() { - return _super !== null && _super.apply(this, arguments) || this; - } - Object.defineProperty(InfuraProvider.prototype, "projectId", { - get: function () { return this.apiKey; }, - enumerable: true, - configurable: true - }); - InfuraProvider.getApiKey = function (apiKey) { - if (apiKey == null) { - return defaultProjectId; - } - return apiKey; - }; - InfuraProvider.getUrl = function (network, apiKey) { - var host = null; - switch (network.name) { - case "homestead": - host = "mainnet.infura.io"; - break; - case "ropsten": - host = "ropsten.infura.io"; - break; - case "rinkeby": - host = "rinkeby.infura.io"; - break; - case "kovan": - host = "kovan.infura.io"; - break; - case "goerli": - host = "goerli.infura.io"; - break; - default: - logger.throwError("unsupported network", logger_1.Logger.errors.INVALID_ARGUMENT, { - argument: "network", - value: network - }); - } - return "https:/" + "/" + host + "/v3/" + apiKey; - }; - return InfuraProvider; -}(url_json_rpc_provider_1.UrlJsonRpcProvider)); -exports.InfuraProvider = InfuraProvider; - -},{"./_version":97,"./url-json-rpc-provider":109,"@ethersproject/logger":91}],107:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var abstract_signer_1 = require("@ethersproject/abstract-signer"); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var networks_1 = require("@ethersproject/networks"); -var properties_1 = require("@ethersproject/properties"); -var strings_1 = require("@ethersproject/strings"); -var web_1 = require("@ethersproject/web"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var base_provider_1 = require("./base-provider"); -function timer(timeout) { - return new Promise(function (resolve) { - setTimeout(function () { - resolve(); - }, timeout); - }); -} -function getResult(payload) { - if (payload.error) { - // @TODO: not any - var error = new Error(payload.error.message); - error.code = payload.error.code; - error.data = payload.error.data; - throw error; - } - return payload.result; -} -function getLowerCase(value) { - if (value) { - return value.toLowerCase(); - } - return value; -} -var _constructorGuard = {}; -var JsonRpcSigner = /** @class */ (function (_super) { - __extends(JsonRpcSigner, _super); - function JsonRpcSigner(constructorGuard, provider, addressOrIndex) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, JsonRpcSigner); - _this = _super.call(this) || this; - if (constructorGuard !== _constructorGuard) { - throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); - } - properties_1.defineReadOnly(_this, "provider", provider); - if (addressOrIndex == null) { - addressOrIndex = 0; - } - if (typeof (addressOrIndex) === "string") { - properties_1.defineReadOnly(_this, "_address", _this.provider.formatter.address(addressOrIndex)); - properties_1.defineReadOnly(_this, "_index", null); - } - else if (typeof (addressOrIndex) === "number") { - properties_1.defineReadOnly(_this, "_index", addressOrIndex); - properties_1.defineReadOnly(_this, "_address", null); - } - else { - logger.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); - } - return _this; - } - JsonRpcSigner.prototype.connect = function (provider) { - return logger.throwError("cannot alter JSON-RPC Signer connection", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "connect" - }); - }; - JsonRpcSigner.prototype.connectUnchecked = function () { - return new UncheckedJsonRpcSigner(_constructorGuard, this.provider, this._address || this._index); - }; - JsonRpcSigner.prototype.getAddress = function () { - var _this = this; - if (this._address) { - return Promise.resolve(this._address); - } - return this.provider.send("eth_accounts", []).then(function (accounts) { - if (accounts.length <= _this._index) { - logger.throwError("unknown account #" + _this._index, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "getAddress" - }); - } - return _this.provider.formatter.address(accounts[_this._index]); - }); - }; - JsonRpcSigner.prototype.sendUncheckedTransaction = function (transaction) { - var _this = this; - transaction = properties_1.shallowCopy(transaction); - var fromAddress = this.getAddress().then(function (address) { - if (address) { - address = address.toLowerCase(); - } - return address; - }); - // The JSON-RPC for eth_sendTransaction uses 90000 gas; if the user - // wishes to use this, it is easy to specify explicitly, otherwise - // we look it up for them. - if (transaction.gasLimit == null) { - var estimate = properties_1.shallowCopy(transaction); - estimate.from = fromAddress; - transaction.gasLimit = this.provider.estimateGas(estimate); - } - return Promise.all([ - properties_1.resolveProperties(transaction), - fromAddress - ]).then(function (results) { - var tx = results[0]; - var hexTx = _this.provider.constructor.hexlifyTransaction(tx); - hexTx.from = results[1]; - return _this.provider.send("eth_sendTransaction", [hexTx]).then(function (hash) { - return hash; - }, function (error) { - if (error.responseText) { - // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) - if (error.responseText.indexOf("insufficient funds") >= 0) { - logger.throwError("insufficient funds", logger_1.Logger.errors.INSUFFICIENT_FUNDS, { - transaction: tx - }); - } - if (error.responseText.indexOf("nonce too low") >= 0) { - logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, { - transaction: tx - }); - } - if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { - logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, { - transaction: tx - }); - } - } - throw error; - }); - }); - }; - JsonRpcSigner.prototype.signTransaction = function (transaction) { - return logger.throwError("signing transactions is unsupported", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "signTransaction" - }); - }; - JsonRpcSigner.prototype.sendTransaction = function (transaction) { - var _this = this; - return this.sendUncheckedTransaction(transaction).then(function (hash) { - return web_1.poll(function () { - return _this.provider.getTransaction(hash).then(function (tx) { - if (tx === null) { - return undefined; - } - return _this.provider._wrapTransaction(tx, hash); - }); - }, { onceBlock: _this.provider }).catch(function (error) { - error.transactionHash = hash; - throw error; - }); - }); - }; - JsonRpcSigner.prototype.signMessage = function (message) { - var _this = this; - var data = ((typeof (message) === "string") ? strings_1.toUtf8Bytes(message) : message); - return this.getAddress().then(function (address) { - // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign - return _this.provider.send("eth_sign", [address.toLowerCase(), bytes_1.hexlify(data)]); - }); - }; - JsonRpcSigner.prototype.unlock = function (password) { - var provider = this.provider; - return this.getAddress().then(function (address) { - return provider.send("personal_unlockAccount", [address.toLowerCase(), password, null]); - }); - }; - return JsonRpcSigner; -}(abstract_signer_1.Signer)); -exports.JsonRpcSigner = JsonRpcSigner; -var UncheckedJsonRpcSigner = /** @class */ (function (_super) { - __extends(UncheckedJsonRpcSigner, _super); - function UncheckedJsonRpcSigner() { - return _super !== null && _super.apply(this, arguments) || this; - } - UncheckedJsonRpcSigner.prototype.sendTransaction = function (transaction) { - var _this = this; - return this.sendUncheckedTransaction(transaction).then(function (hash) { - return { - hash: hash, - nonce: null, - gasLimit: null, - gasPrice: null, - data: null, - value: null, - chainId: null, - confirmations: 0, - from: null, - wait: function (confirmations) { return _this.provider.waitForTransaction(hash, confirmations); } - }; - }); - }; - return UncheckedJsonRpcSigner; -}(JsonRpcSigner)); -var allowedTransactionKeys = { - chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true -}; -var JsonRpcProvider = /** @class */ (function (_super) { - __extends(JsonRpcProvider, _super); - function JsonRpcProvider(url, network) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, JsonRpcProvider); - // One parameter, but it is a network name, so swap it with the URL - if (typeof (url) === "string") { - if (network === null && networks_1.getNetwork(url)) { - network = url; - url = null; - } - } - if (network) { - // The network has been specified explicitly, we can use it - _this = _super.call(this, network) || this; - } - else { - // The network is unknown, query the JSON-RPC for it - var ready = new Promise(function (resolve, reject) { - setTimeout(function () { - _this.send("eth_chainId", []).then(function (result) { - resolve(networks_1.getNetwork(bignumber_1.BigNumber.from(result).toNumber())); - }).catch(function (error) { - _this.send("net_version", []).then(function (result) { - resolve(networks_1.getNetwork(bignumber_1.BigNumber.from(result).toNumber())); - }).catch(function (error) { - reject(logger.makeError("could not detect network", logger_1.Logger.errors.NETWORK_ERROR)); - }); - }); - }); - }); - _this = _super.call(this, ready) || this; - } - // Default URL - if (!url) { - url = "http:/" + "/localhost:8545"; - } - if (typeof (url) === "string") { - _this.connection = { - url: url - }; - } - else { - _this.connection = url; - } - _this._nextId = 42; - return _this; - } - JsonRpcProvider.prototype.getSigner = function (addressOrIndex) { - return new JsonRpcSigner(_constructorGuard, this, addressOrIndex); - }; - JsonRpcProvider.prototype.getUncheckedSigner = function (addressOrIndex) { - return this.getSigner(addressOrIndex).connectUnchecked(); - }; - JsonRpcProvider.prototype.listAccounts = function () { - var _this = this; - return this.send("eth_accounts", []).then(function (accounts) { - return accounts.map(function (a) { return _this.formatter.address(a); }); - }); - }; - JsonRpcProvider.prototype.send = function (method, params) { - var _this = this; - var request = { - method: method, - params: params, - id: (this._nextId++), - jsonrpc: "2.0" - }; - this.emit("debug", { - action: "request", - request: properties_1.deepCopy(request), - provider: this - }); - return web_1.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) { - _this.emit("debug", { - action: "response", - request: request, - response: result, - provider: _this - }); - return result; - }); - }; - JsonRpcProvider.prototype.perform = function (method, params) { - switch (method) { - case "getBlockNumber": - return this.send("eth_blockNumber", []); - case "getGasPrice": - return this.send("eth_gasPrice", []); - case "getBalance": - return this.send("eth_getBalance", [getLowerCase(params.address), params.blockTag]); - case "getTransactionCount": - return this.send("eth_getTransactionCount", [getLowerCase(params.address), params.blockTag]); - case "getCode": - return this.send("eth_getCode", [getLowerCase(params.address), params.blockTag]); - case "getStorageAt": - return this.send("eth_getStorageAt", [getLowerCase(params.address), params.position, params.blockTag]); - case "sendTransaction": - return this.send("eth_sendRawTransaction", [params.signedTransaction]).catch(function (error) { - if (error.responseText) { - // "insufficient funds for gas * price + value" - if (error.responseText.indexOf("insufficient funds") > 0) { - logger.throwError("insufficient funds", logger_1.Logger.errors.INSUFFICIENT_FUNDS, {}); - } - // "nonce too low" - if (error.responseText.indexOf("nonce too low") > 0) { - logger.throwError("nonce has already been used", logger_1.Logger.errors.NONCE_EXPIRED, {}); - } - // "replacement transaction underpriced" - if (error.responseText.indexOf("replacement transaction underpriced") > 0) { - logger.throwError("replacement fee too low", logger_1.Logger.errors.REPLACEMENT_UNDERPRICED, {}); - } - } - throw error; - }); - case "getBlock": - if (params.blockTag) { - return this.send("eth_getBlockByNumber", [params.blockTag, !!params.includeTransactions]); - } - else if (params.blockHash) { - return this.send("eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]); - } - return logger.throwArgumentError("invalid block tag or block hash", "params", params); - case "getTransaction": - return this.send("eth_getTransactionByHash", [params.transactionHash]); - case "getTransactionReceipt": - return this.send("eth_getTransactionReceipt", [params.transactionHash]); - case "call": - return this.send("eth_call", [this.constructor.hexlifyTransaction(params.transaction, { from: true }), params.blockTag]); - case "estimateGas": - return this.send("eth_estimateGas", [this.constructor.hexlifyTransaction(params.transaction, { from: true })]); - case "getLogs": - if (params.filter && params.filter.address != null) { - params.filter.address = getLowerCase(params.filter.address); - } - return this.send("eth_getLogs", [params.filter]); - default: - break; - } - return logger.throwError(method + " not implemented", logger_1.Logger.errors.NOT_IMPLEMENTED, { operation: method }); - }; - JsonRpcProvider.prototype._startPending = function () { - if (this._pendingFilter != null) { - return; - } - var self = this; - var pendingFilter = this.send("eth_newPendingTransactionFilter", []); - this._pendingFilter = pendingFilter; - pendingFilter.then(function (filterId) { - function poll() { - self.send("eth_getFilterChanges", [filterId]).then(function (hashes) { - if (self._pendingFilter != pendingFilter) { - return null; - } - var seq = Promise.resolve(); - hashes.forEach(function (hash) { - // @TODO: This should be garbage collected at some point... How? When? - self._emitted["t:" + hash.toLowerCase()] = "pending"; - seq = seq.then(function () { - return self.getTransaction(hash).then(function (tx) { - self.emit("pending", tx); - return null; - }); - }); - }); - return seq.then(function () { - return timer(1000); - }); - }).then(function () { - if (self._pendingFilter != pendingFilter) { - self.send("eth_uninstallFilter", [filterId]); - return; - } - setTimeout(function () { poll(); }, 0); - return null; - }).catch(function (error) { }); - } - poll(); - return filterId; - }).catch(function (error) { }); - }; - JsonRpcProvider.prototype._stopPending = function () { - this._pendingFilter = null; - }; - // Convert an ethers.js transaction into a JSON-RPC transaction - // - gasLimit => gas - // - All values hexlified - // - All numeric values zero-striped - // NOTE: This allows a TransactionRequest, but all values should be resolved - // before this is called - JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) { - // Check only allowed properties are given - var allowed = properties_1.shallowCopy(allowedTransactionKeys); - if (allowExtra) { - for (var key in allowExtra) { - if (allowExtra[key]) { - allowed[key] = true; - } - } - } - properties_1.checkProperties(transaction, allowed); - var result = {}; - // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. - ["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) { - if (transaction[key] == null) { - return; - } - var value = bytes_1.hexValue(transaction[key]); - if (key === "gasLimit") { - key = "gas"; - } - result[key] = value; - }); - ["from", "to", "data"].forEach(function (key) { - if (transaction[key] == null) { - return; - } - result[key] = bytes_1.hexlify(transaction[key]); - }); - return result; - }; - return JsonRpcProvider; -}(base_provider_1.BaseProvider)); -exports.JsonRpcProvider = JsonRpcProvider; - -},{"./_version":97,"./base-provider":99,"@ethersproject/abstract-signer":60,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/networks":93,"@ethersproject/properties":96,"@ethersproject/strings":123,"@ethersproject/web":132}],108:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var url_json_rpc_provider_1 = require("./url-json-rpc-provider"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -// Special API key provided by Nodesmith for ethers.js -var defaultApiKey = "ETHERS_JS_SHARED"; -var NodesmithProvider = /** @class */ (function (_super) { - __extends(NodesmithProvider, _super); - function NodesmithProvider() { - return _super !== null && _super.apply(this, arguments) || this; - } - NodesmithProvider.getApiKey = function (apiKey) { - return apiKey || defaultApiKey; - }; - NodesmithProvider.getUrl = function (network, apiKey) { - var host = null; - switch (network.name) { - case "homestead": - host = "https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc"; - break; - case "ropsten": - host = "https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc"; - break; - case "rinkeby": - host = "https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc"; - break; - case "goerli": - host = "https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc"; - break; - case "kovan": - host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; - break; - default: - logger.throwArgumentError("unsupported network", "network", arguments[0]); - } - return (host + "?apiKey=" + apiKey); - }; - return NodesmithProvider; -}(url_json_rpc_provider_1.UrlJsonRpcProvider)); -exports.NodesmithProvider = NodesmithProvider; - -},{"./_version":97,"./url-json-rpc-provider":109,"@ethersproject/logger":91}],109:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var networks_1 = require("@ethersproject/networks"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var json_rpc_provider_1 = require("./json-rpc-provider"); -var UrlJsonRpcProvider = /** @class */ (function (_super) { - __extends(UrlJsonRpcProvider, _super); - function UrlJsonRpcProvider(network, apiKey) { - var _newTarget = this.constructor; - var _this = this; - logger.checkAbstract(_newTarget, UrlJsonRpcProvider); - // Normalize the Network and API Key - network = properties_1.getStatic((_newTarget), "getNetwork")(network); - apiKey = properties_1.getStatic((_newTarget), "getApiKey")(apiKey); - var url = properties_1.getStatic((_newTarget), "getUrl")(network, apiKey); - _this = _super.call(this, url, network) || this; - properties_1.defineReadOnly(_this, "apiKey", apiKey); - return _this; - } - UrlJsonRpcProvider.prototype._startPending = function () { - logger.warn("WARNING: API provider does not support pending filters"); - }; - UrlJsonRpcProvider.prototype.getSigner = function (address) { - logger.throwError("API provider does not support signing", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); - return null; - }; - UrlJsonRpcProvider.prototype.listAccounts = function () { - return Promise.resolve([]); - }; - UrlJsonRpcProvider.getNetwork = function (network) { - return networks_1.getNetwork((network == null) ? "homestead" : network); - }; - // Return a defaultApiKey if null, otherwise validate the API key - UrlJsonRpcProvider.getApiKey = function (apiKey) { - return apiKey; - }; - // Returns the url for the given network and API key - UrlJsonRpcProvider.getUrl = function (network, apiKey) { - return logger.throwError("not implemented; sub-classes must override getUrl", logger_1.Logger.errors.NOT_IMPLEMENTED, { - operation: "getUrl" - }); - }; - return UrlJsonRpcProvider; -}(json_rpc_provider_1.JsonRpcProvider)); -exports.UrlJsonRpcProvider = UrlJsonRpcProvider; - -},{"./_version":97,"./json-rpc-provider":107,"@ethersproject/logger":91,"@ethersproject/networks":93,"@ethersproject/properties":96}],110:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var json_rpc_provider_1 = require("./json-rpc-provider"); -/* -@TODO -utils.defineProperty(Web3Signer, "onchange", { - -}); - -*/ -var Web3Provider = /** @class */ (function (_super) { - __extends(Web3Provider, _super); - function Web3Provider(web3Provider, network) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, Web3Provider); - // HTTP has a host; IPC has a path. - _this = _super.call(this, web3Provider.host || web3Provider.path || "", network) || this; - if (web3Provider) { - if (web3Provider.sendAsync) { - _this._sendAsync = web3Provider.sendAsync.bind(web3Provider); - } - else if (web3Provider.send) { - _this._sendAsync = web3Provider.send.bind(web3Provider); - } - } - if (!web3Provider || !_this._sendAsync) { - logger.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); - } - properties_1.defineReadOnly(_this, "_web3Provider", web3Provider); - return _this; - } - Web3Provider.prototype.send = function (method, params) { - var _this = this; - // Metamask complains about eth_sign (and on some versions hangs) - if (method == "eth_sign" && this._web3Provider.isMetaMask) { - // https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign - method = "personal_sign"; - params = [params[1], params[0]]; - } - return new Promise(function (resolve, reject) { - var request = { - method: method, - params: params, - id: 42, - jsonrpc: "2.0" - }; - _this._sendAsync(request, function (error, result) { - if (error) { - reject(error); - return; - } - if (result.error) { - // @TODO: not any - var error_1 = new Error(result.error.message); - error_1.code = result.error.code; - error_1.data = result.error.data; - reject(error_1); - return; - } - resolve(result.result); - }); - }); - }; - return Web3Provider; -}(json_rpc_provider_1.JsonRpcProvider)); -exports.Web3Provider = Web3Provider; - -},{"./_version":97,"./json-rpc-provider":107,"@ethersproject/logger":91,"@ethersproject/properties":96}],111:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "random/5.0.0-beta.127"; - -},{}],112:[function(require,module,exports){ -(function (global){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var shuffle_1 = require("./shuffle"); -exports.shuffled = shuffle_1.shuffled; -var crypto = global.crypto || global.msCrypto; -if (!crypto || !crypto.getRandomValues) { - logger.warn("WARNING: Missing strong random number source"); - crypto = { - getRandomValues: function (buffer) { - return logger.throwError("no secure random source avaialble", logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "crypto.getRandomValues" - }); - } - }; -} -function randomBytes(length) { - if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { - logger.throwArgumentError("invalid length", "length", length); - } - var result = new Uint8Array(length); - crypto.getRandomValues(result); - return bytes_1.arrayify(result); -} -exports.randomBytes = randomBytes; -; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_version":111,"./shuffle":113,"@ethersproject/bytes":70,"@ethersproject/logger":91}],113:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -function shuffled(array) { - array = array.slice(); - for (var i = array.length - 1; i > 0; i--) { - var j = Math.floor(Math.random() * (i + 1)); - var tmp = array[i]; - array[i] = array[j]; - array[j] = tmp; - } - return array; -} -exports.shuffled = shuffled; - -},{}],114:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//See: https://github.com/ethereum/wiki/wiki/RLP -var bytes_1 = require("@ethersproject/bytes"); -function arrayifyInteger(value) { - var result = []; - while (value) { - result.unshift(value & 0xff); - value >>= 8; - } - return result; -} -function unarrayifyInteger(data, offset, length) { - var result = 0; - for (var i = 0; i < length; i++) { - result = (result * 256) + data[offset + i]; - } - return result; -} -function _encode(object) { - if (Array.isArray(object)) { - var payload_1 = []; - object.forEach(function (child) { - payload_1 = payload_1.concat(_encode(child)); - }); - if (payload_1.length <= 55) { - payload_1.unshift(0xc0 + payload_1.length); - return payload_1; - } - var length_1 = arrayifyInteger(payload_1.length); - length_1.unshift(0xf7 + length_1.length); - return length_1.concat(payload_1); - } - var data = Array.prototype.slice.call(bytes_1.arrayify(object)); - if (data.length === 1 && data[0] <= 0x7f) { - return data; - } - else if (data.length <= 55) { - data.unshift(0x80 + data.length); - return data; - } - var length = arrayifyInteger(data.length); - length.unshift(0xb7 + length.length); - return length.concat(data); -} -function encode(object) { - return bytes_1.hexlify(_encode(object)); -} -exports.encode = encode; -function _decodeChildren(data, offset, childOffset, length) { - var result = []; - while (childOffset < offset + 1 + length) { - var decoded = _decode(data, childOffset); - result.push(decoded.result); - childOffset += decoded.consumed; - if (childOffset > offset + 1 + length) { - throw new Error("invalid rlp"); - } - } - return { consumed: (1 + length), result: result }; -} -// returns { consumed: number, result: Object } -function _decode(data, offset) { - if (data.length === 0) { - throw new Error("invalid rlp data"); - } - // Array with extra length prefix - if (data[offset] >= 0xf8) { - var lengthLength = data[offset] - 0xf7; - if (offset + 1 + lengthLength > data.length) { - throw new Error("too short"); - } - var length_2 = unarrayifyInteger(data, offset + 1, lengthLength); - if (offset + 1 + lengthLength + length_2 > data.length) { - throw new Error("to short"); - } - return _decodeChildren(data, offset, offset + 1 + lengthLength, lengthLength + length_2); - } - else if (data[offset] >= 0xc0) { - var length_3 = data[offset] - 0xc0; - if (offset + 1 + length_3 > data.length) { - throw new Error("invalid rlp data"); - } - return _decodeChildren(data, offset, offset + 1, length_3); - } - else if (data[offset] >= 0xb8) { - var lengthLength = data[offset] - 0xb7; - if (offset + 1 + lengthLength > data.length) { - throw new Error("invalid rlp data"); - } - var length_4 = unarrayifyInteger(data, offset + 1, lengthLength); - if (offset + 1 + lengthLength + length_4 > data.length) { - throw new Error("invalid rlp data"); - } - var result = bytes_1.hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4)); - return { consumed: (1 + lengthLength + length_4), result: result }; - } - else if (data[offset] >= 0x80) { - var length_5 = data[offset] - 0x80; - if (offset + 1 + length_5 > data.length) { - throw new Error("invlaid rlp data"); - } - var result = bytes_1.hexlify(data.slice(offset + 1, offset + 1 + length_5)); - return { consumed: (1 + length_5), result: result }; - } - return { consumed: 1, result: bytes_1.hexlify(data[offset]) }; -} -function decode(data) { - var bytes = bytes_1.arrayify(data); - var decoded = _decode(bytes, 0); - if (decoded.consumed !== bytes.length) { - throw new Error("invalid rlp data"); - } - return decoded.result; -} -exports.decode = decode; - -},{"@ethersproject/bytes":70}],115:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "sha2/5.0.0-beta.128"; - -},{}],116:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var hash = __importStar(require("hash.js")); -var bytes_1 = require("@ethersproject/bytes"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var SupportedAlgorithms; -(function (SupportedAlgorithms) { - SupportedAlgorithms["sha256"] = "sha256"; - SupportedAlgorithms["sha512"] = "sha512"; -})(SupportedAlgorithms = exports.SupportedAlgorithms || (exports.SupportedAlgorithms = {})); -; -function ripemd160(data) { - return "0x" + (hash.ripemd160().update(bytes_1.arrayify(data)).digest("hex")); -} -exports.ripemd160 = ripemd160; -function sha256(data) { - return "0x" + (hash.sha256().update(bytes_1.arrayify(data)).digest("hex")); -} -exports.sha256 = sha256; -function sha512(data) { - return "0x" + (hash.sha512().update(bytes_1.arrayify(data)).digest("hex")); -} -exports.sha512 = sha512; -function computeHmac(algorithm, key, data) { - if (!SupportedAlgorithms[algorithm]) { - logger.throwError("unsupported algorithm " + algorithm, logger_1.Logger.errors.UNSUPPORTED_OPERATION, { - operation: "hmac", - algorithm: algorithm - }); - } - return "0x" + hash.hmac(hash[algorithm], bytes_1.arrayify(key)).update(bytes_1.arrayify(data)).digest("hex"); -} -exports.computeHmac = computeHmac; - -},{"./_version":115,"@ethersproject/bytes":70,"@ethersproject/logger":91,"hash.js":21}],117:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "signing-key/5.0.0-beta.128"; - -},{}],118:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var elliptic_1 = require("elliptic"); -var bytes_1 = require("@ethersproject/bytes"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var _curve = null; -function getCurve() { - if (!_curve) { - _curve = new elliptic_1.ec("secp256k1"); - } - return _curve; -} -var SigningKey = /** @class */ (function () { - function SigningKey(privateKey) { - properties_1.defineReadOnly(this, "curve", "secp256k1"); - properties_1.defineReadOnly(this, "privateKey", bytes_1.hexlify(privateKey)); - var keyPair = getCurve().keyFromPrivate(bytes_1.arrayify(this.privateKey)); - properties_1.defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); - properties_1.defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); - properties_1.defineReadOnly(this, "_isSigningKey", true); - } - SigningKey.prototype._addPoint = function (other) { - var p0 = getCurve().keyFromPublic(bytes_1.arrayify(this.publicKey)); - var p1 = getCurve().keyFromPublic(bytes_1.arrayify(other)); - return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); - }; - SigningKey.prototype.signDigest = function (digest) { - var keyPair = getCurve().keyFromPrivate(bytes_1.arrayify(this.privateKey)); - var signature = keyPair.sign(bytes_1.arrayify(digest), { canonical: true }); - return bytes_1.splitSignature({ - recoveryParam: signature.recoveryParam, - r: bytes_1.hexZeroPad("0x" + signature.r.toString(16), 32), - s: bytes_1.hexZeroPad("0x" + signature.s.toString(16), 32), - }); - }; - SigningKey.prototype.computeSharedSecret = function (otherKey) { - var keyPair = getCurve().keyFromPrivate(bytes_1.arrayify(this.privateKey)); - var otherKeyPair = getCurve().keyFromPublic(bytes_1.arrayify(computePublicKey(otherKey))); - return bytes_1.hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); - }; - SigningKey.isSigningKey = function (value) { - return !!(value && value._isSigningKey); - }; - return SigningKey; -}()); -exports.SigningKey = SigningKey; -function recoverPublicKey(digest, signature) { - var sig = bytes_1.splitSignature(signature); - var rs = { r: bytes_1.arrayify(sig.r), s: bytes_1.arrayify(sig.s) }; - return "0x" + getCurve().recoverPubKey(bytes_1.arrayify(digest), rs, sig.recoveryParam).encode("hex", false); -} -exports.recoverPublicKey = recoverPublicKey; -function computePublicKey(key, compressed) { - var bytes = bytes_1.arrayify(key); - if (bytes.length === 32) { - var signingKey = new SigningKey(bytes); - if (compressed) { - return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); - } - return signingKey.publicKey; - } - else if (bytes.length === 33) { - if (compressed) { - return bytes_1.hexlify(bytes); - } - return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); - } - else if (bytes.length === 65) { - if (!compressed) { - return bytes_1.hexlify(bytes); - } - return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); - } - return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); -} -exports.computePublicKey = computePublicKey; - -},{"./_version":117,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96,"elliptic":6}],119:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var keccak256_1 = require("@ethersproject/keccak256"); -var sha2_1 = require("@ethersproject/sha2"); -var strings_1 = require("@ethersproject/strings"); -var regexBytes = new RegExp("^bytes([0-9]+)$"); -var regexNumber = new RegExp("^(u?int)([0-9]*)$"); -var regexArray = new RegExp("^(.*)\\[([0-9]*)\\]$"); -var Zeros = "0000000000000000000000000000000000000000000000000000000000000000"; -function _pack(type, value, isArray) { - switch (type) { - case "address": - if (isArray) { - return bytes_1.zeroPad(value, 32); - } - return bytes_1.arrayify(value); - case "string": - return strings_1.toUtf8Bytes(value); - case "bytes": - return bytes_1.arrayify(value); - case "bool": - value = (value ? "0x01" : "0x00"); - if (isArray) { - return bytes_1.zeroPad(value, 32); - } - return bytes_1.arrayify(value); - } - var match = type.match(regexNumber); - if (match) { - //let signed = (match[1] === "int") - var size = parseInt(match[2] || "256"); - if ((size % 8 != 0) || size === 0 || size > 256) { - throw new Error("invalid number type - " + type); - } - if (isArray) { - size = 256; - } - value = bignumber_1.BigNumber.from(value).toTwos(size); - return bytes_1.zeroPad(value, size / 8); - } - match = type.match(regexBytes); - if (match) { - var size = parseInt(match[1]); - if (String(size) != match[1] || size === 0 || size > 32) { - throw new Error("invalid number type - " + type); - } - if (bytes_1.arrayify(value).byteLength !== size) { - throw new Error("invalid value for " + type); - } - if (isArray) { - return bytes_1.arrayify((value + Zeros).substring(0, 66)); - } - return value; - } - match = type.match(regexArray); - if (match && Array.isArray(value)) { - var baseType_1 = match[1]; - var count = parseInt(match[2] || String(value.length)); - if (count != value.length) { - throw new Error("invalid value for " + type); - } - var result_1 = []; - value.forEach(function (value) { - result_1.push(_pack(baseType_1, value, true)); - }); - return bytes_1.concat(result_1); - } - throw new Error("unknown type - " + type); -} -// @TODO: Array Enum -function pack(types, values) { - if (types.length != values.length) { - throw new Error("type/value count mismatch"); - } - var tight = []; - types.forEach(function (type, index) { - tight.push(_pack(type, values[index])); - }); - return bytes_1.hexlify(bytes_1.concat(tight)); -} -exports.pack = pack; -function keccak256(types, values) { - return keccak256_1.keccak256(pack(types, values)); -} -exports.keccak256 = keccak256; -function sha256(types, values) { - return sha2_1.sha256(pack(types, values)); -} -exports.sha256 = sha256; - -},{"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/keccak256":89,"@ethersproject/sha2":116,"@ethersproject/strings":123}],120:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "strings/5.0.0-beta.129"; - -},{}],121:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var constants_1 = require("@ethersproject/constants"); -var bytes_1 = require("@ethersproject/bytes"); -var utf8_1 = require("./utf8"); -function formatBytes32String(text) { - // Get the bytes - var bytes = utf8_1.toUtf8Bytes(text); - // Check we have room for null-termination - if (bytes.length > 31) { - throw new Error("bytes32 string must be less than 32 bytes"); - } - // Zero-pad (implicitly null-terminates) - return bytes_1.hexlify(bytes_1.concat([bytes, constants_1.HashZero]).slice(0, 32)); -} -exports.formatBytes32String = formatBytes32String; -function parseBytes32String(bytes) { - var data = bytes_1.arrayify(bytes); - // Must be 32 bytes with a null-termination - if (data.length !== 32) { - throw new Error("invalid bytes32 - not 32 bytes long"); - } - if (data[31] !== 0) { - throw new Error("invalid bytes32 string - no null terminator"); - } - // Find the null termination - var length = 31; - while (data[length - 1] === 0) { - length--; - } - // Determine the string value - return utf8_1.toUtf8String(data.slice(0, length)); -} -exports.parseBytes32String = parseBytes32String; - -},{"./utf8":124,"@ethersproject/bytes":70,"@ethersproject/constants":71}],122:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var utf8_1 = require("./utf8"); -function bytes2(data) { - if ((data.length % 4) !== 0) { - throw new Error("bad data"); - } - var result = []; - for (var i = 0; i < data.length; i += 4) { - result.push(parseInt(data.substring(i, i + 4), 16)); - } - return result; -} -function createTable(data, func) { - if (!func) { - func = function (value) { return [parseInt(value, 16)]; }; - } - var lo = 0; - var result = {}; - data.split(",").forEach(function (pair) { - var comps = pair.split(":"); - lo += parseInt(comps[0], 16); - result[lo] = func(comps[1]); - }); - return result; -} -function createRangeTable(data) { - var hi = 0; - return data.split(",").map(function (v) { - var comps = v.split("-"); - if (comps.length === 1) { - comps[1] = "0"; - } - else if (comps[1] === "") { - comps[1] = "1"; - } - var lo = hi + parseInt(comps[0], 16); - hi = parseInt(comps[1], 16); - return { l: lo, h: hi }; - }); -} -function matchMap(value, ranges) { - var lo = 0; - for (var i = 0; i < ranges.length; i++) { - var range = ranges[i]; - lo += range.l; - if (value >= lo && value <= lo + range.h && ((value - lo) % (range.d || 1)) === 0) { - if (range.e && range.e.indexOf(value - lo) !== -1) { - continue; - } - return range; - } - } - return null; -} -var Table_A_1_ranges = createRangeTable("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"); -// @TODO: Make this relative... -var Table_B_1_flags = "ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function (v) { return parseInt(v, 16); }); -var Table_B_2_ranges = [ - { h: 25, s: 32, l: 65 }, - { h: 30, s: 32, e: [23], l: 127 }, - { h: 54, s: 1, e: [48], l: 64, d: 2 }, - { h: 14, s: 1, l: 57, d: 2 }, - { h: 44, s: 1, l: 17, d: 2 }, - { h: 10, s: 1, e: [2, 6, 8], l: 61, d: 2 }, - { h: 16, s: 1, l: 68, d: 2 }, - { h: 84, s: 1, e: [18, 24, 66], l: 19, d: 2 }, - { h: 26, s: 32, e: [17], l: 435 }, - { h: 22, s: 1, l: 71, d: 2 }, - { h: 15, s: 80, l: 40 }, - { h: 31, s: 32, l: 16 }, - { h: 32, s: 1, l: 80, d: 2 }, - { h: 52, s: 1, l: 42, d: 2 }, - { h: 12, s: 1, l: 55, d: 2 }, - { h: 40, s: 1, e: [38], l: 15, d: 2 }, - { h: 14, s: 1, l: 48, d: 2 }, - { h: 37, s: 48, l: 49 }, - { h: 148, s: 1, l: 6351, d: 2 }, - { h: 88, s: 1, l: 160, d: 2 }, - { h: 15, s: 16, l: 704 }, - { h: 25, s: 26, l: 854 }, - { h: 25, s: 32, l: 55915 }, - { h: 37, s: 40, l: 1247 }, - { h: 25, s: -119711, l: 53248 }, - { h: 25, s: -119763, l: 52 }, - { h: 25, s: -119815, l: 52 }, - { h: 25, s: -119867, e: [1, 4, 5, 7, 8, 11, 12, 17], l: 52 }, - { h: 25, s: -119919, l: 52 }, - { h: 24, s: -119971, e: [2, 7, 8, 17], l: 52 }, - { h: 24, s: -120023, e: [2, 7, 13, 15, 16, 17], l: 52 }, - { h: 25, s: -120075, l: 52 }, - { h: 25, s: -120127, l: 52 }, - { h: 25, s: -120179, l: 52 }, - { h: 25, s: -120231, l: 52 }, - { h: 25, s: -120283, l: 52 }, - { h: 25, s: -120335, l: 52 }, - { h: 24, s: -119543, e: [17], l: 56 }, - { h: 24, s: -119601, e: [17], l: 58 }, - { h: 24, s: -119659, e: [17], l: 58 }, - { h: 24, s: -119717, e: [17], l: 58 }, - { h: 24, s: -119775, e: [17], l: 58 } -]; -var Table_B_2_lut_abs = createTable("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"); -var Table_B_2_lut_rel = createTable("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"); -var Table_B_2_complex = createTable("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D", bytes2); -var Table_C_ranges = createRangeTable("80-20,2a0-,39c,32,f71,18e,7f2-f,19-7,30-4,7-5,f81-b,5,a800-20ff,4d1-1f,110,fa-6,d174-7,2e84-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,ffff-,2,1f-5f,ff7f-20001"); -function flatten(values) { - return values.reduce(function (accum, value) { - value.forEach(function (value) { accum.push(value); }); - return accum; - }, []); -} -function _nameprepTableA1(codepoint) { - return !!matchMap(codepoint, Table_A_1_ranges); -} -exports._nameprepTableA1 = _nameprepTableA1; -function _nameprepTableB2(codepoint) { - var range = matchMap(codepoint, Table_B_2_ranges); - if (range) { - return [codepoint + range.s]; - } - var codes = Table_B_2_lut_abs[codepoint]; - if (codes) { - return codes; - } - var shift = Table_B_2_lut_rel[codepoint]; - if (shift) { - return [codepoint + shift[0]]; - } - var complex = Table_B_2_complex[codepoint]; - if (complex) { - return complex; - } - return null; -} -exports._nameprepTableB2 = _nameprepTableB2; -function _nameprepTableC(codepoint) { - return !!matchMap(codepoint, Table_C_ranges); -} -exports._nameprepTableC = _nameprepTableC; -function nameprep(value) { - // This allows platforms with incomplete normalize to bypass - // it for very basic names which the built-in toLowerCase - // will certainly handle correctly - if (value.match(/^[a-z0-9-]*$/i) && value.length <= 59) { - return value.toLowerCase(); - } - // Get the code points (keeping the current normalization) - var codes = utf8_1.toUtf8CodePoints(value); - codes = flatten(codes.map(function (code) { - // Substitute Table B.1 (Maps to Nothing) - if (Table_B_1_flags.indexOf(code) >= 0) { - return []; - } - if (code >= 0xfe00 && code <= 0xfe0f) { - return []; - } - // Substitute Table B.2 (Case Folding) - var codesTableB2 = _nameprepTableB2(code); - if (codesTableB2) { - return codesTableB2; - } - // No Substitution - return [code]; - })); - // Normalize using form KC - codes = utf8_1.toUtf8CodePoints(utf8_1._toUtf8String(codes), utf8_1.UnicodeNormalizationForm.NFKC); - // Prohibit Tables C.1.2, C.2.2, C.3, C.4, C.5, C.6, C.7, C.8, C.9 - codes.forEach(function (code) { - if (_nameprepTableC(code)) { - throw new Error("STRINGPREP_CONTAINS_PROHIBITED"); - } - }); - // Prohibit Unassigned Code Points (Table A.1) - codes.forEach(function (code) { - if (_nameprepTableA1(code)) { - throw new Error("STRINGPREP_CONTAINS_UNASSIGNED"); - } - }); - // IDNA extras - var name = utf8_1._toUtf8String(codes); - // IDNA: 4.2.3.1 - if (name.substring(0, 1) === "-" || name.substring(2, 4) === "--" || name.substring(name.length - 1) === "-") { - throw new Error("invalid hyphen"); - } - // IDNA: 4.2.4 - if (name.length > 63) { - throw new Error("too long"); - } - return name; -} -exports.nameprep = nameprep; - -},{"./utf8":124}],123:[function(require,module,exports){ -"use strcit"; -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes32_1 = require("./bytes32"); -exports.formatBytes32String = bytes32_1.formatBytes32String; -exports.parseBytes32String = bytes32_1.parseBytes32String; -var idna_1 = require("./idna"); -exports.nameprep = idna_1.nameprep; -var utf8_1 = require("./utf8"); -exports._toEscapedUtf8String = utf8_1._toEscapedUtf8String; -exports.toUtf8Bytes = utf8_1.toUtf8Bytes; -exports.toUtf8CodePoints = utf8_1.toUtf8CodePoints; -exports.toUtf8String = utf8_1.toUtf8String; -exports.UnicodeNormalizationForm = utf8_1.UnicodeNormalizationForm; - -},{"./bytes32":121,"./idna":122,"./utf8":124}],124:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var bytes_1 = require("@ethersproject/bytes"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -/////////////////////////////// -var UnicodeNormalizationForm; -(function (UnicodeNormalizationForm) { - UnicodeNormalizationForm["current"] = ""; - UnicodeNormalizationForm["NFC"] = "NFC"; - UnicodeNormalizationForm["NFD"] = "NFD"; - UnicodeNormalizationForm["NFKC"] = "NFKC"; - UnicodeNormalizationForm["NFKD"] = "NFKD"; -})(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {})); -; -// http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 -function getUtf8CodePoints(bytes, ignoreErrors) { - bytes = bytes_1.arrayify(bytes); - var result = []; - var i = 0; - // Invalid bytes are ignored - while (i < bytes.length) { - var c = bytes[i++]; - // 0xxx xxxx - if (c >> 7 === 0) { - result.push(c); - continue; - } - // Multibyte; how many bytes left for this character? - var extraLength = null; - var overlongMask = null; - // 110x xxxx 10xx xxxx - if ((c & 0xe0) === 0xc0) { - extraLength = 1; - overlongMask = 0x7f; - // 1110 xxxx 10xx xxxx 10xx xxxx - } - else if ((c & 0xf0) === 0xe0) { - extraLength = 2; - overlongMask = 0x7ff; - // 1111 0xxx 10xx xxxx 10xx xxxx 10xx xxxx - } - else if ((c & 0xf8) === 0xf0) { - extraLength = 3; - overlongMask = 0xffff; - } - else { - if (!ignoreErrors) { - if ((c & 0xc0) === 0x80) { - throw new Error("invalid utf8 byte sequence; unexpected continuation byte"); - } - throw new Error("invalid utf8 byte sequence; invalid prefix"); - } - continue; - } - // Do we have enough bytes in our data? - if (i + extraLength > bytes.length) { - if (!ignoreErrors) { - throw new Error("invalid utf8 byte sequence; too short"); - } - // If there is an invalid unprocessed byte, skip continuation bytes - for (; i < bytes.length; i++) { - if (bytes[i] >> 6 !== 0x02) { - break; - } - } - continue; - } - // Remove the length prefix from the char - var res = c & ((1 << (8 - extraLength - 1)) - 1); - for (var j = 0; j < extraLength; j++) { - var nextChar = bytes[i]; - // Invalid continuation byte - if ((nextChar & 0xc0) != 0x80) { - res = null; - break; - } - ; - res = (res << 6) | (nextChar & 0x3f); - i++; - } - if (res === null) { - if (!ignoreErrors) { - throw new Error("invalid utf8 byte sequence; invalid continuation byte"); - } - continue; - } - // Check for overlong seuences (more bytes than needed) - if (res <= overlongMask) { - if (!ignoreErrors) { - throw new Error("invalid utf8 byte sequence; overlong"); - } - continue; - } - // Maximum code point - if (res > 0x10ffff) { - if (!ignoreErrors) { - throw new Error("invalid utf8 byte sequence; out-of-range"); - } - continue; - } - // Reserved for UTF-16 surrogate halves - if (res >= 0xd800 && res <= 0xdfff) { - if (!ignoreErrors) { - throw new Error("invalid utf8 byte sequence; utf-16 surrogate"); - } - continue; - } - result.push(res); - } - return result; -} -// http://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array -function toUtf8Bytes(str, form) { - if (form === void 0) { form = UnicodeNormalizationForm.current; } - if (form != UnicodeNormalizationForm.current) { - logger.checkNormalize(); - str = str.normalize(form); - } - var result = []; - for (var i = 0; i < str.length; i++) { - var c = str.charCodeAt(i); - if (c < 0x80) { - result.push(c); - } - else if (c < 0x800) { - result.push((c >> 6) | 0xc0); - result.push((c & 0x3f) | 0x80); - } - else if ((c & 0xfc00) == 0xd800) { - i++; - var c2 = str.charCodeAt(i); - if (i >= str.length || (c2 & 0xfc00) !== 0xdc00) { - throw new Error("invalid utf-8 string"); - } - // Surrogate Pair - c = 0x10000 + ((c & 0x03ff) << 10) + (c2 & 0x03ff); - result.push((c >> 18) | 0xf0); - result.push(((c >> 12) & 0x3f) | 0x80); - result.push(((c >> 6) & 0x3f) | 0x80); - result.push((c & 0x3f) | 0x80); - } - else { - result.push((c >> 12) | 0xe0); - result.push(((c >> 6) & 0x3f) | 0x80); - result.push((c & 0x3f) | 0x80); - } - } - return bytes_1.arrayify(result); -} -exports.toUtf8Bytes = toUtf8Bytes; -; -function escapeChar(value) { - var hex = ("0000" + value.toString(16)); - return "\\u" + hex.substring(hex.length - 4); -} -function _toEscapedUtf8String(bytes, ignoreErrors) { - return '"' + getUtf8CodePoints(bytes, ignoreErrors).map(function (codePoint) { - if (codePoint < 256) { - switch (codePoint) { - case 8: return "\\b"; - case 9: return "\\t"; - case 10: return "\\n"; - case 13: return "\\r"; - case 34: return "\\\""; - case 92: return "\\\\"; - } - if (codePoint >= 32 && codePoint < 127) { - return String.fromCharCode(codePoint); - } - } - if (codePoint <= 0xffff) { - return escapeChar(codePoint); - } - codePoint -= 0x10000; - return escapeChar(((codePoint >> 10) & 0x3ff) + 0xd800) + escapeChar((codePoint & 0x3ff) + 0xdc00); - }).join("") + '"'; -} -exports._toEscapedUtf8String = _toEscapedUtf8String; -function _toUtf8String(codePoints) { - return codePoints.map(function (codePoint) { - if (codePoint <= 0xffff) { - return String.fromCharCode(codePoint); - } - codePoint -= 0x10000; - return String.fromCharCode((((codePoint >> 10) & 0x3ff) + 0xd800), ((codePoint & 0x3ff) + 0xdc00)); - }).join(""); -} -exports._toUtf8String = _toUtf8String; -function toUtf8String(bytes, ignoreErrors) { - return _toUtf8String(getUtf8CodePoints(bytes, ignoreErrors)); -} -exports.toUtf8String = toUtf8String; -function toUtf8CodePoints(str, form) { - if (form === void 0) { form = UnicodeNormalizationForm.current; } - return getUtf8CodePoints(toUtf8Bytes(str, form)); -} -exports.toUtf8CodePoints = toUtf8CodePoints; - -},{"./_version":120,"@ethersproject/bytes":70,"@ethersproject/logger":91}],125:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "transactions/5.0.0-beta.127"; - -},{}],126:[function(require,module,exports){ -"use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var address_1 = require("@ethersproject/address"); -var bignumber_1 = require("@ethersproject/bignumber"); -var bytes_1 = require("@ethersproject/bytes"); -var constants_1 = require("@ethersproject/constants"); -var keccak256_1 = require("@ethersproject/keccak256"); -var properties_1 = require("@ethersproject/properties"); -var RLP = __importStar(require("@ethersproject/rlp")); -var signing_key_1 = require("@ethersproject/signing-key"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -/////////////////////////////// -function handleAddress(value) { - if (value === "0x") { - return null; - } - return address_1.getAddress(value); -} -function handleNumber(value) { - if (value === "0x") { - return constants_1.Zero; - } - return bignumber_1.BigNumber.from(value); -} -var transactionFields = [ - { name: "nonce", maxLength: 32 }, - { name: "gasPrice", maxLength: 32 }, - { name: "gasLimit", maxLength: 32 }, - { name: "to", length: 20 }, - { name: "value", maxLength: 32 }, - { name: "data" }, -]; -var allowedTransactionKeys = { - chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true -}; -function computeAddress(key) { - var publicKey = signing_key_1.computePublicKey(key); - return address_1.getAddress(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.hexDataSlice(publicKey, 1)), 12)); -} -exports.computeAddress = computeAddress; -function recoverAddress(digest, signature) { - return computeAddress(signing_key_1.recoverPublicKey(bytes_1.arrayify(digest), signature)); -} -exports.recoverAddress = recoverAddress; -function serialize(transaction, signature) { - properties_1.checkProperties(transaction, allowedTransactionKeys); - var raw = []; - transactionFields.forEach(function (fieldInfo) { - var value = transaction[fieldInfo.name] || ([]); - value = bytes_1.arrayify(bytes_1.hexlify(value)); - // Fixed-width field - if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { - logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); - } - // Variable-width (with a maximum) - if (fieldInfo.maxLength) { - value = bytes_1.stripZeros(value); - if (value.length > fieldInfo.maxLength) { - logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); - } - } - raw.push(bytes_1.hexlify(value)); - }); - if (transaction.chainId != null && transaction.chainId !== 0) { - raw.push(bytes_1.hexlify(transaction.chainId)); - raw.push("0x"); - raw.push("0x"); - } - var unsignedTransaction = RLP.encode(raw); - // Requesting an unsigned transation - if (!signature) { - return unsignedTransaction; - } - // The splitSignature will ensure the transaction has a recoveryParam in the - // case that the signTransaction function only adds a v. - var sig = bytes_1.splitSignature(signature); - // We pushed a chainId and null r, s on for hashing only; remove those - var v = 27 + sig.recoveryParam; - if (raw.length === 9) { - raw.pop(); - raw.pop(); - raw.pop(); - v += transaction.chainId * 2 + 8; - } - raw.push(bytes_1.hexlify(v)); - raw.push(bytes_1.stripZeros(bytes_1.arrayify(sig.r))); - raw.push(bytes_1.stripZeros(bytes_1.arrayify(sig.s))); - return RLP.encode(raw); -} -exports.serialize = serialize; -function parse(rawTransaction) { - var transaction = RLP.decode(rawTransaction); - if (transaction.length !== 9 && transaction.length !== 6) { - logger.throwArgumentError("invalid raw transaction", "rawTransactin", rawTransaction); - } - var tx = { - nonce: handleNumber(transaction[0]).toNumber(), - gasPrice: handleNumber(transaction[1]), - gasLimit: handleNumber(transaction[2]), - to: handleAddress(transaction[3]), - value: handleNumber(transaction[4]), - data: transaction[5], - chainId: 0 - }; - // Legacy unsigned transaction - if (transaction.length === 6) { - return tx; - } - try { - tx.v = bignumber_1.BigNumber.from(transaction[6]).toNumber(); - } - catch (error) { - console.log(error); - return tx; - } - tx.r = bytes_1.hexZeroPad(transaction[7], 32); - tx.s = bytes_1.hexZeroPad(transaction[8], 32); - if (bignumber_1.BigNumber.from(tx.r).isZero() && bignumber_1.BigNumber.from(tx.s).isZero()) { - // EIP-155 unsigned transaction - tx.chainId = tx.v; - tx.v = 0; - } - else { - // Signed Tranasaction - tx.chainId = Math.floor((tx.v - 35) / 2); - if (tx.chainId < 0) { - tx.chainId = 0; - } - var recoveryParam = tx.v - 27; - var raw = transaction.slice(0, 6); - if (tx.chainId !== 0) { - raw.push(bytes_1.hexlify(tx.chainId)); - raw.push("0x"); - raw.push("0x"); - recoveryParam -= tx.chainId * 2 + 8; - } - var digest = keccak256_1.keccak256(RLP.encode(raw)); - try { - tx.from = recoverAddress(digest, { r: bytes_1.hexlify(tx.r), s: bytes_1.hexlify(tx.s), recoveryParam: recoveryParam }); - } - catch (error) { - console.log(error); - } - tx.hash = keccak256_1.keccak256(rawTransaction); - } - return tx; -} -exports.parse = parse; - -},{"./_version":125,"@ethersproject/address":62,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/constants":71,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/rlp":114,"@ethersproject/signing-key":118}],127:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "units/5.0.0-beta.126"; - -},{}],128:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var fixednumber_1 = require("@ethersproject/bignumber/fixednumber"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -var names = [ - "wei", - "kwei", - "mwei", - "gwei", - "szabo", - "finney", - "ether", -]; -// Some environments have issues with RegEx that contain back-tracking, so we cannot -// use them. -function commify(value) { - var comps = String(value).split("."); - if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { - logger.throwArgumentError("invalid value", "value", value); - } - // Make sure we have at least one whole digit (0 if none) - var whole = comps[0]; - var negative = ""; - if (whole.substring(0, 1) === "-") { - negative = "-"; - whole = whole.substring(1); - } - // Make sure we have at least 1 whole digit with no leading zeros - while (whole.substring(0, 1) === "0") { - whole = whole.substring(1); - } - if (whole === "") { - whole = "0"; - } - var suffix = ""; - if (comps.length === 2) { - suffix = "." + (comps[1] || "0"); - } - var formatted = []; - while (whole.length) { - if (whole.length <= 3) { - formatted.unshift(whole); - break; - } - else { - var index = whole.length - 3; - formatted.unshift(whole.substring(index)); - whole = whole.substring(0, index); - } - } - return negative + formatted.join(",") + suffix; -} -exports.commify = commify; -function formatUnits(value, unitName) { - if (typeof (unitName) === "string") { - var index = names.indexOf(unitName); - if (index !== -1) { - unitName = 3 * index; - } - } - return fixednumber_1.formatFixed(value, (unitName != null) ? unitName : 18); -} -exports.formatUnits = formatUnits; -function parseUnits(value, unitName) { - if (typeof (unitName) === "string") { - var index = names.indexOf(unitName); - if (index !== -1) { - unitName = 3 * index; - } - } - return fixednumber_1.parseFixed(value, (unitName != null) ? unitName : 18); -} -exports.parseUnits = parseUnits; -function formatEther(wei) { - return formatUnits(wei, 18); -} -exports.formatEther = formatEther; -function parseEther(ether) { - return parseUnits(ether, 18); -} -exports.parseEther = parseEther; - -},{"./_version":127,"@ethersproject/bignumber/fixednumber":67,"@ethersproject/logger":91}],129:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "wallet/5.0.0-beta.129"; - -},{}],130:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var address_1 = require("@ethersproject/address"); -var abstract_provider_1 = require("@ethersproject/abstract-provider"); -var abstract_signer_1 = require("@ethersproject/abstract-signer"); -var bytes_1 = require("@ethersproject/bytes"); -var hash_1 = require("@ethersproject/hash"); -var hdnode_1 = require("@ethersproject/hdnode"); -var keccak256_1 = require("@ethersproject/keccak256"); -var properties_1 = require("@ethersproject/properties"); -var random_1 = require("@ethersproject/random"); -var signing_key_1 = require("@ethersproject/signing-key"); -var json_wallets_1 = require("@ethersproject/json-wallets"); -var transactions_1 = require("@ethersproject/transactions"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -function isAccount(value) { - return (value != null && bytes_1.isHexString(value.privateKey, 32) && value.address != null); -} -var Wallet = /** @class */ (function (_super) { - __extends(Wallet, _super); - function Wallet(privateKey, provider) { - var _newTarget = this.constructor; - var _this = this; - logger.checkNew(_newTarget, Wallet); - _this = _super.call(this) || this; - if (isAccount(privateKey)) { - var signingKey_1 = new signing_key_1.SigningKey(privateKey.privateKey); - properties_1.defineReadOnly(_this, "_signingKey", function () { return signingKey_1; }); - properties_1.defineReadOnly(_this, "address", transactions_1.computeAddress(_this.publicKey)); - if (_this.address !== address_1.getAddress(privateKey.address)) { - logger.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); - } - if (privateKey.mnemonic != null) { - var mnemonic_1 = privateKey.mnemonic; - var path = privateKey.path || hdnode_1.defaultPath; - properties_1.defineReadOnly(_this, "_mnemonic", function () { return mnemonic_1; }); - properties_1.defineReadOnly(_this, "path", privateKey.path); - var node = hdnode_1.HDNode.fromMnemonic(mnemonic_1).derivePath(path); - if (transactions_1.computeAddress(node.privateKey) !== _this.address) { - logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); - } - } - else { - properties_1.defineReadOnly(_this, "_mnemonic", function () { return null; }); - properties_1.defineReadOnly(_this, "path", null); - } - } - else { - if (signing_key_1.SigningKey.isSigningKey(privateKey)) { - if (privateKey.curve !== "secp256k1") { - logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); - } - properties_1.defineReadOnly(_this, "_signingKey", function () { return privateKey; }); - } - else { - var signingKey_2 = new signing_key_1.SigningKey(privateKey); - properties_1.defineReadOnly(_this, "_signingKey", function () { return signingKey_2; }); - } - properties_1.defineReadOnly(_this, "_mnemonic", function () { return null; }); - properties_1.defineReadOnly(_this, "path", null); - properties_1.defineReadOnly(_this, "address", transactions_1.computeAddress(_this.publicKey)); - } - if (provider && !abstract_provider_1.Provider.isProvider(provider)) { - logger.throwArgumentError("invalid provider", "provider", provider); - } - properties_1.defineReadOnly(_this, "provider", provider || null); - return _this; - } - Object.defineProperty(Wallet.prototype, "mnemonic", { - get: function () { return this._mnemonic(); }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Wallet.prototype, "privateKey", { - get: function () { return this._signingKey().privateKey; }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Wallet.prototype, "publicKey", { - get: function () { return this._signingKey().publicKey; }, - enumerable: true, - configurable: true - }); - Wallet.prototype.getAddress = function () { - return Promise.resolve(this.address); - }; - Wallet.prototype.connect = function (provider) { - return new Wallet(this, provider); - }; - Wallet.prototype.signTransaction = function (transaction) { - var _this = this; - return properties_1.resolveProperties(transaction).then(function (tx) { - if (tx.from != null) { - if (address_1.getAddress(tx.from) !== _this.address) { - throw new Error("transaction from address mismatch"); - } - delete tx.from; - } - var signature = _this._signingKey().signDigest(keccak256_1.keccak256(transactions_1.serialize(tx))); - return transactions_1.serialize(tx, signature); - }); - }; - Wallet.prototype.signMessage = function (message) { - return Promise.resolve(bytes_1.joinSignature(this._signingKey().signDigest(hash_1.hashMessage(message)))); - }; - Wallet.prototype.encrypt = function (password, options, progressCallback) { - if (typeof (options) === "function" && !progressCallback) { - progressCallback = options; - options = {}; - } - if (progressCallback && typeof (progressCallback) !== "function") { - throw new Error("invalid callback"); - } - if (!options) { - options = {}; - } - return json_wallets_1.encryptKeystore(this, password, options, progressCallback); - }; - /** - * Static methods to create Wallet instances. - */ - Wallet.createRandom = function (options) { - var entropy = random_1.randomBytes(16); - if (!options) { - options = {}; - } - if (options.extraEntropy) { - entropy = bytes_1.arrayify(bytes_1.hexDataSlice(keccak256_1.keccak256(bytes_1.concat([entropy, options.extraEntropy])), 0, 16)); - } - var mnemonic = hdnode_1.entropyToMnemonic(entropy, options.locale); - return Wallet.fromMnemonic(mnemonic, options.path, options.locale); - }; - Wallet.fromEncryptedJson = function (json, password, progressCallback) { - return json_wallets_1.decryptJsonWallet(json, password, progressCallback).then(function (account) { - return new Wallet(account); - }); - }; - Wallet.fromMnemonic = function (mnemonic, path, wordlist) { - if (!path) { - path = hdnode_1.defaultPath; - } - return new Wallet(hdnode_1.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); - }; - return Wallet; -}(abstract_signer_1.Signer)); -exports.Wallet = Wallet; -function verifyMessage(message, signature) { - return transactions_1.recoverAddress(hash_1.hashMessage(message), signature); -} -exports.verifyMessage = verifyMessage; - -},{"./_version":129,"@ethersproject/abstract-provider":58,"@ethersproject/abstract-signer":60,"@ethersproject/address":62,"@ethersproject/bytes":70,"@ethersproject/hash":80,"@ethersproject/hdnode":82,"@ethersproject/json-wallets":85,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/random":112,"@ethersproject/signing-key":118,"@ethersproject/transactions":126}],131:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "web/5.0.0-beta.128"; - -},{}],132:[function(require,module,exports){ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var base64_1 = require("@ethersproject/base64"); -var properties_1 = require("@ethersproject/properties"); -var strings_1 = require("@ethersproject/strings"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -function fetchJson(connection, json, processFunc) { - var headers = {}; - var url = null; - // @TODO: Allow ConnectionInfo to override some of these values - var options = { - method: "GET", - mode: "cors", - cache: "no-cache", - credentials: "same-origin", - redirect: "follow", - referrer: "client", - }; - var timeout = 2 * 60 * 1000; - if (typeof (connection) === "string") { - url = connection; - } - else if (typeof (connection) === "object") { - if (connection == null || connection.url == null) { - logger.throwArgumentError("missing URL", "connection.url", connection); - } - url = connection.url; - if (typeof (connection.timeout) === "number" && connection.timeout > 0) { - timeout = connection.timeout; - } - if (connection.headers) { - for (var key in connection.headers) { - headers[key.toLowerCase()] = { key: key, value: String(connection.headers[key]) }; - } - } - if (connection.user != null && connection.password != null) { - if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) { - logger.throwError("basic authentication requires a secure https url", logger_1.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" }); - } - var authorization = connection.user + ":" + connection.password; - headers["authorization"] = { - key: "Authorization", - value: "Basic " + base64_1.encode(strings_1.toUtf8Bytes(authorization)) - }; - } - } - return new Promise(function (resolve, reject) { - var timer = null; - if (timeout) { - timer = setTimeout(function () { - if (timer == null) { - return; - } - timer = null; - reject(logger.makeError("timeout", logger_1.Logger.errors.TIMEOUT, { timeout: timeout })); - }, timeout); - } - var cancelTimeout = function () { - if (timer == null) { - return; - } - clearTimeout(timer); - timer = null; - }; - if (json) { - options.method = "POST"; - options.body = json; - headers["content-type"] = { key: "Content-Type", value: "application/json" }; - } - var flatHeaders = {}; - Object.keys(headers).forEach(function (key) { - var header = headers[key]; - flatHeaders[header.key] = header.value; - }); - options.headers = flatHeaders; - return cross_fetch_1.default(url, options).then(function (response) { - return response.text().then(function (body) { - if (!response.ok) { - logger.throwError("bad response", logger_1.Logger.errors.SERVER_ERROR, { - status: response.status, - body: body, - type: response.type, - url: response.url - }); - } - return body; - }); - }).then(function (text) { - var json = null; - try { - json = JSON.parse(text); - } - catch (error) { - logger.throwError("invalid JSON", logger_1.Logger.errors.SERVER_ERROR, { - body: text, - error: error, - url: url - }); - } - if (processFunc) { - try { - json = processFunc(json); - } - catch (error) { - logger.throwError("processing response error", logger_1.Logger.errors.SERVER_ERROR, { - body: json, - error: error - }); - } - } - return json; - }, function (error) { - throw error; - }).then(function (result) { - cancelTimeout(); - resolve(result); - }, function (error) { - cancelTimeout(); - reject(error); - }); - }); -} -exports.fetchJson = fetchJson; -function poll(func, options) { - if (!options) { - options = {}; - } - options = properties_1.shallowCopy(options); - if (options.floor == null) { - options.floor = 0; - } - if (options.ceiling == null) { - options.ceiling = 10000; - } - if (options.interval == null) { - options.interval = 250; - } - return new Promise(function (resolve, reject) { - var timer = null; - var done = false; - // Returns true if cancel was successful. Unsuccessful cancel means we're already done. - var cancel = function () { - if (done) { - return false; - } - done = true; - if (timer) { - clearTimeout(timer); - } - return true; - }; - if (options.timeout) { - timer = setTimeout(function () { - if (cancel()) { - reject(new Error("timeout")); - } - }, options.timeout); - } - var retryLimit = options.retryLimit; - var attempt = 0; - function check() { - return func().then(function (result) { - // If we have a result, or are allowed null then we're done - if (result !== undefined) { - if (cancel()) { - resolve(result); - } - } - else if (options.onceBlock) { - options.onceBlock.once("block", check); - // Otherwise, exponential back-off (up to 10s) our next request - } - else if (!done) { - attempt++; - if (attempt > retryLimit) { - if (cancel()) { - reject(new Error("retry limit reached")); - } - return; - } - var timeout = options.interval * parseInt(String(Math.random() * Math.pow(2, attempt))); - if (timeout < options.floor) { - timeout = options.floor; - } - if (timeout > options.ceiling) { - timeout = options.ceiling; - } - setTimeout(check, timeout); - } - return null; - }, function (error) { - if (cancel()) { - reject(error); - } - }); - } - check(); - }); -} -exports.poll = poll; - -},{"./_version":131,"@ethersproject/base64":63,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/strings":123,"cross-fetch":5}],133:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = "wordlists/5.0.0-beta.127"; - -},{}],134:[function(require,module,exports){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// Wordlists -// See: https://github.com/bitcoin/bips/blob/master/bip-0039/bip-0039-wordlists.md -var wordlist_1 = require("./wordlist"); -exports.Wordlist = wordlist_1.Wordlist; -var lang_en_1 = require("./lang-en"); -var wordlists = { en: lang_en_1.langEn }; -exports.wordlists = wordlists; - -},{"./lang-en":135,"./wordlist":136}],135:[function(require,module,exports){ -"use strict"; -var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; - return function (d, b) { - extendStatics(d, b); - function __() { this.constructor = d; } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); - }; -})(); -Object.defineProperty(exports, "__esModule", { value: true }); -var wordlist_1 = require("./wordlist"); -var words = "AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo"; -var wordlist = null; -function loadWords(lang) { - if (wordlist != null) { - return; - } - wordlist = words.replace(/([A-Z])/g, " $1").toLowerCase().substring(1).split(" "); - if (wordlist_1.check(lang) !== "0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60") { - wordlist = null; - throw new Error("BIP39 Wordlist for en (English) FAILED"); - } -} -var LangEn = /** @class */ (function (_super) { - __extends(LangEn, _super); - function LangEn() { - return _super.call(this, "en") || this; - } - LangEn.prototype.getWord = function (index) { - loadWords(this); - return wordlist[index]; - }; - LangEn.prototype.getWordIndex = function (word) { - loadWords(this); - return wordlist.indexOf(word); - }; - return LangEn; -}(wordlist_1.Wordlist)); -var langEn = new LangEn(); -exports.langEn = langEn; -wordlist_1.register(langEn); - -},{"./wordlist":136}],136:[function(require,module,exports){ -(function (global){ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// This gets overriddenby gulp during bip39-XX -var exportWordlist = false; -var hash_1 = require("@ethersproject/hash"); -var properties_1 = require("@ethersproject/properties"); -var logger_1 = require("@ethersproject/logger"); -var _version_1 = require("./_version"); -var logger = new logger_1.Logger(_version_1.version); -function check(wordlist) { - var words = []; - for (var i = 0; i < 2048; i++) { - var word = wordlist.getWord(i); - if (i !== wordlist.getWordIndex(word)) { - return "0x"; - } - words.push(word); - } - return hash_1.id(words.join("\n") + "\n"); -} -exports.check = check; -var Wordlist = /** @class */ (function () { - function Wordlist(locale) { - var _newTarget = this.constructor; - logger.checkAbstract(_newTarget, Wordlist); - properties_1.defineReadOnly(this, "locale", locale); - } - // Subclasses may override this - Wordlist.prototype.split = function (mnemonic) { - return mnemonic.toLowerCase().split(/ +/g); - }; - // Subclasses may override this - Wordlist.prototype.join = function (words) { - return words.join(" "); - }; - return Wordlist; -}()); -exports.Wordlist = Wordlist; -function register(lang, name) { - if (!name) { - name = lang.locale; - } - if (exportWordlist) { - var g = global; - if (!(g.wordlists)) { - properties_1.defineReadOnly(g, "wordlists", {}); - } - if (!g.wordlists[name]) { - properties_1.defineReadOnly(g.wordlists, name, lang); - } - if (g.ethers && g.ethers.wordlists) { - if (!g.ethers.wordlists[name]) { - properties_1.defineReadOnly(g.ethers.wordlists, name, lang); - } - } - } -} -exports.register = register; - -}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./_version":133,"@ethersproject/hash":80,"@ethersproject/logger":91,"@ethersproject/properties":96}]},{},[76])(76) -}); diff --git a/packages/ethers/dist/ethers.min.js b/packages/ethers/dist/ethers.min.js deleted file mode 100644 index ece31f82c..000000000 --- a/packages/ethers/dist/ethers.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).ethers=e()}}(function(){return function(){return function e(t,r,n){function i(s,a){if(!r[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=r[s]={exports:{}};t[s][0].call(h.exports,function(e){return i(t[s][1][e]||e)},h,h.exports,e,t,r,n)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s255)return!1;return!0}function o(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!i(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(n(e.length)&&i(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function s(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var u=function(){return{toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}}}(),c=function(){var e="0123456789abcdef";return{toBytes:function(e){for(var t=[],r=0;r>4]+e[15&i])}return r.join("")}}}(),h={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],l=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],g=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],m=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],k=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function S(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var s,a=0,u=i;u>16&255]<<24^l[s>>8&255]<<16^l[255&s]<<8^l[s>>24&255]^f[a]<<24,a+=1,8!=i)for(t=1;t>8&255]<<8^l[s>>16&255]<<16^l[s>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[c][d]=o[t],this._Kd[e-c][d]=o[t++],u++}for(var c=1;c>24&255]^P[s>>16&255]^k[s>>8&255]^A[255&s]},M.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=S(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var o=1;o>24&255]^g[n[(i+1)%4]>>16&255]^m[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[o][i];n=r.slice()}var a,u=s(16);for(i=0;i<4;i++)a=this._Ke[t][i],u[4*i]=255&(l[n[i]>>24&255]^a>>24),u[4*i+1]=255&(l[n[(i+1)%4]>>16&255]^a>>16),u[4*i+2]=255&(l[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(l[255&n[(i+3)%4]]^a);return u},M.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=S(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var o=1;o>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[o][i];n=r.slice()}var a,u=s(16);for(i=0;i<4;i++)a=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^a>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return u};var j=function(e){if(!(this instanceof j))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new M(e)};j.prototype.encrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=s(e.length),r=s(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},T.prototype.setBytes=function(e){if(16!=(e=o(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},T.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var R=function(e,t){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof T||(t=new T(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new M(e)};R.prototype.encrypt=function(e){for(var t=o(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),s=t;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,s=o%n,a=Math.min(o,o-s)+r,c=0,h=r;h1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],h=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],s=i*o,a=67108863&s,u=s/67108864|0;r.words[0]=a;for(var c=1;c>>26,f=67108863&u,l=Math.min(c,t.length-1),d=Math.max(0,c-e.length+1);d<=l;d++){var p=c-d|0;h+=(s=(i=0|e.words[p])*(o=0|t.words[d])+f)/67108864|0,f=67108863&s}r.words[c]=0|f,u=0|h}return 0!==u?r.words[c]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(e=e||10,t=0|t||1,16===e||"hex"===e){r="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var l=h[e],d=f[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?g+r:c[l-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==s),this.toArrayLike(s,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var s,a,u="le"===t,c=new e(o),h=this.clone();if(u){for(a=0;!h.isZero();a++)s=h.andln(255),h.iushrn(8),c[a]=s;for(;a=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==o&&s>26,this.words[s]=67108863&t;if(0===o&&s>>13,d=0|s[1],p=8191&d,g=d>>>13,m=0|s[2],y=8191&m,v=m>>>13,b=0|s[3],w=8191&b,_=b>>>13,E=0|s[4],P=8191&E,k=E>>>13,A=0|s[5],S=8191&A,M=A>>>13,j=0|s[6],x=8191&j,O=j>>>13,N=0|s[7],T=8191&N,R=N>>>13,C=0|s[8],B=8191&C,I=C>>>13,F=0|s[9],L=8191&F,D=F>>>13,U=0|a[0],z=8191&U,H=U>>>13,K=0|a[1],q=8191&K,W=K>>>13,G=0|a[2],V=8191&G,J=G>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,ee=Q>>>13,te=0|a[5],re=8191&te,ne=te>>>13,ie=0|a[6],oe=8191&ie,se=ie>>>13,ae=0|a[7],ue=8191&ae,ce=ae>>>13,he=0|a[8],fe=8191&he,le=he>>>13,de=0|a[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(c+(n=Math.imul(f,z))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(l,z)|0))<<13)|0;c=((o=Math.imul(l,H))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(g,z)|0,o=Math.imul(g,H);var ye=(c+(n=n+Math.imul(f,q)|0)|0)+((8191&(i=(i=i+Math.imul(f,W)|0)+Math.imul(l,q)|0))<<13)|0;c=((o=o+Math.imul(l,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(g,q)|0,o=o+Math.imul(g,W)|0;var ve=(c+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(l,V)|0))<<13)|0;c=((o=o+Math.imul(l,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(g,V)|0,o=o+Math.imul(g,J)|0;var be=(c+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(l,X)|0))<<13)|0;c=((o=o+Math.imul(l,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(g,X)|0,o=o+Math.imul(g,$)|0;var we=(c+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,ee)|0)+Math.imul(l,Y)|0))<<13)|0;c=((o=o+Math.imul(l,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(S,z),i=(i=Math.imul(S,H))+Math.imul(M,z)|0,o=Math.imul(M,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,Y)|0,o=o+Math.imul(g,ee)|0;var _e=(c+(n=n+Math.imul(f,re)|0)|0)+((8191&(i=(i=i+Math.imul(f,ne)|0)+Math.imul(l,re)|0))<<13)|0;c=((o=o+Math.imul(l,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(x,z),i=(i=Math.imul(x,H))+Math.imul(O,z)|0,o=Math.imul(O,H),n=n+Math.imul(S,q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(M,q)|0,o=o+Math.imul(M,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(c+(n=n+Math.imul(f,oe)|0)|0)+((8191&(i=(i=i+Math.imul(f,se)|0)+Math.imul(l,oe)|0))<<13)|0;c=((o=o+Math.imul(l,se)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(T,z),i=(i=Math.imul(T,H))+Math.imul(R,z)|0,o=Math.imul(R,H),n=n+Math.imul(x,q)|0,i=(i=i+Math.imul(x,W)|0)+Math.imul(O,q)|0,o=o+Math.imul(O,W)|0,n=n+Math.imul(S,V)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(M,V)|0,o=o+Math.imul(M,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,se)|0;var Pe=(c+(n=n+Math.imul(f,ue)|0)|0)+((8191&(i=(i=i+Math.imul(f,ce)|0)+Math.imul(l,ue)|0))<<13)|0;c=((o=o+Math.imul(l,ce)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(B,z),i=(i=Math.imul(B,H))+Math.imul(I,z)|0,o=Math.imul(I,H),n=n+Math.imul(T,q)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(x,V)|0,i=(i=i+Math.imul(x,J)|0)+Math.imul(O,V)|0,o=o+Math.imul(O,J)|0,n=n+Math.imul(S,X)|0,i=(i=i+Math.imul(S,$)|0)+Math.imul(M,X)|0,o=o+Math.imul(M,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,se)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,se)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,ce)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,ce)|0;var ke=(c+(n=n+Math.imul(f,fe)|0)|0)+((8191&(i=(i=i+Math.imul(f,le)|0)+Math.imul(l,fe)|0))<<13)|0;c=((o=o+Math.imul(l,le)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(L,z),i=(i=Math.imul(L,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(B,q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(I,q)|0,o=o+Math.imul(I,W)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(x,X)|0,i=(i=i+Math.imul(x,$)|0)+Math.imul(O,X)|0,o=o+Math.imul(O,$)|0,n=n+Math.imul(S,Y)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(M,Y)|0,o=o+Math.imul(M,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,se)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,se)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,ce)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,ce)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,le)|0)+Math.imul(g,fe)|0,o=o+Math.imul(g,le)|0;var Ae=(c+(n=n+Math.imul(f,pe)|0)|0)+((8191&(i=(i=i+Math.imul(f,ge)|0)+Math.imul(l,pe)|0))<<13)|0;c=((o=o+Math.imul(l,ge)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(L,q),i=(i=Math.imul(L,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(B,V)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(I,V)|0,o=o+Math.imul(I,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,$)|0,n=n+Math.imul(x,Y)|0,i=(i=i+Math.imul(x,ee)|0)+Math.imul(O,Y)|0,o=o+Math.imul(O,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(M,re)|0,o=o+Math.imul(M,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,se)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,se)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,ce)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,ce)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,le)|0)+Math.imul(v,fe)|0,o=o+Math.imul(v,le)|0;var Se=(c+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;c=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(B,X)|0,i=(i=i+Math.imul(B,$)|0)+Math.imul(I,X)|0,o=o+Math.imul(I,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(x,re)|0,i=(i=i+Math.imul(x,ne)|0)+Math.imul(O,re)|0,o=o+Math.imul(O,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,se)|0)+Math.imul(M,oe)|0,o=o+Math.imul(M,se)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,ce)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,ce)|0,n=n+Math.imul(w,fe)|0,i=(i=i+Math.imul(w,le)|0)+Math.imul(_,fe)|0,o=o+Math.imul(_,le)|0;var Me=(c+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,ge)|0)+Math.imul(v,pe)|0))<<13)|0;c=((o=o+Math.imul(v,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(B,Y)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(I,Y)|0,o=o+Math.imul(I,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(x,oe)|0,i=(i=i+Math.imul(x,se)|0)+Math.imul(O,oe)|0,o=o+Math.imul(O,se)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,ce)|0)+Math.imul(M,ue)|0,o=o+Math.imul(M,ce)|0,n=n+Math.imul(P,fe)|0,i=(i=i+Math.imul(P,le)|0)+Math.imul(k,fe)|0,o=o+Math.imul(k,le)|0;var je=(c+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(_,pe)|0))<<13)|0;c=((o=o+Math.imul(_,ge)|0)+(i>>>13)|0)+(je>>>26)|0,je&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(I,re)|0,o=o+Math.imul(I,ne)|0,n=n+Math.imul(T,oe)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,se)|0,n=n+Math.imul(x,ue)|0,i=(i=i+Math.imul(x,ce)|0)+Math.imul(O,ue)|0,o=o+Math.imul(O,ce)|0,n=n+Math.imul(S,fe)|0,i=(i=i+Math.imul(S,le)|0)+Math.imul(M,fe)|0,o=o+Math.imul(M,le)|0;var xe=(c+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,ge)|0)+Math.imul(k,pe)|0))<<13)|0;c=((o=o+Math.imul(k,ge)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(L,re),i=(i=Math.imul(L,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,se)|0)+Math.imul(I,oe)|0,o=o+Math.imul(I,se)|0,n=n+Math.imul(T,ue)|0,i=(i=i+Math.imul(T,ce)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,ce)|0,n=n+Math.imul(x,fe)|0,i=(i=i+Math.imul(x,le)|0)+Math.imul(O,fe)|0,o=o+Math.imul(O,le)|0;var Oe=(c+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(M,pe)|0))<<13)|0;c=((o=o+Math.imul(M,ge)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(L,oe),i=(i=Math.imul(L,se))+Math.imul(D,oe)|0,o=Math.imul(D,se),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,ce)|0)+Math.imul(I,ue)|0,o=o+Math.imul(I,ce)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,le)|0)+Math.imul(R,fe)|0,o=o+Math.imul(R,le)|0;var Ne=(c+(n=n+Math.imul(x,pe)|0)|0)+((8191&(i=(i=i+Math.imul(x,ge)|0)+Math.imul(O,pe)|0))<<13)|0;c=((o=o+Math.imul(O,ge)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(L,ue),i=(i=Math.imul(L,ce))+Math.imul(D,ue)|0,o=Math.imul(D,ce),n=n+Math.imul(B,fe)|0,i=(i=i+Math.imul(B,le)|0)+Math.imul(I,fe)|0,o=o+Math.imul(I,le)|0;var Te=(c+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,ge)|0)+Math.imul(R,pe)|0))<<13)|0;c=((o=o+Math.imul(R,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(L,fe),i=(i=Math.imul(L,le))+Math.imul(D,fe)|0,o=Math.imul(D,le);var Re=(c+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ge)|0)+Math.imul(I,pe)|0))<<13)|0;c=((o=o+Math.imul(I,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Ce=(c+(n=Math.imul(L,pe))|0)+((8191&(i=(i=Math.imul(L,ge))+Math.imul(D,pe)|0))<<13)|0;return c=((o=Math.imul(D,ge))+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,u[0]=me,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=ke,u[9]=Ae,u[10]=Se,u[11]=Me,u[12]=je,u[13]=xe,u[14]=Oe,u[15]=Ne,u[16]=Te,u[17]=Re,u[18]=Ce,0!==c&&(u[19]=c,r.length++),r};function p(e,t,r){return(new g).mulp(e,t,r)}function g(e,t){this.x=e,this.y=t}Math.imul||(d=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},g.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},g.prototype.permute=function(e,t,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,r[2*s+1]=8191&o,o>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var s=0;for(t=0;t>>26-r}s&&(this.words[t]=s,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,s=Math.min((e-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,c=0;c=0&&(0!==h||c>=i);c--){var f=0|this.words[c];this.words[c]=h<<26-o|f>>>o,h=f&a}return u&&0!==h&&(u.words[u.length++]=h),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===a)return this.strip();for(n(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,u=n.length-i.length;if("mod"!==t){(a=new o(null)).length=u+1,a.words=new Array(a.length);for(var c=0;c=0;f--){var l=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(l=Math.min(l/s|0,67108863),n._ishlnsubmul(i,l,f);0!==n.negative;)l--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=l)}return a&&a.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(i=a.div.neg()),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.iadd(e)),{div:i,mod:s}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(s=a.mod.neg(),r&&0!==s.negative&&s.isub(e)),{div:a.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,s,a},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),s=new o(0),a=new o(0),u=new o(1),c=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++c;for(var h=r.clone(),f=t.clone();!t.isZero();){for(var l=0,d=1;0==(t.words[0]&d)&&l<26;++l,d<<=1);if(l>0)for(t.iushrn(l);l-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(h),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(h),u.isub(f)),a.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(a),s.isub(u)):(r.isub(t),a.isub(i),u.isub(s))}return{a:a,b:u,gcd:r.iushln(c)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,s=new o(1),a=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var c=0,h=1;0==(t.words[0]&h)&&c<26;++c,h<<=1);if(c>0)for(t.iushrn(c);c-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);for(var f=0,l=1;0==(r.words[0]&l)&&f<26;++f,l<<=1);if(f>0)for(r.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);t.cmp(r)>=0?(t.isub(r),s.isub(a)):(r.isub(t),a.isub(s))}return(i=0===t.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new E(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var m={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},i(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(m[e])return m[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return m[e]=t,t},E.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);n(!i.isZero());var a=new o(1).toRed(this),u=a.redNeg(),c=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new o(2*h*h).toRed(this);0!==this.pow(h,c).cmp(u);)h.redIAdd(u);for(var f=this.pow(h,i),l=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=s;0!==d.cmp(a);){for(var g=d,m=0;0!==g.cmp(a);m++)g=g.redSqr();n(m=0;n--){for(var c=t.words[n],h=u-1;h>=0;h--){var f=c>>h&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===h)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}u=26}return i},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new P(e)},i(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(void 0===t||t,this)},{buffer:4}],3:[function(e,t,r){(function(e){t.exports=function(t){var r=new Uint8Array(t);return(e.crypto||e.msCrypto).getRandomValues(r),r}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(e,t,r){},{}],5:[function(e,t,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:this);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function s(e){return"string"!=typeof e&&(e=String(e)),e}function a(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function c(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function h(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function f(e){var t=new FileReader,r=h(t);return t.readAsArrayBuffer(e),r}function l(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=l(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=l(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=c(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var e,t,r,n=c(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=h(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})},d.call(g.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var s=new g(e,n);if(s.signal&&s.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function c(){a.abort()}a.onload=function(){var e,t,r={status:a.status,statusText:a.statusText,headers:(e=a.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new y(n,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach(function(e,t){a.setRequestHeader(t,e)}),s.signal&&(s.signal.addEventListener("abort",c),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",c)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=g,e.Response=y),t.Headers=u,t.Request=g,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,t.exports=r},{}],6:[function(e,t,r){"use strict";var n=r;n.version=e("../package.json").version,n.utils=e("./elliptic/utils"),n.rand=e("brorand"),n.hmacDRBG=e("./elliptic/hmac-drbg"),n.curve=e("./elliptic/curve"),n.curves=e("./elliptic/curves"),n.ec=e("./elliptic/ec"),n.eddsa=e("./elliptic/eddsa")},{"../package.json":20,"./elliptic/curve":9,"./elliptic/curves":12,"./elliptic/ec":13,"./elliptic/eddsa":16,"./elliptic/hmac-drbg":17,"./elliptic/utils":19,brorand:3}],7:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.getNAF,s=i.getJSF,a=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function c(e,t){this.curve=e,this.type=t,this.precomputed=null}t.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){a(e.precomputed);var r=e._getDoubles(),n=o(t,1),i=(1<=u;t--)c=(c<<1)+n[t];s.push(c)}for(var h=this.jpoint(null,null,null),f=this.jpoint(null,null,null),l=i;l>0;l--){for(u=0;u=0;c--){for(t=0;c>=0&&0===s[c];c--)t++;if(c>=0&&t++,u=u.dblp(t),c<0)break;var h=s[c];a(0!==h),u="affine"===e.type?h>0?u.mixedAdd(i[h-1>>1]):u.mixedAdd(i[-h-1>>1].neg()):h>0?u.add(i[h-1>>1]):u.add(i[-h-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,u=this._wnafT2,c=this._wnafT3,h=0,f=0;f=1;f-=2){var d=f-1,p=f;if(1===a[d]&&1===a[p]){var g=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(g[1]=t[d].add(t[p]),g[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(g[1]=t[d].toJ().mixedAdd(t[p]),g[2]=t[d].add(t[p].neg())):(g[1]=t[d].toJ().mixedAdd(t[p]),g[2]=t[d].toJ().mixedAdd(t[p].neg()));var m=[-3,-1,-5,-7,0,7,5,1,3],y=s(r[d],r[p]);h=Math.max(y[0].length,h),c[d]=new Array(h),c[p]=new Array(h);for(var v=0;v=0;f--){for(var P=0;f>=0;){var k=!0;for(v=0;v=0&&P++,_=_.dblp(P),f<0)break;for(v=0;v0?A=u[v][S-1>>1]:S<0&&(A=u[v][-S-1>>1].neg()),_="affine"===A.type?_.mixedAdd(A):_.add(A))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},c.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),u=i.mul(r.b),c=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:u.add(c).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},h.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(e){return e=new o(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},h.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},h.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},h.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},h.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},s(f,a.BasePoint),c.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),u=o.redSub(s);if(0===a.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),h=c.redMul(a),f=n.redMul(c),l=u.redSqr().redIAdd(h).redISub(f).redISub(f),d=u.redMul(f.redISub(l)).redISub(o.redMul(h)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(l,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),c=u.redMul(s),h=r.redMul(u),f=a.redSqr().redIAdd(c).redISub(h).redISub(h),l=a.redMul(h.redISub(f)).redISub(i.redMul(c)),d=this.z.redMul(s);return this.curve.jpoint(f,l,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}return!1},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},{"../../elliptic":6,"../curve":9,"bn.js":2,inherits:33}],12:[function(e,t,r){"use strict";var n,i=r,o=e("hash.js"),s=e("../elliptic"),a=s.utils.assert;function u(e){"short"===e.type?this.curve=new s.curve.short(e):"edwards"===e.type?this.curve=new s.curve.edwards(e):this.curve=new s.curve.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function c(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,c("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),c("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),c("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),c("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),c("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),c("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),c("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=e("./precomputed/secp256k1")}catch(e){n=void 0}c("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},{"../elliptic":6,"./precomputed/secp256k1":18,"hash.js":21}],13:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic"),o=i.utils.assert,s=e("./key"),a=e("./signature");function u(e){if(!(this instanceof u))return new u(e);"string"==typeof e&&(o(i.curves.hasOwnProperty(e),"Unknown curve "+e),e=i.curves[e]),e instanceof i.curves.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}t.exports=u,u.prototype.keyPair=function(e){return new s(this,e)},u.prototype.keyFromPrivate=function(e,t){return s.fromPrivate(this,e,t)},u.prototype.keyFromPublic=function(e,t){return s.fromPublic(this,e,t)},u.prototype.genKeyPair=function(e){e||(e={});for(var t=new i.hmacDRBG({hash:this.hash,pers:e.pers,entropy:e.entropy||i.rand(this.hash.hmacStrength),nonce:this.n.toArray()}),r=this.n.byteLength(),o=this.n.sub(new n(2));;){var s=new n(t.generate(r));if(!(s.cmp(o)>0))return s.iaddn(1),this.keyFromPrivate(s)}},u.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},u.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var s=this.n.byteLength(),u=t.getPrivate().toArray("be",s),c=e.toArray("be",s),h=new i.hmacDRBG({hash:this.hash,entropy:u,nonce:c,pers:o.pers,persEnc:o.persEnc}),f=this.n.sub(new n(1)),l=0;;l++){var d=o.k?o.k(l):new n(h.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(f)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var g=p.getX(),m=g.umod(this.n);if(0!==m.cmpn(0)){var y=d.invm(this.n).mul(m.mul(t.getPrivate()).iadd(e));if(0!==(y=y.umod(this.n)).cmpn(0)){var v=(p.getY().isOdd()?1:0)|(0!==g.cmp(m)?2:0);return o.canonical&&y.cmp(this.nh)>0&&(y=this.n.sub(y),v^=1),new a({r:m,s:y,recoveryParam:v})}}}}}},u.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new a(t,"hex")).r,s=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var u,c=s.invm(this.n),h=c.mul(e).umod(this.n),f=c.mul(o).umod(this.n);return this.curve._maxwellTrick?!(u=this.g.jmulAdd(h,r.getPublic(),f)).isInfinity()&&u.eqXToP(o):!(u=this.g.mulAdd(h,r.getPublic(),f)).isInfinity()&&0===u.getX().umod(this.n).cmp(o)},u.prototype.recoverPubKey=function(e,t,r,i){o((3&r)===r,"The recovery param is more than two bits"),t=new a(t,i);var s=this.n,u=new n(e),c=t.r,h=t.s,f=1&r,l=r>>1;if(c.cmp(this.curve.p.umod(this.curve.n))>=0&&l)throw new Error("Unable to find sencond key candinate");c=l?this.curve.pointFromX(c.add(this.curve.n),f):this.curve.pointFromX(c,f);var d=t.r.invm(s),p=s.sub(u).mul(d).umod(s),g=h.mul(d).umod(s);return this.g.mulAdd(p,c,g)},u.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new a(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},{"../../elliptic":6,"./key":14,"./signature":15,"bn.js":2}],14:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils.assert;function o(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}t.exports=o,o.fromPublic=function(e,t,r){return t instanceof o?t:new o(e,{pub:t,pubEnc:r})},o.fromPrivate=function(e,t,r){return t instanceof o?t:new o(e,{priv:t,privEnc:r})},o.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},o.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},o.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},o.prototype._importPrivate=function(e,t){this.priv=new n(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},o.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?i(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||i(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},o.prototype.derive=function(e){return e.mul(this.priv).getX()},o.prototype.sign=function(e,t,r){return this.ec.sign(e,this,t,r)},o.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},o.prototype.inspect=function(){return""}},{"../../elliptic":6,"bn.js":2}],15:[function(e,t,r){"use strict";var n=e("bn.js"),i=e("../../elliptic").utils,o=i.assert;function s(e,t){if(e instanceof s)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}t.exports=s,s.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new function(){this.place=0};if(48!==e[r.place++])return!1;if(a(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var o=a(e,r),s=e.slice(r.place,o+r.place);if(r.place+=o,2!==e[r.place++])return!1;var u=a(e,r);if(e.length!==u+r.place)return!1;var c=e.slice(r.place,u+r.place);return 0===s[0]&&128&s[1]&&(s=s.slice(1)),0===c[0]&&128&c[1]&&(c=c.slice(1)),this.r=new n(s),this.s=new n(c),this.recoveryParam=null,!0},s.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=u(t),r=u(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),s=[48];return c(s,o.length),s=s.concat(o),i.encode(s,e)}},{"../../elliptic":6,"bn.js":2}],16:[function(e,t,r){arguments[4][8][0].apply(r,arguments)},{dup:8}],17:[function(e,t,r){"use strict";var n=e("hash.js"),i=e("../elliptic").utils,o=i.assert;function s(e){if(!(this instanceof s))return new s(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this.reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc),r=i.toArray(e.nonce,e.nonceEnc),n=i.toArray(e.pers,e.persEnc);o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}t.exports=s,s.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this.reseed=1},s.prototype.generate=function(e,t,r,n){if(this.reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n),this._update(r));for(var o=[];o.length>8,s=255&i;o?r.push(o,s):r.push(s)}return r},n.zero2=o,n.toHex=s,n.encode=function(e,t){return"hex"===t?s(e):e},n.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,s,a,u=e.andln(3)+n&3,c=t.andln(3)+i&3;3===u&&(u=-1),3===c&&(c=-1),o=0==(1&u)?0:3!=(a=e.andln(7)+n&7)&&5!==a||2!==c?u:-u,r[0].push(o),s=0==(1&c)?0:3!=(a=t.andln(7)+i&7)&&5!==a||2!==u?c:-c,r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},{"bn.js":2}],20:[function(e,t,r){t.exports={version:"6.3.3"}},{}],21:[function(e,t,r){var n=r;n.utils=e("./hash/utils"),n.common=e("./hash/common"),n.sha=e("./hash/sha"),n.ripemd=e("./hash/ripemd"),n.hmac=e("./hash/hmac"),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},{"./hash/common":22,"./hash/hmac":23,"./hash/ripemd":24,"./hash/sha":25,"./hash/utils":32}],22:[function(e,t,r){"use strict";var n=e("./utils"),i=e("minimalistic-assert");function o(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}r.BlockHash=o,o.prototype.update=function(e,t){if(e=n.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;othis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t>>3},r.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},{"../utils":32}],32:[function(e,t,r){"use strict";var n=e("minimalistic-assert"),i=e("inherits");function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function a(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}r.inherits=i,r.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return s},r.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},r.rotr32=function(e,t){return e>>>t|e<<32-t},r.rotl32=function(e,t){return e<>>32-t},r.sum32=function(e,t){return e+t>>>0},r.sum32_3=function(e,t,r){return e+t+r>>>0},r.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},r.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},r.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o>>0,e[t+1]=o},r.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},r.sum64_lo=function(e,t,r,n){return t+n>>>0},r.sum64_4_hi=function(e,t,r,n,i,o,s,a){var u=0,c=t;return u+=(c=c+n>>>0)>>0)>>0)>>0},r.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},r.sum64_5_hi=function(e,t,r,n,i,o,s,a,u,c){var h=0,f=t;return h+=(f=f+n>>>0)>>0)>>0)>>0)>>0},r.sum64_5_lo=function(e,t,r,n,i,o,s,a,u,c){return t+n+o+a+c>>>0},r.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},r.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},r.shr64_hi=function(e,t,r){return e>>>r},r.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},{inherits:33,"minimalistic-assert":35}],33:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],34:[function(e,t,r){(function(e,r){!function(){"use strict";var n="object"==typeof window?window:{};!n.JS_SHA3_NO_NODE_JS&&"object"==typeof e&&e.versions&&e.versions.node&&(n=r);for(var i=!n.JS_SHA3_NO_COMMON_JS&&"object"==typeof t&&t.exports,o="0123456789abcdef".split(""),s=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],u=[224,256,384,512],c=["hex","buffer","arrayBuffer","array"],h=function(e,t,r){return function(n){return new _(e,t,e).update(n)[r]()}},f=function(e,t,r){return function(n,i){return new _(e,t,i).update(n)[r]()}},l=function(e,t){var r=h(e,t,"hex");r.create=function(){return new _(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}_.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,o=this.blocks,a=this.byteCount,u=this.blockCount,c=0,h=this.s;c>2]|=e[c]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=o[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+o[15&e]+o[e>>12&15]+o[e>>8&15]+o[e>>20&15]+o[e>>16&15]+o[e>>28&15]+o[e>>24&15];a%t==0&&(E(r),s=0)}return i&&(e=r[s],i>0&&(u+=o[e>>4&15]+o[15&e]),i>1&&(u+=o[e>>12&15]+o[e>>8&15]),i>2&&(u+=o[e>>20&15]+o[e>>16&15])),u},_.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var u=new Uint32Array(e);s>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;a%r==0&&E(n)}return o&&(e=a<<2,t=n[s],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var E=function(e){var t,r,n,i,o,s,u,c,h,f,l,d,p,g,m,y,v,b,w,_,E,P,k,A,S,M,j,x,O,N,T,R,C,B,I,F,L,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,se,ae,ue,ce,he;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],h=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],l=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|h>>>31),r=o^(h<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(f<<1|l>>>31),r=u^(l<<1|f>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|p>>>31),r=h^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=f^(i<<1|o>>>31),r=l^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,g=e[0],m=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,x=e[20]<<3|e[21]>>>29,O=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,B=e[2]<<1|e[3]>>>31,I=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,N=e[33]<<13|e[32]>>>19,T=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,he=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,F=e[14]<<6|e[15]>>>26,L=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,C=e[44]<<29|e[45]>>>3,A=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,M=e[18]<<20|e[19]>>>12,j=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,k=e[49]<<14|e[48]>>>18,e[0]=g^~y&b,e[1]=m^~v&w,e[10]=A^~M&x,e[11]=S^~j&O,e[20]=B^~F&D,e[21]=I^~L&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&se,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=M^~x&N,e[13]=j^~O&T,e[22]=F^~D&z,e[23]=L^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&ae,e[43]=ie^~se&ue,e[4]=b^~_&P,e[5]=w^~E&k,e[14]=x^~N&R,e[15]=O^~T&C,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~ae&ce,e[45]=se^~ue&he,e[6]=_^~P&g,e[7]=E^~k&m,e[16]=N^~R&A,e[17]=T^~C&S,e[26]=z^~K&B,e[27]=H^~q&I,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=ae^~ce&te,e[47]=ue^~he&re,e[8]=P^~g&y,e[9]=k^~m&v,e[18]=R^~A&M,e[19]=C^~S&j,e[28]=K^~B&F,e[29]=q^~I&L,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=ce^~te&ne,e[49]=he^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(i)t.exports=p;else for(m=0;m=64;){var d,p,g,m,y,v=r,b=n,w=i,_=o,E=s,P=a,k=u,A=c;for(p=0;p<16;p++)g=f+4*p,h[p]=(255&e[g])<<24|(255&e[g+1])<<16|(255&e[g+2])<<8|255&e[g+3];for(p=16;p<64;p++)m=((d=h[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=h[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,h[p]=(m+h[p-7]|0)+(y+h[p-16]|0)|0;for(p=0;p<64;p++)m=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&k)|0)+(A+(t[p]+h[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,A=k,k=P,P=E,E=_+m|0,_=w,w=b,b=v,v=m+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,s=s+E|0,a=a+P|0,u=u+k|0,c=c+A|0,f+=64,l-=64}}f(e);var l,d=e.length%64,p=e.length/536870912|0,g=e.length<<3,m=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),l=d+1;l>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(g>>>24&255),y.push(g>>>16&255),y.push(g>>>8&255),y.push(g>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255]}function s(e,t,r){var n;e=e.length<=64?e:o(e);var i=64+t.length+4,s=new Array(i),a=new Array(64),u=[];for(n=0;n<64;n++)s[n]=54;for(n=0;n=i-4;e--){if(s[e]++,s[e]<=255)return;s[e]=0}}for(;r>=32;)c(),u=u.concat(o(a.concat(o(s)))),r-=32;return r>0&&(c(),u=u.concat(o(a.concat(o(s))).slice(0,r))),u}function a(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)h(e,16*o,i,16),c(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function c(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=u(t[0]+t[12],7),t[8]^=u(t[4]+t[0],9),t[12]^=u(t[8]+t[4],13),t[0]^=u(t[12]+t[8],18),t[9]^=u(t[5]+t[1],7),t[13]^=u(t[9]+t[5],9),t[1]^=u(t[13]+t[9],13),t[5]^=u(t[1]+t[13],18),t[14]^=u(t[10]+t[6],7),t[2]^=u(t[14]+t[10],9),t[6]^=u(t[2]+t[14],13),t[10]^=u(t[6]+t[2],18),t[3]^=u(t[15]+t[11],7),t[7]^=u(t[3]+t[15],9),t[11]^=u(t[7]+t[3],13),t[15]^=u(t[11]+t[7],18),t[1]^=u(t[0]+t[3],7),t[2]^=u(t[1]+t[0],9),t[3]^=u(t[2]+t[1],13),t[0]^=u(t[3]+t[2],18),t[6]^=u(t[5]+t[4],7),t[7]^=u(t[6]+t[5],9),t[4]^=u(t[7]+t[6],13),t[5]^=u(t[4]+t[7],18),t[11]^=u(t[10]+t[9],7),t[8]^=u(t[11]+t[10],9),t[9]^=u(t[8]+t[11],13),t[10]^=u(t[9]+t[8],18),t[12]^=u(t[15]+t[14],7),t[13]^=u(t[12]+t[15],9),t[14]^=u(t[13]+t[12],13),t[15]^=u(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function h(e,t,r,n){for(var i=0;i=256)return!1}return!0}function d(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function p(t,r,n,o,u,c,p){if(!p)throw new Error("missing callback");if(n=d(n,"N"),o=d(o,"r"),u=d(u,"p"),c=d(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>i/128/o)throw new Error("N too large");if(o>i/128/u)throw new Error("r too large");if(!l(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!l(r))throw new Error("salt must be an array or buffer");r=Array.prototype.slice.call(r);for(var g=s(t,r,128*u*o),m=new Uint32Array(32*u*o),y=0;yT&&(r=T);for(var e=0;eT&&(r=T);for(e=0;e>0&255),g.push(m[e]>>8&255),g.push(m[e]>>16&255),g.push(m[e]>>24&255);var d=s(t,g,c);return p(null,1,d)}R(C)};C()}void 0!==r?t.exports=p:n&&(n.scrypt&&(n._scrypt=n.scrypt),n.scrypt=p)}(this)}).call(this,e("timers").setImmediate)},{timers:38}],38:[function(e,t,r){(function(e){t.exports={setImmediate:e.setImmediate}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],39:[function(e,t,r){(function(e){var r;if(e.crypto&&crypto.getRandomValues){var n=new Uint8Array(16);r=function(){return crypto.getRandomValues(n),n}}if(!r){var i=new Array(16);r=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),i[t]=e>>>((3&t)<<3)&255;return i}}t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],40:[function(e,t,r){for(var n=e("./rng"),i=[],o={},s=0;s<256;s++)i[s]=(s+256).toString(16).substr(1),o[i[s]]=s;function a(e,t){var r=t||0,n=i;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var u=n(),c=[1|u[0],u[1],u[2],u[3],u[4],u[5]],h=16383&(u[6]<<8|u[7]),f=0,l=0;function d(e,t,r){var i=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var o=(e=e||{}).random||(e.rng||n)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,t)for(var s=0;s<16;s++)t[i+s]=o[s];return t||a(o)}var p=d;p.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:h,s=void 0!==e.msecs?e.msecs:(new Date).getTime(),u=void 0!==e.nsecs?e.nsecs:l+1,d=s-f+(u-l)/1e4;if(d<0&&void 0===e.clockseq&&(o=o+1&16383),(d<0||s>f)&&void 0===e.nsecs&&(u=0),u>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");f=s,l=u,h=o;var p=(1e4*(268435455&(s+=122192928e5))+u)%4294967296;i[n++]=p>>>24&255,i[n++]=p>>>16&255,i[n++]=p>>>8&255,i[n++]=255&p;var g=s/4294967296*1e4&268435455;i[n++]=g>>>8&255,i[n++]=255&g,i[n++]=g>>>24&15|16,i[n++]=g>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var m=e.node||c,y=0;y<6;y++)i[n+y]=m[y];return t||a(i)},p.v4=d,p.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=o[e])});i<16;)t[n+i++]=0;return t},p.unparse=a,t.exports=p},{"./rng":39}],41:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="abi/5.0.0-beta.136"},{}],42:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes"),i=e("@ethersproject/properties"),o=e("@ethersproject/logger"),s=e("./_version"),a=new o.Logger(s.version),u=e("./coders/abstract-coder"),c=e("./coders/address"),h=e("./coders/array"),f=e("./coders/boolean"),l=e("./coders/bytes"),d=e("./coders/fixed-bytes"),p=e("./coders/null"),g=e("./coders/number"),m=e("./coders/string"),y=e("./coders/tuple"),v=e("./fragments"),b=new RegExp(/^bytes([0-9]*)$/),w=new RegExp(/^(u?int)([0-9]*)$/),_=function(){function e(t){var r=this.constructor;a.checkNew(r,e),i.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new c.AddressCoder(e.name);case"bool":return new f.BooleanCoder(e.name);case"string":return new m.StringCoder(e.name);case"bytes":return new l.BytesCoder(e.name);case"array":return new h.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new y.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new p.NullCoder(e.name)}var r,n=e.type.match(w);return n?((0===(r=parseInt(n[2]||"256"))||r>256||r%8!=0)&&a.throwArgumentError("invalid "+n[1]+" bit length","param",e),new g.NumberCoder(r/8,"int"===n[1],e.name)):(n=e.type.match(b))?((0===(r=parseInt(n[1]))||r>32)&&a.throwArgumentError("invalid bytes length","param",e),new d.FixedBytesCoder(r,e.name)):a.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new u.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new u.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var r=this;e.length!==t.length&&a.throwError("types/values length mismatch",o.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var n=e.map(function(e){return r._getCoder(v.ParamType.from(e))}),i=new y.TupleCoder(n,"_"),s=this._getWriter();return i.encode(s,t),s.data},e.prototype.decode=function(e,t){var r=this,i=e.map(function(e){return r._getCoder(v.ParamType.from(e))});return new y.TupleCoder(i,"_").decode(this._getReader(n.arrayify(t)))},e}();r.AbiCoder=_,r.defaultAbiCoder=new _},{"./_version":41,"./coders/abstract-coder":43,"./coders/address":44,"./coders/array":46,"./coders/boolean":47,"./coders/bytes":48,"./coders/fixed-bytes":49,"./coders/null":50,"./coders/number":51,"./coders/string":52,"./coders/tuple":53,"./fragments":54,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96}],43:[function(e,t,r){"use trict";"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes"),i=e("@ethersproject/bignumber"),o=e("@ethersproject/properties"),s=e("@ethersproject/logger"),a=e("../_version"),u=new s.Logger(a.version),c=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){u.throwArgumentError(e,this.localName,t)},e}();r.Coder=c;var h=function(){function e(e){o.defineReadOnly(this,"wordSize",e||32),this._data=n.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return n.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=n.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=n.arrayify(e);return t.length%this.wordSize&&(t=n.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=n.arrayify(i.BigNumber.from(e));return t.length>this.wordSize&&u.throwError("value out-of-bounds",s.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=n.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();r.Writer=h;var f=function(){function e(e,t,r){o.defineReadOnly(this,"_data",n.arrayify(e)),o.defineReadOnly(this,"wordSize",t||32),o.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return n.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var r=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&u.throwError("data out-of-bounds",s.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return i.BigNumber.from(this.readBytes(this.wordSize))},e}();r.Reader=f},{"../_version":41,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96}],44:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/address"),s=e("@ethersproject/bytes"),a=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{o.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return o.getAddress(s.hexZeroPad(e.readValue().toHexString(),20))},t}(e("./abstract-coder").Coder);r.AddressCoder=a},{"./abstract-coder":43,"@ethersproject/address":62,"@ethersproject/bytes":70}],45:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(e("./abstract-coder").Coder);r.AnonymousCoder=o},{"./abstract-coder":43}],46:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/logger"),s=e("../_version"),a=new o.Logger(s.version),u=e("./abstract-coder"),c=e("./anonymous");function h(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else a.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&a.throwArgumentError("types/value length mismatch","tuple",r);var i=new u.Writer(e.wordSize),o=new u.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var a=o.length;e.encode(o,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+a)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var c=e.writeBytes(i.data);return c+=e.writeBytes(o.data)}function f(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var s=e.readValue(),a=n.subReader(s.toNumber());o=t.decode(a),i+=a.consumed}else o=t.decode(e);void 0!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=h,r.unpack=f;var l=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",s=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,s)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),a.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=o.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=v;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||c.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&c.throwError("cannot format a constructor for sighash",a.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(h,{type:e.type,inputs:e.inputs?e.inputs.map(g.fromObject):[],payable:r.payable,gas:e.gas?o.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(M);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=m(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(y);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||c.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(h,{type:e.type,name:S(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(g.fromObject):[],outputs:e.outputs?e.outputs.map(g.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?o.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(M);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(A))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=m(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(M);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=m(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function k(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var A=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function S(e){if(!e||!e.match(A))throw new Error("invalid identifier: '"+e+"'");return e}var M=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")},{"./_version":41,"@ethersproject/bignumber":68,"@ethersproject/logger":91,"@ethersproject/properties":96}],55:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./fragments");r.ConstructorFragment=n.ConstructorFragment,r.EventFragment=n.EventFragment,r.FormatTypes=n.FormatTypes,r.Fragment=n.Fragment,r.FunctionFragment=n.FunctionFragment,r.ParamType=n.ParamType;var i=e("./abi-coder");r.AbiCoder=i.AbiCoder,r.defaultAbiCoder=i.defaultAbiCoder;var o=e("./interface");r.Indexed=o.Indexed,r.Interface=o.Interface},{"./abi-coder":42,"./fragments":54,"./interface":56}],56:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/address"),s=e("@ethersproject/bignumber"),a=e("@ethersproject/bytes"),u=e("@ethersproject/hash"),c=e("@ethersproject/keccak256"),h=e("@ethersproject/properties"),f=e("./abi-coder"),l=e("./fragments"),d=e("@ethersproject/logger"),p=e("./_version"),g=new d.Logger(p.version),m=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(h.Description);r.LogDescription=m;var y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t}(h.Description);r.TransactionDescription=y;var v=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isIndexed=function(e){return!(!e||!e._isIndexed)},t}(h.Description);r.Indexed=v;var b=function(){return function(){}}();r.Result=b;var w=function(){function e(t){var r=this.constructor,n=this;g.checkNew(r,e);var i=[];i="string"==typeof t?JSON.parse(t):t,h.defineReadOnly(this,"fragments",i.map(function(e){return l.Fragment.from(e)}).filter(function(e){return null!=e})),h.defineReadOnly(this,"_abiCoder",h.getStatic(r,"getAbiCoder")()),h.defineReadOnly(this,"functions",{}),h.defineReadOnly(this,"errors",{}),h.defineReadOnly(this,"events",{}),h.defineReadOnly(this,"structs",{}),this.fragments.forEach(function(e){var t=null;switch(e.type){case"constructor":return n.deploy?void g.warn("duplicate definition - constructor"):void h.defineReadOnly(n,"deploy",e);case"function":t=n.functions;break;case"event":t=n.events;break;default:return}var r=e.format();t[r]?g.warn("duplicate definition - "+r):t[r]=e}),[this.events,this.functions].forEach(function(e){var t=function(e){var t={};for(var r in e){var n=e[r].name;t[n]||(t[n]=0),t[n]++}return t}(e);Object.keys(e).forEach(function(r){var n=e[r];1===t[n.name]?e[n.name]=n:g.warn("duplicate definition - "+n.name)})}),this.deploy||h.defineReadOnly(this,"deploy",l.ConstructorFragment.from({type:"constructor"})),h.defineReadOnly(this,"_isInterface",!0)}return e.getAbiCoder=function(){return f.defaultAbiCoder},e.getAddress=function(e){return o.getAddress(e)},e.prototype._sighashify=function(e){return a.hexDataSlice(u.id(e.format()),0,4)},e.prototype._topicify=function(e){return u.id(e.format())},e.prototype.getFunction=function(e){return a.isHexString(e)?_(e,this.getSighash.bind(this),this.functions):-1===e.indexOf("(")?this.functions[e.trim()]||null:this.functions[l.FunctionFragment.fromString(e).format()]},e.prototype.getEvent=function(e){return a.isHexString(e)?_(e,this.getEventTopic.bind(this),this.events):-1===e.indexOf("(")?this.events[e]:this.events[l.EventFragment.fromString(e).format()]},e.prototype.getSighash=function(e){return"string"==typeof e&&(e=this.getFunction(e)),this._sighashify(e)},e.prototype.getEventTopic=function(e){return"string"==typeof e&&(e=this.getEvent(e)),this._topicify(e)},e.prototype._encodeParams=function(e,t){return this._abiCoder.encode(e,t)},e.prototype.encodeDeploy=function(e){return this._encodeParams(this.deploy.inputs,e||[])},e.prototype.encodeFunctionData=function(e,t){return"string"==typeof e&&(e=this.getFunction(e)),a.hexlify(a.concat([this.getSighash(e),this._encodeParams(e.inputs,t||[])]))},e.prototype.decodeFunctionResult=function(e,t){"string"==typeof e&&(e=this.getFunction(e));var r=a.arrayify(t),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(e.outputs,r)}catch(e){}break;case 4:"0x08c379a0"===a.hexlify(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return g.throwError("call revert exception",d.Logger.errors.CALL_EXCEPTION,{method:e.format(),errorSignature:i,errorArgs:[n],reason:n})},e.prototype.encodeFilterTopics=function(e,t){var r=this;"string"==typeof e&&(e=this.getEvent(e)),t.length>e.inputs.length&&g.throwError("too many arguments for "+e.format(),d.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var o=e.inputs[i];o.indexed?null==t?n.push(null):"string"===o.type?n.push(u.id(t)):"bytes"===o.type?n.push(c.keccak256(a.hexlify(t))):-1!==o.type.indexOf("[")||"tuple"===o.type.substring(0,5)?g.throwArgumentError("filtering with tuples or arrays not supported","contract."+o.name,t):("address"===o.type&&r._abiCoder.encode(["address"],[t]),n.push(a.hexZeroPad(a.hexlify(t),32))):null!=t&&g.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+o.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);a.isHexString(r[0],32)&&r[0].toLowerCase()===n||g.throwError("fragment/topic mismatch",d.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],o=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(l.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(o.push(e),s.push(!1))});var u=null!=r?this._abiCoder.decode(i,a.concat(r)):null,c=this._abiCoder.decode(o,t),h=[],f=0,p=0;return e.inputs.forEach(function(e,t){e.indexed?null==u?h[t]=new v({_isIndexed:!0,hash:null}):s[t]?h[t]=new v({_isIndexed:!0,hash:u[p++]}):h[t]=u[p++]:h[t]=c[f++]}),h},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new y({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:s.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new m({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function _(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=w},{"./_version":41,"./abi-coder":42,"./fragments":54,"@ethersproject/address":62,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/hash":80,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96}],57:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="abstract-provider/5.0.0-beta.130"},{}],58:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/bytes"),s=e("@ethersproject/properties"),a=e("@ethersproject/logger"),u=e("./_version"),c=new a.Logger(u.version),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(s.Description);r.ForkEvent=h;var f=function(e){function t(t,r){return o.isHexString(t,32)||c.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(h);r.BlockForkEvent=f;var l=function(e){function t(t,r){return o.isHexString(t,32)||c.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(h);r.TransactionForkEvent=l;var d=function(e){function t(t,r,n){return o.isHexString(t,32)||c.throwArgumentError("invalid transaction hash","beforeHash",t),o.isHexString(r,32)||c.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(h);r.TransactionOrderForkEvent=d;var p=function(){function e(){var t=this.constructor;c.checkAbstract(t,e),s.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=p},{"./_version":57,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96}],59:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="abstract-signer/5.0.0-beta.131"},{}],60:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/properties"),s=e("@ethersproject/logger"),a=e("./_version"),u=new s.Logger(a.version),c=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],h=function(){function e(){var t=this.constructor;u.checkAbstract(t,e),o.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),o.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),o.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===c.indexOf(t)&&u.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=o.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return o.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&u.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){u.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",s.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),o.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||u.throwError("missing provider",s.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=h;var f=function(e){function t(r,n){var i,s=this.constructor;return u.checkNew(s,t),i=e.call(this)||this,o.defineReadOnly(i,"address",r),o.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){u.throwError(e,s.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(h);r.VoidSigner=f},{"./_version":59,"@ethersproject/logger":91,"@ethersproject/properties":96}],61:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="address/5.0.0-beta.127"},{}],62:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("bn.js")),o=e("@ethersproject/bytes"),s=e("@ethersproject/keccak256"),a=e("@ethersproject/rlp"),u=e("@ethersproject/logger"),c=e("./_version"),h=new u.Logger(c.version);function f(e){o.isHexString(e,20)||h.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=o.arrayify(s.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var l={},d=0;d<10;d++)l[String(d)]=String(d);for(d=0;d<26;d++)l[String.fromCharCode(65+d)]=String(10+d);var p,g=Math.floor((p=9007199254740991,Math.log10?Math.log10(p):Math.log(p)/Math.LN10));function m(e){var t="";for((e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00").split("").forEach(function(e){t+=l[e]});t.length>=g;){var r=t.substring(0,g);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function y(e){var t=null;if("string"!=typeof e&&h.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=f(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&h.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==m(e)&&h.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=f("0x"+t)}else h.throwArgumentError("invalid address","address",e);return t}r.getAddress=y,r.isAddress=function(e){try{return y(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(y(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+m("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=y(e.from)}catch(t){h.throwArgumentError("missing from address","transaction",e)}var r=o.stripZeros(o.arrayify(e.nonce));return y(o.hexDataSlice(s.keccak256(a.encode([t,r])),12))}},{"./_version":61,"@ethersproject/bytes":70,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/rlp":114,"bn.js":2}],63:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes");r.decode=function(e){e=atob(e);for(var t=[],r=0;r0;)r.push(o%this.base),o=o/this.base|0}for(var a="",u=0;0===t[u]&&u=0;--c)a+=this.alphabet[r[c]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;o>0;)t.push(255&o),o>>=8}for(var a=0;e[a]===this._leader&&a=9007199254740991||t<=-9007199254740991)&&p("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):o.isBytes(t)?e.from(o.hexlify(t)):t._hex&&o.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):u.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function f(e){if("string"!=typeof e)return f(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&u.throwArgumentError("invalid hex","value",e),"0x00"===(e=f(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function l(e){return h.from(f(e))}function d(e){var t=h.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function p(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),u.throwError(e,s.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=h},{"./_version":65,"@ethersproject/bytes":70,"@ethersproject/logger":91,"bn.js":2}],67:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes"),i=e("@ethersproject/logger"),o=e("./_version"),s=new i.Logger(o.version),a=e("./bignumber"),u={},c=a.BigNumber.from(0),h=a.BigNumber.from(-1);function f(e,t,r,n){var o={fault:t,operation:r};return void 0!==n&&(o.value=n),s.throwError(e,i.Logger.errors.NUMERIC_FAULT,o)}for(var l="0";l.length<256;)l+=l;function d(e){if("number"!=typeof e)try{e=a.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+l.substring(0,e):s.throwArgumentError("invalid decimal size","decimals",e)}function p(e,t){null==t&&(t=0);var r=d(t),n=(e=a.BigNumber.from(e)).lt(c);n&&(e=e.mul(h));for(var i=e.mod(r).toString();i.length2&&s.throwArgumentError("too many decimal points","value",e);var o=i[0],u=i[1];for(o||(o="0"),u||(u="0"),u.length>r.length-1&&f("fractional component exceeds decimals","underflow","parseFixed");u.length80&&s.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",i),new e(u,r,n,i)},e}();r.FixedFormat=m;var y=function(){function e(t,r,n,i){var o=this.constructor;s.checkNew(o,e),this.format=i,this._hex=r,this._value=n,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&s.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=g(this._value,this.format.decimals),n=g(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=g(this._value,this.format.decimals),n=g(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=g(this._value,this.format.decimals),n=g(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=g(this._value,this.format.decimals),n=g(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&s.throwArgumentError("invalid decimal cound","decimals",t);var r=this.toString().split(".");if(r[1].length<=t)return this;var n="0."+l.substring(0,t)+"5";return r=this.addUnsafe(e.fromString(n,this.format))._value.split("."),e.fromString(r[0]+"."+r[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&s.throwArgumentError("invalid byte width","width",e);var t=a.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return n.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||a.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(p(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var i=m.from(r),o=g(t,i.decimals);!i.signed&&o.lt(c)&&f("unsigned value cannot be negative","overflow","value",t);var s=null;i.signed?s=o.toTwos(i.width).toHexString():(s=o.toHexString(),s=n.hexZeroPad(s,i.width/8));var a=p(o,i.decimals);return new e(u,s,a,i)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(n.arrayify(t).length>i.width/8)throw new Error("overflow");var o=a.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var s=o.toTwos((i.signed?0:1)+i.width).toHexString(),c=p(o,i.decimals);return new e(u,s,c,i)},e.from=function(t,r){if("string"==typeof t)return e.fromString(t,r);if(n.isBytes(t))return e.fromBytes(t,r);try{return e.fromValue(t,0,r)}catch(e){if(e.code!==i.Logger.errors.INVALID_ARGUMENT)throw e}return s.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();r.FixedNumber=y},{"./_version":65,"./bignumber":66,"@ethersproject/bytes":70,"@ethersproject/logger":91}],68:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bignumber");r.BigNumber=n.BigNumber;var i=e("./fixednumber");r.FixedNumber=i.FixedNumber},{"./bignumber":66,"./fixednumber":67}],69:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="bytes/5.0.0-beta.128"},{}],70:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/logger"),i=e("./_version"),o=new n.Logger(i.version);function s(e){return!!e.toHexString}function a(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return a(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function u(e){return l(e)&&!(e.length%2)||c(e)}function c(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function h(e,t){if(t||(t={}),"number"==typeof e){o.checkSafeUint53(e,"invalid arrayify value");for(var r=[];e;)r.unshift(255&e),e/=256;return 0===r.length&&r.push(0),a(new Uint8Array(r))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),s(e)&&(e=e.toHexString()),l(e)){var n=e.substring(2);!t.allowOddLength&&n.length%2&&o.throwArgumentError("hex data is odd-length","value",e);r=[];for(var i=0;it&&o.throwArgumentError("value out of range","value",arguments[0]);var r=new Uint8Array(t);return r.set(e,t-e.length),a(r)},r.isHexString=l;var d="0123456789abcdef";function p(e,t){if(t||(t={}),"number"==typeof e){o.checkSafeUint53(e,"invalid hexlify value");for(var r="";e;)r=d[15&e]+r,e=Math.floor(e/16);return r.length?(r.length%2&&(r="0"+r),"0x"+r):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),s(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&o.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(c(e)){for(var n="0x",i=0;i>4]+d[15&a]}return n}return o.throwArgumentError("invalid hexlify value","value",e)}function g(e){"string"!=typeof e&&(e=p(e)),l(e)||o.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&o.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function y(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(u(e)){var r=h(e);65!==r.length&&o.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=p(r.slice(0,32)),t.s=p(r.slice(32,64)),t.v=r[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(r[32]|=128),t._vs=p(r.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&o.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&o.throwArgumentError("signature _vs overflow","signature",e);var n=(a=h(t._vs))[0]>=128?1:0,i=27+t.recoveryParam;a[0]&=127;var s=p(a);null==t.s?t.s=s:t.s!==s&&o.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=i:t.v!==i&&o.throwArgumentError("signature v mismatch _vs","signature",e),null==n?t.recoveryParam=n:t.recoveryParam!==n&&o.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var a;if(null==t.v&&null==t.recoveryParam&&o.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&o.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&o.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(a=h(t.s))[0]>=128&&o.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(a[0]|=128),t._vs=p(a)}return t}r.hexlify=p,r.hexDataLength=function(e){if("string"!=typeof e)e=p(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},r.hexDataSlice=function(e,t,r){return"string"!=typeof e?e=p(e):(!l(e)||e.length%2)&&o.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=r?"0x"+e.substring(t,2+2*r):"0x"+e.substring(t)},r.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=p(e).substring(2)}),t},r.hexValue=function(e){var t=g(p(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},r.hexStripZeros=g,r.hexZeroPad=m,r.splitSignature=y,r.joinSignature=function(e){return p(f([(e=y(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}},{"./_version":69,"@ethersproject/logger":91}],71:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bignumber");r.AddressZero="0x0000000000000000000000000000000000000000";r.HashZero="0x0000000000000000000000000000000000000000000000000000000000000000";r.EtherSymbol="Ξ";var i=n.BigNumber.from(-1);r.NegativeOne=i;var o=n.BigNumber.from(0);r.Zero=o;var s=n.BigNumber.from(1);r.One=s;var a=n.BigNumber.from(2);r.Two=a;var u=n.BigNumber.from("1000000000000000000");r.WeiPerEther=u;var c=n.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");r.MaxUint256=c},{"@ethersproject/bignumber":68}],72:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="contracts/5.0.0-beta.136"},{}],73:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/abi"),s=e("@ethersproject/abstract-provider"),a=e("@ethersproject/abstract-signer"),u=e("@ethersproject/address"),c=e("@ethersproject/bignumber"),h=e("@ethersproject/bytes"),f=e("@ethersproject/constants"),l=e("@ethersproject/properties"),d=e("@ethersproject/logger"),p=e("./_version"),g=new d.Logger(p.version),m={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function y(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return y(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return y(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return y(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function v(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],o=0;o0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=k;var A=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:h.isBytes(t)?h.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!h.isHexString(i)||i.length%2)&&g.throwArgumentError("invalid bytecode","bytecode",t),r&&!a.Signer.isSigner(r)&&g.throwArgumentError("invalid signer","signer",r),l.defineReadOnly(this,"bytecode",i),l.defineReadOnly(this,"interface",l.getStatic(n,"getInterface")(e)),l.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t=256)throw new Error("Depth too large!");return w(i.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",i.hexlify(this.depth),this.parentFingerprint,i.hexZeroPad(i.hexlify(this.index),4),this.chainCode,null!=this.privateKey?i.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(_,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var n=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");n.set(i.arrayify(this.privateKey),1),r&&(r+="'")}else n.set(i.arrayify(this.publicKey));for(var s=24;s>=0;s-=8)n[33+(s>>3)]=t>>24-s&255;var a=i.arrayify(h.computeHmac(h.SupportedAlgorithms.sha512,this.chainCode,n)),u=a.slice(0,32),f=a.slice(32),l=null,d=null;this.privateKey?l=b(o.BigNumber.from(u).add(this.privateKey).mod(m)):d=new c.SigningKey(i.hexlify(u))._addPoint(this.publicKey);return new e(_,l,d,this.fingerprint,b(f),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invlaid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=i.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=i.arrayify(h.computeHmac(h.SupportedAlgorithms.sha512,y,n));return new e(_,b(o.slice(0,32)),null,"0x00000000",b(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=A(k(t,n),n),e._fromSeed(P(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var r=n.Base58.decode(t);82===r.length&&w(r.slice(0,78))===t||g.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var o=r[4],s=i.hexlify(r.slice(5,9)),a=parseInt(i.hexlify(r.slice(9,13)).substring(2),16),u=i.hexlify(r.slice(13,45)),c=r.slice(45,78);switch(i.hexlify(r.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(_,null,i.hexlify(c),s,u,a,o,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(_,i.hexlify(c.slice(1)),null,s,u,a,o,null,null)}return g.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function P(e,t){t||(t="");var r=s.toUtf8Bytes("mnemonic"+t,s.UnicodeNormalizationForm.NFKD);return a.pbkdf2(s.toUtf8Bytes(e,s.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function k(e,t){t||(t=l.wordlists.en),g.checkNormalize();var r=t.split(e);if(r.length%3!=0)throw new Error("invalid mnemonic");for(var n=i.arrayify(new Uint8Array(Math.ceil(11*r.length/8))),o=0,s=0;s>3]|=1<<7-o%8),o++}var c=32*r.length/3,f=v(r.length/3),d=i.arrayify(h.sha256(n.slice(0,c/8)))[0];if((d&=f)!==(n[n.length-1]&f))throw new Error("invalid checksum");return i.hexlify(n.slice(0,c/8))}function A(e,t){if((e=i.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,o=0;o8?(r[r.length-1]<<=8,r[r.length-1]|=e[o],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[o]>>8-n,r.push(e[o]&(1<<8-n)-1),n+=3);var s=i.arrayify(h.sha256(e))[0],a=e.length/4;return s&=v(a),r[r.length-1]<<=a,r[r.length-1]|=s>>8-a,t||(t=l.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}r.HDNode=E,r.mnemonicToSeed=P,r.mnemonicToEntropy=k,r.entropyToMnemonic=A,r.isValidMnemonic=function(e,t){try{return k(e,t),!0}catch(e){}return!1}},{"./_version":81,"@ethersproject/basex":64,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/pbkdf2":94,"@ethersproject/properties":96,"@ethersproject/sha2":116,"@ethersproject/signing-key":118,"@ethersproject/strings":123,"@ethersproject/transactions":126,"@ethersproject/wordlists":134}],83:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="json-wallets/5.0.0-beta.128"},{}],84:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=o(e("aes-js")),a=e("@ethersproject/address"),u=e("@ethersproject/bytes"),c=e("@ethersproject/keccak256"),h=e("@ethersproject/pbkdf2"),f=e("@ethersproject/strings"),l=e("@ethersproject/properties"),d=e("@ethersproject/logger"),p=e("./_version"),g=new d.Logger(p.version),m=e("./utils"),y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isCrowdsaleAccount=function(e){return!(!e||!e._isCrowdsaleAccount)},t}(l.Description);r.CrowdsaleAccount=y,r.decrypt=function(e,t){var r=JSON.parse(e);t=m.getPassword(t);var n=a.getAddress(m.searchPath(r,"ethaddr")),i=m.looseArrayify(m.searchPath(r,"encseed"));i&&i.length%16==0||g.throwArgumentError("invalid encseed","json",e);var o=u.arrayify(h.pbkdf2(t,t,2e3,32,"sha256")).slice(0,16),l=i.slice(0,16),d=i.slice(16),p=new s.default.ModeOfOperation.cbc(o,l),v=u.arrayify(p.decrypt(d));v=s.default.padding.pkcs7.strip(v);for(var b="",w=0;wo[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return u||(u=new e(a.version)),u},e.setCensorship=function(t,r){if(n){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}i=!!t,n=!!r},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();r.Logger=h},{"./_version":90}],92:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="networks/5.0.0-beta.128"},{}],93:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/logger"),i=e("./_version"),o=new n.Logger(i.version);function s(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function a(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var u={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:s("homestead")},c={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:s("ropsten")},h={unspecified:{chainId:0,name:"unspecified"},homestead:u,mainnet:u,morden:{chainId:2,name:"morden"},ropsten:c,testnet:c,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:s("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:s("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:s("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:a("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:a("https://web3.gastracker.io/morden","classicTestnet")}};r.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in h){var r=h[t];if(r.chainId===e)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var n=h[e];return null==n?null:{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress,_defaultProvider:n._defaultProvider||null}}var i=h[e.name];return i?(0!==e.chainId&&e.chainId!==i.chainId&&o.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:i.chainId,ensAddress:e.ensAddress||i.ensAddress||null,_defaultProvider:e._defaultProvider||i._defaultProvider||null}):("number"!=typeof e.chainId&&o.throwArgumentError("invalid network chainId","network",e),e)}},{"./_version":92,"@ethersproject/logger":91}],94:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes"),i=e("@ethersproject/sha2");r.pbkdf2=function(e,t,r,o,s){var a;e=n.arrayify(e),t=n.arrayify(t);var u,c,h=1,f=new Uint8Array(o),l=new Uint8Array(t.length+4);l.set(t);for(var d=1;d<=h;d++){l[t.length]=d>>24&255,l[t.length+1]=d>>16&255,l[t.length+2]=d>>8&255,l[t.length+3]=255&d;var p=n.arrayify(i.computeHmac(s,e,l));a||(a=p.length,c=new Uint8Array(a),u=o-((h=Math.ceil(o/a))-1)*a),c.set(p);for(var g=1;g=0||"block"===this.tag||"pending"===this.tag},e}(),E=null,P=1,k=function(e){function t(t){var r=this.constructor,n=this;if(g.checkNew(r,o.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)h.defineReadOnly(n,"ready",t.then(function(e){return h.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=h.getStatic(r,"getNetwork")(t);i?(h.defineReadOnly(n,"_network",i),h.defineReadOnly(n,"ready",Promise.resolve(n._network))):g.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==E&&(E=new m.Formatter),E},t.getNetwork=function(e){return c.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=P++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],s=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(s);break;case"filter":var a=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:a};u.address||delete u.address;s=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(s)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=w();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=f.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return g.throwError(e+" not implemented",d.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new _(b(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&h.throwError("insufficient funds",u.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&h.throwError("nonce has already been used",u.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&h.throwError("replacement fee too low",u.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",c(i+=o);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,c(i+=o);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,c(i+=o);case"call":if((g=f(r.transaction))&&(g="&"+g),i+="/api?module=proxy&action=eth_call"+g,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return c(i+=o);case"estimateGas":var g;return(g=f(r.transaction))&&(g="&"+g),i+="/api?module=proxy&action=eth_estimateGas&"+g,c(i+=o);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+p(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+p(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var m=r.filter.topics[0];if("string"!=typeof m||66!==m.length)throw new Error("unsupported topic0 format");i+="&topic0="+m}}catch(e){return Promise.reject(e)}var y=this;return c(i+=o,l).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?y.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",c(i+=o,l).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),a.fetchJson(i,null,l).then(function(e){n.emit("debug",{action:"response",request:i,response:s.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(e("./base-provider").BaseProvider);r.EtherscanProvider=g},{"./_version":97,"./base-provider":99,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/web":132}],103:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/random"),s=e("@ethersproject/properties"),a=e("@ethersproject/logger"),u=e("./_version"),c=new a.Logger(u.version);function h(){return(new Date).getTime()}function f(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||c.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var l=1,d=function(e){function t(r,n,i){var o=this.constructor,u=this;c.checkNew(o,t),0===r.length&&c.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?c.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&c.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var h=i.reduce(function(e,t){return e+t});if(null==n?n=h/2:n>h&&c.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),f(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return f(e)||c.throwError("getNetwork returned null",a.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return s.defineReadOnly(u,"providers",Object.freeze(r.slice())),s.defineReadOnly(u,"quorum",n),s.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return c.throwError("unknown method error",a.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=h(),u=o.shuffled(this.providers).map(function(o,a){var u=n.weights[a],c=l++;return{run:function(){var a=h(),f=a-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:u,start:f,provider:o},request:{method:e,params:s.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=h()-a;return n.emit("debug",{action:"response",rid:c,backend:{weight:u,start:f,duration:i,provider:o},request:{method:e,params:s.deepCopy(r)},response:s.deepCopy(t)}),{weight:u,result:t}},function(t){var i=h()-a;return n.emit("debug",{action:"response",rid:c,backend:{weight:u,start:f,duration:i,provider:o},request:{method:e,params:s.deepCopy(r)},error:t}),{weight:u,error:t}})},weight:u}});return"sendTransaction"===e?Promise.all(u.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=h[g][0].result;return n.emit("debug","quorum",-1,{weight:m,result:y}),t(y),void(h=null)}}}if(0===u.length&&0===s){if("getGasPrice"===e){var v=[];Object.keys(h).forEach(function(e){h[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===o&&(o=c.makeError("failed to meet quorum",a.Logger.errors.SERVER_ERROR,{results:Object.keys(h).map(function(t){return{method:e,params:r,result:t,weight:h[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(o)}setTimeout(f,0)}}),s=0&&p.throwError("insufficient funds",l.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&p.throwError("nonce has already been used",l.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&p.throwError("replacement fee too low",l.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return p.throwError("signing transactions is unsupported",l.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return f.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?h.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),a.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(o.Signer);r.JsonRpcSigner=b;var w=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(b),_={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},E=function(e){function t(r,n){var i=this.constructor,o=this;if(p.checkNew(i,t),"string"==typeof r&&null===n&&u.getNetwork(r)&&(n=r,r=null),n)o=e.call(this,n)||this;else{var a=new Promise(function(e,t){setTimeout(function(){o.send("eth_chainId",[]).then(function(t){e(u.getNetwork(s.BigNumber.from(t).toNumber()))}).catch(function(r){o.send("net_version",[]).then(function(t){e(u.getNetwork(s.BigNumber.from(t).toNumber()))}).catch(function(e){t(p.makeError("could not detect network",l.Logger.errors.NETWORK_ERROR))})})})});o=e.call(this,a)||this}return r||(r="http://localhost:8545"),o.connection="string"==typeof r?{url:r}:r,o._nextId=42,o}return i(t,e),t.prototype.getSigner=function(e){return new b(v,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:c.deepCopy(n),provider:this}),f.fetchJson(this.connection,JSON.stringify(n),m).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[y(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[y(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[y(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[y(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&p.throwError("insufficient funds",l.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&p.throwError("nonce has already been used",l.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&p.throwError("replacement fee too low",l.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):p.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=y(t.filter.address)),this.send("eth_getLogs",[t.filter])}return p.throwError(e+" not implemented",l.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=c.shallowCopy(_);if(t)for(var n in t)t[n]&&(r[n]=!0);c.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=a.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=a.hexlify(e[t]))}),i},t}(g.BaseProvider);r.JsonRpcProvider=E},{"./_version":97,"./base-provider":99,"@ethersproject/abstract-signer":60,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/networks":93,"@ethersproject/properties":96,"@ethersproject/strings":123,"@ethersproject/web":132}],108:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("./url-json-rpc-provider"),s=e("@ethersproject/logger"),a=e("./_version"),u=new s.Logger(a.version),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return e||"ETHERS_JS_SHARED"},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:u.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+t},t}(o.UrlJsonRpcProvider);r.NodesmithProvider=c},{"./_version":97,"./url-json-rpc-provider":109,"@ethersproject/logger":91}],109:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/networks"),s=e("@ethersproject/properties"),a=e("@ethersproject/logger"),u=e("./_version"),c=new a.Logger(u.version),h=function(e){function t(r,n){var i,o=this.constructor;c.checkAbstract(o,t),r=s.getStatic(o,"getNetwork")(r),n=s.getStatic(o,"getApiKey")(n);var a=s.getStatic(o,"getUrl")(r,n);return i=e.call(this,a,r)||this,s.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){c.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return c.throwError("API provider does not support signing",a.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return o.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return c.throwError("not implemented; sub-classes must override getUrl",a.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(e("./json-rpc-provider").JsonRpcProvider);r.UrlJsonRpcProvider=h},{"./_version":97,"./json-rpc-provider":107,"@ethersproject/logger":91,"@ethersproject/networks":93,"@ethersproject/properties":96}],110:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/properties"),s=e("@ethersproject/logger"),a=e("./_version"),u=new s.Logger(a.version),c=function(e){function t(r,n){var i=this.constructor,s=this;return u.checkNew(i,t),s=e.call(this,r.host||r.path||"",n)||this,r&&(r.sendAsync?s._sendAsync=r.sendAsync.bind(r):r.send&&(s._sendAsync=r.send.bind(r))),r&&s._sendAsync||u.throwArgumentError("invalid web3Provider","web3Provider",r),o.defineReadOnly(s,"_web3Provider",r),s}return i(t,e),t.prototype.send=function(e,t){var r=this;return"eth_sign"==e&&this._web3Provider.isMetaMask&&(e="personal_sign",t=[t[1],t[0]]),new Promise(function(n,i){var o={method:e,params:t,id:42,jsonrpc:"2.0"};r._sendAsync(o,function(e,t){if(e)i(e);else{if(t.error){var r=new Error(t.error.message);return r.code=t.error.code,r.data=t.error.data,void i(r)}n(t.result)}})})},t}(e("./json-rpc-provider").JsonRpcProvider);r.Web3Provider=c},{"./_version":97,"./json-rpc-provider":107,"@ethersproject/logger":91,"@ethersproject/properties":96}],111:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="random/5.0.0-beta.127"},{}],112:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes"),i=e("@ethersproject/logger"),o=e("./_version"),s=new i.Logger(o.version),a=e("./shuffle");r.shuffled=a.shuffled;var u=t.crypto||t.msCrypto;u&&u.getRandomValues||(s.warn("WARNING: Missing strong random number source"),u={getRandomValues:function(e){return s.throwError("no secure random source avaialble",i.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&s.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return u.getRandomValues(t),n.arrayify(t)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_version":111,"./shuffle":113,"@ethersproject/bytes":70,"@ethersproject/logger":91}],113:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}},{}],114:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bytes");function i(e){for(var t=[];e;)t.unshift(255&e),e>>=8;return t}function o(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function a(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=o(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return s(e,t,t+1+a,a+r)}if(e[t]>=192){var i=e[t]-192;if(t+1+i>e.length)throw new Error("invalid rlp data");return s(e,t,t+1,i)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var u=o(e,t+1,a);if(t+1+a+u>e.length)throw new Error("invalid rlp data");return{consumed:1+a+u,result:n.hexlify(e.slice(t+1+a,t+1+a+u))}}if(e[t]>=128){var c=e[t]-128;if(t+1+c>e.length)throw new Error("invlaid rlp data");return{consumed:1+c,result:n.hexlify(e.slice(t+1,t+1+c))}}return{consumed:1,result:n.hexlify(e[t])}}r.encode=function(e){return n.hexlify(function e(t){if(Array.isArray(t)){var r=[];if(t.forEach(function(t){r=r.concat(e(t))}),r.length<=55)return r.unshift(192+r.length),r;var o=i(r.length);return o.unshift(247+o.length),o.concat(r)}var s=Array.prototype.slice.call(n.arrayify(t));if(1===s.length&&s[0]<=127)return s;if(s.length<=55)return s.unshift(128+s.length),s;var a=i(s.length);return a.unshift(183+a.length),a.concat(s)}(e))},r.decode=function(e){var t=n.arrayify(e),r=a(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}},{"@ethersproject/bytes":70}],115:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="sha2/5.0.0-beta.128"},{}],116:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i,o=n(e("hash.js")),s=e("@ethersproject/bytes"),a=e("@ethersproject/logger"),u=e("./_version"),c=new a.Logger(u.version);!function(e){e.sha256="sha256",e.sha512="sha512"}(i=r.SupportedAlgorithms||(r.SupportedAlgorithms={})),r.ripemd160=function(e){return"0x"+o.ripemd160().update(s.arrayify(e)).digest("hex")},r.sha256=function(e){return"0x"+o.sha256().update(s.arrayify(e)).digest("hex")},r.sha512=function(e){return"0x"+o.sha512().update(s.arrayify(e)).digest("hex")},r.computeHmac=function(e,t,r){return i[e]||c.throwError("unsupported algorithm "+e,a.Logger.errors.UNSUPPORTED_OPERATION,{operation:"hmac",algorithm:e}),"0x"+o.hmac(o[e],s.arrayify(t)).update(s.arrayify(r)).digest("hex")}},{"./_version":115,"@ethersproject/bytes":70,"@ethersproject/logger":91,"hash.js":21}],117:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="signing-key/5.0.0-beta.128"},{}],118:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("elliptic"),i=e("@ethersproject/bytes"),o=e("@ethersproject/properties"),s=e("@ethersproject/logger"),a=e("./_version"),u=new s.Logger(a.version),c=null;function h(){return c||(c=new n.ec("secp256k1")),c}var f=function(){function e(e){o.defineReadOnly(this,"curve","secp256k1"),o.defineReadOnly(this,"privateKey",i.hexlify(e));var t=h().keyFromPrivate(i.arrayify(this.privateKey));o.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),o.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),o.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=h().keyFromPublic(i.arrayify(this.publicKey)),r=h().keyFromPublic(i.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=h().keyFromPrivate(i.arrayify(this.privateKey)).sign(i.arrayify(e),{canonical:!0});return i.splitSignature({recoveryParam:t.recoveryParam,r:i.hexZeroPad("0x"+t.r.toString(16),32),s:i.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=h().keyFromPrivate(i.arrayify(this.privateKey)),r=h().keyFromPublic(i.arrayify(l(e)));return i.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function l(e,t){var r=i.arrayify(e);if(32===r.length){var n=new f(r);return t?"0x"+h().keyFromPrivate(r).getPublic(!0,"hex"):n.publicKey}return 33===r.length?t?i.hexlify(r):"0x"+h().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?t?"0x"+h().keyFromPublic(r).getPublic(!0,"hex"):i.hexlify(r):u.throwArgumentError("invalid public or private key","key","[REDACTED]")}r.SigningKey=f,r.recoverPublicKey=function(e,t){var r=i.splitSignature(t),n={r:i.arrayify(r.r),s:i.arrayify(r.s)};return"0x"+h().recoverPubKey(i.arrayify(e),n,r.recoveryParam).encode("hex",!1)},r.computePublicKey=l},{"./_version":117,"@ethersproject/bytes":70,"@ethersproject/logger":91,"@ethersproject/properties":96,elliptic:6}],119:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bignumber"),i=e("@ethersproject/bytes"),o=e("@ethersproject/keccak256"),s=e("@ethersproject/sha2"),a=e("@ethersproject/strings"),u=new RegExp("^bytes([0-9]+)$"),c=new RegExp("^(u?int)([0-9]*)$"),h=new RegExp("^(.*)\\[([0-9]*)\\]$"),f="0000000000000000000000000000000000000000000000000000000000000000";function l(e,t){if(e.length!=t.length)throw new Error("type/value count mismatch");var r=[];return e.forEach(function(e,o){r.push(function e(t,r,o){switch(t){case"address":return o?i.zeroPad(r,32):i.arrayify(r);case"string":return a.toUtf8Bytes(r);case"bytes":return i.arrayify(r);case"bool":return r=r?"0x01":"0x00",o?i.zeroPad(r,32):i.arrayify(r)}var s=t.match(c);if(s){if((l=parseInt(s[2]||"256"))%8!=0||0===l||l>256)throw new Error("invalid number type - "+t);return o&&(l=256),r=n.BigNumber.from(r).toTwos(l),i.zeroPad(r,l/8)}if(s=t.match(u)){var l=parseInt(s[1]);if(String(l)!=s[1]||0===l||l>32)throw new Error("invalid number type - "+t);if(i.arrayify(r).byteLength!==l)throw new Error("invalid value for "+t);return o?i.arrayify((r+f).substring(0,66)):r}if((s=t.match(h))&&Array.isArray(r)){var d=s[1];if(parseInt(s[2]||String(r.length))!=r.length)throw new Error("invalid value for "+t);var p=[];return r.forEach(function(t){p.push(e(d,t,!0))}),i.concat(p)}throw new Error("unknown type - "+t)}(e,t[o]))}),i.hexlify(i.concat(r))}r.pack=l,r.keccak256=function(e,t){return o.keccak256(l(e,t))},r.sha256=function(e,t){return s.sha256(l(e,t))}},{"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/keccak256":89,"@ethersproject/sha2":116,"@ethersproject/strings":123}],120:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="strings/5.0.0-beta.129"},{}],121:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/constants"),i=e("@ethersproject/bytes"),o=e("./utf8");r.formatBytes32String=function(e){var t=o.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return i.hexlify(i.concat([t,n.HashZero]).slice(0,32))},r.parseBytes32String=function(e){var t=i.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return o.toUtf8String(t.slice(0,r))}},{"./utf8":124,"@ethersproject/bytes":70,"@ethersproject/constants":71}],122:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./utf8");function i(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function o(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function s(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}var a=o("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),u="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),c=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],h=i("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=i("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),l=i("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=g(e);return t||[e]}).reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(t=n.toUtf8CodePoints(n._toUtf8String(t),n.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(m(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),t.forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var r=n._toUtf8String(t);if("-"===r.substring(0,1)||"--"===r.substring(2,4)||"-"===r.substring(r.length-1))throw new Error("invalid hyphen");if(r.length>63)throw new Error("too long");return r}},{"./utf8":124}],123:[function(e,t,r){"use strcit";"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./bytes32");r.formatBytes32String=n.formatBytes32String,r.parseBytes32String=n.parseBytes32String;var i=e("./idna");r.nameprep=i.nameprep;var o=e("./utf8");r._toEscapedUtf8String=o._toEscapedUtf8String,r.toUtf8Bytes=o.toUtf8Bytes,r.toUtf8CodePoints=o.toUtf8CodePoints,r.toUtf8String=o.toUtf8String,r.UnicodeNormalizationForm=o.UnicodeNormalizationForm},{"./bytes32":121,"./idna":122,"./utf8":124}],124:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n,i=e("@ethersproject/bytes"),o=e("@ethersproject/logger"),s=e("./_version"),a=new o.Logger(s.version);function u(e,t){e=i.arrayify(e);for(var r=[],n=0;n>7!=0){var s=null,a=null;if(192==(224&o))s=1,a=127;else if(224==(240&o))s=2,a=2047;else{if(240!=(248&o)){if(!t){if(128==(192&o))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}s=3,a=65535}if(n+s>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var u=o&(1<<8-s-1)-1,c=0;c1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(u>=55296&&u<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(u);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(o)}return r}function c(e,t){void 0===t&&(t=n.current),t!=n.current&&(a.checkNormalize(),e=e.normalize(t));for(var r=[],o=0;o>6|192),r.push(63&s|128);else if(55296==(64512&s)){o++;var u=e.charCodeAt(o);if(o>=e.length||56320!=(64512&u))throw new Error("invalid utf-8 string");s=65536+((1023&s)<<10)+(1023&u),r.push(s>>18|240),r.push(s>>12&63|128),r.push(s>>6&63|128),r.push(63&s|128)}else r.push(s>>12|224),r.push(s>>6&63|128),r.push(63&s|128)}return i.arrayify(r)}function h(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function f(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(n=r.UnicodeNormalizationForm||(r.UnicodeNormalizationForm={})),r.toUtf8Bytes=c,r._toEscapedUtf8String=function(e,t){return'"'+u(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?h(e):h(55296+((e-=65536)>>10&1023))+h(56320+(1023&e))}).join("")+'"'},r._toUtf8String=f,r.toUtf8String=function(e,t){return f(u(e,t))},r.toUtf8CodePoints=function(e,t){return void 0===t&&(t=n.current),u(c(e,t))}},{"./_version":120,"@ethersproject/bytes":70,"@ethersproject/logger":91}],125:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="transactions/5.0.0-beta.127"},{}],126:[function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=e("@ethersproject/address"),o=e("@ethersproject/bignumber"),s=e("@ethersproject/bytes"),a=e("@ethersproject/constants"),u=e("@ethersproject/keccak256"),c=e("@ethersproject/properties"),h=n(e("@ethersproject/rlp")),f=e("@ethersproject/signing-key"),l=e("@ethersproject/logger"),d=e("./_version"),p=new l.Logger(d.version);function g(e){return"0x"===e?a.Zero:o.BigNumber.from(e)}var m=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],y={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function v(e){var t=f.computePublicKey(e);return i.getAddress(s.hexDataSlice(u.keccak256(s.hexDataSlice(t,1)),12))}function b(e,t){return v(f.recoverPublicKey(s.arrayify(e),t))}r.computeAddress=v,r.recoverAddress=b,r.serialize=function(e,t){c.checkProperties(e,y);var r=[];m.forEach(function(t){var n=e[t.name]||[];n=s.arrayify(s.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&p.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=s.stripZeros(n)).length>t.maxLength&&p.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(s.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(s.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=h.encode(r);if(!t)return n;var i=s.splitSignature(t),o=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),o+=2*e.chainId+8),r.push(s.hexlify(o)),r.push(s.stripZeros(s.arrayify(i.r))),r.push(s.stripZeros(s.arrayify(i.s))),h.encode(r)},r.parse=function(e){var t=h.decode(e);9!==t.length&&6!==t.length&&p.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:g(t[0]).toNumber(),gasPrice:g(t[1]),gasLimit:g(t[2]),to:(r=t[3],"0x"===r?null:i.getAddress(r)),value:g(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=o.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=s.hexZeroPad(t[7],32),n.s=s.hexZeroPad(t[8],32),o.BigNumber.from(n.r).isZero()&&o.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var a=n.v-27,c=t.slice(0,6);0!==n.chainId&&(c.push(s.hexlify(n.chainId)),c.push("0x"),c.push("0x"),a-=2*n.chainId+8);var f=u.keccak256(h.encode(c));try{n.from=b(f,{r:s.hexlify(n.r),s:s.hexlify(n.s),recoveryParam:a})}catch(e){console.log(e)}n.hash=u.keccak256(e)}return n}},{"./_version":125,"@ethersproject/address":62,"@ethersproject/bignumber":68,"@ethersproject/bytes":70,"@ethersproject/constants":71,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/rlp":114,"@ethersproject/signing-key":118}],127:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="units/5.0.0-beta.126"},{}],128:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("@ethersproject/bignumber/fixednumber"),i=e("@ethersproject/logger"),o=e("./_version"),s=new i.Logger(o.version),a=["wei","kwei","mwei","gwei","szabo","finney","ether"];function u(e,t){if("string"==typeof t){var r=a.indexOf(t);-1!==r&&(t=3*r)}return n.formatFixed(e,null!=t?t:18)}function c(e,t){if("string"==typeof t){var r=a.indexOf(t);-1!==r&&(t=3*r)}return n.parseFixed(e,null!=t?t:18)}r.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&s.throwArgumentError("invalid value","value",e);var r=t[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");var i="";2===t.length&&(i="."+(t[1]||"0"));for(var o=[];r.length;){if(r.length<=3){o.unshift(r);break}var a=r.length-3;o.unshift(r.substring(a)),r=r.substring(0,a)}return n+o.join(",")+i},r.formatUnits=u,r.parseUnits=c,r.formatEther=function(e){return u(e,18)},r.parseEther=function(e){return c(e,18)}},{"./_version":127,"@ethersproject/bignumber/fixednumber":67,"@ethersproject/logger":91}],129:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="wallet/5.0.0-beta.129"},{}],130:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("@ethersproject/address"),s=e("@ethersproject/abstract-provider"),a=e("@ethersproject/abstract-signer"),u=e("@ethersproject/bytes"),c=e("@ethersproject/hash"),h=e("@ethersproject/hdnode"),f=e("@ethersproject/keccak256"),l=e("@ethersproject/properties"),d=e("@ethersproject/random"),p=e("@ethersproject/signing-key"),g=e("@ethersproject/json-wallets"),m=e("@ethersproject/transactions"),y=e("@ethersproject/logger"),v=e("./_version"),b=new y.Logger(v.version);var w=function(e){function t(r,n){var i,a,c=this.constructor;if(b.checkNew(c,t),i=e.call(this)||this,null!=(a=r)&&u.isHexString(a.privateKey,32)&&null!=a.address){var f=new p.SigningKey(r.privateKey);if(l.defineReadOnly(i,"_signingKey",function(){return f}),l.defineReadOnly(i,"address",m.computeAddress(i.publicKey)),i.address!==o.getAddress(r.address)&&b.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var d=r.mnemonic,g=r.path||h.defaultPath;l.defineReadOnly(i,"_mnemonic",function(){return d}),l.defineReadOnly(i,"path",r.path);var y=h.HDNode.fromMnemonic(d).derivePath(g);m.computeAddress(y.privateKey)!==i.address&&b.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else l.defineReadOnly(i,"_mnemonic",function(){return null}),l.defineReadOnly(i,"path",null)}else{if(p.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&b.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),l.defineReadOnly(i,"_signingKey",function(){return r});else{var v=new p.SigningKey(r);l.defineReadOnly(i,"_signingKey",function(){return v})}l.defineReadOnly(i,"_mnemonic",function(){return null}),l.defineReadOnly(i,"path",null),l.defineReadOnly(i,"address",m.computeAddress(i.publicKey))}return n&&!s.Provider.isProvider(n)&&b.throwArgumentError("invalid provider","provider",n),l.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return l.resolveProperties(e).then(function(e){if(null!=e.from){if(o.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(f.keccak256(m.serialize(e)));return m.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(u.joinSignature(this._signingKey().signDigest(c.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),g.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=d.randomBytes(16);e||(e={}),e.extraEntropy&&(r=u.arrayify(u.hexDataSlice(f.keccak256(u.concat([r,e.extraEntropy])),0,16)));var n=h.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return g.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=h.defaultPath),new t(h.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(a.Signer);r.Wallet=w,r.verifyMessage=function(e,t){return m.recoverAddress(c.hashMessage(e),t)}},{"./_version":129,"@ethersproject/abstract-provider":58,"@ethersproject/abstract-signer":60,"@ethersproject/address":62,"@ethersproject/bytes":70,"@ethersproject/hash":80,"@ethersproject/hdnode":82,"@ethersproject/json-wallets":85,"@ethersproject/keccak256":89,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/random":112,"@ethersproject/signing-key":118,"@ethersproject/transactions":126}],131:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="web/5.0.0-beta.128"},{}],132:[function(e,t,r){"use strict";var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var i=n(e("cross-fetch")),o=e("@ethersproject/base64"),s=e("@ethersproject/properties"),a=e("@ethersproject/strings"),u=e("@ethersproject/logger"),c=e("./_version"),h=new u.Logger(c.version);r.fetchJson=function(e,t,r){var n={},s=null,c={method:"GET",mode:"cors",cache:"no-cache",credentials:"same-origin",redirect:"follow",referrer:"client"},f=12e4;if("string"==typeof e)s=e;else if("object"==typeof e){if(null!=e&&null!=e.url||h.throwArgumentError("missing URL","connection.url",e),s=e.url,"number"==typeof e.timeout&&e.timeout>0&&(f=e.timeout),e.headers)for(var l in e.headers)n[l.toLowerCase()]={key:l,value:String(e.headers[l])};if(null!=e.user&&null!=e.password){"https:"!==s.substring(0,6)&&!0!==e.allowInsecureAuthentication&&h.throwError("basic authentication requires a secure https url",u.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:s,user:e.user,password:"[REDACTED]"});var d=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+o.encode(a.toUtf8Bytes(d))}}}return new Promise(function(e,o){var a=null;f&&(a=setTimeout(function(){null!=a&&(a=null,o(h.makeError("timeout",u.Logger.errors.TIMEOUT,{timeout:f})))},f));var l=function(){null!=a&&(clearTimeout(a),a=null)};t&&(c.method="POST",c.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),c.headers=d,i.default(s,c).then(function(e){return e.text().then(function(t){return e.ok||h.throwError("bad response",u.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){h.throwError("invalid JSON",u.Logger.errors.SERVER_ERROR,{body:e,error:t,url:s})}if(r)try{t=r(t)}catch(e){h.throwError("processing response error",u.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){l(),e(t)},function(e){l(),o(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=s.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,s=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){s()&&n(new Error("timeout"))},t.timeout));var a=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)s()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>a)return void(s()&&n(new Error("retry limit reached")));var c=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ct.ceiling&&(c=t.ceiling),setTimeout(i,c)}return null},function(e){s()&&n(e)})}()})}},{"./_version":131,"@ethersproject/base64":63,"@ethersproject/logger":91,"@ethersproject/properties":96,"@ethersproject/strings":123,"cross-fetch":5}],133:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.version="wordlists/5.0.0-beta.127"},{}],134:[function(e,t,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=e("./wordlist");r.Wordlist=n.Wordlist;var i={en:e("./lang-en").langEn};r.wordlists=i},{"./lang-en":135,"./wordlist":136}],135:[function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=e("./wordlist"),s="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function u(e){if(null==a&&(a=s.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==o.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var c=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return u(this),a[e]},t.prototype.getWordIndex=function(e){return u(this),a.indexOf(e)},t}(o.Wordlist));r.langEn=c,o.register(c)},{"./wordlist":136}],136:[function(e,t,r){(function(t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=e("@ethersproject/hash"),o=e("@ethersproject/properties"),s=e("@ethersproject/logger"),a=e("./_version"),u=new s.Logger(a.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return i.id(t.join("\n")+"\n")};var c=function(){function e(t){var r=this.constructor;u.checkAbstract(r,e),o.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=c,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||o.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||o.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||o.defineReadOnly(i.ethers.wordlists,r,e))}}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./_version":133,"@ethersproject/hash":80,"@ethersproject/logger":91,"@ethersproject/properties":96}]},{},[76])(76)}); \ No newline at end of file diff --git a/packages/ethers/dist/ethers.umd.js b/packages/ethers/dist/ethers.umd.js index cdd8b5d31..4be9d3232 100644 --- a/packages/ethers/dist/ethers.umd.js +++ b/packages/ethers/dist/ethers.umd.js @@ -3464,13 +3464,13 @@ var _version = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "logger/5.0.0-beta.129"; + exports.version = "logger/5.0.0-beta.128"; }); var _version$1 = unwrapExports(_version); var _version_1 = _version.version; - var logger = createCommonjsModule(function (module, exports) { + var lib = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _permanentCensorErrors = false; @@ -3752,24 +3752,24 @@ exports.Logger = Logger; }); - var index = unwrapExports(logger); - var logger_1 = logger.Logger; + var index = unwrapExports(lib); + var lib_1 = lib.Logger; var _version$2 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "bytes/5.0.0-beta.129"; + exports.version = "bytes/5.0.0-beta.128"; }); var _version$3 = unwrapExports(_version$2); var _version_1$1 = _version$2.version; - var bytes = createCommonjsModule(function (module, exports) { + var lib$1 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$2.version); + var logger = new lib.Logger(_version$2.version); /////////////////////////////// function isHexable(value) { return !!(value.toHexString); @@ -3815,7 +3815,7 @@ options = {}; } if (typeof (value) === "number") { - logger$1.checkSafeUint53(value, "invalid arrayify value"); + logger.checkSafeUint53(value, "invalid arrayify value"); var result = []; while (value) { result.unshift(value & 0xff); @@ -3835,7 +3835,7 @@ if (isHexString(value)) { var hex = value.substring(2); if (!options.allowOddLength && hex.length % 2) { - logger$1.throwArgumentError("hex data is odd-length", "value", value); + logger.throwArgumentError("hex data is odd-length", "value", value); } var result = []; for (var i = 0; i < hex.length; i += 2) { @@ -3846,7 +3846,7 @@ if (isBytes(value)) { return addSlice(new Uint8Array(value)); } - return logger$1.throwArgumentError("invalid arrayify value", "value", value); + return logger.throwArgumentError("invalid arrayify value", "value", value); } exports.arrayify = arrayify; function concat(items) { @@ -3880,7 +3880,7 @@ function zeroPad(value, length) { value = arrayify(value); if (value.length > length) { - logger$1.throwArgumentError("value out of range", "value", arguments[0]); + logger.throwArgumentError("value out of range", "value", arguments[0]); } var result = new Uint8Array(length); result.set(value, length - value.length); @@ -3903,7 +3903,7 @@ options = {}; } if (typeof (value) === "number") { - logger$1.checkSafeUint53(value, "invalid hexlify value"); + logger.checkSafeUint53(value, "invalid hexlify value"); var hex = ""; while (value) { hex = HexCharacters[value & 0x0f] + hex; @@ -3925,7 +3925,7 @@ } if (isHexString(value)) { if (!options.allowOddLength && value.length % 2) { - logger$1.throwArgumentError("hex data is odd-length", "value", value); + logger.throwArgumentError("hex data is odd-length", "value", value); } return value.toLowerCase(); } @@ -3937,7 +3937,7 @@ } return result; } - return logger$1.throwArgumentError("invalid hexlify value", "value", value); + return logger.throwArgumentError("invalid hexlify value", "value", value); } exports.hexlify = hexlify; /* @@ -3963,7 +3963,7 @@ data = hexlify(data); } else if (!isHexString(data) || (data.length % 2)) { - logger$1.throwArgumentError("invalid hexData", "value", data); + logger.throwArgumentError("invalid hexData", "value", data); } offset = 2 + 2 * offset; if (endOffset != null) { @@ -3993,7 +3993,7 @@ value = hexlify(value); } if (!isHexString(value)) { - logger$1.throwArgumentError("invalid hex string", "value", value); + logger.throwArgumentError("invalid hex string", "value", value); } value = value.substring(2); var offset = 0; @@ -4008,10 +4008,10 @@ value = hexlify(value); } else if (!isHexString(value)) { - logger$1.throwArgumentError("invalid hex string", "value", value); + logger.throwArgumentError("invalid hex string", "value", value); } if (value.length > 2 * length + 2) { - logger$1.throwArgumentError("value out of range", "value", arguments[1]); + logger.throwArgumentError("value out of range", "value", arguments[1]); } while (value.length < 2 * length + 2) { value = "0x0" + value.substring(2); @@ -4030,7 +4030,7 @@ if (isBytesLike(signature)) { var bytes = arrayify(signature); if (bytes.length !== 65) { - logger$1.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); + logger.throwArgumentError("invalid signature string; must be 65 bytes", "signature", signature); } // Get the r and s result.r = hexlify(bytes.slice(0, 32)); @@ -4067,7 +4067,7 @@ } else if (result.recoveryParam != null && result.v != null) { if (result.v !== 27 + result.recoveryParam) { - logger$1.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); + logger.throwArgumentError("signature v mismatch recoveryParam", "signature", signature); } } // Make sure r and s are padded properly @@ -4082,7 +4082,7 @@ if (result._vs != null) { result._vs = hexZeroPad(result._vs, 32); if (result._vs.length > 66) { - logger$1.throwArgumentError("signature _vs overflow", "signature", signature); + logger.throwArgumentError("signature _vs overflow", "signature", signature); } var vs = arrayify(result._vs); var recoveryParam = ((vs[0] >= 128) ? 1 : 0); @@ -4095,37 +4095,37 @@ result.s = s; } else if (result.s !== s) { - logger$1.throwArgumentError("signature v mismatch _vs", "signature", signature); + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); } if (result.v == null) { result.v = v; } else if (result.v !== v) { - logger$1.throwArgumentError("signature v mismatch _vs", "signature", signature); + logger.throwArgumentError("signature v mismatch _vs", "signature", signature); } if (recoveryParam == null) { result.recoveryParam = recoveryParam; } else if (result.recoveryParam !== recoveryParam) { - logger$1.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); + logger.throwArgumentError("signature recoveryParam mismatch _vs", "signature", signature); } } // After all populating, both v and recoveryParam are still missing... if (result.v == null && result.recoveryParam == null) { - logger$1.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); + logger.throwArgumentError("signature requires at least one of recoveryParam, v or _vs", "signature", signature); } // Check for canonical v if (result.v !== 27 && result.v !== 28) { - logger$1.throwArgumentError("signature v not canonical", "signature", signature); + logger.throwArgumentError("signature v not canonical", "signature", signature); } // Check that r and s are in range if (result.r.length > 66 || result.s.length > 66) { - logger$1.throwArgumentError("signature overflow r or s", "signature", signature); + logger.throwArgumentError("signature overflow r or s", "signature", signature); } if (result._vs == null) { var vs = arrayify(result.s); if (vs[0] >= 128) { - logger$1.throwArgumentError("signature s out of range", "signature", signature); + logger.throwArgumentError("signature s out of range", "signature", signature); } if (result.recoveryParam) { vs[0] |= 0x80; @@ -4147,28 +4147,28 @@ exports.joinSignature = joinSignature; }); - var index$1 = unwrapExports(bytes); - var bytes_1 = bytes.isBytesLike; - var bytes_2 = bytes.isBytes; - var bytes_3 = bytes.arrayify; - var bytes_4 = bytes.concat; - var bytes_5 = bytes.stripZeros; - var bytes_6 = bytes.zeroPad; - var bytes_7 = bytes.isHexString; - var bytes_8 = bytes.hexlify; - var bytes_9 = bytes.hexDataLength; - var bytes_10 = bytes.hexDataSlice; - var bytes_11 = bytes.hexConcat; - var bytes_12 = bytes.hexValue; - var bytes_13 = bytes.hexStripZeros; - var bytes_14 = bytes.hexZeroPad; - var bytes_15 = bytes.splitSignature; - var bytes_16 = bytes.joinSignature; + var index$1 = unwrapExports(lib$1); + var lib_1$1 = lib$1.isBytesLike; + var lib_2 = lib$1.isBytes; + var lib_3 = lib$1.arrayify; + var lib_4 = lib$1.concat; + var lib_5 = lib$1.stripZeros; + var lib_6 = lib$1.zeroPad; + var lib_7 = lib$1.isHexString; + var lib_8 = lib$1.hexlify; + var lib_9 = lib$1.hexDataLength; + var lib_10 = lib$1.hexDataSlice; + var lib_11 = lib$1.hexConcat; + var lib_12 = lib$1.hexValue; + var lib_13 = lib$1.hexStripZeros; + var lib_14 = lib$1.hexZeroPad; + var lib_15 = lib$1.splitSignature; + var lib_16 = lib$1.joinSignature; var _version$4 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "bignumber/5.0.0-beta.130"; + exports.version = "bignumber/5.0.0-beta.129"; }); var _version$5 = unwrapExports(_version$4); @@ -4195,24 +4195,24 @@ - var logger$1 = new logger.Logger(_version$4.version); + var logger = new lib.Logger(_version$4.version); var _constructorGuard = {}; var MAX_SAFE = 0x1fffffffffffff; function isBigNumberish(value) { return (value != null) && (BigNumber.isBigNumber(value) || (typeof (value) === "number" && (value % 1) === 0) || (typeof (value) === "string" && !!value.match(/^-?[0-9]+$/)) || - bytes.isHexString(value) || + lib$1.isHexString(value) || (typeof (value) === "bigint") || - bytes.isBytes(value)); + lib$1.isBytes(value)); } exports.isBigNumberish = isBigNumberish; var BigNumber = /** @class */ (function () { function BigNumber(constructorGuard, hex) { var _newTarget = this.constructor; - logger$1.checkNew(_newTarget, BigNumber); + logger.checkNew(_newTarget, BigNumber); if (constructorGuard !== _constructorGuard) { - logger$1.throwError("cannot call consturtor directly; use BigNumber.from", logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("cannot call consturtor directly; use BigNumber.from", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "new (BigNumber)" }); } @@ -4287,7 +4287,7 @@ BigNumber.prototype.toString = function () { // Lots of people expect this, which we do not support, so check if (arguments.length !== 0) { - logger$1.throwError("bigNumber.toString does not accept parameters", logger.Logger.errors.UNEXPECTED_ARGUMENT, {}); + logger.throwError("bigNumber.toString does not accept parameters", lib.Logger.errors.UNEXPECTED_ARGUMENT, {}); } return toBN(this).toString(10); }; @@ -4305,7 +4305,7 @@ if (value.match(/^-?[0-9]+$/)) { return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); } - return logger$1.throwArgumentError("invalid BigNumber string", "value", value); + return logger.throwArgumentError("invalid BigNumber string", "value", value); } if (typeof (value) === "number") { if (value % 1) { @@ -4319,10 +4319,10 @@ if (typeof (value) === "bigint") { return BigNumber.from(value.toString()); } - if (bytes.isBytes(value)) { - return BigNumber.from(bytes.hexlify(value)); + if (lib$1.isBytes(value)) { + return BigNumber.from(lib$1.hexlify(value)); } - if (value._hex && bytes.isHexString(value._hex)) { + if (value._hex && lib$1.isHexString(value._hex)) { return BigNumber.from(value._hex); } if (value.toHexString) { @@ -4331,7 +4331,7 @@ return BigNumber.from(value); } } - return logger$1.throwArgumentError("invalid BigNumber value", "value", value); + return logger.throwArgumentError("invalid BigNumber value", "value", value); }; BigNumber.isBigNumber = function (value) { return !!(value && value._isBigNumber); @@ -4351,7 +4351,7 @@ value = value.substring(1); // Cannot have mulitple negative signs (e.g. "--0x04") if (value[0] === "-") { - logger$1.throwArgumentError("invalid hex", "value", value); + logger.throwArgumentError("invalid hex", "value", value); } // Call toHex on the positive component value = toHex(value); @@ -4395,7 +4395,7 @@ if (value != null) { params.value = value; } - return logger$1.throwError(fault, logger.Logger.errors.NUMERIC_FAULT, params); + return logger.throwError(fault, lib.Logger.errors.NUMERIC_FAULT, params); } }); @@ -4409,7 +4409,7 @@ - var logger$1 = new logger.Logger(_version$4.version); + var logger = new lib.Logger(_version$4.version); var _constructorGuard = {}; var Zero = bignumber.BigNumber.from(0); @@ -4419,7 +4419,7 @@ if (value !== undefined) { params.value = value; } - return logger$1.throwError(message, logger.Logger.errors.NUMERIC_FAULT, params); + return logger.throwError(message, lib.Logger.errors.NUMERIC_FAULT, params); } // Constant to pull zeros from for multipliers var zeros = "0"; @@ -4437,7 +4437,7 @@ if (typeof (decimals) === "number" && decimals >= 0 && decimals <= 256 && !(decimals % 1)) { return ("1" + zeros.substring(0, decimals)); } - return logger$1.throwArgumentError("invalid decimal size", "decimals", decimals); + return logger.throwArgumentError("invalid decimal size", "decimals", decimals); } function formatFixed(value, decimals) { if (decimals == null) { @@ -4470,7 +4470,7 @@ } var multiplier = getMultiplier(decimals); if (typeof (value) !== "string" || !value.match(/^-?[0-9.,]+$/)) { - logger$1.throwArgumentError("invalid decimal value", "value", value); + logger.throwArgumentError("invalid decimal value", "value", value); } if (multiplier.length - 1 === 0) { return bignumber.BigNumber.from(value); @@ -4481,12 +4481,12 @@ value = value.substring(1); } if (value === ".") { - logger$1.throwArgumentError("missing value", "value", value); + logger.throwArgumentError("missing value", "value", value); } // Split it into a whole and fractional part var comps = value.split("."); if (comps.length > 2) { - logger$1.throwArgumentError("too many decimal points", "value", value); + logger.throwArgumentError("too many decimal points", "value", value); } var whole = comps[0], fraction = comps[1]; if (!whole) { @@ -4538,7 +4538,7 @@ else if (value != null) { var match = value.match(/^(u?)fixed([0-9]+)x([0-9]+)$/); if (!match) { - logger$1.throwArgumentError("invalid fixed format", "format", value); + logger.throwArgumentError("invalid fixed format", "format", value); } signed = (match[1] !== "u"); width = parseInt(match[2]); @@ -4551,7 +4551,7 @@ return defaultValue; } if (typeof (value[key]) !== type) { - logger$1.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); + logger.throwArgumentError("invalid fixed format (" + key + " not " + type + ")", "format." + key, value[key]); } return value[key]; }; @@ -4560,10 +4560,10 @@ decimals = check("decimals", "number", decimals); } if (width % 8) { - logger$1.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); + logger.throwArgumentError("invalid fixed format width (not byte aligned)", "format.width", width); } if (decimals > 80) { - logger$1.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); + logger.throwArgumentError("invalid fixed format (decimals too large)", "format.decimals", decimals); } return new FixedFormat(_constructorGuard, signed, width, decimals); }; @@ -4573,7 +4573,7 @@ var FixedNumber = /** @class */ (function () { function FixedNumber(constructorGuard, hex, value, format) { var _newTarget = this.constructor; - logger$1.checkNew(_newTarget, FixedNumber); + logger.checkNew(_newTarget, FixedNumber); this.format = format; this._hex = hex; this._value = value; @@ -4582,7 +4582,7 @@ } FixedNumber.prototype._checkFormat = function (other) { if (this.format.name !== other.format.name) { - logger$1.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); + logger.throwArgumentError("incompatible format; use fixedNumber.toFormat", "other", other); } }; FixedNumber.prototype.addUnsafe = function (other) { @@ -4615,7 +4615,7 @@ decimals = 0; } if (decimals < 0 || decimals > 80 || (decimals % 1)) { - logger$1.throwArgumentError("invalid decimal cound", "decimals", decimals); + logger.throwArgumentError("invalid decimal cound", "decimals", decimals); } // If we are already in range, we're done var comps = this.toString().split("."); @@ -4634,10 +4634,10 @@ return this._hex; } if (width % 8) { - logger$1.throwArgumentError("invalid byte width", "width", width); + logger.throwArgumentError("invalid byte width", "width", width); } var hex = bignumber.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(width).toHexString(); - return bytes.hexZeroPad(hex, width / 8); + return lib$1.hexZeroPad(hex, width / 8); }; FixedNumber.prototype.toUnsafeFloat = function () { return parseFloat(this.toString()); }; FixedNumber.prototype.toFormat = function (format) { @@ -4672,7 +4672,7 @@ } else { hex = numeric.toHexString(); - hex = bytes.hexZeroPad(hex, fixedFormat.width / 8); + hex = lib$1.hexZeroPad(hex, fixedFormat.width / 8); } var decimal = formatFixed(numeric, fixedFormat.decimals); return new FixedNumber(_constructorGuard, hex, decimal, fixedFormat); @@ -4682,7 +4682,7 @@ format = "fixed"; } var fixedFormat = FixedFormat.from(format); - if (bytes.arrayify(value).length > fixedFormat.width / 8) { + if (lib$1.arrayify(value).length > fixedFormat.width / 8) { throw new Error("overflow"); } var numeric = bignumber.BigNumber.from(value); @@ -4697,7 +4697,7 @@ if (typeof (value) === "string") { return FixedNumber.fromString(value, format); } - if (bytes.isBytes(value)) { + if (lib$1.isBytes(value)) { return FixedNumber.fromBytes(value, format); } try { @@ -4705,11 +4705,11 @@ } catch (error) { // Allow NUMERIC_FAULT to bubble up - if (error.code !== logger.Logger.errors.INVALID_ARGUMENT) { + if (error.code !== lib.Logger.errors.INVALID_ARGUMENT) { throw error; } } - return logger$1.throwArgumentError("invalid FixedNumber value", "value", value); + return logger.throwArgumentError("invalid FixedNumber value", "value", value); }; FixedNumber.isFixedNumber = function (value) { return !!(value && value._isFixedNumber); @@ -4725,34 +4725,40 @@ var fixednumber_3 = fixednumber.FixedFormat; var fixednumber_4 = fixednumber.FixedNumber; - var bignumber$2 = createCommonjsModule(function (module, exports) { + var lib$2 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BigNumber = bignumber.BigNumber; + exports.formatFixed = fixednumber.formatFixed; + exports.FixedFormat = fixednumber.FixedFormat; exports.FixedNumber = fixednumber.FixedNumber; + exports.parseFixed = fixednumber.parseFixed; }); - var index$2 = unwrapExports(bignumber$2); - var bignumber_2$1 = bignumber$2.BigNumber; - var bignumber_3 = bignumber$2.FixedNumber; + var index$2 = unwrapExports(lib$2); + var lib_1$2 = lib$2.BigNumber; + var lib_2$1 = lib$2.formatFixed; + var lib_3$1 = lib$2.FixedFormat; + var lib_4$1 = lib$2.FixedNumber; + var lib_5$1 = lib$2.parseFixed; var _version$6 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "properties/5.0.0-beta.131"; + exports.version = "properties/5.0.0-beta.130"; }); var _version$7 = unwrapExports(_version$6); var _version_1$3 = _version$6.version; - var properties = createCommonjsModule(function (module, exports) { + var lib$3 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$6.version); + var logger = new lib.Logger(_version$6.version); function defineReadOnly(object, name, value) { Object.defineProperty(object, name, { enumerable: true, @@ -4796,11 +4802,11 @@ exports.resolveProperties = resolveProperties; function checkProperties(object, properties) { if (!object || typeof (object) !== "object") { - logger$1.throwArgumentError("invalid object", "object", object); + logger.throwArgumentError("invalid object", "object", object); } Object.keys(object).forEach(function (key) { if (!properties[key]) { - logger$1.throwArgumentError("invalid object key - " + key, "transaction:" + key, object); + logger.throwArgumentError("invalid object key - " + key, "transaction:" + key, object); } }); } @@ -4859,19 +4865,19 @@ exports.Description = Description; }); - var index$3 = unwrapExports(properties); - var properties_1 = properties.defineReadOnly; - var properties_2 = properties.getStatic; - var properties_3 = properties.resolveProperties; - var properties_4 = properties.checkProperties; - var properties_5 = properties.shallowCopy; - var properties_6 = properties.deepCopy; - var properties_7 = properties.Description; + var index$3 = unwrapExports(lib$3); + var lib_1$3 = lib$3.defineReadOnly; + var lib_2$2 = lib$3.getStatic; + var lib_3$2 = lib$3.resolveProperties; + var lib_4$2 = lib$3.checkProperties; + var lib_5$2 = lib$3.shallowCopy; + var lib_6$1 = lib$3.deepCopy; + var lib_7$1 = lib$3.Description; var _version$8 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "abi/5.0.0-beta.137"; + exports.version = "abi/5.0.0-beta.136"; }); var _version$9 = unwrapExports(_version$8); @@ -4897,7 +4903,7 @@ - var logger$1 = new logger.Logger(_version$8.version); + var logger = new lib.Logger(_version$8.version); ; var _constructorGuard = {}; var ModifiersBytes = { calldata: true, memory: true, storage: true }; @@ -4913,7 +4919,7 @@ } } if (ModifiersBytes[name] || name === "payable") { - logger$1.throwArgumentError("invalid modifier", "name", name); + logger.throwArgumentError("invalid modifier", "name", name); } return false; } @@ -5078,7 +5084,7 @@ } function populate(object, params) { for (var key in params) { - properties.defineReadOnly(object, key, params[key]); + lib$3.defineReadOnly(object, key, params[key]); } } exports.FormatTypes = Object.freeze({ @@ -5128,7 +5134,7 @@ format = exports.FormatTypes.sighash; } if (!exports.FormatTypes[format]) { - logger$1.throwArgumentError("invalid format type", "format", format); + logger.throwArgumentError("invalid format type", "format", format); } if (format === exports.FormatTypes.json) { var result_1 = { @@ -5243,7 +5249,7 @@ // @TODO: return null; } - return logger$1.throwArgumentError("invalid fragment object", "value", value); + return logger.throwArgumentError("invalid fragment object", "value", value); }; Fragment.fromString = function (value) { // Make sure the "returns" is surrounded by a space and all whitespace is exactly one space @@ -5277,7 +5283,7 @@ format = exports.FormatTypes.sighash; } if (!exports.FormatTypes[format]) { - logger$1.throwArgumentError("invalid format type", "format", format); + logger.throwArgumentError("invalid format type", "format", format); } if (format === exports.FormatTypes.json) { return JSON.stringify({ @@ -5333,7 +5339,7 @@ case "": break; default: - logger$1.warn("unknown modifier: " + modifier); + logger.warn("unknown modifier: " + modifier); } }); return EventFragment.fromObject({ @@ -5359,7 +5365,7 @@ if (!comps[1].match(/^[0-9]+$/)) { throw new Error("invalid signature gas"); } - params.gas = bignumber$2.BigNumber.from(comps[1]); + params.gas = lib$2.BigNumber.from(comps[1]); return comps[0]; } return value; @@ -5440,7 +5446,7 @@ format = exports.FormatTypes.sighash; } if (!exports.FormatTypes[format]) { - logger$1.throwArgumentError("invalid format type", "format", format); + logger.throwArgumentError("invalid format type", "format", format); } if (format === exports.FormatTypes.json) { return JSON.stringify({ @@ -5452,7 +5458,7 @@ }); } if (format === exports.FormatTypes.sighash) { - logger$1.throwError("cannot format a constructor for sighash", logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("cannot format a constructor for sighash", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "format(sighash)" }); } @@ -5483,7 +5489,7 @@ type: value.type, inputs: (value.inputs ? value.inputs.map(ParamType.fromObject) : []), payable: state.payable, - gas: (value.gas ? bignumber$2.BigNumber.from(value.gas) : null) + gas: (value.gas ? lib$2.BigNumber.from(value.gas) : null) }); }; ConstructorFragment.fromString = function (value) { @@ -5516,7 +5522,7 @@ format = exports.FormatTypes.sighash; } if (!exports.FormatTypes[format]) { - logger$1.throwArgumentError("invalid format type", "format", format); + logger.throwArgumentError("invalid format type", "format", format); } if (format === exports.FormatTypes.json) { return JSON.stringify({ @@ -5575,7 +5581,7 @@ outputs: (value.outputs ? value.outputs.map(ParamType.fromObject) : []), payable: state.payable, stateMutability: state.stateMutability, - gas: (value.gas ? bignumber$2.BigNumber.from(value.gas) : null) + gas: (value.gas ? lib$2.BigNumber.from(value.gas) : null) }); }; FunctionFragment.fromString = function (value) { @@ -5684,7 +5690,7 @@ - var logger$1 = new logger.Logger(_version$8.version); + var logger = new lib.Logger(_version$8.version); var Coder = /** @class */ (function () { function Coder(name, type, localName, dynamic) { this.name = name; @@ -5693,19 +5699,19 @@ this.dynamic = dynamic; } Coder.prototype._throwError = function (message, value) { - logger$1.throwArgumentError(message, this.localName, value); + logger.throwArgumentError(message, this.localName, value); }; return Coder; }()); exports.Coder = Coder; var Writer = /** @class */ (function () { function Writer(wordSize) { - properties.defineReadOnly(this, "wordSize", wordSize || 32); - this._data = bytes.arrayify([]); + lib$3.defineReadOnly(this, "wordSize", wordSize || 32); + this._data = lib$1.arrayify([]); this._padding = new Uint8Array(wordSize); } Object.defineProperty(Writer.prototype, "data", { - get: function () { return bytes.hexlify(this._data); }, + get: function () { return lib$1.hexlify(this._data); }, enumerable: true, configurable: true }); @@ -5715,29 +5721,29 @@ configurable: true }); Writer.prototype._writeData = function (data) { - this._data = bytes.concat([this._data, data]); + this._data = lib$1.concat([this._data, data]); return data.length; }; // Arrayish items; padded on the right to wordSize Writer.prototype.writeBytes = function (value) { - var bytes$1 = bytes.arrayify(value); - if (bytes$1.length % this.wordSize) { - bytes$1 = bytes.concat([bytes$1, this._padding.slice(bytes$1.length % this.wordSize)]); + var bytes = lib$1.arrayify(value); + if (bytes.length % this.wordSize) { + bytes = lib$1.concat([bytes, this._padding.slice(bytes.length % this.wordSize)]); } - return this._writeData(bytes$1); + return this._writeData(bytes); }; Writer.prototype._getValue = function (value) { - var bytes$1 = bytes.arrayify(bignumber$2.BigNumber.from(value)); - if (bytes$1.length > this.wordSize) { - logger$1.throwError("value out-of-bounds", logger.Logger.errors.BUFFER_OVERRUN, { + var bytes = lib$1.arrayify(lib$2.BigNumber.from(value)); + if (bytes.length > this.wordSize) { + logger.throwError("value out-of-bounds", lib.Logger.errors.BUFFER_OVERRUN, { length: this.wordSize, - offset: bytes$1.length + offset: bytes.length }); } - if (bytes$1.length % this.wordSize) { - bytes$1 = bytes.concat([this._padding.slice(bytes$1.length % this.wordSize), bytes$1]); + if (bytes.length % this.wordSize) { + bytes = lib$1.concat([this._padding.slice(bytes.length % this.wordSize), bytes]); } - return bytes$1; + return bytes; }; // BigNumberish items; padded on the left to wordSize Writer.prototype.writeValue = function (value) { @@ -5756,13 +5762,13 @@ exports.Writer = Writer; var Reader = /** @class */ (function () { function Reader(data, wordSize, coerceFunc) { - properties.defineReadOnly(this, "_data", bytes.arrayify(data)); - properties.defineReadOnly(this, "wordSize", wordSize || 32); - properties.defineReadOnly(this, "_coerceFunc", coerceFunc); + lib$3.defineReadOnly(this, "_data", lib$1.arrayify(data)); + lib$3.defineReadOnly(this, "wordSize", wordSize || 32); + lib$3.defineReadOnly(this, "_coerceFunc", coerceFunc); this._offset = 0; } Object.defineProperty(Reader.prototype, "data", { - get: function () { return bytes.hexlify(this._data); }, + get: function () { return lib$1.hexlify(this._data); }, enumerable: true, configurable: true }); @@ -5788,7 +5794,7 @@ Reader.prototype._peekBytes = function (offset, length) { var alignedLength = Math.ceil(length / this.wordSize) * this.wordSize; if (this._offset + alignedLength > this._data.length) { - logger$1.throwError("data out-of-bounds", logger.Logger.errors.BUFFER_OVERRUN, { + logger.throwError("data out-of-bounds", lib.Logger.errors.BUFFER_OVERRUN, { length: this._data.length, offset: this._offset + alignedLength }); @@ -5805,7 +5811,7 @@ return bytes.slice(0, length); }; Reader.prototype.readValue = function () { - return bignumber$2.BigNumber.from(this.readBytes(this.wordSize)); + return lib$2.BigNumber.from(this.readBytes(this.wordSize)); }; return Reader; }()); @@ -6295,7 +6301,7 @@ })(); }); - var keccak256_1 = createCommonjsModule(function (module, exports) { + var lib$4 = createCommonjsModule(function (module, exports) { "use strict"; var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -6304,15 +6310,15 @@ var js_sha3_1 = __importDefault(sha3); function keccak256(data) { - return '0x' + js_sha3_1.default.keccak_256(bytes.arrayify(data)); + return '0x' + js_sha3_1.default.keccak_256(lib$1.arrayify(data)); } exports.keccak256 = keccak256; }); - var index$4 = unwrapExports(keccak256_1); - var keccak256_2 = keccak256_1.keccak256; + var index$4 = unwrapExports(lib$4); + var lib_1$4 = lib$4.keccak256; - var rlp = createCommonjsModule(function (module, exports) { + var lib$5 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); //See: https://github.com/ethereum/wiki/wiki/RLP @@ -6346,7 +6352,7 @@ length_1.unshift(0xf7 + length_1.length); return length_1.concat(payload_1); } - var data = Array.prototype.slice.call(bytes.arrayify(object)); + var data = Array.prototype.slice.call(lib$1.arrayify(object)); if (data.length === 1 && data[0] <= 0x7f) { return data; } @@ -6359,7 +6365,7 @@ return length.concat(data); } function encode(object) { - return bytes.hexlify(_encode(object)); + return lib$1.hexlify(_encode(object)); } exports.encode = encode; function _decodeChildren(data, offset, childOffset, length) { @@ -6407,7 +6413,7 @@ if (offset + 1 + lengthLength + length_4 > data.length) { throw new Error("invalid rlp data"); } - var result = bytes.hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4)); + var result = lib$1.hexlify(data.slice(offset + 1 + lengthLength, offset + 1 + lengthLength + length_4)); return { consumed: (1 + lengthLength + length_4), result: result }; } else if (data[offset] >= 0x80) { @@ -6415,15 +6421,15 @@ if (offset + 1 + length_5 > data.length) { throw new Error("invlaid rlp data"); } - var result = bytes.hexlify(data.slice(offset + 1, offset + 1 + length_5)); + var result = lib$1.hexlify(data.slice(offset + 1, offset + 1 + length_5)); return { consumed: (1 + length_5), result: result }; } - return { consumed: 1, result: bytes.hexlify(data[offset]) }; + return { consumed: 1, result: lib$1.hexlify(data[offset]) }; } function decode(data) { - var bytes$1 = bytes.arrayify(data); - var decoded = _decode(bytes$1, 0); - if (decoded.consumed !== bytes$1.length) { + var bytes = lib$1.arrayify(data); + var decoded = _decode(bytes, 0); + if (decoded.consumed !== bytes.length) { throw new Error("invalid rlp data"); } return decoded.result; @@ -6431,20 +6437,20 @@ exports.decode = decode; }); - var index$5 = unwrapExports(rlp); - var rlp_1 = rlp.encode; - var rlp_2 = rlp.decode; + var index$5 = unwrapExports(lib$5); + var lib_1$5 = lib$5.encode; + var lib_2$3 = lib$5.decode; var _version$a = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "address/5.0.0-beta.128"; + exports.version = "address/5.0.0-beta.127"; }); var _version$b = unwrapExports(_version$a); var _version_1$5 = _version$a.version; - var address = createCommonjsModule(function (module, exports) { + var lib$6 = createCommonjsModule(function (module, exports) { "use strict"; var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; @@ -6461,10 +6467,10 @@ - var logger$1 = new logger.Logger(_version$a.version); + var logger = new lib.Logger(_version$a.version); function getChecksumAddress(address) { - if (!bytes.isHexString(address, 20)) { - logger$1.throwArgumentError("invalid address", "address", address); + if (!lib$1.isHexString(address, 20)) { + logger.throwArgumentError("invalid address", "address", address); } address = address.toLowerCase(); var chars = address.substring(2).split(""); @@ -6472,7 +6478,7 @@ for (var i = 0; i < 40; i++) { hashed[i] = chars[i].charCodeAt(0); } - hashed = bytes.arrayify(keccak256_1.keccak256(hashed)); + hashed = lib$1.arrayify(lib$4.keccak256(hashed)); for (var i = 0; i < 40; i += 2) { if ((hashed[i >> 1] >> 4) >= 8) { chars[i] = chars[i].toUpperCase(); @@ -6524,7 +6530,7 @@ function getAddress(address) { var result = null; if (typeof (address) !== "string") { - logger$1.throwArgumentError("invalid address", "address", address); + logger.throwArgumentError("invalid address", "address", address); } if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) { // Missing the 0x prefix @@ -6534,14 +6540,14 @@ result = getChecksumAddress(address); // It is a checksummed address with a bad checksum if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) { - logger$1.throwArgumentError("bad address checksum", "address", address); + logger.throwArgumentError("bad address checksum", "address", address); } // Maybe ICAP? (we only support direct mode) } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) { // It is an ICAP address with a bad checksum if (address.substring(2, 4) !== ibanChecksum(address)) { - logger$1.throwArgumentError("bad icap checksum", "address", address); + logger.throwArgumentError("bad icap checksum", "address", address); } result = (new BN.BN(address.substring(4), 36)).toString(16); while (result.length < 40) { @@ -6550,7 +6556,7 @@ result = getChecksumAddress("0x" + result); } else { - logger$1.throwArgumentError("invalid address", "address", address); + logger.throwArgumentError("invalid address", "address", address); } return result; } @@ -6579,21 +6585,21 @@ from = getAddress(transaction.from); } catch (error) { - logger$1.throwArgumentError("missing from address", "transaction", transaction); + logger.throwArgumentError("missing from address", "transaction", transaction); } - var nonce = bytes.stripZeros(bytes.arrayify(transaction.nonce)); - return getAddress(bytes.hexDataSlice(keccak256_1.keccak256(rlp.encode([from, nonce])), 12)); + var nonce = lib$1.stripZeros(lib$1.arrayify(transaction.nonce)); + return getAddress(lib$1.hexDataSlice(lib$4.keccak256(lib$5.encode([from, nonce])), 12)); } exports.getContractAddress = getContractAddress; }); - var index$6 = unwrapExports(address); - var address_1 = address.getAddress; - var address_2 = address.isAddress; - var address_3 = address.getIcapAddress; - var address_4 = address.getContractAddress; + var index$6 = unwrapExports(lib$6); + var lib_1$6 = lib$6.getAddress; + var lib_2$4 = lib$6.isAddress; + var lib_3$3 = lib$6.getIcapAddress; + var lib_4$3 = lib$6.getContractAddress; - var address$1 = createCommonjsModule(function (module, exports) { + var address = createCommonjsModule(function (module, exports) { "use strict"; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { var extendStatics = function (d, b) { @@ -6619,7 +6625,7 @@ } AddressCoder.prototype.encode = function (writer, value) { try { - address.getAddress(value); + lib$6.getAddress(value); } catch (error) { this._throwError(error.message, value); @@ -6627,15 +6633,15 @@ return writer.writeValue(value); }; AddressCoder.prototype.decode = function (reader) { - return address.getAddress(bytes.hexZeroPad(reader.readValue().toHexString(), 20)); + return lib$6.getAddress(lib$1.hexZeroPad(reader.readValue().toHexString(), 20)); }; return AddressCoder; }(abstractCoder.Coder)); exports.AddressCoder = AddressCoder; }); - var address$2 = unwrapExports(address$1); - var address_2$1 = address$1.AddressCoder; + var address$1 = unwrapExports(address); + var address_2 = address.AddressCoder; var anonymous = createCommonjsModule(function (module, exports) { "use strict"; @@ -6694,7 +6700,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$8.version); + var logger = new lib.Logger(_version$8.version); function pack(writer, coders, values) { @@ -6709,10 +6715,10 @@ values = arrayValues_1; } else { - logger$1.throwArgumentError("invalid tuple value", "tuple", values); + logger.throwArgumentError("invalid tuple value", "tuple", values); } if (coders.length !== values.length) { - logger$1.throwArgumentError("types/value length mismatch", "tuple", values); + logger.throwArgumentError("types/value length mismatch", "tuple", values); } var staticWriter = new abstractCoder.Writer(writer.wordSize); var dynamicWriter = new abstractCoder.Writer(writer.wordSize); @@ -6803,7 +6809,7 @@ count = value.length; writer.writeValue(value.length); } - logger$1.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); + logger.checkArgumentCount(count, value.length, "coder array" + (this.localName ? (" " + this.localName) : "")); var coders = []; for (var i = 0; i < value.length; i++) { coders.push(this.coder); @@ -6867,7 +6873,7 @@ var boolean = unwrapExports(boolean_1); var boolean_2 = boolean_1.BooleanCoder; - var bytes$1 = createCommonjsModule(function (module, exports) { + var bytes = createCommonjsModule(function (module, exports) { "use strict"; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { var extendStatics = function (d, b) { @@ -6891,7 +6897,7 @@ return _super.call(this, type, type, localName, true) || this; } DynamicBytesCoder.prototype.encode = function (writer, value) { - value = bytes.arrayify(value); + value = lib$1.arrayify(value); var length = writer.writeValue(value.length); length += writer.writeBytes(value); return length; @@ -6908,16 +6914,16 @@ return _super.call(this, "bytes", localName) || this; } BytesCoder.prototype.decode = function (reader) { - return reader.coerce(this.name, bytes.hexlify(_super.prototype.decode.call(this, reader))); + return reader.coerce(this.name, lib$1.hexlify(_super.prototype.decode.call(this, reader))); }; return BytesCoder; }(DynamicBytesCoder)); exports.BytesCoder = BytesCoder; }); - var bytes$2 = unwrapExports(bytes$1); - var bytes_2$1 = bytes$1.DynamicBytesCoder; - var bytes_3$1 = bytes$1.BytesCoder; + var bytes$1 = unwrapExports(bytes); + var bytes_2 = bytes.DynamicBytesCoder; + var bytes_3 = bytes.BytesCoder; var fixedBytes = createCommonjsModule(function (module, exports) { "use strict"; @@ -6948,14 +6954,14 @@ return _this; } FixedBytesCoder.prototype.encode = function (writer, value) { - var data = bytes.arrayify(value); + var data = lib$1.arrayify(value); if (data.length !== this.size) { this._throwError("incorrect data length", value); } return writer.writeBytes(data); }; FixedBytesCoder.prototype.decode = function (reader) { - return reader.coerce(this.name, bytes.hexlify(reader.readBytes(this.size))); + return reader.coerce(this.name, lib$1.hexlify(reader.readBytes(this.size))); }; return FixedBytesCoder; }(abstractCoder.Coder)); @@ -7005,7 +7011,7 @@ var _null$1 = unwrapExports(_null); var _null_1 = _null.NullCoder; - var constants = createCommonjsModule(function (module, exports) { + var lib$7 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -7018,30 +7024,30 @@ // NFKC (composed) var EtherSymbol = "\u039e"; exports.EtherSymbol = EtherSymbol; - var NegativeOne = bignumber$2.BigNumber.from(-1); + var NegativeOne = lib$2.BigNumber.from(-1); exports.NegativeOne = NegativeOne; - var Zero = bignumber$2.BigNumber.from(0); + var Zero = lib$2.BigNumber.from(0); exports.Zero = Zero; - var One = bignumber$2.BigNumber.from(1); + var One = lib$2.BigNumber.from(1); exports.One = One; - var Two = bignumber$2.BigNumber.from(2); + var Two = lib$2.BigNumber.from(2); exports.Two = Two; - var WeiPerEther = bignumber$2.BigNumber.from("1000000000000000000"); + var WeiPerEther = lib$2.BigNumber.from("1000000000000000000"); exports.WeiPerEther = WeiPerEther; - var MaxUint256 = bignumber$2.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); + var MaxUint256 = lib$2.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); exports.MaxUint256 = MaxUint256; }); - var index$7 = unwrapExports(constants); - var constants_1 = constants.AddressZero; - var constants_2 = constants.HashZero; - var constants_3 = constants.EtherSymbol; - var constants_4 = constants.NegativeOne; - var constants_5 = constants.Zero; - var constants_6 = constants.One; - var constants_7 = constants.Two; - var constants_8 = constants.WeiPerEther; - var constants_9 = constants.MaxUint256; + var index$7 = unwrapExports(lib$7); + var lib_1$7 = lib$7.AddressZero; + var lib_2$5 = lib$7.HashZero; + var lib_3$4 = lib$7.EtherSymbol; + var lib_4$4 = lib$7.NegativeOne; + var lib_5$3 = lib$7.Zero; + var lib_6$2 = lib$7.One; + var lib_7$2 = lib$7.Two; + var lib_8$1 = lib$7.WeiPerEther; + var lib_9$1 = lib$7.MaxUint256; var number = createCommonjsModule(function (module, exports) { "use strict"; @@ -7073,16 +7079,16 @@ return _this; } NumberCoder.prototype.encode = function (writer, value) { - var v = bignumber$2.BigNumber.from(value); + var v = lib$2.BigNumber.from(value); // Check bounds are safe for encoding - var maxUintValue = constants.MaxUint256.maskn(writer.wordSize * 8); + var maxUintValue = lib$7.MaxUint256.maskn(writer.wordSize * 8); if (this.signed) { var bounds = maxUintValue.maskn(this.size * 8 - 1); - if (v.gt(bounds) || v.lt(bounds.add(constants.One).mul(constants.NegativeOne))) { + if (v.gt(bounds) || v.lt(bounds.add(lib$7.One).mul(lib$7.NegativeOne))) { this._throwError("value out-of-bounds", value); } } - else if (v.lt(constants.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { + else if (v.lt(lib$7.Zero) || v.gt(maxUintValue.maskn(this.size * 8))) { this._throwError("value out-of-bounds", value); } v = v.toTwos(this.size * 8).maskn(this.size * 8); @@ -7109,7 +7115,7 @@ var _version$c = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "strings/5.0.0-beta.130"; + exports.version = "strings/5.0.0-beta.129"; }); var _version$d = unwrapExports(_version$c); @@ -7121,7 +7127,7 @@ - var logger$1 = new logger.Logger(_version$c.version); + var logger = new lib.Logger(_version$c.version); /////////////////////////////// var UnicodeNormalizationForm; (function (UnicodeNormalizationForm) { @@ -7133,13 +7139,13 @@ })(UnicodeNormalizationForm = exports.UnicodeNormalizationForm || (exports.UnicodeNormalizationForm = {})); ; // http://stackoverflow.com/questions/13356493/decode-utf-8-with-javascript#13691499 - function getUtf8CodePoints(bytes$1, ignoreErrors) { - bytes$1 = bytes.arrayify(bytes$1); + function getUtf8CodePoints(bytes, ignoreErrors) { + bytes = lib$1.arrayify(bytes); var result = []; var i = 0; // Invalid bytes are ignored - while (i < bytes$1.length) { - var c = bytes$1[i++]; + while (i < bytes.length) { + var c = bytes[i++]; // 0xxx xxxx if (c >> 7 === 0) { result.push(c); @@ -7173,13 +7179,13 @@ continue; } // Do we have enough bytes in our data? - if (i + extraLength > bytes$1.length) { + if (i + extraLength > bytes.length) { if (!ignoreErrors) { throw new Error("invalid utf8 byte sequence; too short"); } // If there is an invalid unprocessed byte, skip continuation bytes - for (; i < bytes$1.length; i++) { - if (bytes$1[i] >> 6 !== 0x02) { + for (; i < bytes.length; i++) { + if (bytes[i] >> 6 !== 0x02) { break; } } @@ -7188,7 +7194,7 @@ // Remove the length prefix from the char var res = c & ((1 << (8 - extraLength - 1)) - 1); for (var j = 0; j < extraLength; j++) { - var nextChar = bytes$1[i]; + var nextChar = bytes[i]; // Invalid continuation byte if ((nextChar & 0xc0) != 0x80) { res = null; @@ -7233,7 +7239,7 @@ function toUtf8Bytes(str, form) { if (form === void 0) { form = UnicodeNormalizationForm.current; } if (form != UnicodeNormalizationForm.current) { - logger$1.checkNormalize(); + logger.checkNormalize(); str = str.normalize(form); } var result = []; @@ -7265,7 +7271,7 @@ result.push((c & 0x3f) | 0x80); } } - return bytes.arrayify(result); + return lib$1.arrayify(result); } exports.toUtf8Bytes = toUtf8Bytes; ; @@ -7333,17 +7339,17 @@ function formatBytes32String(text) { // Get the bytes - var bytes$1 = utf8.toUtf8Bytes(text); + var bytes = utf8.toUtf8Bytes(text); // Check we have room for null-termination - if (bytes$1.length > 31) { + if (bytes.length > 31) { throw new Error("bytes32 string must be less than 32 bytes"); } // Zero-pad (implicitly null-terminates) - return bytes.hexlify(bytes.concat([bytes$1, constants.HashZero]).slice(0, 32)); + return lib$1.hexlify(lib$1.concat([bytes, lib$7.HashZero]).slice(0, 32)); } exports.formatBytes32String = formatBytes32String; - function parseBytes32String(bytes$1) { - var data = bytes.arrayify(bytes$1); + function parseBytes32String(bytes) { + var data = lib$1.arrayify(bytes); // Must be 32 bytes with a null-termination if (data.length !== 32) { throw new Error("invalid bytes32 - not 32 bytes long"); @@ -7567,7 +7573,7 @@ var idna_3 = idna._nameprepTableC; var idna_4 = idna.nameprep; - var strings = createCommonjsModule(function (module, exports) { + var lib$8 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -7583,15 +7589,15 @@ exports.UnicodeNormalizationForm = utf8.UnicodeNormalizationForm; }); - var index$8 = unwrapExports(strings); - var strings_1 = strings.formatBytes32String; - var strings_2 = strings.parseBytes32String; - var strings_3 = strings.nameprep; - var strings_4 = strings._toEscapedUtf8String; - var strings_5 = strings.toUtf8Bytes; - var strings_6 = strings.toUtf8CodePoints; - var strings_7 = strings.toUtf8String; - var strings_8 = strings.UnicodeNormalizationForm; + var index$8 = unwrapExports(lib$8); + var lib_1$8 = lib$8.formatBytes32String; + var lib_2$6 = lib$8.parseBytes32String; + var lib_3$5 = lib$8.nameprep; + var lib_4$5 = lib$8._toEscapedUtf8String; + var lib_5$4 = lib$8.toUtf8Bytes; + var lib_6$3 = lib$8.toUtf8CodePoints; + var lib_7$3 = lib$8.toUtf8String; + var lib_8$2 = lib$8.UnicodeNormalizationForm; var string = createCommonjsModule(function (module, exports) { "use strict"; @@ -7617,13 +7623,13 @@ return _super.call(this, "string", localName) || this; } StringCoder.prototype.encode = function (writer, value) { - return _super.prototype.encode.call(this, writer, strings.toUtf8Bytes(value)); + return _super.prototype.encode.call(this, writer, lib$8.toUtf8Bytes(value)); }; StringCoder.prototype.decode = function (reader) { - return strings.toUtf8String(_super.prototype.decode.call(this, reader)); + return lib$8.toUtf8String(_super.prototype.decode.call(this, reader)); }; return StringCoder; - }(bytes$1.DynamicBytesCoder)); + }(bytes.DynamicBytesCoder)); exports.StringCoder = StringCoder; }); @@ -7687,7 +7693,7 @@ - var logger$1 = new logger.Logger(_version$8.version); + var logger = new lib.Logger(_version$8.version); @@ -7704,20 +7710,20 @@ var AbiCoder = /** @class */ (function () { function AbiCoder(coerceFunc) { var _newTarget = this.constructor; - logger$1.checkNew(_newTarget, AbiCoder); - properties.defineReadOnly(this, "coerceFunc", coerceFunc || null); + logger.checkNew(_newTarget, AbiCoder); + lib$3.defineReadOnly(this, "coerceFunc", coerceFunc || null); } AbiCoder.prototype._getCoder = function (param) { var _this = this; switch (param.baseType) { case "address": - return new address$1.AddressCoder(param.name); + return new address.AddressCoder(param.name); case "bool": return new boolean_1.BooleanCoder(param.name); case "string": return new string.StringCoder(param.name); case "bytes": - return new bytes$1.BytesCoder(param.name); + return new bytes.BytesCoder(param.name); case "array": return new array.ArrayCoder(this._getCoder(param.arrayChildren), param.arrayLength, param.name); case "tuple": @@ -7732,7 +7738,7 @@ if (match) { var size = parseInt(match[2] || "256"); if (size === 0 || size > 256 || (size % 8) !== 0) { - logger$1.throwArgumentError("invalid " + match[1] + " bit length", "param", param); + logger.throwArgumentError("invalid " + match[1] + " bit length", "param", param); } return new number.NumberCoder(size / 8, (match[1] === "int"), param.name); } @@ -7741,11 +7747,11 @@ if (match) { var size = parseInt(match[1]); if (size === 0 || size > 32) { - logger$1.throwArgumentError("invalid bytes length", "param", param); + logger.throwArgumentError("invalid bytes length", "param", param); } return new fixedBytes.FixedBytesCoder(size, param.name); } - return logger$1.throwError("invalid type", "type", param.type); + return logger.throwError("invalid type", "type", param.type); }; AbiCoder.prototype._getWordSize = function () { return 32; }; AbiCoder.prototype._getReader = function (data) { @@ -7757,7 +7763,7 @@ AbiCoder.prototype.encode = function (types, values) { var _this = this; if (types.length !== values.length) { - logger$1.throwError("types/values length mismatch", logger.Logger.errors.INVALID_ARGUMENT, { + logger.throwError("types/values length mismatch", lib.Logger.errors.INVALID_ARGUMENT, { count: { types: types.length, values: values.length }, value: { types: types, values: values } }); @@ -7772,7 +7778,7 @@ var _this = this; var coders = types.map(function (type) { return _this._getCoder(fragments.ParamType.from(type)); }); var coder = new tuple.TupleCoder(coders, "_"); - return coder.decode(this._getReader(bytes.arrayify(data))); + return coder.decode(this._getReader(lib$1.arrayify(data))); }; return AbiCoder; }()); @@ -7787,13 +7793,13 @@ var _version$e = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "hash/5.0.0-beta.128"; + exports.version = "hash/5.0.0-beta.127"; }); var _version$f = unwrapExports(_version$e); var _version_1$7 = _version$e.version; - var hash = createCommonjsModule(function (module, exports) { + var lib$9 = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -7801,7 +7807,7 @@ - var logger$1 = new logger.Logger(_version$e.version); + var logger = new lib.Logger(_version$e.version); /////////////////////////////// var Zeros = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); var Partition = new RegExp("^((.*)\\.)?([^.]+)$"); @@ -7809,7 +7815,7 @@ try { var comps = name.split("."); for (var i = 0; i < comps.length; i++) { - if (strings.nameprep(comps[i]).length === 0) { + if (lib$8.nameprep(comps[i]).length === 0) { throw new Error("empty"); } } @@ -7821,42 +7827,42 @@ exports.isValidName = isValidName; function namehash(name) { if (typeof (name) !== "string") { - logger$1.throwArgumentError("invalid address - " + String(name), "name", name); + logger.throwArgumentError("invalid address - " + String(name), "name", name); } var result = Zeros; while (name.length) { var partition = name.match(Partition); - var label = strings.toUtf8Bytes(strings.nameprep(partition[3])); - result = keccak256_1.keccak256(bytes.concat([result, keccak256_1.keccak256(label)])); + var label = lib$8.toUtf8Bytes(lib$8.nameprep(partition[3])); + result = lib$4.keccak256(lib$1.concat([result, lib$4.keccak256(label)])); name = partition[2] || ""; } - return bytes.hexlify(result); + return lib$1.hexlify(result); } exports.namehash = namehash; function id(text) { - return keccak256_1.keccak256(strings.toUtf8Bytes(text)); + return lib$4.keccak256(lib$8.toUtf8Bytes(text)); } exports.id = id; exports.messagePrefix = "\x19Ethereum Signed Message:\n"; function hashMessage(message) { if (typeof (message) === "string") { - message = strings.toUtf8Bytes(message); + message = lib$8.toUtf8Bytes(message); } - return keccak256_1.keccak256(bytes.concat([ - strings.toUtf8Bytes(exports.messagePrefix), - strings.toUtf8Bytes(String(message.length)), + return lib$4.keccak256(lib$1.concat([ + lib$8.toUtf8Bytes(exports.messagePrefix), + lib$8.toUtf8Bytes(String(message.length)), message ])); } exports.hashMessage = hashMessage; }); - var index$9 = unwrapExports(hash); - var hash_1 = hash.isValidName; - var hash_2 = hash.namehash; - var hash_3 = hash.id; - var hash_4 = hash.messagePrefix; - var hash_5 = hash.hashMessage; + var index$9 = unwrapExports(lib$9); + var lib_1$9 = lib$9.isValidName; + var lib_2$7 = lib$9.namehash; + var lib_3$6 = lib$9.id; + var lib_4$6 = lib$9.messagePrefix; + var lib_5$5 = lib$9.hashMessage; var _interface = createCommonjsModule(function (module, exports) { "use strict"; @@ -7884,14 +7890,14 @@ - var logger$1 = new logger.Logger(_version$8.version); + var logger = new lib.Logger(_version$8.version); var LogDescription = /** @class */ (function (_super) { __extends(LogDescription, _super); function LogDescription() { return _super !== null && _super.apply(this, arguments) || this; } return LogDescription; - }(properties.Description)); + }(lib$3.Description)); exports.LogDescription = LogDescription; var TransactionDescription = /** @class */ (function (_super) { __extends(TransactionDescription, _super); @@ -7899,7 +7905,7 @@ return _super !== null && _super.apply(this, arguments) || this; } return TransactionDescription; - }(properties.Description)); + }(lib$3.Description)); exports.TransactionDescription = TransactionDescription; var Indexed = /** @class */ (function (_super) { __extends(Indexed, _super); @@ -7910,7 +7916,7 @@ return !!(value && value._isIndexed); }; return Indexed; - }(properties.Description)); + }(lib$3.Description)); exports.Indexed = Indexed; var Result = /** @class */ (function () { function Result() { @@ -7922,7 +7928,7 @@ function Interface(fragments$1) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, Interface); + logger.checkNew(_newTarget, Interface); var abi = []; if (typeof (fragments$1) === "string") { abi = JSON.parse(fragments$1); @@ -7930,24 +7936,24 @@ else { abi = fragments$1; } - properties.defineReadOnly(this, "fragments", abi.map(function (fragment) { + lib$3.defineReadOnly(this, "fragments", abi.map(function (fragment) { return fragments.Fragment.from(fragment); }).filter(function (fragment) { return (fragment != null); })); - properties.defineReadOnly(this, "_abiCoder", properties.getStatic((_newTarget), "getAbiCoder")()); - properties.defineReadOnly(this, "functions", {}); - properties.defineReadOnly(this, "errors", {}); - properties.defineReadOnly(this, "events", {}); - properties.defineReadOnly(this, "structs", {}); + lib$3.defineReadOnly(this, "_abiCoder", lib$3.getStatic((_newTarget), "getAbiCoder")()); + lib$3.defineReadOnly(this, "functions", {}); + lib$3.defineReadOnly(this, "errors", {}); + lib$3.defineReadOnly(this, "events", {}); + lib$3.defineReadOnly(this, "structs", {}); // Add all fragments by their signature this.fragments.forEach(function (fragment) { var bucket = null; switch (fragment.type) { case "constructor": if (_this.deploy) { - logger$1.warn("duplicate definition - constructor"); + logger.warn("duplicate definition - constructor"); return; } - properties.defineReadOnly(_this, "deploy", fragment); + lib$3.defineReadOnly(_this, "deploy", fragment); return; case "function": bucket = _this.functions; @@ -7960,7 +7966,7 @@ } var signature = fragment.format(); if (bucket[signature]) { - logger$1.warn("duplicate definition - " + signature); + logger.warn("duplicate definition - " + signature); return; } bucket[signature] = fragment; @@ -7971,7 +7977,7 @@ Object.keys(bucket).forEach(function (signature) { var fragment = bucket[signature]; if (count[fragment.name] !== 1) { - logger$1.warn("duplicate definition - " + fragment.name); + logger.warn("duplicate definition - " + fragment.name); return; } bucket[fragment.name] = fragment; @@ -7979,24 +7985,24 @@ }); // If we do not have a constructor use the default "constructor() payable" if (!this.deploy) { - properties.defineReadOnly(this, "deploy", fragments.ConstructorFragment.from({ type: "constructor" })); + lib$3.defineReadOnly(this, "deploy", fragments.ConstructorFragment.from({ type: "constructor" })); } - properties.defineReadOnly(this, "_isInterface", true); + lib$3.defineReadOnly(this, "_isInterface", true); } Interface.getAbiCoder = function () { return abiCoder.defaultAbiCoder; }; - Interface.getAddress = function (address$1) { - return address.getAddress(address$1); + Interface.getAddress = function (address) { + return lib$6.getAddress(address); }; Interface.prototype._sighashify = function (functionFragment) { - return bytes.hexDataSlice(hash.id(functionFragment.format()), 0, 4); + return lib$1.hexDataSlice(lib$9.id(functionFragment.format()), 0, 4); }; Interface.prototype._topicify = function (eventFragment) { - return hash.id(eventFragment.format()); + return lib$9.id(eventFragment.format()); }; Interface.prototype.getFunction = function (nameOrSignatureOrSighash) { - if (bytes.isHexString(nameOrSignatureOrSighash)) { + if (lib$1.isHexString(nameOrSignatureOrSighash)) { return getFragment(nameOrSignatureOrSighash, this.getSighash.bind(this), this.functions); } // It is a bare name, look up the function (will return null if ambiguous) @@ -8007,7 +8013,7 @@ return this.functions[fragments.FunctionFragment.fromString(nameOrSignatureOrSighash).format()]; }; Interface.prototype.getEvent = function (nameOrSignatureOrTopic) { - if (bytes.isHexString(nameOrSignatureOrTopic)) { + if (lib$1.isHexString(nameOrSignatureOrTopic)) { return getFragment(nameOrSignatureOrTopic, this.getEventTopic.bind(this), this.events); } // It is a bare name, look up the function (will return null if ambiguous) @@ -8038,7 +8044,7 @@ if (typeof (functionFragment) === "string") { functionFragment = this.getFunction(functionFragment); } - return bytes.hexlify(bytes.concat([ + return lib$1.hexlify(lib$1.concat([ this.getSighash(functionFragment), this._encodeParams(functionFragment.inputs, values || []) ])); @@ -8047,24 +8053,24 @@ if (typeof (functionFragment) === "string") { functionFragment = this.getFunction(functionFragment); } - var bytes$1 = bytes.arrayify(data); + var bytes = lib$1.arrayify(data); var reason = null; var errorSignature = null; - switch (bytes$1.length % this._abiCoder._getWordSize()) { + switch (bytes.length % this._abiCoder._getWordSize()) { case 0: try { - return this._abiCoder.decode(functionFragment.outputs, bytes$1); + return this._abiCoder.decode(functionFragment.outputs, bytes); } catch (error) { } break; case 4: - if (bytes.hexlify(bytes$1.slice(0, 4)) === "0x08c379a0") { + if (lib$1.hexlify(bytes.slice(0, 4)) === "0x08c379a0") { errorSignature = "Error(string)"; - reason = this._abiCoder.decode(["string"], bytes$1.slice(4)); + reason = this._abiCoder.decode(["string"], bytes.slice(4)); } break; } - return logger$1.throwError("call revert exception", logger.Logger.errors.CALL_EXCEPTION, { + return logger.throwError("call revert exception", lib.Logger.errors.CALL_EXCEPTION, { method: functionFragment.format(), errorSignature: errorSignature, errorArgs: [reason], @@ -8077,7 +8083,7 @@ eventFragment = this.getEvent(eventFragment); } if (values.length > eventFragment.inputs.length) { - logger$1.throwError("too many arguments for " + eventFragment.format(), logger.Logger.errors.UNEXPECTED_ARGUMENT, { + logger.throwError("too many arguments for " + eventFragment.format(), lib.Logger.errors.UNEXPECTED_ARGUMENT, { argument: "values", value: values }); @@ -8090,7 +8096,7 @@ var param = eventFragment.inputs[index]; if (!param.indexed) { if (value != null) { - logger$1.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); + logger.throwArgumentError("cannot filter non-indexed parameters; must be null", ("contract." + param.name), value); } return; } @@ -8098,20 +8104,20 @@ topics.push(null); } else if (param.type === "string") { - topics.push(hash.id(value)); + topics.push(lib$9.id(value)); } else if (param.type === "bytes") { - topics.push(keccak256_1.keccak256(bytes.hexlify(value))); + topics.push(lib$4.keccak256(lib$1.hexlify(value))); } else if (param.type.indexOf("[") !== -1 || param.type.substring(0, 5) === "tuple") { - logger$1.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); + logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value); } else { // Check addresses are valid if (param.type === "address") { _this._abiCoder.encode(["address"], [value]); } - topics.push(bytes.hexZeroPad(bytes.hexlify(value), 32)); + topics.push(lib$1.hexZeroPad(lib$1.hexlify(value), 32)); } }); // Trim off trailing nulls @@ -8126,8 +8132,8 @@ } if (topics != null && !eventFragment.anonymous) { var topicHash = this.getEventTopic(eventFragment); - if (!bytes.isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { - logger$1.throwError("fragment/topic mismatch", logger.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); + if (!lib$1.isHexString(topics[0], 32) || topics[0].toLowerCase() !== topicHash) { + logger.throwError("fragment/topic mismatch", lib.Logger.errors.INVALID_ARGUMENT, { argument: "topics[0]", expected: topicHash, value: topics[0] }); } topics = topics.slice(1); } @@ -8150,7 +8156,7 @@ dynamic.push(false); } }); - var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, bytes.concat(topics)) : null; + var resultIndexed = (topics != null) ? this._abiCoder.decode(indexed, lib$1.concat(topics)) : null; var resultNonIndexed = this._abiCoder.decode(nonIndexed, data); var result = []; var nonIndexedIndex = 0, indexedIndex = 0; @@ -8184,7 +8190,7 @@ name: fragment.name, signature: fragment.format(), sighash: this.getSighash(fragment), - value: bignumber$2.BigNumber.from(tx.value || "0"), + value: lib$2.BigNumber.from(tx.value || "0"), }); }; Interface.prototype.parseLog = function (log) { @@ -8251,7 +8257,7 @@ var _interface_4 = _interface.Result; var _interface_5 = _interface.Interface; - var abi = createCommonjsModule(function (module, exports) { + var lib$a = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -8269,28 +8275,28 @@ exports.Interface = _interface.Interface; }); - var index$a = unwrapExports(abi); - var abi_1 = abi.ConstructorFragment; - var abi_2 = abi.EventFragment; - var abi_3 = abi.FormatTypes; - var abi_4 = abi.Fragment; - var abi_5 = abi.FunctionFragment; - var abi_6 = abi.ParamType; - var abi_7 = abi.AbiCoder; - var abi_8 = abi.defaultAbiCoder; - var abi_9 = abi.Indexed; - var abi_10 = abi.Interface; + var index$a = unwrapExports(lib$a); + var lib_1$a = lib$a.ConstructorFragment; + var lib_2$8 = lib$a.EventFragment; + var lib_3$7 = lib$a.FormatTypes; + var lib_4$7 = lib$a.Fragment; + var lib_5$6 = lib$a.FunctionFragment; + var lib_6$4 = lib$a.ParamType; + var lib_7$4 = lib$a.AbiCoder; + var lib_8$3 = lib$a.defaultAbiCoder; + var lib_9$2 = lib$a.Indexed; + var lib_10$1 = lib$a.Interface; var _version$g = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "abstract-provider/5.0.0-beta.131"; + exports.version = "abstract-provider/5.0.0-beta.130"; }); var _version$h = unwrapExports(_version$g); var _version_1$8 = _version$g.version; - var abstractProvider = createCommonjsModule(function (module, exports) { + var lib$b = createCommonjsModule(function (module, exports) { "use strict"; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { var extendStatics = function (d, b) { @@ -8310,7 +8316,7 @@ - var logger$1 = new logger.Logger(_version$g.version); + var logger = new lib.Logger(_version$g.version); ; ; //export type CallTransactionable = { @@ -8325,14 +8331,14 @@ return !!(value && value._isForkEvent); }; return ForkEvent; - }(properties.Description)); + }(lib$3.Description)); exports.ForkEvent = ForkEvent; var BlockForkEvent = /** @class */ (function (_super) { __extends(BlockForkEvent, _super); function BlockForkEvent(blockhash, expiry) { var _this = this; - if (!bytes.isHexString(blockhash, 32)) { - logger$1.throwArgumentError("invalid blockhash", "blockhash", blockhash); + if (!lib$1.isHexString(blockhash, 32)) { + logger.throwArgumentError("invalid blockhash", "blockhash", blockhash); } _this = _super.call(this, { _isForkEvent: true, @@ -8349,8 +8355,8 @@ __extends(TransactionForkEvent, _super); function TransactionForkEvent(hash, expiry) { var _this = this; - if (!bytes.isHexString(hash, 32)) { - logger$1.throwArgumentError("invalid transaction hash", "hash", hash); + if (!lib$1.isHexString(hash, 32)) { + logger.throwArgumentError("invalid transaction hash", "hash", hash); } _this = _super.call(this, { _isForkEvent: true, @@ -8367,11 +8373,11 @@ __extends(TransactionOrderForkEvent, _super); function TransactionOrderForkEvent(beforeHash, afterHash, expiry) { var _this = this; - if (!bytes.isHexString(beforeHash, 32)) { - logger$1.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); + if (!lib$1.isHexString(beforeHash, 32)) { + logger.throwArgumentError("invalid transaction hash", "beforeHash", beforeHash); } - if (!bytes.isHexString(afterHash, 32)) { - logger$1.throwArgumentError("invalid transaction hash", "afterHash", afterHash); + if (!lib$1.isHexString(afterHash, 32)) { + logger.throwArgumentError("invalid transaction hash", "afterHash", afterHash); } _this = _super.call(this, { _isForkEvent: true, @@ -8390,8 +8396,8 @@ var Provider = /** @class */ (function () { function Provider() { var _newTarget = this.constructor; - logger$1.checkAbstract(_newTarget, Provider); - properties.defineReadOnly(this, "_isProvider", true); + logger.checkAbstract(_newTarget, Provider); + lib$3.defineReadOnly(this, "_isProvider", true); } // Alias for "on" Provider.prototype.addListener = function (eventName, listener) { @@ -8409,23 +8415,23 @@ exports.Provider = Provider; }); - var index$b = unwrapExports(abstractProvider); - var abstractProvider_1 = abstractProvider.ForkEvent; - var abstractProvider_2 = abstractProvider.BlockForkEvent; - var abstractProvider_3 = abstractProvider.TransactionForkEvent; - var abstractProvider_4 = abstractProvider.TransactionOrderForkEvent; - var abstractProvider_5 = abstractProvider.Provider; + var index$b = unwrapExports(lib$b); + var lib_1$b = lib$b.ForkEvent; + var lib_2$9 = lib$b.BlockForkEvent; + var lib_3$8 = lib$b.TransactionForkEvent; + var lib_4$8 = lib$b.TransactionOrderForkEvent; + var lib_5$7 = lib$b.Provider; var _version$i = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "abstract-signer/5.0.0-beta.132"; + exports.version = "abstract-signer/5.0.0-beta.131"; }); var _version$j = unwrapExports(_version$i); var _version_1$9 = _version$i.version; - var abstractSigner = createCommonjsModule(function (module, exports) { + var lib$c = createCommonjsModule(function (module, exports) { "use strict"; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { var extendStatics = function (d, b) { @@ -8444,7 +8450,7 @@ - var logger$1 = new logger.Logger(_version$i.version); + var logger = new lib.Logger(_version$i.version); var allowedTransactionKeys = [ "chainId", "data", "from", "gasLimit", "gasPrice", "nonce", "to", "value" ]; @@ -8459,8 +8465,8 @@ // Sub-classes MUST call super function Signer() { var _newTarget = this.constructor; - logger$1.checkAbstract(_newTarget, Signer); - properties.defineReadOnly(this, "_isSigner", true); + logger.checkAbstract(_newTarget, Signer); + lib$3.defineReadOnly(this, "_isSigner", true); } /////////////////// // Sub-classes MAY override these @@ -8476,7 +8482,7 @@ Signer.prototype.estimateGas = function (transaction) { var _this = this; this._checkProvider("estimateGas"); - return properties.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return lib$3.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { return _this.provider.estimateGas(tx); }); }; @@ -8484,7 +8490,7 @@ Signer.prototype.call = function (transaction, blockTag) { var _this = this; this._checkProvider("call"); - return properties.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return lib$3.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { return _this.provider.call(tx); }); }; @@ -8522,10 +8528,10 @@ Signer.prototype.checkTransaction = function (transaction) { for (var key in transaction) { if (allowedTransactionKeys.indexOf(key) === -1) { - logger$1.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); + logger.throwArgumentError("invalid transaction key: " + key, "transaction", transaction); } } - var tx = properties.shallowCopy(transaction); + var tx = lib$3.shallowCopy(transaction); if (tx.from == null) { tx.from = this.getAddress(); } @@ -8537,7 +8543,7 @@ // - sendTransaction Signer.prototype.populateTransaction = function (transaction) { var _this = this; - return properties.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { + return lib$3.resolveProperties(this.checkTransaction(transaction)).then(function (tx) { if (tx.to != null) { tx.to = Promise.resolve(tx.to).then(function (to) { return _this.resolveName(to); }); } @@ -8557,14 +8563,14 @@ _this.provider.resolveName(tx.from) ]).then(function (results) { if (results[0] !== results[1]) { - logger$1.throwArgumentError("from address mismatch", "transaction", transaction); + logger.throwArgumentError("from address mismatch", "transaction", transaction); } return results[0]; }); } if (tx.gasLimit == null) { tx.gasLimit = _this.estimateGas(tx).catch(function (error) { - logger$1.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", logger.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { + logger.throwError("cannot estimate gas; transaction may fail or may require manual gas limit", lib.Logger.errors.UNPREDICTABLE_GAS_LIMIT, { tx: tx }); }); @@ -8572,14 +8578,14 @@ if (tx.chainId == null) { tx.chainId = _this.getChainId(); } - return properties.resolveProperties(tx); + return lib$3.resolveProperties(tx); }); }; /////////////////// // Sub-classes SHOULD leave these alone Signer.prototype._checkProvider = function (operation) { if (!this.provider) { - logger$1.throwError("missing provider", logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("missing provider", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: (operation || "_checkProvider") }); } @@ -8595,10 +8601,10 @@ function VoidSigner(address, provider) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, VoidSigner); + logger.checkNew(_newTarget, VoidSigner); _this = _super.call(this) || this; - properties.defineReadOnly(_this, "address", address); - properties.defineReadOnly(_this, "provider", provider || null); + lib$3.defineReadOnly(_this, "address", address); + lib$3.defineReadOnly(_this, "provider", provider || null); return _this; } VoidSigner.prototype.getAddress = function () { @@ -8606,7 +8612,7 @@ }; VoidSigner.prototype._fail = function (message, operation) { return Promise.resolve().then(function () { - logger$1.throwError(message, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); + logger.throwError(message, lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: operation }); }); }; VoidSigner.prototype.signMessage = function (message) { @@ -8623,20 +8629,20 @@ exports.VoidSigner = VoidSigner; }); - var index$c = unwrapExports(abstractSigner); - var abstractSigner_1 = abstractSigner.Signer; - var abstractSigner_2 = abstractSigner.VoidSigner; + var index$c = unwrapExports(lib$c); + var lib_1$c = lib$c.Signer; + var lib_2$a = lib$c.VoidSigner; var _version$k = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "contracts/5.0.0-beta.137"; + exports.version = "contracts/5.0.0-beta.136"; }); var _version$l = unwrapExports(_version$k); var _version_1$a = _version$k.version; - var contracts = createCommonjsModule(function (module, exports) { + var lib$d = createCommonjsModule(function (module, exports) { "use strict"; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { var extendStatics = function (d, b) { @@ -8662,7 +8668,7 @@ - var logger$1 = new logger.Logger(_version$k.version); + var logger = new lib.Logger(_version$k.version); /////////////////////////////// var allowedTransactionKeys = { chainId: true, data: true, from: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true @@ -8700,7 +8706,7 @@ var blockTag = null; // If 1 extra parameter was passed in, it contains overrides if (params.length === method.inputs.length + 1 && typeof (params[params.length - 1]) === "object") { - tx = properties.shallowCopy(params.pop()); + tx = lib$3.shallowCopy(params.pop()); if (tx.blockTag != null) { blockTag = tx.blockTag; } @@ -8708,15 +8714,15 @@ // Check for unexpected keys (e.g. using "gas" instead of "gasLimit") for (var key in tx) { if (!allowedTransactionKeys[key]) { - logger$1.throwError(("unknown transaxction override - " + key), "overrides", tx); + logger.throwError(("unknown transaxction override - " + key), "overrides", tx); } } } - logger$1.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); + logger.checkArgumentCount(params.length, method.inputs.length, "passed to contract"); // Check overrides make sense ["data", "to"].forEach(function (key) { if (tx[key] != null) { - logger$1.throwError("cannot override " + key, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + logger.throwError("cannot override " + key, lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); } }); // If the contract was just deployed, wait until it is minded @@ -8733,10 +8739,10 @@ if (method.constant || options.callStatic) { // Call (constant functions) always cost 0 ether if (options.estimate) { - return Promise.resolve(constants.Zero); + return Promise.resolve(lib$7.Zero); } if (!contract.provider && !contract.signer) { - logger$1.throwError("call (constant functions) require a provider or signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" }); + logger.throwError("call (constant functions) require a provider or signer", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "call" }); } // Check overrides make sense ["gasLimit", "gasPrice", "value"].forEach(function (key) { @@ -8745,7 +8751,7 @@ } }); if (options.transaction) { - return properties.resolveProperties(tx); + return lib$3.resolveProperties(tx); } return (contract.signer || contract.provider).call(tx, blockTag).then(function (value) { try { @@ -8756,7 +8762,7 @@ return result; } catch (error) { - if (error.code === logger.Logger.errors.CALL_EXCEPTION) { + if (error.code === lib.Logger.errors.CALL_EXCEPTION) { error.address = contract.address; error.args = params; error.transaction = tx; @@ -8768,28 +8774,28 @@ // Only computing the transaction estimate if (options.estimate) { if (!contract.provider && !contract.signer) { - logger$1.throwError("estimate require a provider or signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); + logger.throwError("estimate require a provider or signer", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "estimateGas" }); } return (contract.signer || contract.provider).estimateGas(tx); } if (tx.gasLimit == null && method.gas != null) { - tx.gasLimit = bignumber$2.BigNumber.from(method.gas).add(21000); + tx.gasLimit = lib$2.BigNumber.from(method.gas).add(21000); } if (tx.value != null && !method.payable) { - logger$1.throwArgumentError("contract method is not payable", "sendTransaction:" + method.format(), tx); + logger.throwArgumentError("contract method is not payable", "sendTransaction:" + method.format(), tx); } if (options.transaction) { - return properties.resolveProperties(tx); + return lib$3.resolveProperties(tx); } if (!contract.signer) { - logger$1.throwError("sending a transaction require a signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); + logger.throwError("sending a transaction require a signer", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }); } return contract.signer.sendTransaction(tx).then(function (tx) { var wait = tx.wait.bind(tx); tx.wait = function (confirmations) { return wait(confirmations).then(function (receipt) { receipt.events = receipt.logs.map(function (log) { - var event = properties.deepCopy(log); + var event = lib$3.deepCopy(log); var parsed = contract.interface.parseLog(log); if (parsed) { event.values = parsed.values; @@ -8827,8 +8833,8 @@ } var RunningEvent = /** @class */ (function () { function RunningEvent(tag, filter) { - properties.defineReadOnly(this, "tag", tag); - properties.defineReadOnly(this, "filter", filter); + lib$3.defineReadOnly(this, "tag", tag); + lib$3.defineReadOnly(this, "filter", filter); this._listeners = []; } RunningEvent.prototype.addListener = function (listener, once) { @@ -8888,7 +8894,7 @@ var topic = contractInterface.getEventTopic(fragment); if (topics) { if (topic !== topics[0]) { - logger$1.throwArgumentError("topic mismatch", "topics", topics); + logger.throwArgumentError("topic mismatch", "topics", topics); } filter.topics = topics.slice(); } @@ -8896,9 +8902,9 @@ filter.topics = [topic]; } _this = _super.call(this, getEventTag(filter), filter) || this; - properties.defineReadOnly(_this, "address", address); - properties.defineReadOnly(_this, "interface", contractInterface); - properties.defineReadOnly(_this, "fragment", fragment); + lib$3.defineReadOnly(_this, "address", address); + lib$3.defineReadOnly(_this, "interface", contractInterface); + lib$3.defineReadOnly(_this, "fragment", fragment); return _this; } FragmentRunningEvent.prototype.prepareEvent = function (event) { @@ -8917,8 +8923,8 @@ __extends(WildcardRunningEvent, _super); function WildcardRunningEvent(address, contractInterface) { var _this = _super.call(this, "*", { address: address }) || this; - properties.defineReadOnly(_this, "address", address); - properties.defineReadOnly(_this, "interface", contractInterface); + lib$3.defineReadOnly(_this, "address", address); + lib$3.defineReadOnly(_this, "interface", contractInterface); return _this; } WildcardRunningEvent.prototype.prepareEvent = function (event) { @@ -8940,29 +8946,29 @@ function Contract(addressOrName, contractInterface, signerOrProvider) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, Contract); + logger.checkNew(_newTarget, Contract); // @TODO: Maybe still check the addressOrName looks like a valid address or name? //address = getAddress(address); - properties.defineReadOnly(this, "interface", properties.getStatic((_newTarget), "getInterface")(contractInterface)); - if (abstractSigner.Signer.isSigner(signerOrProvider)) { - properties.defineReadOnly(this, "provider", signerOrProvider.provider || null); - properties.defineReadOnly(this, "signer", signerOrProvider); + lib$3.defineReadOnly(this, "interface", lib$3.getStatic((_newTarget), "getInterface")(contractInterface)); + if (lib$c.Signer.isSigner(signerOrProvider)) { + lib$3.defineReadOnly(this, "provider", signerOrProvider.provider || null); + lib$3.defineReadOnly(this, "signer", signerOrProvider); } - else if (abstractProvider.Provider.isProvider(signerOrProvider)) { - properties.defineReadOnly(this, "provider", signerOrProvider); - properties.defineReadOnly(this, "signer", null); + else if (lib$b.Provider.isProvider(signerOrProvider)) { + lib$3.defineReadOnly(this, "provider", signerOrProvider); + lib$3.defineReadOnly(this, "signer", null); } else { - logger$1.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); + logger.throwArgumentError("invalid signer or provider", "signerOrProvider", signerOrProvider); } - properties.defineReadOnly(this, "callStatic", {}); - properties.defineReadOnly(this, "estimate", {}); - properties.defineReadOnly(this, "functions", {}); - properties.defineReadOnly(this, "populateTransaction", {}); - properties.defineReadOnly(this, "filters", {}); + lib$3.defineReadOnly(this, "callStatic", {}); + lib$3.defineReadOnly(this, "estimate", {}); + lib$3.defineReadOnly(this, "functions", {}); + lib$3.defineReadOnly(this, "populateTransaction", {}); + lib$3.defineReadOnly(this, "filters", {}); Object.keys(this.interface.events).forEach(function (eventName) { var event = _this.interface.events[eventName]; - properties.defineReadOnly(_this.filters, eventName, function () { + lib$3.defineReadOnly(_this.filters, eventName, function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; @@ -8973,11 +8979,11 @@ }; }); }); - properties.defineReadOnly(this, "_runningEvents", {}); - properties.defineReadOnly(this, "_wrappedEmits", {}); - properties.defineReadOnly(this, "address", addressOrName); + lib$3.defineReadOnly(this, "_runningEvents", {}); + lib$3.defineReadOnly(this, "_wrappedEmits", {}); + lib$3.defineReadOnly(this, "address", addressOrName); if (this.provider) { - properties.defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then(function (address) { + lib$3.defineReadOnly(this, "addressPromise", this.provider.resolveName(addressOrName).then(function (address) { if (address == null) { throw new Error("name not found"); } @@ -8989,40 +8995,40 @@ } else { try { - properties.defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); + lib$3.defineReadOnly(this, "addressPromise", Promise.resolve((this.interface.constructor).getAddress(addressOrName))); } catch (error) { // Without a provider, we cannot use ENS names - logger$1.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); + logger.throwArgumentError("provider is required to use non-address contract address", "addressOrName", addressOrName); } } Object.keys(this.interface.functions).forEach(function (name) { var run = runMethod(_this, name, {}); if (_this[name] == null) { - properties.defineReadOnly(_this, name, run); + lib$3.defineReadOnly(_this, name, run); } if (_this.functions[name] == null) { - properties.defineReadOnly(_this.functions, name, run); + lib$3.defineReadOnly(_this.functions, name, run); } if (_this.callStatic[name] == null) { - properties.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true })); + lib$3.defineReadOnly(_this.callStatic, name, runMethod(_this, name, { callStatic: true })); } if (_this.populateTransaction[name] == null) { - properties.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true })); + lib$3.defineReadOnly(_this.populateTransaction, name, runMethod(_this, name, { transaction: true })); } if (_this.estimate[name] == null) { - properties.defineReadOnly(_this.estimate, name, runMethod(_this, name, { estimate: true })); + lib$3.defineReadOnly(_this.estimate, name, runMethod(_this, name, { estimate: true })); } }); } Contract.getContractAddress = function (transaction) { - return address.getContractAddress(transaction); + return lib$6.getContractAddress(transaction); }; Contract.getInterface = function (contractInterface) { - if (abi.Interface.isInterface(contractInterface)) { + if (lib$a.Interface.isInterface(contractInterface)) { return contractInterface; } - return new abi.Interface(contractInterface); + return new lib$a.Interface(contractInterface); }; // @TODO: Allow timeout? Contract.prototype.deployed = function () { @@ -9043,7 +9049,7 @@ // Otherwise, poll for our code to be deployed this._deployedPromise = this.provider.getCode(this.address, blockTag).then(function (code) { if (code === "0x") { - logger$1.throwError("contract not deployed", logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("contract not deployed", lib.Logger.errors.UNSUPPORTED_OPERATION, { contractAddress: _this.address, operation: "getDeployed" }); @@ -9061,14 +9067,14 @@ Contract.prototype.fallback = function (overrides) { var _this = this; if (!this.signer) { - logger$1.throwError("sending a transaction require a signer", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); + logger.throwError("sending a transaction require a signer", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }); } - var tx = properties.shallowCopy(overrides || {}); + var tx = lib$3.shallowCopy(overrides || {}); ["from", "to"].forEach(function (key) { if (tx[key] == null) { return; } - logger$1.throwError("cannot override " + key, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + logger.throwError("cannot override " + key, lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); }); tx.to = this.addressPromise; return this.deployed().then(function () { @@ -9078,11 +9084,11 @@ // Reconnect to a different signer or provider Contract.prototype.connect = function (signerOrProvider) { if (typeof (signerOrProvider) === "string") { - signerOrProvider = new abstractSigner.VoidSigner(signerOrProvider, this.provider); + signerOrProvider = new lib$c.VoidSigner(signerOrProvider, this.provider); } var contract = new (this.constructor)(this.address, this.interface, signerOrProvider); if (this.deployTransaction) { - properties.defineReadOnly(contract, "deployTransaction", this.deployTransaction); + lib$3.defineReadOnly(contract, "deployTransaction", this.deployTransaction); } return contract; }; @@ -9091,7 +9097,7 @@ return new (this.constructor)(addressOrName, this.interface, this.signer || this.provider); }; Contract.isIndexed = function (value) { - return abi.Indexed.isIndexed(value); + return lib$a.Indexed.isIndexed(value); }; Contract.prototype._normalizeRunningEvent = function (runningEvent) { // Already have an instance of this event running; we can re-use it @@ -9113,7 +9119,7 @@ } var fragment = this.interface.getEvent(eventName); if (!fragment) { - logger$1.throwArgumentError("unknown event - " + eventName, "eventName", eventName); + logger.throwArgumentError("unknown event - " + eventName, "eventName", eventName); } return this._normalizeRunningEvent(new FragmentRunningEvent(this.address, this.interface, fragment)); } @@ -9146,7 +9152,7 @@ }; Contract.prototype._wrapEvent = function (runningEvent, log, listener) { var _this = this; - var event = properties.deepCopy(log); + var event = lib$3.deepCopy(log); try { runningEvent.prepareEvent(event); } @@ -9169,7 +9175,7 @@ Contract.prototype._addEventListener = function (runningEvent, listener, once) { var _this = this; if (!this.provider) { - logger$1.throwError("events require a provider or a signer with a provider", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); + logger.throwError("events require a provider or a signer with a provider", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "once" }); } runningEvent.addListener(listener, once); // Track this running event and its listeners (may already be there; but no hard in updating) @@ -9192,10 +9198,10 @@ Contract.prototype.queryFilter = function (event, fromBlockOrBlockhash, toBlock) { var _this = this; var runningEvent = this._getRunningEvent(event); - var filter = properties.shallowCopy(runningEvent.filter); - if (typeof (fromBlockOrBlockhash) === "string" && bytes.isHexString(fromBlockOrBlockhash, 32)) { + var filter = lib$3.shallowCopy(runningEvent.filter); + if (typeof (fromBlockOrBlockhash) === "string" && lib$1.isHexString(fromBlockOrBlockhash, 32)) { if (toBlock != null) { - logger$1.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); + logger.throwArgumentError("cannot specify toBlock with blockhash", "toBlock", toBlock); } filter.blockhash = fromBlockOrBlockhash; } @@ -9290,8 +9296,8 @@ if (typeof (bytecode) === "string") { bytecodeHex = bytecode; } - else if (bytes.isBytes(bytecode)) { - bytecodeHex = bytes.hexlify(bytecode); + else if (lib$1.isBytes(bytecode)) { + bytecodeHex = lib$1.hexlify(bytecode); } else if (bytecode && typeof (bytecode.object) === "string") { // Allow the bytecode object from the Solidity compiler @@ -9306,16 +9312,16 @@ bytecodeHex = "0x" + bytecodeHex; } // Make sure the final result is valid bytecode - if (!bytes.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { - logger$1.throwArgumentError("invalid bytecode", "bytecode", bytecode); + if (!lib$1.isHexString(bytecodeHex) || (bytecodeHex.length % 2)) { + logger.throwArgumentError("invalid bytecode", "bytecode", bytecode); } // If we have a signer, make sure it is valid - if (signer && !abstractSigner.Signer.isSigner(signer)) { - logger$1.throwArgumentError("invalid signer", "signer", signer); + if (signer && !lib$c.Signer.isSigner(signer)) { + logger.throwArgumentError("invalid signer", "signer", signer); } - properties.defineReadOnly(this, "bytecode", bytecodeHex); - properties.defineReadOnly(this, "interface", properties.getStatic((_newTarget), "getInterface")(contractInterface)); - properties.defineReadOnly(this, "signer", signer || null); + lib$3.defineReadOnly(this, "bytecode", bytecodeHex); + lib$3.defineReadOnly(this, "interface", lib$3.getStatic((_newTarget), "getInterface")(contractInterface)); + lib$3.defineReadOnly(this, "signer", signer || null); } ContractFactory.prototype.getDeployTransaction = function () { var args = []; @@ -9325,7 +9331,7 @@ var tx = {}; // If we have 1 additional argument, we allow transaction overrides if (args.length === this.interface.deploy.inputs.length + 1) { - tx = properties.shallowCopy(args.pop()); + tx = lib$3.shallowCopy(args.pop()); for (var key in tx) { if (!allowedTransactionKeys[key]) { throw new Error("unknown transaction override " + key); @@ -9337,12 +9343,12 @@ if (tx[key] == null) { return; } - logger$1.throwError("cannot override " + key, logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); + logger.throwError("cannot override " + key, lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: key }); }); // Make sure the call matches the constructor signature - logger$1.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); + logger.checkArgumentCount(args.length, this.interface.deploy.inputs.length, " in Contract constructor"); // Set the data to the bytecode + the encoded constructor arguments - tx.data = bytes.hexlify(bytes.concat([ + tx.data = lib$1.hexlify(lib$1.concat([ this.bytecode, this.interface.encodeDeploy(args) ])); @@ -9361,7 +9367,7 @@ return _this.signer.sendTransaction(tx).then(function (tx) { var address = (_this.constructor).getContractAddress(tx); var contract = (_this.constructor).getContract(address, _this.interface, _this.signer); - properties.defineReadOnly(contract, "deployTransaction", tx); + lib$3.defineReadOnly(contract, "deployTransaction", tx); return contract; }); }); @@ -9374,7 +9380,7 @@ }; ContractFactory.fromSolidity = function (compilerOutput, signer) { if (compilerOutput == null) { - logger$1.throwError("missing compiler output", logger.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); + logger.throwError("missing compiler output", lib.Logger.errors.MISSING_ARGUMENT, { argument: "compilerOutput" }); } if (typeof (compilerOutput) === "string") { compilerOutput = JSON.parse(compilerOutput); @@ -9393,7 +9399,7 @@ return Contract.getInterface(contractInterface); }; ContractFactory.getContractAddress = function (tx) { - return address.getContractAddress(tx); + return lib$6.getContractAddress(tx); }; ContractFactory.getContract = function (address, contractInterface, signer) { return new Contract(address, contractInterface, signer); @@ -9403,11 +9409,11 @@ exports.ContractFactory = ContractFactory; }); - var index$d = unwrapExports(contracts); - var contracts_1 = contracts.Contract; - var contracts_2 = contracts.ContractFactory; + var index$d = unwrapExports(lib$d); + var lib_1$d = lib$d.Contract; + var lib_2$b = lib$d.ContractFactory; - var basex = createCommonjsModule(function (module, exports) { + var lib$e = createCommonjsModule(function (module, exports) { "use strict"; /** * var basex = require("base-x"); @@ -9453,17 +9459,17 @@ var BaseX = /** @class */ (function () { function BaseX(alphabet) { - properties.defineReadOnly(this, "alphabet", alphabet); - properties.defineReadOnly(this, "base", alphabet.length); - properties.defineReadOnly(this, "_alphabetMap", {}); - properties.defineReadOnly(this, "_leader", alphabet.charAt(0)); + lib$3.defineReadOnly(this, "alphabet", alphabet); + lib$3.defineReadOnly(this, "base", alphabet.length); + lib$3.defineReadOnly(this, "_alphabetMap", {}); + lib$3.defineReadOnly(this, "_leader", alphabet.charAt(0)); // pre-compute lookup table for (var i = 0; i < alphabet.length; i++) { this._alphabetMap[alphabet.charAt(i)] = i; } } BaseX.prototype.encode = function (value) { - var source = bytes.arrayify(value); + var source = lib$1.arrayify(value); if (source.length === 0) { return ""; } @@ -9495,32 +9501,32 @@ if (typeof (value) !== "string") { throw new TypeError("Expected String"); } - var bytes$1 = []; + var bytes = []; if (value.length === 0) { - return new Uint8Array(bytes$1); + return new Uint8Array(bytes); } - bytes$1.push(0); + bytes.push(0); for (var i = 0; i < value.length; i++) { var byte = this._alphabetMap[value[i]]; if (byte === undefined) { throw new Error("Non-base" + this.base + " character"); } var carry = byte; - for (var j = 0; j < bytes$1.length; ++j) { - carry += bytes$1[j] * this.base; - bytes$1[j] = carry & 0xff; + for (var j = 0; j < bytes.length; ++j) { + carry += bytes[j] * this.base; + bytes[j] = carry & 0xff; carry >>= 8; } while (carry > 0) { - bytes$1.push(carry & 0xff); + bytes.push(carry & 0xff); carry >>= 8; } } // deal with leading zeros for (var k = 0; value[k] === this._leader && k < value.length - 1; ++k) { - bytes$1.push(0); + bytes.push(0); } - return bytes.arrayify(new Uint8Array(bytes$1.reverse())); + return lib$1.arrayify(new Uint8Array(bytes.reverse())); }; return BaseX; }()); @@ -9533,10 +9539,10 @@ //console.log(Base58.encode(Base58.decode("Qmd2V777o5XvJbYMeMb8k2nU5f8d3ciUQ5YpYuWhzv8iDj"))) }); - var index$e = unwrapExports(basex); - var basex_1 = basex.BaseX; - var basex_2 = basex.Base32; - var basex_3 = basex.Base58; + var index$e = unwrapExports(lib$e); + var lib_1$e = lib$e.BaseX; + var lib_2$c = lib$e.Base32; + var lib_3$9 = lib$e.Base58; var minimalisticAssert = assert; @@ -10679,7 +10685,7 @@ return this.outer.digest(enc); }; - var hash_1$1 = createCommonjsModule(function (module, exports) { + var hash_1 = createCommonjsModule(function (module, exports) { var hash = exports; hash.utils = utils; @@ -10700,7 +10706,7 @@ var _version$m = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "sha2/5.0.0-beta.129"; + exports.version = "sha2/5.0.0-beta.128"; }); var _version$n = unwrapExports(_version$m); @@ -10716,11 +10722,11 @@ return result; }; Object.defineProperty(exports, "__esModule", { value: true }); - var hash = __importStar(hash_1$1); + var hash = __importStar(hash_1); - var logger$1 = new logger.Logger(_version$m.version); + var logger = new lib.Logger(_version$m.version); var SupportedAlgorithms; (function (SupportedAlgorithms) { SupportedAlgorithms["sha256"] = "sha256"; @@ -10728,25 +10734,25 @@ })(SupportedAlgorithms = exports.SupportedAlgorithms || (exports.SupportedAlgorithms = {})); ; function ripemd160(data) { - return "0x" + (hash.ripemd160().update(bytes.arrayify(data)).digest("hex")); + return "0x" + (hash.ripemd160().update(lib$1.arrayify(data)).digest("hex")); } exports.ripemd160 = ripemd160; function sha256(data) { - return "0x" + (hash.sha256().update(bytes.arrayify(data)).digest("hex")); + return "0x" + (hash.sha256().update(lib$1.arrayify(data)).digest("hex")); } exports.sha256 = sha256; function sha512(data) { - return "0x" + (hash.sha512().update(bytes.arrayify(data)).digest("hex")); + return "0x" + (hash.sha512().update(lib$1.arrayify(data)).digest("hex")); } exports.sha512 = sha512; function computeHmac(algorithm, key, data) { if (!SupportedAlgorithms[algorithm]) { - logger$1.throwError("unsupported algorithm " + algorithm, logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("unsupported algorithm " + algorithm, lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "hmac", algorithm: algorithm }); } - return "0x" + hash.hmac(hash[algorithm], bytes.arrayify(key)).update(bytes.arrayify(data)).digest("hex"); + return "0x" + hash.hmac(hash[algorithm], lib$1.arrayify(key)).update(lib$1.arrayify(data)).digest("hex"); } exports.computeHmac = computeHmac; }); @@ -10764,8 +10770,8 @@ function pbkdf2(password, salt, iterations, keylen, hashAlgorithm) { - password = bytes.arrayify(password); - salt = bytes.arrayify(salt); + password = lib$1.arrayify(password); + salt = lib$1.arrayify(salt); var hLen; var l = 1; var DK = new Uint8Array(keylen); @@ -10781,7 +10787,7 @@ block1[salt.length + 2] = (i >> 8) & 0xff; block1[salt.length + 3] = i & 0xff; //let U = createHmac(password).update(block1).digest(); - var U = bytes.arrayify(browser.computeHmac(hashAlgorithm, password, block1)); + var U = lib$1.arrayify(browser.computeHmac(hashAlgorithm, password, block1)); if (!hLen) { hLen = U.length; T = new Uint8Array(hLen); @@ -10792,16 +10798,16 @@ T.set(U); for (var j = 1; j < iterations; j++) { //U = createHmac(password).update(U).digest(); - U = bytes.arrayify(browser.computeHmac(hashAlgorithm, password, U)); + U = lib$1.arrayify(browser.computeHmac(hashAlgorithm, password, U)); for (var k = 0; k < hLen; k++) T[k] ^= U[k]; } var destPos = (i - 1) * hLen; var len = (i === l ? r : hLen); //T.copy(DK, destPos, 0, len) - DK.set(bytes.arrayify(T).slice(0, len), destPos); + DK.set(lib$1.arrayify(T).slice(0, len), destPos); } - return bytes.hexlify(DK); + return lib$1.hexlify(DK); } exports.pbkdf2 = pbkdf2; }); @@ -12383,7 +12389,7 @@ a: 'ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc', b: '64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1', n: 'ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831', - hash: hash_1$1.sha256, + hash: hash_1.sha256, gRed: false, g: [ '188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012', @@ -12398,7 +12404,7 @@ a: 'ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe', b: 'b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4', n: 'ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d', - hash: hash_1$1.sha256, + hash: hash_1.sha256, gRed: false, g: [ 'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21', @@ -12413,7 +12419,7 @@ a: 'ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc', b: '5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b', n: 'ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551', - hash: hash_1$1.sha256, + hash: hash_1.sha256, gRed: false, g: [ '6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296', @@ -12432,7 +12438,7 @@ '5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef', n: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 ' + 'f4372ddf 581a0db2 48b0a77a ecec196a ccc52973', - hash: hash_1$1.sha384, + hash: hash_1.sha384, gRed: false, g: [ 'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' + @@ -12457,7 +12463,7 @@ n: '000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ' + 'ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 ' + 'f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409', - hash: hash_1$1.sha512, + hash: hash_1.sha512, gRed: false, g: [ '000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 ' + @@ -12476,7 +12482,7 @@ a: '76d06', b: '1', n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash_1$1.sha256, + hash: hash_1.sha256, gRed: false, g: [ '9' @@ -12492,7 +12498,7 @@ // -121665 * (121666^(-1)) (mod P) d: '52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3', n: '1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed', - hash: hash_1$1.sha256, + hash: hash_1.sha256, gRed: false, g: [ '216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a', @@ -12517,7 +12523,7 @@ b: '7', n: 'ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141', h: '1', - hash: hash_1$1.sha256, + hash: hash_1.sha256, // Precomputed endomorphism beta: '7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee', @@ -12587,7 +12593,7 @@ }; HmacDRBG.prototype._hmac = function hmac() { - return new hash_1$1.hmac(this.hash, this.K); + return new hash_1.hmac(this.hash, this.K); }; HmacDRBG.prototype._update = function update(seed) { @@ -13176,13 +13182,13 @@ var _version$o = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "signing-key/5.0.0-beta.129"; + exports.version = "signing-key/5.0.0-beta.128"; }); var _version$p = unwrapExports(_version$o); var _version_1$c = _version$o.version; - var signingKey = createCommonjsModule(function (module, exports) { + var lib$f = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -13190,7 +13196,7 @@ - var logger$1 = new logger.Logger(_version$o.version); + var logger = new lib.Logger(_version$o.version); var _curve = null; function getCurve() { if (!_curve) { @@ -13200,31 +13206,31 @@ } var SigningKey = /** @class */ (function () { function SigningKey(privateKey) { - properties.defineReadOnly(this, "curve", "secp256k1"); - properties.defineReadOnly(this, "privateKey", bytes.hexlify(privateKey)); - var keyPair = getCurve().keyFromPrivate(bytes.arrayify(this.privateKey)); - properties.defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); - properties.defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); - properties.defineReadOnly(this, "_isSigningKey", true); + lib$3.defineReadOnly(this, "curve", "secp256k1"); + lib$3.defineReadOnly(this, "privateKey", lib$1.hexlify(privateKey)); + var keyPair = getCurve().keyFromPrivate(lib$1.arrayify(this.privateKey)); + lib$3.defineReadOnly(this, "publicKey", "0x" + keyPair.getPublic(false, "hex")); + lib$3.defineReadOnly(this, "compressedPublicKey", "0x" + keyPair.getPublic(true, "hex")); + lib$3.defineReadOnly(this, "_isSigningKey", true); } SigningKey.prototype._addPoint = function (other) { - var p0 = getCurve().keyFromPublic(bytes.arrayify(this.publicKey)); - var p1 = getCurve().keyFromPublic(bytes.arrayify(other)); + var p0 = getCurve().keyFromPublic(lib$1.arrayify(this.publicKey)); + var p1 = getCurve().keyFromPublic(lib$1.arrayify(other)); return "0x" + p0.pub.add(p1.pub).encodeCompressed("hex"); }; SigningKey.prototype.signDigest = function (digest) { - var keyPair = getCurve().keyFromPrivate(bytes.arrayify(this.privateKey)); - var signature = keyPair.sign(bytes.arrayify(digest), { canonical: true }); - return bytes.splitSignature({ + var keyPair = getCurve().keyFromPrivate(lib$1.arrayify(this.privateKey)); + var signature = keyPair.sign(lib$1.arrayify(digest), { canonical: true }); + return lib$1.splitSignature({ recoveryParam: signature.recoveryParam, - r: bytes.hexZeroPad("0x" + signature.r.toString(16), 32), - s: bytes.hexZeroPad("0x" + signature.s.toString(16), 32), + r: lib$1.hexZeroPad("0x" + signature.r.toString(16), 32), + s: lib$1.hexZeroPad("0x" + signature.s.toString(16), 32), }); }; SigningKey.prototype.computeSharedSecret = function (otherKey) { - var keyPair = getCurve().keyFromPrivate(bytes.arrayify(this.privateKey)); - var otherKeyPair = getCurve().keyFromPublic(bytes.arrayify(computePublicKey(otherKey))); - return bytes.hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); + var keyPair = getCurve().keyFromPrivate(lib$1.arrayify(this.privateKey)); + var otherKeyPair = getCurve().keyFromPublic(lib$1.arrayify(computePublicKey(otherKey))); + return lib$1.hexZeroPad("0x" + keyPair.derive(otherKeyPair.getPublic()).toString(16), 32); }; SigningKey.isSigningKey = function (value) { return !!(value && value._isSigningKey); @@ -13233,52 +13239,52 @@ }()); exports.SigningKey = SigningKey; function recoverPublicKey(digest, signature) { - var sig = bytes.splitSignature(signature); - var rs = { r: bytes.arrayify(sig.r), s: bytes.arrayify(sig.s) }; - return "0x" + getCurve().recoverPubKey(bytes.arrayify(digest), rs, sig.recoveryParam).encode("hex", false); + var sig = lib$1.splitSignature(signature); + var rs = { r: lib$1.arrayify(sig.r), s: lib$1.arrayify(sig.s) }; + return "0x" + getCurve().recoverPubKey(lib$1.arrayify(digest), rs, sig.recoveryParam).encode("hex", false); } exports.recoverPublicKey = recoverPublicKey; function computePublicKey(key, compressed) { - var bytes$1 = bytes.arrayify(key); - if (bytes$1.length === 32) { - var signingKey = new SigningKey(bytes$1); + var bytes = lib$1.arrayify(key); + if (bytes.length === 32) { + var signingKey = new SigningKey(bytes); if (compressed) { - return "0x" + getCurve().keyFromPrivate(bytes$1).getPublic(true, "hex"); + return "0x" + getCurve().keyFromPrivate(bytes).getPublic(true, "hex"); } return signingKey.publicKey; } - else if (bytes$1.length === 33) { + else if (bytes.length === 33) { if (compressed) { - return bytes.hexlify(bytes$1); + return lib$1.hexlify(bytes); } - return "0x" + getCurve().keyFromPublic(bytes$1).getPublic(false, "hex"); + return "0x" + getCurve().keyFromPublic(bytes).getPublic(false, "hex"); } - else if (bytes$1.length === 65) { + else if (bytes.length === 65) { if (!compressed) { - return bytes.hexlify(bytes$1); + return lib$1.hexlify(bytes); } - return "0x" + getCurve().keyFromPublic(bytes$1).getPublic(true, "hex"); + return "0x" + getCurve().keyFromPublic(bytes).getPublic(true, "hex"); } - return logger$1.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); + return logger.throwArgumentError("invalid public or private key", "key", "[REDACTED]"); } exports.computePublicKey = computePublicKey; }); - var index$f = unwrapExports(signingKey); - var signingKey_1 = signingKey.SigningKey; - var signingKey_2 = signingKey.recoverPublicKey; - var signingKey_3 = signingKey.computePublicKey; + var index$f = unwrapExports(lib$f); + var lib_1$f = lib$f.SigningKey; + var lib_2$d = lib$f.recoverPublicKey; + var lib_3$a = lib$f.computePublicKey; var _version$q = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "transactions/5.0.0-beta.128"; + exports.version = "transactions/5.0.0-beta.127"; }); var _version$r = unwrapExports(_version$q); var _version_1$d = _version$q.version; - var transactions = createCommonjsModule(function (module, exports) { + var lib$g = createCommonjsModule(function (module, exports) { "use strict"; var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; @@ -13294,23 +13300,23 @@ - var RLP = __importStar(rlp); + var RLP = __importStar(lib$5); - var logger$1 = new logger.Logger(_version$q.version); + var logger = new lib.Logger(_version$q.version); /////////////////////////////// function handleAddress(value) { if (value === "0x") { return null; } - return address.getAddress(value); + return lib$6.getAddress(value); } function handleNumber(value) { if (value === "0x") { - return constants.Zero; + return lib$7.Zero; } - return bignumber$2.BigNumber.from(value); + return lib$2.BigNumber.from(value); } var transactionFields = [ { name: "nonce", maxLength: 32 }, @@ -13324,35 +13330,35 @@ chainId: true, data: true, gasLimit: true, gasPrice: true, nonce: true, to: true, value: true }; function computeAddress(key) { - var publicKey = signingKey.computePublicKey(key); - return address.getAddress(bytes.hexDataSlice(keccak256_1.keccak256(bytes.hexDataSlice(publicKey, 1)), 12)); + var publicKey = lib$f.computePublicKey(key); + return lib$6.getAddress(lib$1.hexDataSlice(lib$4.keccak256(lib$1.hexDataSlice(publicKey, 1)), 12)); } exports.computeAddress = computeAddress; function recoverAddress(digest, signature) { - return computeAddress(signingKey.recoverPublicKey(bytes.arrayify(digest), signature)); + return computeAddress(lib$f.recoverPublicKey(lib$1.arrayify(digest), signature)); } exports.recoverAddress = recoverAddress; function serialize(transaction, signature) { - properties.checkProperties(transaction, allowedTransactionKeys); + lib$3.checkProperties(transaction, allowedTransactionKeys); var raw = []; transactionFields.forEach(function (fieldInfo) { var value = transaction[fieldInfo.name] || ([]); - value = bytes.arrayify(bytes.hexlify(value)); + value = lib$1.arrayify(lib$1.hexlify(value)); // Fixed-width field if (fieldInfo.length && value.length !== fieldInfo.length && value.length > 0) { - logger$1.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); } // Variable-width (with a maximum) if (fieldInfo.maxLength) { - value = bytes.stripZeros(value); + value = lib$1.stripZeros(value); if (value.length > fieldInfo.maxLength) { - logger$1.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); + logger.throwArgumentError("invalid length for " + fieldInfo.name, ("transaction:" + fieldInfo.name), value); } } - raw.push(bytes.hexlify(value)); + raw.push(lib$1.hexlify(value)); }); if (transaction.chainId != null && transaction.chainId !== 0) { - raw.push(bytes.hexlify(transaction.chainId)); + raw.push(lib$1.hexlify(transaction.chainId)); raw.push("0x"); raw.push("0x"); } @@ -13363,7 +13369,7 @@ } // The splitSignature will ensure the transaction has a recoveryParam in the // case that the signTransaction function only adds a v. - var sig = bytes.splitSignature(signature); + var sig = lib$1.splitSignature(signature); // We pushed a chainId and null r, s on for hashing only; remove those var v = 27 + sig.recoveryParam; if (raw.length === 9) { @@ -13372,16 +13378,16 @@ raw.pop(); v += transaction.chainId * 2 + 8; } - raw.push(bytes.hexlify(v)); - raw.push(bytes.stripZeros(bytes.arrayify(sig.r))); - raw.push(bytes.stripZeros(bytes.arrayify(sig.s))); + raw.push(lib$1.hexlify(v)); + raw.push(lib$1.stripZeros(lib$1.arrayify(sig.r))); + raw.push(lib$1.stripZeros(lib$1.arrayify(sig.s))); return RLP.encode(raw); } exports.serialize = serialize; function parse(rawTransaction) { var transaction = RLP.decode(rawTransaction); if (transaction.length !== 9 && transaction.length !== 6) { - logger$1.throwArgumentError("invalid raw transaction", "rawTransactin", rawTransaction); + logger.throwArgumentError("invalid raw transaction", "rawTransactin", rawTransaction); } var tx = { nonce: handleNumber(transaction[0]).toNumber(), @@ -13397,15 +13403,15 @@ return tx; } try { - tx.v = bignumber$2.BigNumber.from(transaction[6]).toNumber(); + tx.v = lib$2.BigNumber.from(transaction[6]).toNumber(); } catch (error) { console.log(error); return tx; } - tx.r = bytes.hexZeroPad(transaction[7], 32); - tx.s = bytes.hexZeroPad(transaction[8], 32); - if (bignumber$2.BigNumber.from(tx.r).isZero() && bignumber$2.BigNumber.from(tx.s).isZero()) { + tx.r = lib$1.hexZeroPad(transaction[7], 32); + tx.s = lib$1.hexZeroPad(transaction[8], 32); + if (lib$2.BigNumber.from(tx.r).isZero() && lib$2.BigNumber.from(tx.s).isZero()) { // EIP-155 unsigned transaction tx.chainId = tx.v; tx.v = 0; @@ -13419,35 +13425,35 @@ var recoveryParam = tx.v - 27; var raw = transaction.slice(0, 6); if (tx.chainId !== 0) { - raw.push(bytes.hexlify(tx.chainId)); + raw.push(lib$1.hexlify(tx.chainId)); raw.push("0x"); raw.push("0x"); recoveryParam -= tx.chainId * 2 + 8; } - var digest = keccak256_1.keccak256(RLP.encode(raw)); + var digest = lib$4.keccak256(RLP.encode(raw)); try { - tx.from = recoverAddress(digest, { r: bytes.hexlify(tx.r), s: bytes.hexlify(tx.s), recoveryParam: recoveryParam }); + tx.from = recoverAddress(digest, { r: lib$1.hexlify(tx.r), s: lib$1.hexlify(tx.s), recoveryParam: recoveryParam }); } catch (error) { console.log(error); } - tx.hash = keccak256_1.keccak256(rawTransaction); + tx.hash = lib$4.keccak256(rawTransaction); } return tx; } exports.parse = parse; }); - var index$g = unwrapExports(transactions); - var transactions_1 = transactions.computeAddress; - var transactions_2 = transactions.recoverAddress; - var transactions_3 = transactions.serialize; - var transactions_4 = transactions.parse; + var index$g = unwrapExports(lib$g); + var lib_1$g = lib$g.computeAddress; + var lib_2$e = lib$g.recoverAddress; + var lib_3$b = lib$g.serialize; + var lib_4$9 = lib$g.parse; var _version$s = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "wordlists/5.0.0-beta.128"; + exports.version = "wordlists/5.0.0-beta.127"; }); var _version$t = unwrapExports(_version$s); @@ -13462,7 +13468,7 @@ - var logger$1 = new logger.Logger(_version$s.version); + var logger = new lib.Logger(_version$s.version); function check(wordlist) { var words = []; for (var i = 0; i < 2048; i++) { @@ -13472,14 +13478,14 @@ } words.push(word); } - return hash.id(words.join("\n") + "\n"); + return lib$9.id(words.join("\n") + "\n"); } exports.check = check; var Wordlist = /** @class */ (function () { function Wordlist(locale) { var _newTarget = this.constructor; - logger$1.checkAbstract(_newTarget, Wordlist); - properties.defineReadOnly(this, "locale", locale); + logger.checkAbstract(_newTarget, Wordlist); + lib$3.defineReadOnly(this, "locale", locale); } // Subclasses may override this Wordlist.prototype.split = function (mnemonic) { @@ -13499,14 +13505,14 @@ if (exportWordlist) { var g = commonjsGlobal; if (!(g.wordlists)) { - properties.defineReadOnly(g, "wordlists", {}); + lib$3.defineReadOnly(g, "wordlists", {}); } if (!g.wordlists[name]) { - properties.defineReadOnly(g.wordlists, name, lang); + lib$3.defineReadOnly(g.wordlists, name, lang); } if (g.ethers && g.ethers.wordlists) { if (!g.ethers.wordlists[name]) { - properties.defineReadOnly(g.ethers.wordlists, name, lang); + lib$3.defineReadOnly(g.ethers.wordlists, name, lang); } } } @@ -13590,13 +13596,13 @@ var _version$u = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "hdnode/5.0.0-beta.130"; + exports.version = "hdnode/5.0.0-beta.129"; }); var _version$v = unwrapExports(_version$u); var _version_1$f = _version$u.version; - var hdnode = createCommonjsModule(function (module, exports) { + var lib$h = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -13611,10 +13617,10 @@ - var logger$1 = new logger.Logger(_version$u.version); - var N = bignumber$2.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); + var logger = new lib.Logger(_version$u.version); + var N = lib$2.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"); // "Bitcoin seed" - var MasterSecret = strings.toUtf8Bytes("Bitcoin seed"); + var MasterSecret = lib$8.toUtf8Bytes("Bitcoin seed"); var HardenedBit = 0x80000000; // Returns a byte with the MSB bits set function getUpperMask(bits) { @@ -13625,11 +13631,11 @@ return (1 << bits) - 1; } function bytes32(value) { - return bytes.hexZeroPad(bytes.hexlify(value), 32); + return lib$1.hexZeroPad(lib$1.hexlify(value), 32); } function base58check(data) { - var checksum = bytes.hexDataSlice(browser.sha256(browser.sha256(data)), 0, 4); - return basex.Base58.encode(bytes.concat([data, checksum])); + var checksum = lib$1.hexDataSlice(browser.sha256(browser.sha256(data)), 0, 4); + return lib$e.Base58.encode(lib$1.concat([data, checksum])); } var _constructorGuard = {}; exports.defaultPath = "m/44'/60'/0'/0/0"; @@ -13643,27 +13649,27 @@ */ function HDNode(constructorGuard, privateKey, publicKey, parentFingerprint, chainCode, index, depth, mnemonic, path) { var _newTarget = this.constructor; - logger$1.checkNew(_newTarget, HDNode); + logger.checkNew(_newTarget, HDNode); if (constructorGuard !== _constructorGuard) { throw new Error("HDNode constructor cannot be called directly"); } if (privateKey) { - var signingKey$1 = new signingKey.SigningKey(privateKey); - properties.defineReadOnly(this, "privateKey", signingKey$1.privateKey); - properties.defineReadOnly(this, "publicKey", signingKey$1.compressedPublicKey); + var signingKey = new lib$f.SigningKey(privateKey); + lib$3.defineReadOnly(this, "privateKey", signingKey.privateKey); + lib$3.defineReadOnly(this, "publicKey", signingKey.compressedPublicKey); } else { - properties.defineReadOnly(this, "privateKey", null); - properties.defineReadOnly(this, "publicKey", bytes.hexlify(publicKey)); + lib$3.defineReadOnly(this, "privateKey", null); + lib$3.defineReadOnly(this, "publicKey", lib$1.hexlify(publicKey)); } - properties.defineReadOnly(this, "parentFingerprint", parentFingerprint); - properties.defineReadOnly(this, "fingerprint", bytes.hexDataSlice(browser.ripemd160(browser.sha256(this.publicKey)), 0, 4)); - properties.defineReadOnly(this, "address", transactions.computeAddress(this.publicKey)); - properties.defineReadOnly(this, "chainCode", chainCode); - properties.defineReadOnly(this, "index", index); - properties.defineReadOnly(this, "depth", depth); - properties.defineReadOnly(this, "mnemonic", mnemonic); - properties.defineReadOnly(this, "path", path); + lib$3.defineReadOnly(this, "parentFingerprint", parentFingerprint); + lib$3.defineReadOnly(this, "fingerprint", lib$1.hexDataSlice(browser.ripemd160(browser.sha256(this.publicKey)), 0, 4)); + lib$3.defineReadOnly(this, "address", lib$g.computeAddress(this.publicKey)); + lib$3.defineReadOnly(this, "chainCode", chainCode); + lib$3.defineReadOnly(this, "index", index); + lib$3.defineReadOnly(this, "depth", depth); + lib$3.defineReadOnly(this, "mnemonic", mnemonic); + lib$3.defineReadOnly(this, "path", path); } Object.defineProperty(HDNode.prototype, "extendedKey", { get: function () { @@ -13675,13 +13681,13 @@ if (this.depth >= 256) { throw new Error("Depth too large!"); } - return base58check(bytes.concat([ + return base58check(lib$1.concat([ ((this.privateKey != null) ? "0x0488ADE4" : "0x0488B21E"), - bytes.hexlify(this.depth), + lib$1.hexlify(this.depth), this.parentFingerprint, - bytes.hexZeroPad(bytes.hexlify(this.index), 4), + lib$1.hexZeroPad(lib$1.hexlify(this.index), 4), this.chainCode, - ((this.privateKey != null) ? bytes.concat(["0x00", this.privateKey]) : this.publicKey), + ((this.privateKey != null) ? lib$1.concat(["0x00", this.privateKey]) : this.publicKey), ])); }, enumerable: true, @@ -13705,7 +13711,7 @@ throw new Error("cannot derive child of neutered node"); } // Data = 0x00 || ser_256(k_par) - data.set(bytes.arrayify(this.privateKey), 1); + data.set(lib$1.arrayify(this.privateKey), 1); // Hardened path if (path) { path += "'"; @@ -13713,13 +13719,13 @@ } else { // Data = ser_p(point(k_par)) - data.set(bytes.arrayify(this.publicKey)); + data.set(lib$1.arrayify(this.publicKey)); } // Data += ser_32(i) for (var i = 24; i >= 0; i -= 8) { data[33 + (i >> 3)] = ((index >> (24 - i)) & 0xff); } - var I = bytes.arrayify(browser.computeHmac(browser.SupportedAlgorithms.sha512, this.chainCode, data)); + var I = lib$1.arrayify(browser.computeHmac(browser.SupportedAlgorithms.sha512, this.chainCode, data)); var IL = I.slice(0, 32); var IR = I.slice(32); // The private key @@ -13727,10 +13733,10 @@ // The public key var Ki = null; if (this.privateKey) { - ki = bytes32(bignumber$2.BigNumber.from(IL).add(this.privateKey).mod(N)); + ki = bytes32(lib$2.BigNumber.from(IL).add(this.privateKey).mod(N)); } else { - var ek = new signingKey.SigningKey(bytes.hexlify(IL)); + var ek = new lib$f.SigningKey(lib$1.hexlify(IL)); Ki = ek._addPoint(this.publicKey); } return new HDNode(_constructorGuard, ki, Ki, this.fingerprint, bytes32(IR), index, this.depth + 1, this.mnemonic, path); @@ -13767,11 +13773,11 @@ return result; }; HDNode._fromSeed = function (seed, mnemonic) { - var seedArray = bytes.arrayify(seed); + var seedArray = lib$1.arrayify(seed); if (seedArray.length < 16 || seedArray.length > 64) { throw new Error("invalid seed"); } - var I = bytes.arrayify(browser.computeHmac(browser.SupportedAlgorithms.sha512, MasterSecret, seedArray)); + var I = lib$1.arrayify(browser.computeHmac(browser.SupportedAlgorithms.sha512, MasterSecret, seedArray)); return new HDNode(_constructorGuard, bytes32(I.slice(0, 32)), null, "0x00000000", bytes32(I.slice(32)), 0, 0, mnemonic, "m"); }; HDNode.fromMnemonic = function (mnemonic, password, wordlist) { @@ -13783,29 +13789,29 @@ return HDNode._fromSeed(seed, null); }; HDNode.fromExtendedKey = function (extendedKey) { - var bytes$1 = basex.Base58.decode(extendedKey); - if (bytes$1.length !== 82 || base58check(bytes$1.slice(0, 78)) !== extendedKey) { - logger$1.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); + var bytes = lib$e.Base58.decode(extendedKey); + if (bytes.length !== 82 || base58check(bytes.slice(0, 78)) !== extendedKey) { + logger.throwArgumentError("invalid extended key", "extendedKey", "[REDACTED]"); } - var depth = bytes$1[4]; - var parentFingerprint = bytes.hexlify(bytes$1.slice(5, 9)); - var index = parseInt(bytes.hexlify(bytes$1.slice(9, 13)).substring(2), 16); - var chainCode = bytes.hexlify(bytes$1.slice(13, 45)); - var key = bytes$1.slice(45, 78); - switch (bytes.hexlify(bytes$1.slice(0, 4))) { + var depth = bytes[4]; + var parentFingerprint = lib$1.hexlify(bytes.slice(5, 9)); + var index = parseInt(lib$1.hexlify(bytes.slice(9, 13)).substring(2), 16); + var chainCode = lib$1.hexlify(bytes.slice(13, 45)); + var key = bytes.slice(45, 78); + switch (lib$1.hexlify(bytes.slice(0, 4))) { // Public Key case "0x0488b21e": case "0x043587cf": - return new HDNode(_constructorGuard, null, bytes.hexlify(key), parentFingerprint, chainCode, index, depth, null, null); + return new HDNode(_constructorGuard, null, lib$1.hexlify(key), parentFingerprint, chainCode, index, depth, null, null); // Private Key case "0x0488ade4": case "0x04358394 ": if (key[0] !== 0) { break; } - return new HDNode(_constructorGuard, bytes.hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); + return new HDNode(_constructorGuard, lib$1.hexlify(key.slice(1)), null, parentFingerprint, chainCode, index, depth, null, null); } - return logger$1.throwError("invalid extended key", "extendedKey", "[REDACTED]"); + return logger.throwError("invalid extended key", "extendedKey", "[REDACTED]"); }; return HDNode; }()); @@ -13814,20 +13820,20 @@ if (!password) { password = ""; } - var salt = strings.toUtf8Bytes("mnemonic" + password, strings.UnicodeNormalizationForm.NFKD); - return browser$2.pbkdf2(strings.toUtf8Bytes(mnemonic, strings.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); + var salt = lib$8.toUtf8Bytes("mnemonic" + password, lib$8.UnicodeNormalizationForm.NFKD); + return browser$2.pbkdf2(lib$8.toUtf8Bytes(mnemonic, lib$8.UnicodeNormalizationForm.NFKD), salt, 2048, 64, "sha512"); } exports.mnemonicToSeed = mnemonicToSeed; function mnemonicToEntropy(mnemonic, wordlist) { if (!wordlist) { wordlist = browser$4.wordlists["en"]; } - logger$1.checkNormalize(); + logger.checkNormalize(); var words = wordlist.split(mnemonic); if ((words.length % 3) !== 0) { throw new Error("invalid mnemonic"); } - var entropy = bytes.arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); + var entropy = lib$1.arrayify(new Uint8Array(Math.ceil(11 * words.length / 8))); var offset = 0; for (var i = 0; i < words.length; i++) { var index = wordlist.getWordIndex(words[i].normalize("NFKD")); @@ -13844,16 +13850,16 @@ var entropyBits = 32 * words.length / 3; var checksumBits = words.length / 3; var checksumMask = getUpperMask(checksumBits); - var checksum = bytes.arrayify(browser.sha256(entropy.slice(0, entropyBits / 8)))[0]; + var checksum = lib$1.arrayify(browser.sha256(entropy.slice(0, entropyBits / 8)))[0]; checksum &= checksumMask; if (checksum !== (entropy[entropy.length - 1] & checksumMask)) { throw new Error("invalid checksum"); } - return bytes.hexlify(entropy.slice(0, entropyBits / 8)); + return lib$1.hexlify(entropy.slice(0, entropyBits / 8)); } exports.mnemonicToEntropy = mnemonicToEntropy; function entropyToMnemonic(entropy, wordlist) { - entropy = bytes.arrayify(entropy); + entropy = lib$1.arrayify(entropy); if ((entropy.length % 4) !== 0 || entropy.length < 16 || entropy.length > 32) { throw new Error("invalid entropy"); } @@ -13876,7 +13882,7 @@ } } // Compute the checksum bits - var checksum = bytes.arrayify(browser.sha256(entropy))[0]; + var checksum = lib$1.arrayify(browser.sha256(entropy))[0]; var checksumBits = entropy.length / 4; checksum &= getUpperMask(checksumBits); // Shift the checksum into the word indices @@ -13899,18 +13905,18 @@ exports.isValidMnemonic = isValidMnemonic; }); - var index$h = unwrapExports(hdnode); - var hdnode_1 = hdnode.defaultPath; - var hdnode_2 = hdnode.HDNode; - var hdnode_3 = hdnode.mnemonicToSeed; - var hdnode_4 = hdnode.mnemonicToEntropy; - var hdnode_5 = hdnode.entropyToMnemonic; - var hdnode_6 = hdnode.isValidMnemonic; + var index$h = unwrapExports(lib$h); + var lib_1$h = lib$h.defaultPath; + var lib_2$f = lib$h.HDNode; + var lib_3$c = lib$h.mnemonicToSeed; + var lib_4$a = lib$h.mnemonicToEntropy; + var lib_5$8 = lib$h.entropyToMnemonic; + var lib_6$5 = lib$h.isValidMnemonic; var _version$w = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "random/5.0.0-beta.128"; + exports.version = "random/5.0.0-beta.127"; }); var _version$x = unwrapExports(_version$w); @@ -13941,15 +13947,15 @@ - var logger$1 = new logger.Logger(_version$w.version); + var logger = new lib.Logger(_version$w.version); exports.shuffled = shuffle.shuffled; var crypto = commonjsGlobal.crypto || commonjsGlobal.msCrypto; if (!crypto || !crypto.getRandomValues) { - logger$1.warn("WARNING: Missing strong random number source"); + logger.warn("WARNING: Missing strong random number source"); crypto = { getRandomValues: function (buffer) { - return logger$1.throwError("no secure random source avaialble", logger.Logger.errors.UNSUPPORTED_OPERATION, { + return logger.throwError("no secure random source avaialble", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "crypto.getRandomValues" }); } @@ -13957,11 +13963,11 @@ } function randomBytes(length) { if (length <= 0 || length > 1024 || parseInt(String(length)) != length) { - logger$1.throwArgumentError("invalid length", "length", length); + logger.throwArgumentError("invalid length", "length", length); } var result = new Uint8Array(length); crypto.getRandomValues(result); - return bytes.arrayify(result); + return lib$1.arrayify(result); } exports.randomBytes = randomBytes; ; @@ -14775,7 +14781,7 @@ var _version$y = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "json-wallets/5.0.0-beta.129"; + exports.version = "json-wallets/5.0.0-beta.128"; }); var _version$z = unwrapExports(_version$y); @@ -14804,7 +14810,7 @@ if (typeof (hexString) === 'string' && hexString.substring(0, 2) !== '0x') { hexString = '0x' + hexString; } - return bytes.arrayify(hexString); + return lib$1.arrayify(hexString); } exports.looseArrayify = looseArrayify; function zpad(value, length) { @@ -14817,9 +14823,9 @@ exports.zpad = zpad; function getPassword(password) { if (typeof (password) === 'string') { - return strings.toUtf8Bytes(password, strings.UnicodeNormalizationForm.NFKC); + return lib$8.toUtf8Bytes(password, lib$8.UnicodeNormalizationForm.NFKC); } - return bytes.arrayify(password); + return lib$1.arrayify(password); } exports.getPassword = getPassword; function searchPath(object, path) { @@ -14880,7 +14886,7 @@ - var logger$1 = new logger.Logger(_version$y.version); + var logger = new lib.Logger(_version$y.version); var CrowdsaleAccount = /** @class */ (function (_super) { __extends(CrowdsaleAccount, _super); @@ -14891,33 +14897,33 @@ return !!(value && value._isCrowdsaleAccount); }; return CrowdsaleAccount; - }(properties.Description)); + }(lib$3.Description)); exports.CrowdsaleAccount = CrowdsaleAccount; // See: https://github.com/ethereum/pyethsaletool function decrypt(json, password) { var data = JSON.parse(json); password = utils$1.getPassword(password); // Ethereum Address - var ethaddr = address.getAddress(utils$1.searchPath(data, "ethaddr")); + var ethaddr = lib$6.getAddress(utils$1.searchPath(data, "ethaddr")); // Encrypted Seed var encseed = utils$1.looseArrayify(utils$1.searchPath(data, "encseed")); if (!encseed || (encseed.length % 16) !== 0) { - logger$1.throwArgumentError("invalid encseed", "json", json); + logger.throwArgumentError("invalid encseed", "json", json); } - var key = bytes.arrayify(browser$2.pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); + var key = lib$1.arrayify(browser$2.pbkdf2(password, password, 2000, 32, "sha256")).slice(0, 16); var iv = encseed.slice(0, 16); var encryptedSeed = encseed.slice(16); // Decrypt the seed var aesCbc = new aes_js_1.default.ModeOfOperation.cbc(key, iv); - var seed = bytes.arrayify(aesCbc.decrypt(encryptedSeed)); + var seed = lib$1.arrayify(aesCbc.decrypt(encryptedSeed)); seed = aes_js_1.default.padding.pkcs7.strip(seed); // This wallet format is weird... Convert the binary encoded hex to a string. var seedHex = ""; for (var i = 0; i < seed.length; i++) { seedHex += String.fromCharCode(seed[i]); } - var seedHexBytes = strings.toUtf8Bytes(seedHex); - var privateKey = keccak256_1.keccak256(seedHexBytes); + var seedHexBytes = lib$8.toUtf8Bytes(seedHex); + var privateKey = lib$4.keccak256(seedHexBytes); return new CrowdsaleAccount({ _isCrowdsaleAccount: true, address: ethaddr, @@ -14967,7 +14973,7 @@ function getJsonWalletAddress(json) { if (isCrowdsaleWallet(json)) { try { - return address.getAddress(JSON.parse(json).ethaddr); + return lib$6.getAddress(JSON.parse(json).ethaddr); } catch (error) { return null; @@ -14975,7 +14981,7 @@ } if (isKeystoreWallet(json)) { try { - return address.getAddress(JSON.parse(json).address); + return lib$6.getAddress(JSON.parse(json).address); } catch (error) { return null; @@ -15703,7 +15709,7 @@ return !!(value && value._isKeystoreAccount); }; return KeystoreAccount; - }(properties.Description)); + }(lib$3.Description)); exports.KeystoreAccount = KeystoreAccount; function decrypt(json, password, progressCallback) { var data = JSON.parse(json); @@ -15714,16 +15720,16 @@ var iv = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/cipherparams/iv")); var counter = new aes_js_1.default.Counter(iv); var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(key, counter); - return bytes.arrayify(aesCtr.decrypt(ciphertext)); + return lib$1.arrayify(aesCtr.decrypt(ciphertext)); } return null; }; var computeMAC = function (derivedHalf, ciphertext) { - return keccak256_1.keccak256(bytes.concat([derivedHalf, ciphertext])); + return lib$4.keccak256(lib$1.concat([derivedHalf, ciphertext])); }; var getAccount = function (key, reject) { var ciphertext = utils$1.looseArrayify(utils$1.searchPath(data, "crypto/ciphertext")); - var computedMAC = bytes.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); + var computedMAC = lib$1.hexlify(computeMAC(key.slice(16, 32), ciphertext)).substring(2); if (computedMAC !== utils$1.searchPath(data, "crypto/mac").toLowerCase()) { reject(new Error("invalid password")); return null; @@ -15734,14 +15740,14 @@ reject(new Error("unsupported cipher")); return null; } - var address$1 = transactions.computeAddress(privateKey); + var address = lib$g.computeAddress(privateKey); if (data.address) { var check = data.address.toLowerCase(); if (check.substring(0, 2) !== "0x") { check = "0x" + check; } try { - if (address.getAddress(check) !== address$1) { + if (lib$6.getAddress(check) !== address) { reject(new Error("address mismatch")); return null; } @@ -15750,8 +15756,8 @@ } var account = { _isKeystoreAccount: true, - address: address$1, - privateKey: bytes.hexlify(privateKey) + address: address, + privateKey: lib$1.hexlify(privateKey) }; // Version 0.1 x-ethers metadata must contain an encrypted mnemonic phrase if (utils$1.searchPath(data, "x-ethers/version") === "0.1") { @@ -15759,10 +15765,10 @@ var mnemonicIv = utils$1.looseArrayify(utils$1.searchPath(data, "x-ethers/mnemonicCounter")); var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); - var path = utils$1.searchPath(data, "x-ethers/path") || hdnode.defaultPath; - var entropy = bytes.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); - var mnemonic = hdnode.entropyToMnemonic(entropy); - var node = hdnode.HDNode.fromMnemonic(mnemonic).derivePath(path); + var path = utils$1.searchPath(data, "x-ethers/path") || lib$h.defaultPath; + var entropy = lib$1.arrayify(mnemonicAesCtr.decrypt(mnemonicCiphertext)); + var mnemonic = lib$h.entropyToMnemonic(entropy); + var node = lib$h.HDNode.fromMnemonic(mnemonic).derivePath(path); if (node.privateKey != account.privateKey) { reject(new Error("mnemonic mismatch")); return null; @@ -15803,7 +15809,7 @@ reject(error); } else if (key) { - key = bytes.arrayify(key); + key = lib$1.arrayify(key); var account = getAccount(key, reject); if (!account) { return; @@ -15838,7 +15844,7 @@ reject(new Error("unsupported key-derivation derived-key length")); return; } - var key = bytes.arrayify(browser$2.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); + var key = lib$1.arrayify(browser$2.pbkdf2(passwordBytes, salt, c, dkLen, prfFunc)); var account = getAccount(key, reject); if (!account) { return; @@ -15857,11 +15863,11 @@ exports.decrypt = decrypt; function encrypt(account, password, options, progressCallback) { try { - if (address.getAddress(account.address) !== transactions.computeAddress(account.privateKey)) { + if (lib$6.getAddress(account.address) !== lib$g.computeAddress(account.privateKey)) { throw new Error("address/privateKey mismatch"); } if (account.mnemonic != null) { - var node = hdnode.HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || hdnode.defaultPath); + var node = lib$h.HDNode.fromMnemonic(account.mnemonic).derivePath(account.path || lib$h.defaultPath); if (node.privateKey != account.privateKey) { throw new Error("mnemonic mismatch"); } @@ -15881,14 +15887,14 @@ if (!options) { options = {}; } - var privateKey = bytes.arrayify(account.privateKey); + var privateKey = lib$1.arrayify(account.privateKey); var passwordBytes = utils$1.getPassword(password); var entropy = null; var path = account.path; if (account.mnemonic) { - entropy = bytes.arrayify(hdnode.mnemonicToEntropy(account.mnemonic)); + entropy = lib$1.arrayify(lib$h.mnemonicToEntropy(account.mnemonic)); if (!path) { - path = hdnode.defaultPath; + path = lib$h.defaultPath; } } var client = options.client; @@ -15898,7 +15904,7 @@ // Check/generate the salt var salt = null; if (options.salt) { - salt = bytes.arrayify(options.salt); + salt = lib$1.arrayify(options.salt); } else { salt = browser$6.randomBytes(32); @@ -15907,7 +15913,7 @@ // Override initialization vector var iv = null; if (options.iv) { - iv = bytes.arrayify(options.iv); + iv = lib$1.arrayify(options.iv); if (iv.length !== 16) { throw new Error("invalid iv"); } @@ -15918,7 +15924,7 @@ // Override the uuid var uuidRandom = null; if (options.uuid) { - uuidRandom = bytes.arrayify(options.uuid); + uuidRandom = lib$1.arrayify(options.uuid); if (uuidRandom.length !== 16) { throw new Error("invalid uuid"); } @@ -15952,7 +15958,7 @@ reject(error); } else if (key) { - key = bytes.arrayify(key); + key = lib$1.arrayify(key); // This will be used to encrypt the wallet (as per Web3 secret storage) var derivedKey = key.slice(0, 16); var macPrefix = key.slice(16, 32); @@ -15961,9 +15967,9 @@ // Encrypt the private key var counter = new aes_js_1.default.Counter(iv); var aesCtr = new aes_js_1.default.ModeOfOperation.ctr(derivedKey, counter); - var ciphertext = bytes.arrayify(aesCtr.encrypt(privateKey)); + var ciphertext = lib$1.arrayify(aesCtr.encrypt(privateKey)); // Compute the message authentication code, used to check the password - var mac = keccak256_1.keccak256(bytes.concat([macPrefix, ciphertext])); + var mac = lib$4.keccak256(lib$1.concat([macPrefix, ciphertext])); // See: https://github.com/ethereum/wiki/wiki/Web3-Secret-Storage-Definition var data = { address: account.address.substring(2).toLowerCase(), @@ -15972,12 +15978,12 @@ Crypto: { cipher: "aes-128-ctr", cipherparams: { - iv: bytes.hexlify(iv).substring(2), + iv: lib$1.hexlify(iv).substring(2), }, - ciphertext: bytes.hexlify(ciphertext).substring(2), + ciphertext: lib$1.hexlify(ciphertext).substring(2), kdf: "scrypt", kdfparams: { - salt: bytes.hexlify(salt).substring(2), + salt: lib$1.hexlify(salt).substring(2), n: N, dklen: 32, p: p, @@ -15991,7 +15997,7 @@ var mnemonicIv = browser$6.randomBytes(16); var mnemonicCounter = new aes_js_1.default.Counter(mnemonicIv); var mnemonicAesCtr = new aes_js_1.default.ModeOfOperation.ctr(mnemonicKey, mnemonicCounter); - var mnemonicCiphertext = bytes.arrayify(mnemonicAesCtr.encrypt(entropy)); + var mnemonicCiphertext = lib$1.arrayify(mnemonicAesCtr.encrypt(entropy)); var now = new Date(); var timestamp = (now.getUTCFullYear() + "-" + utils$1.zpad(now.getUTCMonth() + 1, 2) + "-" + @@ -16002,8 +16008,8 @@ data["x-ethers"] = { client: client, gethFilename: ("UTC--" + timestamp + "--" + data.address), - mnemonicCounter: bytes.hexlify(mnemonicIv).substring(2), - mnemonicCiphertext: bytes.hexlify(mnemonicCiphertext).substring(2), + mnemonicCounter: lib$1.hexlify(mnemonicIv).substring(2), + mnemonicCiphertext: lib$1.hexlify(mnemonicCiphertext).substring(2), path: path, version: "0.1" }; @@ -16027,7 +16033,7 @@ var keystore_2 = keystore.decrypt; var keystore_3 = keystore.encrypt; - var jsonWallets = createCommonjsModule(function (module, exports) { + var lib$i = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -16058,25 +16064,25 @@ exports.decryptJsonWallet = decryptJsonWallet; }); - var index$i = unwrapExports(jsonWallets); - var jsonWallets_1 = jsonWallets.decryptCrowdsale; - var jsonWallets_2 = jsonWallets.getJsonWalletAddress; - var jsonWallets_3 = jsonWallets.isCrowdsaleWallet; - var jsonWallets_4 = jsonWallets.isKeystoreWallet; - var jsonWallets_5 = jsonWallets.decryptKeystore; - var jsonWallets_6 = jsonWallets.encryptKeystore; - var jsonWallets_7 = jsonWallets.decryptJsonWallet; + var index$i = unwrapExports(lib$i); + var lib_1$i = lib$i.decryptCrowdsale; + var lib_2$g = lib$i.getJsonWalletAddress; + var lib_3$d = lib$i.isCrowdsaleWallet; + var lib_4$b = lib$i.isKeystoreWallet; + var lib_5$9 = lib$i.decryptKeystore; + var lib_6$6 = lib$i.encryptKeystore; + var lib_7$5 = lib$i.decryptJsonWallet; var _version$A = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "wallet/5.0.0-beta.130"; + exports.version = "wallet/5.0.0-beta.129"; }); var _version$B = unwrapExports(_version$A); var _version_1$i = _version$A.version; - var wallet = createCommonjsModule(function (module, exports) { + var lib$j = createCommonjsModule(function (module, exports) { "use strict"; var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { var extendStatics = function (d, b) { @@ -16106,58 +16112,58 @@ - var logger$1 = new logger.Logger(_version$A.version); + var logger = new lib.Logger(_version$A.version); function isAccount(value) { - return (value != null && bytes.isHexString(value.privateKey, 32) && value.address != null); + return (value != null && lib$1.isHexString(value.privateKey, 32) && value.address != null); } var Wallet = /** @class */ (function (_super) { __extends(Wallet, _super); function Wallet(privateKey, provider) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, Wallet); + logger.checkNew(_newTarget, Wallet); _this = _super.call(this) || this; if (isAccount(privateKey)) { - var signingKey_1 = new signingKey.SigningKey(privateKey.privateKey); - properties.defineReadOnly(_this, "_signingKey", function () { return signingKey_1; }); - properties.defineReadOnly(_this, "address", transactions.computeAddress(_this.publicKey)); - if (_this.address !== address.getAddress(privateKey.address)) { - logger$1.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); + var signingKey_1 = new lib$f.SigningKey(privateKey.privateKey); + lib$3.defineReadOnly(_this, "_signingKey", function () { return signingKey_1; }); + lib$3.defineReadOnly(_this, "address", lib$g.computeAddress(_this.publicKey)); + if (_this.address !== lib$6.getAddress(privateKey.address)) { + logger.throwArgumentError("privateKey/address mismatch", "privateKey", "[REDCACTED]"); } if (privateKey.mnemonic != null) { var mnemonic_1 = privateKey.mnemonic; - var path = privateKey.path || hdnode.defaultPath; - properties.defineReadOnly(_this, "_mnemonic", function () { return mnemonic_1; }); - properties.defineReadOnly(_this, "path", privateKey.path); - var node = hdnode.HDNode.fromMnemonic(mnemonic_1).derivePath(path); - if (transactions.computeAddress(node.privateKey) !== _this.address) { - logger$1.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); + var path = privateKey.path || lib$h.defaultPath; + lib$3.defineReadOnly(_this, "_mnemonic", function () { return mnemonic_1; }); + lib$3.defineReadOnly(_this, "path", privateKey.path); + var node = lib$h.HDNode.fromMnemonic(mnemonic_1).derivePath(path); + if (lib$g.computeAddress(node.privateKey) !== _this.address) { + logger.throwArgumentError("mnemonic/address mismatch", "privateKey", "[REDCACTED]"); } } else { - properties.defineReadOnly(_this, "_mnemonic", function () { return null; }); - properties.defineReadOnly(_this, "path", null); + lib$3.defineReadOnly(_this, "_mnemonic", function () { return null; }); + lib$3.defineReadOnly(_this, "path", null); } } else { - if (signingKey.SigningKey.isSigningKey(privateKey)) { + if (lib$f.SigningKey.isSigningKey(privateKey)) { if (privateKey.curve !== "secp256k1") { - logger$1.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); + logger.throwArgumentError("unsupported curve; must be secp256k1", "privateKey", "[REDACTED]"); } - properties.defineReadOnly(_this, "_signingKey", function () { return privateKey; }); + lib$3.defineReadOnly(_this, "_signingKey", function () { return privateKey; }); } else { - var signingKey_2 = new signingKey.SigningKey(privateKey); - properties.defineReadOnly(_this, "_signingKey", function () { return signingKey_2; }); + var signingKey_2 = new lib$f.SigningKey(privateKey); + lib$3.defineReadOnly(_this, "_signingKey", function () { return signingKey_2; }); } - properties.defineReadOnly(_this, "_mnemonic", function () { return null; }); - properties.defineReadOnly(_this, "path", null); - properties.defineReadOnly(_this, "address", transactions.computeAddress(_this.publicKey)); + lib$3.defineReadOnly(_this, "_mnemonic", function () { return null; }); + lib$3.defineReadOnly(_this, "path", null); + lib$3.defineReadOnly(_this, "address", lib$g.computeAddress(_this.publicKey)); } - if (provider && !abstractProvider.Provider.isProvider(provider)) { - logger$1.throwArgumentError("invalid provider", "provider", provider); + if (provider && !lib$b.Provider.isProvider(provider)) { + logger.throwArgumentError("invalid provider", "provider", provider); } - properties.defineReadOnly(_this, "provider", provider || null); + lib$3.defineReadOnly(_this, "provider", provider || null); return _this; } Object.defineProperty(Wallet.prototype, "mnemonic", { @@ -16183,19 +16189,19 @@ }; Wallet.prototype.signTransaction = function (transaction) { var _this = this; - return properties.resolveProperties(transaction).then(function (tx) { + return lib$3.resolveProperties(transaction).then(function (tx) { if (tx.from != null) { - if (address.getAddress(tx.from) !== _this.address) { + if (lib$6.getAddress(tx.from) !== _this.address) { throw new Error("transaction from address mismatch"); } delete tx.from; } - var signature = _this._signingKey().signDigest(keccak256_1.keccak256(transactions.serialize(tx))); - return transactions.serialize(tx, signature); + var signature = _this._signingKey().signDigest(lib$4.keccak256(lib$g.serialize(tx))); + return lib$g.serialize(tx, signature); }); }; Wallet.prototype.signMessage = function (message) { - return Promise.resolve(bytes.joinSignature(this._signingKey().signDigest(hash.hashMessage(message)))); + return Promise.resolve(lib$1.joinSignature(this._signingKey().signDigest(lib$9.hashMessage(message)))); }; Wallet.prototype.encrypt = function (password, options, progressCallback) { if (typeof (options) === "function" && !progressCallback) { @@ -16208,7 +16214,7 @@ if (!options) { options = {}; } - return jsonWallets.encryptKeystore(this, password, options, progressCallback); + return lib$i.encryptKeystore(this, password, options, progressCallback); }; /** * Static methods to create Wallet instances. @@ -16219,50 +16225,50 @@ options = {}; } if (options.extraEntropy) { - entropy = bytes.arrayify(bytes.hexDataSlice(keccak256_1.keccak256(bytes.concat([entropy, options.extraEntropy])), 0, 16)); + entropy = lib$1.arrayify(lib$1.hexDataSlice(lib$4.keccak256(lib$1.concat([entropy, options.extraEntropy])), 0, 16)); } - var mnemonic = hdnode.entropyToMnemonic(entropy, options.locale); + var mnemonic = lib$h.entropyToMnemonic(entropy, options.locale); return Wallet.fromMnemonic(mnemonic, options.path, options.locale); }; Wallet.fromEncryptedJson = function (json, password, progressCallback) { - return jsonWallets.decryptJsonWallet(json, password, progressCallback).then(function (account) { + return lib$i.decryptJsonWallet(json, password, progressCallback).then(function (account) { return new Wallet(account); }); }; Wallet.fromMnemonic = function (mnemonic, path, wordlist) { if (!path) { - path = hdnode.defaultPath; + path = lib$h.defaultPath; } - return new Wallet(hdnode.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); + return new Wallet(lib$h.HDNode.fromMnemonic(mnemonic, null, wordlist).derivePath(path)); }; return Wallet; - }(abstractSigner.Signer)); + }(lib$c.Signer)); exports.Wallet = Wallet; function verifyMessage(message, signature) { - return transactions.recoverAddress(hash.hashMessage(message), signature); + return lib$g.recoverAddress(lib$9.hashMessage(message), signature); } exports.verifyMessage = verifyMessage; }); - var index$j = unwrapExports(wallet); - var wallet_1 = wallet.Wallet; - var wallet_2 = wallet.verifyMessage; + var index$j = unwrapExports(lib$j); + var lib_1$j = lib$j.Wallet; + var lib_2$h = lib$j.verifyMessage; var _version$C = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "networks/5.0.0-beta.129"; + exports.version = "networks/5.0.0-beta.128"; }); var _version$D = unwrapExports(_version$C); var _version_1$j = _version$C.version; - var networks_1 = createCommonjsModule(function (module, exports) { + var lib$k = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$C.version); + var logger = new lib.Logger(_version$C.version); function ethDefaultProvider(network) { return function (providers, options) { if (options == null) { @@ -16414,13 +16420,13 @@ // Not a standard network; check that it is a valid network in general if (!standard) { if (typeof (network.chainId) !== "number") { - logger$1.throwArgumentError("invalid network chainId", "network", network); + logger.throwArgumentError("invalid network chainId", "network", network); } return network; } // Make sure the chainId matches the expected network chainId (or is 0; disable EIP-155) if (network.chainId !== 0 && network.chainId !== standard.chainId) { - logger$1.throwArgumentError("network chainId mismatch", "network", network); + logger.throwArgumentError("network chainId mismatch", "network", network); } // Standard Network (allow overriding the ENS address) return { @@ -16433,8 +16439,8 @@ exports.getNetwork = getNetwork; }); - var index$k = unwrapExports(networks_1); - var networks_2 = networks_1.getNetwork; + var index$k = unwrapExports(lib$k); + var lib_1$k = lib$k.getNetwork; var browserPonyfill = createCommonjsModule(function (module, exports) { var __self__ = (function (root) { @@ -16998,11 +17004,11 @@ for (var i = 0; i < textData.length; i++) { data.push(textData.charCodeAt(i)); } - return bytes.arrayify(data); + return lib$1.arrayify(data); } exports.decode = decode; function encode(data) { - data = bytes.arrayify(data); + data = lib$1.arrayify(data); var textData = ""; for (var i = 0; i < data.length; i++) { textData += String.fromCharCode(data[i]); @@ -17019,13 +17025,13 @@ var _version$E = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "web/5.0.0-beta.129"; + exports.version = "web/5.0.0-beta.128"; }); var _version$F = unwrapExports(_version$E); var _version_1$k = _version$E.version; - var web = createCommonjsModule(function (module, exports) { + var lib$l = createCommonjsModule(function (module, exports) { "use strict"; var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; @@ -17037,7 +17043,7 @@ - var logger$1 = new logger.Logger(_version$E.version); + var logger = new lib.Logger(_version$E.version); function fetchJson(connection, json, processFunc) { var headers = {}; var url = null; @@ -17056,7 +17062,7 @@ } else if (typeof (connection) === "object") { if (connection == null || connection.url == null) { - logger$1.throwArgumentError("missing URL", "connection.url", connection); + logger.throwArgumentError("missing URL", "connection.url", connection); } url = connection.url; if (typeof (connection.timeout) === "number" && connection.timeout > 0) { @@ -17069,12 +17075,12 @@ } if (connection.user != null && connection.password != null) { if (url.substring(0, 6) !== "https:" && connection.allowInsecureAuthentication !== true) { - logger$1.throwError("basic authentication requires a secure https url", logger.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" }); + logger.throwError("basic authentication requires a secure https url", lib.Logger.errors.INVALID_ARGUMENT, { argument: "url", url: url, user: connection.user, password: "[REDACTED]" }); } var authorization = connection.user + ":" + connection.password; headers["authorization"] = { key: "Authorization", - value: "Basic " + browser$8.encode(strings.toUtf8Bytes(authorization)) + value: "Basic " + browser$8.encode(lib$8.toUtf8Bytes(authorization)) }; } } @@ -17086,7 +17092,7 @@ return; } timer = null; - reject(logger$1.makeError("timeout", logger.Logger.errors.TIMEOUT, { timeout: timeout })); + reject(logger.makeError("timeout", lib.Logger.errors.TIMEOUT, { timeout: timeout })); }, timeout); } var cancelTimeout = function () { @@ -17110,7 +17116,7 @@ return cross_fetch_1.default(url, options).then(function (response) { return response.text().then(function (body) { if (!response.ok) { - logger$1.throwError("bad response", logger.Logger.errors.SERVER_ERROR, { + logger.throwError("bad response", lib.Logger.errors.SERVER_ERROR, { status: response.status, body: body, type: response.type, @@ -17125,7 +17131,7 @@ json = JSON.parse(text); } catch (error) { - logger$1.throwError("invalid JSON", logger.Logger.errors.SERVER_ERROR, { + logger.throwError("invalid JSON", lib.Logger.errors.SERVER_ERROR, { body: text, error: error, url: url @@ -17136,7 +17142,7 @@ json = processFunc(json); } catch (error) { - logger$1.throwError("processing response error", logger.Logger.errors.SERVER_ERROR, { + logger.throwError("processing response error", lib.Logger.errors.SERVER_ERROR, { body: json, error: error }); @@ -17159,7 +17165,7 @@ if (!options) { options = {}; } - options = properties.shallowCopy(options); + options = lib$3.shallowCopy(options); if (options.floor == null) { options.floor = 0; } @@ -17234,14 +17240,14 @@ exports.poll = poll; }); - var index$l = unwrapExports(web); - var web_1 = web.fetchJson; - var web_2 = web.poll; + var index$l = unwrapExports(lib$l); + var lib_1$l = lib$l.fetchJson; + var lib_2$i = lib$l.poll; var _version$G = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "providers/5.0.0-beta.141"; + exports.version = "providers/5.0.0-beta.140"; }); var _version$H = unwrapExports(_version$G); @@ -17258,11 +17264,11 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); var Formatter = /** @class */ (function () { function Formatter() { var _newTarget = this.constructor; - logger$1.checkNew(_newTarget, Formatter); + logger.checkNew(_newTarget, Formatter); this.formats = this.getDefaultFormats(); } Formatter.prototype.getDefaultFormats = function () { @@ -17344,7 +17350,7 @@ extraData: data, transactions: Formatter.allowNull(Formatter.arrayOf(hash)), }; - formats.blockWithTransactions = properties.shallowCopy(formats.block); + formats.blockWithTransactions = lib$3.shallowCopy(formats.block); formats.blockWithTransactions.transactions = Formatter.allowNull(Formatter.arrayOf(this.transactionResponse.bind(this))); formats.filter = { fromBlock: Formatter.allowNull(blockTag, undefined), @@ -17369,11 +17375,11 @@ // Requires a BigNumberish that is within the IEEE754 safe integer range; returns a number // Strict! Used on input. Formatter.prototype.number = function (number) { - return bignumber$2.BigNumber.from(number).toNumber(); + return lib$2.BigNumber.from(number).toNumber(); }; // Strict! Used on input. Formatter.prototype.bigNumber = function (value) { - return bignumber$2.BigNumber.from(value); + return lib$2.BigNumber.from(value); }; // Requires a boolean, "true" or "false"; returns a boolean Formatter.prototype.boolean = function (value) { @@ -17396,11 +17402,11 @@ if (!strict && value.substring(0, 2) !== "0x") { value = "0x" + value; } - if (bytes.isHexString(value)) { + if (lib$1.isHexString(value)) { return value.toLowerCase(); } } - return logger$1.throwArgumentError("invalid hash", "value", value); + return logger.throwArgumentError("invalid hash", "value", value); }; Formatter.prototype.data = function (value, strict) { var result = this.hex(value, strict); @@ -17412,17 +17418,17 @@ // Requires an address // Strict! Used on input. Formatter.prototype.address = function (value) { - return address.getAddress(value); + return lib$6.getAddress(value); }; Formatter.prototype.callAddress = function (value) { - if (!bytes.isHexString(value, 32)) { + if (!lib$1.isHexString(value, 32)) { return null; } - var address$1 = address.getAddress(bytes.hexDataSlice(value, 12)); - return (address$1 === constants.AddressZero) ? null : address$1; + var address = lib$6.getAddress(lib$1.hexDataSlice(value, 12)); + return (address === lib$7.AddressZero) ? null : address; }; Formatter.prototype.contractAddress = function (value) { - return address.getContractAddress(value); + return lib$6.getContractAddress(value); }; // Strict! Used on input. Formatter.prototype.blockTag = function (blockTag) { @@ -17435,22 +17441,22 @@ if (blockTag === "latest" || blockTag === "pending") { return blockTag; } - if (typeof (blockTag) === "number" || bytes.isHexString(blockTag)) { - return bytes.hexValue(blockTag); + if (typeof (blockTag) === "number" || lib$1.isHexString(blockTag)) { + return lib$1.hexValue(blockTag); } throw new Error("invalid blockTag"); }; // Requires a hash, optionally requires 0x prefix; returns prefixed lowercase hash. Formatter.prototype.hash = function (value, strict) { var result = this.hex(value, strict); - if (bytes.hexDataLength(result) !== 32) { - return logger$1.throwArgumentError("invalid hash", "value", value); + if (lib$1.hexDataLength(result) !== 32) { + return logger.throwArgumentError("invalid hash", "value", value); } return result; }; // Returns the difficulty as a number, or if too large (i.e. PoA network) null Formatter.prototype.difficulty = function (value) { - var v = bignumber$2.BigNumber.from(value); + var v = lib$2.BigNumber.from(value); try { return v.toNumber(); } @@ -17458,10 +17464,10 @@ return null; }; Formatter.prototype.uint256 = function (value) { - if (!bytes.isHexString(value)) { + if (!lib$1.isHexString(value)) { throw new Error("invalid uint256"); } - return bytes.hexZeroPad(value, 32); + return lib$1.hexZeroPad(value, 32); }; Formatter.prototype._block = function (value, format) { if (value.author != null && value.miner == null) { @@ -17486,7 +17492,7 @@ } // Some clients (TestRPC) do strange things like return 0x0 for the // 0 address; correct this to be a real address - if (transaction.to && bignumber$2.BigNumber.from(transaction.to).isZero()) { + if (transaction.to && lib$2.BigNumber.from(transaction.to).isZero()) { transaction.to = "0x0000000000000000000000000000000000000000"; } // Rename input to data @@ -17525,8 +17531,8 @@ if (transaction.chainId != null && networkId == null && result.v == null) { networkId = transaction.chainId; } - if (bytes.isHexString(networkId)) { - networkId = bignumber$2.BigNumber.from(networkId).toNumber(); + if (lib$1.isHexString(networkId)) { + networkId = lib$2.BigNumber.from(networkId).toNumber(); } if (typeof (networkId) !== "number" && result.v != null) { networkId = (result.v - 35) / 2; @@ -17546,7 +17552,7 @@ return result; }; Formatter.prototype.transaction = function (value) { - return transactions.parse(value); + return lib$g.parse(value); }; Formatter.prototype.receiptLog = function (value) { return Formatter.check(this.formats.receiptLog, value); @@ -17663,7 +17669,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); ////////////////////////////// // Event Serializeing @@ -17671,8 +17677,8 @@ if (topic == null) { return "null"; } - if (bytes.hexDataLength(topic) !== 32) { - logger$1.throwArgumentError("invalid topic", "topic", topic); + if (lib$1.hexDataLength(topic) !== 32) { + logger.throwArgumentError("invalid topic", "topic", topic); } return topic.toLowerCase(); } @@ -17709,7 +17715,7 @@ function getEventTag(eventName) { if (typeof (eventName) === "string") { eventName = eventName.toLowerCase(); - if (bytes.hexDataLength(eventName) === 32) { + if (lib$1.hexDataLength(eventName) === 32) { return "tx:" + eventName; } if (eventName.indexOf(":") === -1) { @@ -17719,8 +17725,8 @@ else if (Array.isArray(eventName)) { return "filter:*:" + serializeTopics(eventName); } - else if (abstractProvider.ForkEvent.isForkEvent(eventName)) { - logger$1.warn("not implemented"); + else if (lib$b.ForkEvent.isForkEvent(eventName)) { + logger.warn("not implemented"); throw new Error("not implemented"); } else if (eventName && typeof (eventName) === "object") { @@ -17746,9 +17752,9 @@ */ var Event = /** @class */ (function () { function Event(tag, listener, once) { - properties.defineReadOnly(this, "tag", tag); - properties.defineReadOnly(this, "listener", listener); - properties.defineReadOnly(this, "once", once); + lib$3.defineReadOnly(this, "tag", tag); + lib$3.defineReadOnly(this, "listener", listener); + lib$3.defineReadOnly(this, "once", once); } Event.prototype.pollable = function () { return (this.tag.indexOf(":") >= 0 || this.tag === "block" || this.tag === "pending"); @@ -17762,25 +17768,25 @@ function BaseProvider(network) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, abstractProvider.Provider); + logger.checkNew(_newTarget, lib$b.Provider); _this = _super.call(this) || this; _this.formatter = _newTarget.getFormatter(); if (network instanceof Promise) { - properties.defineReadOnly(_this, "ready", network.then(function (network) { - properties.defineReadOnly(_this, "_network", network); + lib$3.defineReadOnly(_this, "ready", network.then(function (network) { + lib$3.defineReadOnly(_this, "_network", network); return network; })); // Squash any "unhandled promise" errors; that do not need to be handled _this.ready.catch(function (error) { }); } else { - var knownNetwork = properties.getStatic((_newTarget), "getNetwork")(network); + var knownNetwork = lib$3.getStatic((_newTarget), "getNetwork")(network); if (knownNetwork) { - properties.defineReadOnly(_this, "_network", knownNetwork); - properties.defineReadOnly(_this, "ready", Promise.resolve(_this._network)); + lib$3.defineReadOnly(_this, "_network", knownNetwork); + lib$3.defineReadOnly(_this, "ready", Promise.resolve(_this._network)); } else { - logger$1.throwArgumentError("invalid network", "network", network); + logger.throwArgumentError("invalid network", "network", network); } } _this._lastBlockNumber = -2; @@ -17798,7 +17804,7 @@ return defaultFormatter; }; BaseProvider.getNetwork = function (network) { - return networks_1.getNetwork((network == null) ? "homestead" : network); + return lib$k.getNetwork((network == null) ? "homestead" : network); }; BaseProvider.prototype.poll = function () { var _this = this; @@ -18014,7 +18020,7 @@ Object.keys(params).forEach(function (key) { params[key] = params[key](); }); - return properties.resolveProperties(params).then(function (params) { + return lib$3.resolveProperties(params).then(function (params) { return _this.perform(method, params); }); }); @@ -18032,7 +18038,7 @@ }; BaseProvider.prototype.getGasPrice = function () { return this._runPerform("getGasPrice", {}).then(function (result) { - return bignumber$2.BigNumber.from(result); + return lib$2.BigNumber.from(result); }); }; BaseProvider.prototype.getBalance = function (addressOrName, blockTag) { @@ -18041,7 +18047,7 @@ address: function () { return _this._getAddress(addressOrName); }, blockTag: function () { return _this._getBlockTag(blockTag); } }).then(function (result) { - return bignumber$2.BigNumber.from(result); + return lib$2.BigNumber.from(result); }); }; BaseProvider.prototype.getTransactionCount = function (addressOrName, blockTag) { @@ -18050,7 +18056,7 @@ address: function () { return _this._getAddress(addressOrName); }, blockTag: function () { return _this._getBlockTag(blockTag); } }).then(function (result) { - return bignumber$2.BigNumber.from(result).toNumber(); + return lib$2.BigNumber.from(result).toNumber(); }); }; BaseProvider.prototype.getCode = function (addressOrName, blockTag) { @@ -18059,7 +18065,7 @@ address: function () { return _this._getAddress(addressOrName); }, blockTag: function () { return _this._getBlockTag(blockTag); } }).then(function (result) { - return bytes.hexlify(result); + return lib$1.hexlify(result); }); }; BaseProvider.prototype.getStorageAt = function (addressOrName, position, blockTag) { @@ -18067,21 +18073,21 @@ return this._runPerform("getStorageAt", { address: function () { return _this._getAddress(addressOrName); }, blockTag: function () { return _this._getBlockTag(blockTag); }, - position: function () { return Promise.resolve(position).then(function (p) { return bytes.hexValue(p); }); } + position: function () { return Promise.resolve(position).then(function (p) { return lib$1.hexValue(p); }); } }).then(function (result) { - return bytes.hexlify(result); + return lib$1.hexlify(result); }); }; // This should be called by any subclass wrapping a TransactionResponse BaseProvider.prototype._wrapTransaction = function (tx, hash) { var _this = this; - if (hash != null && bytes.hexDataLength(hash) !== 32) { + if (hash != null && lib$1.hexDataLength(hash) !== 32) { throw new Error("invalid response - sendTransaction"); } var result = tx; // Check the hash we expect is the same as the hash the server reported if (hash != null && tx.hash !== hash) { - logger$1.throwError("Transaction hash mismatch from Provider.sendTransaction.", logger.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); + logger.throwError("Transaction hash mismatch from Provider.sendTransaction.", lib.Logger.errors.UNKNOWN_ERROR, { expectedHash: tx.hash, returnedHash: hash }); } // @TODO: (confirmations? number, timeout? number) result.wait = function (confirmations) { @@ -18098,7 +18104,7 @@ // No longer pending, allow the polling loop to garbage collect this _this._emitted["t:" + tx.hash] = receipt.blockNumber; if (receipt.status === 0) { - logger$1.throwError("transaction failed", logger.Logger.errors.CALL_EXCEPTION, { + logger.throwError("transaction failed", lib.Logger.errors.CALL_EXCEPTION, { transactionHash: tx.hash, transaction: tx, receipt: receipt @@ -18112,7 +18118,7 @@ BaseProvider.prototype.sendTransaction = function (signedTransaction) { var _this = this; return this._runPerform("sendTransaction", { - signedTransaction: function () { return Promise.resolve(signedTransaction).then(function (t) { return bytes.hexlify(t); }); } + signedTransaction: function () { return Promise.resolve(signedTransaction).then(function (t) { return lib$1.hexlify(t); }); } }).then(function (result) { return _this._wrapTransaction(_this.formatter.transaction(signedTransaction), result); }, function (error) { @@ -18139,7 +18145,7 @@ } tx[key] = t[key]; }); - return properties.resolveProperties(tx).then(function (t) { return _this.formatter.transactionRequest(t); }); + return lib$3.resolveProperties(tx).then(function (t) { return _this.formatter.transactionRequest(t); }); }); }; BaseProvider.prototype._getFilter = function (filter) { @@ -18161,7 +18167,7 @@ } filter[key] = _this._getBlockTag(f[key]); }); - return properties.resolveProperties(filter).then(function (f) { return _this.formatter.filter(f); }); + return lib$3.resolveProperties(filter).then(function (f) { return _this.formatter.filter(f); }); }); }; BaseProvider.prototype.call = function (transaction, blockTag) { @@ -18170,7 +18176,7 @@ transaction: function () { return _this._getTransactionRequest(transaction); }, blockTag: function () { return _this._getBlockTag(blockTag); } }).then(function (result) { - return bytes.hexlify(result); + return lib$1.hexlify(result); }); }; BaseProvider.prototype.estimateGas = function (transaction) { @@ -18178,13 +18184,13 @@ return this._runPerform("estimateGas", { transaction: function () { return _this._getTransactionRequest(transaction); } }).then(function (result) { - return bignumber$2.BigNumber.from(result); + return lib$2.BigNumber.from(result); }); }; BaseProvider.prototype._getAddress = function (addressOrName) { return this.resolveName(addressOrName).then(function (address) { if (address == null) { - logger$1.throwError("ENS name not configured", logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("ENS name not configured", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "resolveName(" + JSON.stringify(addressOrName) + ")" }); } @@ -18203,21 +18209,21 @@ var blockTag = null; // If blockTag is a number (not "latest", etc), this is the block number var blockNumber = -128; - if (bytes.isHexString(blockHashOrBlockTag, 32)) { + if (lib$1.isHexString(blockHashOrBlockTag, 32)) { params.blockHash = blockHashOrBlockTag; } else { try { params.blockTag = _this.formatter.blockTag(blockHashOrBlockTag); - if (bytes.isHexString(params.blockTag)) { + if (lib$1.isHexString(params.blockTag)) { blockNumber = parseInt(params.blockTag.substring(2), 16); } } catch (error) { - logger$1.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); + logger.throwArgumentError("invalid block hash or block tag", "blockHashOrBlockTag", blockHashOrBlockTag); } } - return web.poll(function () { + return lib$l.poll(function () { return _this.perform("getBlock", params).then(function (block) { // Block was not found if (block == null) { @@ -18257,10 +18263,10 @@ BaseProvider.prototype.getTransaction = function (transactionHash) { var _this = this; return this.ready.then(function () { - return properties.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { + return lib$3.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { var transactionHash = _a.transactionHash; var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; - return web.poll(function () { + return lib$l.poll(function () { return _this.perform("getTransaction", params).then(function (result) { if (result == null) { if (_this._emitted["t:" + transactionHash] == null) { @@ -18292,10 +18298,10 @@ BaseProvider.prototype.getTransactionReceipt = function (transactionHash) { var _this = this; return this.ready.then(function () { - return properties.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { + return lib$3.resolveProperties({ transactionHash: transactionHash }).then(function (_a) { var transactionHash = _a.transactionHash; var params = { transactionHash: _this.formatter.hash(transactionHash, true) }; - return web.poll(function () { + return lib$l.poll(function () { return _this.perform("getTransactionReceipt", params).then(function (result) { if (result == null) { if (_this._emitted["t:" + transactionHash] == null) { @@ -18348,7 +18354,7 @@ } if (typeof (blockTag) === "number" && blockTag < 0) { if (blockTag % 1) { - logger$1.throwArgumentError("invalid BlockTag", "blockTag", blockTag); + logger.throwArgumentError("invalid BlockTag", "blockTag", blockTag); } return this._getFastBlockNumber().then(function (bn) { bn += blockTag; @@ -18366,10 +18372,10 @@ return this.getNetwork().then(function (network) { // No ENS... if (!network.ensAddress) { - logger$1.throwError("network does support ENS", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); + logger.throwError("network does support ENS", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name }); } // keccak256("resolver(bytes32)") - var data = "0x0178b8bf" + hash.namehash(name).substring(2); + var data = "0x0178b8bf" + lib$9.namehash(name).substring(2); var transaction = { to: network.ensAddress, data: data }; return _this.call(transaction).then(function (data) { return _this.formatter.callAddress(data); @@ -18393,7 +18399,7 @@ return null; } // keccak256("addr(bytes32)") - var data = "0x3b3b57de" + hash.namehash(name).substring(2); + var data = "0x3b3b57de" + lib$9.namehash(name).substring(2); var transaction = { to: resolverAddress, data: data }; return _this.call(transaction).then(function (data) { return _this.formatter.callAddress(data); @@ -18412,23 +18418,23 @@ return null; } // keccak("name(bytes32)") - var data = "0x691f3431" + hash.namehash(name).substring(2); + var data = "0x691f3431" + lib$9.namehash(name).substring(2); return _this.call({ to: resolverAddress, data: data }).then(function (data) { - var bytes$1 = bytes.arrayify(data); + var bytes = lib$1.arrayify(data); // Strip off the dynamic string pointer (0x20) - if (bytes$1.length < 32 || !bignumber$2.BigNumber.from(bytes$1.slice(0, 32)).eq(32)) { + if (bytes.length < 32 || !lib$2.BigNumber.from(bytes.slice(0, 32)).eq(32)) { return null; } - bytes$1 = bytes$1.slice(32); - if (bytes$1.length < 32) { + bytes = bytes.slice(32); + if (bytes.length < 32) { return null; } - var length = bignumber$2.BigNumber.from(bytes$1.slice(0, 32)).toNumber(); - bytes$1 = bytes$1.slice(32); - if (length > bytes$1.length) { + var length = lib$2.BigNumber.from(bytes.slice(0, 32)).toNumber(); + bytes = bytes.slice(32); + if (length > bytes.length) { return null; } - var name = strings.toUtf8String(bytes$1.slice(0, length)); + var name = lib$8.toUtf8String(bytes.slice(0, length)); // Make sure the reverse record matches the foward record return _this.resolveName(name).then(function (addr) { if (addr != address) { @@ -18440,7 +18446,7 @@ }); }; BaseProvider.prototype.perform = function (method, params) { - return logger$1.throwError(method + " not implemented", logger.Logger.errors.NOT_IMPLEMENTED, { operation: method }); + return logger.throwError(method + " not implemented", lib.Logger.errors.NOT_IMPLEMENTED, { operation: method }); }; BaseProvider.prototype._startPending = function () { console.log("WARNING: this provider does not support pending events"); @@ -18548,7 +18554,7 @@ return this; }; return BaseProvider; - }(abstractProvider.Provider)); + }(lib$b.Provider)); exports.BaseProvider = BaseProvider; }); @@ -18580,7 +18586,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); function timer(timeout) { return new Promise(function (resolve) { @@ -18611,30 +18617,30 @@ function JsonRpcSigner(constructorGuard, provider, addressOrIndex) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, JsonRpcSigner); + logger.checkNew(_newTarget, JsonRpcSigner); _this = _super.call(this) || this; if (constructorGuard !== _constructorGuard) { throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner"); } - properties.defineReadOnly(_this, "provider", provider); + lib$3.defineReadOnly(_this, "provider", provider); if (addressOrIndex == null) { addressOrIndex = 0; } if (typeof (addressOrIndex) === "string") { - properties.defineReadOnly(_this, "_address", _this.provider.formatter.address(addressOrIndex)); - properties.defineReadOnly(_this, "_index", null); + lib$3.defineReadOnly(_this, "_address", _this.provider.formatter.address(addressOrIndex)); + lib$3.defineReadOnly(_this, "_index", null); } else if (typeof (addressOrIndex) === "number") { - properties.defineReadOnly(_this, "_index", addressOrIndex); - properties.defineReadOnly(_this, "_address", null); + lib$3.defineReadOnly(_this, "_index", addressOrIndex); + lib$3.defineReadOnly(_this, "_address", null); } else { - logger$1.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); + logger.throwArgumentError("invalid address or index", "addressOrIndex", addressOrIndex); } return _this; } JsonRpcSigner.prototype.connect = function (provider) { - return logger$1.throwError("cannot alter JSON-RPC Signer connection", logger.Logger.errors.UNSUPPORTED_OPERATION, { + return logger.throwError("cannot alter JSON-RPC Signer connection", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "connect" }); }; @@ -18648,7 +18654,7 @@ } return this.provider.send("eth_accounts", []).then(function (accounts) { if (accounts.length <= _this._index) { - logger$1.throwError("unknown account #" + _this._index, logger.Logger.errors.UNSUPPORTED_OPERATION, { + logger.throwError("unknown account #" + _this._index, lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getAddress" }); } @@ -18657,7 +18663,7 @@ }; JsonRpcSigner.prototype.sendUncheckedTransaction = function (transaction) { var _this = this; - transaction = properties.shallowCopy(transaction); + transaction = lib$3.shallowCopy(transaction); var fromAddress = this.getAddress().then(function (address) { if (address) { address = address.toLowerCase(); @@ -18668,12 +18674,12 @@ // wishes to use this, it is easy to specify explicitly, otherwise // we look it up for them. if (transaction.gasLimit == null) { - var estimate = properties.shallowCopy(transaction); + var estimate = lib$3.shallowCopy(transaction); estimate.from = fromAddress; transaction.gasLimit = this.provider.estimateGas(estimate); } return Promise.all([ - properties.resolveProperties(transaction), + lib$3.resolveProperties(transaction), fromAddress ]).then(function (results) { var tx = results[0]; @@ -18685,17 +18691,17 @@ if (error.responseText) { // See: JsonRpcProvider.sendTransaction (@TODO: Expose a ._throwError??) if (error.responseText.indexOf("insufficient funds") >= 0) { - logger$1.throwError("insufficient funds", logger.Logger.errors.INSUFFICIENT_FUNDS, { + logger.throwError("insufficient funds", lib.Logger.errors.INSUFFICIENT_FUNDS, { transaction: tx }); } if (error.responseText.indexOf("nonce too low") >= 0) { - logger$1.throwError("nonce has already been used", logger.Logger.errors.NONCE_EXPIRED, { + logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, { transaction: tx }); } if (error.responseText.indexOf("replacement transaction underpriced") >= 0) { - logger$1.throwError("replacement fee too low", logger.Logger.errors.REPLACEMENT_UNDERPRICED, { + logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, { transaction: tx }); } @@ -18705,14 +18711,14 @@ }); }; JsonRpcSigner.prototype.signTransaction = function (transaction) { - return logger$1.throwError("signing transactions is unsupported", logger.Logger.errors.UNSUPPORTED_OPERATION, { + return logger.throwError("signing transactions is unsupported", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "signTransaction" }); }; JsonRpcSigner.prototype.sendTransaction = function (transaction) { var _this = this; return this.sendUncheckedTransaction(transaction).then(function (hash) { - return web.poll(function () { + return lib$l.poll(function () { return _this.provider.getTransaction(hash).then(function (tx) { if (tx === null) { return undefined; @@ -18727,10 +18733,10 @@ }; JsonRpcSigner.prototype.signMessage = function (message) { var _this = this; - var data = ((typeof (message) === "string") ? strings.toUtf8Bytes(message) : message); + var data = ((typeof (message) === "string") ? lib$8.toUtf8Bytes(message) : message); return this.getAddress().then(function (address) { // https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign - return _this.provider.send("eth_sign", [address.toLowerCase(), bytes.hexlify(data)]); + return _this.provider.send("eth_sign", [address.toLowerCase(), lib$1.hexlify(data)]); }); }; JsonRpcSigner.prototype.unlock = function (password) { @@ -18740,7 +18746,7 @@ }); }; return JsonRpcSigner; - }(abstractSigner.Signer)); + }(lib$c.Signer)); exports.JsonRpcSigner = JsonRpcSigner; var UncheckedJsonRpcSigner = /** @class */ (function (_super) { __extends(UncheckedJsonRpcSigner, _super); @@ -18774,10 +18780,10 @@ function JsonRpcProvider(url, network) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, JsonRpcProvider); + logger.checkNew(_newTarget, JsonRpcProvider); // One parameter, but it is a network name, so swap it with the URL if (typeof (url) === "string") { - if (network === null && networks_1.getNetwork(url)) { + if (network === null && lib$k.getNetwork(url)) { network = url; url = null; } @@ -18791,12 +18797,12 @@ var ready = new Promise(function (resolve, reject) { setTimeout(function () { _this.send("eth_chainId", []).then(function (result) { - resolve(networks_1.getNetwork(bignumber$2.BigNumber.from(result).toNumber())); + resolve(lib$k.getNetwork(lib$2.BigNumber.from(result).toNumber())); }).catch(function (error) { _this.send("net_version", []).then(function (result) { - resolve(networks_1.getNetwork(bignumber$2.BigNumber.from(result).toNumber())); + resolve(lib$k.getNetwork(lib$2.BigNumber.from(result).toNumber())); }).catch(function (error) { - reject(logger$1.makeError("could not detect network", logger.Logger.errors.NETWORK_ERROR)); + reject(logger.makeError("could not detect network", lib.Logger.errors.NETWORK_ERROR)); }); }); }); @@ -18840,10 +18846,10 @@ }; this.emit("debug", { action: "request", - request: properties.deepCopy(request), + request: lib$3.deepCopy(request), provider: this }); - return web.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) { + return lib$l.fetchJson(this.connection, JSON.stringify(request), getResult).then(function (result) { _this.emit("debug", { action: "response", request: request, @@ -18872,15 +18878,15 @@ if (error.responseText) { // "insufficient funds for gas * price + value" if (error.responseText.indexOf("insufficient funds") > 0) { - logger$1.throwError("insufficient funds", logger.Logger.errors.INSUFFICIENT_FUNDS, {}); + logger.throwError("insufficient funds", lib.Logger.errors.INSUFFICIENT_FUNDS, {}); } // "nonce too low" if (error.responseText.indexOf("nonce too low") > 0) { - logger$1.throwError("nonce has already been used", logger.Logger.errors.NONCE_EXPIRED, {}); + logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {}); } // "replacement transaction underpriced" if (error.responseText.indexOf("replacement transaction underpriced") > 0) { - logger$1.throwError("replacement fee too low", logger.Logger.errors.REPLACEMENT_UNDERPRICED, {}); + logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {}); } } throw error; @@ -18892,7 +18898,7 @@ else if (params.blockHash) { return this.send("eth_getBlockByHash", [params.blockHash, !!params.includeTransactions]); } - return logger$1.throwArgumentError("invalid block tag or block hash", "params", params); + return logger.throwArgumentError("invalid block tag or block hash", "params", params); case "getTransaction": return this.send("eth_getTransactionByHash", [params.transactionHash]); case "getTransactionReceipt": @@ -18909,7 +18915,7 @@ default: break; } - return logger$1.throwError(method + " not implemented", logger.Logger.errors.NOT_IMPLEMENTED, { operation: method }); + return logger.throwError(method + " not implemented", lib.Logger.errors.NOT_IMPLEMENTED, { operation: method }); }; JsonRpcProvider.prototype._startPending = function () { if (this._pendingFilter != null) { @@ -18962,7 +18968,7 @@ // before this is called JsonRpcProvider.hexlifyTransaction = function (transaction, allowExtra) { // Check only allowed properties are given - var allowed = properties.shallowCopy(allowedTransactionKeys); + var allowed = lib$3.shallowCopy(allowedTransactionKeys); if (allowExtra) { for (var key in allowExtra) { if (allowExtra[key]) { @@ -18970,14 +18976,14 @@ } } } - properties.checkProperties(transaction, allowed); + lib$3.checkProperties(transaction, allowed); var result = {}; // Some nodes (INFURA ropsten; INFURA mainnet is fine) do not like leading zeros. ["gasLimit", "gasPrice", "nonce", "value"].forEach(function (key) { if (transaction[key] == null) { return; } - var value = bytes.hexValue(transaction[key]); + var value = lib$1.hexValue(transaction[key]); if (key === "gasLimit") { key = "gas"; } @@ -18987,7 +18993,7 @@ if (transaction[key] == null) { return; } - result[key] = bytes.hexlify(transaction[key]); + result[key] = lib$1.hexlify(transaction[key]); }); return result; }; @@ -19020,34 +19026,34 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); var UrlJsonRpcProvider = /** @class */ (function (_super) { __extends(UrlJsonRpcProvider, _super); function UrlJsonRpcProvider(network, apiKey) { var _newTarget = this.constructor; var _this = this; - logger$1.checkAbstract(_newTarget, UrlJsonRpcProvider); + logger.checkAbstract(_newTarget, UrlJsonRpcProvider); // Normalize the Network and API Key - network = properties.getStatic((_newTarget), "getNetwork")(network); - apiKey = properties.getStatic((_newTarget), "getApiKey")(apiKey); - var url = properties.getStatic((_newTarget), "getUrl")(network, apiKey); + network = lib$3.getStatic((_newTarget), "getNetwork")(network); + apiKey = lib$3.getStatic((_newTarget), "getApiKey")(apiKey); + var url = lib$3.getStatic((_newTarget), "getUrl")(network, apiKey); _this = _super.call(this, url, network) || this; - properties.defineReadOnly(_this, "apiKey", apiKey); + lib$3.defineReadOnly(_this, "apiKey", apiKey); return _this; } UrlJsonRpcProvider.prototype._startPending = function () { - logger$1.warn("WARNING: API provider does not support pending filters"); + logger.warn("WARNING: API provider does not support pending filters"); }; UrlJsonRpcProvider.prototype.getSigner = function (address) { - logger$1.throwError("API provider does not support signing", logger.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); + logger.throwError("API provider does not support signing", lib.Logger.errors.UNSUPPORTED_OPERATION, { operation: "getSigner" }); return null; }; UrlJsonRpcProvider.prototype.listAccounts = function () { return Promise.resolve([]); }; UrlJsonRpcProvider.getNetwork = function (network) { - return networks_1.getNetwork((network == null) ? "homestead" : network); + return lib$k.getNetwork((network == null) ? "homestead" : network); }; // Return a defaultApiKey if null, otherwise validate the API key UrlJsonRpcProvider.getApiKey = function (apiKey) { @@ -19055,7 +19061,7 @@ }; // Returns the url for the given network and API key UrlJsonRpcProvider.getUrl = function (network, apiKey) { - return logger$1.throwError("not implemented; sub-classes must override getUrl", logger.Logger.errors.NOT_IMPLEMENTED, { + return logger.throwError("not implemented; sub-classes must override getUrl", lib.Logger.errors.NOT_IMPLEMENTED, { operation: "getUrl" }); }; @@ -19085,7 +19091,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); // This key was provided to ethers.js by Alchemy to be used by the // default provider, but it is recommended that for your own @@ -19119,7 +19125,7 @@ host = "eth-kovan.alchemyapi.io/jsonrpc/"; break; default: - logger$1.throwArgumentError("unsupported network", "network", arguments[0]); + logger.throwArgumentError("unsupported network", "network", arguments[0]); } return ("https:/" + "/" + host + apiKey); }; @@ -19150,7 +19156,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); var CloudflareProvider = /** @class */ (function (_super) { __extends(CloudflareProvider, _super); function CloudflareProvider() { @@ -19158,7 +19164,7 @@ } CloudflareProvider.getUrl = function (network, apiKey) { if (apiKey != null) { - logger$1.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); + logger.throwArgumentError("apiKey not supported for cloudflare", "apiKey", apiKey); } var host = null; switch (network.name) { @@ -19166,7 +19172,7 @@ host = "https://cloudflare-eth.com/"; break; default: - logger$1.throwArgumentError("unsupported network", "network", arguments[0]); + logger.throwArgumentError("unsupported network", "network", arguments[0]); } return host; }; @@ -19199,7 +19205,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); // The transaction has already been sanitized by the calls in Provider function getTransactionString(transaction) { @@ -19208,9 +19214,9 @@ if (transaction[key] == null) { continue; } - var value = bytes.hexlify(transaction[key]); + var value = lib$1.hexlify(transaction[key]); if ({ gasLimit: true, gasPrice: true, nonce: true, value: true }[key]) { - value = bytes.hexValue(value); + value = lib$1.hexValue(value); } result.push(key + "=" + value); } @@ -19264,7 +19270,7 @@ function EtherscanProvider(network, apiKey) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, EtherscanProvider); + logger.checkNew(_newTarget, EtherscanProvider); _this = _super.call(this, network) || this; var name = "invalid"; if (_this.network) { @@ -19290,8 +19296,8 @@ default: throw new Error("unsupported network"); } - properties.defineReadOnly(_this, "baseUrl", baseUrl); - properties.defineReadOnly(_this, "apiKey", apiKey); + lib$3.defineReadOnly(_this, "baseUrl", baseUrl); + lib$3.defineReadOnly(_this, "apiKey", apiKey); return _this; } EtherscanProvider.prototype.perform = function (method, params) { @@ -19307,11 +19313,11 @@ request: url, provider: _this }); - return web.fetchJson(url, null, procFunc || getJsonResult).then(function (result) { + return lib$l.fetchJson(url, null, procFunc || getJsonResult).then(function (result) { _this.emit("debug", { action: "response", request: url, - response: properties.deepCopy(result), + response: lib$3.deepCopy(result), provider: _this }); return result; @@ -19349,15 +19355,15 @@ if (error.responseText) { // "Insufficient funds. The account you tried to send transaction from does not have enough funds. Required 21464000000000 and got: 0" if (error.responseText.toLowerCase().indexOf("insufficient funds") >= 0) { - logger$1.throwError("insufficient funds", logger.Logger.errors.INSUFFICIENT_FUNDS, {}); + logger.throwError("insufficient funds", lib.Logger.errors.INSUFFICIENT_FUNDS, {}); } // "Transaction with the same hash was already imported." if (error.responseText.indexOf("same hash was already imported") >= 0) { - logger$1.throwError("nonce has already been used", logger.Logger.errors.NONCE_EXPIRED, {}); + logger.throwError("nonce has already been used", lib.Logger.errors.NONCE_EXPIRED, {}); } // "Transaction gas price is too low. There is another transaction with same nonce in the queue. Try increasing the gas price or incrementing the nonce." if (error.responseText.indexOf("another transaction with same nonce") >= 0) { - logger$1.throwError("replacement fee too low", logger.Logger.errors.REPLACEMENT_UNDERPRICED, {}); + logger.throwError("replacement fee too low", lib.Logger.errors.REPLACEMENT_UNDERPRICED, {}); } } throw error; @@ -19495,11 +19501,11 @@ request: url, provider: _this }); - return web.fetchJson(url, null, getResult).then(function (result) { + return lib$l.fetchJson(url, null, getResult).then(function (result) { _this.emit("debug", { action: "response", request: url, - response: properties.deepCopy(result), + response: lib$3.deepCopy(result), provider: _this }); var output = []; @@ -19550,7 +19556,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); function now() { return (new Date()).getTime(); } // Returns: @@ -19578,7 +19584,7 @@ (check.ensAddress == null && network.ensAddress == null))) { return; } - logger$1.throwArgumentError("provider mismatch", "networks", networks); + logger.throwArgumentError("provider mismatch", "networks", networks); }); return result; } @@ -19611,12 +19617,12 @@ function FallbackProvider(providers, quorum, weights) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, FallbackProvider); + logger.checkNew(_newTarget, FallbackProvider); if (providers.length === 0) { - logger$1.throwArgumentError("missing providers", "providers", providers); + logger.throwArgumentError("missing providers", "providers", providers); } if (weights != null && weights.length !== providers.length) { - logger$1.throwArgumentError("too many weights", "weights", weights); + logger.throwArgumentError("too many weights", "weights", weights); } else if (!weights) { weights = providers.map(function (p) { return 1; }); @@ -19624,7 +19630,7 @@ else { weights.forEach(function (w) { if (w % 1 || w > 512 || w < 1) { - logger$1.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); + logger.throwArgumentError("invalid weight; must be integer in [1, 512]", "weights", weights); } }); } @@ -19634,7 +19640,7 @@ } else { if (quorum > total) { - logger$1.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); + logger.throwArgumentError("quorum will always fail; larger than total weight", "quorum", quorum); } } // All networks are ready, we can know the network for certain @@ -19646,16 +19652,16 @@ // The network won't be known until all child providers know var ready_1 = Promise.all(providers.map(function (p) { return p.getNetwork(); })).then(function (networks) { if (!checkNetworks(networks)) { - logger$1.throwError("getNetwork returned null", logger.Logger.errors.UNKNOWN_ERROR); + logger.throwError("getNetwork returned null", lib.Logger.errors.UNKNOWN_ERROR); } return networks[0]; }); _this = _super.call(this, ready_1) || this; } // Preserve a copy, so we do not get mutated - properties.defineReadOnly(_this, "providers", Object.freeze(providers.slice())); - properties.defineReadOnly(_this, "quorum", quorum); - properties.defineReadOnly(_this, "weights", Object.freeze(weights.slice())); + lib$3.defineReadOnly(_this, "providers", Object.freeze(providers.slice())); + lib$3.defineReadOnly(_this, "quorum", quorum); + lib$3.defineReadOnly(_this, "weights", Object.freeze(weights.slice())); return _this; } FallbackProvider.doPerform = function (provider, method, params) { @@ -19685,7 +19691,7 @@ case "getLogs": return provider.getLogs(params.filter); } - return logger$1.throwError("unknown method error", logger.Logger.errors.UNKNOWN_ERROR, { + return logger.throwError("unknown method error", lib.Logger.errors.UNKNOWN_ERROR, { method: method, params: params }); @@ -19704,7 +19710,7 @@ action: "request", rid: rid, backend: { weight: weight, start: start, provider: provider }, - request: { method: method, params: properties.deepCopy(params) }, + request: { method: method, params: lib$3.deepCopy(params) }, provider: _this }); return FallbackProvider.doPerform(provider, method, params).then(function (result) { @@ -19713,8 +19719,8 @@ action: "response", rid: rid, backend: { weight: weight, start: start, duration: duration, provider: provider }, - request: { method: method, params: properties.deepCopy(params) }, - response: properties.deepCopy(result) + request: { method: method, params: lib$3.deepCopy(params) }, + response: lib$3.deepCopy(result) }); return { weight: weight, result: result }; }, function (error) { @@ -19723,7 +19729,7 @@ action: "response", rid: rid, backend: { weight: weight, start: start, duration: duration, provider: provider }, - request: { method: method, params: properties.deepCopy(params) }, + request: { method: method, params: lib$3.deepCopy(params) }, error: error }); return { weight: weight, error: error }; @@ -19818,7 +19824,7 @@ return; } if (firstError === null) { - firstError = logger$1.makeError("failed to meet quorum", logger.Logger.errors.SERVER_ERROR, { + firstError = logger.makeError("failed to meet quorum", lib.Logger.errors.SERVER_ERROR, { results: Object.keys(results).map(function (u) { return { method: method, @@ -19854,11 +19860,91 @@ var fallbackProvider_1 = fallbackProvider.FallbackProvider; "use strict"; - var IpcProvider = null; + var browserNet = {}; - var browserIpcProvider = { - IpcProvider: IpcProvider + var ipcProvider = createCommonjsModule(function (module, exports) { + "use strict"; + var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; + })(); + var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; }; + Object.defineProperty(exports, "__esModule", { value: true }); + var net_1 = __importDefault(browserNet); + + + + var logger = new lib.Logger(_version$G.version); + + var IpcProvider = /** @class */ (function (_super) { + __extends(IpcProvider, _super); + function IpcProvider(path, network) { + var _newTarget = this.constructor; + var _this = this; + logger.checkNew(_newTarget, IpcProvider); + if (path == null) { + logger.throwError("missing path", lib.Logger.errors.MISSING_ARGUMENT, { arg: "path" }); + } + _this = _super.call(this, "ipc://" + path, network) || this; + lib$3.defineReadOnly(_this, "path", path); + return _this; + } + // @TODO: Create a connection to the IPC path and use filters instead of polling for block + IpcProvider.prototype.send = function (method, params) { + // This method is very simple right now. We create a new socket + // connection each time, which may be slower, but the main + // advantage we are aiming for now is security. This simplifies + // multiplexing requests (since we do not need to multiplex). + var _this = this; + var payload = JSON.stringify({ + method: method, + params: params, + id: 42, + jsonrpc: "2.0" + }); + return new Promise(function (resolve, reject) { + var response = Buffer.alloc(0); + var stream = net_1.default.connect(_this.path); + stream.on("data", function (data) { + response = Buffer.concat([response, data]); + }); + stream.on("end", function () { + try { + resolve(JSON.parse(response.toString()).result); + // @TODO: Better pull apart the error + stream.destroy(); + } + catch (error) { + reject(error); + stream.destroy(); + } + }); + stream.on("error", function (error) { + reject(error); + stream.destroy(); + }); + stream.write(payload); + stream.end(); + }); + }; + return IpcProvider; + }(jsonRpcProvider.JsonRpcProvider)); + exports.IpcProvider = IpcProvider; + }); + + var ipcProvider$1 = unwrapExports(ipcProvider); + var ipcProvider_1 = ipcProvider.IpcProvider; var infuraProvider = createCommonjsModule(function (module, exports) { "use strict"; @@ -19878,7 +19964,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); var defaultProjectId = "84842078b09946638c03157f83405213"; var InfuraProvider = /** @class */ (function (_super) { @@ -19916,7 +20002,7 @@ host = "goerli.infura.io"; break; default: - logger$1.throwError("unsupported network", logger.Logger.errors.INVALID_ARGUMENT, { + logger.throwError("unsupported network", lib.Logger.errors.INVALID_ARGUMENT, { argument: "network", value: network }); @@ -19950,7 +20036,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); // Special API key provided by Nodesmith for ethers.js var defaultApiKey = "ETHERS_JS_SHARED"; var NodesmithProvider = /** @class */ (function (_super) { @@ -19980,7 +20066,7 @@ host = "https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc"; break; default: - logger$1.throwArgumentError("unsupported network", "network", arguments[0]); + logger.throwArgumentError("unsupported network", "network", arguments[0]); } return (host + "?apiKey=" + apiKey); }; @@ -20011,7 +20097,7 @@ - var logger$1 = new logger.Logger(_version$G.version); + var logger = new lib.Logger(_version$G.version); /* @TODO @@ -20025,7 +20111,7 @@ function Web3Provider(web3Provider, network) { var _newTarget = this.constructor; var _this = this; - logger$1.checkNew(_newTarget, Web3Provider); + logger.checkNew(_newTarget, Web3Provider); // HTTP has a host; IPC has a path. _this = _super.call(this, web3Provider.host || web3Provider.path || "", network) || this; if (web3Provider) { @@ -20037,9 +20123,9 @@ } } if (!web3Provider || !_this._sendAsync) { - logger$1.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); + logger.throwArgumentError("invalid web3Provider", "web3Provider", web3Provider); } - properties.defineReadOnly(_this, "_web3Provider", web3Provider); + lib$3.defineReadOnly(_this, "_web3Provider", web3Provider); return _this; } Web3Provider.prototype.send = function (method, params) { @@ -20082,13 +20168,13 @@ var web3Provider$1 = unwrapExports(web3Provider); var web3Provider_1 = web3Provider.Web3Provider; - var providers = createCommonjsModule(function (module, exports) { + var lib$m = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.Provider = abstractProvider.Provider; + exports.Provider = lib$b.Provider; - exports.getNetwork = networks_1.getNetwork; + exports.getNetwork = lib$k.getNetwork; exports.BaseProvider = baseProvider.BaseProvider; @@ -20100,7 +20186,7 @@ exports.FallbackProvider = fallbackProvider.FallbackProvider; - exports.IpcProvider = browserIpcProvider.IpcProvider; + exports.IpcProvider = ipcProvider.IpcProvider; exports.InfuraProvider = infuraProvider.InfuraProvider; @@ -20114,23 +20200,23 @@ exports.Formatter = formatter.Formatter; }); - var index$m = unwrapExports(providers); - var providers_1 = providers.Provider; - var providers_2 = providers.getNetwork; - var providers_3 = providers.BaseProvider; - var providers_4 = providers.AlchemyProvider; - var providers_5 = providers.CloudflareProvider; - var providers_6 = providers.EtherscanProvider; - var providers_7 = providers.FallbackProvider; - var providers_8 = providers.IpcProvider; - var providers_9 = providers.InfuraProvider; - var providers_10 = providers.JsonRpcProvider; - var providers_11 = providers.JsonRpcSigner; - var providers_12 = providers.NodesmithProvider; - var providers_13 = providers.Web3Provider; - var providers_14 = providers.Formatter; + var index$m = unwrapExports(lib$m); + var lib_1$m = lib$m.Provider; + var lib_2$j = lib$m.getNetwork; + var lib_3$e = lib$m.BaseProvider; + var lib_4$c = lib$m.AlchemyProvider; + var lib_5$a = lib$m.CloudflareProvider; + var lib_6$7 = lib$m.EtherscanProvider; + var lib_7$6 = lib$m.FallbackProvider; + var lib_8$4 = lib$m.IpcProvider; + var lib_9$3 = lib$m.InfuraProvider; + var lib_10$2 = lib$m.JsonRpcProvider; + var lib_11$1 = lib$m.JsonRpcSigner; + var lib_12$1 = lib$m.NodesmithProvider; + var lib_13$1 = lib$m.Web3Provider; + var lib_14$1 = lib$m.Formatter; - var solidity = createCommonjsModule(function (module, exports) { + var lib$n = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -20146,19 +20232,19 @@ switch (type) { case "address": if (isArray) { - return bytes.zeroPad(value, 32); + return lib$1.zeroPad(value, 32); } - return bytes.arrayify(value); + return lib$1.arrayify(value); case "string": - return strings.toUtf8Bytes(value); + return lib$8.toUtf8Bytes(value); case "bytes": - return bytes.arrayify(value); + return lib$1.arrayify(value); case "bool": value = (value ? "0x01" : "0x00"); if (isArray) { - return bytes.zeroPad(value, 32); + return lib$1.zeroPad(value, 32); } - return bytes.arrayify(value); + return lib$1.arrayify(value); } var match = type.match(regexNumber); if (match) { @@ -20170,8 +20256,8 @@ if (isArray) { size = 256; } - value = bignumber$2.BigNumber.from(value).toTwos(size); - return bytes.zeroPad(value, size / 8); + value = lib$2.BigNumber.from(value).toTwos(size); + return lib$1.zeroPad(value, size / 8); } match = type.match(regexBytes); if (match) { @@ -20179,11 +20265,11 @@ if (String(size) != match[1] || size === 0 || size > 32) { throw new Error("invalid number type - " + type); } - if (bytes.arrayify(value).byteLength !== size) { + if (lib$1.arrayify(value).byteLength !== size) { throw new Error("invalid value for " + type); } if (isArray) { - return bytes.arrayify((value + Zeros).substring(0, 66)); + return lib$1.arrayify((value + Zeros).substring(0, 66)); } return value; } @@ -20198,7 +20284,7 @@ value.forEach(function (value) { result_1.push(_pack(baseType_1, value, true)); }); - return bytes.concat(result_1); + return lib$1.concat(result_1); } throw new Error("unknown type - " + type); } @@ -20211,11 +20297,11 @@ types.forEach(function (type, index) { tight.push(_pack(type, values[index])); }); - return bytes.hexlify(bytes.concat(tight)); + return lib$1.hexlify(lib$1.concat(tight)); } exports.pack = pack; function keccak256(types, values) { - return keccak256_1.keccak256(pack(types, values)); + return lib$4.keccak256(pack(types, values)); } exports.keccak256 = keccak256; function sha256(types, values) { @@ -20224,27 +20310,27 @@ exports.sha256 = sha256; }); - var index$n = unwrapExports(solidity); - var solidity_1 = solidity.pack; - var solidity_2 = solidity.keccak256; - var solidity_3 = solidity.sha256; + var index$n = unwrapExports(lib$n); + var lib_1$n = lib$n.pack; + var lib_2$k = lib$n.keccak256; + var lib_3$f = lib$n.sha256; var _version$I = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "units/5.0.0-beta.127"; + exports.version = "units/5.0.0-beta.126"; }); var _version$J = unwrapExports(_version$I); var _version_1$m = _version$I.version; - var units = createCommonjsModule(function (module, exports) { + var lib$o = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - var logger$1 = new logger.Logger(_version$I.version); + var logger = new lib.Logger(_version$I.version); var names = [ "wei", "kwei", @@ -20259,7 +20345,7 @@ function commify(value) { var comps = String(value).split("."); if (comps.length > 2 || !comps[0].match(/^-?[0-9]*$/) || (comps[1] && !comps[1].match(/^[0-9]*$/)) || value === "." || value === "-.") { - logger$1.throwArgumentError("invalid value", "value", value); + logger.throwArgumentError("invalid value", "value", value); } // Make sure we have at least one whole digit (0 if none) var whole = comps[0]; @@ -20301,7 +20387,7 @@ unitName = 3 * index; } } - return fixednumber.formatFixed(value, (unitName != null) ? unitName : 18); + return lib$2.formatFixed(value, (unitName != null) ? unitName : 18); } exports.formatUnits = formatUnits; function parseUnits(value, unitName) { @@ -20311,7 +20397,7 @@ unitName = 3 * index; } } - return fixednumber.parseFixed(value, (unitName != null) ? unitName : 18); + return lib$2.parseFixed(value, (unitName != null) ? unitName : 18); } exports.parseUnits = parseUnits; function formatEther(wei) { @@ -20324,12 +20410,12 @@ exports.parseEther = parseEther; }); - var index$o = unwrapExports(units); - var units_1 = units.commify; - var units_2 = units.formatUnits; - var units_3 = units.parseUnits; - var units_4 = units.formatEther; - var units_5 = units.parseEther; + var index$o = unwrapExports(lib$o); + var lib_1$o = lib$o.commify; + var lib_2$l = lib$o.formatUnits; + var lib_3$g = lib$o.parseUnits; + var lib_4$d = lib$o.formatEther; + var lib_5$b = lib$o.parseEther; var utils$3 = createCommonjsModule(function (module, exports) { "use strict"; @@ -20342,104 +20428,104 @@ }; Object.defineProperty(exports, "__esModule", { value: true }); - exports.AbiCoder = abi.AbiCoder; - exports.defaultAbiCoder = abi.defaultAbiCoder; - exports.EventFragment = abi.EventFragment; - exports.FormatTypes = abi.FormatTypes; - exports.Fragment = abi.Fragment; - exports.FunctionFragment = abi.FunctionFragment; - exports.Indexed = abi.Indexed; - exports.Interface = abi.Interface; - exports.ParamType = abi.ParamType; + exports.AbiCoder = lib$a.AbiCoder; + exports.defaultAbiCoder = lib$a.defaultAbiCoder; + exports.EventFragment = lib$a.EventFragment; + exports.FormatTypes = lib$a.FormatTypes; + exports.Fragment = lib$a.Fragment; + exports.FunctionFragment = lib$a.FunctionFragment; + exports.Indexed = lib$a.Indexed; + exports.Interface = lib$a.Interface; + exports.ParamType = lib$a.ParamType; - exports.getAddress = address.getAddress; - exports.getContractAddress = address.getContractAddress; - exports.getIcapAddress = address.getIcapAddress; - exports.isAddress = address.isAddress; + exports.getAddress = lib$6.getAddress; + exports.getContractAddress = lib$6.getContractAddress; + exports.getIcapAddress = lib$6.getIcapAddress; + exports.isAddress = lib$6.isAddress; var base64 = __importStar(browser$8); exports.base64 = base64; - exports.arrayify = bytes.arrayify; - exports.concat = bytes.concat; - exports.hexDataSlice = bytes.hexDataSlice; - exports.hexDataLength = bytes.hexDataLength; - exports.hexlify = bytes.hexlify; - exports.hexStripZeros = bytes.hexStripZeros; - exports.hexValue = bytes.hexValue; - exports.hexZeroPad = bytes.hexZeroPad; - exports.isHexString = bytes.isHexString; - exports.joinSignature = bytes.joinSignature; - exports.zeroPad = bytes.zeroPad; - exports.splitSignature = bytes.splitSignature; - exports.stripZeros = bytes.stripZeros; + exports.arrayify = lib$1.arrayify; + exports.concat = lib$1.concat; + exports.hexDataSlice = lib$1.hexDataSlice; + exports.hexDataLength = lib$1.hexDataLength; + exports.hexlify = lib$1.hexlify; + exports.hexStripZeros = lib$1.hexStripZeros; + exports.hexValue = lib$1.hexValue; + exports.hexZeroPad = lib$1.hexZeroPad; + exports.isHexString = lib$1.isHexString; + exports.joinSignature = lib$1.joinSignature; + exports.zeroPad = lib$1.zeroPad; + exports.splitSignature = lib$1.splitSignature; + exports.stripZeros = lib$1.stripZeros; - exports.hashMessage = hash.hashMessage; - exports.id = hash.id; - exports.isValidName = hash.isValidName; - exports.namehash = hash.namehash; + exports.hashMessage = lib$9.hashMessage; + exports.id = lib$9.id; + exports.isValidName = lib$9.isValidName; + exports.namehash = lib$9.namehash; - exports.defaultPath = hdnode.defaultPath; - exports.entropyToMnemonic = hdnode.entropyToMnemonic; - exports.HDNode = hdnode.HDNode; - exports.isValidMnemonic = hdnode.isValidMnemonic; - exports.mnemonicToEntropy = hdnode.mnemonicToEntropy; - exports.mnemonicToSeed = hdnode.mnemonicToSeed; + exports.defaultPath = lib$h.defaultPath; + exports.entropyToMnemonic = lib$h.entropyToMnemonic; + exports.HDNode = lib$h.HDNode; + exports.isValidMnemonic = lib$h.isValidMnemonic; + exports.mnemonicToEntropy = lib$h.mnemonicToEntropy; + exports.mnemonicToSeed = lib$h.mnemonicToSeed; - exports.getJsonWalletAddress = jsonWallets.getJsonWalletAddress; + exports.getJsonWalletAddress = lib$i.getJsonWalletAddress; - exports.keccak256 = keccak256_1.keccak256; + exports.keccak256 = lib$4.keccak256; - exports.Logger = logger.Logger; + exports.Logger = lib.Logger; exports.sha256 = browser.sha256; - exports.solidityKeccak256 = solidity.keccak256; - exports.solidityPack = solidity.pack; - exports.soliditySha256 = solidity.sha256; + exports.solidityKeccak256 = lib$n.keccak256; + exports.solidityPack = lib$n.pack; + exports.soliditySha256 = lib$n.sha256; exports.randomBytes = browser$6.randomBytes; - exports.checkProperties = properties.checkProperties; - exports.deepCopy = properties.deepCopy; - exports.defineReadOnly = properties.defineReadOnly; - exports.getStatic = properties.getStatic; - exports.resolveProperties = properties.resolveProperties; - exports.shallowCopy = properties.shallowCopy; - var RLP = __importStar(rlp); + exports.checkProperties = lib$3.checkProperties; + exports.deepCopy = lib$3.deepCopy; + exports.defineReadOnly = lib$3.defineReadOnly; + exports.getStatic = lib$3.getStatic; + exports.resolveProperties = lib$3.resolveProperties; + exports.shallowCopy = lib$3.shallowCopy; + var RLP = __importStar(lib$5); exports.RLP = RLP; - exports.computePublicKey = signingKey.computePublicKey; - exports.recoverPublicKey = signingKey.recoverPublicKey; - exports.SigningKey = signingKey.SigningKey; + exports.computePublicKey = lib$f.computePublicKey; + exports.recoverPublicKey = lib$f.recoverPublicKey; + exports.SigningKey = lib$f.SigningKey; - exports.formatBytes32String = strings.formatBytes32String; - exports.nameprep = strings.nameprep; - exports.parseBytes32String = strings.parseBytes32String; - exports._toEscapedUtf8String = strings._toEscapedUtf8String; - exports.toUtf8Bytes = strings.toUtf8Bytes; - exports.toUtf8CodePoints = strings.toUtf8CodePoints; - exports.toUtf8String = strings.toUtf8String; + exports.formatBytes32String = lib$8.formatBytes32String; + exports.nameprep = lib$8.nameprep; + exports.parseBytes32String = lib$8.parseBytes32String; + exports._toEscapedUtf8String = lib$8._toEscapedUtf8String; + exports.toUtf8Bytes = lib$8.toUtf8Bytes; + exports.toUtf8CodePoints = lib$8.toUtf8CodePoints; + exports.toUtf8String = lib$8.toUtf8String; - exports.computeAddress = transactions.computeAddress; - exports.parseTransaction = transactions.parse; - exports.recoverAddress = transactions.recoverAddress; - exports.serializeTransaction = transactions.serialize; + exports.computeAddress = lib$g.computeAddress; + exports.parseTransaction = lib$g.parse; + exports.recoverAddress = lib$g.recoverAddress; + exports.serializeTransaction = lib$g.serialize; - exports.commify = units.commify; - exports.formatEther = units.formatEther; - exports.parseEther = units.parseEther; - exports.formatUnits = units.formatUnits; - exports.parseUnits = units.parseUnits; + exports.commify = lib$o.commify; + exports.formatEther = lib$o.formatEther; + exports.parseEther = lib$o.parseEther; + exports.formatUnits = lib$o.formatUnits; + exports.parseUnits = lib$o.parseUnits; - exports.verifyMessage = wallet.verifyMessage; + exports.verifyMessage = lib$j.verifyMessage; - exports.fetchJson = web.fetchJson; - exports.poll = web.poll; + exports.fetchJson = lib$l.fetchJson; + exports.poll = lib$l.poll; //////////////////////// // Enums var sha2_2 = browser; exports.SupportedAlgorithms = sha2_2.SupportedAlgorithms; - var strings_2 = strings; + var strings_2 = lib$8; exports.UnicodeNormalizationForm = strings_2.UnicodeNormalizationForm; }); @@ -20533,7 +20619,7 @@ var _version$K = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); - exports.version = "ethers/5.0.0-beta.156"; + exports.version = "ethers/5.0.0-beta.155"; }); var _version$L = unwrapExports(_version$K); @@ -20550,27 +20636,27 @@ }; Object.defineProperty(exports, "__esModule", { value: true }); - exports.Contract = contracts.Contract; - exports.ContractFactory = contracts.ContractFactory; + exports.Contract = lib$d.Contract; + exports.ContractFactory = lib$d.ContractFactory; - exports.BigNumber = bignumber$2.BigNumber; - exports.FixedNumber = bignumber$2.FixedNumber; + exports.BigNumber = lib$2.BigNumber; + exports.FixedNumber = lib$2.FixedNumber; - exports.Signer = abstractSigner.Signer; - exports.VoidSigner = abstractSigner.VoidSigner; + exports.Signer = lib$c.Signer; + exports.VoidSigner = lib$c.VoidSigner; - exports.Wallet = wallet.Wallet; - var constants$1 = __importStar(constants); - exports.constants = constants$1; - var providers$1 = __importStar(providers); - exports.providers = providers$1; + exports.Wallet = lib$j.Wallet; + var constants = __importStar(lib$7); + exports.constants = constants; + var providers = __importStar(lib$m); + exports.providers = providers; exports.Wordlist = browser$4.Wordlist; exports.wordlists = browser$4.wordlists; var utils = __importStar(utils$3); exports.utils = utils; - var errors = logger.Logger.errors; + var errors = lib.Logger.errors; exports.errors = errors; //////////////////////// // Compile-Time Constants @@ -20580,22 +20666,22 @@ // This is generated by "npm run dist" exports.version = _version$K.version; - var logger$1 = new logger.Logger(_version$K.version); - exports.logger = logger$1; + var logger = new lib.Logger(_version$K.version); + exports.logger = logger; //////////////////////// // Helper Functions function getDefaultProvider(network, options) { if (network == null) { network = "homestead"; } - var n = providers$1.getNetwork(network); + var n = providers.getNetwork(network); if (!n || !n._defaultProvider) { - logger$1.throwError("unsupported getDefaultProvider network", logger.Logger.errors.NETWORK_ERROR, { + logger.throwError("unsupported getDefaultProvider network", lib.Logger.errors.NETWORK_ERROR, { operation: "getDefaultProvider", network: network }); } - return n._defaultProvider(providers$1, options); + return n._defaultProvider(providers, options); } exports.getDefaultProvider = getDefaultProvider; }); @@ -20619,7 +20705,7 @@ var ethers_16 = ethers.logger; var ethers_17 = ethers.getDefaultProvider; - var ethers_1$1 = createCommonjsModule(function (module, exports) { + var lib$p = createCommonjsModule(function (module, exports) { "use strict"; function __export(m) { for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; @@ -20637,11 +20723,11 @@ __export(ethers); }); - var index$p = unwrapExports(ethers_1$1); - var ethers_2$1 = ethers_1$1.ethers; + var index$p = unwrapExports(lib$p); + var lib_1$p = lib$p.ethers; exports.default = index$p; - exports.ethers = ethers_2$1; + exports.ethers = lib_1$p; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/packages/ethers/dist/ethers.umd.min.js b/packages/ethers/dist/ethers.umd.min.js index 3a78bbf63..25e5dd16a 100644 --- a/packages/ethers/dist/ethers.umd.min.js +++ b/packages/ethers/dist/ethers.umd.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],C=8191&T,R=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],q=8191&K,W=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,W)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(C,z),i=(i=Math.imul(C,H))+Math.imul(R,z)|0,o=Math.imul(R,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(C,q)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,q)|0,o=o+Math.imul(R,W)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,$)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(C,le)|0,i=(i=i+Math.imul(C,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Ce=(f+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(R,pe)|0))<<13)|0;f=((o=o+Math.imul(R,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Re=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Ce,u[17]=Re,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.129"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.129"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.130"})),d=(r(h),h.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(h.version),a={};r.isBigNumberish=function(e){return null!=e&&(u.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var u=function(){function e(t,r){var n=this.constructor;o.checkNew(n,e),t!==a&&o.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return d(p(this).fromTwos(e))},e.prototype.toTwos=function(e){return d(p(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return d(p(this).add(p(e)))},e.prototype.sub=function(e){return d(p(this).sub(p(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&m("division by zero","div"),d(p(this).div(p(t)))},e.prototype.mul=function(e){return d(p(this).mul(p(e)))},e.prototype.mod=function(e){return d(p(this).mod(p(e)))},e.prototype.pow=function(e){return d(p(this).pow(p(e)))},e.prototype.maskn=function(e){return d(p(this).maskn(e))},e.prototype.eq=function(e){return p(this).eq(p(e))},e.prototype.lt=function(e){return p(this).lt(p(e))},e.prototype.lte=function(e){return p(this).lte(p(e))},e.prototype.gt=function(e){return p(this).gt(p(e))},e.prototype.gte=function(e){return p(this).gte(p(e))},e.prototype.isZero=function(){return p(this).isZero()},e.prototype.toNumber=function(){try{return p(this).toNumber()}catch(e){m("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&o.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(a,c(t)):t.match(/^-?[0-9]+$/)?new e(a,c(new i.BN(t))):o.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&m("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&m("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):o.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function c(e){if("string"!=typeof e)return c(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&o.throwArgumentError("invalid hex","value",e),"0x00"===(e=c(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return u.from(c(e))}function p(e){var t=u.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function m(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.FixedNumber=p.FixedNumber})),g=(r(m),m.BigNumber,m.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.131"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.137"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,C,R,B,I,F,L,j,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,C=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&C,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&R,e[15]=N^~C&B,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~R&S,e[17]=C^~B&M,e[26]=z^~K&I,e[27]=H^~q&F,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=R^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=q^~F&j,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.128"})),S=(r(A),A.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(A.version);function a(e){l.isHexString(e,20)||o.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=l.arrayify(E.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var u={},c=0;c<10;c++)u[String(c)]=String(c);for(c=0;c<26;c++)u[String.fromCharCode(65+c)]=String(10+c);var h,d=Math.floor((h=9007199254740991,Math.log10?Math.log10(h):Math.log(h)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=u[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=a(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=a("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=l.stripZeros(l.arrayify(e.nonce));return m(l.hexDataSlice(E.keccak256(P.encode([t,r])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,R.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new C.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.128"})),q=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(q.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(W),W.LogDescription,W.TransactionDescription,W.Indexed,W.Result,W.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=W.Indexed,t.Interface=W.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.131"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.132"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.137"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger($.version),a={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function s(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return s(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return s(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return s(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function u(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],u=0;u0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=v;var b=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&o.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&o.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ct=Tt;function Rt(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Rt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Ct.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Ct,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var qt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new qt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new qt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.129"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.128"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?R.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.128"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return q.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.130"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invlaid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.128"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},C.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},C.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var R=function(e,t){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof C||(t=new C(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};R.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}C(R)};R()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Cr=0;Cr<256;Cr++)Nr[Cr]=(Cr+256).toString(16).substr(1),Tr[Nr[Cr]]=Cr;function Rr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Rr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Rr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Rr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),C=l.arrayify(T.encrypt(f)),R=new Date,B=R.getUTCFullYear()+"-"+Pr.zpad(R.getUTCMonth()+1,2)+"-"+Pr.zpad(R.getUTCDate(),2)+"T"+Pr.zpad(R.getUTCHours(),2)+"-"+Pr.zpad(R.getUTCMinutes(),2)+"-"+Pr.zpad(R.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(C).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),qr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.130"})),Wr=(r(qr),qr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(qr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(q.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(q.hashMessage(e),t)}})),Gr=(r(Wr),Wr.Wallet,Wr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.129"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.141"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===R.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),pn=(r(dn),dn.pack,dn.keccak256,dn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.127"})),mn=(r(pn),pn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(pn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return p.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return p.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),gn=(r(mn),mn.commify,mn.formatUnits,mn.parseUnits,mn.formatEther,mn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=q.hashMessage,r.id=q.id,r.isValidName=q.isValidName,r.namehash=q.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=dn.keccak256,r.solidityPack=dn.pack,r.soliditySha256=dn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=mn.commify,r.formatEther=mn.formatEther,r.parseEther=mn.parseEther,r.formatUnits=mn.formatUnits,r.parseUnits=mn.parseUnits,r.verifyMessage=Wr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),yn=(r(gn),gn.AbiCoder,gn.defaultAbiCoder,gn.EventFragment,gn.FormatTypes,gn.Fragment,gn.FunctionFragment,gn.Indexed,gn.Interface,gn.ParamType,gn.getAddress,gn.getContractAddress,gn.getIcapAddress,gn.isAddress,gn.base64,gn.arrayify,gn.concat,gn.hexDataSlice,gn.hexDataLength,gn.hexlify,gn.hexStripZeros,gn.hexValue,gn.hexZeroPad,gn.isHexString,gn.joinSignature,gn.zeroPad,gn.splitSignature,gn.stripZeros,gn.hashMessage,gn.id,gn.isValidName,gn.namehash,gn.defaultPath,gn.entropyToMnemonic,gn.HDNode,gn.isValidMnemonic,gn.mnemonicToEntropy,gn.mnemonicToSeed,gn.getJsonWalletAddress,gn.keccak256,gn.Logger,gn.sha256,gn.solidityKeccak256,gn.solidityPack,gn.soliditySha256,gn.randomBytes,gn.checkProperties,gn.deepCopy,gn.defineReadOnly,gn.getStatic,gn.resolveProperties,gn.shallowCopy,gn.RLP,gn.computePublicKey,gn.recoverPublicKey,gn.SigningKey,gn.formatBytes32String,gn.nameprep,gn.parseBytes32String,gn._toEscapedUtf8String,gn.toUtf8Bytes,gn.toUtf8CodePoints,gn.toUtf8String,gn.computeAddress,gn.parseTransaction,gn.recoverAddress,gn.serializeTransaction,gn.commify,gn.formatEther,gn.parseEther,gn.formatUnits,gn.parseUnits,gn.verifyMessage,gn.fetchJson,gn.poll,gn.SupportedAlgorithms,gn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.platform="node"})),vn=(r(yn),yn.platform,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.156"})),bn=(r(vn),vn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=Wr.Wallet;var i=n(R);r.constants=i;var o=n(hn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(gn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.platform=yn.platform,r.version=vn.version;var u=new f.Logger(vn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),wn=(r(bn),bn.Contract,bn.ContractFactory,bn.BigNumber,bn.FixedNumber,bn.Signer,bn.VoidSigner,bn.Wallet,bn.constants,bn.providers,bn.Wordlist,bn.wordlists,bn.utils,bn.errors,bn.platform,bn.version,bn.logger,bn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(bn);r.ethers=i,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(bn)})),_n=r(wn),En=wn.ethers;e.default=_n,e.ethers=En,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],R=8191&T,C=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],q=8191&K,W=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,W)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,z),i=(i=Math.imul(R,H))+Math.imul(C,z)|0,o=Math.imul(C,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(R,q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Ce=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Re,u[17]=Ce,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.128"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.128"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.129"})),d=(r(h),h.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(h.version),a={};r.isBigNumberish=function(e){return null!=e&&(u.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var u=function(){function e(t,r){var n=this.constructor;o.checkNew(n,e),t!==a&&o.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return d(p(this).fromTwos(e))},e.prototype.toTwos=function(e){return d(p(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return d(p(this).add(p(e)))},e.prototype.sub=function(e){return d(p(this).sub(p(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&m("division by zero","div"),d(p(this).div(p(t)))},e.prototype.mul=function(e){return d(p(this).mul(p(e)))},e.prototype.mod=function(e){return d(p(this).mod(p(e)))},e.prototype.pow=function(e){return d(p(this).pow(p(e)))},e.prototype.maskn=function(e){return d(p(this).maskn(e))},e.prototype.eq=function(e){return p(this).eq(p(e))},e.prototype.lt=function(e){return p(this).lt(p(e))},e.prototype.lte=function(e){return p(this).lte(p(e))},e.prototype.gt=function(e){return p(this).gt(p(e))},e.prototype.gte=function(e){return p(this).gte(p(e))},e.prototype.isZero=function(){return p(this).isZero()},e.prototype.toNumber=function(){try{return p(this).toNumber()}catch(e){m("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&o.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(a,c(t)):t.match(/^-?[0-9]+$/)?new e(a,c(new i.BN(t))):o.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&m("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&m("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):o.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function c(e){if("string"!=typeof e)return c(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&o.throwArgumentError("invalid hex","value",e),"0x00"===(e=c(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return u.from(c(e))}function p(e){var t=u.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function m(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.formatFixed=p.formatFixed,t.FixedFormat=p.FixedFormat,t.FixedNumber=p.FixedNumber,t.parseFixed=p.parseFixed})),g=(r(m),m.BigNumber,m.formatFixed,m.FixedFormat,m.FixedNumber,m.parseFixed,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.130"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.136"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,R,C,B,I,F,L,j,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,R=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,C=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&R,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&C,e[15]=N^~R&B,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~C&S,e[17]=R^~B&M,e[26]=z^~K&I,e[27]=H^~q&F,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=C^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=q^~F&j,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.127"})),S=(r(A),A.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(A.version);function a(e){l.isHexString(e,20)||o.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=l.arrayify(E.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var u={},c=0;c<10;c++)u[String(c)]=String(c);for(c=0;c<26;c++)u[String.fromCharCode(65+c)]=String(10+c);var h,d=Math.floor((h=9007199254740991,Math.log10?Math.log10(h):Math.log(h)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=u[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=a(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=a("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=l.stripZeros(l.arrayify(e.nonce));return m(l.hexDataSlice(E.keccak256(P.encode([t,r])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,C.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new R.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.127"})),q=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(q.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(W),W.LogDescription,W.TransactionDescription,W.Indexed,W.Result,W.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=W.Indexed,t.Interface=W.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.130"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.131"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.136"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger($.version),a={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function s(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return s(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return s(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return s(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function u(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],u=0;u0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=v;var b=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&o.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&o.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Rt=Tt;function Ct(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Ct.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Rt.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Rt,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var qt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new qt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new qt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.128"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.127"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?C.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.127"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return q.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.129"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invlaid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.127"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},R.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},R.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var C=function(e,t){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof R||(t=new R(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};C.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}R(C)};C()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Rr=0;Rr<256;Rr++)Nr[Rr]=(Rr+256).toString(16).substr(1),Tr[Nr[Rr]]=Rr;function Cr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Cr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Cr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Cr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),R=l.arrayify(T.encrypt(f)),C=new Date,B=C.getUTCFullYear()+"-"+Pr.zpad(C.getUTCMonth()+1,2)+"-"+Pr.zpad(C.getUTCDate(),2)+"T"+Pr.zpad(C.getUTCHours(),2)+"-"+Pr.zpad(C.getUTCMinutes(),2)+"-"+Pr.zpad(C.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(R).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),qr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.129"})),Wr=(r(qr),qr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(qr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(q.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(q.hashMessage(e),t)}})),Gr=(r(Wr),Wr.Wallet,Wr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.128"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.140"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===C.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),mn=(r(pn),pn.pack,pn.keccak256,pn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.126"})),gn=(r(mn),mn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(mn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),yn=(r(gn),gn.commify,gn.formatUnits,gn.parseUnits,gn.formatEther,gn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=q.hashMessage,r.id=q.id,r.isValidName=q.isValidName,r.namehash=q.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=pn.keccak256,r.solidityPack=pn.pack,r.soliditySha256=pn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=gn.commify,r.formatEther=gn.formatEther,r.parseEther=gn.parseEther,r.formatUnits=gn.formatUnits,r.parseUnits=gn.parseUnits,r.verifyMessage=Wr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),vn=(r(yn),yn.AbiCoder,yn.defaultAbiCoder,yn.EventFragment,yn.FormatTypes,yn.Fragment,yn.FunctionFragment,yn.Indexed,yn.Interface,yn.ParamType,yn.getAddress,yn.getContractAddress,yn.getIcapAddress,yn.isAddress,yn.base64,yn.arrayify,yn.concat,yn.hexDataSlice,yn.hexDataLength,yn.hexlify,yn.hexStripZeros,yn.hexValue,yn.hexZeroPad,yn.isHexString,yn.joinSignature,yn.zeroPad,yn.splitSignature,yn.stripZeros,yn.hashMessage,yn.id,yn.isValidName,yn.namehash,yn.defaultPath,yn.entropyToMnemonic,yn.HDNode,yn.isValidMnemonic,yn.mnemonicToEntropy,yn.mnemonicToSeed,yn.getJsonWalletAddress,yn.keccak256,yn.Logger,yn.sha256,yn.solidityKeccak256,yn.solidityPack,yn.soliditySha256,yn.randomBytes,yn.checkProperties,yn.deepCopy,yn.defineReadOnly,yn.getStatic,yn.resolveProperties,yn.shallowCopy,yn.RLP,yn.computePublicKey,yn.recoverPublicKey,yn.SigningKey,yn.formatBytes32String,yn.nameprep,yn.parseBytes32String,yn._toEscapedUtf8String,yn.toUtf8Bytes,yn.toUtf8CodePoints,yn.toUtf8String,yn.computeAddress,yn.parseTransaction,yn.recoverAddress,yn.serializeTransaction,yn.commify,yn.formatEther,yn.parseEther,yn.formatUnits,yn.parseUnits,yn.verifyMessage,yn.fetchJson,yn.poll,yn.SupportedAlgorithms,yn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.platform="node"})),bn=(r(vn),vn.platform,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.155"})),wn=(r(bn),bn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=Wr.Wallet;var i=n(C);r.constants=i;var o=n(dn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(yn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.platform=vn.platform,r.version=bn.version;var u=new f.Logger(bn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),_n=(r(wn),wn.Contract,wn.ContractFactory,wn.BigNumber,wn.FixedNumber,wn.Signer,wn.VoidSigner,wn.Wallet,wn.constants,wn.providers,wn.Wordlist,wn.wordlists,wn.utils,wn.errors,wn.platform,wn.version,wn.logger,wn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(wn);r.ethers=i,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(wn)})),En=r(_n),Pn=_n.ethers;e.default=En,e.ethers=Pn,Object.defineProperty(e,"__esModule",{value:!0})}); diff --git a/packages/ethers/package.json b/packages/ethers/package.json index a5d352ced..35cb218de 100644 --- a/packages/ethers/package.json +++ b/packages/ethers/package.json @@ -61,5 +61,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xb405e54456bb9eda893991365e18b295b0ce48a434319f02299afee7c7c15320" + "tarballHash": "0x75cf66f7ca99a6b0c1b4a1efc948fdec6efb877ceda8cc749adc0afb1925e1d2" } diff --git a/packages/experimental/package.json b/packages/experimental/package.json index 9c68fabcd..cfc199f48 100644 --- a/packages/experimental/package.json +++ b/packages/experimental/package.json @@ -25,5 +25,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xf5f098266abb3959cec1221ea114f9c9f4330440fd0ebe1e0993961c576675f8" + "tarballHash": "0xaef8cc57062b7338b34d09bae80d7e320fd3f33d2623b76e30efb1a2b064bcc9" } diff --git a/packages/hash/package.json b/packages/hash/package.json index 03ad1116a..227b925ba 100644 --- a/packages/hash/package.json +++ b/packages/hash/package.json @@ -26,5 +26,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x94e31ec73b1932a42dd0ddd31c4684252d8306336f04ad6c20d6fe99e6723e05" + "tarballHash": "0x3bf4cb63c74debd7ce364c5193bc17eeb89162846505175bddd8eae172724d12" } diff --git a/packages/hdnode/package.json b/packages/hdnode/package.json index 34b7772e2..a10da0eab 100644 --- a/packages/hdnode/package.json +++ b/packages/hdnode/package.json @@ -34,5 +34,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x2b740d2841d6666fdbed43d6bd35217d731e93ca51761a5e710140a230f7b159" + "tarballHash": "0x1aa41472296a4ab9726dfaa3c12a9ec142120e45fa76441bd4001f23f7c6c71f" } diff --git a/packages/json-wallets/package.json b/packages/json-wallets/package.json index 042b252f6..53a2dfc85 100644 --- a/packages/json-wallets/package.json +++ b/packages/json-wallets/package.json @@ -36,5 +36,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xe51c8db7ea4eac9042c499bb95f21eeeb75205133771e2c65f965fcec53446f9" + "tarballHash": "0x7bdd9f912bcc5995dd1556175bf3b9b2569e7bf31fec95e4a6fee21fc9c91308" } diff --git a/packages/keccak256/package.json b/packages/keccak256/package.json index 9537e8379..353b0eb1c 100644 --- a/packages/keccak256/package.json +++ b/packages/keccak256/package.json @@ -24,5 +24,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x321ddc3fd8264b4555fc6017e46fcd721aaefc45c72d8dfd42259abf2d7af9d1" + "tarballHash": "0x1292347cbf0e4d2c969b299a48c285da51c2b5c87eee432e1a0ca1316d3c4df3" } diff --git a/packages/logger/package.json b/packages/logger/package.json index 0b5c108dd..aa4fe5234 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -20,5 +20,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xbed8c881ec0bb9bc2aed81dbac8c2bcf51889b7b8caed2053939a1344e402475" + "tarballHash": "0xe63bdaccfd4ac8b5650dfc22ab48a27ae30db28f1e7e5148d5e278d88bca9f06" } diff --git a/packages/networks/package.json b/packages/networks/package.json index 29ed48c4e..ef23073be 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -23,5 +23,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xd9e67edd9e4e88e2f320e073abc4f3e7ff0f41f7cb90cf94122c55ec17ce0f27" + "tarballHash": "0xf3d4268851266407e27c78868f6274203dd14bb6d52a9568f179862f3d00f786" } diff --git a/packages/pbkdf2/package.json b/packages/pbkdf2/package.json index 077d6a130..87d9301e8 100644 --- a/packages/pbkdf2/package.json +++ b/packages/pbkdf2/package.json @@ -3,7 +3,7 @@ "version": "5.0.0-beta.127", "description": "The PBKDF2 password-pbased key derivation function for ethers.", "main": "./lib/index.js", - "browser": "browser.js", + "browser": "./lib/browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x4830330866b12fb72d882f27189212d4edbda5ad2257d5d5903ea265f28786e9" + "tarballHash": "0x5f104b9b5186d943d4b4f6fd7bc7a7e866ea355e39291c3aff275d57dd8badbd" } diff --git a/packages/properties/package.json b/packages/properties/package.json index 491d7949c..f97bace02 100644 --- a/packages/properties/package.json +++ b/packages/properties/package.json @@ -25,5 +25,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x68656684c2b7d12224e1a4dc73bdead0b1043aadfedd139aa082036cbffc5a0e" + "tarballHash": "0x776280f444c3bf1c8c3581c88f3289253d6795adc776a401d17954e096bb60cb" } diff --git a/packages/providers/package.json b/packages/providers/package.json index 21e1b3585..55df81a69 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -4,8 +4,8 @@ "description": "Ethereum Providers for ethers.", "main": "./lib/index.js", "browser": { - "net": "./browser-net.js", - "./ipc-provider": "./browser-ipc-provider.js" + "net": "./lib/browser-net.js", + "./ipc-provider": "./lib/browser-ipc-provider.js" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -44,5 +44,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x7d6d0ea53f6c97c8a247450d2ca7f3a6d85f9fc3911bbadb86c63f12e5295e63" + "tarballHash": "0xb65f2fd000fd23cfc0ae137cf9f039249380b6639e0019ee5d2b43abec7e6271" } diff --git a/packages/random/package.json b/packages/random/package.json index aa5ea22d5..e6c49723b 100644 --- a/packages/random/package.json +++ b/packages/random/package.json @@ -3,7 +3,7 @@ "version": "5.0.0-beta.128", "description": "Random utility functions for ethers.", "main": "./lib/index.js", - "browser": "browser.js", + "browser": "./lib/browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -29,5 +29,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x12bbfa545217fbf34da3e01d4e42d231a202b4b8a615d2f4e10b84c6fa354edb" + "tarballHash": "0xc6450e8215ec6b6d0fccda331c5541d2a5a7ebf86b7d4d0fd83429c08437f826" } diff --git a/packages/rlp/package.json b/packages/rlp/package.json index b40018a25..e005336ed 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -24,5 +24,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xb8ddada3158be8ee0419832c53ef51c466a07b862c56e5402567f5a096ce1f6d" + "tarballHash": "0x33e977a875ac88214d1dd31b62f4a4fb4c18710c3b0ea453b973656c80d4d824" } diff --git a/packages/sha2/package.json b/packages/sha2/package.json index e8c724b14..aeb795347 100644 --- a/packages/sha2/package.json +++ b/packages/sha2/package.json @@ -3,7 +3,7 @@ "version": "5.0.0-beta.129", "description": "The SHA2 family hash functions and HMAC functions for ethers.", "main": "./lib/index.js", - "browser": "browser.js", + "browser": "./lib/browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -26,5 +26,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x1550ecce4b5da09b8f7b95a4313b68d767a73e3f5920ea5636d34022e2971957" + "tarballHash": "0x87b6ff04df9c0df26a7afaf9880262797538b004b0581a72d108510f5b1f9235" } diff --git a/packages/signing-key/package.json b/packages/signing-key/package.json index 33abe9832..c3f0738e7 100644 --- a/packages/signing-key/package.json +++ b/packages/signing-key/package.json @@ -26,5 +26,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xf65693a06f04727d25829cc27edc77c7d0514ca87ecdd1593e968526380cad4b" + "tarballHash": "0x0126d28a0bb036b3a68821568153fc33edd738f21757dcd79f8dfca33d5b09e7" } diff --git a/packages/solidity/package.json b/packages/solidity/package.json index 50ad82d51..b92139217 100644 --- a/packages/solidity/package.json +++ b/packages/solidity/package.json @@ -27,5 +27,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x12c5fdd83ae961c1474dc119a576fd069d15dfd81c555072d8271f7da8b98bef" + "tarballHash": "0x5a24d578f0111ef50d2380aa3f1958e6143d7edab3b1330647e3ac4b77f9115b" } diff --git a/packages/strings/package.json b/packages/strings/package.json index 7fc2a27f0..651b750ec 100644 --- a/packages/strings/package.json +++ b/packages/strings/package.json @@ -27,5 +27,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xc677425c7f1ff6b76a370731692da0995eba3a44861dd93b147874b8fae74007" + "tarballHash": "0xcbb038765fe741066b9e003c1e805d9a6e8c617aeb4a1d96ab40425122fc9dd3" } diff --git a/packages/testcases/lib.esm/generation-scripts/abi.js b/packages/testcases/lib.esm/generation-scripts/abi.js index efb3c8fd0..479ccb4dc 100644 --- a/packages/testcases/lib.esm/generation-scripts/abi.js +++ b/packages/testcases/lib.esm/generation-scripts/abi.js @@ -1,7 +1,7 @@ "use strict"; //let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8549')); //import { compile as _compile } from "solc"; -import { compile } from "@ethersproject/cli/solc"; +import { solc } from "@ethersproject/cli"; import { randomHexString, randomNumber } from ".."; import { BN, keccak256, toChecksumAddress } from "ethereumjs-util"; function hasPrefix(str, prefix) { @@ -510,7 +510,7 @@ for (let i = 0; i < 100; i++) { let solidity = generateSolidity(params); console.log(solidity); console.log(i); - let bytecode = compile(solidity)[0].bytecode; + let bytecode = solc.compile(solidity)[0].bytecode; //console.log(params.map(p => p.type).join(", ")); //console.log(bytecode); let testcase = { diff --git a/packages/testcases/lib.esm/index.js b/packages/testcases/lib.esm/index.js index 5e82b975d..d43478c74 100644 --- a/packages/testcases/lib.esm/index.js +++ b/packages/testcases/lib.esm/index.js @@ -7,12 +7,12 @@ import { keccak256 } from "@ethersproject/keccak256"; import { toUtf8Bytes } from "@ethersproject/strings"; export function saveTests(tag, data) { //let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); - let filename = path.resolve('testcases', tag + '.json.gz'); + let filename = path.resolve('../testcases', tag + '.json.gz'); fs.writeFileSync(filename, zlib.gzipSync(JSON.stringify(data, undefined, ' ') + '\n')); console.log('Save testcase: ' + filename); } export function loadTests(tag) { - let filename = path.resolve(__dirname, 'testcases', tag + '.json.gz'); + let filename = path.resolve(__dirname, '../testcases', tag + '.json.gz'); return JSON.parse(zlib.gunzipSync(fs.readFileSync(filename)).toString()); } export function loadData(filename) { diff --git a/packages/testcases/package.json b/packages/testcases/package.json index 082483c13..5f89c7c40 100644 --- a/packages/testcases/package.json +++ b/packages/testcases/package.json @@ -15,7 +15,7 @@ "browserify-zlib": "^0.2.0" }, "devDependencies": { - "@ethersproject/cli": ">=5.0.0-beta.133", + "@ethersproject/cli": ">=5.0.0-beta.142", "@types/bip39": "2.4.1", "@types/bitcoinjs-lib": "3.3.2", "bip39": "2.5.0", @@ -37,5 +37,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xecb1966755ccacc53768d87bf4a91cf0ca5b46d1ce30268daf651f27bd2a07a9" + "tarballHash": "0x3eecab2eb7ec5cb3a83064cef11b20e9be3abaf360fc24dc22ddb890ba072544" } diff --git a/packages/tests/package.json b/packages/tests/package.json index 926165890..0360150bd 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -37,5 +37,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x6cb1911af4d7c3550c1225b39891e54a8c67276f2d1f9b38ed0b6168711c7dd0" + "tarballHash": "0xbe37358972f6b48eaf05ca1a30f164a3da3370372aa81b5f71a6ced50f93f741" } diff --git a/packages/transactions/package.json b/packages/transactions/package.json index faba8c5d3..a8c8764ed 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -31,5 +31,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x98659289537d6259256584ecd435405580a14f5219f8312be9d95ce30eea5b21" + "tarballHash": "0x5a7f7a0edf47aeda2379fb0759b59d538bb6d68b05508e1ee047643239d3beba" } diff --git a/packages/units/lib.esm/index.js b/packages/units/lib.esm/index.js index 32227e997..046737ca6 100644 --- a/packages/units/lib.esm/index.js +++ b/packages/units/lib.esm/index.js @@ -1,5 +1,5 @@ "use strict"; -import { formatFixed, parseFixed } from "@ethersproject/bignumber/fixednumber"; +import { formatFixed, parseFixed } from "@ethersproject/bignumber"; import { Logger } from "@ethersproject/logger"; import { version } from "./_version"; const logger = new Logger(version); diff --git a/packages/units/package.json b/packages/units/package.json index 394dde412..1f72c3378 100644 --- a/packages/units/package.json +++ b/packages/units/package.json @@ -27,5 +27,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x5479e371548e25506a64d279c312e51f06828b3802cece3c5f3f621b67b61abd" + "tarballHash": "0x03fcf14ceb26ccd22b4bde2095d99815d33a3ee10c663c66863098cb04e5a949" } diff --git a/packages/wallet/lib.esm/index.d.ts b/packages/wallet/lib.esm/index.d.ts index 0d2ad7d78..aa53291fd 100644 --- a/packages/wallet/lib.esm/index.d.ts +++ b/packages/wallet/lib.esm/index.d.ts @@ -3,7 +3,7 @@ import { ExternallyOwnedAccount, Signer } from "@ethersproject/abstract-signer"; import { Bytes, BytesLike, SignatureLike } from "@ethersproject/bytes"; import { SigningKey } from "@ethersproject/signing-key"; import { ProgressCallback } from "@ethersproject/json-wallets"; -import { Wordlist } from "@ethersproject/wordlists/wordlist"; +import { Wordlist } from "@ethersproject/wordlists"; export declare class Wallet extends Signer implements ExternallyOwnedAccount { readonly address: string; readonly provider: Provider; diff --git a/packages/wallet/package.json b/packages/wallet/package.json index 8eac5f424..4491dcf50 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -37,5 +37,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x460a045fc0b735ecdb14c5dd2c93c0dc45658ff46071f41dbf4a7cc6d3af1450" + "tarballHash": "0x089e1006fc830b53ddc8c3c4eb83774a600b56d16e7a86846ff5a82b209d22d6" } diff --git a/packages/web/package.json b/packages/web/package.json index ab0535109..105f11a51 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -27,5 +27,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x79ab00f43c26bd2e93155b849eabaaac737c689bcee3dd73f401b4b2f953f82e" + "tarballHash": "0x10b30a94e8417a1835f4b0468b9cf5523959c856598bbdc914cb5902c0618e50" } diff --git a/packages/wordlists/package.json b/packages/wordlists/package.json index fc99f6acd..6255f4e13 100644 --- a/packages/wordlists/package.json +++ b/packages/wordlists/package.json @@ -3,7 +3,7 @@ "version": "5.0.0-beta.128", "description": "Word lists for BIP39 wallets.", "main": "./lib/index.js", - "browser": "browser.js", + "browser": "./lib/browser.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, @@ -28,5 +28,5 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x2c13e3b70876f57cc7a6f8ad6240f177e2a5b65c80f865aff28c890e784ae1d8" + "tarballHash": "0x7c5bb7cc5b54a118fd80e310c83087a8fbe5c4680812cc8bc78f0205052fbbb7" } diff --git a/rollup.config.js b/rollup.config.js index dd0159f2e..fba615121 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -44,13 +44,13 @@ export default commandLineArgs => { let buildModule = commandLineArgs.configModule; let testing = commandLineArgs.configTest; - let input = "packages/ethers/index.js" + let input = "packages/ethers/lib/index.js" let output = [ "umd" ]; let format = "umd"; let mainFields = [ "browser", "main" ]; if (buildModule) { - input = "packages/ethers/module/index.js"; + input = "packages/ethers/lib.esm/index.js"; output = [ "esm" ]; format = "esm"; mainFields = [ "browser", "module", "main" ]; From 019c1fc7089b3da2d7bd41c933b6c6bc35c8dade Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Mon, 26 Aug 2019 16:00:51 -0400 Subject: [PATCH 04/13] Fixed typo in error message (#592). --- packages/hdnode/src.ts/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hdnode/src.ts/index.ts b/packages/hdnode/src.ts/index.ts index a4c4cce5a..d9d8189ba 100644 --- a/packages/hdnode/src.ts/index.ts +++ b/packages/hdnode/src.ts/index.ts @@ -197,7 +197,7 @@ export class HDNode implements ExternallyOwnedAccount { if (index >= HardenedBit) { throw new Error("invalid path index - " + component); } result = result._derive(index); } else { - throw new Error("invlaid path component - " + component); + throw new Error("invalid path component - " + component); } } From 85b4db7d6db37b853f11a90cf4648c34404edcf9 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sat, 31 Aug 2019 23:56:02 -0400 Subject: [PATCH 05/13] Updated packages with version lock and moved types. --- packages/abi/package.json | 21 ++-- packages/abstract-provider/package.json | 17 ++-- packages/abstract-signer/package.json | 13 +-- packages/address/package.json | 13 +-- packages/base64/package.json | 5 +- packages/basex/package.json | 7 +- packages/bignumber/package.json | 9 +- packages/bytes/package.json | 5 +- packages/cli/lib.esm/bin/ethers-ens.js | 19 ++-- packages/cli/lib.esm/cli.js | 4 +- packages/cli/lib/bin/ethers-ens.js | 19 ++-- packages/cli/lib/cli.js | 4 +- packages/cli/package.json | 7 +- packages/cli/src.ts/bin/ethers-ens.ts | 20 ++-- packages/cli/src.ts/cli.ts | 4 +- packages/constants/package.json | 5 +- packages/contracts/package.json | 23 +++-- packages/errors/package.json | 3 +- packages/ethers/dist/ethers.esm.js | 10 +- packages/ethers/dist/ethers.esm.min.js | 2 +- packages/ethers/dist/ethers.umd.js | 21 +--- packages/ethers/dist/ethers.umd.min.js | 2 +- packages/ethers/lib.esm/ethers.d.ts | 3 +- packages/ethers/lib.esm/ethers.js | 6 +- packages/ethers/lib/ethers.d.ts | 3 +- packages/ethers/lib/ethers.js | 3 - packages/ethers/package.json | 74 ++++++-------- packages/ethers/scripts/transform.js | 111 --------------------- packages/ethers/src.ts/browser-platform.ts | 4 - packages/ethers/src.ts/ethers.ts | 8 +- packages/ethers/src.ts/platform.ts | 3 - packages/experimental/package.json | 7 +- packages/hash/package.json | 11 +- packages/hdnode/lib.esm/index.js | 2 +- packages/hdnode/lib/index.js | 2 +- packages/hdnode/package.json | 27 ++--- packages/json-wallets/package.json | 25 ++--- packages/keccak256/package.json | 5 +- packages/logger/package.json | 3 +- packages/networks/package.json | 5 +- packages/pbkdf2/package.json | 7 +- packages/properties/package.json | 5 +- packages/providers/package.json | 33 +++--- packages/random/package.json | 7 +- packages/rlp/package.json | 5 +- packages/sha2/package.json | 7 +- packages/shims/package.json | 3 +- packages/signing-key/package.json | 9 +- packages/solidity/package.json | 13 +-- packages/strings/package.json | 9 +- packages/testcases/package.json | 11 +- packages/tests/package.json | 7 +- packages/transactions/package.json | 21 ++-- packages/units/package.json | 9 +- packages/wallet/package.json | 33 +++--- packages/web/package.json | 11 +- packages/wordlists/package.json | 13 +-- 57 files changed, 317 insertions(+), 421 deletions(-) delete mode 100644 packages/ethers/scripts/transform.js delete mode 100644 packages/ethers/src.ts/browser-platform.ts delete mode 100644 packages/ethers/src.ts/platform.ts diff --git a/packages/abi/package.json b/packages/abi/package.json index de2b0751f..03e4700a1 100644 --- a/packages/abi/package.json +++ b/packages/abi/package.json @@ -7,15 +7,15 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/hash": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0" + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/hash": ">=5.0.0-beta.128", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/strings": ">=5.0.0-beta.130" }, "keywords": [ "Ethereum", @@ -31,5 +31,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x48cbad8938a128d8f52b87e30c92a1ad2b28af9aee2d1faf1a4c23d60a14b2d3" + "types": "./lib/index.d.ts", + "tarballHash": "0xe4021eb72e5aed6edb4b6cf5fa70f01afa6f1ae200e40bea8861b60a59759b4a" } diff --git a/packages/abstract-provider/package.json b/packages/abstract-provider/package.json index e0fbce4da..97faa39c4 100644 --- a/packages/abstract-provider/package.json +++ b/packages/abstract-provider/package.json @@ -7,13 +7,13 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/networks": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0", - "@ethersproject/web": ">5.0.0-beta.0" + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/networks": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/transactions": ">=5.0.0-beta.128", + "@ethersproject/web": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -29,5 +29,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x478d4364ced856f3b5ee51da258a5ae239b97a5d1a58f25dd25b8e81f692683c" + "types": "./lib/index.d.ts", + "tarballHash": "0x3a2082bb4e5d5f15beb057d863d32cf55a086c6065f05202df62a520f717deea" } diff --git a/packages/abstract-signer/package.json b/packages/abstract-signer/package.json index c024c1d61..c70d86d1f 100644 --- a/packages/abstract-signer/package.json +++ b/packages/abstract-signer/package.json @@ -7,11 +7,11 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abstract-provider": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0" + "@ethersproject/abstract-provider": ">=5.0.0-beta.131", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131" }, "keywords": [ "Ethereum", @@ -27,5 +27,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xc1853f4ac83975080e51babe4f0613122ce5b1b5d68287c84d44a5663cf5546c" + "types": "./lib/index.d.ts", + "tarballHash": "0xfe7d31b31b069c4f4600f1f7eea2a9f271a6f8f919e0c17fc578acae251237db" } diff --git a/packages/address/package.json b/packages/address/package.json index b2d27bc0c..5708a681b 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -7,11 +7,11 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/rlp": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/rlp": ">=5.0.0-beta.126", "bn.js": "^4.4.0" }, "keywords": [ @@ -28,5 +28,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x3f3fd1c8422ddd05719dfb37df8292d27e93ae1ce0d0d48e5cdc263082e35a78" + "types": "./lib/index.d.ts", + "tarballHash": "0x4cf2a1710526cbee72754e01d0819087d80c4e6f95393dfc9037aeec5ed9cde2" } diff --git a/packages/base64/package.json b/packages/base64/package.json index 0132f1ec3..52ab2a11f 100644 --- a/packages/base64/package.json +++ b/packages/base64/package.json @@ -8,7 +8,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -24,5 +24,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x390db88947a298518774fc7b8d5f9b36191df44152bca2370a890d44d44e731f" + "types": "./lib/index.d.ts", + "tarballHash": "0xaf339d29758af1140ec01b737ab3241b28f376a6ff66c85e75d6f8a9b29886f2" } diff --git a/packages/basex/package.json b/packages/basex/package.json index 3d3d01649..29851baa2 100644 --- a/packages/basex/package.json +++ b/packages/basex/package.json @@ -7,8 +7,8 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131" }, "keywords": [ "Ethereum", @@ -24,5 +24,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x6375a21ec47208aa3a867f26061dbd56afcb7eb51f70c6955b99718fe3ebc32a" + "types": "./lib/index.d.ts", + "tarballHash": "0x229d72d84c96d355704e5ee6947554004006ce117a2e18fe46d9fdf3a7697c97" } diff --git a/packages/bignumber/package.json b/packages/bignumber/package.json index 86eb1f2e1..7a87dba14 100644 --- a/packages/bignumber/package.json +++ b/packages/bignumber/package.json @@ -7,9 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", "bn.js": "^4.4.0" }, "keywords": [ @@ -27,5 +27,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x3b0c080f96f262333cb2191f8160e1aef0d93f9af107c1aa0876d007817c9e76" + "types": "./lib/index.d.ts", + "tarballHash": "0x9a95bbb76aa2acea22c52711473585eef5196d7400f9144d6d1322e890fb3264" } diff --git a/packages/bytes/package.json b/packages/bytes/package.json index 45ba381c6..c15d6a566 100644 --- a/packages/bytes/package.json +++ b/packages/bytes/package.json @@ -9,7 +9,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/logger": ">5.0.0-beta.0" + "@ethersproject/logger": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -25,5 +25,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x4b7f4f6a34bc4d5c4fe15a01b7c698e8250f828933bb6202248a660d0fb5edfb" + "types": "./lib/index.d.ts", + "tarballHash": "0x11da50922c3e91c2fa195a580699ba92774bc3275a1154309ffcff8dee314c8d" } diff --git a/packages/cli/lib.esm/bin/ethers-ens.js b/packages/cli/lib.esm/bin/ethers-ens.js index f93a9ffad..3ccf99974 100644 --- a/packages/cli/lib.esm/bin/ethers-ens.js +++ b/packages/cli/lib.esm/bin/ethers-ens.js @@ -482,6 +482,10 @@ class SetControllerPlugin extends AddressAccountPlugin { }); return __awaiter(this, void 0, void 0, function* () { yield _super.run.call(this); + this.dump("Set Subnode: " + this.name, { + "Nodehash": this.nodehash, + "Owner": this.address + }); this.getEns().setOwner(this.nodehash, this.address); }); } @@ -514,8 +518,9 @@ class SetSubnodePlugin extends AddressAccountPlugin { return __awaiter(this, void 0, void 0, function* () { yield _super.run.call(this); this.dump("Set Subnode: " + this.name, { - Label: this.label, - Node: this.node + "Label": this.label, + "Node": this.node, + "Owner": this.address }); yield this.getEns().setSubnodeOwner(ethers.utils.namehash(this.node), ethers.utils.id(this.label), this.address); }); @@ -539,8 +544,8 @@ class SetResolverPlugin extends AddressAccountPlugin { return __awaiter(this, void 0, void 0, function* () { yield _super.run.call(this); this.dump("Set Resolver: " + this.name, { - Nodehash: this.nodehash, - Resolver: this.address + "Nodehash": this.nodehash, + "Resolver": this.address }); yield this.getEns().setResolver(this.nodehash, this.address); }); @@ -561,8 +566,8 @@ class SetAddrPlugin extends AddressAccountPlugin { return __awaiter(this, void 0, void 0, function* () { yield _super.run.call(this); this.dump("Set Addr: " + this.name, { - Nodehash: this.nodehash, - Address: this.address + "Nodehash": this.nodehash, + "Address": this.address }); let resolver = yield this.getResolver(this.nodehash); yield resolver.setAddr(this.nodehash, this.address); @@ -804,7 +809,7 @@ class ReclaimPlugin extends AddressAccountPlugin { return __awaiter(this, void 0, void 0, function* () { yield _super.run.call(this); this.dump("Reclaim: " + this.name, { - Nodehash: this.nodehash, + "Nodehash": this.nodehash, "Address": this.address, }); let registrar = yield this.getEthRegistrar(); diff --git a/packages/cli/lib.esm/cli.js b/packages/cli/lib.esm/cli.js index d874295c6..907d0c8ee 100644 --- a/packages/cli/lib.esm/cli.js +++ b/packages/cli/lib.esm/cli.js @@ -187,7 +187,7 @@ class WrappedSigner extends ethers.Signer { } info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); if (tx.nonce != null) { - info["None"] = tx.nonce; + info["Nonce"] = tx.nonce; } info["Data"] = tx.data; info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); @@ -224,7 +224,7 @@ class WrappedSigner extends ethers.Signer { } info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); if (tx.nonce != null) { - info["None"] = tx.nonce; + info["Nonce"] = tx.nonce; } info["Data"] = tx.data; info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); diff --git a/packages/cli/lib/bin/ethers-ens.js b/packages/cli/lib/bin/ethers-ens.js index fac36e839..5568af019 100644 --- a/packages/cli/lib/bin/ethers-ens.js +++ b/packages/cli/lib/bin/ethers-ens.js @@ -750,6 +750,10 @@ var SetControllerPlugin = /** @class */ (function (_super) { case 0: return [4 /*yield*/, _super.prototype.run.call(this)]; case 1: _a.sent(); + this.dump("Set Subnode: " + this.name, { + "Nodehash": this.nodehash, + "Owner": this.address + }); this.getEns().setOwner(this.nodehash, this.address); return [2 /*return*/]; } @@ -801,8 +805,9 @@ var SetSubnodePlugin = /** @class */ (function (_super) { case 1: _a.sent(); this.dump("Set Subnode: " + this.name, { - Label: this.label, - Node: this.node + "Label": this.label, + "Node": this.node, + "Owner": this.address }); return [4 /*yield*/, this.getEns().setSubnodeOwner(ethers_1.ethers.utils.namehash(this.node), ethers_1.ethers.utils.id(this.label), this.address)]; case 2: @@ -837,8 +842,8 @@ var SetResolverPlugin = /** @class */ (function (_super) { case 1: _a.sent(); this.dump("Set Resolver: " + this.name, { - Nodehash: this.nodehash, - Resolver: this.address + "Nodehash": this.nodehash, + "Resolver": this.address }); return [4 /*yield*/, this.getEns().setResolver(this.nodehash, this.address)]; case 2: @@ -871,8 +876,8 @@ var SetAddrPlugin = /** @class */ (function (_super) { case 1: _a.sent(); this.dump("Set Addr: " + this.name, { - Nodehash: this.nodehash, - Address: this.address + "Nodehash": this.nodehash, + "Address": this.address }); return [4 /*yield*/, this.getResolver(this.nodehash)]; case 2: @@ -1256,7 +1261,7 @@ var ReclaimPlugin = /** @class */ (function (_super) { case 1: _a.sent(); this.dump("Reclaim: " + this.name, { - Nodehash: this.nodehash, + "Nodehash": this.nodehash, "Address": this.address, }); return [4 /*yield*/, this.getEthRegistrar()]; diff --git a/packages/cli/lib/cli.js b/packages/cli/lib/cli.js index 7e284bd05..80abc04ca 100644 --- a/packages/cli/lib/cli.js +++ b/packages/cli/lib/cli.js @@ -287,7 +287,7 @@ var WrappedSigner = /** @class */ (function (_super) { } info["Value"] = (ethers_1.ethers.utils.formatEther(tx.value || 0) + " ether"); if (tx.nonce != null) { - info["None"] = tx.nonce; + info["Nonce"] = tx.nonce; } info["Data"] = tx.data; info["Gas Limit"] = ethers_1.ethers.BigNumber.from(tx.gasLimit || 0).toString(); @@ -341,7 +341,7 @@ var WrappedSigner = /** @class */ (function (_super) { } info["Value"] = (ethers_1.ethers.utils.formatEther(tx.value || 0) + " ether"); if (tx.nonce != null) { - info["None"] = tx.nonce; + info["Nonce"] = tx.nonce; } info["Data"] = tx.data; info["Gas Limit"] = ethers_1.ethers.BigNumber.from(tx.gasLimit || 0).toString(); diff --git a/packages/cli/package.json b/packages/cli/package.json index 1e56aab5d..c4fdfefc2 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -13,8 +13,8 @@ }, "dependencies": { "@types/node": "10.3.2", - "@ethersproject/basex": ">=5.0.0-beta.126", - "ethers": ">5.0.0-beta.0", + "@ethersproject/basex": ">=5.0.0-beta.127", + "ethers": ">=5.0.0-beta.156", "mime-types": "2.1.11", "scrypt-js": "2.0.4", "solc": "0.5.10", @@ -35,5 +35,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x047aa677370e57a4c356aa7ca5d3e692038f4863413141cd1f325526c59a4096" + "types": "./lib/index.d.ts", + "tarballHash": "0x045c7d61113b060ecb79426c442a9bcc28c3ed5baebd6c324b8c5ccdd83aa39c" } diff --git a/packages/cli/src.ts/bin/ethers-ens.ts b/packages/cli/src.ts/bin/ethers-ens.ts index dacf9ed94..59e4de410 100644 --- a/packages/cli/src.ts/bin/ethers-ens.ts +++ b/packages/cli/src.ts/bin/ethers-ens.ts @@ -493,6 +493,11 @@ class SetControllerPlugin extends AddressAccountPlugin { async run(): Promise { await super.run(); + this.dump("Set Subnode: " + this.name, { + "Nodehash": this.nodehash, + "Owner": this.address + }); + this.getEns().setOwner(this.nodehash, this.address); } } @@ -522,8 +527,9 @@ class SetSubnodePlugin extends AddressAccountPlugin { await super.run(); this.dump("Set Subnode: " + this.name, { - Label: this.label, - Node: this.node + "Label": this.label, + "Node": this.node, + "Owner": this.address }); await this.getEns().setSubnodeOwner(ethers.utils.namehash(this.node), ethers.utils.id(this.label), this.address); @@ -547,8 +553,8 @@ class SetResolverPlugin extends AddressAccountPlugin { await super.run(); this.dump("Set Resolver: " + this.name, { - Nodehash: this.nodehash, - Resolver: this.address + "Nodehash": this.nodehash, + "Resolver": this.address }); await this.getEns().setResolver(this.nodehash, this.address); @@ -569,8 +575,8 @@ class SetAddrPlugin extends AddressAccountPlugin { await super.run(); this.dump("Set Addr: " + this.name, { - Nodehash: this.nodehash, - Address: this.address + "Nodehash": this.nodehash, + "Address": this.address }); let resolver = await this.getResolver(this.nodehash); @@ -830,7 +836,7 @@ class ReclaimPlugin extends AddressAccountPlugin { await super.run(); this.dump("Reclaim: " + this.name, { - Nodehash: this.nodehash, + "Nodehash": this.nodehash, "Address": this.address, }); diff --git a/packages/cli/src.ts/cli.ts b/packages/cli/src.ts/cli.ts index e255517fe..5125749d7 100644 --- a/packages/cli/src.ts/cli.ts +++ b/packages/cli/src.ts/cli.ts @@ -196,7 +196,7 @@ class WrappedSigner extends ethers.Signer { if (tx.to != null) { info["To"] = tx.to; } if (tx.from != null) { info["From"] = tx.from; } info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); - if (tx.nonce != null) { info["None"] = tx.nonce; } + if (tx.nonce != null) { info["Nonce"] = tx.nonce; } info["Data"] = tx.data; info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); info["Gas Price"] = (ethers.utils.formatUnits(tx.gasPrice || 0, "gwei") + " gwei"), @@ -234,7 +234,7 @@ class WrappedSigner extends ethers.Signer { if (tx.to != null) { info["To"] = tx.to; } if (tx.from != null) { info["From"] = tx.from; } info["Value"] = (ethers.utils.formatEther(tx.value || 0) + " ether"); - if (tx.nonce != null) { info["None"] = tx.nonce; } + if (tx.nonce != null) { info["Nonce"] = tx.nonce; } info["Data"] = tx.data; info["Gas Limit"] = ethers.BigNumber.from(tx.gasLimit || 0).toString(); info["Gas Price"] = (ethers.utils.formatUnits(tx.gasPrice || 0, "gwei") + " gwei"), diff --git a/packages/constants/package.json b/packages/constants/package.json index f60302494..7f8c812cf 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -7,7 +7,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bignumber": ">5.0.0-beta.0" + "@ethersproject/bignumber": ">=5.0.0-beta.130" }, "keywords": [ "Ethereum", @@ -23,5 +23,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x29b69bfc747774d3debf9874b27f05d4c8ea232d709ce955d931d18624a7b0d3" + "types": "./lib/index.d.ts", + "tarballHash": "0xaeb8888de915b16261b73a42af366ff0cb997714c625dd1d01ad7efb06193ada" } diff --git a/packages/contracts/package.json b/packages/contracts/package.json index 1da47f92a..cf8447166 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -7,16 +7,16 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abi": ">5.0.0-beta.0", - "@ethersproject/abstract-provider": ">5.0.0-beta.0", - "@ethersproject/abstract-signer": ">5.0.0-beta.0", - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0" + "@ethersproject/abi": ">=5.0.0-beta.137", + "@ethersproject/abstract-provider": ">=5.0.0-beta.131", + "@ethersproject/abstract-signer": ">=5.0.0-beta.132", + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/transactions": ">=5.0.0-beta.128" }, "keywords": [ "Ethereum", @@ -32,5 +32,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xd9caa174a4d078052aef924411d3175358bd4539b192b625b3ee3a7a9ba9d653" + "types": "./lib/index.d.ts", + "tarballHash": "0x3506d2a5a71c8d884650f4c345468885f236c3bb8446ef6d192f370f78cc402c" } diff --git a/packages/errors/package.json b/packages/errors/package.json index 9df7f005b..eee6ce45a 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -20,5 +20,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x7acbc055896e553d4aa8a18f61197c58d726ef6f44d01a403c323f28ce41330d" + "types": "./lib/index.d.ts", + "tarballHash": "0xa4090df9190530d90a5a187fe1a831fc1e7178285bdfc561791daa8a1095be43" } diff --git a/packages/ethers/dist/ethers.esm.js b/packages/ethers/dist/ethers.esm.js index 7ad598a38..38efbd5c3 100644 --- a/packages/ethers/dist/ethers.esm.js +++ b/packages/ethers/dist/ethers.esm.js @@ -12701,7 +12701,7 @@ class HDNode { result = result._derive(index); } else { - throw new Error("invlaid path component - " + component); + throw new Error("invalid path component - " + component); } } return result; @@ -18672,9 +18672,6 @@ var utils$1 = /*#__PURE__*/Object.freeze({ Indexed: Indexed }); -"use strict"; -const platform = "node"; - const version$l = "ethers/5.0.0-beta.155"; "use strict"; @@ -18697,7 +18694,6 @@ function getDefaultProvider(network, options) { } var ethers = /*#__PURE__*/Object.freeze({ - version: version$l, Signer: Signer, Wallet: Wallet, VoidSigner: VoidSigner, @@ -18712,10 +18708,10 @@ var ethers = /*#__PURE__*/Object.freeze({ logger: logger$z, utils: utils$1, wordlists: browser_2$1, - platform: platform, + version: version$l, Wordlist: browser_1$2 }); "use strict"; -export { BigNumber, Contract, ContractFactory, FixedNumber, Signer, VoidSigner, Wallet, browser_1$2 as Wordlist, index$1 as constants, errors, ethers, getDefaultProvider, logger$z as logger, platform, providers, utils$1 as utils, version$l as version, browser_2$1 as wordlists }; +export { BigNumber, Contract, ContractFactory, FixedNumber, Signer, VoidSigner, Wallet, browser_1$2 as Wordlist, index$1 as constants, errors, ethers, getDefaultProvider, logger$z as logger, providers, utils$1 as utils, version$l as version, browser_2$1 as wordlists }; diff --git a/packages/ethers/dist/ethers.esm.min.js b/packages/ethers/dist/ethers.esm.min.js index 3f4a0dec6..fc94f112f 100644 --- a/packages/ethers/dist/ethers.esm.min.js +++ b/packages/ethers/dist/ethers.esm.min.js @@ -1 +1 @@ -var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),o=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function o(t,e,r){if(o.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var s;"object"==typeof t?t.exports=o:e.BN=o,o.BN=o,o.wordSize=26;try{s=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),o=e;o=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function h(t,e,r,n){for(var i=0,o=Math.min(t.length,r),s=e;s=49?a-49+10:a>=17?a-17+10:a}return i}o.isBN=function(t){return t instanceof o||null!==t&&"object"==typeof t&&t.constructor.wordSize===o.wordSize&&Array.isArray(t.words)},o.max=function(t,e){return t.cmp(e)>0?t:e},o.min=function(t,e){return t.cmp(e)<0?t:e},o.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},o.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[o]|=s<>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,o++);return this.strip()},o.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var o=t.length-r,s=o%n,a=Math.min(o,o-s)+r,l=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],o=0|e.words[0],s=i*o,a=67108863&s,h=s/67108864|0;r.words[0]=a;for(var l=1;l>>26,f=67108863&h,c=Math.min(l,e.length-1),d=Math.max(0,l-t.length+1);d<=c;d++){var p=l-d|0;u+=(s=(i=0|t.words[p])*(o=0|e.words[d])+f)/67108864|0,f=67108863&s}r.words[l]=0|f,h=0|u}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}o.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,o=0,s=0;s>>24-i&16777215)||s!==this.length-1?l[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,s--)}for(0!==o&&(n=o.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=u[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:l[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(t,e){return r(void 0!==s),this.toArrayLike(s,t,e)},o.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},o.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var s,a,h="le"===e,l=new t(o),u=this.clone();if(h){for(a=0;!u.isZero();a++)s=u.andln(255),u.iushrn(8),l[a]=s;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},o.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},o.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},o.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},o.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},o.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},o.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},o.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},o.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},o.prototype.notn=function(t){return this.clone().inotn(t)},o.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ot.length?this.clone().iadd(t):t.clone().iadd(this)},o.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var o=0,s=0;s>26,this.words[s]=67108863&e;for(;0!==o&&s>26,this.words[s]=67108863&e;if(0===o&&s>>13,d=0|s[1],p=8191&d,m=d>>>13,g=0|s[2],y=8191&g,v=g>>>13,b=0|s[3],w=8191&b,E=b>>>13,_=0|s[4],A=8191&_,S=_>>>13,M=0|s[5],k=8191&M,P=M>>>13,x=0|s[6],T=8191&x,N=x>>>13,I=0|s[7],R=8191&I,C=I>>>13,B=0|s[8],O=8191&B,F=B>>>13,D=0|s[9],L=8191&D,U=D>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],ot=8191&it,st=it>>>13,at=0|a[7],ht=8191&at,lt=at>>>13,ut=0|a[8],ft=8191&ut,ct=ut>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;l=((o=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,o=Math.imul(m,H);var yt=(l+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;l=((o=o+Math.imul(c,G)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,H))+Math.imul(v,j)|0,o=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,o=o+Math.imul(m,G)|0;var vt=(l+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;l=((o=o+Math.imul(c,J)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(E,j)|0,o=Math.imul(E,H),n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(v,K)|0,o=o+Math.imul(v,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var bt=(l+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;l=((o=o+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,H))+Math.imul(S,j)|0,o=Math.imul(S,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,K)|0,o=o+Math.imul(E,G)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var wt=(l+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;l=((o=o+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(P,j)|0,o=Math.imul(P,H),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,K)|0,o=o+Math.imul(S,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(E,V)|0,o=o+Math.imul(E,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,tt)|0;var Et=(l+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;l=((o=o+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(T,j),i=(i=Math.imul(T,H))+Math.imul(N,j)|0,o=Math.imul(N,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,G)|0,n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(S,V)|0,o=o+Math.imul(S,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,X)|0,o=o+Math.imul(E,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,o=o+Math.imul(m,nt)|0;var _t=(l+(n=n+Math.imul(f,ot)|0)|0)+((8191&(i=(i=i+Math.imul(f,st)|0)+Math.imul(c,ot)|0))<<13)|0;l=((o=o+Math.imul(c,st)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(C,j)|0,o=Math.imul(C,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(N,K)|0,o=o+Math.imul(N,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(P,V)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(S,X)|0,o=o+Math.imul(S,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Y)|0,o=o+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,o=o+Math.imul(v,nt)|0,n=n+Math.imul(p,ot)|0,i=(i=i+Math.imul(p,st)|0)+Math.imul(m,ot)|0,o=o+Math.imul(m,st)|0;var At=(l+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(c,ht)|0))<<13)|0;l=((o=o+Math.imul(c,lt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,o=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,G)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(P,X)|0,o=o+Math.imul(P,$)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,Y)|0,o=o+Math.imul(S,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,o=o+Math.imul(E,nt)|0,n=n+Math.imul(y,ot)|0,i=(i=i+Math.imul(y,st)|0)+Math.imul(v,ot)|0,o=o+Math.imul(v,st)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,o=o+Math.imul(m,lt)|0;var St=(l+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;l=((o=o+Math.imul(c,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,H))+Math.imul(U,j)|0,o=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,o=o+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(P,Y)|0,o=o+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,o=o+Math.imul(S,nt)|0,n=n+Math.imul(w,ot)|0,i=(i=i+Math.imul(w,st)|0)+Math.imul(E,ot)|0,o=o+Math.imul(E,st)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,o=o+Math.imul(v,lt)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,o=o+Math.imul(m,ct)|0;var Mt=(l+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((o=o+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,G))+Math.imul(U,K)|0,o=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(P,rt)|0,o=o+Math.imul(P,nt)|0,n=n+Math.imul(A,ot)|0,i=(i=i+Math.imul(A,st)|0)+Math.imul(S,ot)|0,o=o+Math.imul(S,st)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(E,ht)|0,o=o+Math.imul(E,lt)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,o=o+Math.imul(v,ct)|0;var kt=(l+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((o=o+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,J))+Math.imul(U,V)|0,o=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(N,rt)|0,o=o+Math.imul(N,nt)|0,n=n+Math.imul(k,ot)|0,i=(i=i+Math.imul(k,st)|0)+Math.imul(P,ot)|0,o=o+Math.imul(P,st)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,o=o+Math.imul(S,lt)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(E,ft)|0,o=o+Math.imul(E,ct)|0;var Pt=(l+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((o=o+Math.imul(v,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,$))+Math.imul(U,X)|0,o=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,o=o+Math.imul(C,nt)|0,n=n+Math.imul(T,ot)|0,i=(i=i+Math.imul(T,st)|0)+Math.imul(N,ot)|0,o=o+Math.imul(N,st)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(P,ht)|0,o=o+Math.imul(P,lt)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(S,ft)|0,o=o+Math.imul(S,ct)|0;var xt=(l+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((o=o+Math.imul(E,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,tt))+Math.imul(U,Y)|0,o=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,o=o+Math.imul(F,nt)|0,n=n+Math.imul(R,ot)|0,i=(i=i+Math.imul(R,st)|0)+Math.imul(C,ot)|0,o=o+Math.imul(C,st)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(N,ht)|0,o=o+Math.imul(N,lt)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(P,ft)|0,o=o+Math.imul(P,ct)|0;var Tt=(l+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((o=o+Math.imul(S,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul(U,rt)|0,o=Math.imul(U,nt),n=n+Math.imul(O,ot)|0,i=(i=i+Math.imul(O,st)|0)+Math.imul(F,ot)|0,o=o+Math.imul(F,st)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,o=o+Math.imul(C,lt)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(N,ft)|0,o=o+Math.imul(N,ct)|0;var Nt=(l+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((o=o+Math.imul(P,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,ot),i=(i=Math.imul(L,st))+Math.imul(U,ot)|0,o=Math.imul(U,st),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(F,ht)|0,o=o+Math.imul(F,lt)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(C,ft)|0,o=o+Math.imul(C,ct)|0;var It=(l+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((o=o+Math.imul(N,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,lt))+Math.imul(U,ht)|0,o=Math.imul(U,lt),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,o=o+Math.imul(F,ct)|0;var Rt=(l+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(C,pt)|0))<<13)|0;l=((o=o+Math.imul(C,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul(U,ft)|0,o=Math.imul(U,ct);var Ct=(l+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;l=((o=o+Math.imul(F,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(l+(n=Math.imul(L,pt))|0)+((8191&(i=(i=Math.imul(L,mt))+Math.imul(U,pt)|0))<<13)|0;return l=((o=Math.imul(U,mt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Et,h[6]=_t,h[7]=At,h[8]=St,h[9]=Mt,h[10]=kt,h[11]=Pt,h[12]=xt,h[13]=Tt,h[14]=Nt,h[15]=It,h[16]=Rt,h[17]=Ct,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),o.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,s&=67108863}r.words[o]=a,n=s,s=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=o.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,o){for(var s=0;s>>=1)i++;return 1<>>=13,n[2*s+1]=8191&o,o>>>=13;for(s=2*e;s>=26,e+=i/67108864|0,e+=o>>>26,this.words[n]=67108863&o}return 0!==e&&(this.words[n]=e,this.length++),this},o.prototype.muln=function(t){return this.clone().imuln(t)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new o(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(e=0;e>>26-n}s&&(this.words[e]=s,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var o=t%26,s=Math.min((t-o)/26,this.length),a=67108863^67108863>>>o<s)for(this.length-=s,l=0;l=0&&(0!==u||l>=i);l--){var f=0|this.words[l];this.words[l]=u<<26-o|f>>>o,u=f&a}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},o.prototype.shln=function(t){return this.clone().ishln(t)},o.prototype.ushln=function(t){return this.clone().iushln(t)},o.prototype.shrn=function(t){return this.clone().ishrn(t)},o.prototype.ushrn=function(t){return this.clone().iushrn(t)},o.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},o.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,s=0|i.words[i.length-1];0!==(r=26-this._countBits(s))&&(i=i.ushln(r),n.iushln(r),s=0|i.words[i.length-1]);var a,h=n.length-i.length;if("mod"!==e){(a=new o(null)).length=h+1,a.words=new Array(a.length);for(var l=0;l=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/s|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},o.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.iadd(t)),{div:i,mod:s}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(s=a.mod.neg(),n&&0!==s.negative&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new o(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new o(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new o(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,s,a},o.prototype.div=function(t){return this.divmod(t,"div",!1).div},o.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},o.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},o.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},o.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},o.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},o.prototype.divn=function(t){return this.clone().idivn(t)},o.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new o(1),s=new o(0),a=new o(0),h=new o(1),l=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++l;for(var u=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||s.isOdd())&&(i.iadd(u),s.isub(f)),i.iushrn(1),s.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(u),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),s.isub(h)):(n.isub(e),a.isub(i),h.isub(s))}return{a:a,b:h,gcd:n.iushln(l)}},o.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,s=new o(1),a=new o(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var l=0,u=1;0==(e.words[0]&u)&&l<26;++l,u<<=1);if(l>0)for(e.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(h),s.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),s.isub(a)):(n.isub(e),a.isub(s))}return(i=0===e.cmpn(1)?s:a).cmpn(0)<0&&i.iadd(t),i},o.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var o=e;e=r,r=o}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},o.prototype.invm=function(t){return this.egcd(t).a.umod(t)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(t){return this.words[0]&t},o.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[s]=a}return 0!==o&&(this.words[s]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},o.prototype.gtn=function(t){return 1===this.cmpn(t)},o.prototype.gt=function(t){return 1===this.cmp(t)},o.prototype.gten=function(t){return this.cmpn(t)>=0},o.prototype.gte=function(t){return this.cmp(t)>=0},o.prototype.ltn=function(t){return-1===this.cmpn(t)},o.prototype.lt=function(t){return-1===this.cmp(t)},o.prototype.lten=function(t){return this.cmpn(t)<=0},o.prototype.lte=function(t){return this.cmp(t)<=0},o.prototype.eqn=function(t){return 0===this.cmpn(t)},o.prototype.eq=function(t){return 0===this.cmp(t)},o.red=function(t){return new _(t)},o.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(t){return this.red=t,this},o.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},o.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},o.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},o.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},o.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},o.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},o.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},o.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new o(e,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=o._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new o(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=o}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},o._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new o(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),s=0;!i.isZero()&&0===i.andln(1);)s++,i.iushrn(1);r(!i.isZero());var a=new o(1).toRed(this),h=a.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new o(2*u*u).toRed(this);0!==this.pow(u,l).cmp(h);)u.redIAdd(h);for(var f=this.pow(u,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=s;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var l=e.words[n],u=h-1;u>=0;u--){var f=l>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==s?(s<<=1,s|=f,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[s]),a=0,s=0)):a=0}h=26}return i},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},o.mont=function(t){return new A(t)},n(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new o(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),s=o.BN;const a="logger/5.0.0-beta.128";let h=!1,l=!1;const u={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=u.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=u[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>u[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(l)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let o=new Error(t);return o.reason=i,o.code=e,Object.keys(r).forEach(function(t){o[t]=r[t]}),o}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(h){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}l=!!t,h=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.128");function y(t){return!!t.toHexString}function v(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return v(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function E(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),v(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;tE(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),v(n)}function A(t){let e=E(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),v(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function P(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function x(t){if("string"!=typeof t)t=P(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function T(t,e,r){return"string"!=typeof t?t=P(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function N(t){let e=I(P(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=P(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function C(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=E(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=P(r.slice(0,32)),e.s=P(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=P(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=E(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let o=P(r);null==e.s?e.s=o:e.s!==o&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=E(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=P(r)}}return e}function B(t){return P(_([(t=C(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:E,concat:_,stripZeros:A,zeroPad:S,isHexString:M,hexlify:P,hexDataLength:x,hexDataSlice:T,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=P(t).substring(2)}),e},hexValue:N,hexStripZeros:I,hexZeroPad:R,splitSignature:C,joinSignature:B});const F=new p("bignumber/5.0.0-beta.129"),D={},L=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==D&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(D,z(t)):t.match(/^-?[0-9]+$/)?new U(D,z(new s(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=L||t<=-L)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(P(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new s("-"+e.substring(3),16):new s(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.129"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let o=i[0],s=i[1];for(o||(o="0"),s||(s="0"),s.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");s.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let o=$(n,r.decimals);return new tt(G,i,o,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(E(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),o=$(n,r.decimals);return new tt(G,i,o,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.130");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function ot(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function st(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ht(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ht(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ht(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class lt{constructor(t){for(let e in t)this[e]=ht(t[e]);Object.freeze(this)}}var ut=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:ot,shallowCopy:st,deepCopy:ht,Description:lt});const ft="abi/5.0.0-beta.136",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const yt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(vt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==yt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===yt.full?", ":",")+")"):e+=this.type,t!==yt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===yt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:xt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let o={type:"",name:"",state:{allowType:!0}},s=o;for(let r=0;rbt.fromString(t,e))}class Et{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return Et.isFragment(t)?t:"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){return Et.isFragment(t)?t:"function"===t.type?Pt.fromObject(t):"event"===t.type?_t.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return _t.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return Pt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class _t extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){if(_t.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new _t(dt,{name:Nt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),_t.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function At(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function St(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===yt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=At(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),St(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Pt extends kt{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Pt.fromString(t):Pt.fromObject(t)}static fromObject(t){if(Pt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new Pt(dt,{type:t.type,name:Nt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=At(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Tt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),St(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return Pt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function xt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Tt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Nt(t){if(!t||!t.match(Tt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Ct{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Bt{constructor(t){rt(this,"wordSize",t||32),this._data=E([]),this._padding=new Uint8Array(t)}get data(){return P(this._data)}get length(){return this._data.length}_writeData(t){return this._data=_([this._data,t]),t.length}writeBytes(t){let e=E(t);return e.length%this.wordSize&&(e=_([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=E(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=_([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",E(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return P(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],s=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],h=["hex","buffer","arrayBuffer","array"],l=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},u=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=l(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,s=this.blocks,a=this.byteCount,h=this.blockCount,l=0,u=this.s;l>2]|=t[l]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(s[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=s[h],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(E(r),s=0)}return o&&(t=r[s],o>0&&(h+=i[t>>4&15]+i[15&t]),o>1&&(h+=i[t>>12&15]+i[t>>8&15]),o>2&&(h+=i[t>>20&15]+i[t>>16&15])),h},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,s=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);s>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&E(n)}return o&&(t=a<<2,e=n[s],o>0&&(h[t]=255&e),o>1&&(h[t+1]=e>>8&255),o>2&&(h[t+2]=e>>16&255)),h};var E=function(t){var e,r,n,i,o,a,h,l,u,f,c,d,p,m,g,y,v,b,w,E,_,A,S,M,k,P,x,T,N,I,R,C,B,O,F,D,L,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,ot,st,at,ht,lt,ut;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],o=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],h=t[3]^t[13]^t[23]^t[33]^t[43],l=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|h>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(h<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(l<<1|u>>>31),r=o^(u<<1|l>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=h^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=l^(d<<1|p>>>31),r=u^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|o>>>31),r=c^(o<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,T=t[20]<<3|t[21]>>>29,N=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,lt=t[42]<<2|t[43]>>>30,ut=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,L=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,B=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,E=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,P=t[18]<<20|t[19]>>>12,x=t[19]<<20|t[18]>>>12,ot=t[29]<<7|t[28]>>>25,st=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,A=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=m^~y&b,t[1]=g^~v&w,t[10]=M^~P&T,t[11]=k^~x&N,t[20]=O^~D&U,t[21]=F^~L&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&ot,t[41]=rt^~it&st,t[2]=y^~b&E,t[3]=v^~w&_,t[12]=P^~T&I,t[13]=x^~N&R,t[22]=D^~U&j,t[23]=L^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~ot&at,t[43]=it^~st&ht,t[4]=b^~E&A,t[5]=w^~_&S,t[14]=T^~I&C,t[15]=N^~R&B,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=ot^~at<,t[45]=st^~ht&ut,t[6]=E^~A&m,t[7]=_^~S&g,t[16]=I^~C&M,t[17]=R^~B&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~lt&et,t[47]=ht^~ut&rt,t[8]=A^~m&y,t[9]=S^~g&v,t[18]=C^~M&P,t[19]=B^~k&x,t[28]=q^~O&D,t[29]=K^~F&L,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=lt^~et&nt,t[49]=ut^~rt&it,t[0]^=s[n],t[1]^=s[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:P(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:P(t.slice(e+1,e+1+r))}}return{consumed:1,result:P(t[e])}}function qt(t){let e=E(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.127");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=E(Dt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new s(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(T(Dt(zt([e,A(E(t.nonce))])),12))}class Yt extends Ct{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Ct{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Bt(t.wordSize),i=new Bt(t.wordSize),o=[];e.forEach((t,e)=>{let s=r[e];if(t.dynamic){let e=i.length;t.encode(i,s);let r=n.writeUpdatableValue();o.push(t=>{r(t+e)})}else t.encode(n,s)}),o.forEach(t=>{t(n.length)});let s=t.writeBytes(n.data);return s+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let o=null;if(e.dynamic){let r=t.readValue(),s=n.subReader(r.toNumber());o=e.decode(s),i+=s.consumed}else o=e.decode(t);null!=o&&r.push(o)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Ct{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let o=null,s=null;if(192==(224&i))o=1,s=127;else if(224==(240&i))o=2,s=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,s=65535}if(n+o>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-o-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Ae(t,e=Ee.current){e!=Ee.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return E(r)}function Se(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(_e(t,e))}function Pe(t,e=Ee.current){return _e(Ae(t,e))}function xe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Te(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Ne(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ee||(Ee={}));const Ie=Te("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Ce=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Be=xe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=xe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=xe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ne(t,Ce);if(e)return[t+e.s];let r=Be[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=Pe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),Ee.NFKC)).forEach(t=>{if(function(t){return!!Ne(t,De)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Ne(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends se{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Ae(e))}decode(t){return ke(super.decode(t))}}class ze extends Ct{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new oe(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new le(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new he(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Bt(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(E(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.127"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;tEt.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return T($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?sr(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[Pt.fromString(t).format()]}getEvent(t){return M(t)?sr(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[_t.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),P(_([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=E(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===P(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Dt(P(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(P(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],o=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))});let s=null!=r?this._abiCoder.decode(n,_(r)):null,a=this._abiCoder.decode(i,e),h=[],l=0,u=0;return t.inputs.forEach((t,e)=>{t.indexed?null==s?h[e]=new ir({_isIndexed:!0,hash:null}):o[e]?h[e]=new ir({_isIndexed:!0,hash:s[u++]}):h[e]=s[u++]:h[e]=a[l++]}),h}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function sr(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.130");class hr extends lt{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class lr{addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}constructor(){ar.checkAbstract(new.target,lr),rt(this,"_isProvider",!0)}static isProvider(t){return!(!t||!t._isProvider)}}const ur=new p("abstract-signer/5.0.0-beta.131"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){ur.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&ur.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=st(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&ur.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{ur.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||ur.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){ur.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ur.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.136"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function yr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},o=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=st(e.pop())).blockTag&&(o=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(o).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,o).then(r=>{try{let o=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(o=o[0]),o}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ht(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function vr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class Er extends br{constructor(t,e,r,n){let i={address:t},o=e.getEventTopic(r);n?(o!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[o],super(vr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class _r extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Ar{constructor(t,e,r){if(pr.checkNew(new.target,Ar),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):lr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=yr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,yr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,yr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,yr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return or.isInterface(t)?t:new or(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=st(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new _r(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new Er(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new Er(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(vr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ht(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=st(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Sr{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?P(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=st(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=P(_([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Ar.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Ar(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Cr={inherits:Tr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,s=255&i;o?r.push(o,s):r.push(s)}else for(n=0;n>>0}return o},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],o=n+t[e+1]>>>0,s=(o>>0,t[e+1]=o},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,o,s,a){var h=0,l=e;return h+=(l=l+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,o,s,a){return e+n+o+a>>>0},sum64_5_hi:function(t,e,r,n,i,o,s,a,h,l){var u=0,f=e;return u+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,o,s,a,h,l){return e+n+o+a+l>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Br(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Br;Br.prototype.update=function(t,e){if(t=Cr.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Cr.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(t){return Dr(t,17)^Dr(t,19)^t>>>10}},Hr=Cr.sum32,qr=Cr.sum32_4,Kr=Cr.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Cr.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),Pr(t.length<=this.blockSize);for(var e=t.length;e>24&255,u[e.length+1]=f>>16&255,u[e.length+2]=f>>8&255,u[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,u));o||(o=c.length,a=new Uint8Array(o),s=n-((h=Math.ceil(n/o))-1)*o),a.set(c);for(var d=1;d>8,s=255&i;o?r.push(o,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),oi=r(function(t,e){var r=e;r.assert=Pr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var s=i.andln(n-1);o=s>(n>>1)-1?(n>>1)-s:s,i.isubn(o)}else o=0;r.push(o);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,h=1;h0||e.cmpn(-i)>0;){var o,s,a,h=t.andln(3)+n&3,l=e.andln(3)+i&3;if(3===h&&(h=-1),3===l&&(l=-1),0==(1&h))o=0;else o=3!==(a=t.andln(7)+n&7)&&5!==a||2!==l?h:-h;if(r[0].push(o),0==(1&l))s=0;else s=3!==(a=e.andln(7)+i&7)&&5!==a||2!==h?l:-l;r[1].push(s),2*n===o+1&&(n=1-n),2*i===s+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new o(t,"hex","le")}}),si=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=oi.getNAF,hi=oi.getJSF,li=oi.assert;function ui(t,e){this.type=t,this.p=new o(e.p,16),this.red=e.prime?o.red(e.prime):o.mont(this.p),this.zero=new o(0).toRed(this.red),this.one=new o(1).toRed(this.red),this.two=new o(2).toRed(this.red),this.n=e.n&&new o(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=ui;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}ui.prototype.point=function(){throw new Error("Not implemented")},ui.prototype.validate=function(){throw new Error("Not implemented")},ui.prototype._fixedNafMul=function(t,e){li(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=s;e--)a=(a<<1)+n[e];o.push(a)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),u=i;u>0;u--){for(s=0;s=0;a--){for(e=0;a>=0&&0===o[a];a--)e++;if(a>=0&&e++,s=s.dblp(e),a<0)break;var h=o[a];li(0!==h),s="affine"===t.type?h>0?s.mixedAdd(i[h-1>>1]):s.mixedAdd(i[-h-1>>1].neg()):h>0?s.add(i[h-1>>1]):s.add(i[-h-1>>1].neg())}return"affine"===t.type?s.toP():s},ui.prototype._wnafMulAdd=function(t,e,r,n,i){for(var o=this._wnafT1,s=this._wnafT2,a=this._wnafT3,h=0,l=0;l=1;l-=2){var f=l-1,c=l;if(1===o[f]&&1===o[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=hi(r[f],r[c]);h=Math.max(m[0].length,h),a[f]=new Array(h),a[c]=new Array(h);for(var g=0;g=0;l--){for(var E=0;l>=0;){var _=!0;for(g=0;g=0&&E++,b=b.dblp(E),l<0)break;for(g=0;g0?A=s[g][S-1>>1]:S<0&&(A=s[g][-S-1>>1].neg()),b="affine"===A.type?b.mixedAdd(A):b.add(A))}}for(l=0;l=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(s=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:i},{a:s,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),o=r.b.neg().mul(t).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),h=i.mul(r.b),l=o.mul(n.b);return{k1:t.sub(s).sub(a),k2:h.add(l).neg()}},pi.prototype.pointFromX=function(t,e){(t=new o(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new o(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Tr(yi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new yi(this,t,e,r)},yi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},yi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},yi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),o=this.y.redMul(e.redMul(t.z)),s=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=o.redSub(s);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),f=n.redMul(l),c=h.redSqr().redIAdd(u).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(o.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},yi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,o=t.y.redMul(e).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=s.redSqr(),l=h.redMul(s),u=r.redMul(h),f=a.redSqr().redIAdd(l).redISub(u).redISub(u),c=a.redMul(u.redISub(f)).redISub(i.redMul(l)),d=this.z.redMul(s);return this.curve.jpoint(f,c,d)},yi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},yi.prototype.inspect=function(){return this.isInfinity()?"":""},yi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var vi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=vi,r.edwards=bi}),Ei=r(function(t,e){var r,n=e,i=oi.assert;function o(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function s(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new o(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,s("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),s("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),s("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),s("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),s("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),s("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),s("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}s("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");Pr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Ai=_i;_i.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},_i.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Pi=oi.assert;function xi(t,e){if(t instanceof xi)return t;this._importDER(t,e)||(Pi(t.r&&t.s,"Signature without r or s"),this.r=new o(t.r,16),this.s=new o(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ti=xi;function Ni(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,s=e.place;o>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xi.prototype._importDER=function(t,e){t=oi.toArray(t,e);var r=new Ni;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var s=Ii(t,r);if(t.length!==s+r.place)return!1;var a=t.slice(r.place,s+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new o(i),this.s=new o(a),this.recoveryParam=null,!0},xi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Ci(n,e.length),(n=n.concat(e)).push(2),Ci(n,r.length);var i=n.concat(r),o=[48];return Ci(o,i.length),o=o.concat(i),oi.encode(o,t)};var Bi=oi.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Bi(Ei.hasOwnProperty(t),"Unknown curve "+t),t=Ei[t]),t instanceof Ei.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ai({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||si(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new o(2));;){var i=new o(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new o(t,16));for(var i=this.n.byteLength(),s=e.getPrivate().toArray("be",i),a=t.toArray("be",i),h=new Ai({hash:this.hash,entropy:s,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new o(1)),u=0;;u++){var f=n.k?n.k(u):new o(h.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(l)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ti({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new o(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ti(e,"hex")).r,s=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(s.cmpn(1)<0||s.cmp(this.n)>=0)return!1;var a,h=s.invm(this.n),l=h.mul(t).umod(this.n),u=h.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(l,r.getPublic(),u)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(l,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Bi((3&r)===r,"The recovery param is more than two bits"),e=new Ti(e,n);var i=this.n,s=new o(t),a=e.r,h=e.s,l=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var f=e.r.invm(i),c=i.sub(s).mul(f).umod(i),d=h.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ti(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(t,e,i)}catch(t){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Di={},Li=n(ni),Ui=r(function(t,e){var r=e;r.version=Li.version,r.utils=oi,r.rand=si,r.curve=wi,r.curves=Ei,r.ec=Fi,r.eddsa=Di}).ec;const zi=new p("signing-key/5.0.0-beta.128");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",P(t));let e=Hi().keyFromPrivate(E(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(E(this.publicKey)),r=Hi().keyFromPublic(E(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(E(this.privateKey)).sign(E(t),{canonical:!0});return C({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(E(this.privateKey)),r=Hi().keyFromPublic(E(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=C(e),n={r:E(r.r),s:E(r.s)};return"0x"+Hi().recoverPubKey(E(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=E(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?P(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):P(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.127");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(T(Dt(T(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(E(t),e))}function Qi(t,e){ot(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=E(P(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=A(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(P(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(P(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=C(e),o=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),o+=2*t.chainId+8),r.push(P(o)),r.push(A(E(i.r))),r.push(A(E(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(P(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let o=Dt(zt(i));try{r.from=$i(o,{r:P(r.r),s:P(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Dt(t)}return r}var to=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.127"}),eo=(e(to),to.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(to.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var o=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),ut.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||ut.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||ut.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||ut.defineReadOnly(i.ethers.wordlists,r,e))}}})),ro=(e(eo),eo.check,eo.Wordlist,eo.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",s=null;function a(t){if(null==s&&(s=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==eo.check(t)))throw s=null,new Error("BIP39 Wordlist for en (English) FAILED")}var h=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),s[t]},e.prototype.getWordIndex=function(t){return a(this),s.indexOf(t)},e}(eo.Wordlist));r.langEn=h,eo.register(h)})),no=(e(ro),ro.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=eo.Wordlist;var r={en:ro.langEn};e.wordlists=r})),io=(e(no),no.Wordlist),oo=no.wordlists;const so=new p("hdnode/5.0.0-beta.129"),ao=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ho=Ae("Bitcoin seed"),lo=2147483648;function uo(t){return(1<=256)throw new Error("Depth too large!");return co(_([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",P(this.depth),this.parentFingerprint,R(P(this.index),4),this.chainCode,null!=this.privateKey?_(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new go(po,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~lo));let r=new Uint8Array(37);if(t&lo){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(E(this.privateKey),1),e&&(e+="'")}else r.set(E(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=E(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),o=n.slice(32),s=null,a=null;if(this.privateKey)s=fo(U.from(i).add(this.privateKey).mod(ao));else{a=new qi(P(i))._addPoint(this.publicKey)}return new go(po,s,a,this.fingerprint,fo(o),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=lo)throw new Error("invalid path index - "+n);r=r._derive(lo+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invlaid path component - "+n);{let t=parseInt(n);if(t>=lo)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=E(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=E(Yn(Xn.sha512,ho,r));return new go(po,fo(n.slice(0,32)),null,"0x00000000",fo(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=bo(vo(t,r),r),go._fromSeed(yo(t,e),t)}static fromSeed(t){return go._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&co(e.slice(0,78))===t||so.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=P(e.slice(5,9)),i=parseInt(P(e.slice(9,13)).substring(2),16),o=P(e.slice(13,45)),s=e.slice(45,78);switch(P(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new go(po,null,P(s),n,o,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==s[0])break;return new go(po,P(s.slice(1)),null,n,o,i,r,null,null)}return so.throwError("invalid extended key","extendedKey","[REDACTED]")}}function yo(t,e){e||(e="");let r=Ae("mnemonic"+e,Ee.NFKD);return ei(Ae(t,Ee.NFKD),r,2048,64,"sha512")}function vo(t,e){e||(e=oo.en),so.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=E(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let o=32*r.length/3,s=uo(r.length/3),a=E(Qn(n.slice(0,o/8)))[0];if((a&=s)!==(n[n.length-1]&s))throw new Error("invalid checksum");return P(n.slice(0,o/8))}function bo(t,e){if((t=E(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=E(Qn(t))[0],o=t.length/4;return i&=uo(o),r[r.length-1]<<=o,r[r.length-1]|=i>>8-o,e||(e=oo.en),e.join(r.map(t=>e.getWord(t)))}var wo=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.127"}),Eo=(e(wo),wo.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),_o=(e(Eo),Eo.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(wo.version);r.shuffled=Eo.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),Ao=(e(_o),_o.shuffled),So=_o.randomBytes,Mo=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function o(t){return new Uint8Array(t)}function s(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,h={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},l=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),u={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],_=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],A=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=o[e],this._Kd[t-r][e%4]=o[e];for(var s,a=0,h=i;h>16&255]<<24^c[s>>8&255]<<16^c[255&s]<<8^c[s>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[s>>16&255]<<16^c[s>>24&255]<<24;for(e=i/2+1;e>2,d=h%4,this._Ke[l][d]=o[e],this._Kd[t-l][d]=o[e++],h++}for(var l=1;l>24&255]^A[s>>16&255]^S[s>>8&255]^M[255&s]},P.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var s=1;s>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[s][i];n=r.slice()}var a,h=o(16);for(i=0;i<4;i++)a=this._Ke[e][i],h[4*i]=255&(c[n[i]>>24&255]^a>>24),h[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),h[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return h},P.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var s=1;s>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^E[255&n[(i+1)%4]]^this._Kd[s][i];n=r.slice()}var a,h=o(16);for(i=0;i<4;i++)a=this._Kd[e][i],h[4*i]=255&(d[n[i]>>24&255]^a>>24),h[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),h[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return h};var x=function(t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new P(t)};x.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=o(t.length),r=o(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var C=function(t,e){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new P(t)};C.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,E=o,_=s,A=a,S=h,M=l;for(p=0;p<16;p++)m=f+4*p,u[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=u[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=u[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,u[p]=(g+u[p-7]|0)+(y+u[p-16]|0)|0;for(p=0;p<64;p++)g=(((_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&A^~_&S)|0)+(M+(e[p]+u[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,M=S,S=A,A=_,_=E+g|0,E=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+E|0,s=s+_|0,a=a+A|0,h=h+S|0,l=l+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,y=t.slice(t.length-d,t.length);for(y.push(128),c=d+1;c>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255,l>>>24&255,l>>>16&255,l>>>8&255,l>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var o=64+e.length+4,s=new Array(o),a=new Array(64),h=[];for(i=0;i<64;i++)s[i]=54;for(i=0;i=o-4;t--){if(s[t]++,s[t]<=255)return;s[t]=0}}for(;r>=32;)l(),h=h.concat(n(a.concat(n(s)))),r-=32;return r>0&&(l(),h=h.concat(n(a.concat(n(s))).slice(0,r))),h}function o(t,e,r,n,i){var o;for(l(t,16*(2*r-1),i,0,16),o=0;o<2*r;o++)h(t,16*o,i,16),a(i,n),l(i,0,t,e+16*o,16);for(o=0;o>>32-e}function a(t,e){l(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=s(e[0]+e[12],7),e[8]^=s(e[4]+e[0],9),e[12]^=s(e[8]+e[4],13),e[0]^=s(e[12]+e[8],18),e[9]^=s(e[5]+e[1],7),e[13]^=s(e[9]+e[5],9),e[1]^=s(e[13]+e[9],13),e[5]^=s(e[1]+e[13],18),e[14]^=s(e[10]+e[6],7),e[2]^=s(e[14]+e[10],9),e[6]^=s(e[2]+e[14],13),e[10]^=s(e[6]+e[2],18),e[3]^=s(e[15]+e[11],7),e[7]^=s(e[3]+e[15],9),e[11]^=s(e[7]+e[3],13),e[15]^=s(e[11]+e[7],18),e[1]^=s(e[0]+e[3],7),e[2]^=s(e[1]+e[0],9),e[3]^=s(e[2]+e[1],13),e[0]^=s(e[3]+e[2],18),e[6]^=s(e[5]+e[4],7),e[7]^=s(e[6]+e[5],9),e[4]^=s(e[7]+e[6],13),e[5]^=s(e[4]+e[7],18),e[11]^=s(e[10]+e[9],7),e[8]^=s(e[11]+e[10],9),e[9]^=s(e[8]+e[11],13),e[10]^=s(e[9]+e[8],18),e[12]^=s(e[15]+e[14],7),e[13]^=s(e[12]+e[15],9),e[14]^=s(e[13]+e[12],13),e[15]^=s(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function h(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,s,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),s=f(s,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/s)throw new Error("N too large");if(s>r/128/a)throw new Error("r too large");if(!u(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!u(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*s),m=new Uint32Array(32*a*s),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(C)};C()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Fo=new Uint8Array(16);Bo=function(){return crypto.getRandomValues(Fo),Fo}}if(!Bo){var Do=new Array(16);Bo=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Do[e]=t>>>((3&e)<<3)&255;return Do}}for(var Lo=Bo,Uo=[],zo={},jo=0;jo<256;jo++)Uo[jo]=(jo+256).toString(16).substr(1),zo[Uo[jo]]=jo;function Ho(t,e){var r=e||0,n=Uo;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var qo=Lo(),Ko=[1|qo[0],qo[1],qo[2],qo[3],qo[4],qo[5]],Go=16383&(qo[6]<<8|qo[7]),Wo=0,Vo=0;function Jo(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Lo)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var o=0;o<16;o++)e[n+o]=i[o];return e||Ho(i)}var Zo=Jo;Zo.v1=function(t,e,r){var n=e&&r||0,i=e||[],o=void 0!==(t=t||{}).clockseq?t.clockseq:Go,s=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Vo+1,h=s-Wo+(a-Vo)/1e4;if(h<0&&void 0===t.clockseq&&(o=o+1&16383),(h<0||s>Wo)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Wo=s,Vo=a,Go=o;var l=(1e4*(268435455&(s+=122192928e5))+a)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var u=s/4294967296*1e4&268435455;i[n++]=u>>>8&255,i[n++]=255&u,i[n++]=u>>>24&15|16,i[n++]=u>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var f=t.node||Ko,c=0;c<6;c++)i[n+c]=f[c];return e||Ho(i)},Zo.v4=Jo,Zo.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=zo[t])});i<16;)e[n+i++]=0;return e},Zo.unparse=Ho;var Xo=Zo;class $o extends lt{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function Qo(t,e,r){let n=JSON.parse(t),i=xo(e),o=function(t,e){let r=ko(To(n,"crypto/ciphertext"));if(P(function(t,e){return Dt(_([t,e]))}(t.slice(16,32),r)).substring(2)!==To(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===To(n,"crypto/cipher")){let r=ko(To(n,"crypto/cipherparams/iv")),i=new Mo.Counter(r);return E(new Mo.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),o=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let s=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==s)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:s,privateKey:P(i)};if("0.1"===To(n,"x-ethers/version")){let t=ko(To(n,"x-ethers/mnemonicCiphertext")),r=ko(To(n,"x-ethers/mnemonicCounter")),i=new Mo.Counter(r),s=new Mo.ModeOfOperation.ctr(o,i),h=To(n,"x-ethers/path")||mo,l=bo(E(s.decrypt(t))),u=go.fromMnemonic(l).derivePath(h);if(u.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=u.mnemonic,a.path=u.path}return new $o(a)};return new Promise(function(t,e){let s=To(n,"crypto/kdf");if(s&&"string"==typeof s)if("scrypt"===s.toLowerCase()){let s=ko(To(n,"crypto/kdfparams/salt")),a=parseInt(To(n,"crypto/kdfparams/n")),h=parseInt(To(n,"crypto/kdfparams/r")),l=parseInt(To(n,"crypto/kdfparams/p"));if(!a||!h||!l)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(To(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Oo(i,s,a,h,l,64,function(n,i,s){if(n)n.progress=i,e(n);else if(s){s=E(s);let n=o(s,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===s.toLowerCase()){let r=ko(To(n,"crypto/kdfparams/salt")),s=null,a=To(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)s="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));s="sha512"}let h=parseInt(To(n,"crypto/kdfparams/c")),l=parseInt(To(n,"crypto/kdfparams/dklen"));if(32!==l)return void e(new Error("unsupported key-derivation derived-key length"));let u=E(ei(i,r,h,l,s)),f=o(u,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Yo(t,e,r){if(Ro(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=xo(e);let n=$t(To(r,"ethaddr")),i=ko(To(r,"encseed"));i&&i.length%16==0||No.throwArgumentError("invalid encseed","json",t);let o=E(ei(e,e,2e3,32,"sha256")).slice(0,16),s=i.slice(0,16),a=i.slice(16),h=E(new Mo.ModeOfOperation.cbc(o,s).decrypt(a));h=Mo.padding.pkcs7.strip(h);let l="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&ts.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||mo;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(go.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&ts.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&ts.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!lr.isProvider(e)&&ts.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new es(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Dt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(B(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(go.fromMnemonic(t.mnemonic).derivePath(t.path||mo).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=E(t.privateKey),o=xo(e),s=null,a=t.path;t.mnemonic&&(s=E(vo(t.mnemonic)),a||(a=mo));let h=r.client;h||(h="ethers.js");let l=null;l=r.salt?E(r.salt):So(32);let u=null;if(r.iv){if(16!==(u=E(r.iv)).length)throw new Error("invalid iv")}else u=So(16);let f=null;if(r.uuid){if(16!==(f=E(r.uuid)).length)throw new Error("invalid uuid")}else f=So(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Oo(o,l,c,d,p,64,function(o,m,g){if(o)o.progress=m,r(o);else if(g){let r=(g=E(g)).slice(0,16),o=g.slice(16,32),m=g.slice(32,64),y=new Mo.Counter(u),v=E(new Mo.ModeOfOperation.ctr(r,y).encrypt(i)),b=Dt(_([o,v])),w={address:t.address.substring(2).toLowerCase(),id:Xo.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:P(u).substring(2)},ciphertext:P(v).substring(2),kdf:"scrypt",kdfparams:{salt:P(l).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(s){let t=So(16),e=new Mo.Counter(t),r=E(new Mo.ModeOfOperation.ctr(m,e).encrypt(s)),n=new Date,i=n.getUTCFullYear()+"-"+Po(n.getUTCMonth()+1,2)+"-"+Po(n.getUTCDate(),2)+"T"+Po(n.getUTCHours(),2)+"-"+Po(n.getUTCMinutes(),2)+"-"+Po(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:h,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:P(t).substring(2),mnemonicCiphertext:P(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=So(16);t||(t={}),t.extraEntropy&&(e=E(T(Dt(_([e,t.extraEntropy])),0,16)));let r=bo(e,t.locale);return es.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Yo(t,e,r).then(t=>new es(t))}static fromMnemonic(t,e,r){return e||(e=mo),new es(go.fromMnemonic(t,null,r).derivePath(e))}}const rs=new p("networks/5.0.0-beta.128");function ns(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function is(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const os={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ns("homestead")},ss={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ns("ropsten")},as={unspecified:{chainId:0,name:"unspecified"},homestead:os,mainnet:os,morden:{chainId:2,name:"morden"},ropsten:ss,testnet:ss,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ns("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ns("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ns("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:is("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:is("https://web3.gastracker.io/morden","classicTestnet")}};function hs(t){if(null==t)return null;if("number"==typeof t){for(let e in as){let r=as[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=as[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=as[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&rs.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&rs.throwArgumentError("invalid network chainId","network",t),t)}var ls=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function o(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function s(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function y(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];y.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,o){var s=new m(t,n);if(s.signal&&s.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function l(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new y(n,r))},a.onerror=function(){o(new TypeError("Network request failed"))},a.ontimeout=function(){o(new TypeError("Network request failed"))},a.onabort=function(){o(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),s.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),s.signal&&(s.signal.addEventListener("abort",l),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",l)}),a.send(void 0===s._bodyInit?null:s._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=h,t.Request=m,t.Response=y),e.Headers=h,e.Request=m,e.Response=y,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),us=(ls.fetch,ls.Headers,ls.Request,ls.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(s=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&ms.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+ds(Ae(e))}}}return new Promise(function(t,a){let h=null;s&&(h=setTimeout(()=>{null!=h&&(h=null,a(ms.makeError("timeout",p.errors.TIMEOUT,{timeout:s})))},s));let l=()=>{null!=h&&(clearTimeout(h),h=null)};e&&(o.method="POST",o.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let u={};return Object.keys(n).forEach(t=>{let e=n[t];u[e.key]=e.value}),o.headers=u,ls(i,o).then(t=>t.text().then(e=>(t.ok||ms.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){ms.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){ms.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{l(),t(e)},t=>{l(),a(t)})})}function ys(t,e){return e||(e={}),null==(e=st(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,o=!1,s=()=>!o&&(o=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{s()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,h=0;!function i(){return t().then(function(t){if(void 0!==t)s()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!o){if(++h>a)return void(s()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){s()&&n(t)})}()})}const vs="providers/5.0.0-beta.140",bs=new p(vs);class ws{constructor(){bs.checkNew(new.target,ws),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),o=this.hash.bind(this),s=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:o,blockHash:ws.allowNull(o,null),blockNumber:ws.allowNull(a,null),transactionIndex:ws.allowNull(a,null),confirmations:ws.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:ws.allowNull(e,null),value:r,nonce:a,data:i,r:ws.allowNull(this.uint256),s:ws.allowNull(this.uint256),v:ws.allowNull(a),creates:ws.allowNull(e,null),raw:ws.allowNull(i)},t.transactionRequest={from:ws.allowNull(e),nonce:ws.allowNull(a),gasLimit:ws.allowNull(r),gasPrice:ws.allowNull(r),to:ws.allowNull(e),value:ws.allowNull(r),data:ws.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:ws.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:o,address:e,topics:ws.arrayOf(o),data:i,logIndex:a,blockHash:o},t.receipt={to:ws.allowNull(this.address),from:ws.allowNull(this.address),contractAddress:ws.allowNull(e,null),transactionIndex:a,root:ws.allowNull(o),gasUsed:r,logsBloom:ws.allowNull(i),blockHash:o,transactionHash:o,logs:ws.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:ws.allowNull(a,null),cumulativeGasUsed:r,status:ws.allowNull(a)},t.block={hash:o,parentHash:o,number:a,timestamp:a,nonce:ws.allowNull(s),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:ws.allowNull(ws.arrayOf(o))},t.blockWithTransactions=st(t.block),t.blockWithTransactions.transactions=ws.allowNull(ws.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:ws.allowNull(n,void 0),toBlock:ws.allowNull(n,void 0),blockHash:ws.allowNull(o,void 0),address:ws.allowNull(e,void 0),topics:ws.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:ws.allowNull(a),blockHash:ws.allowNull(o),transactionIndex:a,removed:ws.allowNull(this.boolean.bind(this)),address:e,data:ws.allowFalsish(i,"0x"),topics:ws.arrayOf(o),transactionHash:o,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bs.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(T(t,12));return e===ue?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return N(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==x(r)?bs.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),ws.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return ws.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=ws.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return ws.check(this.formats.receiptLog,t)}receipt(t){let e=ws.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return ws.check(this.formats.filter,t)}filterLog(t){return ws.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const Es=new p(vs);function _s(t){return null==t?"null":(32!==x(t)&&Es.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function As(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[_s(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return _s(t)}).join("&")}function Ss(t){if("string"==typeof t){if(32===x(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+As(t);if(hr.isForkEvent(t))throw Es.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+As(t.topics||[])}throw new Error("invalid event - "+t)}function Ms(){return(new Date).getTime()}class ks{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let Ps=null,xs=1;class Ts extends lr{constructor(t){if(Es.checkNew(new.target,lr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):Es.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==Ps&&(Ps=new ws),Ps}static getNetwork(t){return hs(null==t?"homestead":t)}poll(){let t=xs++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let o=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(o);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Ms();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>N(t))}).then(t=>P(t))}_wrapTransaction(t,e){if(null!=e&&32!==x(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&Es.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&Es.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>P(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&Es.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){Es.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return ys(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return ys(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return ys(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>ws.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&Es.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||Es.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=E(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return Es.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ks(Ss(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=Ss(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=Ss(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=Ss(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=Ss(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=Ss(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const Ns=new p(vs);function Is(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Rs(t){return t?t.toLowerCase():t}const Cs={};class Bs extends cr{constructor(t,e,r){if(Ns.checkNew(new.target,Bs),super(),t!==Cs)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):Ns.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return Ns.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Os(Cs,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&Ns.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=st(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=st(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&Ns.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&Ns.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&Ns.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return Ns.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>ys(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Ae(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),P(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Os extends Bs{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fs={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Ds extends Ts{constructor(t,e){if(Ns.checkNew(new.target,Ds),"string"==typeof t&&null===e&&hs(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(hs(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(hs(U.from(e).toNumber()))}).catch(t=>{e(Ns.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Bs(Cs,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ht(r),provider:this}),gs(this.connection,JSON.stringify(r),Is).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Rs(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Rs(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Rs(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Rs(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&Ns.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&Ns.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&Ns.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):Ns.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Rs(e.filter.address)),this.send("eth_getLogs",[e.filter])}return Ns.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=st(Fs);if(e)for(let t in e)e[t]&&(r[t]=!0);ot(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=N(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=P(t[e]))}),n}}const Ls=new p(vs);class Us extends Ds{constructor(t,e){Ls.checkAbstract(new.target,Us),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Ls.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Ls.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return hs(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Ls.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zs=new p(vs),js="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Hs=new p(vs);const qs=new p(vs);function Ks(t){let e=[];for(let r in t){if(null==t[r])continue;let n=P(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=N(n)),e.push(r+"="+n)}return e.join("&")}function Gs(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Ws(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vs(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Js extends Ts{constructor(t,e){qs.checkNew(new.target,Js),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),gs(t,null,e||Ws).then(e=>(this.emit("debug",{action:"response",request:t,response:ht(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Gs);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Ws);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Ws);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qs.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qs.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qs.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ks(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ks(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vs(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vs(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let o=this;return i(r+=n,Gs).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?o.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Gs).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),gs(n,null,Gs).then(t=>{this.emit("debug",{action:"response",request:n,response:ht(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zs=new p(vs);function Xs(){return(new Date).getTime()}function $s(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zs.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qs=1;class Ys extends Ts{constructor(t,e,r){Zs.checkNew(new.target,Ys),0===t.length&&Zs.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zs.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zs.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zs.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$s(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($s(t)||Zs.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zs.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xs(),n=Ao(this.providers).map((n,i)=>{let o=this.weights[i],s=Qs++;return{run:()=>{let i=Xs(),a=i-r;return this.emit("debug",{action:"request",rid:s,backend:{weight:o,start:a,provider:n},request:{method:t,params:ht(e)},provider:this}),Ys.doPerform(n,t,e).then(r=>{let h=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},response:ht(r)}),{weight:o,result:r}},r=>{let h=Xs()-i;return this.emit("debug",{action:"response",rid:s,backend:{weight:o,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},error:r}),{weight:o,error:r}})},weight:o}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let o=null,s=0,a={},h=()=>{if(0===n.length)return;let l=n.shift();s+=l.weight,l.run().then(u=>{if(null!==a){if(s-=l.weight,u.error)null==o&&(o=u.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(u.result);null==a[t]&&(a[t]=[]),a[t].push(u);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===s){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===o&&(o=Zs.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(o)}setTimeout(h,0)}}),s{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(vs),ia="84842078b09946638c03157f83405213";const oa=new p(vs),sa="ETHERS_JS_SHARED";const aa=new p(vs);class ha extends Ds{constructor(t,e){aa.checkNew(new.target,ha),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var la=Object.freeze({Provider:lr,BaseProvider:Ts,FallbackProvider:Ys,AlchemyProvider:class extends Us{static getApiKey(t){return null==t?js:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zs.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Us{static getUrl(t,e){null!=e&&Hs.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Hs.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Js,InfuraProvider:class extends Us{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Ds,NodesmithProvider:class extends Us{static getApiKey(t){return t||sa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:oa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ha,IpcProvider:ra,JsonRpcSigner:Bs,getNetwork:hs,Formatter:ws});const ua=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?S(r,32):E(r);case"string":return Ae(r);case"bytes":return E(r);case"bool":return r=r?"0x01":"0x00",n?S(r,32):E(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),S(r=U.from(r).toTwos(t),t/8)}if(i=e.match(ua)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(E(r).byteLength!==t)throw new Error("invalid value for "+e);return n?E((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let o=[];return r.forEach(function(e){o.push(t(n,e,!0))}),_(o)}throw new Error("unknown type - "+e)}(t,e[n]))}),P(_(r))}const ma=new p("units/5.0.0-beta.126"),ga=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ya(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return $(t,null!=e?e:18)}function va(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return Q(t,null!=e?e:18)}var ba=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:Et,EventFragment:_t,FunctionFragment:Pt,ParamType:bt,FormatTypes:yt,Logger:p,RLP:Kt,fetchJson:gs,poll:ys,checkProperties:ot,deepCopy:ht,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:st,arrayify:E,concat:_,stripZeros:A,zeroPad:S,defaultPath:mo,HDNode:go,SigningKey:qi,Interface:or,base64:ps,hexlify:P,isHexString:M,hexStripZeros:I,hexValue:N,hexZeroPad:R,hexDataLength:x,hexDataSlice:T,nameprep:Le,_toEscapedUtf8String:function(t,e){return'"'+_e(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Se(t):Se(55296+((t-=65536)>>10&1023))+Se(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Ae,toUtf8CodePoints:Pe,toUtf8String:ke,formatBytes32String:function(t){let e=Ae(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return P(_([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=E(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new s($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return ya(t,18)},parseEther:function(t){return va(t,18)},formatUnits:ya,parseUnits:va,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&ma.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let o=[];for(;r.length;){if(r.length<=3){o.unshift(r);break}{let t=r.length-3;o.unshift(r.substring(t)),r=r.substring(0,t)}}return n+o.join(",")+i},keccak256:Dt,sha256:Qn,randomBytes:So,solidityPack:pa,solidityKeccak256:function(t,e){return Dt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:C,joinSignature:B,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Ro(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Co(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:vo,entropyToMnemonic:bo,isValidMnemonic:function(t,e){try{return vo(t,e),!0}catch(t){}return!1},mnemonicToSeed:yo,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return Ee},Indexed:ir});const wa="node",Ea="ethers/5.0.0-beta.155",_a=p.errors,Aa=new p(Ea);function Sa(t,e){null==t&&(t="homestead");let r=hs(t);return r&&r._defaultProvider||Aa.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(la,e)}var Ma=Object.freeze({version:Ea,Signer:cr,Wallet:es,VoidSigner:dr,getDefaultProvider:Sa,providers:la,Contract:Ar,ContractFactory:Sr,BigNumber:U,FixedNumber:tt,constants:ve,errors:_a,logger:Aa,utils:ba,wordlists:oo,platform:"node",Wordlist:io});export{U as BigNumber,Ar as Contract,Sr as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,es as Wallet,io as Wordlist,ve as constants,_a as errors,Ma as ethers,Sa as getDefaultProvider,Aa as logger,wa as platform,la as providers,ba as utils,Ea as version,oo as wordlists}; +var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),s=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function h(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return i}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(i=0,s=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-s&4194303,(s+=24)>=26&&(s-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,a=Math.min(s,s-o)+r,l=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var l=1;l>>26,f=67108863&h,c=Math.min(l,e.length-1),d=Math.max(0,l-t.length+1);d<=c;d++){var p=l-d|0;u+=(o=(i=0|t.words[p])*(s=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[l]=0|f,h=0|u}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,s=0,o=0;o>>24-i&16777215)||o!==this.length-1?l[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=u[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:l[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),s=n||Math.max(1,i);r(i<=s,"byte array longer than desired length"),r(s>0,"Requested array length <= 0"),this.strip();var o,a,h="le"===e,l=new t(s),u=this.clone();if(h){for(a=0;!u.isZero();a++)o=u.andln(255),u.iushrn(8),l[a]=o;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s>>26;for(;0!==i&&s>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,E=b>>>13,_=0|o[4],A=8191&_,S=_>>>13,M=0|o[5],k=8191&M,P=M>>>13,x=0|o[6],T=8191&x,N=x>>>13,I=0|o[7],R=8191&I,C=I>>>13,B=0|o[8],O=8191&B,F=B>>>13,D=0|o[9],L=8191&D,U=D>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ht=8191&at,lt=at>>>13,ut=0|a[8],ft=8191&ut,ct=ut>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;l=((s=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,s=Math.imul(m,H);var yt=(l+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;l=((s=s+Math.imul(c,G)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,H))+Math.imul(v,j)|0,s=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,G)|0;var vt=(l+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;l=((s=s+Math.imul(c,J)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(E,j)|0,s=Math.imul(E,H),n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(v,K)|0,s=s+Math.imul(v,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,J)|0;var bt=(l+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;l=((s=s+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,H))+Math.imul(S,j)|0,s=Math.imul(S,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,K)|0,s=s+Math.imul(E,G)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,s=s+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,$)|0;var wt=(l+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;l=((s=s+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(P,j)|0,s=Math.imul(P,H),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,K)|0,s=s+Math.imul(S,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(E,V)|0,s=s+Math.imul(E,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,tt)|0;var Et=(l+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;l=((s=s+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(T,j),i=(i=Math.imul(T,H))+Math.imul(N,j)|0,s=Math.imul(N,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(P,K)|0,s=s+Math.imul(P,G)|0,n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(S,V)|0,s=s+Math.imul(S,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,X)|0,s=s+Math.imul(E,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,nt)|0;var _t=(l+(n=n+Math.imul(f,st)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(c,st)|0))<<13)|0;l=((s=s+Math.imul(c,ot)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(C,j)|0,s=Math.imul(C,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(P,V)|0,s=s+Math.imul(P,J)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(S,X)|0,s=s+Math.imul(S,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,nt)|0,n=n+Math.imul(p,st)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var At=(l+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(c,ht)|0))<<13)|0;l=((s=s+Math.imul(c,lt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,s=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,G)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(N,V)|0,s=s+Math.imul(N,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,$)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,nt)|0,n=n+Math.imul(y,st)|0,i=(i=i+Math.imul(y,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;l=((s=s+Math.imul(c,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,H))+Math.imul(U,j)|0,s=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,s=s+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,s=s+Math.imul(C,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,nt)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,s=s+Math.imul(m,ct)|0;var Mt=(l+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((s=s+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,G))+Math.imul(U,K)|0,s=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,s=s+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,s=s+Math.imul(C,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,nt)|0,n=n+Math.imul(A,st)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,lt)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,s=s+Math.imul(v,ct)|0;var kt=(l+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,J))+Math.imul(U,V)|0,s=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,s=s+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,nt)|0,n=n+Math.imul(k,st)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(E,ft)|0,s=s+Math.imul(E,ct)|0;var Pt=(l+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,$))+Math.imul(U,X)|0,s=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,s=s+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,nt)|0,n=n+Math.imul(T,st)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(S,ft)|0,s=s+Math.imul(S,ct)|0;var xt=(l+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((s=s+Math.imul(E,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,tt))+Math.imul(U,Y)|0,s=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,s=s+Math.imul(F,nt)|0,n=n+Math.imul(R,st)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(P,ft)|0,s=s+Math.imul(P,ct)|0;var Tt=(l+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul(U,rt)|0,s=Math.imul(U,nt),n=n+Math.imul(O,st)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(F,st)|0,s=s+Math.imul(F,ot)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,lt)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,ct)|0;var Nt=(l+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,st),i=(i=Math.imul(L,ot))+Math.imul(U,st)|0,s=Math.imul(U,ot),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(F,ht)|0,s=s+Math.imul(F,lt)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(C,ft)|0,s=s+Math.imul(C,ct)|0;var It=(l+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,lt))+Math.imul(U,ht)|0,s=Math.imul(U,lt),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,s=s+Math.imul(F,ct)|0;var Rt=(l+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(C,pt)|0))<<13)|0;l=((s=s+Math.imul(C,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul(U,ft)|0,s=Math.imul(U,ct);var Ct=(l+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;l=((s=s+Math.imul(F,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(l+(n=Math.imul(L,pt))|0)+((8191&(i=(i=Math.imul(L,mt))+Math.imul(U,pt)|0))<<13)|0;return l=((s=Math.imul(U,mt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Et,h[6]=_t,h[7]=At,h[8]=St,h[9]=Mt,h[10]=kt,h[11]=Pt,h[12]=xt,h[13]=Tt,h[14]=Nt,h[15]=It,h[16]=Rt,h[17]=Ct,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,s){for(var o=0;o>>=1)i++;return 1<>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=s>>>26,this.words[n]=67108863&s}return 0!==e&&(this.words[n]=e,this.length++),this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new s(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(e=0;e>>26-n}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,l=0;l=0&&(0!==u||l>=i);l--){var f=0|this.words[l];this.words[l]=u<<26-s|f>>>s,u=f&a}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[i+n]=67108863&s}for(;i>26,this.words[i+n]=67108863&s;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,h=n.length-i.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var l=0;l=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},s.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),h=new s(1),l=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++l;for(var u=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(u),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),o.isub(h)):(n.isub(e),a.isub(i),h.isub(o))}return{a:a,b:h,gcd:n.iushln(l)}},s.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new s(1),a=new s(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var l=0,u=1;0==(e.words[0]&u)&&l<26;++l,u<<=1);if(l>0)for(e.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a)):(n.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new _(t)},s.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=s}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new s(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);r(!i.isZero());var a=new s(1).toRed(this),h=a.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new s(2*u*u).toRed(this);0!==this.pow(u,l).cmp(h);)u.redIAdd(h);for(var f=this.pow(u,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var l=e.words[n],u=h-1;u>=0;u--){var f=l>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}h=26}return i},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new A(t)},n(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),o=s.BN;const a="logger/5.0.0-beta.128";let h=!1,l=!1;const u={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=u.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=u[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>u[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(l)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach(function(t){s[t]=r[t]}),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(h){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}l=!!t,h=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.128");function y(t){return!!t.toHexString}function v(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return v(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function E(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),v(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;tE(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),v(n)}function A(t){let e=E(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),v(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function P(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function x(t){if("string"!=typeof t)t=P(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function T(t,e,r){return"string"!=typeof t?t=P(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function N(t){let e=I(P(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=P(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function C(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=E(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=P(r.slice(0,32)),e.s=P(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=P(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=E(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let s=P(r);null==e.s?e.s=s:e.s!==s&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=E(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=P(r)}}return e}function B(t){return P(_([(t=C(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:E,concat:_,stripZeros:A,zeroPad:S,isHexString:M,hexlify:P,hexDataLength:x,hexDataSlice:T,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=P(t).substring(2)}),e},hexValue:N,hexStripZeros:I,hexZeroPad:R,splitSignature:C,joinSignature:B});const F=new p("bignumber/5.0.0-beta.129"),D={},L=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==D&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(D,z(t)):t.match(/^-?[0-9]+$/)?new U(D,z(new o(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=L||t<=-L)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(P(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new o("-"+e.substring(3),16):new o(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.129"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let s=i[0],o=i[1];for(s||(s="0"),o||(o="0"),o.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");o.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let s=$(n,r.decimals);return new tt(G,i,s,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(E(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),s=$(n,r.decimals);return new tt(G,i,s,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.130");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function st(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function ot(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ht(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ht(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ht(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class lt{constructor(t){for(let e in t)this[e]=ht(t[e]);Object.freeze(this)}}var ut=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:st,shallowCopy:ot,deepCopy:ht,Description:lt});const ft="abi/5.0.0-beta.136",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const yt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(vt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==yt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===yt.full?", ":",")+")"):e+=this.type,t!==yt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===yt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:xt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let s={type:"",name:"",state:{allowType:!0}},o=s;for(let r=0;rbt.fromString(t,e))}class Et{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return Et.isFragment(t)?t:"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){return Et.isFragment(t)?t:"function"===t.type?Pt.fromObject(t):"event"===t.type?_t.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return _t.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return Pt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class _t extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){if(_t.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new _t(dt,{name:Nt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),_t.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function At(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function St(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===yt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=At(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),St(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Pt extends kt{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Pt.fromString(t):Pt.fromObject(t)}static fromObject(t){if(Pt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new Pt(dt,{type:t.type,name:Nt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=At(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Tt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),St(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return Pt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function xt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Tt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Nt(t){if(!t||!t.match(Tt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Ct{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Bt{constructor(t){rt(this,"wordSize",t||32),this._data=E([]),this._padding=new Uint8Array(t)}get data(){return P(this._data)}get length(){return this._data.length}_writeData(t){return this._data=_([this._data,t]),t.length}writeBytes(t){let e=E(t);return e.length%this.wordSize&&(e=_([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=E(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=_([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",E(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return P(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),s=[0,8,16,24],o=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],h=["hex","buffer","arrayBuffer","array"],l=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},u=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=l(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,o=this.blocks,a=this.byteCount,h=this.blockCount,l=0,u=this.s;l>2]|=t[l]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=o[h],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(E(r),o=0)}return s&&(t=r[o],s>0&&(h+=i[t>>4&15]+i[15&t]),s>1&&(h+=i[t>>12&15]+i[t>>8&15]),s>2&&(h+=i[t>>20&15]+i[t>>16&15])),h},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);o>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&E(n)}return s&&(t=a<<2,e=n[o],s>0&&(h[t]=255&e),s>1&&(h[t+1]=e>>8&255),s>2&&(h[t+2]=e>>16&255)),h};var E=function(t){var e,r,n,i,s,a,h,l,u,f,c,d,p,m,g,y,v,b,w,E,_,A,S,M,k,P,x,T,N,I,R,C,B,O,F,D,L,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,st,ot,at,ht,lt,ut;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],h=t[3]^t[13]^t[23]^t[33]^t[43],l=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|h>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(h<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(l<<1|u>>>31),r=s^(u<<1|l>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=h^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=l^(d<<1|p>>>31),r=u^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|s>>>31),r=c^(s<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,T=t[20]<<3|t[21]>>>29,N=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,lt=t[42]<<2|t[43]>>>30,ut=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,L=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,B=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,E=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,P=t[18]<<20|t[19]>>>12,x=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,A=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=m^~y&b,t[1]=g^~v&w,t[10]=M^~P&T,t[11]=k^~x&N,t[20]=O^~D&U,t[21]=F^~L&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&st,t[41]=rt^~it&ot,t[2]=y^~b&E,t[3]=v^~w&_,t[12]=P^~T&I,t[13]=x^~N&R,t[22]=D^~U&j,t[23]=L^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~st&at,t[43]=it^~ot&ht,t[4]=b^~E&A,t[5]=w^~_&S,t[14]=T^~I&C,t[15]=N^~R&B,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=st^~at<,t[45]=ot^~ht&ut,t[6]=E^~A&m,t[7]=_^~S&g,t[16]=I^~C&M,t[17]=R^~B&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~lt&et,t[47]=ht^~ut&rt,t[8]=A^~m&y,t[9]=S^~g&v,t[18]=C^~M&P,t[19]=B^~k&x,t[28]=q^~O&D,t[29]=K^~F&L,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=lt^~et&nt,t[49]=ut^~rt&it,t[0]^=o[n],t[1]^=o[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:P(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:P(t.slice(e+1,e+1+r))}}return{consumed:1,result:P(t[e])}}function qt(t){let e=E(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.127");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=E(Dt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new o(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(T(Dt(zt([e,A(E(t.nonce))])),12))}class Yt extends Ct{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Ct{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Bt(t.wordSize),i=new Bt(t.wordSize),s=[];e.forEach((t,e)=>{let o=r[e];if(t.dynamic){let e=i.length;t.encode(i,o);let r=n.writeUpdatableValue();s.push(t=>{r(t+e)})}else t.encode(n,o)}),s.forEach(t=>{t(n.length)});let o=t.writeBytes(n.data);return o+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let s=null;if(e.dynamic){let r=t.readValue(),o=n.subReader(r.toNumber());s=e.decode(o),i+=o.consumed}else s=e.decode(t);null!=s&&r.push(s)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Ct{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let s=null,o=null;if(192==(224&i))s=1,o=127;else if(224==(240&i))s=2,o=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}s=3,o=65535}if(n+s>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-s-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Ae(t,e=Ee.current){e!=Ee.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return E(r)}function Se(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(_e(t,e))}function Pe(t,e=Ee.current){return _e(Ae(t,e))}function xe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Te(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Ne(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ee||(Ee={}));const Ie=Te("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Ce=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Be=xe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=xe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=xe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ne(t,Ce);if(e)return[t+e.s];let r=Be[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=Pe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),Ee.NFKC)).forEach(t=>{if(function(t){return!!Ne(t,De)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Ne(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends oe{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Ae(e))}decode(t){return ke(super.decode(t))}}class ze extends Ct{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new se(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new le(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new he(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Bt(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(E(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.127"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;tEt.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return T($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?or(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[Pt.fromString(t).format()]}getEvent(t){return M(t)?or(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[_t.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),P(_([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=E(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===P(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Dt(P(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(P(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],s=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))});let o=null!=r?this._abiCoder.decode(n,_(r)):null,a=this._abiCoder.decode(i,e),h=[],l=0,u=0;return t.inputs.forEach((t,e)=>{t.indexed?null==o?h[e]=new ir({_isIndexed:!0,hash:null}):s[e]?h[e]=new ir({_isIndexed:!0,hash:o[u++]}):h[e]=o[u++]:h[e]=a[l++]}),h}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function or(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.130");class hr extends lt{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class lr{addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}constructor(){ar.checkAbstract(new.target,lr),rt(this,"_isProvider",!0)}static isProvider(t){return!(!t||!t._isProvider)}}const ur=new p("abstract-signer/5.0.0-beta.131"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){ur.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&ur.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=ot(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&ur.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{ur.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||ur.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){ur.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ur.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.136"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function yr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},s=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=ot(e.pop())).blockTag&&(s=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(s).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,s).then(r=>{try{let s=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(s=s[0]),s}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ht(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function vr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class Er extends br{constructor(t,e,r,n){let i={address:t},s=e.getEventTopic(r);n?(s!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[s],super(vr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class _r extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Ar{constructor(t,e,r){if(pr.checkNew(new.target,Ar),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):lr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=yr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,yr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,yr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,yr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return sr.isInterface(t)?t:new sr(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=ot(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new _r(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new Er(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new Er(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(vr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ht(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=ot(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Sr{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?P(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=ot(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=P(_([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Ar.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Ar(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Cr={inherits:Tr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,o=255&i;s?r.push(s,o):r.push(o)}else for(n=0;n>>0}return s},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],s=n+t[e+1]>>>0,o=(s>>0,t[e+1]=s},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,s,o,a){var h=0,l=e;return h+=(l=l+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,s,o,a){return e+n+s+a>>>0},sum64_5_hi:function(t,e,r,n,i,s,o,a,h,l){var u=0,f=e;return u+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,s,o,a,h,l){return e+n+s+a+l>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Br(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Br;Br.prototype.update=function(t,e){if(t=Cr.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Cr.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,s=8;s>>3},g1_256:function(t){return Dr(t,17)^Dr(t,19)^t>>>10}},Hr=Cr.sum32,qr=Cr.sum32_4,Kr=Cr.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Cr.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),Pr(t.length<=this.blockSize);for(var e=t.length;e>24&255,u[e.length+1]=f>>16&255,u[e.length+2]=f>>8&255,u[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,u));s||(s=c.length,a=new Uint8Array(s),o=n-((h=Math.ceil(n/s))-1)*s),a.set(c);for(var d=1;d>8,o=255&i;s?r.push(s,o):r.push(o)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),si=r(function(t,e){var r=e;r.assert=Pr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var s;if(i.isOdd()){var o=i.andln(n-1);s=o>(n>>1)-1?(n>>1)-o:o,i.isubn(s)}else s=0;r.push(s);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,h=1;h0||e.cmpn(-i)>0;){var s,o,a,h=t.andln(3)+n&3,l=e.andln(3)+i&3;if(3===h&&(h=-1),3===l&&(l=-1),0==(1&h))s=0;else s=3!==(a=t.andln(7)+n&7)&&5!==a||2!==l?h:-h;if(r[0].push(s),0==(1&l))o=0;else o=3!==(a=e.andln(7)+i&7)&&5!==a||2!==h?l:-l;r[1].push(o),2*n===s+1&&(n=1-n),2*i===o+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new s(t,"hex","le")}}),oi=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=si.getNAF,hi=si.getJSF,li=si.assert;function ui(t,e){this.type=t,this.p=new s(e.p,16),this.red=e.prime?s.red(e.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=e.n&&new s(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=ui;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}ui.prototype.point=function(){throw new Error("Not implemented")},ui.prototype.validate=function(){throw new Error("Not implemented")},ui.prototype._fixedNafMul=function(t,e){li(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=o;e--)a=(a<<1)+n[e];s.push(a)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),u=i;u>0;u--){for(o=0;o=0;a--){for(e=0;a>=0&&0===s[a];a--)e++;if(a>=0&&e++,o=o.dblp(e),a<0)break;var h=s[a];li(0!==h),o="affine"===t.type?h>0?o.mixedAdd(i[h-1>>1]):o.mixedAdd(i[-h-1>>1].neg()):h>0?o.add(i[h-1>>1]):o.add(i[-h-1>>1].neg())}return"affine"===t.type?o.toP():o},ui.prototype._wnafMulAdd=function(t,e,r,n,i){for(var s=this._wnafT1,o=this._wnafT2,a=this._wnafT3,h=0,l=0;l=1;l-=2){var f=l-1,c=l;if(1===s[f]&&1===s[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=hi(r[f],r[c]);h=Math.max(m[0].length,h),a[f]=new Array(h),a[c]=new Array(h);for(var g=0;g=0;l--){for(var E=0;l>=0;){var _=!0;for(g=0;g=0&&E++,b=b.dblp(E),l<0)break;for(g=0;g0?A=o[g][S-1>>1]:S<0&&(A=o[g][-S-1>>1].neg()),b="affine"===A.type?b.mixedAdd(A):b.add(A))}}for(l=0;l=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),h=i.mul(r.b),l=s.mul(n.b);return{k1:t.sub(o).sub(a),k2:h.add(l).neg()}},pi.prototype.pointFromX=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,s=0;s":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new s(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Tr(yi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new yi(this,t,e,r)},yi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},yi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},yi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),f=n.redMul(l),c=h.redSqr().redIAdd(u).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},yi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),l=h.redMul(o),u=r.redMul(h),f=a.redSqr().redIAdd(l).redISub(u).redISub(u),c=a.redMul(u.redISub(f)).redISub(i.redMul(l)),d=this.z.redMul(o);return this.curve.jpoint(f,c,d)},yi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},yi.prototype.inspect=function(){return this.isInfinity()?"":""},yi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var vi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=vi,r.edwards=bi}),Ei=r(function(t,e){var r,n=e,i=si.assert;function s(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");Pr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Ai=_i;_i.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},_i.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Pi=si.assert;function xi(t,e){if(t instanceof xi)return t;this._importDER(t,e)||(Pi(t.r&&t.s,"Signature without r or s"),this.r=new s(t.r,16),this.s=new s(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ti=xi;function Ni(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,s=0,o=e.place;s>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xi.prototype._importDER=function(t,e){t=si.toArray(t,e);var r=new Ni;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=Ii(t,r);if(t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},xi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Ci(n,e.length),(n=n.concat(e)).push(2),Ci(n,r.length);var i=n.concat(r),s=[48];return Ci(s,i.length),s=s.concat(i),si.encode(s,t)};var Bi=si.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Bi(Ei.hasOwnProperty(t),"Unknown curve "+t),t=Ei[t]),t instanceof Ei.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ai({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||oi(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new s(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),a=t.toArray("be",i),h=new Ai({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new s(1)),u=0;;u++){var f=n.k?n.k(u):new s(h.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(l)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ti({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new s(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ti(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,h=o.invm(this.n),l=h.mul(t).umod(this.n),u=h.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(l,r.getPublic(),u)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(l,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Bi((3&r)===r,"The recovery param is more than two bits"),e=new Ti(e,n);var i=this.n,o=new s(t),a=e.r,h=e.s,l=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var f=e.r.invm(i),c=i.sub(o).mul(f).umod(i),d=h.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ti(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch(t){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Di={},Li=n(ni),Ui=r(function(t,e){var r=e;r.version=Li.version,r.utils=si,r.rand=oi,r.curve=wi,r.curves=Ei,r.ec=Fi,r.eddsa=Di}).ec;const zi=new p("signing-key/5.0.0-beta.128");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",P(t));let e=Hi().keyFromPrivate(E(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(E(this.publicKey)),r=Hi().keyFromPublic(E(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(E(this.privateKey)).sign(E(t),{canonical:!0});return C({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(E(this.privateKey)),r=Hi().keyFromPublic(E(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=C(e),n={r:E(r.r),s:E(r.s)};return"0x"+Hi().recoverPubKey(E(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=E(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?P(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):P(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.127");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(T(Dt(T(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(E(t),e))}function Qi(t,e){st(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=E(P(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=A(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(P(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(P(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=C(e),s=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),s+=2*t.chainId+8),r.push(P(s)),r.push(A(E(i.r))),r.push(A(E(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(P(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let s=Dt(zt(i));try{r.from=$i(s,{r:P(r.r),s:P(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Dt(t)}return r}var ts=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.127"}),es=(e(ts),ts.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(ts.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var s=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),ut.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=s,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||ut.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||ut.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||ut.defineReadOnly(i.ethers.wordlists,r,e))}}})),rs=(e(es),es.check,es.Wordlist,es.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",o=null;function a(t){if(null==o&&(o=s.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==es.check(t)))throw o=null,new Error("BIP39 Wordlist for en (English) FAILED")}var h=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),o[t]},e.prototype.getWordIndex=function(t){return a(this),o.indexOf(t)},e}(es.Wordlist));r.langEn=h,es.register(h)})),ns=(e(rs),rs.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=es.Wordlist;var r={en:rs.langEn};e.wordlists=r})),is=(e(ns),ns.Wordlist),ss=ns.wordlists;const os=new p("hdnode/5.0.0-beta.129"),as=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),hs=Ae("Bitcoin seed"),ls=2147483648;function us(t){return(1<=256)throw new Error("Depth too large!");return cs(_([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",P(this.depth),this.parentFingerprint,R(P(this.index),4),this.chainCode,null!=this.privateKey?_(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new ms(ds,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~ls));let r=new Uint8Array(37);if(t&ls){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(E(this.privateKey),1),e&&(e+="'")}else r.set(E(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=E(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),s=n.slice(32),o=null,a=null;if(this.privateKey)o=fs(U.from(i).add(this.privateKey).mod(as));else{a=new qi(P(i))._addPoint(this.publicKey)}return new ms(ds,o,a,this.fingerprint,fs(s),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=ls)throw new Error("invalid path index - "+n);r=r._derive(ls+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invalid path component - "+n);{let t=parseInt(n);if(t>=ls)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=E(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=E(Yn(Xn.sha512,hs,r));return new ms(ds,fs(n.slice(0,32)),null,"0x00000000",fs(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=vs(ys(t,r),r),ms._fromSeed(gs(t,e),t)}static fromSeed(t){return ms._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&cs(e.slice(0,78))===t||os.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=P(e.slice(5,9)),i=parseInt(P(e.slice(9,13)).substring(2),16),s=P(e.slice(13,45)),o=e.slice(45,78);switch(P(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new ms(ds,null,P(o),n,s,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==o[0])break;return new ms(ds,P(o.slice(1)),null,n,s,i,r,null,null)}return os.throwError("invalid extended key","extendedKey","[REDACTED]")}}function gs(t,e){e||(e="");let r=Ae("mnemonic"+e,Ee.NFKD);return ei(Ae(t,Ee.NFKD),r,2048,64,"sha512")}function ys(t,e){e||(e=ss.en),os.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=E(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let s=32*r.length/3,o=us(r.length/3),a=E(Qn(n.slice(0,s/8)))[0];if((a&=o)!==(n[n.length-1]&o))throw new Error("invalid checksum");return P(n.slice(0,s/8))}function vs(t,e){if((t=E(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=E(Qn(t))[0],s=t.length/4;return i&=us(s),r[r.length-1]<<=s,r[r.length-1]|=i>>8-s,e||(e=ss.en),e.join(r.map(t=>e.getWord(t)))}var bs=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.127"}),ws=(e(bs),bs.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),Es=(e(ws),ws.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(bs.version);r.shuffled=ws.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),_s=(e(Es),Es.shuffled),As=Es.randomBytes,Ss=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function s(t){return new Uint8Array(t)}function o(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,h={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},l=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),u={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],_=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],A=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=s[e],this._Kd[t-r][e%4]=s[e];for(var o,a=0,h=i;h>16&255]<<24^c[o>>8&255]<<16^c[255&o]<<8^c[o>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[o>>16&255]<<16^c[o>>24&255]<<24;for(e=i/2+1;e>2,d=h%4,this._Ke[l][d]=s[e],this._Kd[t-l][d]=s[e++],h++}for(var l=1;l>24&255]^A[o>>16&255]^S[o>>8&255]^M[255&o]},P.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var o=1;o>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[o][i];n=r.slice()}var a,h=s(16);for(i=0;i<4;i++)a=this._Ke[e][i],h[4*i]=255&(c[n[i]>>24&255]^a>>24),h[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),h[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return h},P.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var o=1;o>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^E[255&n[(i+1)%4]]^this._Kd[o][i];n=r.slice()}var a,h=s(16);for(i=0;i<4;i++)a=this._Kd[e][i],h[4*i]=255&(d[n[i]>>24&255]^a>>24),h[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),h[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return h};var x=function(t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new P(t)};x.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=s(t.length),r=s(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var C=function(t,e){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new P(t)};C.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,E=s,_=o,A=a,S=h,M=l;for(p=0;p<16;p++)m=f+4*p,u[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=u[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=u[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,u[p]=(g+u[p-7]|0)+(y+u[p-16]|0)|0;for(p=0;p<64;p++)g=(((_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&A^~_&S)|0)+(M+(e[p]+u[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,M=S,S=A,A=_,_=E+g|0,E=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,s=s+E|0,o=o+_|0,a=a+A|0,h=h+S|0,l=l+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,y=t.slice(t.length-d,t.length);for(y.push(128),c=d+1;c>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255,l>>>24&255,l>>>16&255,l>>>8&255,l>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var s=64+e.length+4,o=new Array(s),a=new Array(64),h=[];for(i=0;i<64;i++)o[i]=54;for(i=0;i=s-4;t--){if(o[t]++,o[t]<=255)return;o[t]=0}}for(;r>=32;)l(),h=h.concat(n(a.concat(n(o)))),r-=32;return r>0&&(l(),h=h.concat(n(a.concat(n(o))).slice(0,r))),h}function s(t,e,r,n,i){var s;for(l(t,16*(2*r-1),i,0,16),s=0;s<2*r;s++)h(t,16*s,i,16),a(i,n),l(i,0,t,e+16*s,16);for(s=0;s>>32-e}function a(t,e){l(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=o(e[0]+e[12],7),e[8]^=o(e[4]+e[0],9),e[12]^=o(e[8]+e[4],13),e[0]^=o(e[12]+e[8],18),e[9]^=o(e[5]+e[1],7),e[13]^=o(e[9]+e[5],9),e[1]^=o(e[13]+e[9],13),e[5]^=o(e[1]+e[13],18),e[14]^=o(e[10]+e[6],7),e[2]^=o(e[14]+e[10],9),e[6]^=o(e[2]+e[14],13),e[10]^=o(e[6]+e[2],18),e[3]^=o(e[15]+e[11],7),e[7]^=o(e[3]+e[15],9),e[11]^=o(e[7]+e[3],13),e[15]^=o(e[11]+e[7],18),e[1]^=o(e[0]+e[3],7),e[2]^=o(e[1]+e[0],9),e[3]^=o(e[2]+e[1],13),e[0]^=o(e[3]+e[2],18),e[6]^=o(e[5]+e[4],7),e[7]^=o(e[6]+e[5],9),e[4]^=o(e[7]+e[6],13),e[5]^=o(e[4]+e[7],18),e[11]^=o(e[10]+e[9],7),e[8]^=o(e[11]+e[10],9),e[9]^=o(e[8]+e[11],13),e[10]^=o(e[9]+e[8],18),e[12]^=o(e[15]+e[14],7),e[13]^=o(e[12]+e[15],9),e[14]^=o(e[13]+e[12],13),e[15]^=o(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function h(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,o,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),o=f(o,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/o)throw new Error("N too large");if(o>r/128/a)throw new Error("r too large");if(!u(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!u(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*o),m=new Uint32Array(32*a*o),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(C)};C()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Os=new Uint8Array(16);Cs=function(){return crypto.getRandomValues(Os),Os}}if(!Cs){var Fs=new Array(16);Cs=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Fs[e]=t>>>((3&e)<<3)&255;return Fs}}for(var Ds=Cs,Ls=[],Us={},zs=0;zs<256;zs++)Ls[zs]=(zs+256).toString(16).substr(1),Us[Ls[zs]]=zs;function js(t,e){var r=e||0,n=Ls;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var Hs=Ds(),qs=[1|Hs[0],Hs[1],Hs[2],Hs[3],Hs[4],Hs[5]],Ks=16383&(Hs[6]<<8|Hs[7]),Gs=0,Ws=0;function Vs(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Ds)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var s=0;s<16;s++)e[n+s]=i[s];return e||js(i)}var Js=Vs;Js.v1=function(t,e,r){var n=e&&r||0,i=e||[],s=void 0!==(t=t||{}).clockseq?t.clockseq:Ks,o=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Ws+1,h=o-Gs+(a-Ws)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||o>Gs)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Gs=o,Ws=a,Ks=s;var l=(1e4*(268435455&(o+=122192928e5))+a)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var u=o/4294967296*1e4&268435455;i[n++]=u>>>8&255,i[n++]=255&u,i[n++]=u>>>24&15|16,i[n++]=u>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var f=t.node||qs,c=0;c<6;c++)i[n+c]=f[c];return e||js(i)},Js.v4=Vs,Js.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=Us[t])});i<16;)e[n+i++]=0;return e},Js.unparse=js;var Zs=Js;class Xs extends lt{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function $s(t,e,r){let n=JSON.parse(t),i=Ps(e),s=function(t,e){let r=Ms(xs(n,"crypto/ciphertext"));if(P(function(t,e){return Dt(_([t,e]))}(t.slice(16,32),r)).substring(2)!==xs(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===xs(n,"crypto/cipher")){let r=Ms(xs(n,"crypto/cipherparams/iv")),i=new Ss.Counter(r);return E(new Ss.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),s=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let o=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==o)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:o,privateKey:P(i)};if("0.1"===xs(n,"x-ethers/version")){let t=Ms(xs(n,"x-ethers/mnemonicCiphertext")),r=Ms(xs(n,"x-ethers/mnemonicCounter")),i=new Ss.Counter(r),o=new Ss.ModeOfOperation.ctr(s,i),h=xs(n,"x-ethers/path")||ps,l=vs(E(o.decrypt(t))),u=ms.fromMnemonic(l).derivePath(h);if(u.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=u.mnemonic,a.path=u.path}return new Xs(a)};return new Promise(function(t,e){let o=xs(n,"crypto/kdf");if(o&&"string"==typeof o)if("scrypt"===o.toLowerCase()){let o=Ms(xs(n,"crypto/kdfparams/salt")),a=parseInt(xs(n,"crypto/kdfparams/n")),h=parseInt(xs(n,"crypto/kdfparams/r")),l=parseInt(xs(n,"crypto/kdfparams/p"));if(!a||!h||!l)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(xs(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Bs(i,o,a,h,l,64,function(n,i,o){if(n)n.progress=i,e(n);else if(o){o=E(o);let n=s(o,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===o.toLowerCase()){let r=Ms(xs(n,"crypto/kdfparams/salt")),o=null,a=xs(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)o="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));o="sha512"}let h=parseInt(xs(n,"crypto/kdfparams/c")),l=parseInt(xs(n,"crypto/kdfparams/dklen"));if(32!==l)return void e(new Error("unsupported key-derivation derived-key length"));let u=E(ei(i,r,h,l,o)),f=s(u,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Qs(t,e,r){if(Is(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=Ps(e);let n=$t(xs(r,"ethaddr")),i=Ms(xs(r,"encseed"));i&&i.length%16==0||Ts.throwArgumentError("invalid encseed","json",t);let s=E(ei(e,e,2e3,32,"sha256")).slice(0,16),o=i.slice(0,16),a=i.slice(16),h=E(new Ss.ModeOfOperation.cbc(s,o).decrypt(a));h=Ss.padding.pkcs7.strip(h);let l="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&Ys.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||ps;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(ms.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&Ys.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&Ys.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!lr.isProvider(e)&&Ys.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new to(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Dt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(B(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(ms.fromMnemonic(t.mnemonic).derivePath(t.path||ps).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=E(t.privateKey),s=Ps(e),o=null,a=t.path;t.mnemonic&&(o=E(ys(t.mnemonic)),a||(a=ps));let h=r.client;h||(h="ethers.js");let l=null;l=r.salt?E(r.salt):As(32);let u=null;if(r.iv){if(16!==(u=E(r.iv)).length)throw new Error("invalid iv")}else u=As(16);let f=null;if(r.uuid){if(16!==(f=E(r.uuid)).length)throw new Error("invalid uuid")}else f=As(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Bs(s,l,c,d,p,64,function(s,m,g){if(s)s.progress=m,r(s);else if(g){let r=(g=E(g)).slice(0,16),s=g.slice(16,32),m=g.slice(32,64),y=new Ss.Counter(u),v=E(new Ss.ModeOfOperation.ctr(r,y).encrypt(i)),b=Dt(_([s,v])),w={address:t.address.substring(2).toLowerCase(),id:Zs.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:P(u).substring(2)},ciphertext:P(v).substring(2),kdf:"scrypt",kdfparams:{salt:P(l).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(o){let t=As(16),e=new Ss.Counter(t),r=E(new Ss.ModeOfOperation.ctr(m,e).encrypt(o)),n=new Date,i=n.getUTCFullYear()+"-"+ks(n.getUTCMonth()+1,2)+"-"+ks(n.getUTCDate(),2)+"T"+ks(n.getUTCHours(),2)+"-"+ks(n.getUTCMinutes(),2)+"-"+ks(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:h,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:P(t).substring(2),mnemonicCiphertext:P(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=As(16);t||(t={}),t.extraEntropy&&(e=E(T(Dt(_([e,t.extraEntropy])),0,16)));let r=vs(e,t.locale);return to.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Qs(t,e,r).then(t=>new to(t))}static fromMnemonic(t,e,r){return e||(e=ps),new to(ms.fromMnemonic(t,null,r).derivePath(e))}}const eo=new p("networks/5.0.0-beta.128");function ro(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function no(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const io={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ro("homestead")},so={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ro("ropsten")},oo={unspecified:{chainId:0,name:"unspecified"},homestead:io,mainnet:io,morden:{chainId:2,name:"morden"},ropsten:so,testnet:so,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ro("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ro("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ro("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:no("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:no("https://web3.gastracker.io/morden","classicTestnet")}};function ao(t){if(null==t)return null;if("number"==typeof t){for(let e in oo){let r=oo[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=oo[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=oo[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&eo.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&eo.throwArgumentError("invalid network chainId","network",t),t)}var ho=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function s(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function y(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];y.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,s){var o=new m(t,n);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function l(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new y(n,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),o.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),o.signal&&(o.signal.addEventListener("abort",l),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",l)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=h,t.Request=m,t.Response=y),e.Headers=h,e.Request=m,e.Response=y,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),lo=(ho.fetch,ho.Headers,ho.Request,ho.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(o=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&mo.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+co(Ae(e))}}}return new Promise(function(t,a){let h=null;o&&(h=setTimeout(()=>{null!=h&&(h=null,a(mo.makeError("timeout",p.errors.TIMEOUT,{timeout:o})))},o));let l=()=>{null!=h&&(clearTimeout(h),h=null)};e&&(s.method="POST",s.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let u={};return Object.keys(n).forEach(t=>{let e=n[t];u[e.key]=e.value}),s.headers=u,ho(i,s).then(t=>t.text().then(e=>(t.ok||mo.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){mo.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){mo.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{l(),t(e)},t=>{l(),a(t)})})}function yo(t,e){return e||(e={}),null==(e=ot(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,s=!1,o=()=>!s&&(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,h=0;!function i(){return t().then(function(t){if(void 0!==t)o()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!s){if(++h>a)return void(o()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){o()&&n(t)})}()})}const vo="providers/5.0.0-beta.140",bo=new p(vo);class wo{constructor(){bo.checkNew(new.target,wo),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),s=this.hash.bind(this),o=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:s,blockHash:wo.allowNull(s,null),blockNumber:wo.allowNull(a,null),transactionIndex:wo.allowNull(a,null),confirmations:wo.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:wo.allowNull(e,null),value:r,nonce:a,data:i,r:wo.allowNull(this.uint256),s:wo.allowNull(this.uint256),v:wo.allowNull(a),creates:wo.allowNull(e,null),raw:wo.allowNull(i)},t.transactionRequest={from:wo.allowNull(e),nonce:wo.allowNull(a),gasLimit:wo.allowNull(r),gasPrice:wo.allowNull(r),to:wo.allowNull(e),value:wo.allowNull(r),data:wo.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:wo.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:s,address:e,topics:wo.arrayOf(s),data:i,logIndex:a,blockHash:s},t.receipt={to:wo.allowNull(this.address),from:wo.allowNull(this.address),contractAddress:wo.allowNull(e,null),transactionIndex:a,root:wo.allowNull(s),gasUsed:r,logsBloom:wo.allowNull(i),blockHash:s,transactionHash:s,logs:wo.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:wo.allowNull(a,null),cumulativeGasUsed:r,status:wo.allowNull(a)},t.block={hash:s,parentHash:s,number:a,timestamp:a,nonce:wo.allowNull(o),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:wo.allowNull(wo.arrayOf(s))},t.blockWithTransactions=ot(t.block),t.blockWithTransactions.transactions=wo.allowNull(wo.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:wo.allowNull(n,void 0),toBlock:wo.allowNull(n,void 0),blockHash:wo.allowNull(s,void 0),address:wo.allowNull(e,void 0),topics:wo.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:wo.allowNull(a),blockHash:wo.allowNull(s),transactionIndex:a,removed:wo.allowNull(this.boolean.bind(this)),address:e,data:wo.allowFalsish(i,"0x"),topics:wo.arrayOf(s),transactionHash:s,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bo.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(T(t,12));return e===ue?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return N(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==x(r)?bo.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),wo.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return wo.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=wo.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return wo.check(this.formats.receiptLog,t)}receipt(t){let e=wo.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return wo.check(this.formats.filter,t)}filterLog(t){return wo.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const Eo=new p(vo);function _o(t){return null==t?"null":(32!==x(t)&&Eo.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function Ao(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[_o(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return _o(t)}).join("&")}function So(t){if("string"==typeof t){if(32===x(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+Ao(t);if(hr.isForkEvent(t))throw Eo.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+Ao(t.topics||[])}throw new Error("invalid event - "+t)}function Mo(){return(new Date).getTime()}class ko{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let Po=null,xo=1;class To extends lr{constructor(t){if(Eo.checkNew(new.target,lr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):Eo.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==Po&&(Po=new wo),Po}static getNetwork(t){return ao(null==t?"homestead":t)}poll(){let t=xo++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let s=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(s);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Mo();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>N(t))}).then(t=>P(t))}_wrapTransaction(t,e){if(null!=e&&32!==x(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&Eo.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&Eo.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>P(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&Eo.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){Eo.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return yo(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return yo(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return yo(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>wo.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&Eo.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||Eo.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=E(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return Eo.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ko(So(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=So(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=So(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=So(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=So(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=So(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const No=new p(vo);function Io(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Ro(t){return t?t.toLowerCase():t}const Co={};class Bo extends cr{constructor(t,e,r){if(No.checkNew(new.target,Bo),super(),t!==Co)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):No.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return No.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Oo(Co,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&No.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=ot(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=ot(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&No.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&No.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&No.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return No.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>yo(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Ae(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),P(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Oo extends Bo{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fo={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Do extends To{constructor(t,e){if(No.checkNew(new.target,Do),"string"==typeof t&&null===e&&ao(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(ao(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(ao(U.from(e).toNumber()))}).catch(t=>{e(No.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Bo(Co,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ht(r),provider:this}),go(this.connection,JSON.stringify(r),Io).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Ro(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Ro(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Ro(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Ro(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&No.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&No.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&No.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):No.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Ro(e.filter.address)),this.send("eth_getLogs",[e.filter])}return No.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=ot(Fo);if(e)for(let t in e)e[t]&&(r[t]=!0);st(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=N(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=P(t[e]))}),n}}const Lo=new p(vo);class Uo extends Do{constructor(t,e){Lo.checkAbstract(new.target,Uo),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Lo.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Lo.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return ao(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Lo.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zo=new p(vo),jo="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Ho=new p(vo);const qo=new p(vo);function Ko(t){let e=[];for(let r in t){if(null==t[r])continue;let n=P(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=N(n)),e.push(r+"="+n)}return e.join("&")}function Go(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Wo(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vo(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Jo extends To{constructor(t,e){qo.checkNew(new.target,Jo),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),go(t,null,e||Wo).then(e=>(this.emit("debug",{action:"response",request:t,response:ht(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Go);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Wo);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Wo);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qo.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qo.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qo.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ko(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ko(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vo(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vo(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let s=this;return i(r+=n,Go).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?s.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Go).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),go(n,null,Go).then(t=>{this.emit("debug",{action:"response",request:n,response:ht(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zo=new p(vo);function Xo(){return(new Date).getTime()}function $o(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zo.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qo=1;class Yo extends To{constructor(t,e,r){Zo.checkNew(new.target,Yo),0===t.length&&Zo.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zo.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zo.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zo.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$o(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($o(t)||Zo.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zo.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xo(),n=_s(this.providers).map((n,i)=>{let s=this.weights[i],o=Qo++;return{run:()=>{let i=Xo(),a=i-r;return this.emit("debug",{action:"request",rid:o,backend:{weight:s,start:a,provider:n},request:{method:t,params:ht(e)},provider:this}),Yo.doPerform(n,t,e).then(r=>{let h=Xo()-i;return this.emit("debug",{action:"response",rid:o,backend:{weight:s,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},response:ht(r)}),{weight:s,result:r}},r=>{let h=Xo()-i;return this.emit("debug",{action:"response",rid:o,backend:{weight:s,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},error:r}),{weight:s,error:r}})},weight:s}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let s=null,o=0,a={},h=()=>{if(0===n.length)return;let l=n.shift();o+=l.weight,l.run().then(u=>{if(null!==a){if(o-=l.weight,u.error)null==s&&(s=u.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(u.result);null==a[t]&&(a[t]=[]),a[t].push(u);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===o){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===s&&(s=Zo.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(s)}setTimeout(h,0)}}),o{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(vo),ia="84842078b09946638c03157f83405213";const sa=new p(vo),oa="ETHERS_JS_SHARED";const aa=new p(vo);class ha extends Do{constructor(t,e){aa.checkNew(new.target,ha),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var la=Object.freeze({Provider:lr,BaseProvider:To,FallbackProvider:Yo,AlchemyProvider:class extends Uo{static getApiKey(t){return null==t?jo:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zo.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Uo{static getUrl(t,e){null!=e&&Ho.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Ho.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Jo,InfuraProvider:class extends Uo{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Do,NodesmithProvider:class extends Uo{static getApiKey(t){return t||oa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:sa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ha,IpcProvider:ra,JsonRpcSigner:Bo,getNetwork:ao,Formatter:wo});const ua=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?S(r,32):E(r);case"string":return Ae(r);case"bytes":return E(r);case"bool":return r=r?"0x01":"0x00",n?S(r,32):E(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),S(r=U.from(r).toTwos(t),t/8)}if(i=e.match(ua)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(E(r).byteLength!==t)throw new Error("invalid value for "+e);return n?E((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let s=[];return r.forEach(function(e){s.push(t(n,e,!0))}),_(s)}throw new Error("unknown type - "+e)}(t,e[n]))}),P(_(r))}const ma=new p("units/5.0.0-beta.126"),ga=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ya(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return $(t,null!=e?e:18)}function va(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return Q(t,null!=e?e:18)}var ba=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:Et,EventFragment:_t,FunctionFragment:Pt,ParamType:bt,FormatTypes:yt,Logger:p,RLP:Kt,fetchJson:go,poll:yo,checkProperties:st,deepCopy:ht,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:ot,arrayify:E,concat:_,stripZeros:A,zeroPad:S,defaultPath:ps,HDNode:ms,SigningKey:qi,Interface:sr,base64:po,hexlify:P,isHexString:M,hexStripZeros:I,hexValue:N,hexZeroPad:R,hexDataLength:x,hexDataSlice:T,nameprep:Le,_toEscapedUtf8String:function(t,e){return'"'+_e(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Se(t):Se(55296+((t-=65536)>>10&1023))+Se(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Ae,toUtf8CodePoints:Pe,toUtf8String:ke,formatBytes32String:function(t){let e=Ae(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return P(_([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=E(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new o($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return ya(t,18)},parseEther:function(t){return va(t,18)},formatUnits:ya,parseUnits:va,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&ma.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let s=[];for(;r.length;){if(r.length<=3){s.unshift(r);break}{let t=r.length-3;s.unshift(r.substring(t)),r=r.substring(0,t)}}return n+s.join(",")+i},keccak256:Dt,sha256:Qn,randomBytes:As,solidityPack:pa,solidityKeccak256:function(t,e){return Dt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:C,joinSignature:B,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Is(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Rs(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:ys,entropyToMnemonic:vs,isValidMnemonic:function(t,e){try{return ys(t,e),!0}catch(t){}return!1},mnemonicToSeed:gs,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return Ee},Indexed:ir});const wa="ethers/5.0.0-beta.155",Ea=p.errors,_a=new p(wa);function Aa(t,e){null==t&&(t="homestead");let r=ao(t);return r&&r._defaultProvider||_a.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(la,e)}var Sa=Object.freeze({Signer:cr,Wallet:to,VoidSigner:dr,getDefaultProvider:Aa,providers:la,Contract:Ar,ContractFactory:Sr,BigNumber:U,FixedNumber:tt,constants:ve,errors:Ea,logger:_a,utils:ba,wordlists:ss,version:wa,Wordlist:is});export{U as BigNumber,Ar as Contract,Sr as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,to as Wallet,is as Wordlist,ve as constants,Ea as errors,Sa as ethers,Aa as getDefaultProvider,_a as logger,la as providers,ba as utils,wa as version,ss as wordlists}; diff --git a/packages/ethers/dist/ethers.umd.js b/packages/ethers/dist/ethers.umd.js index 4be9d3232..1ecbc1eb9 100644 --- a/packages/ethers/dist/ethers.umd.js +++ b/packages/ethers/dist/ethers.umd.js @@ -13767,7 +13767,7 @@ result = result._derive(index); } else { - throw new Error("invlaid path component - " + component); + throw new Error("invalid path component - " + component); } } return result; @@ -20607,15 +20607,6 @@ var utils_75 = utils$3.SupportedAlgorithms; var utils_76 = utils$3.UnicodeNormalizationForm; - var platform = createCommonjsModule(function (module, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.platform = "node"; - }); - - var platform$1 = unwrapExports(platform); - var platform_1 = platform.platform; - var _version$K = createCommonjsModule(function (module, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); @@ -20660,9 +20651,6 @@ exports.errors = errors; //////////////////////// // Compile-Time Constants - // This is empty in node, and used by browserify to inject extra goodies - - exports.platform = platform.platform; // This is generated by "npm run dist" exports.version = _version$K.version; @@ -20700,10 +20688,9 @@ var ethers_11 = ethers.wordlists; var ethers_12 = ethers.utils; var ethers_13 = ethers.errors; - var ethers_14 = ethers.platform; - var ethers_15 = ethers.version; - var ethers_16 = ethers.logger; - var ethers_17 = ethers.getDefaultProvider; + var ethers_14 = ethers.version; + var ethers_15 = ethers.logger; + var ethers_16 = ethers.getDefaultProvider; var lib$p = createCommonjsModule(function (module, exports) { "use strict"; diff --git a/packages/ethers/dist/ethers.umd.min.js b/packages/ethers/dist/ethers.umd.min.js index 25e5dd16a..47b089258 100644 --- a/packages/ethers/dist/ethers.umd.min.js +++ b/packages/ethers/dist/ethers.umd.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],R=8191&T,C=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],q=8191&K,W=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,W)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,z),i=(i=Math.imul(R,H))+Math.imul(C,z)|0,o=Math.imul(C,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(R,q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Ce=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Re,u[17]=Ce,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.128"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.128"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.129"})),d=(r(h),h.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(h.version),a={};r.isBigNumberish=function(e){return null!=e&&(u.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var u=function(){function e(t,r){var n=this.constructor;o.checkNew(n,e),t!==a&&o.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return d(p(this).fromTwos(e))},e.prototype.toTwos=function(e){return d(p(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return d(p(this).add(p(e)))},e.prototype.sub=function(e){return d(p(this).sub(p(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&m("division by zero","div"),d(p(this).div(p(t)))},e.prototype.mul=function(e){return d(p(this).mul(p(e)))},e.prototype.mod=function(e){return d(p(this).mod(p(e)))},e.prototype.pow=function(e){return d(p(this).pow(p(e)))},e.prototype.maskn=function(e){return d(p(this).maskn(e))},e.prototype.eq=function(e){return p(this).eq(p(e))},e.prototype.lt=function(e){return p(this).lt(p(e))},e.prototype.lte=function(e){return p(this).lte(p(e))},e.prototype.gt=function(e){return p(this).gt(p(e))},e.prototype.gte=function(e){return p(this).gte(p(e))},e.prototype.isZero=function(){return p(this).isZero()},e.prototype.toNumber=function(){try{return p(this).toNumber()}catch(e){m("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&o.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(a,c(t)):t.match(/^-?[0-9]+$/)?new e(a,c(new i.BN(t))):o.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&m("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&m("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):o.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function c(e){if("string"!=typeof e)return c(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&o.throwArgumentError("invalid hex","value",e),"0x00"===(e=c(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return u.from(c(e))}function p(e){var t=u.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function m(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.formatFixed=p.formatFixed,t.FixedFormat=p.FixedFormat,t.FixedNumber=p.FixedNumber,t.parseFixed=p.parseFixed})),g=(r(m),m.BigNumber,m.formatFixed,m.FixedFormat,m.FixedNumber,m.parseFixed,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.130"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.136"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,R,C,B,I,F,L,j,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,R=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,C=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&R,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&C,e[15]=N^~R&B,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~C&S,e[17]=R^~B&M,e[26]=z^~K&I,e[27]=H^~q&F,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=C^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=q^~F&j,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.127"})),S=(r(A),A.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(A.version);function a(e){l.isHexString(e,20)||o.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=l.arrayify(E.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var u={},c=0;c<10;c++)u[String(c)]=String(c);for(c=0;c<26;c++)u[String.fromCharCode(65+c)]=String(10+c);var h,d=Math.floor((h=9007199254740991,Math.log10?Math.log10(h):Math.log(h)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=u[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=a(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=a("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=l.stripZeros(l.arrayify(e.nonce));return m(l.hexDataSlice(E.keccak256(P.encode([t,r])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,C.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new R.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.127"})),q=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(q.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(W),W.LogDescription,W.TransactionDescription,W.Indexed,W.Result,W.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=W.Indexed,t.Interface=W.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.130"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.131"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.136"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger($.version),a={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function s(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return s(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return s(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return s(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function u(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],u=0;u0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=v;var b=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&o.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&o.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Rt=Tt;function Ct(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Ct.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Rt.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Rt,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var qt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new qt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new qt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.128"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.127"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?C.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.127"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return q.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.129"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invlaid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.127"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},R.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},R.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var C=function(e,t){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof R||(t=new R(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};C.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}R(C)};C()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Rr=0;Rr<256;Rr++)Nr[Rr]=(Rr+256).toString(16).substr(1),Tr[Nr[Rr]]=Rr;function Cr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Cr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Cr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Cr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),R=l.arrayify(T.encrypt(f)),C=new Date,B=C.getUTCFullYear()+"-"+Pr.zpad(C.getUTCMonth()+1,2)+"-"+Pr.zpad(C.getUTCDate(),2)+"T"+Pr.zpad(C.getUTCHours(),2)+"-"+Pr.zpad(C.getUTCMinutes(),2)+"-"+Pr.zpad(C.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(R).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),qr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.129"})),Wr=(r(qr),qr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(qr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(q.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(q.hashMessage(e),t)}})),Gr=(r(Wr),Wr.Wallet,Wr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.128"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.140"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===C.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),mn=(r(pn),pn.pack,pn.keccak256,pn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.126"})),gn=(r(mn),mn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(mn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),yn=(r(gn),gn.commify,gn.formatUnits,gn.parseUnits,gn.formatEther,gn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=q.hashMessage,r.id=q.id,r.isValidName=q.isValidName,r.namehash=q.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=pn.keccak256,r.solidityPack=pn.pack,r.soliditySha256=pn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=gn.commify,r.formatEther=gn.formatEther,r.parseEther=gn.parseEther,r.formatUnits=gn.formatUnits,r.parseUnits=gn.parseUnits,r.verifyMessage=Wr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),vn=(r(yn),yn.AbiCoder,yn.defaultAbiCoder,yn.EventFragment,yn.FormatTypes,yn.Fragment,yn.FunctionFragment,yn.Indexed,yn.Interface,yn.ParamType,yn.getAddress,yn.getContractAddress,yn.getIcapAddress,yn.isAddress,yn.base64,yn.arrayify,yn.concat,yn.hexDataSlice,yn.hexDataLength,yn.hexlify,yn.hexStripZeros,yn.hexValue,yn.hexZeroPad,yn.isHexString,yn.joinSignature,yn.zeroPad,yn.splitSignature,yn.stripZeros,yn.hashMessage,yn.id,yn.isValidName,yn.namehash,yn.defaultPath,yn.entropyToMnemonic,yn.HDNode,yn.isValidMnemonic,yn.mnemonicToEntropy,yn.mnemonicToSeed,yn.getJsonWalletAddress,yn.keccak256,yn.Logger,yn.sha256,yn.solidityKeccak256,yn.solidityPack,yn.soliditySha256,yn.randomBytes,yn.checkProperties,yn.deepCopy,yn.defineReadOnly,yn.getStatic,yn.resolveProperties,yn.shallowCopy,yn.RLP,yn.computePublicKey,yn.recoverPublicKey,yn.SigningKey,yn.formatBytes32String,yn.nameprep,yn.parseBytes32String,yn._toEscapedUtf8String,yn.toUtf8Bytes,yn.toUtf8CodePoints,yn.toUtf8String,yn.computeAddress,yn.parseTransaction,yn.recoverAddress,yn.serializeTransaction,yn.commify,yn.formatEther,yn.parseEther,yn.formatUnits,yn.parseUnits,yn.verifyMessage,yn.fetchJson,yn.poll,yn.SupportedAlgorithms,yn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.platform="node"})),bn=(r(vn),vn.platform,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.155"})),wn=(r(bn),bn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=Wr.Wallet;var i=n(C);r.constants=i;var o=n(dn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(yn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.platform=vn.platform,r.version=bn.version;var u=new f.Logger(bn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),_n=(r(wn),wn.Contract,wn.ContractFactory,wn.BigNumber,wn.FixedNumber,wn.Signer,wn.VoidSigner,wn.Wallet,wn.constants,wn.providers,wn.Wordlist,wn.wordlists,wn.utils,wn.errors,wn.platform,wn.version,wn.logger,wn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(wn);r.ethers=i,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(wn)})),En=r(_n),Pn=_n.ethers;e.default=En,e.ethers=Pn,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],R=8191&T,C=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],q=8191&K,W=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,W)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,z),i=(i=Math.imul(R,H))+Math.imul(C,z)|0,o=Math.imul(C,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(R,q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Ce=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Re,u[17]=Ce,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.128"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.128"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.129"})),d=(r(h),h.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(h.version),a={};r.isBigNumberish=function(e){return null!=e&&(u.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var u=function(){function e(t,r){var n=this.constructor;o.checkNew(n,e),t!==a&&o.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return d(p(this).fromTwos(e))},e.prototype.toTwos=function(e){return d(p(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return d(p(this).add(p(e)))},e.prototype.sub=function(e){return d(p(this).sub(p(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&m("division by zero","div"),d(p(this).div(p(t)))},e.prototype.mul=function(e){return d(p(this).mul(p(e)))},e.prototype.mod=function(e){return d(p(this).mod(p(e)))},e.prototype.pow=function(e){return d(p(this).pow(p(e)))},e.prototype.maskn=function(e){return d(p(this).maskn(e))},e.prototype.eq=function(e){return p(this).eq(p(e))},e.prototype.lt=function(e){return p(this).lt(p(e))},e.prototype.lte=function(e){return p(this).lte(p(e))},e.prototype.gt=function(e){return p(this).gt(p(e))},e.prototype.gte=function(e){return p(this).gte(p(e))},e.prototype.isZero=function(){return p(this).isZero()},e.prototype.toNumber=function(){try{return p(this).toNumber()}catch(e){m("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&o.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(a,c(t)):t.match(/^-?[0-9]+$/)?new e(a,c(new i.BN(t))):o.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&m("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&m("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):o.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function c(e){if("string"!=typeof e)return c(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&o.throwArgumentError("invalid hex","value",e),"0x00"===(e=c(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return u.from(c(e))}function p(e){var t=u.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function m(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.formatFixed=p.formatFixed,t.FixedFormat=p.FixedFormat,t.FixedNumber=p.FixedNumber,t.parseFixed=p.parseFixed})),g=(r(m),m.BigNumber,m.formatFixed,m.FixedFormat,m.FixedNumber,m.parseFixed,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.130"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.136"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,R,C,B,I,F,L,j,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,R=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,C=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&R,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&C,e[15]=N^~R&B,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~C&S,e[17]=R^~B&M,e[26]=z^~K&I,e[27]=H^~q&F,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=C^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=q^~F&j,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.127"})),S=(r(A),A.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(A.version);function a(e){l.isHexString(e,20)||o.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=l.arrayify(E.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var u={},c=0;c<10;c++)u[String(c)]=String(c);for(c=0;c<26;c++)u[String.fromCharCode(65+c)]=String(10+c);var h,d=Math.floor((h=9007199254740991,Math.log10?Math.log10(h):Math.log(h)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=u[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=a(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=a("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=l.stripZeros(l.arrayify(e.nonce));return m(l.hexDataSlice(E.keccak256(P.encode([t,r])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,C.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new R.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.127"})),q=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(q.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(W),W.LogDescription,W.TransactionDescription,W.Indexed,W.Result,W.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=W.Indexed,t.Interface=W.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.130"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.131"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.136"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger($.version),a={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function s(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return s(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return s(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return s(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function u(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],u=0;u0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=v;var b=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&o.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&o.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Rt=Tt;function Ct(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Ct.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Rt.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Rt,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var qt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new qt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new qt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.128"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.127"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?C.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.127"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return q.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.129"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invalid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.127"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},R.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},R.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var C=function(e,t){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof R||(t=new R(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};C.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}R(C)};C()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Rr=0;Rr<256;Rr++)Nr[Rr]=(Rr+256).toString(16).substr(1),Tr[Nr[Rr]]=Rr;function Cr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Cr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Cr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Cr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),R=l.arrayify(T.encrypt(f)),C=new Date,B=C.getUTCFullYear()+"-"+Pr.zpad(C.getUTCMonth()+1,2)+"-"+Pr.zpad(C.getUTCDate(),2)+"T"+Pr.zpad(C.getUTCHours(),2)+"-"+Pr.zpad(C.getUTCMinutes(),2)+"-"+Pr.zpad(C.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(R).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),qr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.129"})),Wr=(r(qr),qr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(qr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(q.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(q.hashMessage(e),t)}})),Gr=(r(Wr),Wr.Wallet,Wr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.128"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.140"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===C.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),mn=(r(pn),pn.pack,pn.keccak256,pn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.126"})),gn=(r(mn),mn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(mn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),yn=(r(gn),gn.commify,gn.formatUnits,gn.parseUnits,gn.formatEther,gn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=q.hashMessage,r.id=q.id,r.isValidName=q.isValidName,r.namehash=q.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=pn.keccak256,r.solidityPack=pn.pack,r.soliditySha256=pn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=gn.commify,r.formatEther=gn.formatEther,r.parseEther=gn.parseEther,r.formatUnits=gn.formatUnits,r.parseUnits=gn.parseUnits,r.verifyMessage=Wr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),vn=(r(yn),yn.AbiCoder,yn.defaultAbiCoder,yn.EventFragment,yn.FormatTypes,yn.Fragment,yn.FunctionFragment,yn.Indexed,yn.Interface,yn.ParamType,yn.getAddress,yn.getContractAddress,yn.getIcapAddress,yn.isAddress,yn.base64,yn.arrayify,yn.concat,yn.hexDataSlice,yn.hexDataLength,yn.hexlify,yn.hexStripZeros,yn.hexValue,yn.hexZeroPad,yn.isHexString,yn.joinSignature,yn.zeroPad,yn.splitSignature,yn.stripZeros,yn.hashMessage,yn.id,yn.isValidName,yn.namehash,yn.defaultPath,yn.entropyToMnemonic,yn.HDNode,yn.isValidMnemonic,yn.mnemonicToEntropy,yn.mnemonicToSeed,yn.getJsonWalletAddress,yn.keccak256,yn.Logger,yn.sha256,yn.solidityKeccak256,yn.solidityPack,yn.soliditySha256,yn.randomBytes,yn.checkProperties,yn.deepCopy,yn.defineReadOnly,yn.getStatic,yn.resolveProperties,yn.shallowCopy,yn.RLP,yn.computePublicKey,yn.recoverPublicKey,yn.SigningKey,yn.formatBytes32String,yn.nameprep,yn.parseBytes32String,yn._toEscapedUtf8String,yn.toUtf8Bytes,yn.toUtf8CodePoints,yn.toUtf8String,yn.computeAddress,yn.parseTransaction,yn.recoverAddress,yn.serializeTransaction,yn.commify,yn.formatEther,yn.parseEther,yn.formatUnits,yn.parseUnits,yn.verifyMessage,yn.fetchJson,yn.poll,yn.SupportedAlgorithms,yn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.155"})),bn=(r(vn),vn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=Wr.Wallet;var i=n(C);r.constants=i;var o=n(dn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(yn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.version=vn.version;var u=new f.Logger(vn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),wn=(r(bn),bn.Contract,bn.ContractFactory,bn.BigNumber,bn.FixedNumber,bn.Signer,bn.VoidSigner,bn.Wallet,bn.constants,bn.providers,bn.Wordlist,bn.wordlists,bn.utils,bn.errors,bn.version,bn.logger,bn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(bn);r.ethers=i,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(bn)})),_n=r(wn),En=wn.ethers;e.default=_n,e.ethers=En,Object.defineProperty(e,"__esModule",{value:!0})}); diff --git a/packages/ethers/lib.esm/ethers.d.ts b/packages/ethers/lib.esm/ethers.d.ts index 6b8265238..2a5110075 100644 --- a/packages/ethers/lib.esm/ethers.d.ts +++ b/packages/ethers/lib.esm/ethers.d.ts @@ -12,9 +12,8 @@ declare const errors: { import { BigNumberish } from "@ethersproject/bignumber"; import { Bytes, BytesLike, Signature } from "@ethersproject/bytes"; import { Transaction, UnsignedTransaction } from "@ethersproject/transactions"; -import { platform } from "./platform"; import { version } from "./_version"; declare const logger: utils.Logger; import { ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface } from "@ethersproject/contracts"; declare function getDefaultProvider(network?: providers.Network | string, options?: any): providers.BaseProvider; -export { version, Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, platform, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist }; +export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, version, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist }; diff --git a/packages/ethers/lib.esm/ethers.js b/packages/ethers/lib.esm/ethers.js index 7737aa8bb..5fcb43b2b 100644 --- a/packages/ethers/lib.esm/ethers.js +++ b/packages/ethers/lib.esm/ethers.js @@ -11,8 +11,6 @@ import { Logger } from "@ethersproject/logger"; const errors = Logger.errors; //////////////////////// // Compile-Time Constants -// This is empty in node, and used by browserify to inject extra goodies -import { platform } from "./platform"; // This is generated by "npm run dist" import { version } from "./_version"; const logger = new Logger(version); @@ -33,7 +31,7 @@ function getDefaultProvider(network, options) { } //////////////////////// // Exports -export { version, Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, +export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, //////////////////////// // Compile-Time Constants -platform, Wordlist }; +version, Wordlist }; diff --git a/packages/ethers/lib/ethers.d.ts b/packages/ethers/lib/ethers.d.ts index 6b8265238..2a5110075 100644 --- a/packages/ethers/lib/ethers.d.ts +++ b/packages/ethers/lib/ethers.d.ts @@ -12,9 +12,8 @@ declare const errors: { import { BigNumberish } from "@ethersproject/bignumber"; import { Bytes, BytesLike, Signature } from "@ethersproject/bytes"; import { Transaction, UnsignedTransaction } from "@ethersproject/transactions"; -import { platform } from "./platform"; import { version } from "./_version"; declare const logger: utils.Logger; import { ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface } from "@ethersproject/contracts"; declare function getDefaultProvider(network?: providers.Network | string, options?: any): providers.BaseProvider; -export { version, Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, platform, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist }; +export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, version, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist }; diff --git a/packages/ethers/lib/ethers.js b/packages/ethers/lib/ethers.js index d947bc1b4..f104b996d 100644 --- a/packages/ethers/lib/ethers.js +++ b/packages/ethers/lib/ethers.js @@ -32,9 +32,6 @@ var errors = logger_1.Logger.errors; exports.errors = errors; //////////////////////// // Compile-Time Constants -// This is empty in node, and used by browserify to inject extra goodies -var platform_1 = require("./platform"); -exports.platform = platform_1.platform; // This is generated by "npm run dist" var _version_1 = require("./_version"); exports.version = _version_1.version; diff --git a/packages/ethers/package.json b/packages/ethers/package.json index 35cb218de..00656bdb1 100644 --- a/packages/ethers/package.json +++ b/packages/ethers/package.json @@ -4,49 +4,40 @@ "description": "Umbrella package for most common Ethers libraries.", "main": "./lib/index.js", "scripts": { - "dist": "npm run dist-browser && npm run dist-minified", - "dist-browser": "browserify -s ethers -g ./scripts/transform index.js -o ./dist/ethers.js", - "dist-minified": "uglifyjs --compress --mangle --output ./dist/ethers.min.js -- ./dist/ethers.js", "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abi": ">5.0.0-beta.0", - "@ethersproject/abstract-provider": ">5.0.0-beta.0", - "@ethersproject/abstract-signer": ">5.0.0-beta.0", - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/base64": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/contracts": ">5.0.0-beta.0", - "@ethersproject/hash": ">5.0.0-beta.0", - "@ethersproject/hdnode": ">5.0.0-beta.0", - "@ethersproject/json-wallets": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/networks": ">5.0.0-beta.0", - "@ethersproject/pbkdf2": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/providers": ">5.0.0-beta.0", - "@ethersproject/random": ">5.0.0-beta.0", - "@ethersproject/rlp": ">5.0.0-beta.0", - "@ethersproject/sha2": ">5.0.0-beta.0", - "@ethersproject/signing-key": ">5.0.0-beta.0", - "@ethersproject/solidity": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0", - "@ethersproject/units": ">5.0.0-beta.0", - "@ethersproject/wallet": ">5.0.0-beta.0", - "@ethersproject/web": ">5.0.0-beta.0", - "@ethersproject/wordlists": ">5.0.0-beta.0" - }, - "devDependencies": { - "browserify": "16.2.3", - "uglify-es": "3.3.9" - }, - "browser": { - "platform.js": "browser-platform.js" + "@ethersproject/abi": ">=5.0.0-beta.137", + "@ethersproject/abstract-provider": ">=5.0.0-beta.131", + "@ethersproject/abstract-signer": ">=5.0.0-beta.132", + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/base64": ">=5.0.0-beta.126", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/contracts": ">=5.0.0-beta.137", + "@ethersproject/hash": ">=5.0.0-beta.128", + "@ethersproject/hdnode": ">=5.0.0-beta.130", + "@ethersproject/json-wallets": ">=5.0.0-beta.129", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/networks": ">=5.0.0-beta.129", + "@ethersproject/pbkdf2": ">=5.0.0-beta.127", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/providers": ">=5.0.0-beta.141", + "@ethersproject/random": ">=5.0.0-beta.128", + "@ethersproject/rlp": ">=5.0.0-beta.126", + "@ethersproject/sha2": ">=5.0.0-beta.129", + "@ethersproject/signing-key": ">=5.0.0-beta.129", + "@ethersproject/solidity": ">=5.0.0-beta.126", + "@ethersproject/strings": ">=5.0.0-beta.130", + "@ethersproject/transactions": ">=5.0.0-beta.128", + "@ethersproject/units": ">=5.0.0-beta.127", + "@ethersproject/wallet": ">=5.0.0-beta.130", + "@ethersproject/web": ">=5.0.0-beta.129", + "@ethersproject/wordlists": ">=5.0.0-beta.128" }, + "browser": "./dist/ethers.umd.js", "keywords": [ "Ethereum", "ethers" @@ -60,6 +51,7 @@ "type": "git", "url": "git://github.com/ethers-io/ethers.js.git" }, - "module": "./lib.esm/index.js", - "tarballHash": "0x75cf66f7ca99a6b0c1b4a1efc948fdec6efb877ceda8cc749adc0afb1925e1d2" + "module": "./dist/ethers.esm.js", + "types": "./lib/index.d.ts", + "tarballHash": "0x745f61434bc7e817efc9b7ab44f3816b24078b664c9c666ec91e0e0af4155908" } diff --git a/packages/ethers/scripts/transform.js b/packages/ethers/scripts/transform.js deleted file mode 100644 index 9505ec067..000000000 --- a/packages/ethers/scripts/transform.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const through = require('through'); - -let show = { transformed: true, preserved: true }; - - // The elliptic package.json is only used for its version - var ellipticPackage = require('elliptic/package.json'); - ellipticPackage = JSON.stringify({ version: ellipticPackage.version }); - - var version = require('../package.json').version; - - var undef = "module.exports = undefined;"; - var empty = "module.exports = {};"; - - // This is only used in getKeyPair, which we do not use; but we'll - // leave it in tact using the browser crypto functions - var brorand = "module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; }"; - - // setImmediate is installed globally by our src.browser/shims.ts, loaded from src.ts/index.ts - var process = "module.exports = { browser: true };"; - var timers = "module.exports = { setImmediate: global.setImmediate }; "; - - function readShim(filename) { - return fs.readFileSync('./shims/' + filename + '.js').toString(); - } - - var transforms = { - - // Remove the precomputed secp256k1 points - "elliptic/lib/elliptic/precomputed/secp256k1.js": undef, - - // Remove curves we don't care about - "elliptic/curve/edwards.js": empty, - "elliptic/curve/mont.js": empty, - "elliptic/lib/elliptic/eddsa/.*": empty, - - // We only use the version from this JSON package - "elliptic/package.json" : ellipticPackage, - - // Remove unneeded hashing algorithms - "hash.js/lib/hash/sha/1.js": empty, - "hash.js/lib/hash/sha/224.js": empty, - "hash.js/lib/hash/sha/384.js": empty, - - // Swap out borland for the random bytes we already have - "brorand/index.js": brorand, - - // Used by sha3 if it exists; (so make it not exist) - "process/browser.js": process, - "timers-browserify/main.js": timers, - - "ethers/platform.js": '"use strict";\n\nexports.platform = "browser\"', - }; - - function padding(length) { - let pad = ''; - while (pad.length < length) { pad += ' '; } - return pad; - } - - function transformFile(path) { - for (var pattern in transforms) { - if (path.match(new RegExp('/' + pattern + '$'))) { - return transforms[pattern]; - } - } - return null; - } - -const dirname = path.resolve(__dirname, '../../..'); -module.exports = function(pathname, options) { - let data = ''; - return through(function(chunk) { - data += chunk; - }, function () { - var contents = fs.readFileSync(pathname).toString(); - /* - [ 'Buffer' ].forEach((word) => { - if (contents.indexOf(word) !== -1) { - console.log("Found Bad Word:", word, "in", pathname) - } - }); - */ - var transformed = transformFile(pathname); - var shortPath = pathname; - if (shortPath.substring(0, dirname.length) == dirname) { - shortPath = shortPath.substring(dirname.length); - } - var size = fs.readFileSync(pathname).length; - if (transformed != null) { - if (show.transformed) { - console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', transformed.length); - } - data = transformed; - } else if (shortPath === '/src.ts/utils/wordlist.ts') { - data += '\n\nexportWordlist = true;' - if (show.transformed) { - console.log('Transformed:', shortPath, padding(70 - shortPath.length), size, padding(6 - String(size).length), '=>', data.length); - } - } else { - if (show.preserved) { - console.log('Preserved: ', shortPath, padding(70 - shortPath.length), size); - } - } this.queue(data); - - this.queue(null); - }); -} diff --git a/packages/ethers/src.ts/browser-platform.ts b/packages/ethers/src.ts/browser-platform.ts deleted file mode 100644 index ada08efbd..000000000 --- a/packages/ethers/src.ts/browser-platform.ts +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; - -export const platform = "browser"; - diff --git a/packages/ethers/src.ts/ethers.ts b/packages/ethers/src.ts/ethers.ts index c365c4fe2..f4019de5e 100644 --- a/packages/ethers/src.ts/ethers.ts +++ b/packages/ethers/src.ts/ethers.ts @@ -29,9 +29,6 @@ import { Transaction, UnsignedTransaction } from "@ethersproject/transactions"; //////////////////////// // Compile-Time Constants -// This is empty in node, and used by browserify to inject extra goodies -import { platform } from "./platform"; - // This is generated by "npm run dist" import { version } from "./_version"; @@ -75,8 +72,6 @@ function getDefaultProvider(network?: providers.Network | string, options?: any) // Exports export { - version, - Signer, Wallet, @@ -104,8 +99,7 @@ export { //////////////////////// // Compile-Time Constants - platform, -// version, + version, //////////////////////// diff --git a/packages/ethers/src.ts/platform.ts b/packages/ethers/src.ts/platform.ts deleted file mode 100644 index 54b1039c1..000000000 --- a/packages/ethers/src.ts/platform.ts +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; - -export const platform = "node"; diff --git a/packages/experimental/package.json b/packages/experimental/package.json index cfc199f48..6ad4c8dd7 100644 --- a/packages/experimental/package.json +++ b/packages/experimental/package.json @@ -7,8 +7,8 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/web": ">5.0.0-beta.0", - "ethers": ">5.0.0-beta.0", + "@ethersproject/web": ">=5.0.0-beta.129", + "ethers": ">=5.0.0-beta.156", "scrypt-js": "2.0.4" }, "keywords": [ @@ -25,5 +25,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xaef8cc57062b7338b34d09bae80d7e320fd3f33d2623b76e30efb1a2b064bcc9" + "types": "./lib/index.d.ts", + "tarballHash": "0x2d128ae608d72a963cd452b60ef6e7de728616a5db5aa3d954563c1e5e5a61dd" } diff --git a/packages/hash/package.json b/packages/hash/package.json index 227b925ba..24674653e 100644 --- a/packages/hash/package.json +++ b/packages/hash/package.json @@ -7,10 +7,10 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/strings": ">=5.0.0-beta.130" }, "keywords": [ "Ethereum", @@ -26,5 +26,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x3bf4cb63c74debd7ce364c5193bc17eeb89162846505175bddd8eae172724d12" + "types": "./lib/index.d.ts", + "tarballHash": "0xc98b05c98e389f24c4a131d48e699fe8c71fdce6314e08c85771d8105c11a3a6" } diff --git a/packages/hdnode/lib.esm/index.js b/packages/hdnode/lib.esm/index.js index 0494c10e4..250566cf6 100644 --- a/packages/hdnode/lib.esm/index.js +++ b/packages/hdnode/lib.esm/index.js @@ -156,7 +156,7 @@ export class HDNode { result = result._derive(index); } else { - throw new Error("invlaid path component - " + component); + throw new Error("invalid path component - " + component); } } return result; diff --git a/packages/hdnode/lib/index.js b/packages/hdnode/lib/index.js index 3c6a8c0ba..ed0cf0644 100644 --- a/packages/hdnode/lib/index.js +++ b/packages/hdnode/lib/index.js @@ -162,7 +162,7 @@ var HDNode = /** @class */ (function () { result = result._derive(index); } else { - throw new Error("invlaid path component - " + component); + throw new Error("invalid path component - " + component); } } return result; diff --git a/packages/hdnode/package.json b/packages/hdnode/package.json index a10da0eab..ab5e3a41f 100644 --- a/packages/hdnode/package.json +++ b/packages/hdnode/package.json @@ -7,18 +7,18 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abstract-signer": ">5.0.0-beta.0", - "@ethersproject/basex": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/pbkdf2": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/sha2": ">5.0.0-beta.0", - "@ethersproject/signing-key": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0", - "@ethersproject/wordlists": ">5.0.0-beta.0" + "@ethersproject/abstract-signer": ">=5.0.0-beta.132", + "@ethersproject/basex": ">=5.0.0-beta.127", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/pbkdf2": ">=5.0.0-beta.127", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/sha2": ">=5.0.0-beta.129", + "@ethersproject/signing-key": ">=5.0.0-beta.129", + "@ethersproject/strings": ">=5.0.0-beta.130", + "@ethersproject/transactions": ">=5.0.0-beta.128", + "@ethersproject/wordlists": ">=5.0.0-beta.128" }, "keywords": [ "Ethereum", @@ -34,5 +34,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x1aa41472296a4ab9726dfaa3c12a9ec142120e45fa76441bd4001f23f7c6c71f" + "types": "./lib/index.d.ts", + "tarballHash": "0x9640d4f7336254f291b53454beee842a17fe3d364a333a7ca36d4c0a2f379c4b" } diff --git a/packages/json-wallets/package.json b/packages/json-wallets/package.json index 53a2dfc85..939b551be 100644 --- a/packages/json-wallets/package.json +++ b/packages/json-wallets/package.json @@ -7,17 +7,17 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abstract-signer": ">5.0.0-beta.0", - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/hdnode": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/pbkdf2": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/random": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0", + "@ethersproject/abstract-signer": ">=5.0.0-beta.132", + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/hdnode": ">=5.0.0-beta.130", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/pbkdf2": ">=5.0.0-beta.127", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/random": ">=5.0.0-beta.128", + "@ethersproject/strings": ">=5.0.0-beta.130", + "@ethersproject/transactions": ">=5.0.0-beta.128", "aes-js": "3.0.0", "scrypt-js": "2.0.4", "uuid": "2.0.1" @@ -36,5 +36,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x7bdd9f912bcc5995dd1556175bf3b9b2569e7bf31fec95e4a6fee21fc9c91308" + "types": "./lib/index.d.ts", + "tarballHash": "0x02535f91fea9a0ded1739f635ab6385467386dabfdfd7340c35fdab99e43ce2b" } diff --git a/packages/keccak256/package.json b/packages/keccak256/package.json index 353b0eb1c..fbb53ca16 100644 --- a/packages/keccak256/package.json +++ b/packages/keccak256/package.json @@ -7,7 +7,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", + "@ethersproject/bytes": ">=5.0.0-beta.129", "js-sha3": "0.5.7" }, "keywords": [ @@ -24,5 +24,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x1292347cbf0e4d2c969b299a48c285da51c2b5c87eee432e1a0ca1316d3c4df3" + "types": "./lib/index.d.ts", + "tarballHash": "0x915c089d5a70dc60d293e190f5ad6f236b71d3db15b1029b2c2f9b93c1c2b874" } diff --git a/packages/logger/package.json b/packages/logger/package.json index aa4fe5234..11d5423e9 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -20,5 +20,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xe63bdaccfd4ac8b5650dfc22ab48a27ae30db28f1e7e5148d5e278d88bca9f06" + "types": "./lib/index.d.ts", + "tarballHash": "0xe9beae3de0c03fc44a9d89634010f86855ad0623a857951f623ebcc5c9e7ac99" } diff --git a/packages/networks/package.json b/packages/networks/package.json index ef23073be..db3f28d22 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -7,7 +7,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/logger": ">5.0.0-beta.0" + "@ethersproject/logger": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -23,5 +23,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xf3d4268851266407e27c78868f6274203dd14bb6d52a9568f179862f3d00f786" + "types": "./lib/index.d.ts", + "tarballHash": "0xcad125002afaa15f1dbfc70ee3b38fa76842c1d1cc001e55a655418c1a890356" } diff --git a/packages/pbkdf2/package.json b/packages/pbkdf2/package.json index 87d9301e8..db1cee4a5 100644 --- a/packages/pbkdf2/package.json +++ b/packages/pbkdf2/package.json @@ -8,8 +8,8 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/sha2": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/sha2": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -26,5 +26,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x5f104b9b5186d943d4b4f6fd7bc7a7e866ea355e39291c3aff275d57dd8badbd" + "types": "./lib/index.d.ts", + "tarballHash": "0x93daf28ab8853621286ddd002a1462951f7140322eef402e52fbc8fea6b7b3ed" } diff --git a/packages/properties/package.json b/packages/properties/package.json index f97bace02..35b614bb4 100644 --- a/packages/properties/package.json +++ b/packages/properties/package.json @@ -9,7 +9,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/logger": ">5.0.0-beta.0" + "@ethersproject/logger": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -25,5 +25,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x776280f444c3bf1c8c3581c88f3289253d6795adc776a401d17954e096bb60cb" + "types": "./lib/index.d.ts", + "tarballHash": "0x52e4e17814611ea28122bb0cd323d0879b59d95fea17acf0ef3829925629a586" } diff --git a/packages/providers/package.json b/packages/providers/package.json index 55df81a69..bc7799475 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -11,21 +11,21 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abstract-provider": ">5.0.0-beta.0", - "@ethersproject/abstract-signer": ">5.0.0-beta.0", - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/hash": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/networks": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/random": ">5.0.0-beta.0", - "@ethersproject/rlp": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0", - "@ethersproject/web": ">5.0.0-beta.0" + "@ethersproject/abstract-provider": ">=5.0.0-beta.131", + "@ethersproject/abstract-signer": ">=5.0.0-beta.132", + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/hash": ">=5.0.0-beta.128", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/networks": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/random": ">=5.0.0-beta.128", + "@ethersproject/rlp": ">=5.0.0-beta.126", + "@ethersproject/strings": ">=5.0.0-beta.130", + "@ethersproject/transactions": ">=5.0.0-beta.128", + "@ethersproject/web": ">=5.0.0-beta.129" }, "devDependencies": { "@types/node": "10.3.2" @@ -44,5 +44,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xb65f2fd000fd23cfc0ae137cf9f039249380b6639e0019ee5d2b43abec7e6271" + "types": "./lib/index.d.ts", + "tarballHash": "0x655b117ac21836fcd5bed6025dbd53583596f141bc2b67b833342f60e37038d4" } diff --git a/packages/random/package.json b/packages/random/package.json index e6c49723b..aa7b01314 100644 --- a/packages/random/package.json +++ b/packages/random/package.json @@ -8,8 +8,8 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129" }, "devDependencies": { "@types/node": "10.3.2" @@ -29,5 +29,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xc6450e8215ec6b6d0fccda331c5541d2a5a7ebf86b7d4d0fd83429c08437f826" + "types": "./lib/index.d.ts", + "tarballHash": "0x45c2e53529bd3cf7b1ba4bbbe448813aa2540b792fab4db7bdfbac9c204f1d7e" } diff --git a/packages/rlp/package.json b/packages/rlp/package.json index e005336ed..f46ad2b2c 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -7,7 +7,7 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -24,5 +24,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x33e977a875ac88214d1dd31b62f4a4fb4c18710c3b0ea453b973656c80d4d824" + "types": "./lib/index.d.ts", + "tarballHash": "0x0998523893f5ccc7d3b6029665329ccf09bfcfdea023c5190aaa4a813c8a22cc" } diff --git a/packages/sha2/package.json b/packages/sha2/package.json index aeb795347..399ba4311 100644 --- a/packages/sha2/package.json +++ b/packages/sha2/package.json @@ -8,8 +8,8 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129", "hash.js": "1.1.3" }, "keywords": [ @@ -26,5 +26,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x87b6ff04df9c0df26a7afaf9880262797538b004b0581a72d108510f5b1f9235" + "types": "./lib/index.d.ts", + "tarballHash": "0xcf4df0c243d91af669cf850c762132a62d8557b0dd9257252c8c91cf28c2ffe1" } diff --git a/packages/shims/package.json b/packages/shims/package.json index 9f8852d3c..3c6f8ca11 100644 --- a/packages/shims/package.json +++ b/packages/shims/package.json @@ -26,5 +26,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xaf9de32ae819cac08b2c3ab1ca7ce1f527a2d3c656d8c6dfceb4e9d9d6824aeb" + "types": "./lib/index.d.ts", + "tarballHash": "0x1f5f87ba0d49d519f731a60c62c1545b61b0b33e1de2f4282390b613431e1e5b" } diff --git a/packages/signing-key/package.json b/packages/signing-key/package.json index c3f0738e7..2c295f765 100644 --- a/packages/signing-key/package.json +++ b/packages/signing-key/package.json @@ -7,9 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", "elliptic": "6.5.0" }, "keywords": [ @@ -26,5 +26,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x0126d28a0bb036b3a68821568153fc33edd738f21757dcd79f8dfca33d5b09e7" + "types": "./lib/index.d.ts", + "tarballHash": "0x2c2c7b6d5c1e203010905dc0d6f133c77b23589356e624e8b9aad9efaed3a3e9" } diff --git a/packages/solidity/package.json b/packages/solidity/package.json index b92139217..a076c20c3 100644 --- a/packages/solidity/package.json +++ b/packages/solidity/package.json @@ -7,11 +7,11 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/sha2": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0" + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/sha2": ">=5.0.0-beta.129", + "@ethersproject/strings": ">=5.0.0-beta.130" }, "keywords": [ "Ethereum", @@ -27,5 +27,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x5a24d578f0111ef50d2380aa3f1958e6143d7edab3b1330647e3ac4b77f9115b" + "types": "./lib/index.d.ts", + "tarballHash": "0x70bf6fa88a443007d944e0054cfef78b0423225c96e341afa83ddb62a76faf61" } diff --git a/packages/strings/package.json b/packages/strings/package.json index 651b750ec..781e6330a 100644 --- a/packages/strings/package.json +++ b/packages/strings/package.json @@ -7,9 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/logger": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -27,5 +27,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xcbb038765fe741066b9e003c1e805d9a6e8c617aeb4a1d96ab40425122fc9dd3" + "types": "./lib/index.d.ts", + "tarballHash": "0x07bc7954dde6fb2e82297f1d68c9586f2587d3a1e3cf7b42f8689c697e6ddc15" } diff --git a/packages/testcases/package.json b/packages/testcases/package.json index 5f89c7c40..7b7c75698 100644 --- a/packages/testcases/package.json +++ b/packages/testcases/package.json @@ -8,10 +8,10 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/strings": ">=5.0.0-beta.130", "browserify-zlib": "^0.2.0" }, "devDependencies": { @@ -37,5 +37,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x3eecab2eb7ec5cb3a83064cef11b20e9be3abaf360fc24dc22ddb890ba072544" + "types": "./lib/index.d.ts", + "tarballHash": "0x1a8a6c09a8ab073c966738bd4307cb6e8a342fea21c607f3084f3193b5c6c3e3" } diff --git a/packages/tests/package.json b/packages/tests/package.json index 0360150bd..d17e6877a 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -13,9 +13,9 @@ "test-phantomjs": "npm run dist-phantomjs && phantomjs --web-security=false ../../node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js ./test.html ./tests/reporter.js" }, "dependencies": { - "@ethersproject/testcases": ">5.0.0-beta.0", + "@ethersproject/testcases": ">=5.0.0-beta.131", "@types/mocha": "^5.2.0", - "ethers": ">5.0.0-beta.0", + "ethers": ">=5.0.0-beta.156", "mocha-phantomjs-core": "2.1.2" }, "devDependencies": { @@ -37,5 +37,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0xbe37358972f6b48eaf05ca1a30f164a3da3370372aa81b5f71a6ced50f93f741" + "types": "./lib/index.d.ts", + "tarballHash": "0xab7df0fb51d7584e117b4ed86356f52f0210a3d342dc9e40fce13fdcedc36ce4" } diff --git a/packages/transactions/package.json b/packages/transactions/package.json index a8c8764ed..05c9cb7c9 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -7,15 +7,15 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/rlp": ">5.0.0-beta.0", - "@ethersproject/signing-key": ">5.0.0-beta.0" + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/rlp": ">=5.0.0-beta.126", + "@ethersproject/signing-key": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -31,5 +31,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x5a7f7a0edf47aeda2379fb0759b59d538bb6d68b05508e1ee047643239d3beba" + "types": "./lib/index.d.ts", + "tarballHash": "0x4ec76541ec348502606265f177e00918c3f6bebaaa9404c8d461f2c0419fa702" } diff --git a/packages/units/package.json b/packages/units/package.json index 1f72c3378..5cf49bc47 100644 --- a/packages/units/package.json +++ b/packages/units/package.json @@ -7,9 +7,9 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/constants": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0" + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/constants": ">=5.0.0-beta.128", + "@ethersproject/logger": ">=5.0.0-beta.129" }, "keywords": [ "Ethereum", @@ -27,5 +27,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x03fcf14ceb26ccd22b4bde2095d99815d33a3ee10c663c66863098cb04e5a949" + "types": "./lib/index.d.ts", + "tarballHash": "0x87a9c05d77565d21d20960f9726058aa60d7ba073bf398853c44a72e22a0271b" } diff --git a/packages/wallet/package.json b/packages/wallet/package.json index 4491dcf50..f5e8cbc0e 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -7,21 +7,21 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/abstract-provider": ">5.0.0-beta.0", - "@ethersproject/abstract-signer": ">5.0.0-beta.0", - "@ethersproject/address": ">5.0.0-beta.0", - "@ethersproject/bignumber": ">5.0.0-beta.0", - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/hash": ">5.0.0-beta.0", - "@ethersproject/hdnode": ">5.0.0-beta.0", - "@ethersproject/json-wallets": ">5.0.0-beta.0", - "@ethersproject/keccak256": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/random": ">5.0.0-beta.0", - "@ethersproject/signing-key": ">5.0.0-beta.0", - "@ethersproject/transactions": ">5.0.0-beta.0", - "@ethersproject/wordlists": ">5.0.0-beta.0" + "@ethersproject/abstract-provider": ">=5.0.0-beta.131", + "@ethersproject/abstract-signer": ">=5.0.0-beta.132", + "@ethersproject/address": ">=5.0.0-beta.128", + "@ethersproject/bignumber": ">=5.0.0-beta.130", + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/hash": ">=5.0.0-beta.128", + "@ethersproject/hdnode": ">=5.0.0-beta.130", + "@ethersproject/json-wallets": ">=5.0.0-beta.129", + "@ethersproject/keccak256": ">=5.0.0-beta.127", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/random": ">=5.0.0-beta.128", + "@ethersproject/signing-key": ">=5.0.0-beta.129", + "@ethersproject/transactions": ">=5.0.0-beta.128", + "@ethersproject/wordlists": ">=5.0.0-beta.128" }, "keywords": [ "Ethereum", @@ -37,5 +37,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x089e1006fc830b53ddc8c3c4eb83774a600b56d16e7a86846ff5a82b209d22d6" + "types": "./lib/index.d.ts", + "tarballHash": "0xfd9392a01600789cea9c66e20034bb90bf31d68eef45d855ef9d4e515c244e82" } diff --git a/packages/web/package.json b/packages/web/package.json index 105f11a51..eebe5fef4 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -7,10 +7,10 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/base64": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0", + "@ethersproject/base64": ">=5.0.0-beta.126", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/strings": ">=5.0.0-beta.130", "cross-fetch": "3.0.4" }, "keywords": [ @@ -27,5 +27,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x10b30a94e8417a1835f4b0468b9cf5523959c856598bbdc914cb5902c0618e50" + "types": "./lib/index.d.ts", + "tarballHash": "0x2761dff44f2b31971630f4ce8f929365941dbcf7f4a6f050a940466ed9a185de" } diff --git a/packages/wordlists/package.json b/packages/wordlists/package.json index 6255f4e13..5a3b73bcb 100644 --- a/packages/wordlists/package.json +++ b/packages/wordlists/package.json @@ -8,11 +8,11 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@ethersproject/bytes": ">5.0.0-beta.0", - "@ethersproject/hash": ">5.0.0-beta.0", - "@ethersproject/logger": ">5.0.0-beta.0", - "@ethersproject/properties": ">5.0.0-beta.0", - "@ethersproject/strings": ">5.0.0-beta.0" + "@ethersproject/bytes": ">=5.0.0-beta.129", + "@ethersproject/hash": ">=5.0.0-beta.128", + "@ethersproject/logger": ">=5.0.0-beta.129", + "@ethersproject/properties": ">=5.0.0-beta.131", + "@ethersproject/strings": ">=5.0.0-beta.130" }, "keywords": [ "Ethereum", @@ -28,5 +28,6 @@ "url": "git://github.com/ethers-io/ethers.js.git" }, "module": "./lib.esm/index.js", - "tarballHash": "0x7c5bb7cc5b54a118fd80e310c83087a8fbe5c4680812cc8bc78f0205052fbbb7" + "types": "./lib/index.d.ts", + "tarballHash": "0xfbae6dfff83852be5f9358b699964cadb286b5cbd6dd073b68cda7356e473af4" } From 21876049137644af2b3afa31120ee95d032843a8 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sat, 31 Aug 2019 23:58:54 -0400 Subject: [PATCH 06/13] Added lock-versions admin tool. --- admin/cmds/lock-versions.js | 41 +++++++++++++++++++++++++++++++++++ admin/cmds/update-versions.js | 8 ------- 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 admin/cmds/lock-versions.js diff --git a/admin/cmds/lock-versions.js b/admin/cmds/lock-versions.js new file mode 100644 index 000000000..81a1274f7 --- /dev/null +++ b/admin/cmds/lock-versions.js @@ -0,0 +1,41 @@ +"use strict"; + +const { getOrdered, loadPackage } = require("../depgraph"); +const { savePackage } = require("../local"); +const { log } = require("../log"); + +(async function() { + let versions = { }; + + const dirnames = getOrdered(); + + dirnames.forEach((dirname) => { + let info = loadPackage(dirname); + if (info.name.split("/")[0] === "@ethersproject" || info.name === "ethers") { + versions[info.name] = info.version; + } + }); + + dirnames.forEach((dirname) => { + const info = loadPackage(dirname); + let shown = false; + ["dependencies", "devDependencies"].forEach((key) => { + const deps = info[key]; + if (!deps) { return; } + Object.keys(deps).forEach((name) => { + if (versions[name] == null) { return; } + const value = ">=" + versions[name]; + if (value !== deps[name]) + if (!deps[name]) { return; } + if (!shown) { + log(``); + shown = true; + } + log(` : ${ deps[name] } => `); + deps[name] = value; + }); + }); + savePackage(dirname, info); + }); + +})(); diff --git a/admin/cmds/update-versions.js b/admin/cmds/update-versions.js index e7031847e..9c245e219 100644 --- a/admin/cmds/update-versions.js +++ b/admin/cmds/update-versions.js @@ -51,14 +51,6 @@ if (process.argv.length > 2) { // Get local package.json (update the tarballHash) let info = await updatePackage(dirname); - /* - let info = await updatePackage(dirname, { - repository: { - type: "git", - url: "git://github.com/ethers-io/ethers.js.git" - } - }); - */ // Get the remote package.json (or sub in a placeholder for new pacakges) let npmInfo = await getPackageVersion(info.name); From 1e0ed4e99a22a27fe5057336f8cb320809768f3e Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Sun, 1 Sep 2019 00:13:35 -0400 Subject: [PATCH 07/13] Fixed test suites and reporter. --- package.json | 3 +- packages/tests/lib/reporter.d.ts | 5 ++ packages/tests/lib/reporter.js | 111 +++++++++++++++++++++++++++++++ packages/tests/tsconfig.json | 4 +- 4 files changed, 119 insertions(+), 4 deletions(-) create mode 100644 packages/tests/lib/reporter.d.ts create mode 100644 packages/tests/lib/reporter.js diff --git a/package.json b/package.json index 182fddc5e..b71bbc04a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify", "_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", "_test_prepare": "npm run _dist_prepare && npm run _dist_tests", - "_test_node": "cd packages/tests && mocha --no-colors --reporter ./tests/reporter ./tests/test-*.js", + "_test_node": "cd packages/tests && mocha --no-colors --reporter ./lib/reporter ./lib/test-*.js", "test_node": "npm run _test_prepare && npm run _test_node", "_dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist", "old-test": "npm run _dist_old && npm run test-check", @@ -21,6 +21,7 @@ "old-test-aion-node": "cd packages/aion-tests && mocha --no-colors --reporter ../tests/tests/reporter ./tests/test-*.js", "update-versions": "npm run _dist_prepare && node ./admin/cmds/update-versions", "publish-all": "node ./admin/cmds/publish", + "lock-versions": "node ./admin/cmds/lock-versions", "build-docs": "flatworm docs.wrm docs" }, "devDependencies": { diff --git a/packages/tests/lib/reporter.d.ts b/packages/tests/lib/reporter.d.ts new file mode 100644 index 000000000..ea695d44c --- /dev/null +++ b/packages/tests/lib/reporter.d.ts @@ -0,0 +1,5 @@ +interface Runner { + on(event: string, callback: (...args: Array) => void): Runner; +} +declare function Reporter(runner: Runner): void; +export = Reporter; diff --git a/packages/tests/lib/reporter.js b/packages/tests/lib/reporter.js new file mode 100644 index 000000000..da9969955 --- /dev/null +++ b/packages/tests/lib/reporter.js @@ -0,0 +1,111 @@ +'use strict'; +function getTime() { + return (new Date()).getTime(); +} +function trunc(value) { + if (value >= 0) { + return Math.floor(value); + } + return Math.ceil(value); +} +function getDelta(t0) { + var ds = trunc((getTime() - t0) / 1000); + var minutes = trunc(ds / 60); + var seconds = String(trunc(ds) % 60); + while (seconds.length < 2) { + seconds = '0' + seconds; + } + return '(' + minutes + ':' + seconds + ')'; +} +function Reporter(runner) { + var suites = []; + var lastOutput = getTime(); + function getIndent() { + var result = ''; + for (var i = 0; i < suites.length; i++) { + result += ' '; + } + return result; + } + function log(message) { + if (!message) { + message = ''; + } + var indent = getIndent(); + console.log(indent + message); + lastOutput = getTime(); + } + runner.on('suite', function (suite) { + if (!suite.title) { + log('Testing: Found ' + suite.suites.length + ' test suites'); + } + else { + var filename = (suite.file || '').split('/').pop(); + if (filename) { + filename = ' (' + filename + ')'; + } + log('Test Suite: ' + suite.title + filename); + } + suites.push(suite); + suite._t0 = getTime(); + suite._countFail = 0; + suite._countPass = 0; + suite._countTotal = 0; + }); + runner.on('suite end', function () { + var suite = suites.pop(); + var failure = ''; + if (suite._countTotal > suite._countPass) { + failure = ' (' + (suite._countTotal - suite._countPass) + ' failed)'; + } + log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure); + log(); + if (suites.length > 0) { + var currentSuite = suites[suites.length - 1]; + currentSuite._countFail += suite._countFail; + currentSuite._countPass += suite._countPass; + currentSuite._countTotal += suite._countTotal; + } + }); + runner.on('test', function (test) { + var currentSuite = suites[suites.length - 1]; + if (((getTime() - lastOutput) / 1000) > 60) { + log('[ Still running suite - test #' + currentSuite._countTotal + ' ]'); + lastOutput = getTime(); + } + currentSuite._countTotal++; + }); + runner.on('fail', function (test, error) { + var currentSuite = suites[suites.length - 1]; + currentSuite._countFail++; + var countFail = currentSuite._countFail; + if (countFail > 100) { + if (countFail === 101) { + log('[ Over 100 errors; skipping remaining suite output ]'); + } + return; + } + if (countFail > 25) { + log('Failure: ' + test.title + ' (too many errors; skipping dump)'); + return; + } + log('Failure: ' + test.title); + error.toString().split('\n').forEach(function (line) { + log(' ' + line); + }); + Object.keys(error).forEach(function (key) { + log(' ' + key + ': ' + error[key]); + }); + if (error.stack) { + log("Stack Trace:"); + error.stack.split('\n').forEach(function (line) { + log(' ' + line); + }); + } + }); + runner.on('pass', function (test) { + var currentSuite = suites[suites.length - 1]; + currentSuite._countPass++; + }); +} +module.exports = Reporter; diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index c08252782..f025e9743 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -8,7 +8,5 @@ "./thirdparty.d.ts", "./src.ts/*" ], - "exclude": [ - "./src.ts/reporter.ts" - ] + "exclude": [ ] } From e8028d0e73368257b76b394bb8e2bf63f8aecd71 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 12:25:17 -0400 Subject: [PATCH 08/13] Updated TypeScript version. --- admin/cmds/update-exports.js | 20 +++++++++ package.json | 5 ++- packages/address/src.ts/index.ts | 6 +-- packages/bignumber/src.ts/bignumber.ts | 14 +++--- packages/cli/package.json | 6 ++- packages/ethers/src.ts/index.ts | 59 +++++++++++++++++++++++++- packages/providers/package.json | 4 +- packages/random/package.json | 4 +- rollup.config.js | 16 +++++-- 9 files changed, 111 insertions(+), 23 deletions(-) create mode 100644 admin/cmds/update-exports.js diff --git a/admin/cmds/update-exports.js b/admin/cmds/update-exports.js new file mode 100644 index 000000000..0d16f9e3e --- /dev/null +++ b/admin/cmds/update-exports.js @@ -0,0 +1,20 @@ +"use strict"; + +const fs = require("fs"); +const { resolve } = require("path"); + +const sourceEthers = fs.readFileSync(resolve(__dirname, "../../packages/ethers/src.ts/ethers.ts")).toString(); +const targets = sourceEthers.match(/export\s*{\s*((.|\s)*)}/)[1].trim(); + +const output = `"use strict"; + +import * as ethers from "./ethers"; + +export { ethers }; + +export { + ${ targets } +} from "./ethers"; +`; + +fs.writeFileSync(resolve(__dirname, "../../packages/ethers/src.ts/index.ts"), output); diff --git a/package.json b/package.json index b71bbc04a..b0da48901 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bootstrap": "node ./admin/cmds/reset-build.js && node ./admin/cmds/update-depgraph && lerna bootstrap --hoist", "build": "tsc --build ./tsconfig.project.json", "clean": "node ./admin/cmds/reset-build.js && tsc --build --clean ./tsconfig.project.json", - "_dist_prepare": "npm run clean && npm run bootstrap && npm run build", + "_dist_prepare": "npm run clean && npm run bootstrap && npm run build && node ./admin/cmds/update-exports.js", "_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify", "_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", "_test_prepare": "npm run _dist_prepare && npm run _dist_tests", @@ -27,6 +27,7 @@ "devDependencies": { "@types/assert": "^1.4.1", "@types/mocha": "^5.2.0", + "@types/node": "^12.7.4", "aes-js": "3.0.0", "browserify": "16.2.3", "diff": "4.0.1", @@ -38,7 +39,7 @@ "scrypt-js": "2.0.4", "semver": "^5.6.0", "tar": "4.4.8", - "typescript": "3.3.3", + "typescript": "3.6.2", "rollup": "1.20.1", "rollup-plugin-commonjs": "10.0.2", "rollup-plugin-json": "4.0.0", diff --git a/packages/address/src.ts/index.ts b/packages/address/src.ts/index.ts index 2fcdebe07..1d5a226db 100644 --- a/packages/address/src.ts/index.ts +++ b/packages/address/src.ts/index.ts @@ -1,7 +1,7 @@ "use strict"; // We use this for base 36 maths -import * as BN from "bn.js"; +import { BN } from "bn.js"; import { arrayify, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes"; import { BigNumberish } from "@ethersproject/bignumber"; @@ -106,7 +106,7 @@ export function getAddress(address: string): string { logger.throwArgumentError("bad icap checksum", "address", address); } - result = (new BN.BN(address.substring(4), 36)).toString(16); + result = (new BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = "0" + result; } result = getChecksumAddress("0x" + result); @@ -126,7 +126,7 @@ export function isAddress(address: string): boolean { } export function getIcapAddress(address: string): string { - let base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + let base36 = (new BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } return "XE" + ibanChecksum("XE00" + base36) + base36; } diff --git a/packages/bignumber/src.ts/bignumber.ts b/packages/bignumber/src.ts/bignumber.ts index d8829edf4..8550f8670 100644 --- a/packages/bignumber/src.ts/bignumber.ts +++ b/packages/bignumber/src.ts/bignumber.ts @@ -8,7 +8,7 @@ * */ -import * as BN from "bn.js"; +import { BN } from "bn.js"; import { Bytes, Hexable, hexlify, isBytes, isHexString } from "@ethersproject/bytes"; @@ -154,7 +154,7 @@ export class BigNumber implements Hexable { } if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + return new BigNumber(_constructorGuard, toHex(new BN(value))); } return logger.throwArgumentError("invalid BigNumber string", "value", value); @@ -200,7 +200,7 @@ export class BigNumber implements Hexable { } // Normalize the hex string -function toHex(value: string | BN.BN): string { +function toHex(value: string | BN): string { // For BN, call on the hex string if (typeof(value) !== "string") { @@ -242,16 +242,16 @@ function toHex(value: string | BN.BN): string { return value; } -function toBigNumber(value: BN.BN): BigNumber { +function toBigNumber(value: BN): BigNumber { return BigNumber.from(toHex(value)); } -function toBN(value: BigNumberish): BN.BN { +function toBN(value: BigNumberish): BN { let hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); + return (new BN("-" + hex.substring(3), 16)); } - return new BN.BN(hex.substring(2), 16); + return new BN(hex.substring(2), 16); } function throwFault(fault: string, operation: string, value?: any): never { diff --git a/packages/cli/package.json b/packages/cli/package.json index c4fdfefc2..227076963 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -12,7 +12,6 @@ "ethers-ts": "./lib/bin/ethers-ts.js" }, "dependencies": { - "@types/node": "10.3.2", "@ethersproject/basex": ">=5.0.0-beta.127", "ethers": ">=5.0.0-beta.156", "mime-types": "2.1.11", @@ -20,6 +19,9 @@ "solc": "0.5.10", "solidity-parser-antlr": "^0.3.2" }, + "devDependencies": { + "@types/node": "^12.7.4" + }, "keywords": [ "Ethereum", "ethers", @@ -36,5 +38,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x045c7d61113b060ecb79426c442a9bcc28c3ed5baebd6c324b8c5ccdd83aa39c" + "tarballHash": "0x7224b7a62cd2554bab3585709e8016fc4a7672c33c568dcbdfbf63d838c18283" } diff --git a/packages/ethers/src.ts/index.ts b/packages/ethers/src.ts/index.ts index b7fc3fe0e..74141c45b 100644 --- a/packages/ethers/src.ts/index.ts +++ b/packages/ethers/src.ts/index.ts @@ -4,4 +4,61 @@ import * as ethers from "./ethers"; export { ethers }; -export * from "./ethers"; +export { + Signer, + + Wallet, + VoidSigner, + + getDefaultProvider, + providers, + + Contract, + ContractFactory, + + BigNumber, + FixedNumber, + + constants, + errors, + + logger, + + utils, + + wordlists, + + + //////////////////////// + // Compile-Time Constants + + version, + + + //////////////////////// + // Types + + ContractFunction, + ContractReceipt, + ContractTransaction, + Event, + EventFilter, + + Overrides, + PayableOverrides, + CallOverrides, + + ContractInterface, + + BigNumberish, + + Bytes, + BytesLike, + + Signature, + + Transaction, + UnsignedTransaction, + + Wordlist +} from "./ethers"; diff --git a/packages/providers/package.json b/packages/providers/package.json index bc7799475..c00884f7c 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -28,7 +28,7 @@ "@ethersproject/web": ">=5.0.0-beta.129" }, "devDependencies": { - "@types/node": "10.3.2" + "@types/node": "^12.7.4" }, "keywords": [ "Ethereum", @@ -45,5 +45,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x655b117ac21836fcd5bed6025dbd53583596f141bc2b67b833342f60e37038d4" + "tarballHash": "0xc0b5e1a60b427d64d93f366727dc57777d24bfd92b8ddeb6408b367a7780f045" } diff --git a/packages/random/package.json b/packages/random/package.json index aa7b01314..c956d7f51 100644 --- a/packages/random/package.json +++ b/packages/random/package.json @@ -12,7 +12,7 @@ "@ethersproject/logger": ">=5.0.0-beta.129" }, "devDependencies": { - "@types/node": "10.3.2" + "@types/node": "^12.7.4" }, "keywords": [ "Ethereum", @@ -30,5 +30,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x45c2e53529bd3cf7b1ba4bbbe448813aa2540b792fab4db7bdfbac9c204f1d7e" + "tarballHash": "0x884bc62b2feb8949cbbf59bb1fea3ca8c671ab16149e1688d74b9f1bd360e89c" } diff --git a/rollup.config.js b/rollup.config.js index fba615121..771e55fab 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -12,8 +12,15 @@ function Replacer(options = {}) { return { name: "file-replacer", transform(code, id) { - //console.log(id, code.length); + /* + console.log("------"); + console.log("NAME", id, id.match("node-resolve:empty.js$")); + console.log(code); + console.log("------"); + */ + if (!filter(id)) { return null; } + for (let i = 0; i < suffixes.length; i++) { const suffix = suffixes[i]; if (id.match(new RegExp(suffix))) { @@ -21,7 +28,8 @@ function Replacer(options = {}) { let newCode = options.replace[suffix]; console.log(`Replace: ${ id } (${ code.length } => ${ newCode.length })`); return { - code: newCode + code: newCode, + map: { mappings: '' } }; } } @@ -89,8 +97,8 @@ export default commandLineArgs => { namedExports: { "bn.js": [ "BN" ], "elliptic": [ "ec" ] - } - }) + }, + }), ]; if (minify) { From 4c17c4db0455e1b89fd597c4c929cdc36aa3d90d Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 17:48:26 -0400 Subject: [PATCH 09/13] Removed export star to fix UMD dist file. --- package.json | 2 +- packages/abi/package.json | 2 +- packages/abstract-provider/lib.esm/index.js | 8 +- packages/abstract-provider/package.json | 2 +- packages/abstract-signer/package.json | 2 +- packages/address/lib.esm/index.js | 6 +- packages/address/lib/index.js | 13 +- packages/address/package.json | 2 +- packages/base64/package.json | 2 +- packages/basex/package.json | 2 +- packages/bignumber/lib.esm/bignumber.js | 8 +- packages/bignumber/lib/bignumber.js | 15 +- packages/bignumber/package.json | 2 +- packages/bytes/package.json | 2 +- packages/cli/lib.esm/bin/ethers-ens.js | 3 +- packages/cli/lib.esm/bin/ethers-ts.js | 3 +- packages/cli/lib.esm/bin/ethers.js | 3 +- packages/cli/lib.esm/cli.js | 3 +- packages/cli/lib/bin/ethers-ens.js | 3 +- packages/cli/lib/bin/ethers-ts.js | 3 +- packages/cli/lib/bin/ethers.js | 3 +- packages/cli/lib/cli.js | 3 +- packages/cli/package-lock.json | 552 -------------------- packages/constants/package.json | 2 +- packages/contracts/lib/index.js | 9 +- packages/contracts/package.json | 2 +- packages/errors/package.json | 2 +- packages/ethers/dist/ethers.esm.js | 8 +- packages/ethers/dist/ethers.esm.min.js | 2 +- packages/ethers/dist/ethers.umd.js | 92 +++- packages/ethers/dist/ethers.umd.min.js | 2 +- packages/ethers/lib.esm/index.d.ts | 2 +- packages/ethers/lib.esm/index.js | 5 +- packages/ethers/lib/index.d.ts | 2 +- packages/ethers/lib/index.js | 23 +- packages/ethers/package.json | 2 +- packages/experimental/package.json | 2 +- packages/hash/package.json | 2 +- packages/hdnode/package.json | 2 +- packages/json-wallets/package.json | 2 +- packages/keccak256/package.json | 2 +- packages/logger/package.json | 2 +- packages/networks/package.json | 2 +- packages/pbkdf2/package.json | 2 +- packages/properties/package.json | 2 +- packages/rlp/package.json | 2 +- packages/sha2/package.json | 2 +- packages/signing-key/package.json | 2 +- packages/solidity/package.json | 2 +- packages/strings/package.json | 2 +- packages/testcases/package.json | 2 +- packages/tests/lib.esm/reporter.d.ts | 5 + packages/tests/lib.esm/reporter.js | 110 ++++ packages/tests/lib/reporter.d.ts | 4 +- packages/tests/lib/reporter.js | 3 +- packages/tests/package.json | 2 +- packages/tests/reporter.js | 5 + packages/tests/src.ts/reporter.ts | 3 +- packages/tests/tsconfig.json | 2 +- packages/transactions/package.json | 2 +- packages/units/package.json | 2 +- packages/wallet/package.json | 2 +- packages/web/package.json | 2 +- packages/wordlists/package.json | 2 +- 64 files changed, 299 insertions(+), 672 deletions(-) delete mode 100644 packages/cli/package-lock.json create mode 100644 packages/tests/lib.esm/reporter.d.ts create mode 100644 packages/tests/lib.esm/reporter.js create mode 100644 packages/tests/reporter.js diff --git a/package.json b/package.json index b0da48901..21fcd4320 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "_dist_ethers": "rollup -c && rollup -c --configMinify && rollup -c --configModule && rollup -c --configModule --configMinify", "_dist_tests": "rollup -c --configTest && rollup -c --configTest --configMinify && rollup -c --configTest --configModule && rollup -c --configTest --configModule --configMinify", "_test_prepare": "npm run _dist_prepare && npm run _dist_tests", - "_test_node": "cd packages/tests && mocha --no-colors --reporter ./lib/reporter ./lib/test-*.js", + "_test_node": "cd packages/tests && mocha --no-colors --reporter ./reporter ./lib/test-*.js", "test_node": "npm run _test_prepare && npm run _test_node", "_dist_old": "npm run clean && npm run bootstrap && npm run build && lerna run dist", "old-test": "npm run _dist_old && npm run test-check", diff --git a/packages/abi/package.json b/packages/abi/package.json index 03e4700a1..b0251c910 100644 --- a/packages/abi/package.json +++ b/packages/abi/package.json @@ -32,5 +32,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xe4021eb72e5aed6edb4b6cf5fa70f01afa6f1ae200e40bea8861b60a59759b4a" + "tarballHash": "0x2586b6ca7027e4b47caf53887eae7d3aca64570fb72bcb495838b883be6580f3" } diff --git a/packages/abstract-provider/lib.esm/index.js b/packages/abstract-provider/lib.esm/index.js index e54bdcc71..34a5961cc 100644 --- a/packages/abstract-provider/lib.esm/index.js +++ b/packages/abstract-provider/lib.esm/index.js @@ -60,6 +60,10 @@ export class TransactionOrderForkEvent extends ForkEvent { /////////////////////////////// // Exported Abstracts export class Provider { + constructor() { + logger.checkAbstract(new.target, Provider); + defineReadOnly(this, "_isProvider", true); + } // Alias for "on" addListener(eventName, listener) { return this.on(eventName, listener); @@ -68,10 +72,6 @@ export class Provider { removeListener(eventName, listener) { return this.off(eventName, listener); } - constructor() { - logger.checkAbstract(new.target, Provider); - defineReadOnly(this, "_isProvider", true); - } static isProvider(value) { return !!(value && value._isProvider); } diff --git a/packages/abstract-provider/package.json b/packages/abstract-provider/package.json index 97faa39c4..5aa92b1b0 100644 --- a/packages/abstract-provider/package.json +++ b/packages/abstract-provider/package.json @@ -30,5 +30,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x3a2082bb4e5d5f15beb057d863d32cf55a086c6065f05202df62a520f717deea" + "tarballHash": "0x2beb1736c2a9c8023e74c415353bff10587ae1dc49240ec5dc2620171899f2e6" } diff --git a/packages/abstract-signer/package.json b/packages/abstract-signer/package.json index c70d86d1f..08e13ae24 100644 --- a/packages/abstract-signer/package.json +++ b/packages/abstract-signer/package.json @@ -28,5 +28,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xfe7d31b31b069c4f4600f1f7eea2a9f271a6f8f919e0c17fc578acae251237db" + "tarballHash": "0x29ac3c562b144556a1971d8997ddf92f58733e61d15f78c24fc6e0a7ce4e9b28" } diff --git a/packages/address/lib.esm/index.js b/packages/address/lib.esm/index.js index 706b3a2c5..799d3e5f4 100644 --- a/packages/address/lib.esm/index.js +++ b/packages/address/lib.esm/index.js @@ -1,6 +1,6 @@ "use strict"; // We use this for base 36 maths -import * as BN from "bn.js"; +import { BN } from "bn.js"; import { arrayify, hexDataSlice, isHexString, stripZeros } from "@ethersproject/bytes"; import { keccak256 } from "@ethersproject/keccak256"; import { encode } from "@ethersproject/rlp"; @@ -88,7 +88,7 @@ export function getAddress(address) { if (address.substring(2, 4) !== ibanChecksum(address)) { logger.throwArgumentError("bad icap checksum", "address", address); } - result = (new BN.BN(address.substring(4), 36)).toString(16); + result = (new BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = "0" + result; } @@ -108,7 +108,7 @@ export function isAddress(address) { return false; } export function getIcapAddress(address) { - let base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + let base36 = (new BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } diff --git a/packages/address/lib/index.js b/packages/address/lib/index.js index cee1da3a0..de0f87330 100644 --- a/packages/address/lib/index.js +++ b/packages/address/lib/index.js @@ -1,14 +1,7 @@ "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); // We use this for base 36 maths -var BN = __importStar(require("bn.js")); +var bn_js_1 = require("bn.js"); var bytes_1 = require("@ethersproject/bytes"); var keccak256_1 = require("@ethersproject/keccak256"); var rlp_1 = require("@ethersproject/rlp"); @@ -96,7 +89,7 @@ function getAddress(address) { if (address.substring(2, 4) !== ibanChecksum(address)) { logger.throwArgumentError("bad icap checksum", "address", address); } - result = (new BN.BN(address.substring(4), 36)).toString(16); + result = (new bn_js_1.BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = "0" + result; } @@ -118,7 +111,7 @@ function isAddress(address) { } exports.isAddress = isAddress; function getIcapAddress(address) { - var base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + var base36 = (new bn_js_1.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } diff --git a/packages/address/package.json b/packages/address/package.json index 5708a681b..ff5fb1721 100644 --- a/packages/address/package.json +++ b/packages/address/package.json @@ -29,5 +29,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x4cf2a1710526cbee72754e01d0819087d80c4e6f95393dfc9037aeec5ed9cde2" + "tarballHash": "0x3ca47b90abf21da753646b5b888976f067af8e0afceec65a8523c7f708855c6a" } diff --git a/packages/base64/package.json b/packages/base64/package.json index 52ab2a11f..18bceafda 100644 --- a/packages/base64/package.json +++ b/packages/base64/package.json @@ -25,5 +25,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xaf339d29758af1140ec01b737ab3241b28f376a6ff66c85e75d6f8a9b29886f2" + "tarballHash": "0x1b03890d546a6603f6a326246aaa8a9fa0f25fc40c2f4ba5597f7d6196ea8c51" } diff --git a/packages/basex/package.json b/packages/basex/package.json index 29851baa2..3e338b483 100644 --- a/packages/basex/package.json +++ b/packages/basex/package.json @@ -25,5 +25,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x229d72d84c96d355704e5ee6947554004006ce117a2e18fe46d9fdf3a7697c97" + "tarballHash": "0x9cad634049ece74f8747f53b37b1f46cca4e00a2aac7184fa17eadc4f8675e40" } diff --git a/packages/bignumber/lib.esm/bignumber.js b/packages/bignumber/lib.esm/bignumber.js index 5e15d18a5..004424ca7 100644 --- a/packages/bignumber/lib.esm/bignumber.js +++ b/packages/bignumber/lib.esm/bignumber.js @@ -6,7 +6,7 @@ * because it is used by elliptic, so it is required regardles. * */ -import * as BN from "bn.js"; +import { BN } from "bn.js"; import { hexlify, isBytes, isHexString } from "@ethersproject/bytes"; import { Logger } from "@ethersproject/logger"; import { version } from "./_version"; @@ -116,7 +116,7 @@ export class BigNumber { return new BigNumber(_constructorGuard, toHex(value)); } if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + return new BigNumber(_constructorGuard, toHex(new BN(value))); } return logger.throwArgumentError("invalid BigNumber string", "value", value); } @@ -197,9 +197,9 @@ function toBigNumber(value) { function toBN(value) { let hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); + return (new BN("-" + hex.substring(3), 16)); } - return new BN.BN(hex.substring(2), 16); + return new BN(hex.substring(2), 16); } function throwFault(fault, operation, value) { let params = { fault: fault, operation: operation }; diff --git a/packages/bignumber/lib/bignumber.js b/packages/bignumber/lib/bignumber.js index 21f49b5e0..99aff7dad 100644 --- a/packages/bignumber/lib/bignumber.js +++ b/packages/bignumber/lib/bignumber.js @@ -1,11 +1,4 @@ "use strict"; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); /** * BigNumber @@ -14,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); * because it is used by elliptic, so it is required regardles. * */ -var BN = __importStar(require("bn.js")); +var bn_js_1 = require("bn.js"); var bytes_1 = require("@ethersproject/bytes"); var logger_1 = require("@ethersproject/logger"); var _version_1 = require("./_version"); @@ -126,7 +119,7 @@ var BigNumber = /** @class */ (function () { return new BigNumber(_constructorGuard, toHex(value)); } if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + return new BigNumber(_constructorGuard, toHex(new bn_js_1.BN(value))); } return logger.throwArgumentError("invalid BigNumber string", "value", value); } @@ -209,9 +202,9 @@ function toBigNumber(value) { function toBN(value) { var hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); + return (new bn_js_1.BN("-" + hex.substring(3), 16)); } - return new BN.BN(hex.substring(2), 16); + return new bn_js_1.BN(hex.substring(2), 16); } function throwFault(fault, operation, value) { var params = { fault: fault, operation: operation }; diff --git a/packages/bignumber/package.json b/packages/bignumber/package.json index 7a87dba14..1dc34abf0 100644 --- a/packages/bignumber/package.json +++ b/packages/bignumber/package.json @@ -28,5 +28,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x9a95bbb76aa2acea22c52711473585eef5196d7400f9144d6d1322e890fb3264" + "tarballHash": "0xcc5966135a40d8007d2916aa352db202de42eeef24197ba94eeb01414232cf41" } diff --git a/packages/bytes/package.json b/packages/bytes/package.json index c15d6a566..c5621133b 100644 --- a/packages/bytes/package.json +++ b/packages/bytes/package.json @@ -26,5 +26,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x11da50922c3e91c2fa195a580699ba92774bc3275a1154309ffcff8dee314c8d" + "tarballHash": "0xaedefd50f9571311250bc76aa8698765f69efd5ea43de1ca248ebbf8d34e640e" } diff --git a/packages/cli/lib.esm/bin/ethers-ens.js b/packages/cli/lib.esm/bin/ethers-ens.js index 3ccf99974..4fbf57d4f 100644 --- a/packages/cli/lib.esm/bin/ethers-ens.js +++ b/packages/cli/lib.esm/bin/ethers-ens.js @@ -1,10 +1,11 @@ #!/usr/bin/env node 'use strict'; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib.esm/bin/ethers-ts.js b/packages/cli/lib.esm/bin/ethers-ts.js index fb19bdbf7..18ebe9d64 100644 --- a/packages/cli/lib.esm/bin/ethers-ts.js +++ b/packages/cli/lib.esm/bin/ethers-ts.js @@ -1,10 +1,11 @@ #!/usr/bin/env node 'use strict'; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib.esm/bin/ethers.js b/packages/cli/lib.esm/bin/ethers.js index 4fe91a632..64d65c93c 100644 --- a/packages/cli/lib.esm/bin/ethers.js +++ b/packages/cli/lib.esm/bin/ethers.js @@ -1,10 +1,11 @@ #!/usr/bin/env node "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib.esm/cli.js b/packages/cli/lib.esm/cli.js index 907d0c8ee..4c741e2da 100644 --- a/packages/cli/lib.esm/cli.js +++ b/packages/cli/lib.esm/cli.js @@ -1,9 +1,10 @@ "use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib/bin/ethers-ens.js b/packages/cli/lib/bin/ethers-ens.js index 5568af019..891d5fe00 100644 --- a/packages/cli/lib/bin/ethers-ens.js +++ b/packages/cli/lib/bin/ethers-ens.js @@ -14,10 +14,11 @@ var __extends = (this && this.__extends) || (function () { }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib/bin/ethers-ts.js b/packages/cli/lib/bin/ethers-ts.js index 708f3186d..24346053d 100644 --- a/packages/cli/lib/bin/ethers-ts.js +++ b/packages/cli/lib/bin/ethers-ts.js @@ -14,10 +14,11 @@ var __extends = (this && this.__extends) || (function () { }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib/bin/ethers.js b/packages/cli/lib/bin/ethers.js index 330ee869f..da690a689 100644 --- a/packages/cli/lib/bin/ethers.js +++ b/packages/cli/lib/bin/ethers.js @@ -14,10 +14,11 @@ var __extends = (this && this.__extends) || (function () { }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/lib/cli.js b/packages/cli/lib/cli.js index 80abc04ca..405a93c6a 100644 --- a/packages/cli/lib/cli.js +++ b/packages/cli/lib/cli.js @@ -13,10 +13,11 @@ var __extends = (this && this.__extends) || (function () { }; })(); var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; diff --git a/packages/cli/package-lock.json b/packages/cli/package-lock.json deleted file mode 100644 index e8ecd850b..000000000 --- a/packages/cli/package-lock.json +++ /dev/null @@ -1,552 +0,0 @@ -{ - "name": "@ethersproject/cli", - "version": "5.0.0-beta.129", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "solc": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/solc/-/solc-0.5.8.tgz", - "integrity": "sha512-RQ2SlwPBOBSV7ktNQJkvbiQks3t+3V9dsqD014EdstxnJzSxBuOvbt3P5QXpNPYW1DsEmF7dhOaT3JL7yEae/A==", - "requires": { - "command-exists": "^1.2.8", - "fs-extra": "^0.30.0", - "keccak": "^1.0.2", - "memorystream": "^0.3.1", - "require-from-string": "^2.0.0", - "semver": "^5.5.0", - "tmp": "0.0.33", - "yargs": "^11.0.0" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=" - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" - }, - "bindings": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", - "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "requires": { - "file-uri-to-path": "1.0.0" - } - }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "requires": { - "balanced-match": "^1.0.0", - "concat-map": "0.0.1" - } - }, - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=" - }, - "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", - "requires": { - "string-width": "^2.1.1", - "strip-ansi": "^4.0.0", - "wrap-ansi": "^2.0.0" - } - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" - }, - "command-exists": { - "version": "1.2.8", - "resolved": "https://registry.npmjs.org/command-exists/-/command-exists-1.2.8.tgz", - "integrity": "sha512-PM54PkseWbiiD/mMsbvW351/u+dafwTJ0ye2qB60G1aGQP9j3xK2gmMDc+R34L3nDtx4qMCitXT75mkbkGJDLw==" - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" - }, - "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "requires": { - "lru-cache": "^4.0.1", - "shebang-command": "^1.2.0", - "which": "^1.2.9" - } - }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" - }, - "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", - "requires": { - "cross-spawn": "^5.0.1", - "get-stream": "^3.0.0", - "is-stream": "^1.1.0", - "npm-run-path": "^2.0.0", - "p-finally": "^1.0.0", - "signal-exit": "^3.0.0", - "strip-eof": "^1.0.0" - } - }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" - }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "requires": { - "locate-path": "^2.0.0" - } - }, - "fs-extra": { - "version": "0.30.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-0.30.0.tgz", - "integrity": "sha1-8jP/zAjU2n1DLapEl3aYnbHfk/A=", - "requires": { - "graceful-fs": "^4.1.2", - "jsonfile": "^2.1.0", - "klaw": "^1.0.0", - "path-is-absolute": "^1.0.0", - "rimraf": "^2.2.8" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" - }, - "get-caller-file": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", - "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" - }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" - }, - "glob": { - "version": "7.1.4", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz", - "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==", - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - }, - "graceful-fs": { - "version": "4.1.15", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "requires": { - "once": "^1.3.0", - "wrappy": "1" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" - }, - "jsonfile": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", - "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", - "requires": { - "graceful-fs": "^4.1.6" - } - }, - "keccak": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz", - "integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==", - "requires": { - "bindings": "^1.2.1", - "inherits": "^2.0.3", - "nan": "^2.2.1", - "safe-buffer": "^5.1.0" - } - }, - "klaw": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/klaw/-/klaw-1.3.1.tgz", - "integrity": "sha1-QIhDO0azsbolnXh4XY6W9zugJDk=", - "requires": { - "graceful-fs": "^4.1.9" - } - }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "requires": { - "invert-kv": "^1.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "lru-cache": { - "version": "4.1.5", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", - "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", - "requires": { - "pseudomap": "^1.0.2", - "yallist": "^2.1.2" - } - }, - "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", - "requires": { - "mimic-fn": "^1.0.0" - } - }, - "memorystream": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", - "integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=" - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==" - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "requires": { - "brace-expansion": "^1.1.7" - } - }, - "nan": { - "version": "2.13.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", - "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==" - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "requires": { - "path-key": "^2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "requires": { - "wrappy": "1" - } - }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", - "requires": { - "execa": "^0.7.0", - "lcid": "^1.0.0", - "mem": "^1.1.0" - } - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=" - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" - }, - "require-from-string": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", - "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" - }, - "rimraf": { - "version": "2.6.3", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", - "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", - "requires": { - "glob": "^7.1.3" - } - }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" - }, - "semver": { - "version": "5.7.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", - "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "requires": { - "shebang-regex": "^1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "requires": { - "ansi-regex": "^3.0.0" - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "requires": { - "os-tmpdir": "~1.0.2" - } - }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", - "requires": { - "isexe": "^2.0.0" - } - }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" - }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", - "requires": { - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1" - }, - "dependencies": { - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "requires": { - "number-is-nan": "^1.0.0" - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "requires": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "requires": { - "ansi-regex": "^2.0.0" - } - } - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=" - }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" - }, - "yargs": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", - "integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==", - "requires": { - "cliui": "^4.0.0", - "decamelize": "^1.1.1", - "find-up": "^2.1.0", - "get-caller-file": "^1.0.1", - "os-locale": "^2.0.0", - "require-directory": "^2.1.1", - "require-main-filename": "^1.0.1", - "set-blocking": "^2.0.0", - "string-width": "^2.0.0", - "which-module": "^2.0.0", - "y18n": "^3.2.1", - "yargs-parser": "^9.0.2" - } - }, - "yargs-parser": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz", - "integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=", - "requires": { - "camelcase": "^4.1.0" - } - } - } - } - } -} diff --git a/packages/constants/package.json b/packages/constants/package.json index 7f8c812cf..df86d8223 100644 --- a/packages/constants/package.json +++ b/packages/constants/package.json @@ -24,5 +24,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xaeb8888de915b16261b73a42af366ff0cb997714c625dd1d01ad7efb06193ada" + "tarballHash": "0x1364f6b985d6422adb067281d59a9f69b3cf1a4f9d93877e61b81564d37b2102" } diff --git a/packages/contracts/lib/index.js b/packages/contracts/lib/index.js index a584c1142..7758215c5 100644 --- a/packages/contracts/lib/index.js +++ b/packages/contracts/lib/index.js @@ -12,6 +12,13 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); +var __spreadArrays = (this && this.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +}; Object.defineProperty(exports, "__esModule", { value: true }); var abi_1 = require("@ethersproject/abi"); var abstract_provider_1 = require("@ethersproject/abstract-provider"); @@ -541,7 +548,7 @@ var Contract = /** @class */ (function () { var event = _this._wrapEvent(runningEvent, log, listener); var values = (event.values || []); values.push(event); - _this.emit.apply(_this, [runningEvent.filter].concat(values)); + _this.emit.apply(_this, __spreadArrays([runningEvent.filter], values)); }; this._wrappedEmits[runningEvent.tag] = wrappedEmit; // Special events, like "error" do not have a filter diff --git a/packages/contracts/package.json b/packages/contracts/package.json index cf8447166..90b3e5f79 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -33,5 +33,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x3506d2a5a71c8d884650f4c345468885f236c3bb8446ef6d192f370f78cc402c" + "tarballHash": "0x96959b21d3ac6d5028c69fe586cad288e262ad168b8af3ff3c807bdea5456477" } diff --git a/packages/errors/package.json b/packages/errors/package.json index eee6ce45a..5cb20e858 100644 --- a/packages/errors/package.json +++ b/packages/errors/package.json @@ -21,5 +21,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xa4090df9190530d90a5a187fe1a831fc1e7178285bdfc561791daa8a1095be43" + "tarballHash": "0x512b1e86235f7d9dc5d680f65820d53ab6ca1ac6be70f0d365e2bb25f509fbc5" } diff --git a/packages/ethers/dist/ethers.esm.js b/packages/ethers/dist/ethers.esm.js index 38efbd5c3..918dad879 100644 --- a/packages/ethers/dist/ethers.esm.js +++ b/packages/ethers/dist/ethers.esm.js @@ -7568,6 +7568,10 @@ class TransactionOrderForkEvent extends ForkEvent { /////////////////////////////// // Exported Abstracts class Provider { + constructor() { + logger$c.checkAbstract(new.target, Provider); + defineReadOnly(this, "_isProvider", true); + } // Alias for "on" addListener(eventName, listener) { return this.on(eventName, listener); @@ -7576,10 +7580,6 @@ class Provider { removeListener(eventName, listener) { return this.off(eventName, listener); } - constructor() { - logger$c.checkAbstract(new.target, Provider); - defineReadOnly(this, "_isProvider", true); - } static isProvider(value) { return !!(value && value._isProvider); } diff --git a/packages/ethers/dist/ethers.esm.min.js b/packages/ethers/dist/ethers.esm.min.js index fc94f112f..f4554fd0d 100644 --- a/packages/ethers/dist/ethers.esm.min.js +++ b/packages/ethers/dist/ethers.esm.min.js @@ -1 +1 @@ -var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),s=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function h(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return i}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(i=0,s=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-s&4194303,(s+=24)>=26&&(s-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,a=Math.min(s,s-o)+r,l=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var l=1;l>>26,f=67108863&h,c=Math.min(l,e.length-1),d=Math.max(0,l-t.length+1);d<=c;d++){var p=l-d|0;u+=(o=(i=0|t.words[p])*(s=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[l]=0|f,h=0|u}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,s=0,o=0;o>>24-i&16777215)||o!==this.length-1?l[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=u[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:l[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),s=n||Math.max(1,i);r(i<=s,"byte array longer than desired length"),r(s>0,"Requested array length <= 0"),this.strip();var o,a,h="le"===e,l=new t(s),u=this.clone();if(h){for(a=0;!u.isZero();a++)o=u.andln(255),u.iushrn(8),l[a]=o;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s>>26;for(;0!==i&&s>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,E=b>>>13,_=0|o[4],A=8191&_,S=_>>>13,M=0|o[5],k=8191&M,P=M>>>13,x=0|o[6],T=8191&x,N=x>>>13,I=0|o[7],R=8191&I,C=I>>>13,B=0|o[8],O=8191&B,F=B>>>13,D=0|o[9],L=8191&D,U=D>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ht=8191&at,lt=at>>>13,ut=0|a[8],ft=8191&ut,ct=ut>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;l=((s=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,s=Math.imul(m,H);var yt=(l+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;l=((s=s+Math.imul(c,G)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,H))+Math.imul(v,j)|0,s=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,G)|0;var vt=(l+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;l=((s=s+Math.imul(c,J)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(E,j)|0,s=Math.imul(E,H),n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(v,K)|0,s=s+Math.imul(v,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,J)|0;var bt=(l+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;l=((s=s+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,H))+Math.imul(S,j)|0,s=Math.imul(S,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,K)|0,s=s+Math.imul(E,G)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,s=s+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,$)|0;var wt=(l+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;l=((s=s+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(P,j)|0,s=Math.imul(P,H),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,K)|0,s=s+Math.imul(S,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(E,V)|0,s=s+Math.imul(E,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,tt)|0;var Et=(l+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;l=((s=s+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(T,j),i=(i=Math.imul(T,H))+Math.imul(N,j)|0,s=Math.imul(N,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(P,K)|0,s=s+Math.imul(P,G)|0,n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(S,V)|0,s=s+Math.imul(S,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,X)|0,s=s+Math.imul(E,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,nt)|0;var _t=(l+(n=n+Math.imul(f,st)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(c,st)|0))<<13)|0;l=((s=s+Math.imul(c,ot)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(C,j)|0,s=Math.imul(C,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(P,V)|0,s=s+Math.imul(P,J)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(S,X)|0,s=s+Math.imul(S,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,nt)|0,n=n+Math.imul(p,st)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var At=(l+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(c,ht)|0))<<13)|0;l=((s=s+Math.imul(c,lt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,s=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,G)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(N,V)|0,s=s+Math.imul(N,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,$)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,nt)|0,n=n+Math.imul(y,st)|0,i=(i=i+Math.imul(y,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;l=((s=s+Math.imul(c,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,H))+Math.imul(U,j)|0,s=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,s=s+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,s=s+Math.imul(C,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,nt)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,s=s+Math.imul(m,ct)|0;var Mt=(l+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((s=s+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,G))+Math.imul(U,K)|0,s=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,s=s+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,s=s+Math.imul(C,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,nt)|0,n=n+Math.imul(A,st)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,lt)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,s=s+Math.imul(v,ct)|0;var kt=(l+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,J))+Math.imul(U,V)|0,s=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,s=s+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,nt)|0,n=n+Math.imul(k,st)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(E,ft)|0,s=s+Math.imul(E,ct)|0;var Pt=(l+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,$))+Math.imul(U,X)|0,s=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,s=s+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,nt)|0,n=n+Math.imul(T,st)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(S,ft)|0,s=s+Math.imul(S,ct)|0;var xt=(l+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((s=s+Math.imul(E,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,tt))+Math.imul(U,Y)|0,s=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,s=s+Math.imul(F,nt)|0,n=n+Math.imul(R,st)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(P,ft)|0,s=s+Math.imul(P,ct)|0;var Tt=(l+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul(U,rt)|0,s=Math.imul(U,nt),n=n+Math.imul(O,st)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(F,st)|0,s=s+Math.imul(F,ot)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,lt)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,ct)|0;var Nt=(l+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,st),i=(i=Math.imul(L,ot))+Math.imul(U,st)|0,s=Math.imul(U,ot),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(F,ht)|0,s=s+Math.imul(F,lt)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(C,ft)|0,s=s+Math.imul(C,ct)|0;var It=(l+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,lt))+Math.imul(U,ht)|0,s=Math.imul(U,lt),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,s=s+Math.imul(F,ct)|0;var Rt=(l+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(C,pt)|0))<<13)|0;l=((s=s+Math.imul(C,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul(U,ft)|0,s=Math.imul(U,ct);var Ct=(l+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;l=((s=s+Math.imul(F,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(l+(n=Math.imul(L,pt))|0)+((8191&(i=(i=Math.imul(L,mt))+Math.imul(U,pt)|0))<<13)|0;return l=((s=Math.imul(U,mt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Et,h[6]=_t,h[7]=At,h[8]=St,h[9]=Mt,h[10]=kt,h[11]=Pt,h[12]=xt,h[13]=Tt,h[14]=Nt,h[15]=It,h[16]=Rt,h[17]=Ct,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,s){for(var o=0;o>>=1)i++;return 1<>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=s>>>26,this.words[n]=67108863&s}return 0!==e&&(this.words[n]=e,this.length++),this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new s(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(e=0;e>>26-n}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,l=0;l=0&&(0!==u||l>=i);l--){var f=0|this.words[l];this.words[l]=u<<26-s|f>>>s,u=f&a}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[i+n]=67108863&s}for(;i>26,this.words[i+n]=67108863&s;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,h=n.length-i.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var l=0;l=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},s.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),h=new s(1),l=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++l;for(var u=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(u),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),o.isub(h)):(n.isub(e),a.isub(i),h.isub(o))}return{a:a,b:h,gcd:n.iushln(l)}},s.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new s(1),a=new s(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var l=0,u=1;0==(e.words[0]&u)&&l<26;++l,u<<=1);if(l>0)for(e.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a)):(n.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new _(t)},s.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=s}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new s(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);r(!i.isZero());var a=new s(1).toRed(this),h=a.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new s(2*u*u).toRed(this);0!==this.pow(u,l).cmp(h);)u.redIAdd(h);for(var f=this.pow(u,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var l=e.words[n],u=h-1;u>=0;u--){var f=l>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}h=26}return i},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new A(t)},n(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),o=s.BN;const a="logger/5.0.0-beta.128";let h=!1,l=!1;const u={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=u.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=u[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>u[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(l)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach(function(t){s[t]=r[t]}),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(h){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}l=!!t,h=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.128");function y(t){return!!t.toHexString}function v(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return v(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function E(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),v(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;tE(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),v(n)}function A(t){let e=E(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),v(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function P(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function x(t){if("string"!=typeof t)t=P(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function T(t,e,r){return"string"!=typeof t?t=P(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function N(t){let e=I(P(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=P(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function C(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=E(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=P(r.slice(0,32)),e.s=P(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=P(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=E(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let s=P(r);null==e.s?e.s=s:e.s!==s&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=E(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=P(r)}}return e}function B(t){return P(_([(t=C(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:E,concat:_,stripZeros:A,zeroPad:S,isHexString:M,hexlify:P,hexDataLength:x,hexDataSlice:T,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=P(t).substring(2)}),e},hexValue:N,hexStripZeros:I,hexZeroPad:R,splitSignature:C,joinSignature:B});const F=new p("bignumber/5.0.0-beta.129"),D={},L=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==D&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(D,z(t)):t.match(/^-?[0-9]+$/)?new U(D,z(new o(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=L||t<=-L)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(P(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new o("-"+e.substring(3),16):new o(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.129"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let s=i[0],o=i[1];for(s||(s="0"),o||(o="0"),o.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");o.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let s=$(n,r.decimals);return new tt(G,i,s,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(E(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),s=$(n,r.decimals);return new tt(G,i,s,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.130");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function st(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function ot(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ht(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ht(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ht(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class lt{constructor(t){for(let e in t)this[e]=ht(t[e]);Object.freeze(this)}}var ut=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:st,shallowCopy:ot,deepCopy:ht,Description:lt});const ft="abi/5.0.0-beta.136",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const yt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(vt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==yt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===yt.full?", ":",")+")"):e+=this.type,t!==yt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===yt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:xt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let s={type:"",name:"",state:{allowType:!0}},o=s;for(let r=0;rbt.fromString(t,e))}class Et{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return Et.isFragment(t)?t:"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){return Et.isFragment(t)?t:"function"===t.type?Pt.fromObject(t):"event"===t.type?_t.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return _t.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return Pt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class _t extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){if(_t.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new _t(dt,{name:Nt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),_t.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function At(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function St(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===yt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=At(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),St(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Pt extends kt{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Pt.fromString(t):Pt.fromObject(t)}static fromObject(t){if(Pt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new Pt(dt,{type:t.type,name:Nt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=At(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Tt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),St(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return Pt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function xt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Tt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Nt(t){if(!t||!t.match(Tt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Ct{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Bt{constructor(t){rt(this,"wordSize",t||32),this._data=E([]),this._padding=new Uint8Array(t)}get data(){return P(this._data)}get length(){return this._data.length}_writeData(t){return this._data=_([this._data,t]),t.length}writeBytes(t){let e=E(t);return e.length%this.wordSize&&(e=_([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=E(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=_([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",E(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return P(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),s=[0,8,16,24],o=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],h=["hex","buffer","arrayBuffer","array"],l=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},u=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=l(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,o=this.blocks,a=this.byteCount,h=this.blockCount,l=0,u=this.s;l>2]|=t[l]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=o[h],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(E(r),o=0)}return s&&(t=r[o],s>0&&(h+=i[t>>4&15]+i[15&t]),s>1&&(h+=i[t>>12&15]+i[t>>8&15]),s>2&&(h+=i[t>>20&15]+i[t>>16&15])),h},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);o>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&E(n)}return s&&(t=a<<2,e=n[o],s>0&&(h[t]=255&e),s>1&&(h[t+1]=e>>8&255),s>2&&(h[t+2]=e>>16&255)),h};var E=function(t){var e,r,n,i,s,a,h,l,u,f,c,d,p,m,g,y,v,b,w,E,_,A,S,M,k,P,x,T,N,I,R,C,B,O,F,D,L,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,st,ot,at,ht,lt,ut;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],h=t[3]^t[13]^t[23]^t[33]^t[43],l=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|h>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(h<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(l<<1|u>>>31),r=s^(u<<1|l>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=h^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=l^(d<<1|p>>>31),r=u^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|s>>>31),r=c^(s<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,T=t[20]<<3|t[21]>>>29,N=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,lt=t[42]<<2|t[43]>>>30,ut=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,L=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,B=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,E=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,P=t[18]<<20|t[19]>>>12,x=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,A=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=m^~y&b,t[1]=g^~v&w,t[10]=M^~P&T,t[11]=k^~x&N,t[20]=O^~D&U,t[21]=F^~L&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&st,t[41]=rt^~it&ot,t[2]=y^~b&E,t[3]=v^~w&_,t[12]=P^~T&I,t[13]=x^~N&R,t[22]=D^~U&j,t[23]=L^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~st&at,t[43]=it^~ot&ht,t[4]=b^~E&A,t[5]=w^~_&S,t[14]=T^~I&C,t[15]=N^~R&B,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=st^~at<,t[45]=ot^~ht&ut,t[6]=E^~A&m,t[7]=_^~S&g,t[16]=I^~C&M,t[17]=R^~B&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~lt&et,t[47]=ht^~ut&rt,t[8]=A^~m&y,t[9]=S^~g&v,t[18]=C^~M&P,t[19]=B^~k&x,t[28]=q^~O&D,t[29]=K^~F&L,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=lt^~et&nt,t[49]=ut^~rt&it,t[0]^=o[n],t[1]^=o[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:P(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:P(t.slice(e+1,e+1+r))}}return{consumed:1,result:P(t[e])}}function qt(t){let e=E(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.127");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=E(Dt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new o(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(T(Dt(zt([e,A(E(t.nonce))])),12))}class Yt extends Ct{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Ct{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Bt(t.wordSize),i=new Bt(t.wordSize),s=[];e.forEach((t,e)=>{let o=r[e];if(t.dynamic){let e=i.length;t.encode(i,o);let r=n.writeUpdatableValue();s.push(t=>{r(t+e)})}else t.encode(n,o)}),s.forEach(t=>{t(n.length)});let o=t.writeBytes(n.data);return o+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let s=null;if(e.dynamic){let r=t.readValue(),o=n.subReader(r.toNumber());s=e.decode(o),i+=o.consumed}else s=e.decode(t);null!=s&&r.push(s)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Ct{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let s=null,o=null;if(192==(224&i))s=1,o=127;else if(224==(240&i))s=2,o=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}s=3,o=65535}if(n+s>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-s-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Ae(t,e=Ee.current){e!=Ee.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return E(r)}function Se(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(_e(t,e))}function Pe(t,e=Ee.current){return _e(Ae(t,e))}function xe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Te(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Ne(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ee||(Ee={}));const Ie=Te("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Ce=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Be=xe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=xe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=xe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ne(t,Ce);if(e)return[t+e.s];let r=Be[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=Pe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),Ee.NFKC)).forEach(t=>{if(function(t){return!!Ne(t,De)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Ne(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends oe{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Ae(e))}decode(t){return ke(super.decode(t))}}class ze extends Ct{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new se(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new le(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new he(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Bt(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(E(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.127"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;tEt.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return T($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?or(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[Pt.fromString(t).format()]}getEvent(t){return M(t)?or(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[_t.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),P(_([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=E(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===P(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Dt(P(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(P(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],s=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))});let o=null!=r?this._abiCoder.decode(n,_(r)):null,a=this._abiCoder.decode(i,e),h=[],l=0,u=0;return t.inputs.forEach((t,e)=>{t.indexed?null==o?h[e]=new ir({_isIndexed:!0,hash:null}):s[e]?h[e]=new ir({_isIndexed:!0,hash:o[u++]}):h[e]=o[u++]:h[e]=a[l++]}),h}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function or(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.130");class hr extends lt{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class lr{addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}constructor(){ar.checkAbstract(new.target,lr),rt(this,"_isProvider",!0)}static isProvider(t){return!(!t||!t._isProvider)}}const ur=new p("abstract-signer/5.0.0-beta.131"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){ur.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&ur.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=ot(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&ur.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{ur.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||ur.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){ur.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ur.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.136"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function yr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},s=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=ot(e.pop())).blockTag&&(s=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(s).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,s).then(r=>{try{let s=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(s=s[0]),s}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ht(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function vr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class Er extends br{constructor(t,e,r,n){let i={address:t},s=e.getEventTopic(r);n?(s!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[s],super(vr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class _r extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Ar{constructor(t,e,r){if(pr.checkNew(new.target,Ar),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):lr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=yr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,yr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,yr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,yr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return sr.isInterface(t)?t:new sr(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=ot(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new _r(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new Er(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new Er(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(vr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ht(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=ot(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Sr{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?P(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=ot(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=P(_([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Ar.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Ar(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Cr={inherits:Tr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,o=255&i;s?r.push(s,o):r.push(o)}else for(n=0;n>>0}return s},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],s=n+t[e+1]>>>0,o=(s>>0,t[e+1]=s},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,s,o,a){var h=0,l=e;return h+=(l=l+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,s,o,a){return e+n+s+a>>>0},sum64_5_hi:function(t,e,r,n,i,s,o,a,h,l){var u=0,f=e;return u+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,s,o,a,h,l){return e+n+s+a+l>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Br(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Br;Br.prototype.update=function(t,e){if(t=Cr.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Cr.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,s=8;s>>3},g1_256:function(t){return Dr(t,17)^Dr(t,19)^t>>>10}},Hr=Cr.sum32,qr=Cr.sum32_4,Kr=Cr.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Cr.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),Pr(t.length<=this.blockSize);for(var e=t.length;e>24&255,u[e.length+1]=f>>16&255,u[e.length+2]=f>>8&255,u[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,u));s||(s=c.length,a=new Uint8Array(s),o=n-((h=Math.ceil(n/s))-1)*s),a.set(c);for(var d=1;d>8,o=255&i;s?r.push(s,o):r.push(o)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),si=r(function(t,e){var r=e;r.assert=Pr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var s;if(i.isOdd()){var o=i.andln(n-1);s=o>(n>>1)-1?(n>>1)-o:o,i.isubn(s)}else s=0;r.push(s);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,h=1;h0||e.cmpn(-i)>0;){var s,o,a,h=t.andln(3)+n&3,l=e.andln(3)+i&3;if(3===h&&(h=-1),3===l&&(l=-1),0==(1&h))s=0;else s=3!==(a=t.andln(7)+n&7)&&5!==a||2!==l?h:-h;if(r[0].push(s),0==(1&l))o=0;else o=3!==(a=e.andln(7)+i&7)&&5!==a||2!==h?l:-l;r[1].push(o),2*n===s+1&&(n=1-n),2*i===o+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new s(t,"hex","le")}}),oi=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=si.getNAF,hi=si.getJSF,li=si.assert;function ui(t,e){this.type=t,this.p=new s(e.p,16),this.red=e.prime?s.red(e.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=e.n&&new s(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=ui;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}ui.prototype.point=function(){throw new Error("Not implemented")},ui.prototype.validate=function(){throw new Error("Not implemented")},ui.prototype._fixedNafMul=function(t,e){li(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=o;e--)a=(a<<1)+n[e];s.push(a)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),u=i;u>0;u--){for(o=0;o=0;a--){for(e=0;a>=0&&0===s[a];a--)e++;if(a>=0&&e++,o=o.dblp(e),a<0)break;var h=s[a];li(0!==h),o="affine"===t.type?h>0?o.mixedAdd(i[h-1>>1]):o.mixedAdd(i[-h-1>>1].neg()):h>0?o.add(i[h-1>>1]):o.add(i[-h-1>>1].neg())}return"affine"===t.type?o.toP():o},ui.prototype._wnafMulAdd=function(t,e,r,n,i){for(var s=this._wnafT1,o=this._wnafT2,a=this._wnafT3,h=0,l=0;l=1;l-=2){var f=l-1,c=l;if(1===s[f]&&1===s[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=hi(r[f],r[c]);h=Math.max(m[0].length,h),a[f]=new Array(h),a[c]=new Array(h);for(var g=0;g=0;l--){for(var E=0;l>=0;){var _=!0;for(g=0;g=0&&E++,b=b.dblp(E),l<0)break;for(g=0;g0?A=o[g][S-1>>1]:S<0&&(A=o[g][-S-1>>1].neg()),b="affine"===A.type?b.mixedAdd(A):b.add(A))}}for(l=0;l=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),h=i.mul(r.b),l=s.mul(n.b);return{k1:t.sub(o).sub(a),k2:h.add(l).neg()}},pi.prototype.pointFromX=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,s=0;s":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new s(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Tr(yi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new yi(this,t,e,r)},yi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},yi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},yi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),f=n.redMul(l),c=h.redSqr().redIAdd(u).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},yi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),l=h.redMul(o),u=r.redMul(h),f=a.redSqr().redIAdd(l).redISub(u).redISub(u),c=a.redMul(u.redISub(f)).redISub(i.redMul(l)),d=this.z.redMul(o);return this.curve.jpoint(f,c,d)},yi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},yi.prototype.inspect=function(){return this.isInfinity()?"":""},yi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var vi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=vi,r.edwards=bi}),Ei=r(function(t,e){var r,n=e,i=si.assert;function s(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");Pr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Ai=_i;_i.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},_i.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Pi=si.assert;function xi(t,e){if(t instanceof xi)return t;this._importDER(t,e)||(Pi(t.r&&t.s,"Signature without r or s"),this.r=new s(t.r,16),this.s=new s(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ti=xi;function Ni(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,s=0,o=e.place;s>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xi.prototype._importDER=function(t,e){t=si.toArray(t,e);var r=new Ni;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=Ii(t,r);if(t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},xi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Ci(n,e.length),(n=n.concat(e)).push(2),Ci(n,r.length);var i=n.concat(r),s=[48];return Ci(s,i.length),s=s.concat(i),si.encode(s,t)};var Bi=si.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Bi(Ei.hasOwnProperty(t),"Unknown curve "+t),t=Ei[t]),t instanceof Ei.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ai({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||oi(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new s(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),a=t.toArray("be",i),h=new Ai({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new s(1)),u=0;;u++){var f=n.k?n.k(u):new s(h.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(l)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ti({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new s(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ti(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,h=o.invm(this.n),l=h.mul(t).umod(this.n),u=h.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(l,r.getPublic(),u)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(l,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Bi((3&r)===r,"The recovery param is more than two bits"),e=new Ti(e,n);var i=this.n,o=new s(t),a=e.r,h=e.s,l=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var f=e.r.invm(i),c=i.sub(o).mul(f).umod(i),d=h.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ti(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch(t){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Di={},Li=n(ni),Ui=r(function(t,e){var r=e;r.version=Li.version,r.utils=si,r.rand=oi,r.curve=wi,r.curves=Ei,r.ec=Fi,r.eddsa=Di}).ec;const zi=new p("signing-key/5.0.0-beta.128");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",P(t));let e=Hi().keyFromPrivate(E(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(E(this.publicKey)),r=Hi().keyFromPublic(E(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(E(this.privateKey)).sign(E(t),{canonical:!0});return C({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(E(this.privateKey)),r=Hi().keyFromPublic(E(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=C(e),n={r:E(r.r),s:E(r.s)};return"0x"+Hi().recoverPubKey(E(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=E(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?P(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):P(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.127");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(T(Dt(T(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(E(t),e))}function Qi(t,e){st(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=E(P(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=A(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(P(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(P(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=C(e),s=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),s+=2*t.chainId+8),r.push(P(s)),r.push(A(E(i.r))),r.push(A(E(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(P(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let s=Dt(zt(i));try{r.from=$i(s,{r:P(r.r),s:P(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Dt(t)}return r}var ts=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.127"}),es=(e(ts),ts.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(ts.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var s=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),ut.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=s,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||ut.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||ut.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||ut.defineReadOnly(i.ethers.wordlists,r,e))}}})),rs=(e(es),es.check,es.Wordlist,es.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",o=null;function a(t){if(null==o&&(o=s.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==es.check(t)))throw o=null,new Error("BIP39 Wordlist for en (English) FAILED")}var h=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),o[t]},e.prototype.getWordIndex=function(t){return a(this),o.indexOf(t)},e}(es.Wordlist));r.langEn=h,es.register(h)})),ns=(e(rs),rs.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=es.Wordlist;var r={en:rs.langEn};e.wordlists=r})),is=(e(ns),ns.Wordlist),ss=ns.wordlists;const os=new p("hdnode/5.0.0-beta.129"),as=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),hs=Ae("Bitcoin seed"),ls=2147483648;function us(t){return(1<=256)throw new Error("Depth too large!");return cs(_([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",P(this.depth),this.parentFingerprint,R(P(this.index),4),this.chainCode,null!=this.privateKey?_(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new ms(ds,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~ls));let r=new Uint8Array(37);if(t&ls){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(E(this.privateKey),1),e&&(e+="'")}else r.set(E(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=E(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),s=n.slice(32),o=null,a=null;if(this.privateKey)o=fs(U.from(i).add(this.privateKey).mod(as));else{a=new qi(P(i))._addPoint(this.publicKey)}return new ms(ds,o,a,this.fingerprint,fs(s),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=ls)throw new Error("invalid path index - "+n);r=r._derive(ls+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invalid path component - "+n);{let t=parseInt(n);if(t>=ls)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=E(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=E(Yn(Xn.sha512,hs,r));return new ms(ds,fs(n.slice(0,32)),null,"0x00000000",fs(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=vs(ys(t,r),r),ms._fromSeed(gs(t,e),t)}static fromSeed(t){return ms._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&cs(e.slice(0,78))===t||os.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=P(e.slice(5,9)),i=parseInt(P(e.slice(9,13)).substring(2),16),s=P(e.slice(13,45)),o=e.slice(45,78);switch(P(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new ms(ds,null,P(o),n,s,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==o[0])break;return new ms(ds,P(o.slice(1)),null,n,s,i,r,null,null)}return os.throwError("invalid extended key","extendedKey","[REDACTED]")}}function gs(t,e){e||(e="");let r=Ae("mnemonic"+e,Ee.NFKD);return ei(Ae(t,Ee.NFKD),r,2048,64,"sha512")}function ys(t,e){e||(e=ss.en),os.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=E(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let s=32*r.length/3,o=us(r.length/3),a=E(Qn(n.slice(0,s/8)))[0];if((a&=o)!==(n[n.length-1]&o))throw new Error("invalid checksum");return P(n.slice(0,s/8))}function vs(t,e){if((t=E(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=E(Qn(t))[0],s=t.length/4;return i&=us(s),r[r.length-1]<<=s,r[r.length-1]|=i>>8-s,e||(e=ss.en),e.join(r.map(t=>e.getWord(t)))}var bs=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.127"}),ws=(e(bs),bs.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),Es=(e(ws),ws.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(bs.version);r.shuffled=ws.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),_s=(e(Es),Es.shuffled),As=Es.randomBytes,Ss=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function s(t){return new Uint8Array(t)}function o(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,h={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},l=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),u={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],_=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],A=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=s[e],this._Kd[t-r][e%4]=s[e];for(var o,a=0,h=i;h>16&255]<<24^c[o>>8&255]<<16^c[255&o]<<8^c[o>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[o>>16&255]<<16^c[o>>24&255]<<24;for(e=i/2+1;e>2,d=h%4,this._Ke[l][d]=s[e],this._Kd[t-l][d]=s[e++],h++}for(var l=1;l>24&255]^A[o>>16&255]^S[o>>8&255]^M[255&o]},P.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var o=1;o>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[o][i];n=r.slice()}var a,h=s(16);for(i=0;i<4;i++)a=this._Ke[e][i],h[4*i]=255&(c[n[i]>>24&255]^a>>24),h[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),h[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return h},P.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var o=1;o>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^E[255&n[(i+1)%4]]^this._Kd[o][i];n=r.slice()}var a,h=s(16);for(i=0;i<4;i++)a=this._Kd[e][i],h[4*i]=255&(d[n[i]>>24&255]^a>>24),h[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),h[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return h};var x=function(t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new P(t)};x.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=s(t.length),r=s(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var C=function(t,e){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new P(t)};C.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,E=s,_=o,A=a,S=h,M=l;for(p=0;p<16;p++)m=f+4*p,u[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=u[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=u[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,u[p]=(g+u[p-7]|0)+(y+u[p-16]|0)|0;for(p=0;p<64;p++)g=(((_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&A^~_&S)|0)+(M+(e[p]+u[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,M=S,S=A,A=_,_=E+g|0,E=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,s=s+E|0,o=o+_|0,a=a+A|0,h=h+S|0,l=l+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,y=t.slice(t.length-d,t.length);for(y.push(128),c=d+1;c>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255,l>>>24&255,l>>>16&255,l>>>8&255,l>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var s=64+e.length+4,o=new Array(s),a=new Array(64),h=[];for(i=0;i<64;i++)o[i]=54;for(i=0;i=s-4;t--){if(o[t]++,o[t]<=255)return;o[t]=0}}for(;r>=32;)l(),h=h.concat(n(a.concat(n(o)))),r-=32;return r>0&&(l(),h=h.concat(n(a.concat(n(o))).slice(0,r))),h}function s(t,e,r,n,i){var s;for(l(t,16*(2*r-1),i,0,16),s=0;s<2*r;s++)h(t,16*s,i,16),a(i,n),l(i,0,t,e+16*s,16);for(s=0;s>>32-e}function a(t,e){l(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=o(e[0]+e[12],7),e[8]^=o(e[4]+e[0],9),e[12]^=o(e[8]+e[4],13),e[0]^=o(e[12]+e[8],18),e[9]^=o(e[5]+e[1],7),e[13]^=o(e[9]+e[5],9),e[1]^=o(e[13]+e[9],13),e[5]^=o(e[1]+e[13],18),e[14]^=o(e[10]+e[6],7),e[2]^=o(e[14]+e[10],9),e[6]^=o(e[2]+e[14],13),e[10]^=o(e[6]+e[2],18),e[3]^=o(e[15]+e[11],7),e[7]^=o(e[3]+e[15],9),e[11]^=o(e[7]+e[3],13),e[15]^=o(e[11]+e[7],18),e[1]^=o(e[0]+e[3],7),e[2]^=o(e[1]+e[0],9),e[3]^=o(e[2]+e[1],13),e[0]^=o(e[3]+e[2],18),e[6]^=o(e[5]+e[4],7),e[7]^=o(e[6]+e[5],9),e[4]^=o(e[7]+e[6],13),e[5]^=o(e[4]+e[7],18),e[11]^=o(e[10]+e[9],7),e[8]^=o(e[11]+e[10],9),e[9]^=o(e[8]+e[11],13),e[10]^=o(e[9]+e[8],18),e[12]^=o(e[15]+e[14],7),e[13]^=o(e[12]+e[15],9),e[14]^=o(e[13]+e[12],13),e[15]^=o(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function h(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,o,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),o=f(o,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/o)throw new Error("N too large");if(o>r/128/a)throw new Error("r too large");if(!u(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!u(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*o),m=new Uint32Array(32*a*o),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(C)};C()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Os=new Uint8Array(16);Cs=function(){return crypto.getRandomValues(Os),Os}}if(!Cs){var Fs=new Array(16);Cs=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Fs[e]=t>>>((3&e)<<3)&255;return Fs}}for(var Ds=Cs,Ls=[],Us={},zs=0;zs<256;zs++)Ls[zs]=(zs+256).toString(16).substr(1),Us[Ls[zs]]=zs;function js(t,e){var r=e||0,n=Ls;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var Hs=Ds(),qs=[1|Hs[0],Hs[1],Hs[2],Hs[3],Hs[4],Hs[5]],Ks=16383&(Hs[6]<<8|Hs[7]),Gs=0,Ws=0;function Vs(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Ds)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var s=0;s<16;s++)e[n+s]=i[s];return e||js(i)}var Js=Vs;Js.v1=function(t,e,r){var n=e&&r||0,i=e||[],s=void 0!==(t=t||{}).clockseq?t.clockseq:Ks,o=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Ws+1,h=o-Gs+(a-Ws)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||o>Gs)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Gs=o,Ws=a,Ks=s;var l=(1e4*(268435455&(o+=122192928e5))+a)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var u=o/4294967296*1e4&268435455;i[n++]=u>>>8&255,i[n++]=255&u,i[n++]=u>>>24&15|16,i[n++]=u>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var f=t.node||qs,c=0;c<6;c++)i[n+c]=f[c];return e||js(i)},Js.v4=Vs,Js.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=Us[t])});i<16;)e[n+i++]=0;return e},Js.unparse=js;var Zs=Js;class Xs extends lt{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function $s(t,e,r){let n=JSON.parse(t),i=Ps(e),s=function(t,e){let r=Ms(xs(n,"crypto/ciphertext"));if(P(function(t,e){return Dt(_([t,e]))}(t.slice(16,32),r)).substring(2)!==xs(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===xs(n,"crypto/cipher")){let r=Ms(xs(n,"crypto/cipherparams/iv")),i=new Ss.Counter(r);return E(new Ss.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),s=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let o=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==o)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:o,privateKey:P(i)};if("0.1"===xs(n,"x-ethers/version")){let t=Ms(xs(n,"x-ethers/mnemonicCiphertext")),r=Ms(xs(n,"x-ethers/mnemonicCounter")),i=new Ss.Counter(r),o=new Ss.ModeOfOperation.ctr(s,i),h=xs(n,"x-ethers/path")||ps,l=vs(E(o.decrypt(t))),u=ms.fromMnemonic(l).derivePath(h);if(u.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=u.mnemonic,a.path=u.path}return new Xs(a)};return new Promise(function(t,e){let o=xs(n,"crypto/kdf");if(o&&"string"==typeof o)if("scrypt"===o.toLowerCase()){let o=Ms(xs(n,"crypto/kdfparams/salt")),a=parseInt(xs(n,"crypto/kdfparams/n")),h=parseInt(xs(n,"crypto/kdfparams/r")),l=parseInt(xs(n,"crypto/kdfparams/p"));if(!a||!h||!l)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(xs(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Bs(i,o,a,h,l,64,function(n,i,o){if(n)n.progress=i,e(n);else if(o){o=E(o);let n=s(o,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===o.toLowerCase()){let r=Ms(xs(n,"crypto/kdfparams/salt")),o=null,a=xs(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)o="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));o="sha512"}let h=parseInt(xs(n,"crypto/kdfparams/c")),l=parseInt(xs(n,"crypto/kdfparams/dklen"));if(32!==l)return void e(new Error("unsupported key-derivation derived-key length"));let u=E(ei(i,r,h,l,o)),f=s(u,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Qs(t,e,r){if(Is(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=Ps(e);let n=$t(xs(r,"ethaddr")),i=Ms(xs(r,"encseed"));i&&i.length%16==0||Ts.throwArgumentError("invalid encseed","json",t);let s=E(ei(e,e,2e3,32,"sha256")).slice(0,16),o=i.slice(0,16),a=i.slice(16),h=E(new Ss.ModeOfOperation.cbc(s,o).decrypt(a));h=Ss.padding.pkcs7.strip(h);let l="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&Ys.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||ps;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(ms.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&Ys.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&Ys.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!lr.isProvider(e)&&Ys.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new to(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Dt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(B(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(ms.fromMnemonic(t.mnemonic).derivePath(t.path||ps).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=E(t.privateKey),s=Ps(e),o=null,a=t.path;t.mnemonic&&(o=E(ys(t.mnemonic)),a||(a=ps));let h=r.client;h||(h="ethers.js");let l=null;l=r.salt?E(r.salt):As(32);let u=null;if(r.iv){if(16!==(u=E(r.iv)).length)throw new Error("invalid iv")}else u=As(16);let f=null;if(r.uuid){if(16!==(f=E(r.uuid)).length)throw new Error("invalid uuid")}else f=As(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Bs(s,l,c,d,p,64,function(s,m,g){if(s)s.progress=m,r(s);else if(g){let r=(g=E(g)).slice(0,16),s=g.slice(16,32),m=g.slice(32,64),y=new Ss.Counter(u),v=E(new Ss.ModeOfOperation.ctr(r,y).encrypt(i)),b=Dt(_([s,v])),w={address:t.address.substring(2).toLowerCase(),id:Zs.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:P(u).substring(2)},ciphertext:P(v).substring(2),kdf:"scrypt",kdfparams:{salt:P(l).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(o){let t=As(16),e=new Ss.Counter(t),r=E(new Ss.ModeOfOperation.ctr(m,e).encrypt(o)),n=new Date,i=n.getUTCFullYear()+"-"+ks(n.getUTCMonth()+1,2)+"-"+ks(n.getUTCDate(),2)+"T"+ks(n.getUTCHours(),2)+"-"+ks(n.getUTCMinutes(),2)+"-"+ks(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:h,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:P(t).substring(2),mnemonicCiphertext:P(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=As(16);t||(t={}),t.extraEntropy&&(e=E(T(Dt(_([e,t.extraEntropy])),0,16)));let r=vs(e,t.locale);return to.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Qs(t,e,r).then(t=>new to(t))}static fromMnemonic(t,e,r){return e||(e=ps),new to(ms.fromMnemonic(t,null,r).derivePath(e))}}const eo=new p("networks/5.0.0-beta.128");function ro(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function no(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const io={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ro("homestead")},so={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ro("ropsten")},oo={unspecified:{chainId:0,name:"unspecified"},homestead:io,mainnet:io,morden:{chainId:2,name:"morden"},ropsten:so,testnet:so,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ro("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ro("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ro("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:no("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:no("https://web3.gastracker.io/morden","classicTestnet")}};function ao(t){if(null==t)return null;if("number"==typeof t){for(let e in oo){let r=oo[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=oo[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=oo[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&eo.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&eo.throwArgumentError("invalid network chainId","network",t),t)}var ho=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function s(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function y(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];y.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,s){var o=new m(t,n);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function l(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new y(n,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),o.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),o.signal&&(o.signal.addEventListener("abort",l),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",l)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=h,t.Request=m,t.Response=y),e.Headers=h,e.Request=m,e.Response=y,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),lo=(ho.fetch,ho.Headers,ho.Request,ho.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(o=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&mo.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+co(Ae(e))}}}return new Promise(function(t,a){let h=null;o&&(h=setTimeout(()=>{null!=h&&(h=null,a(mo.makeError("timeout",p.errors.TIMEOUT,{timeout:o})))},o));let l=()=>{null!=h&&(clearTimeout(h),h=null)};e&&(s.method="POST",s.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let u={};return Object.keys(n).forEach(t=>{let e=n[t];u[e.key]=e.value}),s.headers=u,ho(i,s).then(t=>t.text().then(e=>(t.ok||mo.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){mo.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){mo.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{l(),t(e)},t=>{l(),a(t)})})}function yo(t,e){return e||(e={}),null==(e=ot(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,s=!1,o=()=>!s&&(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,h=0;!function i(){return t().then(function(t){if(void 0!==t)o()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!s){if(++h>a)return void(o()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){o()&&n(t)})}()})}const vo="providers/5.0.0-beta.140",bo=new p(vo);class wo{constructor(){bo.checkNew(new.target,wo),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),s=this.hash.bind(this),o=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:s,blockHash:wo.allowNull(s,null),blockNumber:wo.allowNull(a,null),transactionIndex:wo.allowNull(a,null),confirmations:wo.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:wo.allowNull(e,null),value:r,nonce:a,data:i,r:wo.allowNull(this.uint256),s:wo.allowNull(this.uint256),v:wo.allowNull(a),creates:wo.allowNull(e,null),raw:wo.allowNull(i)},t.transactionRequest={from:wo.allowNull(e),nonce:wo.allowNull(a),gasLimit:wo.allowNull(r),gasPrice:wo.allowNull(r),to:wo.allowNull(e),value:wo.allowNull(r),data:wo.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:wo.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:s,address:e,topics:wo.arrayOf(s),data:i,logIndex:a,blockHash:s},t.receipt={to:wo.allowNull(this.address),from:wo.allowNull(this.address),contractAddress:wo.allowNull(e,null),transactionIndex:a,root:wo.allowNull(s),gasUsed:r,logsBloom:wo.allowNull(i),blockHash:s,transactionHash:s,logs:wo.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:wo.allowNull(a,null),cumulativeGasUsed:r,status:wo.allowNull(a)},t.block={hash:s,parentHash:s,number:a,timestamp:a,nonce:wo.allowNull(o),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:wo.allowNull(wo.arrayOf(s))},t.blockWithTransactions=ot(t.block),t.blockWithTransactions.transactions=wo.allowNull(wo.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:wo.allowNull(n,void 0),toBlock:wo.allowNull(n,void 0),blockHash:wo.allowNull(s,void 0),address:wo.allowNull(e,void 0),topics:wo.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:wo.allowNull(a),blockHash:wo.allowNull(s),transactionIndex:a,removed:wo.allowNull(this.boolean.bind(this)),address:e,data:wo.allowFalsish(i,"0x"),topics:wo.arrayOf(s),transactionHash:s,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bo.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(T(t,12));return e===ue?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return N(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==x(r)?bo.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),wo.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return wo.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=wo.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return wo.check(this.formats.receiptLog,t)}receipt(t){let e=wo.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return wo.check(this.formats.filter,t)}filterLog(t){return wo.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const Eo=new p(vo);function _o(t){return null==t?"null":(32!==x(t)&&Eo.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function Ao(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[_o(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return _o(t)}).join("&")}function So(t){if("string"==typeof t){if(32===x(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+Ao(t);if(hr.isForkEvent(t))throw Eo.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+Ao(t.topics||[])}throw new Error("invalid event - "+t)}function Mo(){return(new Date).getTime()}class ko{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let Po=null,xo=1;class To extends lr{constructor(t){if(Eo.checkNew(new.target,lr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):Eo.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==Po&&(Po=new wo),Po}static getNetwork(t){return ao(null==t?"homestead":t)}poll(){let t=xo++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let s=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(s);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Mo();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>N(t))}).then(t=>P(t))}_wrapTransaction(t,e){if(null!=e&&32!==x(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&Eo.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&Eo.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>P(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&Eo.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){Eo.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return yo(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return yo(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return yo(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>wo.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&Eo.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||Eo.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=E(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return Eo.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ko(So(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=So(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=So(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=So(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=So(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=So(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const No=new p(vo);function Io(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Ro(t){return t?t.toLowerCase():t}const Co={};class Bo extends cr{constructor(t,e,r){if(No.checkNew(new.target,Bo),super(),t!==Co)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):No.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return No.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Oo(Co,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&No.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=ot(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=ot(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&No.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&No.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&No.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return No.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>yo(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Ae(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),P(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Oo extends Bo{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fo={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Do extends To{constructor(t,e){if(No.checkNew(new.target,Do),"string"==typeof t&&null===e&&ao(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(ao(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(ao(U.from(e).toNumber()))}).catch(t=>{e(No.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Bo(Co,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ht(r),provider:this}),go(this.connection,JSON.stringify(r),Io).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Ro(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Ro(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Ro(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Ro(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&No.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&No.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&No.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):No.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Ro(e.filter.address)),this.send("eth_getLogs",[e.filter])}return No.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=ot(Fo);if(e)for(let t in e)e[t]&&(r[t]=!0);st(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=N(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=P(t[e]))}),n}}const Lo=new p(vo);class Uo extends Do{constructor(t,e){Lo.checkAbstract(new.target,Uo),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Lo.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Lo.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return ao(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Lo.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zo=new p(vo),jo="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Ho=new p(vo);const qo=new p(vo);function Ko(t){let e=[];for(let r in t){if(null==t[r])continue;let n=P(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=N(n)),e.push(r+"="+n)}return e.join("&")}function Go(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Wo(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vo(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Jo extends To{constructor(t,e){qo.checkNew(new.target,Jo),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),go(t,null,e||Wo).then(e=>(this.emit("debug",{action:"response",request:t,response:ht(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Go);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Wo);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Wo);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qo.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qo.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qo.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ko(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ko(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vo(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vo(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let s=this;return i(r+=n,Go).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?s.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Go).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),go(n,null,Go).then(t=>{this.emit("debug",{action:"response",request:n,response:ht(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zo=new p(vo);function Xo(){return(new Date).getTime()}function $o(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zo.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qo=1;class Yo extends To{constructor(t,e,r){Zo.checkNew(new.target,Yo),0===t.length&&Zo.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zo.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zo.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zo.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$o(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($o(t)||Zo.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zo.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xo(),n=_s(this.providers).map((n,i)=>{let s=this.weights[i],o=Qo++;return{run:()=>{let i=Xo(),a=i-r;return this.emit("debug",{action:"request",rid:o,backend:{weight:s,start:a,provider:n},request:{method:t,params:ht(e)},provider:this}),Yo.doPerform(n,t,e).then(r=>{let h=Xo()-i;return this.emit("debug",{action:"response",rid:o,backend:{weight:s,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},response:ht(r)}),{weight:s,result:r}},r=>{let h=Xo()-i;return this.emit("debug",{action:"response",rid:o,backend:{weight:s,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},error:r}),{weight:s,error:r}})},weight:s}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let s=null,o=0,a={},h=()=>{if(0===n.length)return;let l=n.shift();o+=l.weight,l.run().then(u=>{if(null!==a){if(o-=l.weight,u.error)null==s&&(s=u.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(u.result);null==a[t]&&(a[t]=[]),a[t].push(u);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===o){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===s&&(s=Zo.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(s)}setTimeout(h,0)}}),o{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(vo),ia="84842078b09946638c03157f83405213";const sa=new p(vo),oa="ETHERS_JS_SHARED";const aa=new p(vo);class ha extends Do{constructor(t,e){aa.checkNew(new.target,ha),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var la=Object.freeze({Provider:lr,BaseProvider:To,FallbackProvider:Yo,AlchemyProvider:class extends Uo{static getApiKey(t){return null==t?jo:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zo.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Uo{static getUrl(t,e){null!=e&&Ho.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Ho.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Jo,InfuraProvider:class extends Uo{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Do,NodesmithProvider:class extends Uo{static getApiKey(t){return t||oa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:sa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ha,IpcProvider:ra,JsonRpcSigner:Bo,getNetwork:ao,Formatter:wo});const ua=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?S(r,32):E(r);case"string":return Ae(r);case"bytes":return E(r);case"bool":return r=r?"0x01":"0x00",n?S(r,32):E(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),S(r=U.from(r).toTwos(t),t/8)}if(i=e.match(ua)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(E(r).byteLength!==t)throw new Error("invalid value for "+e);return n?E((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let s=[];return r.forEach(function(e){s.push(t(n,e,!0))}),_(s)}throw new Error("unknown type - "+e)}(t,e[n]))}),P(_(r))}const ma=new p("units/5.0.0-beta.126"),ga=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ya(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return $(t,null!=e?e:18)}function va(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return Q(t,null!=e?e:18)}var ba=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:Et,EventFragment:_t,FunctionFragment:Pt,ParamType:bt,FormatTypes:yt,Logger:p,RLP:Kt,fetchJson:go,poll:yo,checkProperties:st,deepCopy:ht,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:ot,arrayify:E,concat:_,stripZeros:A,zeroPad:S,defaultPath:ps,HDNode:ms,SigningKey:qi,Interface:sr,base64:po,hexlify:P,isHexString:M,hexStripZeros:I,hexValue:N,hexZeroPad:R,hexDataLength:x,hexDataSlice:T,nameprep:Le,_toEscapedUtf8String:function(t,e){return'"'+_e(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Se(t):Se(55296+((t-=65536)>>10&1023))+Se(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Ae,toUtf8CodePoints:Pe,toUtf8String:ke,formatBytes32String:function(t){let e=Ae(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return P(_([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=E(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new o($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return ya(t,18)},parseEther:function(t){return va(t,18)},formatUnits:ya,parseUnits:va,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&ma.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let s=[];for(;r.length;){if(r.length<=3){s.unshift(r);break}{let t=r.length-3;s.unshift(r.substring(t)),r=r.substring(0,t)}}return n+s.join(",")+i},keccak256:Dt,sha256:Qn,randomBytes:As,solidityPack:pa,solidityKeccak256:function(t,e){return Dt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:C,joinSignature:B,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Is(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Rs(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:ys,entropyToMnemonic:vs,isValidMnemonic:function(t,e){try{return ys(t,e),!0}catch(t){}return!1},mnemonicToSeed:gs,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return Ee},Indexed:ir});const wa="ethers/5.0.0-beta.155",Ea=p.errors,_a=new p(wa);function Aa(t,e){null==t&&(t="homestead");let r=ao(t);return r&&r._defaultProvider||_a.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(la,e)}var Sa=Object.freeze({Signer:cr,Wallet:to,VoidSigner:dr,getDefaultProvider:Aa,providers:la,Contract:Ar,ContractFactory:Sr,BigNumber:U,FixedNumber:tt,constants:ve,errors:Ea,logger:_a,utils:ba,wordlists:ss,version:wa,Wordlist:is});export{U as BigNumber,Ar as Contract,Sr as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,to as Wallet,is as Wordlist,ve as constants,Ea as errors,Sa as ethers,Aa as getDefaultProvider,_a as logger,la as providers,ba as utils,wa as version,ss as wordlists}; +var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function r(t,e){return t(e={exports:{}},e.exports),e.exports}function n(t){return t&&t.default||t}var i=n(Object.freeze({default:{}})),s=r(function(e){!function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}function n(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}function s(t,e,r){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(r=e,e=10),this._init(t||0,e||10,r||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o=i.Buffer}catch(t){}function a(t,e,r){for(var n=0,i=Math.min(t.length,r),s=e;s=49&&o<=54?o-49+10:o>=17&&o<=22?o-17+10:15&o}return n}function h(t,e,r,n){for(var i=0,s=Math.min(t.length,r),o=e;o=49?a-49+10:a>=17?a-17+10:a}return i}s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),r(e===(0|e)&&e>=2&&e<=36);var i=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&i++,16===e?this._parseHex(t,i):this._parseBase(t,e,i),"-"===t[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(r(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initArray=function(t,e,n){if(r("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)o=t[i]|t[i-1]<<8|t[i-2]<<16,this.words[s]|=o<>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(i=0,s=0;i>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this.strip()},s.prototype._parseHex=function(t,e){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var r=0;r=e;r-=6)i=a(t,r,r+6),this.words[n]|=i<>>26-s&4194303,(s+=24)>=26&&(s-=26,n++);r+6!==e&&(i=a(t,e,r+6),this.words[n]|=i<>>26-s&4194303),this.strip()},s.prototype._parseBase=function(t,e,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=e)n++;n--,i=i/e|0;for(var s=t.length-r,o=s%n,a=Math.min(s,s-o)+r,l=0,u=r;u1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},s.prototype.inspect=function(){return(this.red?""};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],u=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function c(t,e,r){r.negative=e.negative^t.negative;var n=t.length+e.length|0;r.length=n,n=n-1|0;var i=0|t.words[0],s=0|e.words[0],o=i*s,a=67108863&o,h=o/67108864|0;r.words[0]=a;for(var l=1;l>>26,f=67108863&h,c=Math.min(l,e.length-1),d=Math.max(0,l-t.length+1);d<=c;d++){var p=l-d|0;u+=(o=(i=0|t.words[p])*(s=0|e.words[d])+f)/67108864|0,f=67108863&o}r.words[l]=0|f,h=0|u}return 0!==h?r.words[l]=0|h:r.length--,r.strip()}s.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var i=0,s=0,o=0;o>>24-i&16777215)||o!==this.length-1?l[6-h.length]+h+n:h+n,(i+=2)>=26&&(i-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var c=u[t],d=f[t];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(t);n=(p=p.idivn(d)).isZero()?m+n:l[c-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16)},s.prototype.toBuffer=function(t,e){return r(void 0!==o),this.toArrayLike(o,t,e)},s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)},s.prototype.toArrayLike=function(t,e,n){var i=this.byteLength(),s=n||Math.max(1,i);r(i<=s,"byte array longer than desired length"),r(s>0,"Requested array length <= 0"),this.strip();var o,a,h="le"===e,l=new t(s),u=this.clone();if(h){for(a=0;!u.isZero();a++)o=u.andln(255),u.iushrn(8),l[a]=o;for(;a=4096&&(r+=13,e>>>=13),e>=64&&(r+=7,e>>>=7),e>=8&&(r+=4,e>>>=4),e>=2&&(r+=2,e>>>=2),r+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,r=0;return 0==(8191&e)&&(r+=13,e>>>=13),0==(127&e)&&(r+=7,e>>>=7),0==(15&e)&&(r+=4,e>>>=4),0==(3&e)&&(r+=2,e>>>=2),0==(1&e)&&r++,r},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;et.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var r=0;rt.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,r;this.length>t.length?(e=this,r=t):(e=t,r=this);for(var n=0;nt.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){r("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){r("number"==typeof t&&t>=0);var n=t/26|0,i=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<t.length?(r=this,n=t):(r=t,n=this);for(var i=0,s=0;s>>26;for(;0!==i&&s>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;st.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var r,n,i=this.cmp(t);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=t):(r=t,n=this);for(var s=0,o=0;o>26,this.words[o]=67108863&e;for(;0!==s&&o>26,this.words[o]=67108863&e;if(0===s&&o>>13,d=0|o[1],p=8191&d,m=d>>>13,g=0|o[2],y=8191&g,v=g>>>13,b=0|o[3],w=8191&b,E=b>>>13,_=0|o[4],A=8191&_,S=_>>>13,M=0|o[5],k=8191&M,P=M>>>13,x=0|o[6],T=8191&x,N=x>>>13,I=0|o[7],R=8191&I,C=I>>>13,B=0|o[8],O=8191&B,F=B>>>13,D=0|o[9],L=8191&D,U=D>>>13,z=0|a[0],j=8191&z,H=z>>>13,q=0|a[1],K=8191&q,G=q>>>13,W=0|a[2],V=8191&W,J=W>>>13,Z=0|a[3],X=8191&Z,$=Z>>>13,Q=0|a[4],Y=8191&Q,tt=Q>>>13,et=0|a[5],rt=8191&et,nt=et>>>13,it=0|a[6],st=8191&it,ot=it>>>13,at=0|a[7],ht=8191&at,lt=at>>>13,ut=0|a[8],ft=8191&ut,ct=ut>>>13,dt=0|a[9],pt=8191&dt,mt=dt>>>13;r.negative=t.negative^e.negative,r.length=19;var gt=(l+(n=Math.imul(f,j))|0)+((8191&(i=(i=Math.imul(f,H))+Math.imul(c,j)|0))<<13)|0;l=((s=Math.imul(c,H))+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,n=Math.imul(p,j),i=(i=Math.imul(p,H))+Math.imul(m,j)|0,s=Math.imul(m,H);var yt=(l+(n=n+Math.imul(f,K)|0)|0)+((8191&(i=(i=i+Math.imul(f,G)|0)+Math.imul(c,K)|0))<<13)|0;l=((s=s+Math.imul(c,G)|0)+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,n=Math.imul(y,j),i=(i=Math.imul(y,H))+Math.imul(v,j)|0,s=Math.imul(v,H),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,G)|0)+Math.imul(m,K)|0,s=s+Math.imul(m,G)|0;var vt=(l+(n=n+Math.imul(f,V)|0)|0)+((8191&(i=(i=i+Math.imul(f,J)|0)+Math.imul(c,V)|0))<<13)|0;l=((s=s+Math.imul(c,J)|0)+(i>>>13)|0)+(vt>>>26)|0,vt&=67108863,n=Math.imul(w,j),i=(i=Math.imul(w,H))+Math.imul(E,j)|0,s=Math.imul(E,H),n=n+Math.imul(y,K)|0,i=(i=i+Math.imul(y,G)|0)+Math.imul(v,K)|0,s=s+Math.imul(v,G)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,s=s+Math.imul(m,J)|0;var bt=(l+(n=n+Math.imul(f,X)|0)|0)+((8191&(i=(i=i+Math.imul(f,$)|0)+Math.imul(c,X)|0))<<13)|0;l=((s=s+Math.imul(c,$)|0)+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,n=Math.imul(A,j),i=(i=Math.imul(A,H))+Math.imul(S,j)|0,s=Math.imul(S,H),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,G)|0)+Math.imul(E,K)|0,s=s+Math.imul(E,G)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,s=s+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,s=s+Math.imul(m,$)|0;var wt=(l+(n=n+Math.imul(f,Y)|0)|0)+((8191&(i=(i=i+Math.imul(f,tt)|0)+Math.imul(c,Y)|0))<<13)|0;l=((s=s+Math.imul(c,tt)|0)+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,n=Math.imul(k,j),i=(i=Math.imul(k,H))+Math.imul(P,j)|0,s=Math.imul(P,H),n=n+Math.imul(A,K)|0,i=(i=i+Math.imul(A,G)|0)+Math.imul(S,K)|0,s=s+Math.imul(S,G)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(E,V)|0,s=s+Math.imul(E,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,s=s+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,tt)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,tt)|0;var Et=(l+(n=n+Math.imul(f,rt)|0)|0)+((8191&(i=(i=i+Math.imul(f,nt)|0)+Math.imul(c,rt)|0))<<13)|0;l=((s=s+Math.imul(c,nt)|0)+(i>>>13)|0)+(Et>>>26)|0,Et&=67108863,n=Math.imul(T,j),i=(i=Math.imul(T,H))+Math.imul(N,j)|0,s=Math.imul(N,H),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,G)|0)+Math.imul(P,K)|0,s=s+Math.imul(P,G)|0,n=n+Math.imul(A,V)|0,i=(i=i+Math.imul(A,J)|0)+Math.imul(S,V)|0,s=s+Math.imul(S,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(E,X)|0,s=s+Math.imul(E,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,tt)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,tt)|0,n=n+Math.imul(p,rt)|0,i=(i=i+Math.imul(p,nt)|0)+Math.imul(m,rt)|0,s=s+Math.imul(m,nt)|0;var _t=(l+(n=n+Math.imul(f,st)|0)|0)+((8191&(i=(i=i+Math.imul(f,ot)|0)+Math.imul(c,st)|0))<<13)|0;l=((s=s+Math.imul(c,ot)|0)+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,n=Math.imul(R,j),i=(i=Math.imul(R,H))+Math.imul(C,j)|0,s=Math.imul(C,H),n=n+Math.imul(T,K)|0,i=(i=i+Math.imul(T,G)|0)+Math.imul(N,K)|0,s=s+Math.imul(N,G)|0,n=n+Math.imul(k,V)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(P,V)|0,s=s+Math.imul(P,J)|0,n=n+Math.imul(A,X)|0,i=(i=i+Math.imul(A,$)|0)+Math.imul(S,X)|0,s=s+Math.imul(S,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,tt)|0)+Math.imul(E,Y)|0,s=s+Math.imul(E,tt)|0,n=n+Math.imul(y,rt)|0,i=(i=i+Math.imul(y,nt)|0)+Math.imul(v,rt)|0,s=s+Math.imul(v,nt)|0,n=n+Math.imul(p,st)|0,i=(i=i+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var At=(l+(n=n+Math.imul(f,ht)|0)|0)+((8191&(i=(i=i+Math.imul(f,lt)|0)+Math.imul(c,ht)|0))<<13)|0;l=((s=s+Math.imul(c,lt)|0)+(i>>>13)|0)+(At>>>26)|0,At&=67108863,n=Math.imul(O,j),i=(i=Math.imul(O,H))+Math.imul(F,j)|0,s=Math.imul(F,H),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,G)|0)+Math.imul(C,K)|0,s=s+Math.imul(C,G)|0,n=n+Math.imul(T,V)|0,i=(i=i+Math.imul(T,J)|0)+Math.imul(N,V)|0,s=s+Math.imul(N,J)|0,n=n+Math.imul(k,X)|0,i=(i=i+Math.imul(k,$)|0)+Math.imul(P,X)|0,s=s+Math.imul(P,$)|0,n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,tt)|0)+Math.imul(S,Y)|0,s=s+Math.imul(S,tt)|0,n=n+Math.imul(w,rt)|0,i=(i=i+Math.imul(w,nt)|0)+Math.imul(E,rt)|0,s=s+Math.imul(E,nt)|0,n=n+Math.imul(y,st)|0,i=(i=i+Math.imul(y,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,n=n+Math.imul(p,ht)|0,i=(i=i+Math.imul(p,lt)|0)+Math.imul(m,ht)|0,s=s+Math.imul(m,lt)|0;var St=(l+(n=n+Math.imul(f,ft)|0)|0)+((8191&(i=(i=i+Math.imul(f,ct)|0)+Math.imul(c,ft)|0))<<13)|0;l=((s=s+Math.imul(c,ct)|0)+(i>>>13)|0)+(St>>>26)|0,St&=67108863,n=Math.imul(L,j),i=(i=Math.imul(L,H))+Math.imul(U,j)|0,s=Math.imul(U,H),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,G)|0)+Math.imul(F,K)|0,s=s+Math.imul(F,G)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,s=s+Math.imul(C,J)|0,n=n+Math.imul(T,X)|0,i=(i=i+Math.imul(T,$)|0)+Math.imul(N,X)|0,s=s+Math.imul(N,$)|0,n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,tt)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,tt)|0,n=n+Math.imul(A,rt)|0,i=(i=i+Math.imul(A,nt)|0)+Math.imul(S,rt)|0,s=s+Math.imul(S,nt)|0,n=n+Math.imul(w,st)|0,i=(i=i+Math.imul(w,ot)|0)+Math.imul(E,st)|0,s=s+Math.imul(E,ot)|0,n=n+Math.imul(y,ht)|0,i=(i=i+Math.imul(y,lt)|0)+Math.imul(v,ht)|0,s=s+Math.imul(v,lt)|0,n=n+Math.imul(p,ft)|0,i=(i=i+Math.imul(p,ct)|0)+Math.imul(m,ft)|0,s=s+Math.imul(m,ct)|0;var Mt=(l+(n=n+Math.imul(f,pt)|0)|0)+((8191&(i=(i=i+Math.imul(f,mt)|0)+Math.imul(c,pt)|0))<<13)|0;l=((s=s+Math.imul(c,mt)|0)+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,n=Math.imul(L,K),i=(i=Math.imul(L,G))+Math.imul(U,K)|0,s=Math.imul(U,G),n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(F,V)|0,s=s+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,s=s+Math.imul(C,$)|0,n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,tt)|0)+Math.imul(N,Y)|0,s=s+Math.imul(N,tt)|0,n=n+Math.imul(k,rt)|0,i=(i=i+Math.imul(k,nt)|0)+Math.imul(P,rt)|0,s=s+Math.imul(P,nt)|0,n=n+Math.imul(A,st)|0,i=(i=i+Math.imul(A,ot)|0)+Math.imul(S,st)|0,s=s+Math.imul(S,ot)|0,n=n+Math.imul(w,ht)|0,i=(i=i+Math.imul(w,lt)|0)+Math.imul(E,ht)|0,s=s+Math.imul(E,lt)|0,n=n+Math.imul(y,ft)|0,i=(i=i+Math.imul(y,ct)|0)+Math.imul(v,ft)|0,s=s+Math.imul(v,ct)|0;var kt=(l+(n=n+Math.imul(p,pt)|0)|0)+((8191&(i=(i=i+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;l=((s=s+Math.imul(m,mt)|0)+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,n=Math.imul(L,V),i=(i=Math.imul(L,J))+Math.imul(U,V)|0,s=Math.imul(U,J),n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(F,X)|0,s=s+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,tt)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,tt)|0,n=n+Math.imul(T,rt)|0,i=(i=i+Math.imul(T,nt)|0)+Math.imul(N,rt)|0,s=s+Math.imul(N,nt)|0,n=n+Math.imul(k,st)|0,i=(i=i+Math.imul(k,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,n=n+Math.imul(A,ht)|0,i=(i=i+Math.imul(A,lt)|0)+Math.imul(S,ht)|0,s=s+Math.imul(S,lt)|0,n=n+Math.imul(w,ft)|0,i=(i=i+Math.imul(w,ct)|0)+Math.imul(E,ft)|0,s=s+Math.imul(E,ct)|0;var Pt=(l+(n=n+Math.imul(y,pt)|0)|0)+((8191&(i=(i=i+Math.imul(y,mt)|0)+Math.imul(v,pt)|0))<<13)|0;l=((s=s+Math.imul(v,mt)|0)+(i>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,n=Math.imul(L,X),i=(i=Math.imul(L,$))+Math.imul(U,X)|0,s=Math.imul(U,$),n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,tt)|0)+Math.imul(F,Y)|0,s=s+Math.imul(F,tt)|0,n=n+Math.imul(R,rt)|0,i=(i=i+Math.imul(R,nt)|0)+Math.imul(C,rt)|0,s=s+Math.imul(C,nt)|0,n=n+Math.imul(T,st)|0,i=(i=i+Math.imul(T,ot)|0)+Math.imul(N,st)|0,s=s+Math.imul(N,ot)|0,n=n+Math.imul(k,ht)|0,i=(i=i+Math.imul(k,lt)|0)+Math.imul(P,ht)|0,s=s+Math.imul(P,lt)|0,n=n+Math.imul(A,ft)|0,i=(i=i+Math.imul(A,ct)|0)+Math.imul(S,ft)|0,s=s+Math.imul(S,ct)|0;var xt=(l+(n=n+Math.imul(w,pt)|0)|0)+((8191&(i=(i=i+Math.imul(w,mt)|0)+Math.imul(E,pt)|0))<<13)|0;l=((s=s+Math.imul(E,mt)|0)+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,n=Math.imul(L,Y),i=(i=Math.imul(L,tt))+Math.imul(U,Y)|0,s=Math.imul(U,tt),n=n+Math.imul(O,rt)|0,i=(i=i+Math.imul(O,nt)|0)+Math.imul(F,rt)|0,s=s+Math.imul(F,nt)|0,n=n+Math.imul(R,st)|0,i=(i=i+Math.imul(R,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,n=n+Math.imul(T,ht)|0,i=(i=i+Math.imul(T,lt)|0)+Math.imul(N,ht)|0,s=s+Math.imul(N,lt)|0,n=n+Math.imul(k,ft)|0,i=(i=i+Math.imul(k,ct)|0)+Math.imul(P,ft)|0,s=s+Math.imul(P,ct)|0;var Tt=(l+(n=n+Math.imul(A,pt)|0)|0)+((8191&(i=(i=i+Math.imul(A,mt)|0)+Math.imul(S,pt)|0))<<13)|0;l=((s=s+Math.imul(S,mt)|0)+(i>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,n=Math.imul(L,rt),i=(i=Math.imul(L,nt))+Math.imul(U,rt)|0,s=Math.imul(U,nt),n=n+Math.imul(O,st)|0,i=(i=i+Math.imul(O,ot)|0)+Math.imul(F,st)|0,s=s+Math.imul(F,ot)|0,n=n+Math.imul(R,ht)|0,i=(i=i+Math.imul(R,lt)|0)+Math.imul(C,ht)|0,s=s+Math.imul(C,lt)|0,n=n+Math.imul(T,ft)|0,i=(i=i+Math.imul(T,ct)|0)+Math.imul(N,ft)|0,s=s+Math.imul(N,ct)|0;var Nt=(l+(n=n+Math.imul(k,pt)|0)|0)+((8191&(i=(i=i+Math.imul(k,mt)|0)+Math.imul(P,pt)|0))<<13)|0;l=((s=s+Math.imul(P,mt)|0)+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,n=Math.imul(L,st),i=(i=Math.imul(L,ot))+Math.imul(U,st)|0,s=Math.imul(U,ot),n=n+Math.imul(O,ht)|0,i=(i=i+Math.imul(O,lt)|0)+Math.imul(F,ht)|0,s=s+Math.imul(F,lt)|0,n=n+Math.imul(R,ft)|0,i=(i=i+Math.imul(R,ct)|0)+Math.imul(C,ft)|0,s=s+Math.imul(C,ct)|0;var It=(l+(n=n+Math.imul(T,pt)|0)|0)+((8191&(i=(i=i+Math.imul(T,mt)|0)+Math.imul(N,pt)|0))<<13)|0;l=((s=s+Math.imul(N,mt)|0)+(i>>>13)|0)+(It>>>26)|0,It&=67108863,n=Math.imul(L,ht),i=(i=Math.imul(L,lt))+Math.imul(U,ht)|0,s=Math.imul(U,lt),n=n+Math.imul(O,ft)|0,i=(i=i+Math.imul(O,ct)|0)+Math.imul(F,ft)|0,s=s+Math.imul(F,ct)|0;var Rt=(l+(n=n+Math.imul(R,pt)|0)|0)+((8191&(i=(i=i+Math.imul(R,mt)|0)+Math.imul(C,pt)|0))<<13)|0;l=((s=s+Math.imul(C,mt)|0)+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,n=Math.imul(L,ft),i=(i=Math.imul(L,ct))+Math.imul(U,ft)|0,s=Math.imul(U,ct);var Ct=(l+(n=n+Math.imul(O,pt)|0)|0)+((8191&(i=(i=i+Math.imul(O,mt)|0)+Math.imul(F,pt)|0))<<13)|0;l=((s=s+Math.imul(F,mt)|0)+(i>>>13)|0)+(Ct>>>26)|0,Ct&=67108863;var Bt=(l+(n=Math.imul(L,pt))|0)+((8191&(i=(i=Math.imul(L,mt))+Math.imul(U,pt)|0))<<13)|0;return l=((s=Math.imul(U,mt))+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h[0]=gt,h[1]=yt,h[2]=vt,h[3]=bt,h[4]=wt,h[5]=Et,h[6]=_t,h[7]=At,h[8]=St,h[9]=Mt,h[10]=kt,h[11]=Pt,h[12]=xt,h[13]=Tt,h[14]=Nt,h[15]=It,h[16]=Rt,h[17]=Ct,h[18]=Bt,0!==l&&(h[19]=l,r.length++),r};function p(t,e,r){return(new m).mulp(t,e,r)}function m(t,e){this.x=t,this.y=e}Math.imul||(d=c),s.prototype.mulTo=function(t,e){var r=this.length+t.length;return 10===this.length&&10===t.length?d(this,t,e):r<63?c(this,t,e):r<1024?function(t,e,r){r.negative=e.negative^t.negative,r.length=t.length+e.length;for(var n=0,i=0,s=0;s>>26)|0)>>>26,o&=67108863}r.words[s]=a,n=o,o=i}return 0!==n?r.words[s]=n:r.length--,r.strip()}(this,t,e):p(this,t,e)},m.prototype.makeRBT=function(t){for(var e=new Array(t),r=s.prototype._countBits(t)-1,n=0;n>=1;return n},m.prototype.permute=function(t,e,r,n,i,s){for(var o=0;o>>=1)i++;return 1<>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*e;o>=26,e+=i/67108864|0,e+=s>>>26,this.words[n]=67108863&s}return 0!==e&&(this.words[n]=e,this.length++),this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),r=0;r>>i}return e}(t);if(0===e.length)return new s(1);for(var r=this,n=0;n=0);var e,n=t%26,i=(t-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(e=0;e>>26-n}o&&(this.words[e]=o,this.length++)}if(0!==i){for(e=this.length-1;e>=0;e--)this.words[e+i]=this.words[e];for(e=0;e=0),i=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<o)for(this.length-=o,l=0;l=0&&(0!==u||l>=i);l--){var f=0|this.words[l];this.words[l]=u<<26-s|f>>>s,u=f&a}return h&&0!==u&&(h.words[h.length++]=u),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},s.prototype.ishrn=function(t,e,n){return r(0===this.negative),this.iushrn(t,e,n)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){r("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,i=1<=0);var e=t%26,n=(t-e)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var i=67108863^67108863>>>e<=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(r("number"==typeof t),r(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e>26)-(h/67108864|0),this.words[i+n]=67108863&s}for(;i>26,this.words[i+n]=67108863&s;if(0===a)return this.strip();for(r(-1===a),a=0,i=0;i>26,this.words[i]=67108863&s;return this.negative=1,this.strip()},s.prototype._wordDiv=function(t,e){var r=(this.length,t.length),n=this.clone(),i=t,o=0|i.words[i.length-1];0!==(r=26-this._countBits(o))&&(i=i.ushln(r),n.iushln(r),o=0|i.words[i.length-1]);var a,h=n.length-i.length;if("mod"!==e){(a=new s(null)).length=h+1,a.words=new Array(a.length);for(var l=0;l=0;f--){var c=67108864*(0|n.words[i.length+f])+(0|n.words[i.length+f-1]);for(c=Math.min(c/o|0,67108863),n._ishlnsubmul(i,c,f);0!==n.negative;)c--,n.negative=0,n._ishlnsubmul(i,1,f),n.isZero()||(n.negative^=1);a&&(a.words[f]=c)}return a&&a.strip(),n.strip(),"div"!==e&&0!==r&&n.iushrn(r),{div:a||null,mod:n}},s.prototype.divmod=function(t,e,n){return r(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(i=a.div.neg()),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(t)),{div:i,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(i=a.div.neg()),{div:i,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modn(t.words[0]))}:this._wordDiv(t,e);var i,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var r=0!==e.div.negative?e.mod.isub(t):e.mod,n=t.ushrn(1),i=t.andln(1),s=r.cmp(n);return s<0||1===i&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modn=function(t){r(t<=67108863);for(var e=(1<<26)%t,n=0,i=this.length-1;i>=0;i--)n=(e*n+(0|this.words[i]))%t;return n},s.prototype.idivn=function(t){r(t<=67108863);for(var e=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*e;this.words[n]=i/t|0,e=i%t}return this.strip()},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i=new s(1),o=new s(0),a=new s(0),h=new s(1),l=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++l;for(var u=n.clone(),f=e.clone();!e.isZero();){for(var c=0,d=1;0==(e.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(e.iushrn(c);c-- >0;)(i.isOdd()||o.isOdd())&&(i.iadd(u),o.isub(f)),i.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||h.isOdd())&&(a.iadd(u),h.isub(f)),a.iushrn(1),h.iushrn(1);e.cmp(n)>=0?(e.isub(n),i.isub(a),o.isub(h)):(n.isub(e),a.isub(i),h.isub(o))}return{a:a,b:h,gcd:n.iushln(l)}},s.prototype._invmp=function(t){r(0===t.negative),r(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var i,o=new s(1),a=new s(0),h=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var l=0,u=1;0==(e.words[0]&u)&&l<26;++l,u<<=1);if(l>0)for(e.iushrn(l);l-- >0;)o.isOdd()&&o.iadd(h),o.iushrn(1);for(var f=0,c=1;0==(n.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(n.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(h),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a)):(n.isub(e),a.isub(o))}return(i=0===e.cmpn(1)?o:a).cmpn(0)<0&&i.iadd(t),i},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),r=t.clone();e.negative=0,r.negative=0;for(var n=0;e.isEven()&&r.isEven();n++)e.iushrn(1),r.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=e.cmp(r);if(i<0){var s=e;e=r,r=s}else if(0===i||0===r.cmpn(1))break;e.isub(r)}return r.iushln(n)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){r("number"==typeof t);var e=t%26,n=(t-e)/26,i=1<>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)e=1;else{n&&(t=-t),r(t<=67108863,"Number is too big");var i=0|this.words[0];e=i===t?0:it.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|t.words[r];if(n!==i){ni&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new _(t)},s.prototype.toRed=function(t){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return r(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return r(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var g={k256:null,p224:null,p192:null,p25519:null};function y(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else r(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function A(t){_.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},y.prototype.ireduce=function(t){var e,r=t;do{this.split(r,this.tmp),e=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(e>this.n);var n=e0?r.isub(this.p):r.strip(),r},y.prototype.split=function(t,e){t.iushrn(this.n,0,e)},y.prototype.imulK=function(t){return t.imul(this.k)},n(v,y),v.prototype.split=function(t,e){for(var r=Math.min(t.length,9),n=0;n>>22,i=s}i>>>=22,t.words[n-10]=i,0===i&&t.length>10?t.length-=10:t.length-=9},v.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,r=0;r>>=26,t.words[r]=i,e=n}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(g[t])return g[t];var e;if("k256"===t)e=new v;else if("p224"===t)e=new b;else if("p192"===t)e=new w;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new E}return g[t]=e,e},_.prototype._verify1=function(t){r(0===t.negative,"red works only with positives"),r(t.red,"red works only with red numbers")},_.prototype._verify2=function(t,e){r(0==(t.negative|e.negative),"red works only with positives"),r(t.red&&t.red===e.red,"red works only with red numbers")},_.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):t.umod(this.m)._forceRed(this)},_.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},_.prototype.add=function(t,e){this._verify2(t,e);var r=t.add(e);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(t,e){this._verify2(t,e);var r=t.iadd(e);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(t,e){this._verify2(t,e);var r=t.sub(e);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(t,e){this._verify2(t,e);var r=t.isub(e);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},_.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},_.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},_.prototype.isqr=function(t){return this.imul(t,t.clone())},_.prototype.sqr=function(t){return this.mul(t,t)},_.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(r(e%2==1),3===e){var n=this.m.add(new s(1)).iushrn(2);return this.pow(t,n)}for(var i=this.m.subn(1),o=0;!i.isZero()&&0===i.andln(1);)o++,i.iushrn(1);r(!i.isZero());var a=new s(1).toRed(this),h=a.redNeg(),l=this.m.subn(1).iushrn(1),u=this.m.bitLength();for(u=new s(2*u*u).toRed(this);0!==this.pow(u,l).cmp(h);)u.redIAdd(h);for(var f=this.pow(u,i),c=this.pow(t,i.addn(1).iushrn(1)),d=this.pow(t,i),p=o;0!==d.cmp(a);){for(var m=d,g=0;0!==m.cmp(a);g++)m=m.redSqr();r(g=0;n--){for(var l=e.words[n],u=h-1;u>=0;u--){var f=l>>u&1;i!==r[0]&&(i=this.sqr(i)),0!==f||0!==o?(o<<=1,o|=f,(4===++a||0===n&&0===u)&&(i=this.mul(i,r[o]),a=0,o=0)):a=0}h=26}return i},_.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},_.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new A(t)},n(A,_),A.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},A.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},A.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var r=t.imul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),s=i;return i.cmp(this.m)>=0?s=i.isub(this.m):i.cmpn(0)<0&&(s=i.iadd(this.m)),s._forceRed(this)},A.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var r=t.mul(e),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),o=s.BN;const a="logger/5.0.0-beta.128";let h=!1,l=!1;const u={debug:1,default:2,info:2,warn:3,error:4,off:5};let f=u.default,c=null;let d=function(){try{let t=[];if(["NFD","NFC","NFKD","NFKC"].forEach(e=>{try{if("test"!=="test".normalize(e))throw new Error("bad normalize")}catch(r){t.push(e)}}),t.length)throw new Error("missing "+t.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(t){return t.message}return null}();class p{constructor(t){Object.defineProperty(this,"version",{enumerable:!0,value:t,writable:!1})}setLogLevel(t){let e=u[t];null!=e?f=e:this.warn("invliad log level - "+t)}_log(t,e){f>u[t]||console.log.apply(console,e)}debug(...t){this._log(p.levels.DEBUG,t)}info(...t){this._log(p.levels.INFO,t)}warn(...t){this._log(p.levels.WARNING,t)}makeError(t,e,r){if(l)return new Error("unknown error");e||(e=p.errors.UNKNOWN_ERROR),r||(r={});let n=[];Object.keys(r).forEach(t=>{try{n.push(t+"="+JSON.stringify(r[t]))}catch(e){n.push(t+"="+JSON.stringify(r[t].toString()))}}),n.push("version="+this.version);let i=t;n.length&&(t+=" ("+n.join(", ")+")");let s=new Error(t);return s.reason=i,s.code=e,Object.keys(r).forEach(function(t){s[t]=r[t]}),s}throwError(t,e,r){throw this.makeError(t,e,r)}throwArgumentError(t,e,r){return this.throwError(t,p.errors.INVALID_ARGUMENT,{argument:e,value:r})}checkNormalize(t){null==t&&(t="platform missing String.prototype.normalize"),d&&this.throwError("platform missing String.prototype.normalize",p.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:d})}checkSafeUint53(t,e){"number"==typeof t&&(null==e&&(e="value not safe"),(t<0||t>=9007199254740991)&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(e,p.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))}checkArgumentCount(t,e,r){r=r?": "+r:"",te&&this.throwError("too many arguments"+r,p.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:e})}checkNew(t,e){t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}checkAbstract(t,e){t===e?this.throwError("cannot instantiate abstract class "+JSON.stringify(e.name)+" directly; use a sub-class",p.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",p.errors.MISSING_NEW,{name:e.name})}static globalLogger(){return c||(c=new p(a)),c}static setCensorship(t,e){if(h){if(!t)return;this.globalLogger().throwError("error censorship permanent",p.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}l=!!t,h=!!e}}p.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},p.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"};var m=Object.freeze({Logger:p});const g=new p("bytes/5.0.0-beta.128");function y(t){return!!t.toHexString}function v(t){return t.slice?t:(t.slice=function(){let e=Array.prototype.slice.call(arguments);return v(new Uint8Array(Array.prototype.slice.apply(t,e)))},t)}function b(t){return M(t)&&!(t.length%2)||w(t)}function w(t){if(null==t)return!1;if(t.constructor===Uint8Array)return!0;if("string"==typeof t)return!1;if(null==t.length)return!1;for(let e=0;e=256||r%1)return!1}return!0}function E(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid arrayify value");let e=[];for(;t;)e.unshift(255&t),t/=256;return 0===e.length&&e.push(0),v(new Uint8Array(e))}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t)&&(t=t.toHexString()),M(t)){let r=t.substring(2);!e.allowOddLength&&r.length%2&&g.throwArgumentError("hex data is odd-length","value",t);let n=[];for(let t=0;tE(t)),r=e.reduce((t,e)=>t+e.length,0),n=new Uint8Array(r);return e.reduce((t,e)=>(n.set(e,t),t+e.length),0),v(n)}function A(t){let e=E(t);if(0===e.length)return e;let r=0;for(;re&&g.throwArgumentError("value out of range","value",arguments[0]);let r=new Uint8Array(e);return r.set(t,e-t.length),v(r)}function M(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/))&&(!e||t.length===2+2*e)}const k="0123456789abcdef";function P(t,e){if(e||(e={}),"number"==typeof t){g.checkSafeUint53(t,"invalid hexlify value");let e="";for(;t;)e=k[15&t]+e,t=Math.floor(t/16);return e.length?(e.length%2&&(e="0"+e),"0x"+e):"0x00"}if(e.allowMissingPrefix&&"string"==typeof t&&"0x"!==t.substring(0,2)&&(t="0x"+t),y(t))return t.toHexString();if(M(t))return!e.allowOddLength&&t.length%2&&g.throwArgumentError("hex data is odd-length","value",t),t.toLowerCase();if(w(t)){let e="0x";for(let r=0;r>4]+k[15&n]}return e}return g.throwArgumentError("invalid hexlify value","value",t)}function x(t){if("string"!=typeof t)t=P(t);else if(!M(t)||t.length%2)return null;return(t.length-2)/2}function T(t,e,r){return"string"!=typeof t?t=P(t):(!M(t)||t.length%2)&&g.throwArgumentError("invalid hexData","value",t),e=2+2*e,null!=r?"0x"+t.substring(e,2+2*r):"0x"+t.substring(e)}function N(t){let e=I(P(t,{allowOddLength:!0}));return"0x"===e?"0x0":e}function I(t){"string"!=typeof t&&(t=P(t)),M(t)||g.throwArgumentError("invalid hex string","value",t),t=t.substring(2);let e=0;for(;e2*e+2&&g.throwArgumentError("value out of range","value",arguments[1]);t.length<2*e+2;)t="0x0"+t.substring(2);return t}function C(t){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(b(t)){let r=E(t);65!==r.length&&g.throwArgumentError("invalid signature string; must be 65 bytes","signature",t),e.r=P(r.slice(0,32)),e.s=P(r.slice(32,64)),e.v=r[64],27!==e.v&&28!==e.v&&(e.v=27+e.v%2),e.recoveryParam=e.v-27,e.recoveryParam&&(r[32]|=128),e._vs=P(r.slice(32,64))}else{if(e.r=t.r,e.s=t.s,e.v=t.v,e.recoveryParam=t.recoveryParam,e._vs=t._vs,null!=e.v&&27!=e.v&&28!=e.v&&(e.v=27+e.v%2),null==e.recoveryParam&&null!=e.v?e.recoveryParam=1-e.v%2:null!=e.recoveryParam&&null==e.v?e.v=27+e.recoveryParam:null!=e.recoveryParam&&null!=e.v&&e.v!==27+e.recoveryParam&&g.throwArgumentError("signature v mismatch recoveryParam","signature",t),null!=e.r&&(e.r=R(e.r,32)),null!=e.s&&(e.s=R(e.s,32)),null!=e._vs){e._vs=R(e._vs,32),e._vs.length>66&&g.throwArgumentError("signature _vs overflow","signature",t);let r=E(e._vs),n=r[0]>=128?1:0,i=27+e.recoveryParam;r[0]&=127;let s=P(r);null==e.s?e.s=s:e.s!==s&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==e.v?e.v=i:e.v!==i&&g.throwArgumentError("signature v mismatch _vs","signature",t),null==n?e.recoveryParam=n:e.recoveryParam!==n&&g.throwArgumentError("signature recoveryParam mismatch _vs","signature",t)}if(null==e.v&&null==e.recoveryParam&&g.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",t),27!==e.v&&28!==e.v&&g.throwArgumentError("signature v not canonical","signature",t),(e.r.length>66||e.s.length>66)&&g.throwArgumentError("signature overflow r or s","signature",t),null==e._vs){let r=E(e.s);r[0]>=128&&g.throwArgumentError("signature s out of range","signature",t),e.recoveryParam&&(r[0]|=128),e._vs=P(r)}}return e}function B(t){return P(_([(t=C(t)).r,t.s,t.recoveryParam?"0x1c":"0x1b"]))}var O=Object.freeze({isBytesLike:b,isBytes:w,arrayify:E,concat:_,stripZeros:A,zeroPad:S,isHexString:M,hexlify:P,hexDataLength:x,hexDataSlice:T,hexConcat:function(t){let e="0x";return t.forEach(t=>{e+=P(t).substring(2)}),e},hexValue:N,hexStripZeros:I,hexZeroPad:R,splitSignature:C,joinSignature:B});const F=new p("bignumber/5.0.0-beta.129"),D={},L=9007199254740991;class U{constructor(t,e){F.checkNew(new.target,U),t!==D&&F.throwError("cannot call consturtor directly; use BigNumber.from",p.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=e,this._isBigNumber=!0,Object.freeze(this)}fromTwos(t){return j(H(this).fromTwos(t))}toTwos(t){return j(H(this).toTwos(t))}abs(){return"-"===this._hex[0]?U.from(this._hex.substring(1)):this}add(t){return j(H(this).add(H(t)))}sub(t){return j(H(this).sub(H(t)))}div(t){return U.from(t).isZero()&&q("division by zero","div"),j(H(this).div(H(t)))}mul(t){return j(H(this).mul(H(t)))}mod(t){return j(H(this).mod(H(t)))}pow(t){return j(H(this).pow(H(t)))}maskn(t){return j(H(this).maskn(t))}eq(t){return H(this).eq(H(t))}lt(t){return H(this).lt(H(t))}lte(t){return H(this).lte(H(t))}gt(t){return H(this).gt(H(t))}gte(t){return H(this).gte(H(t))}isZero(){return H(this).isZero()}toNumber(){try{return H(this).toNumber()}catch(t){q("overflow","toNumber",this.toString())}return null}toString(){return 0!==arguments.length&&F.throwError("bigNumber.toString does not accept parameters",p.errors.UNEXPECTED_ARGUMENT,{}),H(this).toString(10)}toHexString(){return this._hex}static from(t){return t instanceof U?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new U(D,z(t)):t.match(/^-?[0-9]+$/)?new U(D,z(new o(t))):F.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&q("underflow","BigNumber.from",t),(t>=L||t<=-L)&&q("overflow","BigNumber.from",t),U.from(String(t))):"bigint"==typeof t?U.from(t.toString()):w(t)?U.from(P(t)):t._hex&&M(t._hex)?U.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?U.from(t):F.throwArgumentError("invalid BigNumber value","value",t)}static isBigNumber(t){return!(!t||!t._isBigNumber)}}function z(t){if("string"!=typeof t)return z(t.toString(16));if("-"===t[0])return"-"===(t=t.substring(1))[0]&&F.throwArgumentError("invalid hex","value",t),"0x00"===(t=z(t))?t:"-"+t;if("0x"!==t.substring(0,2)&&(t="0x"+t),"0x"===t)return"0x00";for(t.length%2&&(t="0x0"+t.substring(2));t.length>4&&"0x00"===t.substring(0,4);)t="0x"+t.substring(4);return t}function j(t){return U.from(z(t))}function H(t){let e=U.from(t).toHexString();return"-"===e[0]?new o("-"+e.substring(3),16):new o(e.substring(2),16)}function q(t,e,r){let n={fault:t,operation:e};return null!=r&&(n.value=r),F.throwError(t,p.errors.NUMERIC_FAULT,n)}const K=new p("bignumber/5.0.0-beta.129"),G={},W=U.from(0),V=U.from(-1);function J(t,e,r,n){let i={fault:e,operation:r};return void 0!==n&&(i.value=n),K.throwError(t,p.errors.NUMERIC_FAULT,i)}let Z="0";for(;Z.length<256;)Z+=Z;function X(t){if("number"!=typeof t)try{t=U.from(t).toNumber()}catch(t){}return"number"==typeof t&&t>=0&&t<=256&&!(t%1)?"1"+Z.substring(0,t):K.throwArgumentError("invalid decimal size","decimals",t)}function $(t,e){null==e&&(e=0);let r=X(e),n=(t=U.from(t)).lt(W);n&&(t=t.mul(V));let i=t.mod(r).toString();for(;i.length2&&K.throwArgumentError("too many decimal points","value",t);let s=i[0],o=i[1];for(s||(s="0"),o||(o="0"),o.length>r.length-1&&J("fractional component exceeds decimals","underflow","parseFixed");o.lengthnull==t[e]?n:(typeof t[e]!==r&&K.throwArgumentError("invalid fixed format ("+e+" not "+r+")","format."+e,t[e]),t[e]);e=i("signed","boolean",e),r=i("width","number",r),n=i("decimals","number",n)}return r%8&&K.throwArgumentError("invalid fixed format width (not byte aligned)","format.width",r),n>80&&K.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",n),new Y(G,e,r,n)}}class tt{constructor(t,e,r,n){K.checkNew(new.target,tt),this.format=n,this._hex=e,this._value=r,this._isFixedNumber=!0,Object.freeze(this)}_checkFormat(t){this.format.name!==t.format.name&&K.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",t)}addUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.add(r),this.format.decimals,this.format)}subUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.sub(r),this.format.decimals,this.format)}mulUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(r).div(this.format._multiplier),this.format.decimals,this.format)}divUnsafe(t){this._checkFormat(t);let e=Q(this._value,this.format.decimals),r=Q(t._value,t.format.decimals);return tt.fromValue(e.mul(this.format._multiplier).div(r),this.format.decimals,this.format)}round(t){null==t&&(t=0),(t<0||t>80||t%1)&&K.throwArgumentError("invalid decimal cound","decimals",t);let e=this.toString().split(".");if(e[1].length<=t)return this;let r="0."+Z.substring(0,t)+"5";return e=this.addUnsafe(tt.fromString(r,this.format))._value.split("."),tt.fromString(e[0]+"."+e[1].substring(0,t))}toString(){return this._value}toHexString(t){if(null==t)return this._hex;return t%8&&K.throwArgumentError("invalid byte width","width",t),R(U.from(this._hex).fromTwos(this.format.width).toTwos(t).toHexString(),t/8)}toUnsafeFloat(){return parseFloat(this.toString())}toFormat(t){return tt.fromString(this._value,t)}static fromValue(t,e,r){return null!=r||null==e||function(t){return null!=t&&(U.isBigNumber(t)||"number"==typeof t&&t%1==0||"string"==typeof t&&!!t.match(/^-?[0-9]+$/)||M(t)||"bigint"==typeof t||w(t))}(e)||(r=e,e=null),null==e&&(e=0),null==r&&(r="fixed"),tt.fromString($(t,e),Y.from(r))}static fromString(t,e){null==e&&(e="fixed");let r=Y.from(e),n=Q(t,r.decimals);!r.signed&&n.lt(W)&&J("unsigned value cannot be negative","overflow","value",t);let i=null;i=r.signed?n.toTwos(r.width).toHexString():R(i=n.toHexString(),r.width/8);let s=$(n,r.decimals);return new tt(G,i,s,r)}static fromBytes(t,e){null==e&&(e="fixed");let r=Y.from(e);if(E(t).length>r.width/8)throw new Error("overflow");let n=U.from(t);r.signed&&(n=n.fromTwos(r.width));let i=n.toTwos((r.signed?0:1)+r.width).toHexString(),s=$(n,r.decimals);return new tt(G,i,s,r)}static from(t,e){if("string"==typeof t)return tt.fromString(t,e);if(w(t))return tt.fromBytes(t,e);try{return tt.fromValue(t,0,e)}catch(t){if(t.code!==p.errors.INVALID_ARGUMENT)throw t}return K.throwArgumentError("invalid FixedNumber value","value",t)}static isFixedNumber(t){return!(!t||!t._isFixedNumber)}}const et=new p("properties/5.0.0-beta.130");function rt(t,e,r){Object.defineProperty(t,e,{enumerable:!0,value:r,writable:!1})}function nt(t,e){for(let r=0;r<32;r++){if(t[e])return t[e];if(!t.prototype||"object"!=typeof t.prototype)break;t=Object.getPrototypeOf(t.prototype).constructor}return null}function it(t){let e=Object.keys(t).map(e=>{let r=t[e];return r instanceof Promise?r.then(t=>({key:e,value:t})):Promise.resolve({key:e,value:r})});return Promise.all(e).then(t=>{return t.reduce((t,e)=>(t[e.key]=e.value,t),{})})}function st(t,e){t&&"object"==typeof t||et.throwArgumentError("invalid object","object",t),Object.keys(t).forEach(r=>{e[r]||et.throwArgumentError("invalid object key - "+r,"transaction:"+r,t)})}function ot(t){let e={};for(let r in t)e[r]=t[r];return e}let at={bigint:!0,boolean:!0,number:!0,string:!0};function ht(t){if(null==t||at[typeof t])return t;if(Array.isArray(t))return Object.freeze(t.map(t=>ht(t)));if("object"==typeof t){if(Object.isFrozen(t))return t;let e={};for(let r in t){let n=t[r];void 0!==n&&rt(e,r,ht(n))}return e}if("function"==typeof t)return t;throw new Error("Cannot deepCopy "+typeof t)}class lt{constructor(t){for(let e in t)this[e]=ht(t[e]);Object.freeze(this)}}var ut=Object.freeze({defineReadOnly:rt,getStatic:nt,resolveProperties:it,checkProperties:st,shallowCopy:ot,deepCopy:ht,Description:lt});const ft="abi/5.0.0-beta.136",ct=new p(ft),dt={};let pt={calldata:!0,memory:!0,storage:!0};function mt(t,e){if("bytes"===t||"string"===t){if(pt[e])return!0}else if("address"===t&&"payable"===e)return!0;return(pt[e]||"payable"===e)&&ct.throwArgumentError("invalid modifier","name",e),!1}function gt(t,e){for(let r in e)rt(t,r,e[r])}const yt=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"}),vt=new RegExp(/^(.*)\[([0-9]*)\]$/);class bt{constructor(t,e){if(t!==dt)throw new Error("use fromString");gt(this,e);let r=this.type.match(vt);gt(this,r?{arrayLength:parseInt(r[2]||"-1"),arrayChildren:bt.fromObject({type:r[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json){let e={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(e.indexed=this.indexed),this.components&&(e.components=this.components.map(e=>JSON.parse(e.format(t)))),JSON.stringify(e)}let e="";return"array"===this.baseType?(e+=this.arrayChildren.format(t),e+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(t!==yt.sighash&&(e+=this.type),e+="("+this.components.map(e=>e.format(t)).join(t===yt.full?", ":",")+")"):e+=this.type,t!==yt.sighash&&(!0===this.indexed&&(e+=" indexed"),t===yt.full&&this.name&&(e+=" "+this.name)),e}static from(t,e){return"string"==typeof t?bt.fromString(t,e):bt.fromObject(t)}static fromObject(t){return bt.isParamType(t)?t:new bt(dt,{name:t.name||null,type:xt(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(bt.fromObject):null})}static fromString(t,e){return function(t){return bt.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(t,e){let r=t;function n(t){throw new Error("unexpected character '"+r[t]+"' at position "+t+" in '"+r+"'")}function i(t){let r={type:"",name:"",parent:t,state:{allowType:!0}};return e&&(r.indexed=!1),r}t=t.replace(/\s/g," ");let s={type:"",name:"",state:{allowType:!0}},o=s;for(let r=0;rbt.fromString(t,e))}class Et{constructor(t,e){if(t!==dt)throw new Error("use a static from method");gt(this,e),this._isFragment=!0,Object.freeze(this)}static from(t){return Et.isFragment(t)?t:"string"==typeof t?Et.fromString(t):Et.fromObject(t)}static fromObject(t){return Et.isFragment(t)?t:"function"===t.type?Pt.fromObject(t):"event"===t.type?_t.fromObject(t):"constructor"===t.type?kt.fromObject(t):"fallback"===t.type?null:ct.throwArgumentError("invalid fragment object","value",t)}static fromString(t){if("event"===(t=(t=(t=t.replace(/\s/g," ")).replace(/\(/g," (").replace(/\)/g,") ").replace(/\s+/g," ")).trim()).split(" ")[0])return _t.fromString(t.substring(5).trim());if("function"===t.split(" ")[0])return Pt.fromString(t.substring(8).trim());if("constructor"===t.split("(")[0].trim())return kt.fromString(t.trim());throw new Error("unknown fragment")}static isFragment(t){return!(!t||!t._isFragment)}}class _t extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="event "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&this.anonymous&&(e+="anonymous "),e.trim()}static from(t){return"string"==typeof t?_t.fromString(t):_t.fromObject(t)}static fromObject(t){if(_t.isEventFragment(t))return t;if("event"!==t.type)throw new Error("invalid event object - "+t.type);return new _t(dt,{name:Nt(t.name),anonymous:t.anonymous,inputs:t.inputs?t.inputs.map(bt.fromObject):[],type:"event"})}static fromString(t){let e=t.match(It);if(!e)throw new Error("invalid event: "+t);let r=!1;return e[3].split(" ").forEach(t=>{switch(t.trim()){case"anonymous":r=!0;break;case"":break;default:ct.warn("unknown modifier: "+t)}}),_t.fromObject({name:e[1].trim(),anonymous:r,inputs:wt(e[2],!0),type:"event"})}static isEventFragment(t){return t&&t._isFragment&&"event"===t.type}}function At(t,e){e.gas=null;let r=t.split("@");if(1!==r.length){if(r.length>2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return e.gas=U.from(r[1]),r[0]}return t}function St(t,e){e.constant=!1,e.payable=!1,e.stateMutability="nonpayable",t.split(" ").forEach(t=>{switch(t.trim()){case"constant":e.constant=!0;break;case"payable":e.payable=!0,e.stateMutability="payable";break;case"pure":e.constant=!0,e.stateMutability="pure";break;case"view":e.constant=!0,e.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+t)}})}function Mt(t){let e={constant:!1,payable:!0,stateMutability:"payable"};if(null!=t.stateMutability){if(e.stateMutability=t.stateMutability,e.constant="view"===e.stateMutability||"pure"===e.stateMutability,null!=t.constant&&!!t.constant!==e.constant)throw new Error("cannot have constant function with mutability "+e.stateMutability);if(e.payable="payable"===e.stateMutability,null!=t.payable&&!!t.payable!==e.payable)throw new Error("cannot have payable function with mutability "+e.stateMutability)}else if(null!=t.payable){if(e.payable=!!t.payable,e.stateMutability=e.payable?"payable":"nonpayable",e.constant=!e.payable,null!=t.constant&&t.constant!==e.constant)throw new Error("cannot have constant payable function")}else null!=t.constant&&(e.constant=!!t.constant,e.payable=!e.constant,e.stateMutability=e.constant?"view":"payable");return e}class kt extends Et{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t)))});t===yt.sighash&&ct.throwError("cannot format a constructor for sighash",p.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});let e="constructor("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "),e.trim()}static from(t){return"string"==typeof t?kt.fromString(t):kt.fromObject(t)}static fromObject(t){if(kt.isConstructorFragment(t))return t;if("constructor"!==t.type)throw new Error("invalid constructor object - "+t.type);let e=Mt(t);if(e.constant)throw new Error("constructor cannot be constant");return new kt(dt,{type:t.type,inputs:t.inputs?t.inputs.map(bt.fromObject):[],payable:e.payable,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"constructor"},r=(t=At(t,e)).match(It);if(!r)throw new Error("invalid constructor: "+t);if("constructor"!==r[1].trim())throw new Error("invalid constructor");return e.inputs=wt(r[2].trim(),!1),St(r[3].trim(),e),kt.fromObject(e)}static isConstructorFragment(t){return t&&t._isFragment&&"constructor"===t.type}}class Pt extends kt{format(t){if(t||(t=yt.sighash),yt[t]||ct.throwArgumentError("invalid format type","format",t),t===yt.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(e=>JSON.parse(e.format(t))),ouputs:this.outputs.map(e=>JSON.parse(e.format(t)))});let e="";return t!==yt.sighash&&(e+="function "),e+=this.name+"("+this.inputs.map(e=>e.format(t)).join(t===yt.full?", ":",")+") ",t!==yt.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(e+=this.stateMutability+" "):this.constant&&(e+="view "),this.outputs&&this.outputs.length&&(e+="returns ("+this.outputs.map(e=>e.format(t)).join(", ")+") "),null!=this.gas&&(e+="@"+this.gas.toString()+" ")),e.trim()}static from(t){return"string"==typeof t?Pt.fromString(t):Pt.fromObject(t)}static fromObject(t){if(Pt.isFunctionFragment(t))return t;if("function"!==t.type)throw new Error("invalid function object - "+t.type);let e=Mt(t);return new Pt(dt,{type:t.type,name:Nt(t.name),constant:e.constant,inputs:t.inputs?t.inputs.map(bt.fromObject):[],outputs:t.outputs?t.outputs.map(bt.fromObject):[],payable:e.payable,stateMutability:e.stateMutability,gas:t.gas?U.from(t.gas):null})}static fromString(t){let e={type:"function"},r=(t=At(t,e)).split(" returns ");if(r.length>2)throw new Error("invalid function");let n=r[0].match(It);if(!n)throw new Error("invalid signature");if(e.name=n[1].trim(),!e.name.match(Tt))throw new Error("invalid identifier: '"+e.name+"'");if(e.inputs=wt(n[2],!1),St(n[3].trim(),e),r.length>1){let t=r[1].match(It);if(""!=t[1].trim()||""!=t[3].trim())throw new Error("unexpected tokens");e.outputs=wt(t[2],!1)}else e.outputs=[];return Pt.fromObject(e)}static isFunctionFragment(t){return t&&t._isFragment&&"function"===t.type}}function xt(t){return t.match(/^uint($|[^1-9])/)?t="uint256"+t.substring(4):t.match(/^int($|[^1-9])/)&&(t="int256"+t.substring(3)),t}const Tt=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function Nt(t){if(!t||!t.match(Tt))throw new Error("invalid identifier: '"+t+"'");return t}const It=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$");const Rt=new p(ft);class Ct{constructor(t,e,r,n){this.name=t,this.type=e,this.localName=r,this.dynamic=n}_throwError(t,e){Rt.throwArgumentError(t,this.localName,e)}}class Bt{constructor(t){rt(this,"wordSize",t||32),this._data=E([]),this._padding=new Uint8Array(t)}get data(){return P(this._data)}get length(){return this._data.length}_writeData(t){return this._data=_([this._data,t]),t.length}writeBytes(t){let e=E(t);return e.length%this.wordSize&&(e=_([e,this._padding.slice(e.length%this.wordSize)])),this._writeData(e)}_getValue(t){let e=E(U.from(t));return e.length>this.wordSize&&Rt.throwError("value out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:e.length}),e.length%this.wordSize&&(e=_([this._padding.slice(e.length%this.wordSize),e])),e}writeValue(t){return this._writeData(this._getValue(t))}writeUpdatableValue(){let t=this.length;return this.writeValue(0),e=>{this._data.set(this._getValue(e),t)}}}class Ot{constructor(t,e,r){rt(this,"_data",E(t)),rt(this,"wordSize",e||32),rt(this,"_coerceFunc",r),this._offset=0}get data(){return P(this._data)}get consumed(){return this._offset}static coerce(t,e){let r=t.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(e=e.toNumber()),e}coerce(t,e){return this._coerceFunc?this._coerceFunc(t,e):Ot.coerce(t,e)}_peekBytes(t,e){let r=Math.ceil(e/this.wordSize)*this.wordSize;return this._offset+r>this._data.length&&Rt.throwError("data out-of-bounds",p.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+r}),this._data.slice(this._offset,this._offset+r)}subReader(t){return new Ot(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)}readBytes(t){let e=this._peekBytes(0,t);return this._offset+=e.length,e.slice(0,t)}readValue(){return U.from(this.readBytes(this.wordSize))}}var Ft=r(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),s=[0,8,16,24],o=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],a=[224,256,384,512],h=["hex","buffer","arrayBuffer","array"],l=function(t,e,r){return function(n){return new w(t,e,t).update(n)[r]()}},u=function(t,e,r){return function(n,i){return new w(t,e,i).update(n)[r]()}},f=function(t,e){var r=l(t,e,"hex");r.create=function(){return new w(t,e,t)},r.update=function(t){return r.create().update(t)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(t){var e="string"!=typeof t;e&&t.constructor===ArrayBuffer&&(t=new Uint8Array(t));for(var r,n,i=t.length,o=this.blocks,a=this.byteCount,h=this.blockCount,l=0,u=this.s;l>2]|=t[l]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(o[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=a){for(this.start=r-a,this.block=o[h],r=0;r>2]|=this.padding[3&e],this.lastByteIndex===this.byteCount)for(t[0]=t[r],e=1;e>4&15]+i[15&t]+i[t>>12&15]+i[t>>8&15]+i[t>>20&15]+i[t>>16&15]+i[t>>28&15]+i[t>>24&15];a%e==0&&(E(r),o=0)}return s&&(t=r[o],s>0&&(h+=i[t>>4&15]+i[15&t]),s>1&&(h+=i[t>>12&15]+i[t>>8&15]),s>2&&(h+=i[t>>20&15]+i[t>>16&15])),h},w.prototype.arrayBuffer=function(){this.finalize();var t,e=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;t=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var h=new Uint32Array(t);o>8&255,h[t+2]=e>>16&255,h[t+3]=e>>24&255;a%r==0&&E(n)}return s&&(t=a<<2,e=n[o],s>0&&(h[t]=255&e),s>1&&(h[t+1]=e>>8&255),s>2&&(h[t+2]=e>>16&255)),h};var E=function(t){var e,r,n,i,s,a,h,l,u,f,c,d,p,m,g,y,v,b,w,E,_,A,S,M,k,P,x,T,N,I,R,C,B,O,F,D,L,U,z,j,H,q,K,G,W,V,J,Z,X,$,Q,Y,tt,et,rt,nt,it,st,ot,at,ht,lt,ut;for(n=0;n<48;n+=2)i=t[0]^t[10]^t[20]^t[30]^t[40],s=t[1]^t[11]^t[21]^t[31]^t[41],a=t[2]^t[12]^t[22]^t[32]^t[42],h=t[3]^t[13]^t[23]^t[33]^t[43],l=t[4]^t[14]^t[24]^t[34]^t[44],u=t[5]^t[15]^t[25]^t[35]^t[45],f=t[6]^t[16]^t[26]^t[36]^t[46],c=t[7]^t[17]^t[27]^t[37]^t[47],e=(d=t[8]^t[18]^t[28]^t[38]^t[48])^(a<<1|h>>>31),r=(p=t[9]^t[19]^t[29]^t[39]^t[49])^(h<<1|a>>>31),t[0]^=e,t[1]^=r,t[10]^=e,t[11]^=r,t[20]^=e,t[21]^=r,t[30]^=e,t[31]^=r,t[40]^=e,t[41]^=r,e=i^(l<<1|u>>>31),r=s^(u<<1|l>>>31),t[2]^=e,t[3]^=r,t[12]^=e,t[13]^=r,t[22]^=e,t[23]^=r,t[32]^=e,t[33]^=r,t[42]^=e,t[43]^=r,e=a^(f<<1|c>>>31),r=h^(c<<1|f>>>31),t[4]^=e,t[5]^=r,t[14]^=e,t[15]^=r,t[24]^=e,t[25]^=r,t[34]^=e,t[35]^=r,t[44]^=e,t[45]^=r,e=l^(d<<1|p>>>31),r=u^(p<<1|d>>>31),t[6]^=e,t[7]^=r,t[16]^=e,t[17]^=r,t[26]^=e,t[27]^=r,t[36]^=e,t[37]^=r,t[46]^=e,t[47]^=r,e=f^(i<<1|s>>>31),r=c^(s<<1|i>>>31),t[8]^=e,t[9]^=r,t[18]^=e,t[19]^=r,t[28]^=e,t[29]^=r,t[38]^=e,t[39]^=r,t[48]^=e,t[49]^=r,m=t[0],g=t[1],V=t[11]<<4|t[10]>>>28,J=t[10]<<4|t[11]>>>28,T=t[20]<<3|t[21]>>>29,N=t[21]<<3|t[20]>>>29,at=t[31]<<9|t[30]>>>23,ht=t[30]<<9|t[31]>>>23,q=t[40]<<18|t[41]>>>14,K=t[41]<<18|t[40]>>>14,O=t[2]<<1|t[3]>>>31,F=t[3]<<1|t[2]>>>31,y=t[13]<<12|t[12]>>>20,v=t[12]<<12|t[13]>>>20,Z=t[22]<<10|t[23]>>>22,X=t[23]<<10|t[22]>>>22,I=t[33]<<13|t[32]>>>19,R=t[32]<<13|t[33]>>>19,lt=t[42]<<2|t[43]>>>30,ut=t[43]<<2|t[42]>>>30,et=t[5]<<30|t[4]>>>2,rt=t[4]<<30|t[5]>>>2,D=t[14]<<6|t[15]>>>26,L=t[15]<<6|t[14]>>>26,b=t[25]<<11|t[24]>>>21,w=t[24]<<11|t[25]>>>21,$=t[34]<<15|t[35]>>>17,Q=t[35]<<15|t[34]>>>17,C=t[45]<<29|t[44]>>>3,B=t[44]<<29|t[45]>>>3,M=t[6]<<28|t[7]>>>4,k=t[7]<<28|t[6]>>>4,nt=t[17]<<23|t[16]>>>9,it=t[16]<<23|t[17]>>>9,U=t[26]<<25|t[27]>>>7,z=t[27]<<25|t[26]>>>7,E=t[36]<<21|t[37]>>>11,_=t[37]<<21|t[36]>>>11,Y=t[47]<<24|t[46]>>>8,tt=t[46]<<24|t[47]>>>8,G=t[8]<<27|t[9]>>>5,W=t[9]<<27|t[8]>>>5,P=t[18]<<20|t[19]>>>12,x=t[19]<<20|t[18]>>>12,st=t[29]<<7|t[28]>>>25,ot=t[28]<<7|t[29]>>>25,j=t[38]<<8|t[39]>>>24,H=t[39]<<8|t[38]>>>24,A=t[48]<<14|t[49]>>>18,S=t[49]<<14|t[48]>>>18,t[0]=m^~y&b,t[1]=g^~v&w,t[10]=M^~P&T,t[11]=k^~x&N,t[20]=O^~D&U,t[21]=F^~L&z,t[30]=G^~V&Z,t[31]=W^~J&X,t[40]=et^~nt&st,t[41]=rt^~it&ot,t[2]=y^~b&E,t[3]=v^~w&_,t[12]=P^~T&I,t[13]=x^~N&R,t[22]=D^~U&j,t[23]=L^~z&H,t[32]=V^~Z&$,t[33]=J^~X&Q,t[42]=nt^~st&at,t[43]=it^~ot&ht,t[4]=b^~E&A,t[5]=w^~_&S,t[14]=T^~I&C,t[15]=N^~R&B,t[24]=U^~j&q,t[25]=z^~H&K,t[34]=Z^~$&Y,t[35]=X^~Q&tt,t[44]=st^~at<,t[45]=ot^~ht&ut,t[6]=E^~A&m,t[7]=_^~S&g,t[16]=I^~C&M,t[17]=R^~B&k,t[26]=j^~q&O,t[27]=H^~K&F,t[36]=$^~Y&G,t[37]=Q^~tt&W,t[46]=at^~lt&et,t[47]=ht^~ut&rt,t[8]=A^~m&y,t[9]=S^~g&v,t[18]=C^~M&P,t[19]=B^~k&x,t[28]=q^~O&D,t[29]=K^~F&L,t[38]=Y^~G&V,t[39]=tt^~W&J,t[48]=lt^~et&nt,t[49]=ut^~rt&it,t[0]^=o[n],t[1]^=o[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return e}function Ut(t,e,r){let n=0;for(let i=0;ie+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function Ht(t,e){if(0===t.length)throw new Error("invalid rlp data");if(t[e]>=248){let r=t[e]-247;if(e+1+r>t.length)throw new Error("too short");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("to short");return jt(t,e,e+1+r,r+n)}if(t[e]>=192){let r=t[e]-192;if(e+1+r>t.length)throw new Error("invalid rlp data");return jt(t,e,e+1,r)}if(t[e]>=184){let r=t[e]-183;if(e+1+r>t.length)throw new Error("invalid rlp data");let n=Ut(t,e+1,r);if(e+1+r+n>t.length)throw new Error("invalid rlp data");return{consumed:1+r+n,result:P(t.slice(e+1+r,e+1+r+n))}}if(t[e]>=128){let r=t[e]-128;if(e+1+r>t.length)throw new Error("invlaid rlp data");return{consumed:1+r,result:P(t.slice(e+1,e+1+r))}}return{consumed:1,result:P(t[e])}}function qt(t){let e=E(t),r=Ht(e,0);if(r.consumed!==e.length)throw new Error("invalid rlp data");return r.result}var Kt=Object.freeze({encode:zt,decode:qt});const Gt=new p("address/5.0.0-beta.127");function Wt(t){M(t,20)||Gt.throwArgumentError("invalid address","address",t);let e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);r=E(Dt(r));for(let t=0;t<40;t+=2)r[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&r[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}let Vt={};for(let t=0;t<10;t++)Vt[String(t)]=String(t);for(let t=0;t<26;t++)Vt[String.fromCharCode(65+t)]=String(10+t);let Jt=Math.floor((Zt=9007199254740991,Math.log10?Math.log10(Zt):Math.log(Zt)/Math.LN10));var Zt;function Xt(t){t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00";let e="";for(t.split("").forEach(function(t){e+=Vt[t]});e.length>=Jt;){let t=e.substring(0,Jt);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}function $t(t){let e=null;if("string"!=typeof t&&Gt.throwArgumentError("invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==t.substring(0,2)&&(t="0x"+t),e=Wt(t),t.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==t&&Gt.throwArgumentError("bad address checksum","address",t);else if(t.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(t.substring(2,4)!==Xt(t)&&Gt.throwArgumentError("bad icap checksum","address",t),e=new o(t.substring(4),36).toString(16);e.length<40;)e="0"+e;e=Wt("0x"+e)}else Gt.throwArgumentError("invalid address","address",t);return e}function Qt(t){let e=null;try{e=$t(t.from)}catch(e){Gt.throwArgumentError("missing from address","transaction",t)}return $t(T(Dt(zt([e,A(E(t.nonce))])),12))}class Yt extends Ct{constructor(t){super("address","address",t,!1)}encode(t,e){try{$t(e)}catch(t){this._throwError(t.message,e)}return t.writeValue(e)}decode(t){return $t(R(t.readValue().toHexString(),20))}}class te extends Ct{constructor(t){super(t.name,t.type,void 0,t.dynamic),this.coder=t}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}const ee=new p(ft);function re(t,e,r){if(Array.isArray(r));else if(r&&"object"==typeof r){let t=[];e.forEach(function(e){t.push(r[e.localName])}),r=t}else ee.throwArgumentError("invalid tuple value","tuple",r);e.length!==r.length&&ee.throwArgumentError("types/value length mismatch","tuple",r);let n=new Bt(t.wordSize),i=new Bt(t.wordSize),s=[];e.forEach((t,e)=>{let o=r[e];if(t.dynamic){let e=i.length;t.encode(i,o);let r=n.writeUpdatableValue();s.push(t=>{r(t+e)})}else t.encode(n,o)}),s.forEach(t=>{t(n.length)});let o=t.writeBytes(n.data);return o+=t.writeBytes(i.data)}function ne(t,e){let r=[],n=t.subReader(0),i=0;return e.forEach(e=>{let s=null;if(e.dynamic){let r=t.readValue(),o=n.subReader(r.toNumber());s=e.decode(o),i+=o.consumed}else s=e.decode(t);null!=s&&r.push(s)}),t.readBytes(i),e.forEach((t,e)=>{let n=t.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[e]))}),r}class ie extends Ct{constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),this.coder=t,this.length=e}encode(t,e){Array.isArray(e)||this._throwError("expected array value",e);let r=this.length;-1===r&&(r=e.length,t.writeValue(e.length)),ee.checkArgumentCount(r,e.length,"coder array"+(this.localName?" "+this.localName:""));let n=[];for(let t=0;t>7==0){r.push(i);continue}let s=null,o=null;if(192==(224&i))s=1,o=127;else if(224==(240&i))s=2,o=2047;else{if(240!=(248&i)){if(!e){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}s=3,o=65535}if(n+s>t.length){if(!e)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);continue}let a=i&(1<<8-s-1)-1;for(let e=0;e1114111){if(!e)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(a>=55296&&a<=57343){if(!e)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(a);else if(!e)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}return r}function Ae(t,e=Ee.current){e!=Ee.current&&(we.checkNormalize(),t=t.normalize(e));let r=[];for(let e=0;e>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;let i=t.charCodeAt(e);if(e>=t.length||56320!=(64512&i))throw new Error("invalid utf-8 string");n=65536+((1023&n)<<10)+(1023&i),r.push(n>>18|240),r.push(n>>12&63|128),r.push(n>>6&63|128),r.push(63&n|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return E(r)}function Se(t){let e="0000"+t.toString(16);return"\\u"+e.substring(e.length-4)}function Me(t){return t.map(t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t)))).join("")}function ke(t,e){return Me(_e(t,e))}function Pe(t,e=Ee.current){return _e(Ae(t,e))}function xe(t,e){e||(e=function(t){return[parseInt(t,16)]});let r=0,n={};return t.split(",").forEach(t=>{let i=t.split(":");r+=parseInt(i[0],16),n[r]=e(i[1])}),n}function Te(t){let e=0;return t.split(",").map(t=>{let r=t.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:e+parseInt(r[0],16),h:e=parseInt(r[1],16)}})}function Ne(t,e){let r=0;for(let n=0;n=(r+=i.l)&&t<=r+i.h&&(t-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(t-r))continue;return i}}return null}!function(t){t.current="",t.NFC="NFC",t.NFD="NFD",t.NFKC="NFKC",t.NFKD="NFKD"}(Ee||(Ee={}));const Ie=Te("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),Re="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(t=>parseInt(t,16)),Ce=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],Be=xe("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),Oe=xe("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),Fe=xe("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(t){if(t.length%4!=0)throw new Error("bad data");let e=[];for(let r=0;r{if(Re.indexOf(t)>=0)return[];if(t>=65024&&t<=65039)return[];let e=function(t){let e=Ne(t,Ce);if(e)return[t+e.s];let r=Be[t];if(r)return r;let n=Oe[t];if(n)return[t+n[0]];let i=Fe[t];return i||null}(t);return e||[t]}),(e=Pe(Me(e=r.reduce((t,e)=>(e.forEach(e=>{t.push(e)}),t),[])),Ee.NFKC)).forEach(t=>{if(function(t){return!!Ne(t,De)}(t))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),e.forEach(t=>{if(function(t){return!!Ne(t,Ie)}(t))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});let n=Me(e);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}class Ue extends oe{constructor(t){super("string",t)}encode(t,e){return super.encode(t,Ae(e))}decode(t){return ke(super.decode(t))}}class ze extends Ct{constructor(t,e){let r=!1,n=[];t.forEach(t=>{t.dynamic&&(r=!0),n.push(t.type)}),super("tuple","tuple("+n.join(",")+")",e,r),this.coders=t}encode(t,e){return re(t,this.coders,e)}decode(t){return t.coerce(this.name,ne(t,this.coders))}}const je=new p(ft),He=new RegExp(/^bytes([0-9]*)$/),qe=new RegExp(/^(u?int)([0-9]*)$/);class Ke{constructor(t){je.checkNew(new.target,Ke),rt(this,"coerceFunc",t||null)}_getCoder(t){switch(t.baseType){case"address":return new Yt(t.name);case"bool":return new se(t.name);case"string":return new Ue(t.name);case"bytes":return new ae(t.name);case"array":return new ie(this._getCoder(t.arrayChildren),t.arrayLength,t.name);case"tuple":return new ze((t.components||[]).map(t=>this._getCoder(t)),t.name);case"":return new le(t.name)}let e=t.type.match(qe);if(e){let r=parseInt(e[2]||"256");return(0===r||r>256||r%8!=0)&&je.throwArgumentError("invalid "+e[1]+" bit length","param",t),new be(r/8,"int"===e[1],t.name)}if(e=t.type.match(He)){let r=parseInt(e[1]);return(0===r||r>32)&&je.throwArgumentError("invalid bytes length","param",t),new he(r,t.name)}return je.throwError("invalid type","type",t.type)}_getWordSize(){return 32}_getReader(t){return new Ot(t,this._getWordSize(),this.coerceFunc)}_getWriter(){return new Bt(this._getWordSize())}encode(t,e){t.length!==e.length&&je.throwError("types/values length mismatch",p.errors.INVALID_ARGUMENT,{count:{types:t.length,values:e.length},value:{types:t,values:e}});let r=t.map(t=>this._getCoder(bt.from(t))),n=new ze(r,"_"),i=this._getWriter();return n.encode(i,e),i.data}decode(t,e){let r=t.map(t=>this._getCoder(bt.from(t)));return new ze(r,"_").decode(this._getReader(E(e)))}}const Ge=new Ke,We=new p("hash/5.0.0-beta.127"),Ve=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Je=new RegExp("^((.*)\\.)?([^.]+)$");function Ze(t){try{let e=t.split(".");for(let t=0;tEt.from(t)).filter(t=>null!=t)),rt(this,"_abiCoder",nt(new.target,"getAbiCoder")()),rt(this,"functions",{}),rt(this,"errors",{}),rt(this,"events",{}),rt(this,"structs",{}),this.fragments.forEach(t=>{let e=null;switch(t.type){case"constructor":return this.deploy?void er.warn("duplicate definition - constructor"):void rt(this,"deploy",t);case"function":e=this.functions;break;case"event":e=this.events;break;default:return}let r=t.format();e[r]?er.warn("duplicate definition - "+r):e[r]=t}),[this.events,this.functions].forEach(t=>{let e=function(t){let e={};for(let r in t){let n=t[r].name;e[n]||(e[n]=0),e[n]++}return e}(t);Object.keys(t).forEach(r=>{let n=t[r];1===e[n.name]?t[n.name]=n:er.warn("duplicate definition - "+n.name)})}),this.deploy||rt(this,"deploy",kt.from({type:"constructor"})),rt(this,"_isInterface",!0)}static getAbiCoder(){return Ge}static getAddress(t){return $t(t)}_sighashify(t){return T($e(t.format()),0,4)}_topicify(t){return $e(t.format())}getFunction(t){return M(t)?or(t,this.getSighash.bind(this),this.functions):-1===t.indexOf("(")?this.functions[t.trim()]||null:this.functions[Pt.fromString(t).format()]}getEvent(t){return M(t)?or(t,this.getEventTopic.bind(this),this.events):-1===t.indexOf("(")?this.events[t]:this.events[_t.fromString(t).format()]}getSighash(t){return"string"==typeof t&&(t=this.getFunction(t)),this._sighashify(t)}getEventTopic(t){return"string"==typeof t&&(t=this.getEvent(t)),this._topicify(t)}_encodeParams(t,e){return this._abiCoder.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}encodeFunctionData(t,e){return"string"==typeof t&&(t=this.getFunction(t)),P(_([this.getSighash(t),this._encodeParams(t.inputs,e||[])]))}decodeFunctionResult(t,e){"string"==typeof t&&(t=this.getFunction(t));let r=E(e),n=null,i=null;switch(r.length%this._abiCoder._getWordSize()){case 0:try{return this._abiCoder.decode(t.outputs,r)}catch(t){}break;case 4:"0x08c379a0"===P(r.slice(0,4))&&(i="Error(string)",n=this._abiCoder.decode(["string"],r.slice(4)))}return er.throwError("call revert exception",p.errors.CALL_EXCEPTION,{method:t.format(),errorSignature:i,errorArgs:[n],reason:n})}encodeFilterTopics(t,e){"string"==typeof t&&(t=this.getEvent(t)),e.length>t.inputs.length&&er.throwError("too many arguments for "+t.format(),p.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:e});let r=[];for(t.anonymous||r.push(this.getEventTopic(t)),e.forEach((e,n)=>{let i=t.inputs[n];i.indexed?null==e?r.push(null):"string"===i.type?r.push($e(e)):"bytes"===i.type?r.push(Dt(P(e))):-1!==i.type.indexOf("[")||"tuple"===i.type.substring(0,5)?er.throwArgumentError("filtering with tuples or arrays not supported","contract."+i.name,e):("address"===i.type&&this._abiCoder.encode(["address"],[e]),r.push(R(P(e),32))):null!=e&&er.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+i.name,e)});r.length&&null===r[r.length-1];)r.pop();return r}decodeEventLog(t,e,r){if("string"==typeof t&&(t=this.getEvent(t)),null!=r&&!t.anonymous){let e=this.getEventTopic(t);M(r[0],32)&&r[0].toLowerCase()===e||er.throwError("fragment/topic mismatch",p.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:e,value:r[0]}),r=r.slice(1)}let n=[],i=[],s=[];t.inputs.forEach((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(bt.fromObject({type:"bytes32",name:t.name})),s.push(!0)):(n.push(t),s.push(!1)):(i.push(t),s.push(!1))});let o=null!=r?this._abiCoder.decode(n,_(r)):null,a=this._abiCoder.decode(i,e),h=[],l=0,u=0;return t.inputs.forEach((t,e)=>{t.indexed?null==o?h[e]=new ir({_isIndexed:!0,hash:null}):s[e]?h[e]=new ir({_isIndexed:!0,hash:o[u++]}):h[e]=o[u++]:h[e]=a[l++]}),h}parseTransaction(t){let e=this.getFunction(t.data.substring(0,10).toLowerCase());return e?new nr({args:this._abiCoder.decode(e.inputs,"0x"+t.data.substring(10)),functionFragment:e,name:e.name,signature:e.format(),sighash:this.getSighash(e),value:U.from(t.value||"0")}):null}parseLog(t){let e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new rr({eventFragment:e,name:e.name,signature:e.format(),topic:this.getEventTopic(e),values:this.decodeEventLog(e,t.data,t.topics)})}static isInterface(t){return!(!t||!t._isInterface)}}function or(t,e,r){for(let n in r){if(-1===n.indexOf("("))continue;let i=r[n];if(e(i)===t)return i}return null}const ar=new p("abstract-provider/5.0.0-beta.130");class hr extends lt{static isForkEvent(t){return!(!t||!t._isForkEvent)}}class lr{constructor(){ar.checkAbstract(new.target,lr),rt(this,"_isProvider",!0)}addListener(t,e){return this.on(t,e)}removeListener(t,e){return this.off(t,e)}static isProvider(t){return!(!t||!t._isProvider)}}const ur=new p("abstract-signer/5.0.0-beta.131"),fr=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"];class cr{constructor(){ur.checkAbstract(new.target,cr),rt(this,"_isSigner",!0)}getBalance(t){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),t)}getTransactionCount(t){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),t)}estimateGas(t){return this._checkProvider("estimateGas"),it(this.checkTransaction(t)).then(t=>this.provider.estimateGas(t))}call(t,e){return this._checkProvider("call"),it(this.checkTransaction(t)).then(t=>this.provider.call(t))}sendTransaction(t){return this._checkProvider("sendTransaction"),this.populateTransaction(t).then(t=>this.signTransaction(t).then(t=>this.provider.sendTransaction(t)))}getChainId(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(t=>t.chainId)}getGasPrice(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()}resolveName(t){return this._checkProvider("resolveName"),this.provider.resolveName(t)}checkTransaction(t){for(let e in t)-1===fr.indexOf(e)&&ur.throwArgumentError("invalid transaction key: "+e,"transaction",t);let e=ot(t);return null==e.from&&(e.from=this.getAddress()),e}populateTransaction(t){return it(this.checkTransaction(t)).then(e=>(null!=e.to&&(e.to=Promise.resolve(e.to).then(t=>this.resolveName(t))),null==e.gasPrice&&(e.gasPrice=this.getGasPrice()),null==e.nonce&&(e.nonce=this.getTransactionCount("pending")),null==e.from?e.from=this.getAddress():e.from=Promise.all([this.getAddress(),this.provider.resolveName(e.from)]).then(e=>(e[0]!==e[1]&&ur.throwArgumentError("from address mismatch","transaction",t),e[0])),null==e.gasLimit&&(e.gasLimit=this.estimateGas(e).catch(t=>{ur.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",p.errors.UNPREDICTABLE_GAS_LIMIT,{tx:e})})),null==e.chainId&&(e.chainId=this.getChainId()),it(e)))}_checkProvider(t){this.provider||ur.throwError("missing provider",p.errors.UNSUPPORTED_OPERATION,{operation:t||"_checkProvider"})}static isSigner(t){return!(!t||!t._isSigner)}}class dr extends cr{constructor(t,e){ur.checkNew(new.target,dr),super(),rt(this,"address",t),rt(this,"provider",e||null)}getAddress(){return Promise.resolve(this.address)}_fail(t,e){return Promise.resolve().then(()=>{ur.throwError(t,p.errors.UNSUPPORTED_OPERATION,{operation:e})})}signMessage(t){return this._fail("VoidSigner cannot sign messages","signMessage")}signTransaction(t){return this._fail("VoidSigner cannot sign transactions","signTransaction")}connect(t){return new dr(this.address,t)}}const pr=new p("contracts/5.0.0-beta.136"),mr={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function gr(t,e,r){if(Array.isArray(r))return Promise.all(r.map((r,n)=>gr(t,Array.isArray(e)?e[n]:e[r.name],r)));if("address"===r.type)return t.resolveName(e);if("tuple"===r.type)return gr(t,e,r.components);if("array"===r.baseType){if(!Array.isArray(e))throw new Error("invalid value for array");return Promise.all(e.map(e=>gr(t,e,r.arrayChildren)))}return Promise.resolve(e)}function yr(t,e,r){let n=t.interface.functions[e];return function(...e){let i={},s=null;if(e.length===n.inputs.length+1&&"object"==typeof e[e.length-1]){null!=(i=ot(e.pop())).blockTag&&(s=i.blockTag),delete i.blockTag;for(let t in i)mr[t]||pr.throwError("unknown transaxction override - "+t,"overrides",i)}return pr.checkArgumentCount(e.length,n.inputs.length,"passed to contract"),["data","to"].forEach(function(t){null!=i[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),null!=t.deployTransaction?i.to=t._deployed(s).then(()=>t.addressPromise):i.to=t.addressPromise,gr(t.signer||t.provider,e,n.inputs).then(e=>(i.data=t.interface.encodeFunctionData(n,e),n.constant||r.callStatic?r.estimate?Promise.resolve(de):(t.provider||t.signer||pr.throwError("call (constant functions) require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"call"}),["gasLimit","gasPrice","value"].forEach(function(t){if(null!=i[t])throw new Error("call cannot override "+t)}),r.transaction?it(i):(t.signer||t.provider).call(i,s).then(r=>{try{let s=t.interface.decodeFunctionResult(n,r);return 1===n.outputs.length&&(s=s[0]),s}catch(r){throw r.code===p.errors.CALL_EXCEPTION&&(r.address=t.address,r.args=e,r.transaction=i),r}})):r.estimate?(t.provider||t.signer||pr.throwError("estimate require a provider or signer",p.errors.UNSUPPORTED_OPERATION,{operation:"estimateGas"}),(t.signer||t.provider).estimateGas(i)):(null==i.gasLimit&&null!=n.gas&&(i.gasLimit=U.from(n.gas).add(21e3)),null==i.value||n.payable||pr.throwArgumentError("contract method is not payable","sendTransaction:"+n.format(),i),r.transaction?it(i):(t.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction"}),t.signer.sendTransaction(i).then(e=>{let r=e.wait.bind(e);return e.wait=e=>r(e).then(e=>(e.events=e.logs.map(r=>{let n=ht(r),i=t.interface.parseLog(r);return i&&(n.values=i.values,n.decode=(t,e)=>this.interface.decodeEventLog(i.eventFragment,t,e),n.event=i.name,n.eventSignature=i.signature),n.removeListener=()=>t.provider,n.getBlock=()=>t.provider.getBlock(e.blockHash),n.getTransaction=()=>t.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>Promise.resolve(e),n}),e)),e})))))}}function vr(t){return!t.address||null!=t.topics&&0!==t.topics.length?(t.address||"*")+"@"+(t.topics?t.topics.join(":"):""):"*"}class br{constructor(t,e){rt(this,"tag",t),rt(this,"filter",e),this._listeners=[]}addListener(t,e){this._listeners.push({listener:t,once:e})}removeListener(t){let e=!1;this._listeners=this._listeners.filter(r=>!(!e&&r.listener===t)||(e=!0,!1))}removeAllListeners(){this._listeners=[]}listeners(){return this._listeners.map(t=>t.listener)}listenerCount(){return this._listeners.length}run(t){let e=this.listenerCount();return this._listeners=this._listeners.filter(e=>{let r=t.slice();return setTimeout(()=>{e.listener.apply(this,r)},0),!e.once}),e}prepareEvent(t){}}class wr extends br{constructor(){super("error",null)}}class Er extends br{constructor(t,e,r,n){let i={address:t},s=e.getEventTopic(r);n?(s!==n[0]&&pr.throwArgumentError("topic mismatch","topics",n),i.topics=n.slice()):i.topics=[s],super(vr(i),i),rt(this,"address",t),rt(this,"interface",e),rt(this,"fragment",r)}prepareEvent(t){super.prepareEvent(t),t.event=this.fragment.name,t.eventSignature=this.fragment.format(),t.decode=(t,e)=>this.interface.decodeEventLog(this.fragment,t,e),t.values=this.interface.decodeEventLog(this.fragment,t.data,t.topics)}}class _r extends br{constructor(t,e){super("*",{address:t}),rt(this,"address",t),rt(this,"interface",e)}prepareEvent(t){super.prepareEvent(t);let e=this.interface.parseLog(t);e&&(t.event=e.name,t.eventSignature=e.signature,t.decode=(t,r)=>this.interface.decodeEventLog(e.eventFragment,t,r),t.values=e.values)}}class Ar{constructor(t,e,r){if(pr.checkNew(new.target,Ar),rt(this,"interface",nt(new.target,"getInterface")(e)),cr.isSigner(r)?(rt(this,"provider",r.provider||null),rt(this,"signer",r)):lr.isProvider(r)?(rt(this,"provider",r),rt(this,"signer",null)):pr.throwArgumentError("invalid signer or provider","signerOrProvider",r),rt(this,"callStatic",{}),rt(this,"estimate",{}),rt(this,"functions",{}),rt(this,"populateTransaction",{}),rt(this,"filters",{}),Object.keys(this.interface.events).forEach(t=>{let e=this.interface.events[t];rt(this.filters,t,(...t)=>({address:this.address,topics:this.interface.encodeFilterTopics(e,t)}))}),rt(this,"_runningEvents",{}),rt(this,"_wrappedEmits",{}),rt(this,"address",t),this.provider)rt(this,"addressPromise",this.provider.resolveName(t).then(t=>{if(null==t)throw new Error("name not found");return t}).catch(e=>{throw console.log("ERROR: Cannot find Contract - "+t),e}));else try{rt(this,"addressPromise",Promise.resolve(this.interface.constructor.getAddress(t)))}catch(e){pr.throwArgumentError("provider is required to use non-address contract address","addressOrName",t)}Object.keys(this.interface.functions).forEach(t=>{let e=yr(this,t,{});null==this[t]&&rt(this,t,e),null==this.functions[t]&&rt(this.functions,t,e),null==this.callStatic[t]&&rt(this.callStatic,t,yr(this,t,{callStatic:!0})),null==this.populateTransaction[t]&&rt(this.populateTransaction,t,yr(this,t,{transaction:!0})),null==this.estimate[t]&&rt(this.estimate,t,yr(this,t,{estimate:!0}))})}static getContractAddress(t){return Qt(t)}static getInterface(t){return sr.isInterface(t)?t:new sr(t)}deployed(){return this._deployed()}_deployed(t){return this._deployedPromise||(this.deployTransaction?this._deployedPromise=this.deployTransaction.wait().then(()=>this):this._deployedPromise=this.provider.getCode(this.address,t).then(t=>("0x"===t&&pr.throwError("contract not deployed",p.errors.UNSUPPORTED_OPERATION,{contractAddress:this.address,operation:"getDeployed"}),this))),this._deployedPromise}fallback(t){this.signer||pr.throwError("sending a transaction require a signer",p.errors.UNSUPPORTED_OPERATION,{operation:"sendTransaction(fallback)"});let e=ot(t||{});return["from","to"].forEach(function(t){null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),e.to=this.addressPromise,this.deployed().then(()=>this.signer.sendTransaction(e))}connect(t){"string"==typeof t&&(t=new dr(t,this.provider));let e=new this.constructor(this.address,this.interface,t);return this.deployTransaction&&rt(e,"deployTransaction",this.deployTransaction),e}attach(t){return new this.constructor(t,this.interface,this.signer||this.provider)}static isIndexed(t){return ir.isIndexed(t)}_normalizeRunningEvent(t){return this._runningEvents[t.tag]?this._runningEvents[t.tag]:t}_getRunningEvent(t){if("string"==typeof t){if("error"===t)return this._normalizeRunningEvent(new wr);if("*"===t)return this._normalizeRunningEvent(new _r(this.address,this.interface));let e=this.interface.getEvent(t);return e||pr.throwArgumentError("unknown event - "+t,"eventName",t),this._normalizeRunningEvent(new Er(this.address,this.interface,e))}let e={address:this.address};if(t.topics){if(t.topics[0]){let e=this.interface.getEvent(t.topics[0]);if(e)return this._normalizeRunningEvent(new Er(this.address,this.interface,e,t.topics))}e.topics=t.topics}return this._normalizeRunningEvent(new br(vr(e),e))}_checkRunningEvents(t){0===t.listenerCount()&&delete this._runningEvents[t.tag];let e=this._wrappedEmits[t.tag];e&&(this.provider.off(t.filter,e),delete this._wrappedEmits[t.tag])}_wrapEvent(t,e,r){let n=ht(e);try{t.prepareEvent(n)}catch(t){throw this.emit("error",t),t}return n.removeListener=()=>{r&&(t.removeListener(r),this._checkRunningEvents(t))},n.getBlock=()=>this.provider.getBlock(e.blockHash),n.getTransaction=()=>this.provider.getTransaction(e.transactionHash),n.getTransactionReceipt=()=>this.provider.getTransactionReceipt(e.transactionHash),n}_addEventListener(t,e,r){if(this.provider||pr.throwError("events require a provider or a signer with a provider",p.errors.UNSUPPORTED_OPERATION,{operation:"once"}),t.addListener(e,r),this._runningEvents[t.tag]=t,!this._wrappedEmits[t.tag]){let r=r=>{let n=this._wrapEvent(t,r,e),i=n.values||[];i.push(n),this.emit(t.filter,...i)};this._wrappedEmits[t.tag]=r,null!=t.filter&&this.provider.on(t.filter,r)}}queryFilter(t,e,r){let n=this._getRunningEvent(t),i=ot(n.filter);return"string"==typeof e&&M(e,32)?(null!=r&&pr.throwArgumentError("cannot specify toBlock with blockhash","toBlock",r),i.blockhash=e):(i.fromBlock=null!=e?e:0,i.toBlock=null!=r?r:"latest"),this.provider.getLogs(i).then(t=>t.map(t=>this._wrapEvent(n,t,null)))}on(t,e){return this._addEventListener(this._getRunningEvent(t),e,!1),this}once(t,e){return this._addEventListener(this._getRunningEvent(t),e,!0),this}emit(t,...e){if(!this.provider)return!1;let r=this._getRunningEvent(t),n=r.run(e)>0;return this._checkRunningEvents(r),n}listenerCount(t){return this.provider?this._getRunningEvent(t).listenerCount():0}listeners(t){if(!this.provider)return[];if(null==t){let t=[];for(let e in this._runningEvents)this._runningEvents[e].listeners().forEach(e=>{t.push(e)});return t}return this._getRunningEvent(t).listeners()}removeAllListeners(t){if(!this.provider)return this;if(null==t){for(let t in this._runningEvents){let e=this._runningEvents[t];e.removeAllListeners(),this._checkRunningEvents(e)}return this}let e=this._getRunningEvent(t);return e.removeAllListeners(),this._checkRunningEvents(e),this}off(t,e){if(!this.provider)return this;let r=this._getRunningEvent(t);return r.removeListener(e),this._checkRunningEvents(r),this}removeListener(t,e){return this.off(t,e)}}class Sr{constructor(t,e,r){let n=null;"0x"!==(n="string"==typeof e?e:w(e)?P(e):e&&"string"==typeof e.object?e.object:"!").substring(0,2)&&(n="0x"+n),(!M(n)||n.length%2)&&pr.throwArgumentError("invalid bytecode","bytecode",e),r&&!cr.isSigner(r)&&pr.throwArgumentError("invalid signer","signer",r),rt(this,"bytecode",n),rt(this,"interface",nt(new.target,"getInterface")(t)),rt(this,"signer",r||null)}getDeployTransaction(...t){let e={};if(t.length===this.interface.deploy.inputs.length+1){e=ot(t.pop());for(let t in e)if(!mr[t])throw new Error("unknown transaction override "+t)}return["data","from","to"].forEach(t=>{null!=e[t]&&pr.throwError("cannot override "+t,p.errors.UNSUPPORTED_OPERATION,{operation:t})}),pr.checkArgumentCount(t.length,this.interface.deploy.inputs.length," in Contract constructor"),e.data=P(_([this.bytecode,this.interface.encodeDeploy(t)])),e}deploy(...t){return gr(this.signer,t,this.interface.deploy.inputs).then(t=>{let e=this.getDeployTransaction(...t);return this.signer.sendTransaction(e).then(t=>{let e=this.constructor.getContractAddress(t),r=this.constructor.getContract(e,this.interface,this.signer);return rt(r,"deployTransaction",t),r})})}attach(t){return this.constructor.getContract(t,this.interface,this.signer)}connect(t){return new this.constructor(this.interface,this.bytecode,t)}static fromSolidity(t,e){null==t&&pr.throwError("missing compiler output",p.errors.MISSING_ARGUMENT,{argument:"compilerOutput"}),"string"==typeof t&&(t=JSON.parse(t));let r=t.abi,n=null;return t.bytecode?n=t.bytecode:t.evm&&t.evm.bytecode&&(n=t.evm.bytecode),new this(r,n,e)}static getInterface(t){return Ar.getInterface(t)}static getContractAddress(t){return Qt(t)}static getContract(t,e,r){return new Ar(t,e,r)}}class Mr{constructor(t){rt(this,"alphabet",t),rt(this,"base",t.length),rt(this,"_alphabetMap",{}),rt(this,"_leader",t.charAt(0));for(let e=0;e0;)r.push(n%this.base),n=n/this.base|0}let n="";for(let t=0;0===e[t]&&t=0;--t)n+=this.alphabet[r[t]];return n}decode(t){if("string"!=typeof t)throw new TypeError("Expected String");let e=[];if(0===t.length)return new Uint8Array(e);e.push(0);for(let r=0;r>=8;for(;i>0;)e.push(255&i),i>>=8}for(let r=0;t[r]===this._leader&&r>>24|t>>>8&65280|t<<8&16711680|(255&t)<<24)>>>0}function Ir(t){return 1===t.length?"0"+t:t}function Rr(t){return 7===t.length?"0"+t:6===t.length?"00"+t:5===t.length?"000"+t:4===t.length?"0000"+t:3===t.length?"00000"+t:2===t.length?"000000"+t:1===t.length?"0000000"+t:t}var Cr={inherits:Tr,toArray:function(t,e){if(Array.isArray(t))return t.slice();if(!t)return[];var r=[];if("string"==typeof t)if(e){if("hex"===e)for((t=t.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(t="0"+t),n=0;n>8,o=255&i;s?r.push(s,o):r.push(o)}else for(n=0;n>>0}return s},split32:function(t,e){for(var r=new Array(4*t.length),n=0,i=0;n>>24,r[i+1]=s>>>16&255,r[i+2]=s>>>8&255,r[i+3]=255&s):(r[i+3]=s>>>24,r[i+2]=s>>>16&255,r[i+1]=s>>>8&255,r[i]=255&s)}return r},rotr32:function(t,e){return t>>>e|t<<32-e},rotl32:function(t,e){return t<>>32-e},sum32:function(t,e){return t+e>>>0},sum32_3:function(t,e,r){return t+e+r>>>0},sum32_4:function(t,e,r,n){return t+e+r+n>>>0},sum32_5:function(t,e,r,n,i){return t+e+r+n+i>>>0},sum64:function(t,e,r,n){var i=t[e],s=n+t[e+1]>>>0,o=(s>>0,t[e+1]=s},sum64_hi:function(t,e,r,n){return(e+n>>>0>>0},sum64_lo:function(t,e,r,n){return e+n>>>0},sum64_4_hi:function(t,e,r,n,i,s,o,a){var h=0,l=e;return h+=(l=l+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(t,e,r,n,i,s,o,a){return e+n+s+a>>>0},sum64_5_hi:function(t,e,r,n,i,s,o,a,h,l){var u=0,f=e;return u+=(f=f+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(t,e,r,n,i,s,o,a,h,l){return e+n+s+a+l>>>0},rotr64_hi:function(t,e,r){return(e<<32-r|t>>>r)>>>0},rotr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0},shr64_hi:function(t,e,r){return t>>>r},shr64_lo:function(t,e,r){return(t<<32-r|e>>>r)>>>0}};function Br(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var Or=Br;Br.prototype.update=function(t,e){if(t=Cr.toArray(t,e),this.pending?this.pending=this.pending.concat(t):this.pending=t,this.pendingTotal+=t.length,this.pending.length>=this._delta8){var r=(t=this.pending).length%this._delta8;this.pending=t.slice(t.length-r,t.length),0===this.pending.length&&(this.pending=null),t=Cr.join32(t,0,t.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=t>>>16&255,n[i++]=t>>>8&255,n[i++]=255&t}else for(n[i++]=255&t,n[i++]=t>>>8&255,n[i++]=t>>>16&255,n[i++]=t>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,s=8;s>>3},g1_256:function(t){return Dr(t,17)^Dr(t,19)^t>>>10}},Hr=Cr.sum32,qr=Cr.sum32_4,Kr=Cr.sum32_5,Gr=jr.ch32,Wr=jr.maj32,Vr=jr.s0_256,Jr=jr.s1_256,Zr=jr.g0_256,Xr=jr.g1_256,$r=Fr.BlockHash,Qr=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Yr(){if(!(this instanceof Yr))return new Yr;$r.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Qr,this.W=new Array(64)}Cr.inherits(Yr,$r);var tn=Yr;Yr.blockSize=512,Yr.outSize=256,Yr.hmacStrength=192,Yr.padLength=64,Yr.prototype._update=function(t,e){for(var r=this.W,n=0;n<16;n++)r[n]=t[e+n];for(;nthis.blockSize&&(t=(new this.Hash).update(t).digest()),Pr(t.length<=this.blockSize);for(var e=t.length;e>24&255,u[e.length+1]=f>>16&255,u[e.length+2]=f>>8&255,u[e.length+3]=255&f;var c=O.arrayify(Zn.computeHmac(i,t,u));s||(s=c.length,a=new Uint8Array(s),o=n-((h=Math.ceil(n/s))-1)*s),a.set(c);for(var d=1;d>8,o=255&i;s?r.push(s,o):r.push(o)}return r},r.zero2=n,r.toHex=i,r.encode=function(t,e){return"hex"===e?i(t):t}}),si=r(function(t,e){var r=e;r.assert=Pr,r.toArray=ii.toArray,r.zero2=ii.zero2,r.toHex=ii.toHex,r.encode=ii.encode,r.getNAF=function(t,e){for(var r=[],n=1<=0;){var s;if(i.isOdd()){var o=i.andln(n-1);s=o>(n>>1)-1?(n>>1)-o:o,i.isubn(s)}else s=0;r.push(s);for(var a=0!==i.cmpn(0)&&0===i.andln(n-1)?e+1:1,h=1;h0||e.cmpn(-i)>0;){var s,o,a,h=t.andln(3)+n&3,l=e.andln(3)+i&3;if(3===h&&(h=-1),3===l&&(l=-1),0==(1&h))s=0;else s=3!==(a=t.andln(7)+n&7)&&5!==a||2!==l?h:-h;if(r[0].push(s),0==(1&l))o=0;else o=3!==(a=e.andln(7)+i&7)&&5!==a||2!==h?l:-l;r[1].push(o),2*n===s+1&&(n=1-n),2*i===o+1&&(i=1-i),t.iushrn(1),e.iushrn(1)}return r},r.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(t){return"string"==typeof t?r.toArray(t,"hex"):t},r.intFromLE=function(t){return new s(t,"hex","le")}}),oi=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},ai=si.getNAF,hi=si.getJSF,li=si.assert;function ui(t,e){this.type=t,this.p=new s(e.p,16),this.red=e.prime?s.red(e.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=e.n&&new s(e.n,16),this.g=e.g&&this.pointFromJSON(e.g,e.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var fi=ui;function ci(t,e){this.curve=t,this.type=e,this.precomputed=null}ui.prototype.point=function(){throw new Error("Not implemented")},ui.prototype.validate=function(){throw new Error("Not implemented")},ui.prototype._fixedNafMul=function(t,e){li(t.precomputed);var r=t._getDoubles(),n=ai(e,1),i=(1<=o;e--)a=(a<<1)+n[e];s.push(a)}for(var h=this.jpoint(null,null,null),l=this.jpoint(null,null,null),u=i;u>0;u--){for(o=0;o=0;a--){for(e=0;a>=0&&0===s[a];a--)e++;if(a>=0&&e++,o=o.dblp(e),a<0)break;var h=s[a];li(0!==h),o="affine"===t.type?h>0?o.mixedAdd(i[h-1>>1]):o.mixedAdd(i[-h-1>>1].neg()):h>0?o.add(i[h-1>>1]):o.add(i[-h-1>>1].neg())}return"affine"===t.type?o.toP():o},ui.prototype._wnafMulAdd=function(t,e,r,n,i){for(var s=this._wnafT1,o=this._wnafT2,a=this._wnafT3,h=0,l=0;l=1;l-=2){var f=l-1,c=l;if(1===s[f]&&1===s[c]){var d=[e[f],null,null,e[c]];0===e[f].y.cmp(e[c].y)?(d[1]=e[f].add(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg())):0===e[f].y.cmp(e[c].y.redNeg())?(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].add(e[c].neg())):(d[1]=e[f].toJ().mixedAdd(e[c]),d[2]=e[f].toJ().mixedAdd(e[c].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=hi(r[f],r[c]);h=Math.max(m[0].length,h),a[f]=new Array(h),a[c]=new Array(h);for(var g=0;g=0;l--){for(var E=0;l>=0;){var _=!0;for(g=0;g=0&&E++,b=b.dblp(E),l<0)break;for(g=0;g0?A=o[g][S-1>>1]:S<0&&(A=o[g][-S-1>>1].neg()),b="affine"===A.type?b.mixedAdd(A):b.add(A))}}for(l=0;l=Math.ceil((t.bitLength()+1)/e.step)},ci.prototype._getDoubles=function(t,e){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=e,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},pi.prototype._endoSplit=function(t){var e=this.endo.basis,r=e[0],n=e[1],i=n.b.mul(t).divRound(this.n),s=r.b.neg().mul(t).divRound(this.n),o=i.mul(r.a),a=s.mul(n.a),h=i.mul(r.b),l=s.mul(n.b);return{k1:t.sub(o).sub(a),k2:h.add(l).neg()}},pi.prototype.pointFromX=function(t,e){(t=new s(t,16)).red||(t=t.toRed(this.red));var r=t.redSqr().redMul(t).redIAdd(t.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(e&&!i||!e&&i)&&(n=n.redNeg()),this.point(t,n)},pi.prototype.validate=function(t){if(t.inf)return!0;var e=t.x,r=t.y,n=this.a.redMul(e),i=e.redSqr().redMul(e).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},pi.prototype._endoWnafMulAdd=function(t,e,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,s=0;s":""},gi.prototype.isInfinity=function(){return this.inf},gi.prototype.add=function(t){if(this.inf)return t;if(t.inf)return this;if(this.eq(t))return this.dbl();if(this.neg().eq(t))return this.curve.point(null,null);if(0===this.x.cmp(t.x))return this.curve.point(null,null);var e=this.y.redSub(t.y);0!==e.cmpn(0)&&(e=e.redMul(this.x.redSub(t.x).redInvm()));var r=e.redSqr().redISub(this.x).redISub(t.x),n=e.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},gi.prototype.dbl=function(){if(this.inf)return this;var t=this.y.redAdd(this.y);if(0===t.cmpn(0))return this.curve.point(null,null);var e=this.curve.a,r=this.x.redSqr(),n=t.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(e).redMul(n),s=i.redSqr().redISub(this.x.redAdd(this.x)),o=i.redMul(this.x.redSub(s)).redISub(this.y);return this.curve.point(s,o)},gi.prototype.getX=function(){return this.x.fromRed()},gi.prototype.getY=function(){return this.y.fromRed()},gi.prototype.mul=function(t){return t=new s(t,16),this._hasDoubles(t)?this.curve._fixedNafMul(this,t):this.curve.endo?this.curve._endoWnafMulAdd([this],[t]):this.curve._wnafMul(this,t)},gi.prototype.mulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},gi.prototype.jmulAdd=function(t,e,r){var n=[this,e],i=[t,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},gi.prototype.eq=function(t){return this===t||this.inf===t.inf&&(this.inf||0===this.x.cmp(t.x)&&0===this.y.cmp(t.y))},gi.prototype.neg=function(t){if(this.inf)return this;var e=this.curve.point(this.x,this.y.redNeg());if(t&&this.precomputed){var r=this.precomputed,n=function(t){return t.neg()};e.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return e},gi.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},Tr(yi,fi.BasePoint),pi.prototype.jpoint=function(t,e,r){return new yi(this,t,e,r)},yi.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var t=this.z.redInvm(),e=t.redSqr(),r=this.x.redMul(e),n=this.y.redMul(e).redMul(t);return this.curve.point(r,n)},yi.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},yi.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(e),i=t.x.redMul(r),s=this.y.redMul(e.redMul(t.z)),o=t.y.redMul(r.redMul(this.z)),a=n.redSub(i),h=s.redSub(o);if(0===a.cmpn(0))return 0!==h.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var l=a.redSqr(),u=l.redMul(a),f=n.redMul(l),c=h.redSqr().redIAdd(u).redISub(f).redISub(f),d=h.redMul(f.redISub(c)).redISub(s.redMul(u)),p=this.z.redMul(t.z).redMul(a);return this.curve.jpoint(c,d,p)},yi.prototype.mixedAdd=function(t){if(this.isInfinity())return t.toJ();if(t.isInfinity())return this;var e=this.z.redSqr(),r=this.x,n=t.x.redMul(e),i=this.y,s=t.y.redMul(e).redMul(this.z),o=r.redSub(n),a=i.redSub(s);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=o.redSqr(),l=h.redMul(o),u=r.redMul(h),f=a.redSqr().redIAdd(l).redISub(u).redISub(u),c=a.redMul(u.redISub(f)).redISub(i.redMul(l)),d=this.z.redMul(o);return this.curve.jpoint(f,c,d)},yi.prototype.dblp=function(t){if(0===t)return this;if(this.isInfinity())return this;if(!t)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var e=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},yi.prototype.inspect=function(){return this.isInfinity()?"":""},yi.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var vi={},bi={},wi=r(function(t,e){var r=e;r.base=fi,r.short=mi,r.mont=vi,r.edwards=bi}),Ei=r(function(t,e){var r,n=e,i=si.assert;function s(t){"short"===t.type?this.curve=new wi.short(t):"edwards"===t.type?this.curve=new wi.edwards(t):this.curve=new wi.mont(t),this.g=this.curve.g,this.n=this.curve.n,this.hash=t.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function o(t,e){Object.defineProperty(n,t,{configurable:!0,enumerable:!0,get:function(){var r=new s(e);return Object.defineProperty(n,t,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=s,o("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:Vn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),o("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:Vn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),o("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:Vn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),o("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:Vn.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),o("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:Vn.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),o("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["9"]}),o("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Vn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(t){r=void 0}o("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:Vn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function _i(t){if(!(this instanceof _i))return new _i(t);this.hash=t.hash,this.predResist=!!t.predResist,this.outLen=this.hash.outSize,this.minEntropy=t.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ii.toArray(t.entropy,t.entropyEnc||"hex"),r=ii.toArray(t.nonce,t.nonceEnc||"hex"),n=ii.toArray(t.pers,t.persEnc||"hex");Pr(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,r,n)}var Ai=_i;_i.prototype._init=function(t,e,r){var n=t.concat(e).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(t.concat(r||[])),this._reseed=1},_i.prototype.generate=function(t,e,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof e&&(n=r,r=e,e=null),r&&(r=ii.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Pi=si.assert;function xi(t,e){if(t instanceof xi)return t;this._importDER(t,e)||(Pi(t.r&&t.s,"Signature without r or s"),this.r=new s(t.r,16),this.s=new s(t.s,16),void 0===t.recoveryParam?this.recoveryParam=null:this.recoveryParam=t.recoveryParam)}var Ti=xi;function Ni(){this.place=0}function Ii(t,e){var r=t[e.place++];if(!(128&r))return r;for(var n=15&r,i=0,s=0,o=e.place;s>>3);for(t.push(128|r);--r;)t.push(e>>>(r<<3)&255);t.push(e)}}xi.prototype._importDER=function(t,e){t=si.toArray(t,e);var r=new Ni;if(48!==t[r.place++])return!1;if(Ii(t,r)+r.place!==t.length)return!1;if(2!==t[r.place++])return!1;var n=Ii(t,r),i=t.slice(r.place,n+r.place);if(r.place+=n,2!==t[r.place++])return!1;var o=Ii(t,r);if(t.length!==o+r.place)return!1;var a=t.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},xi.prototype.toDER=function(t){var e=this.r.toArray(),r=this.s.toArray();for(128&e[0]&&(e=[0].concat(e)),128&r[0]&&(r=[0].concat(r)),e=Ri(e),r=Ri(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];Ci(n,e.length),(n=n.concat(e)).push(2),Ci(n,r.length);var i=n.concat(r),s=[48];return Ci(s,i.length),s=s.concat(i),si.encode(s,t)};var Bi=si.assert;function Oi(t){if(!(this instanceof Oi))return new Oi(t);"string"==typeof t&&(Bi(Ei.hasOwnProperty(t),"Unknown curve "+t),t=Ei[t]),t instanceof Ei.PresetCurve&&(t={curve:t}),this.curve=t.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=t.curve.g,this.g.precompute(t.curve.n.bitLength()+1),this.hash=t.hash||t.curve.hash}var Fi=Oi;Oi.prototype.keyPair=function(t){return new ki(this,t)},Oi.prototype.keyFromPrivate=function(t,e){return ki.fromPrivate(this,t,e)},Oi.prototype.keyFromPublic=function(t,e){return ki.fromPublic(this,t,e)},Oi.prototype.genKeyPair=function(t){t||(t={});for(var e=new Ai({hash:this.hash,pers:t.pers,persEnc:t.persEnc||"utf8",entropy:t.entropy||oi(this.hash.hmacStrength),entropyEnc:t.entropy&&t.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(e.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},Oi.prototype._truncateToN=function(t,e){var r=8*t.byteLength()-this.n.bitLength();return r>0&&(t=t.ushrn(r)),!e&&t.cmp(this.n)>=0?t.sub(this.n):t},Oi.prototype.sign=function(t,e,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),e=this.keyFromPrivate(e,r),t=this._truncateToN(new s(t,16));for(var i=this.n.byteLength(),o=e.getPrivate().toArray("be",i),a=t.toArray("be",i),h=new Ai({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),l=this.n.sub(new s(1)),u=0;;u++){var f=n.k?n.k(u):new s(h.generate(this.n.byteLength()));if(!((f=this._truncateToN(f,!0)).cmpn(1)<=0||f.cmp(l)>=0)){var c=this.g.mul(f);if(!c.isInfinity()){var d=c.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=f.invm(this.n).mul(p.mul(e.getPrivate()).iadd(t));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(c.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Ti({r:p,s:m,recoveryParam:g})}}}}}},Oi.prototype.verify=function(t,e,r,n){t=this._truncateToN(new s(t,16)),r=this.keyFromPublic(r,n);var i=(e=new Ti(e,"hex")).r,o=e.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,h=o.invm(this.n),l=h.mul(t).umod(this.n),u=h.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(l,r.getPublic(),u)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(l,r.getPublic(),u)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},Oi.prototype.recoverPubKey=function(t,e,r,n){Bi((3&r)===r,"The recovery param is more than two bits"),e=new Ti(e,n);var i=this.n,o=new s(t),a=e.r,h=e.s,l=1&r,u=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var f=e.r.invm(i),c=i.sub(o).mul(f).umod(i),d=h.mul(f).umod(i);return this.g.mulAdd(c,a,d)},Oi.prototype.getKeyRecoveryParam=function(t,e,r,n){if(null!==(e=new Ti(e,n)).recoveryParam)return e.recoveryParam;for(var i=0;i<4;i++){var s;try{s=this.recoverPubKey(t,e,i)}catch(t){continue}if(s.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var Di={},Li=n(ni),Ui=r(function(t,e){var r=e;r.version=Li.version,r.utils=si,r.rand=oi,r.curve=wi,r.curves=Ei,r.ec=Fi,r.eddsa=Di}).ec;const zi=new p("signing-key/5.0.0-beta.128");let ji=null;function Hi(){return ji||(ji=new Ui("secp256k1")),ji}class qi{constructor(t){rt(this,"curve","secp256k1"),rt(this,"privateKey",P(t));let e=Hi().keyFromPrivate(E(this.privateKey));rt(this,"publicKey","0x"+e.getPublic(!1,"hex")),rt(this,"compressedPublicKey","0x"+e.getPublic(!0,"hex")),rt(this,"_isSigningKey",!0)}_addPoint(t){let e=Hi().keyFromPublic(E(this.publicKey)),r=Hi().keyFromPublic(E(t));return"0x"+e.pub.add(r.pub).encodeCompressed("hex")}signDigest(t){let e=Hi().keyFromPrivate(E(this.privateKey)).sign(E(t),{canonical:!0});return C({recoveryParam:e.recoveryParam,r:R("0x"+e.r.toString(16),32),s:R("0x"+e.s.toString(16),32)})}computeSharedSecret(t){let e=Hi().keyFromPrivate(E(this.privateKey)),r=Hi().keyFromPublic(E(Gi(t)));return R("0x"+e.derive(r.getPublic()).toString(16),32)}static isSigningKey(t){return!(!t||!t._isSigningKey)}}function Ki(t,e){let r=C(e),n={r:E(r.r),s:E(r.s)};return"0x"+Hi().recoverPubKey(E(t),n,r.recoveryParam).encode("hex",!1)}function Gi(t,e){let r=E(t);if(32===r.length){let t=new qi(r);return e?"0x"+Hi().keyFromPrivate(r).getPublic(!0,"hex"):t.publicKey}return 33===r.length?e?P(r):"0x"+Hi().keyFromPublic(r).getPublic(!1,"hex"):65===r.length?e?"0x"+Hi().keyFromPublic(r).getPublic(!0,"hex"):P(r):zi.throwArgumentError("invalid public or private key","key","[REDACTED]")}const Wi=new p("transactions/5.0.0-beta.127");function Vi(t){return"0x"===t?de:U.from(t)}const Ji=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],Zi={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function Xi(t){return $t(T(Dt(T(Gi(t),1)),12))}function $i(t,e){return Xi(Ki(E(t),e))}function Qi(t,e){st(t,Zi);let r=[];Ji.forEach(function(e){let n=t[e.name]||[];n=E(P(n)),e.length&&n.length!==e.length&&n.length>0&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),e.maxLength&&(n=A(n)).length>e.maxLength&&Wi.throwArgumentError("invalid length for "+e.name,"transaction:"+e.name,n),r.push(P(n))}),null!=t.chainId&&0!==t.chainId&&(r.push(P(t.chainId)),r.push("0x"),r.push("0x"));let n=zt(r);if(!e)return n;let i=C(e),s=27+i.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),s+=2*t.chainId+8),r.push(P(s)),r.push(A(E(i.r))),r.push(A(E(i.s))),zt(r)}function Yi(t){let e=qt(t);9!==e.length&&6!==e.length&&Wi.throwArgumentError("invalid raw transaction","rawTransactin",t);let r={nonce:Vi(e[0]).toNumber(),gasPrice:Vi(e[1]),gasLimit:Vi(e[2]),to:(n=e[3],"0x"===n?null:$t(n)),value:Vi(e[4]),data:e[5],chainId:0};var n;if(6===e.length)return r;try{r.v=U.from(e[6]).toNumber()}catch(t){return console.log(t),r}if(r.r=R(e[7],32),r.s=R(e[8],32),U.from(r.r).isZero()&&U.from(r.s).isZero())r.chainId=r.v,r.v=0;else{r.chainId=Math.floor((r.v-35)/2),r.chainId<0&&(r.chainId=0);let n=r.v-27,i=e.slice(0,6);0!==r.chainId&&(i.push(P(r.chainId)),i.push("0x"),i.push("0x"),n-=2*r.chainId+8);let s=Dt(zt(i));try{r.from=$i(s,{r:P(r.r),s:P(r.s),recoveryParam:n})}catch(t){console.log(t)}r.hash=Dt(t)}return r}var ts=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="wordlists/5.0.0-beta.127"}),es=(e(ts),ts.version,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new m.Logger(ts.version);r.check=function(t){for(var e=[],r=0;r<2048;r++){var n=t.getWord(r);if(r!==t.getWordIndex(n))return"0x";e.push(n)}return tr.id(e.join("\n")+"\n")};var s=function(){function t(e){var r=this.constructor;i.checkAbstract(r,t),ut.defineReadOnly(this,"locale",e)}return t.prototype.split=function(t){return t.toLowerCase().split(/ +/g)},t.prototype.join=function(t){return t.join(" ")},t}();r.Wordlist=s,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||ut.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||ut.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||ut.defineReadOnly(i.ethers.wordlists,r,e))}}})),rs=(e(es),es.check,es.Wordlist,es.register,r(function(e,r){var n,i=t&&t.__extends||(n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var s="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",o=null;function a(t){if(null==o&&(o=s.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==es.check(t)))throw o=null,new Error("BIP39 Wordlist for en (English) FAILED")}var h=new(function(t){function e(){return t.call(this,"en")||this}return i(e,t),e.prototype.getWord=function(t){return a(this),o[t]},e.prototype.getWordIndex=function(t){return a(this),o.indexOf(t)},e}(es.Wordlist));r.langEn=h,es.register(h)})),ns=(e(rs),rs.langEn,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Wordlist=es.Wordlist;var r={en:rs.langEn};e.wordlists=r})),is=(e(ns),ns.Wordlist),ss=ns.wordlists;const os=new p("hdnode/5.0.0-beta.129"),as=U.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),hs=Ae("Bitcoin seed"),ls=2147483648;function us(t){return(1<=256)throw new Error("Depth too large!");return cs(_([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",P(this.depth),this.parentFingerprint,R(P(this.index),4),this.chainCode,null!=this.privateKey?_(["0x00",this.privateKey]):this.publicKey]))}neuter(){return new ms(ds,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)}_derive(t){if(t>4294967295)throw new Error("invalid index - "+String(t));let e=this.path;e&&(e+="/"+(t&~ls));let r=new Uint8Array(37);if(t&ls){if(!this.privateKey)throw new Error("cannot derive child of neutered node");r.set(E(this.privateKey),1),e&&(e+="'")}else r.set(E(this.publicKey));for(let e=24;e>=0;e-=8)r[33+(e>>3)]=t>>24-e&255;let n=E(Yn(Xn.sha512,this.chainCode,r)),i=n.slice(0,32),s=n.slice(32),o=null,a=null;if(this.privateKey)o=fs(U.from(i).add(this.privateKey).mod(as));else{a=new qi(P(i))._addPoint(this.publicKey)}return new ms(ds,o,a,this.fingerprint,fs(s),t,this.depth+1,this.mnemonic,e)}derivePath(t){let e=t.split("/");if(0===e.length||"m"===e[0]&&0!==this.depth)throw new Error("invalid path - "+t);"m"===e[0]&&e.shift();let r=this;for(let t=0;t=ls)throw new Error("invalid path index - "+n);r=r._derive(ls+t)}else{if(!n.match(/^[0-9]+$/))throw new Error("invalid path component - "+n);{let t=parseInt(n);if(t>=ls)throw new Error("invalid path index - "+n);r=r._derive(t)}}}return r}static _fromSeed(t,e){let r=E(t);if(r.length<16||r.length>64)throw new Error("invalid seed");let n=E(Yn(Xn.sha512,hs,r));return new ms(ds,fs(n.slice(0,32)),null,"0x00000000",fs(n.slice(32)),0,0,e,"m")}static fromMnemonic(t,e,r){return t=vs(ys(t,r),r),ms._fromSeed(gs(t,e),t)}static fromSeed(t){return ms._fromSeed(t,null)}static fromExtendedKey(t){let e=kr.decode(t);82===e.length&&cs(e.slice(0,78))===t||os.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");let r=e[4],n=P(e.slice(5,9)),i=parseInt(P(e.slice(9,13)).substring(2),16),s=P(e.slice(13,45)),o=e.slice(45,78);switch(P(e.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new ms(ds,null,P(o),n,s,i,r,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==o[0])break;return new ms(ds,P(o.slice(1)),null,n,s,i,r,null,null)}return os.throwError("invalid extended key","extendedKey","[REDACTED]")}}function gs(t,e){e||(e="");let r=Ae("mnemonic"+e,Ee.NFKD);return ei(Ae(t,Ee.NFKD),r,2048,64,"sha512")}function ys(t,e){e||(e=ss.en),os.checkNormalize();let r=e.split(t);if(r.length%3!=0)throw new Error("invalid mnemonic");let n=E(new Uint8Array(Math.ceil(11*r.length/8))),i=0;for(let t=0;t>3]|=1<<7-i%8),i++}let s=32*r.length/3,o=us(r.length/3),a=E(Qn(n.slice(0,s/8)))[0];if((a&=o)!==(n[n.length-1]&o))throw new Error("invalid checksum");return P(n.slice(0,s/8))}function vs(t,e){if((t=E(t)).length%4!=0||t.length<16||t.length>32)throw new Error("invalid entropy");let r=[0],n=11;for(let e=0;e8?(r[r.length-1]<<=8,r[r.length-1]|=t[e],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=t[e]>>8-n,r.push(t[e]&(1<<8-n)-1),n+=3);let i=E(Qn(t))[0],s=t.length/4;return i&=us(s),r[r.length-1]<<=s,r[r.length-1]|=i>>8-s,e||(e=ss.en),e.join(r.map(t=>e.getWord(t)))}var bs=r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.version="random/5.0.0-beta.127"}),ws=(e(bs),bs.version,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.shuffled=function(t){for(var e=(t=t.slice()).length-1;e>0;e--){var r=Math.floor(Math.random()*(e+1)),n=t[e];t[e]=t[r],t[r]=n}return t}})),Es=(e(ws),ws.shuffled,r(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new m.Logger(bs.version);r.shuffled=ws.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(t){return n.throwError("no secure random source avaialble",m.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(t){(t<=0||t>1024||parseInt(String(t))!=t)&&n.throwArgumentError("invalid length","length",t);var e=new Uint8Array(t);return i.getRandomValues(e),O.arrayify(e)}})),_s=(e(Es),Es.shuffled),As=Es.randomBytes,Ss=r(function(t,e){!function(e){function r(t){return parseInt(t)===t}function n(t){if(!r(t.length))return!1;for(var e=0;e255)return!1;return!0}function i(t,e){if(t.buffer&&ArrayBuffer.isView(t)&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!n(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(r(t.length)&&n(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function s(t){return new Uint8Array(t)}function o(t,e,r,n,i){null==n&&null==i||(t=t.slice?t.slice(n,i):Array.prototype.slice.call(t,n,i)),e.set(t,r)}var a,h={toBytes:function(t){var e=[],r=0;for(t=encodeURI(t);r191&&n<224?(e.push(String.fromCharCode((31&n)<<6|63&t[r+1])),r+=2):(e.push(String.fromCharCode((15&n)<<12|(63&t[r+1])<<6|63&t[r+2])),r+=3)}return e.join("")}},l=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],r=0;r>4]+a[15&n])}return e.join("")}}),u={16:10,24:12,32:14},f=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],c=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],E=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],_=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],A=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],S=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],M=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function k(t){for(var e=[],r=0;r>2,this._Ke[r][e%4]=s[e],this._Kd[t-r][e%4]=s[e];for(var o,a=0,h=i;h>16&255]<<24^c[o>>8&255]<<16^c[255&o]<<8^c[o>>24&255]^f[a]<<24,a+=1,8!=i)for(e=1;e>8&255]<<8^c[o>>16&255]<<16^c[o>>24&255]<<24;for(e=i/2+1;e>2,d=h%4,this._Ke[l][d]=s[e],this._Kd[t-l][d]=s[e++],h++}for(var l=1;l>24&255]^A[o>>16&255]^S[o>>8&255]^M[255&o]},P.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var o=1;o>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[o][i];n=r.slice()}var a,h=s(16);for(i=0;i<4;i++)a=this._Ke[e][i],h[4*i]=255&(c[n[i]>>24&255]^a>>24),h[4*i+1]=255&(c[n[(i+1)%4]>>16&255]^a>>16),h[4*i+2]=255&(c[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(c[255&n[(i+3)%4]]^a);return h},P.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,r=[0,0,0,0],n=k(t),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var o=1;o>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^E[255&n[(i+1)%4]]^this._Kd[o][i];n=r.slice()}var a,h=s(16);for(i=0;i<4;i++)a=this._Kd[e][i],h[4*i]=255&(d[n[i]>>24&255]^a>>24),h[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^a>>16),h[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^a>>8),h[4*i+3]=255&(d[255&n[(i+1)%4]]^a);return h};var x=function(t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new P(t)};x.prototype.encrypt=function(t){if((t=i(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=s(t.length),r=s(16),n=0;n=0;--e)this._counter[e]=t%256,t>>=8},R.prototype.setBytes=function(t){if(16!=(t=i(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},R.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var C=function(t,e){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof R||(e=new R(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new P(t)};C.prototype.encrypt=function(t){for(var e=i(t,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=t.length-e,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,E=s,_=o,A=a,S=h,M=l;for(p=0;p<16;p++)m=f+4*p,u[p]=(255&t[m])<<24|(255&t[m+1])<<16|(255&t[m+2])<<8|255&t[m+3];for(p=16;p<64;p++)g=((d=u[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=u[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,u[p]=(g+u[p-7]|0)+(y+u[p-16]|0)|0;for(p=0;p<64;p++)g=(((_>>>6|_<<26)^(_>>>11|_<<21)^(_>>>25|_<<7))+(_&A^~_&S)|0)+(M+(e[p]+u[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,M=S,S=A,A=_,_=E+g|0,E=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,s=s+E|0,o=o+_|0,a=a+A|0,h=h+S|0,l=l+M|0,f+=64,c-=64}}f(t);var c,d=t.length%64,p=t.length/536870912|0,m=t.length<<3,g=d<56?56:120,y=t.slice(t.length-d,t.length);for(y.push(128),c=d+1;c>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),f(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,h>>>24&255,h>>>16&255,h>>>8&255,h>>>0&255,l>>>24&255,l>>>16&255,l>>>8&255,l>>>0&255]}function i(t,e,r){var i;t=t.length<=64?t:n(t);var s=64+e.length+4,o=new Array(s),a=new Array(64),h=[];for(i=0;i<64;i++)o[i]=54;for(i=0;i=s-4;t--){if(o[t]++,o[t]<=255)return;o[t]=0}}for(;r>=32;)l(),h=h.concat(n(a.concat(n(o)))),r-=32;return r>0&&(l(),h=h.concat(n(a.concat(n(o))).slice(0,r))),h}function s(t,e,r,n,i){var s;for(l(t,16*(2*r-1),i,0,16),s=0;s<2*r;s++)h(t,16*s,i,16),a(i,n),l(i,0,t,e+16*s,16);for(s=0;s>>32-e}function a(t,e){l(t,0,e,0,16);for(var r=8;r>0;r-=2)e[4]^=o(e[0]+e[12],7),e[8]^=o(e[4]+e[0],9),e[12]^=o(e[8]+e[4],13),e[0]^=o(e[12]+e[8],18),e[9]^=o(e[5]+e[1],7),e[13]^=o(e[9]+e[5],9),e[1]^=o(e[13]+e[9],13),e[5]^=o(e[1]+e[13],18),e[14]^=o(e[10]+e[6],7),e[2]^=o(e[14]+e[10],9),e[6]^=o(e[2]+e[14],13),e[10]^=o(e[6]+e[2],18),e[3]^=o(e[15]+e[11],7),e[7]^=o(e[3]+e[15],9),e[11]^=o(e[7]+e[3],13),e[15]^=o(e[11]+e[7],18),e[1]^=o(e[0]+e[3],7),e[2]^=o(e[1]+e[0],9),e[3]^=o(e[2]+e[1],13),e[0]^=o(e[3]+e[2],18),e[6]^=o(e[5]+e[4],7),e[7]^=o(e[6]+e[5],9),e[4]^=o(e[7]+e[6],13),e[5]^=o(e[4]+e[7],18),e[11]^=o(e[10]+e[9],7),e[8]^=o(e[11]+e[10],9),e[9]^=o(e[8]+e[11],13),e[10]^=o(e[9]+e[8],18),e[12]^=o(e[15]+e[14],7),e[13]^=o(e[12]+e[15],9),e[14]^=o(e[13]+e[12],13),e[15]^=o(e[14]+e[13],18);for(r=0;r<16;++r)t[r]+=e[r]}function h(t,e,r,n){for(var i=0;i=256)return!1}return!0}function f(t,e){var r=parseInt(t);if(t!=r)throw new Error("invalid "+e);return r}function c(t,e,n,o,a,c,d){if(!d)throw new Error("missing callback");if(n=f(n,"N"),o=f(o,"r"),a=f(a,"p"),c=f(c,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/o)throw new Error("N too large");if(o>r/128/a)throw new Error("r too large");if(!u(t))throw new Error("password must be an array or buffer");if(t=Array.prototype.slice.call(t),!u(e))throw new Error("salt must be an array or buffer");e=Array.prototype.slice.call(e);for(var p=i(t,e,128*a*o),m=new Uint32Array(32*a*o),g=0;gI&&(r=I);for(var e=0;eI&&(r=I);for(e=0;e>0&255),p.push(m[e]>>8&255),p.push(m[e]>>16&255),p.push(m[e]>>24&255);var g=i(t,p,c);return d(null,1,g)}R(C)};C()}t.exports=c}()});if(t.crypto&&crypto.getRandomValues){var Os=new Uint8Array(16);Cs=function(){return crypto.getRandomValues(Os),Os}}if(!Cs){var Fs=new Array(16);Cs=function(){for(var t,e=0;e<16;e++)0==(3&e)&&(t=4294967296*Math.random()),Fs[e]=t>>>((3&e)<<3)&255;return Fs}}for(var Ds=Cs,Ls=[],Us={},zs=0;zs<256;zs++)Ls[zs]=(zs+256).toString(16).substr(1),Us[Ls[zs]]=zs;function js(t,e){var r=e||0,n=Ls;return n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+"-"+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]+n[t[r++]]}var Hs=Ds(),qs=[1|Hs[0],Hs[1],Hs[2],Hs[3],Hs[4],Hs[5]],Ks=16383&(Hs[6]<<8|Hs[7]),Gs=0,Ws=0;function Vs(t,e,r){var n=e&&r||0;"string"==typeof t&&(e="binary"==t?new Array(16):null,t=null);var i=(t=t||{}).random||(t.rng||Ds)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e)for(var s=0;s<16;s++)e[n+s]=i[s];return e||js(i)}var Js=Vs;Js.v1=function(t,e,r){var n=e&&r||0,i=e||[],s=void 0!==(t=t||{}).clockseq?t.clockseq:Ks,o=void 0!==t.msecs?t.msecs:(new Date).getTime(),a=void 0!==t.nsecs?t.nsecs:Ws+1,h=o-Gs+(a-Ws)/1e4;if(h<0&&void 0===t.clockseq&&(s=s+1&16383),(h<0||o>Gs)&&void 0===t.nsecs&&(a=0),a>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Gs=o,Ws=a,Ks=s;var l=(1e4*(268435455&(o+=122192928e5))+a)%4294967296;i[n++]=l>>>24&255,i[n++]=l>>>16&255,i[n++]=l>>>8&255,i[n++]=255&l;var u=o/4294967296*1e4&268435455;i[n++]=u>>>8&255,i[n++]=255&u,i[n++]=u>>>24&15|16,i[n++]=u>>>16&255,i[n++]=s>>>8|128,i[n++]=255&s;for(var f=t.node||qs,c=0;c<6;c++)i[n+c]=f[c];return e||js(i)},Js.v4=Vs,Js.parse=function(t,e,r){var n=e&&r||0,i=0;for(e=e||[],t.toLowerCase().replace(/[0-9a-f]{2}/g,function(t){i<16&&(e[n+i++]=Us[t])});i<16;)e[n+i++]=0;return e},Js.unparse=js;var Zs=Js;class Xs extends lt{isKeystoreAccount(t){return!(!t||!t._isKeystoreAccount)}}function $s(t,e,r){let n=JSON.parse(t),i=Ps(e),s=function(t,e){let r=Ms(xs(n,"crypto/ciphertext"));if(P(function(t,e){return Dt(_([t,e]))}(t.slice(16,32),r)).substring(2)!==xs(n,"crypto/mac").toLowerCase())return e(new Error("invalid password")),null;let i=function(t,e){if("aes-128-ctr"===xs(n,"crypto/cipher")){let r=Ms(xs(n,"crypto/cipherparams/iv")),i=new Ss.Counter(r);return E(new Ss.ModeOfOperation.ctr(t,i).decrypt(e))}return null}(t.slice(0,16),r),s=t.slice(32,64);if(!i)return e(new Error("unsupported cipher")),null;let o=Xi(i);if(n.address){let t=n.address.toLowerCase();"0x"!==t.substring(0,2)&&(t="0x"+t);try{if($t(t)!==o)return e(new Error("address mismatch")),null}catch(t){}}let a={_isKeystoreAccount:!0,address:o,privateKey:P(i)};if("0.1"===xs(n,"x-ethers/version")){let t=Ms(xs(n,"x-ethers/mnemonicCiphertext")),r=Ms(xs(n,"x-ethers/mnemonicCounter")),i=new Ss.Counter(r),o=new Ss.ModeOfOperation.ctr(s,i),h=xs(n,"x-ethers/path")||ps,l=vs(E(o.decrypt(t))),u=ms.fromMnemonic(l).derivePath(h);if(u.privateKey!=a.privateKey)return e(new Error("mnemonic mismatch")),null;a.mnemonic=u.mnemonic,a.path=u.path}return new Xs(a)};return new Promise(function(t,e){let o=xs(n,"crypto/kdf");if(o&&"string"==typeof o)if("scrypt"===o.toLowerCase()){let o=Ms(xs(n,"crypto/kdfparams/salt")),a=parseInt(xs(n,"crypto/kdfparams/n")),h=parseInt(xs(n,"crypto/kdfparams/r")),l=parseInt(xs(n,"crypto/kdfparams/p"));if(!a||!h||!l)return void e(new Error("unsupported key-derivation function parameters"));if(0!=(a&a-1))return void e(new Error("unsupported key-derivation function parameter value for N"));if(32!==parseInt(xs(n,"crypto/kdfparams/dklen")))return void e(new Error("unsupported key-derivation derived-key length"));r&&r(0),Bs(i,o,a,h,l,64,function(n,i,o){if(n)n.progress=i,e(n);else if(o){o=E(o);let n=s(o,e);if(!n)return;r&&r(1),t(n)}else if(r)return r(i)})}else if("pbkdf2"===o.toLowerCase()){let r=Ms(xs(n,"crypto/kdfparams/salt")),o=null,a=xs(n,"crypto/kdfparams/prf");if("hmac-sha256"===a)o="sha256";else{if("hmac-sha512"!==a)return void e(new Error("unsupported prf"));o="sha512"}let h=parseInt(xs(n,"crypto/kdfparams/c")),l=parseInt(xs(n,"crypto/kdfparams/dklen"));if(32!==l)return void e(new Error("unsupported key-derivation derived-key length"));let u=E(ei(i,r,h,l,o)),f=s(u,e);if(!f)return;t(f)}else e(new Error("unsupported key-derivation function"));else e(new Error("unsupported key-derivation function"))})}function Qs(t,e,r){if(Is(t)){r&&r(0);let n=function(t,e){let r=JSON.parse(t);e=Ps(e);let n=$t(xs(r,"ethaddr")),i=Ms(xs(r,"encseed"));i&&i.length%16==0||Ts.throwArgumentError("invalid encseed","json",t);let s=E(ei(e,e,2e3,32,"sha256")).slice(0,16),o=i.slice(0,16),a=i.slice(16),h=E(new Ss.ModeOfOperation.cbc(s,o).decrypt(a));h=Ss.padding.pkcs7.strip(h);let l="";for(let t=0;te),rt(this,"address",Xi(this.publicKey)),this.address!==$t(t.address)&&Ys.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=t.mnemonic){let e=t.mnemonic,r=t.path||ps;rt(this,"_mnemonic",()=>e),rt(this,"path",t.path),Xi(ms.fromMnemonic(e).derivePath(r).privateKey)!==this.address&&Ys.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else rt(this,"_mnemonic",()=>null),rt(this,"path",null)}else{if(qi.isSigningKey(t))"secp256k1"!==t.curve&&Ys.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),rt(this,"_signingKey",()=>t);else{let e=new qi(t);rt(this,"_signingKey",()=>e)}rt(this,"_mnemonic",()=>null),rt(this,"path",null),rt(this,"address",Xi(this.publicKey))}var r;e&&!lr.isProvider(e)&&Ys.throwArgumentError("invalid provider","provider",e),rt(this,"provider",e||null)}get mnemonic(){return this._mnemonic()}get privateKey(){return this._signingKey().privateKey}get publicKey(){return this._signingKey().publicKey}getAddress(){return Promise.resolve(this.address)}connect(t){return new to(this,t)}signTransaction(t){return it(t).then(t=>{if(null!=t.from){if($t(t.from)!==this.address)throw new Error("transaction from address mismatch");delete t.from}let e=this._signingKey().signDigest(Dt(Qi(t)));return Qi(t,e)})}signMessage(t){return Promise.resolve(B(this._signingKey().signDigest(Ye(t))))}encrypt(t,e,r){if("function"!=typeof e||r||(r=e,e={}),r&&"function"!=typeof r)throw new Error("invalid callback");return e||(e={}),function(t,e,r,n){try{if($t(t.address)!==Xi(t.privateKey))throw new Error("address/privateKey mismatch");if(null!=t.mnemonic){if(ms.fromMnemonic(t.mnemonic).derivePath(t.path||ps).privateKey!=t.privateKey)throw new Error("mnemonic mismatch")}else if(null!=t.path)throw new Error("cannot specify path without mnemonic")}catch(t){return Promise.reject(t)}"function"!=typeof r||n||(n=r,r={}),r||(r={});let i=E(t.privateKey),s=Ps(e),o=null,a=t.path;t.mnemonic&&(o=E(ys(t.mnemonic)),a||(a=ps));let h=r.client;h||(h="ethers.js");let l=null;l=r.salt?E(r.salt):As(32);let u=null;if(r.iv){if(16!==(u=E(r.iv)).length)throw new Error("invalid iv")}else u=As(16);let f=null;if(r.uuid){if(16!==(f=E(r.uuid)).length)throw new Error("invalid uuid")}else f=As(16);let c=1<<17,d=8,p=1;return r.scrypt&&(r.scrypt.N&&(c=r.scrypt.N),r.scrypt.r&&(d=r.scrypt.r),r.scrypt.p&&(p=r.scrypt.p)),new Promise(function(e,r){n&&n(0),Bs(s,l,c,d,p,64,function(s,m,g){if(s)s.progress=m,r(s);else if(g){let r=(g=E(g)).slice(0,16),s=g.slice(16,32),m=g.slice(32,64),y=new Ss.Counter(u),v=E(new Ss.ModeOfOperation.ctr(r,y).encrypt(i)),b=Dt(_([s,v])),w={address:t.address.substring(2).toLowerCase(),id:Zs.v4({random:f}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:P(u).substring(2)},ciphertext:P(v).substring(2),kdf:"scrypt",kdfparams:{salt:P(l).substring(2),n:c,dklen:32,p:p,r:d},mac:b.substring(2)}};if(o){let t=As(16),e=new Ss.Counter(t),r=E(new Ss.ModeOfOperation.ctr(m,e).encrypt(o)),n=new Date,i=n.getUTCFullYear()+"-"+ks(n.getUTCMonth()+1,2)+"-"+ks(n.getUTCDate(),2)+"T"+ks(n.getUTCHours(),2)+"-"+ks(n.getUTCMinutes(),2)+"-"+ks(n.getUTCSeconds(),2)+".0Z";w["x-ethers"]={client:h,gethFilename:"UTC--"+i+"--"+w.address,mnemonicCounter:P(t).substring(2),mnemonicCiphertext:P(r).substring(2),path:a,version:"0.1"}}n&&n(1),e(JSON.stringify(w))}else if(n)return n(m)})})}(this,t,e,r)}static createRandom(t){let e=As(16);t||(t={}),t.extraEntropy&&(e=E(T(Dt(_([e,t.extraEntropy])),0,16)));let r=vs(e,t.locale);return to.fromMnemonic(r,t.path,t.locale)}static fromEncryptedJson(t,e,r){return Qs(t,e,r).then(t=>new to(t))}static fromMnemonic(t,e,r){return e||(e=ps),new to(ms.fromMnemonic(t,null,r).derivePath(e))}}const eo=new p("networks/5.0.0-beta.128");function ro(t){return function(e,r){null==r&&(r={});let n=[];if(e.InfuraProvider)try{n.push(new e.InfuraProvider(t,r.infura))}catch(t){}if(e.EtherscanProvider)try{n.push(new e.EtherscanProvider(t,r.etherscan))}catch(t){}if(e.NodesmithProvider)try{n.push(new e.NodesmithProvider(t,r.nodesmith))}catch(t){}if(e.AlchemyProvider)try{n.push(new e.AlchemyProvider(t,r.alchemy))}catch(t){}if(e.CloudflareProvider)try{n.push(new e.CloudflareProvider(t))}catch(t){}return 0===n.length?null:e.FallbackProvider?new e.FallbackProvider(n):n[0]}}function no(t,e){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(t,e):null}}const io={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:ro("homestead")},so={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:ro("ropsten")},oo={unspecified:{chainId:0,name:"unspecified"},homestead:io,mainnet:io,morden:{chainId:2,name:"morden"},ropsten:so,testnet:so,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:ro("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:ro("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:ro("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:no("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:no("https://web3.gastracker.io/morden","classicTestnet")}};function ao(t){if(null==t)return null;if("number"==typeof t){for(let e in oo){let r=oo[e];if(r.chainId===t)return{name:r.name,chainId:r.chainId,ensAddress:r.ensAddress||null,_defaultProvider:r._defaultProvider||null}}return{chainId:t,name:"unknown"}}if("string"==typeof t){let e=oo[t];return null==e?null:{name:e.name,chainId:e.chainId,ensAddress:e.ensAddress,_defaultProvider:e._defaultProvider||null}}let e=oo[t.name];return e?(0!==t.chainId&&t.chainId!==e.chainId&&eo.throwArgumentError("network chainId mismatch","network",t),{name:t.name,chainId:e.chainId,ensAddress:t.ensAddress||e.ensAddress||null,_defaultProvider:t._defaultProvider||e._defaultProvider||null}):("number"!=typeof t.chainId&&eo.throwArgumentError("invalid network chainId","network",t),t)}var ho=r(function(e,r){var n=function(t){function e(){this.fetch=!1,this.DOMException=t.DOMException}return e.prototype=t,new e}("undefined"!=typeof self?self:t);!function(t){!function(e){var r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(t){return t&&n.indexOf(Object.prototype.toString.call(t))>-1};function s(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function o(t){return"string"!=typeof t&&(t=String(t)),t}function a(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return r.iterable&&(e[Symbol.iterator]=function(){return e}),e}function h(t){this.map={},t instanceof h?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function l(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function u(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function f(t){var e=new FileReader,r=u(e);return e.readAsArrayBuffer(t),r}function c(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:r.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:r.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():r.arrayBuffer&&r.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=c(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||i(t))?this._bodyArrayBuffer=c(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var t=l(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?l(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var t,e,r,n=l(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=u(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function y(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new h(e.headers),this.url=e.url||"",this._initBody(t)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},y.error=function(){var t=new y(null,{status:0,statusText:""});return t.type="error",t};var v=[301,302,303,307,308];y.redirect=function(t,e){if(-1===v.indexOf(e))throw new RangeError("Invalid status code");return new y(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function b(t,n){return new Promise(function(i,s){var o=new m(t,n);if(o.signal&&o.signal.aborted)return s(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function l(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new h,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var n="response"in a?a.response:a.responseText;i(new y(n,r))},a.onerror=function(){s(new TypeError("Network request failed"))},a.ontimeout=function(){s(new TypeError("Network request failed"))},a.onabort=function(){s(new e.DOMException("Aborted","AbortError"))},a.open(o.method,o.url,!0),"include"===o.credentials?a.withCredentials=!0:"omit"===o.credentials&&(a.withCredentials=!1),"responseType"in a&&r.blob&&(a.responseType="blob"),o.headers.forEach(function(t,e){a.setRequestHeader(e,t)}),o.signal&&(o.signal.addEventListener("abort",l),a.onreadystatechange=function(){4===a.readyState&&o.signal.removeEventListener("abort",l)}),a.send(void 0===o._bodyInit?null:o._bodyInit)})}b.polyfill=!0,t.fetch||(t.fetch=b,t.Headers=h,t.Request=m,t.Response=y),e.Headers=h,e.Request=m,e.Response=y,e.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r}),lo=(ho.fetch,ho.Headers,ho.Request,ho.Response,r(function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){t=atob(t);for(var e=[],r=0;r0&&(o=t.timeout),t.headers)for(let e in t.headers)n[e.toLowerCase()]={key:e,value:String(t.headers[e])};if(null!=t.user&&null!=t.password){"https:"!==i.substring(0,6)&&!0!==t.allowInsecureAuthentication&&mo.throwError("basic authentication requires a secure https url",p.errors.INVALID_ARGUMENT,{argument:"url",url:i,user:t.user,password:"[REDACTED]"});let e=t.user+":"+t.password;n.authorization={key:"Authorization",value:"Basic "+co(Ae(e))}}}return new Promise(function(t,a){let h=null;o&&(h=setTimeout(()=>{null!=h&&(h=null,a(mo.makeError("timeout",p.errors.TIMEOUT,{timeout:o})))},o));let l=()=>{null!=h&&(clearTimeout(h),h=null)};e&&(s.method="POST",s.body=e,n["content-type"]={key:"Content-Type",value:"application/json"});let u={};return Object.keys(n).forEach(t=>{let e=n[t];u[e.key]=e.value}),s.headers=u,ho(i,s).then(t=>t.text().then(e=>(t.ok||mo.throwError("bad response",p.errors.SERVER_ERROR,{status:t.status,body:e,type:t.type,url:t.url}),e))).then(t=>{let e=null;try{e=JSON.parse(t)}catch(e){mo.throwError("invalid JSON",p.errors.SERVER_ERROR,{body:t,error:e,url:i})}if(r)try{e=r(e)}catch(t){mo.throwError("processing response error",p.errors.SERVER_ERROR,{body:e,error:t})}return e},t=>{throw t}).then(e=>{l(),t(e)},t=>{l(),a(t)})})}function yo(t,e){return e||(e={}),null==(e=ot(e)).floor&&(e.floor=0),null==e.ceiling&&(e.ceiling=1e4),null==e.interval&&(e.interval=250),new Promise(function(r,n){let i=null,s=!1,o=()=>!s&&(s=!0,i&&clearTimeout(i),!0);e.timeout&&(i=setTimeout(()=>{o()&&n(new Error("timeout"))},e.timeout));let a=e.retryLimit,h=0;!function i(){return t().then(function(t){if(void 0!==t)o()&&r(t);else if(e.onceBlock)e.onceBlock.once("block",i);else if(!s){if(++h>a)return void(o()&&n(new Error("retry limit reached")));let t=e.interval*parseInt(String(Math.random()*Math.pow(2,h)));te.ceiling&&(t=e.ceiling),setTimeout(i,t)}return null},function(t){o()&&n(t)})}()})}const vo="providers/5.0.0-beta.140",bo=new p(vo);class wo{constructor(){bo.checkNew(new.target,wo),this.formats=this.getDefaultFormats()}getDefaultFormats(){let t={},e=this.address.bind(this),r=this.bigNumber.bind(this),n=this.blockTag.bind(this),i=this.data.bind(this),s=this.hash.bind(this),o=this.hex.bind(this),a=this.number.bind(this);return t.transaction={hash:s,blockHash:wo.allowNull(s,null),blockNumber:wo.allowNull(a,null),transactionIndex:wo.allowNull(a,null),confirmations:wo.allowNull(a,null),from:e,gasPrice:r,gasLimit:r,to:wo.allowNull(e,null),value:r,nonce:a,data:i,r:wo.allowNull(this.uint256),s:wo.allowNull(this.uint256),v:wo.allowNull(a),creates:wo.allowNull(e,null),raw:wo.allowNull(i)},t.transactionRequest={from:wo.allowNull(e),nonce:wo.allowNull(a),gasLimit:wo.allowNull(r),gasPrice:wo.allowNull(r),to:wo.allowNull(e),value:wo.allowNull(r),data:wo.allowNull(t=>this.data(t,!0))},t.receiptLog={transactionLogIndex:wo.allowNull(a),transactionIndex:a,blockNumber:a,transactionHash:s,address:e,topics:wo.arrayOf(s),data:i,logIndex:a,blockHash:s},t.receipt={to:wo.allowNull(this.address),from:wo.allowNull(this.address),contractAddress:wo.allowNull(e,null),transactionIndex:a,root:wo.allowNull(s),gasUsed:r,logsBloom:wo.allowNull(i),blockHash:s,transactionHash:s,logs:wo.arrayOf(this.receiptLog.bind(this)),blockNumber:a,confirmations:wo.allowNull(a,null),cumulativeGasUsed:r,status:wo.allowNull(a)},t.block={hash:s,parentHash:s,number:a,timestamp:a,nonce:wo.allowNull(o),difficulty:this.difficulty.bind(this),gasLimit:r,gasUsed:r,miner:e,extraData:i,transactions:wo.allowNull(wo.arrayOf(s))},t.blockWithTransactions=ot(t.block),t.blockWithTransactions.transactions=wo.allowNull(wo.arrayOf(this.transactionResponse.bind(this))),t.filter={fromBlock:wo.allowNull(n,void 0),toBlock:wo.allowNull(n,void 0),blockHash:wo.allowNull(s,void 0),address:wo.allowNull(e,void 0),topics:wo.allowNull(this.topics.bind(this),void 0)},t.filterLog={blockNumber:wo.allowNull(a),blockHash:wo.allowNull(s),transactionIndex:a,removed:wo.allowNull(this.boolean.bind(this)),address:e,data:wo.allowFalsish(i,"0x"),topics:wo.arrayOf(s),transactionHash:s,logIndex:a},t}number(t){return U.from(t).toNumber()}bigNumber(t){return U.from(t)}boolean(t){if("boolean"==typeof t)return t;if("string"==typeof t){if("true"===(t=t.toLowerCase()))return!0;if("false"===t)return!1}throw new Error("invaid boolean - "+t)}hex(t,e){return"string"==typeof t&&(e||"0x"===t.substring(0,2)||(t="0x"+t),M(t))?t.toLowerCase():bo.throwArgumentError("invalid hash","value",t)}data(t,e){let r=this.hex(t,e);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+t);return r}address(t){return $t(t)}callAddress(t){if(!M(t,32))return null;let e=$t(T(t,12));return e===ue?null:e}contractAddress(t){return Qt(t)}blockTag(t){if(null==t)return"latest";if("earliest"===t)return"0x0";if("latest"===t||"pending"===t)return t;if("number"==typeof t||M(t))return N(t);throw new Error("invalid blockTag")}hash(t,e){let r=this.hex(t,e);return 32!==x(r)?bo.throwArgumentError("invalid hash","value",t):r}difficulty(t){let e=U.from(t);try{return e.toNumber()}catch(t){}return null}uint256(t){if(!M(t))throw new Error("invalid uint256");return R(t,32)}_block(t,e){return null!=t.author&&null==t.miner&&(t.miner=t.author),wo.check(e,t)}block(t){return this._block(t,this.formats.block)}blockWithTransactions(t){return this._block(t,this.formats.blockWithTransactions)}transactionRequest(t){return wo.check(this.formats.transactionRequest,t)}transactionResponse(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&U.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));let e=wo.check(this.formats.transaction,t),r=t.networkId;return null!=t.chainId&&null==r&&null==e.v&&(r=t.chainId),M(r)&&(r=U.from(r).toNumber()),"number"!=typeof r&&null!=e.v&&((r=(e.v-35)/2)<0&&(r=0),r=parseInt(r)),"number"!=typeof r&&(r=0),e.networkId=r,e.blockHash&&"x"===e.blockHash.replace(/0/g,"")&&(e.blockHash=null),e}transaction(t){return Yi(t)}receiptLog(t){return wo.check(this.formats.receiptLog,t)}receipt(t){let e=wo.check(this.formats.receipt,t);return e.logs.forEach((t,e)=>{null==t.transactionLogIndex&&(t.transactionLogIndex=e)}),null!=t.status&&(e.byzantium=!0),e}topics(t){return Array.isArray(t)?t.map(t=>this.topics(t)):null!=t?this.hash(t,!0):null}filter(t){return wo.check(this.formats.filter,t)}filterLog(t){return wo.check(this.formats.filterLog,t)}static check(t,e){let r={};for(let n in t)try{let i=t[n](e[n]);void 0!==i&&(r[n]=i)}catch(t){throw t.checkKey=n,t.checkValue=e[n],t}return r}static allowNull(t,e){return function(r){return null==r?e:t(r)}}static allowFalsish(t,e){return function(r){return r?t(r):e}}static arrayOf(t){return function(e){if(!Array.isArray(e))throw new Error("not an array");let r=[];return e.forEach(function(e){r.push(t(e))}),r}}}const Eo=new p(vo);function _o(t){return null==t?"null":(32!==x(t)&&Eo.throwArgumentError("invalid topic","topic",t),t.toLowerCase())}function Ao(t){for(t=t.slice();null==t[t.length-1];)t.pop();return t.map(t=>{if(Array.isArray(t)){let e={};t.forEach(t=>{e[_o(t)]=!0});let r=Object.keys(e);return r.sort(),r.join("|")}return _o(t)}).join("&")}function So(t){if("string"==typeof t){if(32===x(t=t.toLowerCase()))return"tx:"+t;if(-1===t.indexOf(":"))return t}else{if(Array.isArray(t))return"filter:*:"+Ao(t);if(hr.isForkEvent(t))throw Eo.warn("not implemented"),new Error("not implemented");if(t&&"object"==typeof t)return"filter:"+(t.address||"*")+":"+Ao(t.topics||[])}throw new Error("invalid event - "+t)}function Mo(){return(new Date).getTime()}class ko{constructor(t,e,r){rt(this,"tag",t),rt(this,"listener",e),rt(this,"once",r)}pollable(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag}}let Po=null,xo=1;class To extends lr{constructor(t){if(Eo.checkNew(new.target,lr),super(),this.formatter=new.target.getFormatter(),t instanceof Promise)rt(this,"ready",t.then(t=>(rt(this,"_network",t),t))),this.ready.catch(t=>{});else{let e=nt(new.target,"getNetwork")(t);e?(rt(this,"_network",e),rt(this,"ready",Promise.resolve(this._network))):Eo.throwArgumentError("invalid network","network",t)}this._lastBlockNumber=-2,this._events=[],this._pollingInterval=4e3,this._emitted={block:-2},this._fastQueryDate=0}static getFormatter(){return null==Po&&(Po=new wo),Po}static getNetwork(t){return ao(null==t?"homestead":t)}poll(){let t=xo++;this.emit("willPoll",t);let e=[];this.getBlockNumber().then(t=>{if(this._setFastBlockNumber(t),t!==this._lastBlockNumber){-2===this._emitted.block&&(this._emitted.block=t-1);for(let e=this._emitted.block+1;e<=t;e++)this.emit("block",e);return this._emitted.block!==t&&(this._emitted.block=t,Object.keys(this._emitted).forEach(e=>{if("block"===e)return;let r=this._emitted[e];"pending"!==r&&t-r>12&&delete this._emitted[e]})),-2===this._lastBlockNumber&&(this._lastBlockNumber=t-1),this._events.forEach(r=>{let n=r.tag.split(":");switch(n[0]){case"tx":{let t=n[1],r=this.getTransactionReceipt(t).then(e=>e&&null!=e.blockNumber?(this._emitted["t:"+t]=e.blockNumber,this.emit(t,e),null):null).catch(t=>{this.emit("error",t)});e.push(r);break}case"filter":{let r=function(t){return t.split(/&/g).map(t=>t.split("|").map(t=>"null"===t?null:t))}(n[2]),i={address:n[1],fromBlock:this._lastBlockNumber+1,toBlock:t,topics:r};i.address||delete i.address;let s=this.getLogs(i).then(t=>{if(0!==t.length)return t.forEach(t=>{this._emitted["b:"+t.blockHash]=t.blockNumber,this._emitted["t:"+t.transactionHash]=t.blockNumber,this.emit(i,t)}),null}).catch(t=>{this.emit("error",t)});e.push(s);break}}}),this._lastBlockNumber=t,null}}).catch(t=>{}),Promise.all(e).then(()=>{this.emit("didPoll",t)})}resetEventsBlock(t){this._lastBlockNumber=t-1,this.polling&&this.poll()}get network(){return this._network}getNetwork(){return this.ready}get blockNumber(){return this._fastBlockNumber}get polling(){return null!=this._poller}set polling(t){setTimeout(()=>{t&&!this._poller?this._poller=setInterval(this.poll.bind(this),this.pollingInterval):!t&&this._poller&&(clearInterval(this._poller),this._poller=null)},0)}get pollingInterval(){return this._pollingInterval}set pollingInterval(t){if("number"!=typeof t||t<=0||parseInt(String(t))!=t)throw new Error("invalid polling interval");this._pollingInterval=t,this._poller&&(clearInterval(this._poller),this._poller=setInterval(()=>{this.poll()},this._pollingInterval))}_getFastBlockNumber(){let t=Mo();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(t=>((null==this._fastBlockNumber||t>this._fastBlockNumber)&&(this._fastBlockNumber=t),this._fastBlockNumber))),this._fastBlockNumberPromise}_setFastBlockNumber(t){null!=this._fastBlockNumber&&tthis._fastBlockNumber)&&(this._fastBlockNumber=t,this._fastBlockNumberPromise=Promise.resolve(t)))}waitForTransaction(t,e){return null==e&&(e=1),0===e?this.getTransactionReceipt(t):new Promise(r=>{let n=i=>{i.confirmations(Object.keys(e).forEach(t=>{e[t]=e[t]()}),it(e).then(e=>this.perform(t,e))))}getBlockNumber(){return this._runPerform("getBlockNumber",{}).then(t=>{let e=parseInt(t);if(e!=t)throw new Error("invalid response - getBlockNumber");return this._setFastBlockNumber(e),e})}getGasPrice(){return this._runPerform("getGasPrice",{}).then(t=>U.from(t))}getBalance(t,e){return this._runPerform("getBalance",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t))}getTransactionCount(t,e){return this._runPerform("getTransactionCount",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>U.from(t).toNumber())}getCode(t,e){return this._runPerform("getCode",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}getStorageAt(t,e,r){return this._runPerform("getStorageAt",{address:()=>this._getAddress(t),blockTag:()=>this._getBlockTag(r),position:()=>Promise.resolve(e).then(t=>N(t))}).then(t=>P(t))}_wrapTransaction(t,e){if(null!=e&&32!==x(e))throw new Error("invalid response - sendTransaction");let r=t;return null!=e&&t.hash!==e&&Eo.throwError("Transaction hash mismatch from Provider.sendTransaction.",p.errors.UNKNOWN_ERROR,{expectedHash:t.hash,returnedHash:e}),r.wait=e=>(0!==e&&(this._emitted["t:"+t.hash]="pending"),this.waitForTransaction(t.hash,e).then(r=>null==r&&0===e?null:(this._emitted["t:"+t.hash]=r.blockNumber,0===r.status&&Eo.throwError("transaction failed",p.errors.CALL_EXCEPTION,{transactionHash:t.hash,transaction:t,receipt:r}),r))),r}sendTransaction(t){return this._runPerform("sendTransaction",{signedTransaction:()=>Promise.resolve(t).then(t=>P(t))}).then(e=>this._wrapTransaction(this.formatter.transaction(t),e),e=>{throw e.transaction=this.formatter.transaction(t),e.transaction.hash&&(e.transactionHash=e.transaction.hash),e})}_getTransactionRequest(t){return Promise.resolve(t).then(t=>{let e={};return["from","to"].forEach(r=>{null!=t[r]&&(e[r]=Promise.resolve(t[r]).then(t=>t?this._getAddress(t):null))}),["data","gasLimit","gasPrice","value"].forEach(r=>{null!=t[r]&&(e[r]=t[r])}),it(e).then(t=>this.formatter.transactionRequest(t))})}_getFilter(t){return Promise.resolve(t).then(t=>{let e={};return null!=t.address&&(e.address=this._getAddress(t.address)),t.topics&&(e.topics=t.topics),null!=t.blockHash&&(e.blockHash=t.blockHash),["fromBlock","toBlock"].forEach(r=>{null!=t[r]&&(e[r]=this._getBlockTag(t[r]))}),it(e).then(t=>this.formatter.filter(t))})}call(t,e){return this._runPerform("call",{transaction:()=>this._getTransactionRequest(t),blockTag:()=>this._getBlockTag(e)}).then(t=>P(t))}estimateGas(t){return this._runPerform("estimateGas",{transaction:()=>this._getTransactionRequest(t)}).then(t=>U.from(t))}_getAddress(t){return this.resolveName(t).then(e=>(null==e&&Eo.throwError("ENS name not configured",p.errors.UNSUPPORTED_OPERATION,{operation:`resolveName(${JSON.stringify(t)})`}),e))}_getBlock(t,e){return this.ready.then(()=>this._getBlockTag(t).then(t=>{let r={includeTransactions:!!e},n=-128;if(M(t,32))r.blockHash=t;else try{r.blockTag=this.formatter.blockTag(t),M(r.blockTag)&&(n=parseInt(r.blockTag.substring(2),16))}catch(e){Eo.throwArgumentError("invalid block hash or block tag","blockHashOrBlockTag",t)}return yo(()=>this.perform("getBlock",r).then(t=>{if(null!=t)return e?this.formatter.blockWithTransactions(t):this.formatter.block(t)}),{onceBlock:this})}))}getBlock(t){return this._getBlock(t,!1)}getBlockWithTransactions(t){return this._getBlock(t,!0)}getTransaction(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return yo(()=>this.perform("getTransaction",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;let r=this.formatter.transactionResponse(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,this._wrapTransaction(r)});return this._wrapTransaction(r)}),{onceBlock:this})}))}getTransactionReceipt(t){return this.ready.then(()=>it({transactionHash:t}).then(({transactionHash:t})=>{let e={transactionHash:this.formatter.hash(t,!0)};return yo(()=>this.perform("getTransactionReceipt",e).then(e=>{if(null==e)return null==this._emitted["t:"+t]?null:void 0;if(null==e.blockHash)return;let r=this.formatter.receipt(e);if(null==r.blockNumber)r.confirmations=0;else if(null==r.confirmations)return this._getFastBlockNumber().then(t=>{let e=t-r.blockNumber+1;return e<=0&&(e=1),r.confirmations=e,r});return r}),{onceBlock:this})}))}getLogs(t){return this._runPerform("getLogs",{filter:()=>this._getFilter(t)}).then(t=>wo.arrayOf(this.formatter.filterLog.bind(this.formatter))(t))}getEtherPrice(){return this._runPerform("getEtherPrice",{}).then(t=>t)}_getBlockTag(t){return t instanceof Promise?t.then(t=>this._getBlockTag(t)):"number"==typeof t&&t<0?(t%1&&Eo.throwArgumentError("invalid BlockTag","blockTag",t),this._getFastBlockNumber().then(e=>((e+=t)<0&&(e=0),this.formatter.blockTag(e)))):Promise.resolve(this.formatter.blockTag(t))}_getResolver(t){return this.getNetwork().then(e=>{e.ensAddress||Eo.throwError("network does support ENS",p.errors.UNSUPPORTED_OPERATION,{operation:"ENS",network:e.name});let r="0x0178b8bf"+Xe(t).substring(2),n={to:e.ensAddress,data:r};return this.call(n).then(t=>this.formatter.callAddress(t))})}resolveName(t){if(t instanceof Promise)return t.then(t=>this.resolveName(t));try{return Promise.resolve(this.formatter.address(t))}catch(t){}return this._getResolver(t).then(e=>{if(!e)return null;let r={to:e,data:"0x3b3b57de"+Xe(t).substring(2)};return this.call(r).then(t=>this.formatter.callAddress(t))})}lookupAddress(t){if(t instanceof Promise)return t.then(t=>this.lookupAddress(t));let e=(t=this.formatter.address(t)).substring(2)+".addr.reverse";return this._getResolver(e).then(r=>{if(!r)return null;let n="0x691f3431"+Xe(e).substring(2);return this.call({to:r,data:n}).then(e=>{let r=E(e);if(r.length<32||!U.from(r.slice(0,32)).eq(32))return null;if((r=r.slice(32)).length<32)return null;let n=U.from(r.slice(0,32)).toNumber();if(n>(r=r.slice(32)).length)return null;let i=ke(r.slice(0,n));return this.resolveName(i).then(e=>e!=t?null:i)})})}perform(t,e){return Eo.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){console.log("WARNING: this provider does not support pending events")}_stopPending(){}_checkPolling(){this.polling=this._events.filter(t=>t.pollable()).length>0}_addEventListener(t,e,r){return this._events.push(new ko(So(t),e,r)),"pending"===t&&this._startPending(),this._checkPolling(),this}on(t,e){return this._addEventListener(t,e,!1)}once(t,e){return this._addEventListener(t,e,!0)}emit(t,...e){let r=!1,n=So(t);return this._events=this._events.filter(t=>t.tag!==n||(setTimeout(()=>{t.listener.apply(this,e)},0),r=!0,!t.once)),this._checkPolling(),r}listenerCount(t){if(!t)return this._events.length;let e=So(t);return this._events.filter(t=>t.tag===e).length}listeners(t){if(null==t)return this._events.map(t=>t.listener);let e=So(t);return this._events.filter(t=>t.tag===e).map(t=>t.listener)}off(t,e){if(null==e)return this.removeAllListeners(t);let r=!1,n=So(t);return this._events=this._events.filter(t=>t.tag!==n||t.listener!=e||(!!r||(r=!0,!1))),"pending"===t&&0===this.listenerCount("pending")&&this._stopPending(),this._checkPolling(),this}removeAllListeners(t){if(null==t)this._events=[],this._stopPending();else{let e=So(t);this._events=this._events.filter(t=>t.tag!==e),"pending"===t&&this._stopPending()}return this._checkPolling(),this}}const No=new p(vo);function Io(t){if(t.error){let e=new Error(t.error.message);throw e.code=t.error.code,e.data=t.error.data,e}return t.result}function Ro(t){return t?t.toLowerCase():t}const Co={};class Bo extends cr{constructor(t,e,r){if(No.checkNew(new.target,Bo),super(),t!==Co)throw new Error("do not call the JsonRpcSigner constructor directly; use provider.getSigner");rt(this,"provider",e),null==r&&(r=0),"string"==typeof r?(rt(this,"_address",this.provider.formatter.address(r)),rt(this,"_index",null)):"number"==typeof r?(rt(this,"_index",r),rt(this,"_address",null)):No.throwArgumentError("invalid address or index","addressOrIndex",r)}connect(t){return No.throwError("cannot alter JSON-RPC Signer connection",p.errors.UNSUPPORTED_OPERATION,{operation:"connect"})}connectUnchecked(){return new Oo(Co,this.provider,this._address||this._index)}getAddress(){return this._address?Promise.resolve(this._address):this.provider.send("eth_accounts",[]).then(t=>(t.length<=this._index&&No.throwError("unknown account #"+this._index,p.errors.UNSUPPORTED_OPERATION,{operation:"getAddress"}),this.provider.formatter.address(t[this._index])))}sendUncheckedTransaction(t){t=ot(t);let e=this.getAddress().then(t=>(t&&(t=t.toLowerCase()),t));if(null==t.gasLimit){let r=ot(t);r.from=e,t.gasLimit=this.provider.estimateGas(r)}return Promise.all([it(t),e]).then(t=>{let e=t[0],r=this.provider.constructor.hexlifyTransaction(e);return r.from=t[1],this.provider.send("eth_sendTransaction",[r]).then(t=>t,t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>=0&&No.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{transaction:e}),t.responseText.indexOf("nonce too low")>=0&&No.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{transaction:e}),t.responseText.indexOf("replacement transaction underpriced")>=0&&No.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{transaction:e})),t})})}signTransaction(t){return No.throwError("signing transactions is unsupported",p.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})}sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>yo(()=>this.provider.getTransaction(t).then(e=>{if(null!==e)return this.provider._wrapTransaction(e,t)}),{onceBlock:this.provider}).catch(e=>{throw e.transactionHash=t,e}))}signMessage(t){let e="string"==typeof t?Ae(t):t;return this.getAddress().then(t=>this.provider.send("eth_sign",[t.toLowerCase(),P(e)]))}unlock(t){let e=this.provider;return this.getAddress().then(function(r){return e.send("personal_unlockAccount",[r.toLowerCase(),t,null])})}}class Oo extends Bo{sendTransaction(t){return this.sendUncheckedTransaction(t).then(t=>({hash:t,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:e=>this.provider.waitForTransaction(t,e)}))}}const Fo={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};class Do extends To{constructor(t,e){if(No.checkNew(new.target,Do),"string"==typeof t&&null===e&&ao(t)&&(e=t,t=null),e)super(e);else{super(new Promise((t,e)=>{setTimeout(()=>{this.send("eth_chainId",[]).then(e=>{t(ao(U.from(e).toNumber()))}).catch(r=>{this.send("net_version",[]).then(e=>{t(ao(U.from(e).toNumber()))}).catch(t=>{e(No.makeError("could not detect network",p.errors.NETWORK_ERROR))})})})}))}t||(t="http://localhost:8545"),this.connection="string"==typeof t?{url:t}:t,this._nextId=42}getSigner(t){return new Bo(Co,this,t)}getUncheckedSigner(t){return this.getSigner(t).connectUnchecked()}listAccounts(){return this.send("eth_accounts",[]).then(t=>t.map(t=>this.formatter.address(t)))}send(t,e){let r={method:t,params:e,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:ht(r),provider:this}),go(this.connection,JSON.stringify(r),Io).then(t=>(this.emit("debug",{action:"response",request:r,response:t,provider:this}),t))}perform(t,e){switch(t){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[Ro(e.address),e.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[Ro(e.address),e.blockTag]);case"getCode":return this.send("eth_getCode",[Ro(e.address),e.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[Ro(e.address),e.position,e.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[e.signedTransaction]).catch(t=>{throw t.responseText&&(t.responseText.indexOf("insufficient funds")>0&&No.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("nonce too low")>0&&No.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("replacement transaction underpriced")>0&&No.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":return e.blockTag?this.send("eth_getBlockByNumber",[e.blockTag,!!e.includeTransactions]):e.blockHash?this.send("eth_getBlockByHash",[e.blockHash,!!e.includeTransactions]):No.throwArgumentError("invalid block tag or block hash","params",e);case"getTransaction":return this.send("eth_getTransactionByHash",[e.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[e.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(e.transaction,{from:!0}),e.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(e.transaction,{from:!0})]);case"getLogs":return e.filter&&null!=e.filter.address&&(e.filter.address=Ro(e.filter.address)),this.send("eth_getLogs",[e.filter])}return No.throwError(t+" not implemented",p.errors.NOT_IMPLEMENTED,{operation:t})}_startPending(){if(null!=this._pendingFilter)return;let t=this,e=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=e,e.then(function(r){return function n(){t.send("eth_getFilterChanges",[r]).then(function(r){if(t._pendingFilter!=e)return null;let n=Promise.resolve();return r.forEach(function(e){t._emitted["t:"+e.toLowerCase()]="pending",n=n.then(function(){return t.getTransaction(e).then(function(e){return t.emit("pending",e),null})})}),n.then(function(){return t=1e3,new Promise(function(e){setTimeout(function(){e()},t)});var t})}).then(function(){if(t._pendingFilter==e)return setTimeout(function(){n()},0),null;t.send("eth_uninstallFilter",[r])}).catch(t=>{})}(),r}).catch(t=>{})}_stopPending(){this._pendingFilter=null}static hexlifyTransaction(t,e){let r=ot(Fo);if(e)for(let t in e)e[t]&&(r[t]=!0);st(t,r);let n={};return["gasLimit","gasPrice","nonce","value"].forEach(function(e){if(null==t[e])return;let r=N(t[e]);"gasLimit"===e&&(e="gas"),n[e]=r}),["from","to","data"].forEach(function(e){null!=t[e]&&(n[e]=P(t[e]))}),n}}const Lo=new p(vo);class Uo extends Do{constructor(t,e){Lo.checkAbstract(new.target,Uo),t=nt(new.target,"getNetwork")(t),e=nt(new.target,"getApiKey")(e),super(nt(new.target,"getUrl")(t,e),t),rt(this,"apiKey",e)}_startPending(){Lo.warn("WARNING: API provider does not support pending filters")}getSigner(t){return Lo.throwError("API provider does not support signing",p.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null}listAccounts(){return Promise.resolve([])}static getNetwork(t){return ao(null==t?"homestead":t)}static getApiKey(t){return t}static getUrl(t,e){return Lo.throwError("not implemented; sub-classes must override getUrl",p.errors.NOT_IMPLEMENTED,{operation:"getUrl"})}}const zo=new p(vo),jo="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";const Ho=new p(vo);const qo=new p(vo);function Ko(t){let e=[];for(let r in t){if(null==t[r])continue;let n=P(t[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=N(n)),e.push(r+"="+n)}return e.join("&")}function Go(t){if(0==t.status&&("No records found"===t.message||"No transactions found"===t.message))return t.result;if(1!=t.status||"OK"!=t.message){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}return t.result}function Wo(t){if("2.0"!=t.jsonrpc){let e=new Error("invalid response");throw e.result=JSON.stringify(t),e}if(t.error){let e=new Error(t.error.message||"unknown error");throw t.error.code&&(e.code=t.error.code),t.error.data&&(e.data=t.error.data),e}return t.result}function Vo(t){if("pending"===t)throw new Error("pending not supported");return"latest"===t?t:parseInt(t.substring(2),16)}class Jo extends To{constructor(t,e){qo.checkNew(new.target,Jo),super(t);let r="invalid";this.network&&(r=this.network.name);let n=null;switch(r){case"homestead":n="https://api.etherscan.io";break;case"ropsten":n="https://api-ropsten.etherscan.io";break;case"rinkeby":n="https://api-rinkeby.etherscan.io";break;case"kovan":n="https://api-kovan.etherscan.io";break;case"goerli":n="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}rt(this,"baseUrl",n),rt(this,"apiKey",e)}perform(t,e){let r=this.baseUrl,n="";this.apiKey&&(n+="&apikey="+this.apiKey);let i=(t,e)=>(this.emit("debug",{action:"request",request:t,provider:this}),go(t,null,e||Wo).then(e=>(this.emit("debug",{action:"response",request:t,response:ht(e),provider:this}),e)));switch(t){case"getBlockNumber":return i(r+="/api?module=proxy&action=eth_blockNumber"+n);case"getGasPrice":return i(r+="/api?module=proxy&action=eth_gasPrice"+n);case"getBalance":return r+="/api?module=account&action=balance&address="+e.address,i(r+="&tag="+e.blockTag+n,Go);case"getTransactionCount":return r+="/api?module=proxy&action=eth_getTransactionCount&address="+e.address,i(r+="&tag="+e.blockTag+n);case"getCode":return r+="/api?module=proxy&action=eth_getCode&address="+e.address,i(r+="&tag="+e.blockTag+n,Wo);case"getStorageAt":return r+="/api?module=proxy&action=eth_getStorageAt&address="+e.address,r+="&position="+e.position,i(r+="&tag="+e.blockTag+n,Wo);case"sendTransaction":return r+="/api?module=proxy&action=eth_sendRawTransaction&hex="+e.signedTransaction,i(r+=n).catch(t=>{throw t.responseText&&(t.responseText.toLowerCase().indexOf("insufficient funds")>=0&&qo.throwError("insufficient funds",p.errors.INSUFFICIENT_FUNDS,{}),t.responseText.indexOf("same hash was already imported")>=0&&qo.throwError("nonce has already been used",p.errors.NONCE_EXPIRED,{}),t.responseText.indexOf("another transaction with same nonce")>=0&&qo.throwError("replacement fee too low",p.errors.REPLACEMENT_UNDERPRICED,{})),t});case"getBlock":if(e.blockTag)return r+="/api?module=proxy&action=eth_getBlockByNumber&tag="+e.blockTag,e.includeTransactions?r+="&boolean=true":r+="&boolean=false",i(r+=n);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return r+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+e.transactionHash,i(r+=n);case"getTransactionReceipt":return r+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+e.transactionHash,i(r+=n);case"call":{let t=Ko(e.transaction);if(t&&(t="&"+t),r+="/api?module=proxy&action=eth_call"+t,"latest"!==e.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return i(r+=n)}case"estimateGas":{let t=Ko(e.transaction);return t&&(t="&"+t),r+="/api?module=proxy&action=eth_estimateGas&"+t,i(r+=n)}case"getLogs":r+="/api?module=logs&action=getLogs";try{if(e.filter.fromBlock&&(r+="&fromBlock="+Vo(e.filter.fromBlock)),e.filter.toBlock&&(r+="&toBlock="+Vo(e.filter.toBlock)),e.filter.address&&(r+="&address="+e.filter.address),e.filter.topics&&e.filter.topics.length>0){if(e.filter.topics.length>1)throw new Error("unsupported topic format");let t=e.filter.topics[0];if("string"!=typeof t||66!==t.length)throw new Error("unsupported topic0 format");r+="&topic0="+t}}catch(t){return Promise.reject(t)}let s=this;return i(r+=n,Go).then(function(t){let e={},r=Promise.resolve();return t.forEach(function(t){r=r.then(function(){return null!=t.blockHash?null:(t.blockHash=e[t.transactionHash],null==t.blockHash?s.getTransaction(t.transactionHash).then(function(r){return e[t.transactionHash]=r.blockHash,t.blockHash=r.blockHash,null}):null)})}),r.then(function(){return t})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(r+="/api?module=stats&action=ethprice",i(r+=n,Go).then(function(t){return parseFloat(t.ethusd)}))}return super.perform(t,e)}getHistory(t,e,r){let n=this.baseUrl,i="";return this.apiKey&&(i+="&apikey="+this.apiKey),null==e&&(e=0),null==r&&(r=99999999),this.resolveName(t).then(t=>(n+="/api?module=account&action=txlist&address="+t,n+="&startblock="+e,n+="&endblock="+r,n+="&sort=asc"+i,this.emit("debug",{action:"request",request:n,provider:this}),go(n,null,Go).then(t=>{this.emit("debug",{action:"response",request:n,response:ht(t),provider:this});let e=[];return t.forEach(t=>{["contractAddress","to"].forEach(function(e){""==t[e]&&delete t[e]}),null==t.creates&&null!=t.contractAddress&&(t.creates=t.contractAddress);let r=this.formatter.transactionResponse(t);t.timeStamp&&(r.timestamp=parseInt(t.timeStamp)),e.push(r)}),e})))}}const Zo=new p(vo);function Xo(){return(new Date).getTime()}function $o(t){let e=!0,r=null;return t.forEach(n=>{null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||Zo.throwArgumentError("provider mismatch","networks",t):r=n:e=!1}),e}let Qo=1;class Yo extends To{constructor(t,e,r){Zo.checkNew(new.target,Yo),0===t.length&&Zo.throwArgumentError("missing providers","providers",t),null!=r&&r.length!==t.length?Zo.throwArgumentError("too many weights","weights",r):r?r.forEach(t=>{(t%1||t>512||t<1)&&Zo.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",r)}):r=t.map(t=>1);let n=r.reduce((t,e)=>t+e);if(null==e?e=n/2:e>n&&Zo.throwArgumentError("quorum will always fail; larger than total weight","quorum",e),$o(t.map(t=>t.network)))super(t[0].network);else{super(Promise.all(t.map(t=>t.getNetwork())).then(t=>($o(t)||Zo.throwError("getNetwork returned null",p.errors.UNKNOWN_ERROR),t[0])))}rt(this,"providers",Object.freeze(t.slice())),rt(this,"quorum",e),rt(this,"weights",Object.freeze(r.slice()))}static doPerform(t,e,r){switch(e){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return t[e]();case"getBalance":case"getTransactionCount":case"getCode":return t[e](r.address,r.blockTag||"latest");case"getStorageAt":return t.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return t.sendTransaction(r.signedTransaction).then(t=>t.hash);case"getBlock":return t[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return t[e](r.transaction);case"getTransaction":case"getTransactionReceipt":return t[e](r.transactionHash);case"getLogs":return t.getLogs(r.filter)}return Zo.throwError("unknown method error",p.errors.UNKNOWN_ERROR,{method:e,params:r})}perform(t,e){let r=Xo(),n=_s(this.providers).map((n,i)=>{let s=this.weights[i],o=Qo++;return{run:()=>{let i=Xo(),a=i-r;return this.emit("debug",{action:"request",rid:o,backend:{weight:s,start:a,provider:n},request:{method:t,params:ht(e)},provider:this}),Yo.doPerform(n,t,e).then(r=>{let h=Xo()-i;return this.emit("debug",{action:"response",rid:o,backend:{weight:s,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},response:ht(r)}),{weight:s,result:r}},r=>{let h=Xo()-i;return this.emit("debug",{action:"response",rid:o,backend:{weight:s,start:a,duration:h,provider:n},request:{method:t,params:ht(e)},error:r}),{weight:s,error:r}})},weight:s}});return"sendTransaction"===t?Promise.all(n.map(t=>t.run())).then(t=>{for(let e=0;e{let s=null,o=0,a={},h=()=>{if(0===n.length)return;let l=n.shift();o+=l.weight,l.run().then(u=>{if(null!==a){if(o-=l.weight,u.error)null==s&&(s=u.error);else{let t=function t(e){if(Array.isArray(e))return JSON.stringify(e.map(e=>t(e)));if(null===e)return"null";if("object"==typeof e){let r=Object.keys(e);return r.sort(),"{"+r.map(r=>{let n=e[r];return n="function"==typeof n?"function{}":t(n),JSON.stringify(r)+"="+t(n)}).join(",")+"}"}return JSON.stringify(e)}(u.result);null==a[t]&&(a[t]=[]),a[t].push(u);for(let t in a){let e=a[t].reduce((t,e)=>t+e.weight,0);if(e>=this.quorum){let n=a[t][0].result;return this.emit("debug","quorum",-1,{weight:e,result:n}),r(n),void(a=null)}}}if(0===n.length&&0===o){if("getGasPrice"===t){const t=[];Object.keys(a).forEach(e=>{a[e].forEach(e=>{e.result&&t.push(e.result)})}),t.sort((t,e)=>t.lt(e)?-1:t.gt(e)?1:0);let e=parseInt(String(t.length/2));return t.length%2?void r(t[e]):void r(t[e-1].add(t[e]).div(2))}return null===s&&(s=Zo.makeError("failed to meet quorum",p.errors.SERVER_ERROR,{results:Object.keys(a).map(r=>({method:t,params:e,result:r,weight:a[r].reduce((t,e)=>t+e.weight,0)}))})),void i(s)}setTimeout(h,0)}}),o{let n=Buffer.alloc(0),i=ta.connect(this.path);i.on("data",t=>{n=Buffer.concat([n,t])}),i.on("end",()=>{try{t(JSON.parse(n.toString()).result),i.destroy()}catch(t){e(t),i.destroy()}}),i.on("error",t=>{e(t),i.destroy()}),i.write(r),i.end()})}}const na=new p(vo),ia="84842078b09946638c03157f83405213";const sa=new p(vo),oa="ETHERS_JS_SHARED";const aa=new p(vo);class ha extends Do{constructor(t,e){aa.checkNew(new.target,ha),super(t.host||t.path||"",e),t&&(t.sendAsync?this._sendAsync=t.sendAsync.bind(t):t.send&&(this._sendAsync=t.send.bind(t))),t&&this._sendAsync||aa.throwArgumentError("invalid web3Provider","web3Provider",t),rt(this,"_web3Provider",t)}send(t,e){return"eth_sign"==t&&this._web3Provider.isMetaMask&&(t="personal_sign",e=[e[1],e[0]]),new Promise((r,n)=>{let i={method:t,params:e,id:42,jsonrpc:"2.0"};this._sendAsync(i,function(t,e){if(t)n(t);else{if(e.error){let t=new Error(e.error.message);return t.code=e.error.code,t.data=e.error.data,void n(t)}r(e.result)}})})}}var la=Object.freeze({Provider:lr,BaseProvider:To,FallbackProvider:Yo,AlchemyProvider:class extends Uo{static getApiKey(t){return null==t?jo:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:zo.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+e}},CloudflareProvider:class extends Uo{static getUrl(t,e){null!=e&&Ho.throwArgumentError("apiKey not supported for cloudflare","apiKey",e);let r=null;switch(t.name){case"homestead":r="https://cloudflare-eth.com/";break;default:Ho.throwArgumentError("unsupported network","network",arguments[0])}return r}},EtherscanProvider:Jo,InfuraProvider:class extends Uo{get projectId(){return this.apiKey}static getApiKey(t){return null==t?ia:t}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="mainnet.infura.io";break;case"ropsten":r="ropsten.infura.io";break;case"rinkeby":r="rinkeby.infura.io";break;case"kovan":r="kovan.infura.io";break;case"goerli":r="goerli.infura.io";break;default:na.throwError("unsupported network",p.errors.INVALID_ARGUMENT,{argument:"network",value:t})}return"https://"+r+"/v3/"+e}},JsonRpcProvider:Do,NodesmithProvider:class extends Uo{static getApiKey(t){return t||oa}static getUrl(t,e){let r=null;switch(t.name){case"homestead":r="https://ethereum.api.nodesmith.io/v1/mainnet/jsonrpc";break;case"ropsten":r="https://ethereum.api.nodesmith.io/v1/ropsten/jsonrpc";break;case"rinkeby":r="https://ethereum.api.nodesmith.io/v1/rinkeby/jsonrpc";break;case"goerli":r="https://ethereum.api.nodesmith.io/v1/goerli/jsonrpc";break;case"kovan":r="https://ethereum.api.nodesmith.io/v1/kovan/jsonrpc";break;default:sa.throwArgumentError("unsupported network","network",arguments[0])}return r+"?apiKey="+e}},Web3Provider:ha,IpcProvider:ra,JsonRpcSigner:Bo,getNetwork:ao,Formatter:wo});const ua=new RegExp("^bytes([0-9]+)$"),fa=new RegExp("^(u?int)([0-9]*)$"),ca=new RegExp("^(.*)\\[([0-9]*)\\]$"),da="0000000000000000000000000000000000000000000000000000000000000000";function pa(t,e){if(t.length!=e.length)throw new Error("type/value count mismatch");let r=[];return t.forEach(function(t,n){r.push(function t(e,r,n){switch(e){case"address":return n?S(r,32):E(r);case"string":return Ae(r);case"bytes":return E(r);case"bool":return r=r?"0x01":"0x00",n?S(r,32):E(r)}let i=e.match(fa);if(i){let t=parseInt(i[2]||"256");if(t%8!=0||0===t||t>256)throw new Error("invalid number type - "+e);return n&&(t=256),S(r=U.from(r).toTwos(t),t/8)}if(i=e.match(ua)){let t=parseInt(i[1]);if(String(t)!=i[1]||0===t||t>32)throw new Error("invalid number type - "+e);if(E(r).byteLength!==t)throw new Error("invalid value for "+e);return n?E((r+da).substring(0,66)):r}if((i=e.match(ca))&&Array.isArray(r)){let n=i[1];if(parseInt(i[2]||String(r.length))!=r.length)throw new Error("invalid value for "+e);let s=[];return r.forEach(function(e){s.push(t(n,e,!0))}),_(s)}throw new Error("unknown type - "+e)}(t,e[n]))}),P(_(r))}const ma=new p("units/5.0.0-beta.126"),ga=["wei","kwei","mwei","gwei","szabo","finney","ether"];function ya(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return $(t,null!=e?e:18)}function va(t,e){if("string"==typeof e){let t=ga.indexOf(e);-1!==t&&(e=3*t)}return Q(t,null!=e?e:18)}var ba=Object.freeze({AbiCoder:Ke,defaultAbiCoder:Ge,Fragment:Et,EventFragment:_t,FunctionFragment:Pt,ParamType:bt,FormatTypes:yt,Logger:p,RLP:Kt,fetchJson:go,poll:yo,checkProperties:st,deepCopy:ht,defineReadOnly:rt,getStatic:nt,resolveProperties:it,shallowCopy:ot,arrayify:E,concat:_,stripZeros:A,zeroPad:S,defaultPath:ps,HDNode:ms,SigningKey:qi,Interface:sr,base64:po,hexlify:P,isHexString:M,hexStripZeros:I,hexValue:N,hexZeroPad:R,hexDataLength:x,hexDataSlice:T,nameprep:Le,_toEscapedUtf8String:function(t,e){return'"'+_e(t,e).map(t=>{if(t<256){switch(t){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(t>=32&&t<127)return String.fromCharCode(t)}return t<=65535?Se(t):Se(55296+((t-=65536)>>10&1023))+Se(56320+(1023&t))}).join("")+'"'},toUtf8Bytes:Ae,toUtf8CodePoints:Pe,toUtf8String:ke,formatBytes32String:function(t){let e=Ae(t);if(e.length>31)throw new Error("bytes32 string must be less than 32 bytes");return P(_([e,fe]).slice(0,32))},parseBytes32String:function(t){let e=E(t);if(32!==e.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==e[31])throw new Error("invalid bytes32 string - no null terminator");let r=31;for(;0===e[r-1];)r--;return ke(e.slice(0,r))},hashMessage:Ye,namehash:Xe,isValidName:Ze,id:$e,getAddress:$t,getIcapAddress:function(t){let e=new o($t(t).substring(2),16).toString(36).toUpperCase();for(;e.length<30;)e="0"+e;return"XE"+Xt("XE00"+e)+e},getContractAddress:Qt,isAddress:function(t){try{return $t(t),!0}catch(t){}return!1},formatEther:function(t){return ya(t,18)},parseEther:function(t){return va(t,18)},formatUnits:ya,parseUnits:va,commify:function(t){let e=String(t).split(".");(e.length>2||!e[0].match(/^-?[0-9]*$/)||e[1]&&!e[1].match(/^[0-9]*$/)||"."===t||"-."===t)&&ma.throwArgumentError("invalid value","value",t);let r=e[0],n="";for("-"===r.substring(0,1)&&(n="-",r=r.substring(1));"0"===r.substring(0,1);)r=r.substring(1);""===r&&(r="0");let i="";2===e.length&&(i="."+(e[1]||"0"));let s=[];for(;r.length;){if(r.length<=3){s.unshift(r);break}{let t=r.length-3;s.unshift(r.substring(t)),r=r.substring(0,t)}}return n+s.join(",")+i},keccak256:Dt,sha256:Qn,randomBytes:As,solidityPack:pa,solidityKeccak256:function(t,e){return Dt(pa(t,e))},soliditySha256:function(t,e){return Qn(pa(t,e))},splitSignature:C,joinSignature:B,parseTransaction:Yi,serializeTransaction:Qi,getJsonWalletAddress:function(t){if(Is(t))try{return $t(JSON.parse(t).ethaddr)}catch(t){return null}if(Rs(t))try{return $t(JSON.parse(t).address)}catch(t){return null}return null},computeAddress:Xi,recoverAddress:$i,computePublicKey:Gi,recoverPublicKey:Ki,verifyMessage:function(t,e){return $i(Ye(t),e)},mnemonicToEntropy:ys,entropyToMnemonic:vs,isValidMnemonic:function(t,e){try{return ys(t,e),!0}catch(t){}return!1},mnemonicToSeed:gs,SupportedAlgorithms:Xn,get UnicodeNormalizationForm(){return Ee},Indexed:ir});const wa="ethers/5.0.0-beta.155",Ea=p.errors,_a=new p(wa);function Aa(t,e){null==t&&(t="homestead");let r=ao(t);return r&&r._defaultProvider||_a.throwError("unsupported getDefaultProvider network",p.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:t}),r._defaultProvider(la,e)}var Sa=Object.freeze({Signer:cr,Wallet:to,VoidSigner:dr,getDefaultProvider:Aa,providers:la,Contract:Ar,ContractFactory:Sr,BigNumber:U,FixedNumber:tt,constants:ve,errors:Ea,logger:_a,utils:ba,wordlists:ss,version:wa,Wordlist:is});export{U as BigNumber,Ar as Contract,Sr as ContractFactory,tt as FixedNumber,cr as Signer,dr as VoidSigner,to as Wallet,is as Wordlist,ve as constants,Ea as errors,Sa as ethers,Aa as getDefaultProvider,_a as logger,la as providers,ba as utils,wa as version,ss as wordlists}; diff --git a/packages/ethers/dist/ethers.umd.js b/packages/ethers/dist/ethers.umd.js index 1ecbc1eb9..5d92b2678 100644 --- a/packages/ethers/dist/ethers.umd.js +++ b/packages/ethers/dist/ethers.umd.js @@ -4176,13 +4176,6 @@ var bignumber = createCommonjsModule(function (module, exports) { "use strict"; - var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; - }; Object.defineProperty(exports, "__esModule", { value: true }); /** * BigNumber @@ -4191,7 +4184,7 @@ * because it is used by elliptic, so it is required regardles. * */ - var BN = __importStar(bn); + @@ -4303,7 +4296,7 @@ return new BigNumber(_constructorGuard, toHex(value)); } if (value.match(/^-?[0-9]+$/)) { - return new BigNumber(_constructorGuard, toHex(new BN.BN(value))); + return new BigNumber(_constructorGuard, toHex(new bn.BN(value))); } return logger.throwArgumentError("invalid BigNumber string", "value", value); } @@ -4386,9 +4379,9 @@ function toBN(value) { var hex = BigNumber.from(value).toHexString(); if (hex[0] === "-") { - return (new BN.BN("-" + hex.substring(3), 16)); + return (new bn.BN("-" + hex.substring(3), 16)); } - return new BN.BN(hex.substring(2), 16); + return new bn.BN(hex.substring(2), 16); } function throwFault(fault, operation, value) { var params = { fault: fault, operation: operation }; @@ -6452,16 +6445,9 @@ var lib$6 = createCommonjsModule(function (module, exports) { "use strict"; - var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; - }; Object.defineProperty(exports, "__esModule", { value: true }); // We use this for base 36 maths - var BN = __importStar(bn); + @@ -6549,7 +6535,7 @@ if (address.substring(2, 4) !== ibanChecksum(address)) { logger.throwArgumentError("bad icap checksum", "address", address); } - result = (new BN.BN(address.substring(4), 36)).toString(16); + result = (new bn.BN(address.substring(4), 36)).toString(16); while (result.length < 40) { result = "0" + result; } @@ -6571,7 +6557,7 @@ } exports.isAddress = isAddress; function getIcapAddress(address) { - var base36 = (new BN.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); + var base36 = (new bn.BN(getAddress(address).substring(2), 16)).toString(36).toUpperCase(); while (base36.length < 30) { base36 = "0" + base36; } @@ -8657,6 +8643,13 @@ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); + var __spreadArrays = (commonjsGlobal && commonjsGlobal.__spreadArrays) || function () { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; + }; Object.defineProperty(exports, "__esModule", { value: true }); @@ -9186,7 +9179,7 @@ var event = _this._wrapEvent(runningEvent, log, listener); var values = (event.values || []); values.push(event); - _this.emit.apply(_this, [runningEvent.filter].concat(values)); + _this.emit.apply(_this, __spreadArrays([runningEvent.filter], values)); }; this._wrappedEmits[runningEvent.tag] = wrappedEmit; // Special events, like "error" do not have a filter @@ -20694,9 +20687,6 @@ var lib$p = createCommonjsModule(function (module, exports) { "use strict"; - function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; - } var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; @@ -20707,14 +20697,64 @@ Object.defineProperty(exports, "__esModule", { value: true }); var ethers$1 = __importStar(ethers); exports.ethers = ethers$1; - __export(ethers); + var ethers_1 = ethers; + exports.Signer = ethers_1.Signer; + exports.Wallet = ethers_1.Wallet; + exports.VoidSigner = ethers_1.VoidSigner; + exports.getDefaultProvider = ethers_1.getDefaultProvider; + exports.providers = ethers_1.providers; + exports.Contract = ethers_1.Contract; + exports.ContractFactory = ethers_1.ContractFactory; + exports.BigNumber = ethers_1.BigNumber; + exports.FixedNumber = ethers_1.FixedNumber; + exports.constants = ethers_1.constants; + exports.errors = ethers_1.errors; + exports.logger = ethers_1.logger; + exports.utils = ethers_1.utils; + exports.wordlists = ethers_1.wordlists; + //////////////////////// + // Compile-Time Constants + exports.version = ethers_1.version; + exports.Wordlist = ethers_1.Wordlist; }); var index$p = unwrapExports(lib$p); var lib_1$p = lib$p.ethers; + var lib_2$m = lib$p.Signer; + var lib_3$h = lib$p.Wallet; + var lib_4$e = lib$p.VoidSigner; + var lib_5$c = lib$p.getDefaultProvider; + var lib_6$8 = lib$p.providers; + var lib_7$7 = lib$p.Contract; + var lib_8$5 = lib$p.ContractFactory; + var lib_9$4 = lib$p.BigNumber; + var lib_10$3 = lib$p.FixedNumber; + var lib_11$2 = lib$p.constants; + var lib_12$2 = lib$p.errors; + var lib_13$2 = lib$p.logger; + var lib_14$2 = lib$p.utils; + var lib_15$1 = lib$p.wordlists; + var lib_16$1 = lib$p.version; + var lib_17 = lib$p.Wordlist; + exports.BigNumber = lib_9$4; + exports.Contract = lib_7$7; + exports.ContractFactory = lib_8$5; + exports.FixedNumber = lib_10$3; + exports.Signer = lib_2$m; + exports.VoidSigner = lib_4$e; + exports.Wallet = lib_3$h; + exports.Wordlist = lib_17; + exports.constants = lib_11$2; exports.default = index$p; + exports.errors = lib_12$2; exports.ethers = lib_1$p; + exports.getDefaultProvider = lib_5$c; + exports.logger = lib_13$2; + exports.providers = lib_6$8; + exports.utils = lib_14$2; + exports.version = lib_16$1; + exports.wordlists = lib_15$1; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/packages/ethers/dist/ethers.umd.min.js b/packages/ethers/dist/ethers.umd.min.js index 47b089258..64acc3cf9 100644 --- a/packages/ethers/dist/ethers.umd.min.js +++ b/packages/ethers/dist/ethers.umd.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],R=8191&T,C=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],q=8191&K,W=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(m,q)|0,o=o+Math.imul(m,W)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,q)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(v,q)|0,o=o+Math.imul(v,W)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,q)|0,i=(i=i+Math.imul(P,W)|0)+Math.imul(A,q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,q)|0,i=(i=i+Math.imul(M,W)|0)+Math.imul(k,q)|0,o=o+Math.imul(k,W)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,z),i=(i=Math.imul(R,H))+Math.imul(C,z)|0,o=Math.imul(C,H),n=n+Math.imul(O,q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(N,q)|0,o=o+Math.imul(N,W)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(R,q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,q)|0,i=(i=i+Math.imul(I,W)|0)+Math.imul(F,q)|0,o=o+Math.imul(F,W)|0,n=n+Math.imul(R,V)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,V)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,q),i=(i=Math.imul(j,W))+Math.imul(D,q)|0,o=Math.imul(D,W),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(R,X)|0,i=(i=i+Math.imul(R,$)|0)+Math.imul(C,X)|0,o=o+Math.imul(C,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(R,Y)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,Y)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,me)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Ce=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Re,u[17]=Ce,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.128"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.128"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.129"})),d=(r(h),h.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(h.version),a={};r.isBigNumberish=function(e){return null!=e&&(u.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var u=function(){function e(t,r){var n=this.constructor;o.checkNew(n,e),t!==a&&o.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=r,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return d(p(this).fromTwos(e))},e.prototype.toTwos=function(e){return d(p(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return d(p(this).add(p(e)))},e.prototype.sub=function(e){return d(p(this).sub(p(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&m("division by zero","div"),d(p(this).div(p(t)))},e.prototype.mul=function(e){return d(p(this).mul(p(e)))},e.prototype.mod=function(e){return d(p(this).mod(p(e)))},e.prototype.pow=function(e){return d(p(this).pow(p(e)))},e.prototype.maskn=function(e){return d(p(this).maskn(e))},e.prototype.eq=function(e){return p(this).eq(p(e))},e.prototype.lt=function(e){return p(this).lt(p(e))},e.prototype.lte=function(e){return p(this).lte(p(e))},e.prototype.gt=function(e){return p(this).gt(p(e))},e.prototype.gte=function(e){return p(this).gte(p(e))},e.prototype.isZero=function(){return p(this).isZero()},e.prototype.toNumber=function(){try{return p(this).toNumber()}catch(e){m("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&o.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),p(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(a,c(t)):t.match(/^-?[0-9]+$/)?new e(a,c(new i.BN(t))):o.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&m("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&m("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):o.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function c(e){if("string"!=typeof e)return c(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&o.throwArgumentError("invalid hex","value",e),"0x00"===(e=c(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function d(e){return u.from(c(e))}function p(e){var t=u.from(e).toHexString();return"-"===t[0]?new i.BN("-"+t.substring(3),16):new i.BN(t.substring(2),16)}function m(e,t,r){var n={fault:e,operation:t};return null!=r&&(n.value=r),o.throwError(e,f.Logger.errors.NUMERIC_FAULT,n)}r.BigNumber=u})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.formatFixed=p.formatFixed,t.FixedFormat=p.FixedFormat,t.FixedNumber=p.FixedNumber,t.parseFixed=p.parseFixed})),g=(r(m),m.BigNumber,m.formatFixed,m.FixedFormat,m.FixedNumber,m.parseFixed,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.130"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.136"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,R,C,B,I,F,L,j,D,U,z,H,K,q,W,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,q=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,R=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,C=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,W=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=W^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&R,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&C,e[15]=N^~R&B,e[24]=D^~z&K,e[25]=U^~H&q,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~C&S,e[17]=R^~B&M,e[26]=z^~K&I,e[27]=H^~q&F,e[36]=$^~Y&W,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=C^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=q^~F&j,e[38]=Y^~W&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.127"})),S=(r(A),A.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(s),o=new f.Logger(A.version);function a(e){l.isHexString(e,20)||o.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),r=new Uint8Array(40),n=0;n<40;n++)r[n]=t[n].charCodeAt(0);r=l.arrayify(E.keccak256(r));for(n=0;n<40;n+=2)r[n>>1]>>4>=8&&(t[n]=t[n].toUpperCase()),(15&r[n>>1])>=8&&(t[n+1]=t[n+1].toUpperCase());return"0x"+t.join("")}for(var u={},c=0;c<10;c++)u[String(c)]=String(c);for(c=0;c<26;c++)u[String.fromCharCode(65+c)]=String(10+c);var h,d=Math.floor((h=9007199254740991,Math.log10?Math.log10(h):Math.log(h)/Math.LN10));function p(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=u[e]});t.length>=d;){var r=t.substring(0,d);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function m(e){var t=null;if("string"!=typeof e&&o.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=a(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&o.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==p(e)&&o.throwArgumentError("bad icap checksum","address",e),t=new i.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=a("0x"+t)}else o.throwArgumentError("invalid address","address",e);return t}r.getAddress=m,r.isAddress=function(e){try{return m(e),!0}catch(e){}return!1},r.getIcapAddress=function(e){for(var t=new i.BN(m(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+p("XE00"+t)+t},r.getContractAddress=function(e){var t=null;try{t=m(e.from)}catch(t){o.throwArgumentError("missing from address","transaction",e)}var r=l.stripZeros(l.arrayify(e.nonce));return m(l.hexDataSlice(E.keccak256(P.encode([t,r])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,C.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new R.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.127"})),q=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(q.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(W),W.LogDescription,W.TransactionDescription,W.Indexed,W.Result,W.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=W.Indexed,t.Interface=W.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.130"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.131"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.136"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger($.version),a={chainId:!0,data:!0,from:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function s(e,t,r){if(Array.isArray(r))return Promise.all(r.map(function(r,n){return s(e,Array.isArray(t)?t[n]:t[r.name],r)}));if("address"===r.type)return e.resolveName(t);if("tuple"===r.type)return s(e,t,r.components);if("array"===r.baseType){if(!Array.isArray(t))throw new Error("invalid value for array");return Promise.all(t.map(function(t){return s(e,t,r.arrayChildren)}))}return Promise.resolve(t)}function u(e,t,r){var n=e.interface.functions[t];return function(){for(var t=this,i=[],u=0;u0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=v;var b=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&o.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&o.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Rt=Tt;function Ct(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Ct.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Rt.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Rt,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var qt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new qt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new qt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.128"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.127"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?C.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.127"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return q.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.129"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invalid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.127"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},R.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},R.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var C=function(e,t){if(!(this instanceof C))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof R||(t=new R(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};C.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}R(C)};C()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Rr=0;Rr<256;Rr++)Nr[Rr]=(Rr+256).toString(16).substr(1),Tr[Nr[Rr]]=Rr;function Cr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Cr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Cr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Cr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),R=l.arrayify(T.encrypt(f)),C=new Date,B=C.getUTCFullYear()+"-"+Pr.zpad(C.getUTCMonth()+1,2)+"-"+Pr.zpad(C.getUTCDate(),2)+"T"+Pr.zpad(C.getUTCHours(),2)+"-"+Pr.zpad(C.getUTCMinutes(),2)+"-"+Pr.zpad(C.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(R).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),qr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.129"})),Wr=(r(qr),qr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(qr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(q.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(q.hashMessage(e),t)}})),Gr=(r(Wr),Wr.Wallet,Wr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.128"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.140"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===C.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),mn=(r(pn),pn.pack,pn.keccak256,pn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.126"})),gn=(r(mn),mn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(mn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),yn=(r(gn),gn.commify,gn.formatUnits,gn.parseUnits,gn.formatEther,gn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=q.hashMessage,r.id=q.id,r.isValidName=q.isValidName,r.namehash=q.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=pn.keccak256,r.solidityPack=pn.pack,r.soliditySha256=pn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=gn.commify,r.formatEther=gn.formatEther,r.parseEther=gn.parseEther,r.formatUnits=gn.formatUnits,r.parseUnits=gn.parseUnits,r.verifyMessage=Wr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),vn=(r(yn),yn.AbiCoder,yn.defaultAbiCoder,yn.EventFragment,yn.FormatTypes,yn.Fragment,yn.FunctionFragment,yn.Indexed,yn.Interface,yn.ParamType,yn.getAddress,yn.getContractAddress,yn.getIcapAddress,yn.isAddress,yn.base64,yn.arrayify,yn.concat,yn.hexDataSlice,yn.hexDataLength,yn.hexlify,yn.hexStripZeros,yn.hexValue,yn.hexZeroPad,yn.isHexString,yn.joinSignature,yn.zeroPad,yn.splitSignature,yn.stripZeros,yn.hashMessage,yn.id,yn.isValidName,yn.namehash,yn.defaultPath,yn.entropyToMnemonic,yn.HDNode,yn.isValidMnemonic,yn.mnemonicToEntropy,yn.mnemonicToSeed,yn.getJsonWalletAddress,yn.keccak256,yn.Logger,yn.sha256,yn.solidityKeccak256,yn.solidityPack,yn.soliditySha256,yn.randomBytes,yn.checkProperties,yn.deepCopy,yn.defineReadOnly,yn.getStatic,yn.resolveProperties,yn.shallowCopy,yn.RLP,yn.computePublicKey,yn.recoverPublicKey,yn.SigningKey,yn.formatBytes32String,yn.nameprep,yn.parseBytes32String,yn._toEscapedUtf8String,yn.toUtf8Bytes,yn.toUtf8CodePoints,yn.toUtf8String,yn.computeAddress,yn.parseTransaction,yn.recoverAddress,yn.serializeTransaction,yn.commify,yn.formatEther,yn.parseEther,yn.formatUnits,yn.parseUnits,yn.verifyMessage,yn.fetchJson,yn.poll,yn.SupportedAlgorithms,yn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.155"})),bn=(r(vn),vn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=Wr.Wallet;var i=n(C);r.constants=i;var o=n(dn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(yn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.version=vn.version;var u=new f.Logger(vn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),wn=(r(bn),bn.Contract,bn.ContractFactory,bn.BigNumber,bn.FixedNumber,bn.Signer,bn.VoidSigner,bn.Wallet,bn.constants,bn.providers,bn.Wordlist,bn.wordlists,bn.utils,bn.errors,bn.version,bn.logger,bn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(bn);r.ethers=i,function(e){for(var t in e)r.hasOwnProperty(t)||(r[t]=e[t])}(bn)})),_n=r(wn),En=wn.ethers;e.default=_n,e.ethers=En,Object.defineProperty(e,"__esModule",{value:!0})}); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).ethers={})}(this,function(e){"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){return e(t={exports:{}},t.exports),t.exports}function i(e){return e&&e.default||e}var o=Object.freeze({default:{}}),a=i(o),s=n(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var o;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{o=a.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),o=t;o=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function u(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===n)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},i.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=s(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},i.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,s=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],c=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],l=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function h(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?f[6-u.length]+u+n:u+n,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(n=o.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=c[e],d=l[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var m=p.modn(d).toString(e);n=(p=p.idivn(d)).isZero()?m+n:f[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==o),this.toArrayLike(o,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),o=n||Math.max(1,i);r(i<=o,"byte array longer than desired length"),r(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,m=d>>>13,g=0|a[2],y=8191&g,v=g>>>13,b=0|a[3],w=8191&b,_=b>>>13,E=0|a[4],P=8191&E,A=E>>>13,S=0|a[5],M=8191&S,k=S>>>13,x=0|a[6],O=8191&x,N=x>>>13,T=0|a[7],C=8191&T,R=T>>>13,B=0|a[8],I=8191&B,F=B>>>13,L=0|a[9],j=8191&L,D=L>>>13,U=0|s[0],z=8191&U,H=U>>>13,K=0|s[1],W=8191&K,q=K>>>13,G=0|s[2],V=8191&G,J=G>>>13,Z=0|s[3],X=8191&Z,$=Z>>>13,Q=0|s[4],Y=8191&Q,ee=Q>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,me=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,z))|0)+((8191&(i=(i=Math.imul(l,H))+Math.imul(h,z)|0))<<13)|0;f=((o=Math.imul(h,H))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,z),i=(i=Math.imul(p,H))+Math.imul(m,z)|0,o=Math.imul(m,H);var ye=(f+(n=n+Math.imul(l,W)|0)|0)+((8191&(i=(i=i+Math.imul(l,q)|0)+Math.imul(h,W)|0))<<13)|0;f=((o=o+Math.imul(h,q)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(y,z),i=(i=Math.imul(y,H))+Math.imul(v,z)|0,o=Math.imul(v,H),n=n+Math.imul(p,W)|0,i=(i=i+Math.imul(p,q)|0)+Math.imul(m,W)|0,o=o+Math.imul(m,q)|0;var ve=(f+(n=n+Math.imul(l,V)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,V)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(w,z),i=(i=Math.imul(w,H))+Math.imul(_,z)|0,o=Math.imul(_,H),n=n+Math.imul(y,W)|0,i=(i=i+Math.imul(y,q)|0)+Math.imul(v,W)|0,o=o+Math.imul(v,q)|0,n=n+Math.imul(p,V)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(m,V)|0,o=o+Math.imul(m,J)|0;var be=(f+(n=n+Math.imul(l,X)|0)|0)+((8191&(i=(i=i+Math.imul(l,$)|0)+Math.imul(h,X)|0))<<13)|0;f=((o=o+Math.imul(h,$)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(P,z),i=(i=Math.imul(P,H))+Math.imul(A,z)|0,o=Math.imul(A,H),n=n+Math.imul(w,W)|0,i=(i=i+Math.imul(w,q)|0)+Math.imul(_,W)|0,o=o+Math.imul(_,q)|0,n=n+Math.imul(y,V)|0,i=(i=i+Math.imul(y,J)|0)+Math.imul(v,V)|0,o=o+Math.imul(v,J)|0,n=n+Math.imul(p,X)|0,i=(i=i+Math.imul(p,$)|0)+Math.imul(m,X)|0,o=o+Math.imul(m,$)|0;var we=(f+(n=n+Math.imul(l,Y)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,Y)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(M,z),i=(i=Math.imul(M,H))+Math.imul(k,z)|0,o=Math.imul(k,H),n=n+Math.imul(P,W)|0,i=(i=i+Math.imul(P,q)|0)+Math.imul(A,W)|0,o=o+Math.imul(A,q)|0,n=n+Math.imul(w,V)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,V)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(y,X)|0,i=(i=i+Math.imul(y,$)|0)+Math.imul(v,X)|0,o=o+Math.imul(v,$)|0,n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(m,Y)|0,o=o+Math.imul(m,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(O,z),i=(i=Math.imul(O,H))+Math.imul(N,z)|0,o=Math.imul(N,H),n=n+Math.imul(M,W)|0,i=(i=i+Math.imul(M,q)|0)+Math.imul(k,W)|0,o=o+Math.imul(k,q)|0,n=n+Math.imul(P,V)|0,i=(i=i+Math.imul(P,J)|0)+Math.imul(A,V)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,X)|0,i=(i=i+Math.imul(w,$)|0)+Math.imul(_,X)|0,o=o+Math.imul(_,$)|0,n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(v,Y)|0,o=o+Math.imul(v,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(m,re)|0,o=o+Math.imul(m,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(C,z),i=(i=Math.imul(C,H))+Math.imul(R,z)|0,o=Math.imul(R,H),n=n+Math.imul(O,W)|0,i=(i=i+Math.imul(O,q)|0)+Math.imul(N,W)|0,o=o+Math.imul(N,q)|0,n=n+Math.imul(M,V)|0,i=(i=i+Math.imul(M,J)|0)+Math.imul(k,V)|0,o=o+Math.imul(k,J)|0,n=n+Math.imul(P,X)|0,i=(i=i+Math.imul(P,$)|0)+Math.imul(A,X)|0,o=o+Math.imul(A,$)|0,n=n+Math.imul(w,Y)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,Y)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(v,re)|0,o=o+Math.imul(v,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(m,oe)|0,o=o+Math.imul(m,ae)|0;var Pe=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(I,z),i=(i=Math.imul(I,H))+Math.imul(F,z)|0,o=Math.imul(F,H),n=n+Math.imul(C,W)|0,i=(i=i+Math.imul(C,q)|0)+Math.imul(R,W)|0,o=o+Math.imul(R,q)|0,n=n+Math.imul(O,V)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(N,V)|0,o=o+Math.imul(N,J)|0,n=n+Math.imul(M,X)|0,i=(i=i+Math.imul(M,$)|0)+Math.imul(k,X)|0,o=o+Math.imul(k,$)|0,n=n+Math.imul(P,Y)|0,i=(i=i+Math.imul(P,ee)|0)+Math.imul(A,Y)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(y,oe)|0,i=(i=i+Math.imul(y,ae)|0)+Math.imul(v,oe)|0,o=o+Math.imul(v,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(m,ue)|0,o=o+Math.imul(m,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,z),i=(i=Math.imul(j,H))+Math.imul(D,z)|0,o=Math.imul(D,H),n=n+Math.imul(I,W)|0,i=(i=i+Math.imul(I,q)|0)+Math.imul(F,W)|0,o=o+Math.imul(F,q)|0,n=n+Math.imul(C,V)|0,i=(i=i+Math.imul(C,J)|0)+Math.imul(R,V)|0,o=o+Math.imul(R,J)|0,n=n+Math.imul(O,X)|0,i=(i=i+Math.imul(O,$)|0)+Math.imul(N,X)|0,o=o+Math.imul(N,$)|0,n=n+Math.imul(M,Y)|0,i=(i=i+Math.imul(M,ee)|0)+Math.imul(k,Y)|0,o=o+Math.imul(k,ee)|0,n=n+Math.imul(P,re)|0,i=(i=i+Math.imul(P,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(y,ue)|0,i=(i=i+Math.imul(y,fe)|0)+Math.imul(v,ue)|0,o=o+Math.imul(v,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(m,le)|0,o=o+Math.imul(m,he)|0;var Se=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,me)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,me)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(j,W),i=(i=Math.imul(j,q))+Math.imul(D,W)|0,o=Math.imul(D,q),n=n+Math.imul(I,V)|0,i=(i=i+Math.imul(I,J)|0)+Math.imul(F,V)|0,o=o+Math.imul(F,J)|0,n=n+Math.imul(C,X)|0,i=(i=i+Math.imul(C,$)|0)+Math.imul(R,X)|0,o=o+Math.imul(R,$)|0,n=n+Math.imul(O,Y)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(N,Y)|0,o=o+Math.imul(N,ee)|0,n=n+Math.imul(M,re)|0,i=(i=i+Math.imul(M,ne)|0)+Math.imul(k,re)|0,o=o+Math.imul(k,ne)|0,n=n+Math.imul(P,oe)|0,i=(i=i+Math.imul(P,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(y,le)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(v,le)|0,o=o+Math.imul(v,he)|0;var Me=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,me)|0)+Math.imul(m,pe)|0))<<13)|0;f=((o=o+Math.imul(m,me)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,V),i=(i=Math.imul(j,J))+Math.imul(D,V)|0,o=Math.imul(D,J),n=n+Math.imul(I,X)|0,i=(i=i+Math.imul(I,$)|0)+Math.imul(F,X)|0,o=o+Math.imul(F,$)|0,n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(R,Y)|0,o=o+Math.imul(R,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(N,re)|0,o=o+Math.imul(N,ne)|0,n=n+Math.imul(M,oe)|0,i=(i=i+Math.imul(M,ae)|0)+Math.imul(k,oe)|0,o=o+Math.imul(k,ae)|0,n=n+Math.imul(P,ue)|0,i=(i=i+Math.imul(P,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var ke=(f+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,me)|0)+Math.imul(v,pe)|0))<<13)|0;f=((o=o+Math.imul(v,me)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,X),i=(i=Math.imul(j,$))+Math.imul(D,X)|0,o=Math.imul(D,$),n=n+Math.imul(I,Y)|0,i=(i=i+Math.imul(I,ee)|0)+Math.imul(F,Y)|0,o=o+Math.imul(F,ee)|0,n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(R,re)|0,o=o+Math.imul(R,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(N,oe)|0,o=o+Math.imul(N,ae)|0,n=n+Math.imul(M,ue)|0,i=(i=i+Math.imul(M,fe)|0)+Math.imul(k,ue)|0,o=o+Math.imul(k,fe)|0,n=n+Math.imul(P,le)|0,i=(i=i+Math.imul(P,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var xe=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,me)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,me)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,Y),i=(i=Math.imul(j,ee))+Math.imul(D,Y)|0,o=Math.imul(D,ee),n=n+Math.imul(I,re)|0,i=(i=i+Math.imul(I,ne)|0)+Math.imul(F,re)|0,o=o+Math.imul(F,ne)|0,n=n+Math.imul(C,oe)|0,i=(i=i+Math.imul(C,ae)|0)+Math.imul(R,oe)|0,o=o+Math.imul(R,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(N,ue)|0,o=o+Math.imul(N,fe)|0,n=n+Math.imul(M,le)|0,i=(i=i+Math.imul(M,he)|0)+Math.imul(k,le)|0,o=o+Math.imul(k,he)|0;var Oe=(f+(n=n+Math.imul(P,pe)|0)|0)+((8191&(i=(i=i+Math.imul(P,me)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,me)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(D,re)|0,o=Math.imul(D,ne),n=n+Math.imul(I,oe)|0,i=(i=i+Math.imul(I,ae)|0)+Math.imul(F,oe)|0,o=o+Math.imul(F,ae)|0,n=n+Math.imul(C,ue)|0,i=(i=i+Math.imul(C,fe)|0)+Math.imul(R,ue)|0,o=o+Math.imul(R,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(N,le)|0,o=o+Math.imul(N,he)|0;var Ne=(f+(n=n+Math.imul(M,pe)|0)|0)+((8191&(i=(i=i+Math.imul(M,me)|0)+Math.imul(k,pe)|0))<<13)|0;f=((o=o+Math.imul(k,me)|0)+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(D,oe)|0,o=Math.imul(D,ae),n=n+Math.imul(I,ue)|0,i=(i=i+Math.imul(I,fe)|0)+Math.imul(F,ue)|0,o=o+Math.imul(F,fe)|0,n=n+Math.imul(C,le)|0,i=(i=i+Math.imul(C,he)|0)+Math.imul(R,le)|0,o=o+Math.imul(R,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,me)|0)+Math.imul(N,pe)|0))<<13)|0;f=((o=o+Math.imul(N,me)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(D,ue)|0,o=Math.imul(D,fe),n=n+Math.imul(I,le)|0,i=(i=i+Math.imul(I,he)|0)+Math.imul(F,le)|0,o=o+Math.imul(F,he)|0;var Ce=(f+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,me)|0)+Math.imul(R,pe)|0))<<13)|0;f=((o=o+Math.imul(R,me)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(D,le)|0,o=Math.imul(D,he);var Re=(f+(n=n+Math.imul(I,pe)|0)|0)+((8191&(i=(i=i+Math.imul(I,me)|0)+Math.imul(F,pe)|0))<<13)|0;f=((o=o+Math.imul(F,me)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Be=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,me))+Math.imul(D,pe)|0))<<13)|0;return f=((o=Math.imul(D,me))+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,u[0]=ge,u[1]=ye,u[2]=ve,u[3]=be,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Pe,u[8]=Ae,u[9]=Se,u[10]=Me,u[11]=ke,u[12]=xe,u[13]=Oe,u[14]=Ne,u[15]=Te,u[16]=Ce,u[17]=Re,u[18]=Be,0!==f&&(u[19]=f,r.length++),r};function p(e,t,r){return(new m).mulp(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(d=h),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?d(this,e,t):r<63?h(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):p(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,n[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[n]=67108863&o}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,o=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+n]=67108863&o}for(;i>26,this.words[i+n]=67108863&o;if(0===s)return this.strip();for(r(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),o=e,a=0|o.words[o.length-1];0!==(r=26-this._countBits(a))&&(o=o.ushln(r),n.iushln(r),a=0|o.words[o.length-1]);var s,u=n.length-o.length;if("mod"!==t){(s=new i(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[o.length+l])+(0|n.words[o.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(o,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(o,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),u=new i(1),f=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++f;for(var c=n.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(c),a.isub(l)),o.iushrn(1),a.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(u)):(n.isub(t),s.isub(o),u.isub(a))}return{a:s,b:u,gcd:n.iushln(f)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),u=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(n.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(n.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function w(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function _(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function P(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):r.strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},n(v,y),v.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new b;else if("p192"===e)t=new w;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new _}return g[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},E.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},E.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,o),h=this.pow(e,o.addn(1).iushrn(1)),d=this.pow(e,o),p=a;0!==d.cmp(s);){for(var m=d,g=0;0!==m.cmp(s);g++)m=m.redSqr();r(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;o!==r[0]&&(o=this.sqr(o)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(o=this.mul(o,r[a]),s=0,a=0)):s=0}u=26}return o},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new P(e)},n(P,E),P.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},P.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},P.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},P.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=r.isub(n).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},P.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,t)}),u=(s.BN,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="logger/5.0.0-beta.128"})),f=(r(u),u.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=!1,n=!1,i={debug:1,default:2,info:2,warn:3,error:4,off:5},o=i.default,a=null;var s=function(){try{var e=[];if(["NFD","NFC","NFKD","NFKC"].forEach(function(t){try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}}),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}(),f=function(){function e(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}return e.prototype.setLogLevel=function(e){var t=i[e];null!=t?o=t:this.warn("invliad log level - "+e)},e.prototype._log=function(e,t){o>i[e]||console.log.apply(console,t)},e.prototype.debug=function(){for(var t=[],r=0;r=9007199254740991)&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:t}),t%1&&this.throwError(r,e.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:t}))},e.prototype.checkArgumentCount=function(t,r,n){n=n?": "+n:"",tr&&this.throwError("too many arguments"+n,e.errors.UNEXPECTED_ARGUMENT,{count:t,expectedCount:r})},e.prototype.checkNew=function(t,r){t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.prototype.checkAbstract=function(t,r){t===r?this.throwError("cannot instantiate abstract class "+JSON.stringify(r.name)+" directly; use a sub-class",e.errors.UNSUPPORTED_OPERATION,{name:t.name,operation:"new"}):t!==Object&&null!=t||this.throwError("missing new",e.errors.MISSING_NEW,{name:r.name})},e.globalLogger=function(){return a||(a=new e(u.version)),a},e.setCensorship=function(t,i){if(r){if(!t)return;this.globalLogger().throwError("error censorship permanent",e.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}n=!!t,r=!!i},e.errors={UNKNOWN_ERROR:"UNKNOWN_ERROR",NOT_IMPLEMENTED:"NOT_IMPLEMENTED",UNSUPPORTED_OPERATION:"UNSUPPORTED_OPERATION",NETWORK_ERROR:"NETWORK_ERROR",SERVER_ERROR:"SERVER_ERROR",TIMEOUT:"TIMEOUT",BUFFER_OVERRUN:"BUFFER_OVERRUN",NUMERIC_FAULT:"NUMERIC_FAULT",MISSING_NEW:"MISSING_NEW",INVALID_ARGUMENT:"INVALID_ARGUMENT",MISSING_ARGUMENT:"MISSING_ARGUMENT",UNEXPECTED_ARGUMENT:"UNEXPECTED_ARGUMENT",CALL_EXCEPTION:"CALL_EXCEPTION",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",NONCE_EXPIRED:"NONCE_EXPIRED",REPLACEMENT_UNDERPRICED:"REPLACEMENT_UNDERPRICED",UNPREDICTABLE_GAS_LIMIT:"UNPREDICTABLE_GAS_LIMIT"},e.levels={DEBUG:"DEBUG",INFO:"INFO",WARNING:"WARNING",ERROR:"ERROR",OFF:"OFF"},e}();t.Logger=f})),c=(r(f),f.Logger,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bytes/5.0.0-beta.128"})),l=(r(c),c.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(c.version);function n(e){return!!e.toHexString}function i(e){return e.slice?e:(e.slice=function(){var t=Array.prototype.slice.call(arguments);return i(new Uint8Array(Array.prototype.slice.apply(e,t)))},e)}function o(e){return l(e)&&!(e.length%2)||a(e)}function a(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"==typeof e)return!1;if(null==e.length)return!1;for(var t=0;t=256||r%1)return!1}return!0}function s(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid arrayify value");for(var o=[];e;)o.unshift(255&e),e/=256;return 0===o.length&&o.push(0),i(new Uint8Array(o))}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e)&&(e=e.toHexString()),l(e)){var s=e.substring(2);!t.allowOddLength&&s.length%2&&r.throwArgumentError("hex data is odd-length","value",e);o=[];for(var u=0;ut&&r.throwArgumentError("value out of range","value",arguments[0]);var n=new Uint8Array(t);return n.set(e,t-e.length),i(n)},t.isHexString=l;var h="0123456789abcdef";function d(e,t){if(t||(t={}),"number"==typeof e){r.checkSafeUint53(e,"invalid hexlify value");for(var i="";e;)i=h[15&e]+i,e=Math.floor(e/16);return i.length?(i.length%2&&(i="0"+i),"0x"+i):"0x00"}if(t.allowMissingPrefix&&"string"==typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),n(e))return e.toHexString();if(l(e))return!t.allowOddLength&&e.length%2&&r.throwArgumentError("hex data is odd-length","value",e),e.toLowerCase();if(a(e)){for(var o="0x",s=0;s>4]+h[15&u]}return o}return r.throwArgumentError("invalid hexlify value","value",e)}function p(e){"string"!=typeof e&&(e=d(e)),l(e)||r.throwArgumentError("invalid hex string","value",e),e=e.substring(2);for(var t=0;t2*t+2&&r.throwArgumentError("value out of range","value",arguments[1]);e.length<2*t+2;)e="0x0"+e.substring(2);return e}function g(e){var t={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0};if(o(e)){var n=s(e);65!==n.length&&r.throwArgumentError("invalid signature string; must be 65 bytes","signature",e),t.r=d(n.slice(0,32)),t.s=d(n.slice(32,64)),t.v=n[64],27!==t.v&&28!==t.v&&(t.v=27+t.v%2),t.recoveryParam=t.v-27,t.recoveryParam&&(n[32]|=128),t._vs=d(n.slice(32,64))}else{if(t.r=e.r,t.s=e.s,t.v=e.v,t.recoveryParam=e.recoveryParam,t._vs=e._vs,null!=t.v&&27!=t.v&&28!=t.v&&(t.v=27+t.v%2),null==t.recoveryParam&&null!=t.v?t.recoveryParam=1-t.v%2:null!=t.recoveryParam&&null==t.v?t.v=27+t.recoveryParam:null!=t.recoveryParam&&null!=t.v&&t.v!==27+t.recoveryParam&&r.throwArgumentError("signature v mismatch recoveryParam","signature",e),null!=t.r&&(t.r=m(t.r,32)),null!=t.s&&(t.s=m(t.s,32)),null!=t._vs){t._vs=m(t._vs,32),t._vs.length>66&&r.throwArgumentError("signature _vs overflow","signature",e);var i=(f=s(t._vs))[0]>=128?1:0,a=27+t.recoveryParam;f[0]&=127;var u=d(f);null==t.s?t.s=u:t.s!==u&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==t.v?t.v=a:t.v!==a&&r.throwArgumentError("signature v mismatch _vs","signature",e),null==i?t.recoveryParam=i:t.recoveryParam!==i&&r.throwArgumentError("signature recoveryParam mismatch _vs","signature",e)}var f;if(null==t.v&&null==t.recoveryParam&&r.throwArgumentError("signature requires at least one of recoveryParam, v or _vs","signature",e),27!==t.v&&28!==t.v&&r.throwArgumentError("signature v not canonical","signature",e),(t.r.length>66||t.s.length>66)&&r.throwArgumentError("signature overflow r or s","signature",e),null==t._vs)(f=s(t.s))[0]>=128&&r.throwArgumentError("signature s out of range","signature",e),t.recoveryParam&&(f[0]|=128),t._vs=d(f)}return t}t.hexlify=d,t.hexDataLength=function(e){if("string"!=typeof e)e=d(e);else if(!l(e)||e.length%2)return null;return(e.length-2)/2},t.hexDataSlice=function(e,t,n){return"string"!=typeof e?e=d(e):(!l(e)||e.length%2)&&r.throwArgumentError("invalid hexData","value",e),t=2+2*t,null!=n?"0x"+e.substring(t,2+2*n):"0x"+e.substring(t)},t.hexConcat=function(e){var t="0x";return e.forEach(function(e){t+=d(e).substring(2)}),t},t.hexValue=function(e){var t=p(d(e,{allowOddLength:!0}));return"0x"===t?"0x0":t},t.hexStripZeros=p,t.hexZeroPad=m,t.splitSignature=g,t.joinSignature=function(e){return d(u([(e=g(e)).r,e.s,e.recoveryParam?"0x1c":"0x1b"]))}})),h=(r(l),l.isBytesLike,l.isBytes,l.arrayify,l.concat,l.stripZeros,l.zeroPad,l.isHexString,l.hexlify,l.hexDataLength,l.hexDataSlice,l.hexConcat,l.hexValue,l.hexStripZeros,l.hexZeroPad,l.splitSignature,l.joinSignature,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="bignumber/5.0.0-beta.129"})),d=(r(h),h.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={};t.isBigNumberish=function(e){return null!=e&&(i.isBigNumber(e)||"number"==typeof e&&e%1==0||"string"==typeof e&&!!e.match(/^-?[0-9]+$/)||l.isHexString(e)||"bigint"==typeof e||l.isBytes(e))};var i=function(){function e(t,i){var o=this.constructor;r.checkNew(o,e),t!==n&&r.throwError("cannot call consturtor directly; use BigNumber.from",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"new (BigNumber)"}),this._hex=i,this._isBigNumber=!0,Object.freeze(this)}return e.prototype.fromTwos=function(e){return a(u(this).fromTwos(e))},e.prototype.toTwos=function(e){return a(u(this).toTwos(e))},e.prototype.abs=function(){return"-"===this._hex[0]?e.from(this._hex.substring(1)):this},e.prototype.add=function(e){return a(u(this).add(u(e)))},e.prototype.sub=function(e){return a(u(this).sub(u(e)))},e.prototype.div=function(t){return e.from(t).isZero()&&c("division by zero","div"),a(u(this).div(u(t)))},e.prototype.mul=function(e){return a(u(this).mul(u(e)))},e.prototype.mod=function(e){return a(u(this).mod(u(e)))},e.prototype.pow=function(e){return a(u(this).pow(u(e)))},e.prototype.maskn=function(e){return a(u(this).maskn(e))},e.prototype.eq=function(e){return u(this).eq(u(e))},e.prototype.lt=function(e){return u(this).lt(u(e))},e.prototype.lte=function(e){return u(this).lte(u(e))},e.prototype.gt=function(e){return u(this).gt(u(e))},e.prototype.gte=function(e){return u(this).gte(u(e))},e.prototype.isZero=function(){return u(this).isZero()},e.prototype.toNumber=function(){try{return u(this).toNumber()}catch(e){c("overflow","toNumber",this.toString())}return null},e.prototype.toString=function(){return 0!==arguments.length&&r.throwError("bigNumber.toString does not accept parameters",f.Logger.errors.UNEXPECTED_ARGUMENT,{}),u(this).toString(10)},e.prototype.toHexString=function(){return this._hex},e.from=function(t){return t instanceof e?t:"string"==typeof t?t.match(/-?0x[0-9a-f]+/i)?new e(n,o(t)):t.match(/^-?[0-9]+$/)?new e(n,o(new s.BN(t))):r.throwArgumentError("invalid BigNumber string","value",t):"number"==typeof t?(t%1&&c("underflow","BigNumber.from",t),(t>=9007199254740991||t<=-9007199254740991)&&c("overflow","BigNumber.from",t),e.from(String(t))):"bigint"==typeof t?e.from(t.toString()):l.isBytes(t)?e.from(l.hexlify(t)):t._hex&&l.isHexString(t._hex)?e.from(t._hex):t.toHexString&&"string"==typeof(t=t.toHexString())?e.from(t):r.throwArgumentError("invalid BigNumber value","value",t)},e.isBigNumber=function(e){return!(!e||!e._isBigNumber)},e}();function o(e){if("string"!=typeof e)return o(e.toString(16));if("-"===e[0])return"-"===(e=e.substring(1))[0]&&r.throwArgumentError("invalid hex","value",e),"0x00"===(e=o(e))?e:"-"+e;if("0x"!==e.substring(0,2)&&(e="0x"+e),"0x"===e)return"0x00";for(e.length%2&&(e="0x0"+e.substring(2));e.length>4&&"0x00"===e.substring(0,4);)e="0x"+e.substring(4);return e}function a(e){return i.from(o(e))}function u(e){var t=i.from(e).toHexString();return"-"===t[0]?new s.BN("-"+t.substring(3),16):new s.BN(t.substring(2),16)}function c(e,t,n){var i={fault:e,operation:t};return null!=n&&(i.value=n),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,i)}t.BigNumber=i})),p=(r(d),d.isBigNumberish,d.BigNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(h.version),n={},i=d.BigNumber.from(0),o=d.BigNumber.from(-1);function a(e,t,n,i){var o={fault:t,operation:n};return void 0!==i&&(o.value=i),r.throwError(e,f.Logger.errors.NUMERIC_FAULT,o)}for(var s="0";s.length<256;)s+=s;function u(e){if("number"!=typeof e)try{e=d.BigNumber.from(e).toNumber()}catch(e){}return"number"==typeof e&&e>=0&&e<=256&&!(e%1)?"1"+s.substring(0,e):r.throwArgumentError("invalid decimal size","decimals",e)}function c(e,t){null==t&&(t=0);var r=u(t),n=(e=d.BigNumber.from(e)).lt(i);n&&(e=e.mul(o));for(var a=e.mod(r).toString();a.length2&&r.throwArgumentError("too many decimal points","value",e);var f=s[0],c=s[1];for(f||(f="0"),c||(c="0"),c.length>n.length-1&&a("fractional component exceeds decimals","underflow","parseFixed");c.length80&&r.throwArgumentError("invalid fixed format (decimals too large)","format.decimals",a),new e(n,i,o,a)},e}();t.FixedFormat=m;var g=function(){function e(t,n,i,o){var a=this.constructor;r.checkNew(a,e),this.format=o,this._hex=n,this._value=i,this._isFixedNumber=!0,Object.freeze(this)}return e.prototype._checkFormat=function(e){this.format.name!==e.format.name&&r.throwArgumentError("incompatible format; use fixedNumber.toFormat","other",e)},e.prototype.addUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.add(n),this.format.decimals,this.format)},e.prototype.subUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.sub(n),this.format.decimals,this.format)},e.prototype.mulUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(n).div(this.format._multiplier),this.format.decimals,this.format)},e.prototype.divUnsafe=function(t){this._checkFormat(t);var r=p(this._value,this.format.decimals),n=p(t._value,t.format.decimals);return e.fromValue(r.mul(this.format._multiplier).div(n),this.format.decimals,this.format)},e.prototype.round=function(t){null==t&&(t=0),(t<0||t>80||t%1)&&r.throwArgumentError("invalid decimal cound","decimals",t);var n=this.toString().split(".");if(n[1].length<=t)return this;var i="0."+s.substring(0,t)+"5";return n=this.addUnsafe(e.fromString(i,this.format))._value.split("."),e.fromString(n[0]+"."+n[1].substring(0,t))},e.prototype.toString=function(){return this._value},e.prototype.toHexString=function(e){if(null==e)return this._hex;e%8&&r.throwArgumentError("invalid byte width","width",e);var t=d.BigNumber.from(this._hex).fromTwos(this.format.width).toTwos(e).toHexString();return l.hexZeroPad(t,e/8)},e.prototype.toUnsafeFloat=function(){return parseFloat(this.toString())},e.prototype.toFormat=function(t){return e.fromString(this._value,t)},e.fromValue=function(t,r,n){return null!=n||null==r||d.isBigNumberish(r)||(n=r,r=null),null==r&&(r=0),null==n&&(n="fixed"),e.fromString(c(t,r),m.from(n))},e.fromString=function(t,r){null==r&&(r="fixed");var o=m.from(r),s=p(t,o.decimals);!o.signed&&s.lt(i)&&a("unsigned value cannot be negative","overflow","value",t);var u=null;o.signed?u=s.toTwos(o.width).toHexString():(u=s.toHexString(),u=l.hexZeroPad(u,o.width/8));var f=c(s,o.decimals);return new e(n,u,f,o)},e.fromBytes=function(t,r){null==r&&(r="fixed");var i=m.from(r);if(l.arrayify(t).length>i.width/8)throw new Error("overflow");var o=d.BigNumber.from(t);i.signed&&(o=o.fromTwos(i.width));var a=o.toTwos((i.signed?0:1)+i.width).toHexString(),s=c(o,i.decimals);return new e(n,a,s,i)},e.from=function(t,n){if("string"==typeof t)return e.fromString(t,n);if(l.isBytes(t))return e.fromBytes(t,n);try{return e.fromValue(t,0,n)}catch(e){if(e.code!==f.Logger.errors.INVALID_ARGUMENT)throw e}return r.throwArgumentError("invalid FixedNumber value","value",t)},e.isFixedNumber=function(e){return!(!e||!e._isFixedNumber)},e}();t.FixedNumber=g})),m=(r(p),p.formatFixed,p.parseFixed,p.FixedFormat,p.FixedNumber,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.BigNumber=d.BigNumber,t.formatFixed=p.formatFixed,t.FixedFormat=p.FixedFormat,t.FixedNumber=p.FixedNumber,t.parseFixed=p.parseFixed})),g=(r(m),m.BigNumber,m.formatFixed,m.FixedFormat,m.FixedNumber,m.parseFixed,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="properties/5.0.0-beta.130"})),y=(r(g),g.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(g.version);function n(e,t,r){Object.defineProperty(e,t,{enumerable:!0,value:r,writable:!1})}t.defineReadOnly=n,t.getStatic=function(e,t){for(var r=0;r<32;r++){if(e[t])return e[t];if(!e.prototype||"object"!=typeof e.prototype)break;e=Object.getPrototypeOf(e.prototype).constructor}return null},t.resolveProperties=function(e){var t=Object.keys(e).map(function(t){var r=e[t];return r instanceof Promise?r.then(function(e){return{key:t,value:e}}):Promise.resolve({key:t,value:r})});return Promise.all(t).then(function(e){return e.reduce(function(e,t){return e[t.key]=t.value,e},{})})},t.checkProperties=function(e,t){e&&"object"==typeof e||r.throwArgumentError("invalid object","object",e),Object.keys(e).forEach(function(n){t[n]||r.throwArgumentError("invalid object key - "+n,"transaction:"+n,e)})},t.shallowCopy=function(e){var t={};for(var r in e)t[r]=e[r];return t};var i={bigint:!0,boolean:!0,number:!0,string:!0};function o(e){if(null==e||i[typeof e])return e;if(Array.isArray(e))return Object.freeze(e.map(function(e){return o(e)}));if("object"==typeof e){if(Object.isFrozen(e))return e;var t={};for(var r in e){var a=e[r];void 0!==a&&n(t,r,o(a))}return t}if("function"==typeof e)return e;throw new Error("Cannot deepCopy "+typeof e)}t.deepCopy=o;var a=function(e){for(var t in e)this[t]=o(e[t]);Object.freeze(this)};t.Description=a})),v=(r(y),y.defineReadOnly,y.getStatic,y.resolveProperties,y.checkProperties,y.shallowCopy,y.deepCopy,y.Description,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abi/5.0.0-beta.136"})),b=(r(v),v.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version),a={},s={calldata:!0,memory:!0,storage:!0};function u(e,t){if("bytes"===e||"string"===e){if(s[t])return!0}else if("address"===e&&"payable"===t)return!0;return(s[t]||"payable"===t)&&o.throwArgumentError("invalid modifier","name",t),!1}function c(e,t){for(var r in t)y.defineReadOnly(e,r,t[r])}r.FormatTypes=Object.freeze({sighash:"sighash",minimal:"minimal",full:"full",json:"json"});var l=new RegExp(/^(.*)\[([0-9]*)\]$/),h=function(){function e(t,r){if(t!==a)throw new Error("use fromString");c(this,r);var n=this.type.match(l);c(this,n?{arrayLength:parseInt(n[2]||"-1"),arrayChildren:e.fromObject({type:n[1],components:this.components}),baseType:"array"}:{arrayLength:null,arrayChildren:null,baseType:null!=this.components?"tuple":this.type}),this._isParamType=!0,Object.freeze(this)}return e.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json){var t={type:"tuple"===this.baseType?"tuple":this.type,name:this.name||void 0};return"boolean"==typeof this.indexed&&(t.indexed=this.indexed),this.components&&(t.components=this.components.map(function(t){return JSON.parse(t.format(e))})),JSON.stringify(t)}var n="";return"array"===this.baseType?(n+=this.arrayChildren.format(e),n+="["+(this.arrayLength<0?"":String(this.arrayLength))+"]"):"tuple"===this.baseType?(e!==r.FormatTypes.sighash&&(n+=this.type),n+="("+this.components.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+")"):n+=this.type,e!==r.FormatTypes.sighash&&(!0===this.indexed&&(n+=" indexed"),e===r.FormatTypes.full&&this.name&&(n+=" "+this.name)),n},e.from=function(t,r){return"string"==typeof t?e.fromString(t,r):e.fromObject(t)},e.fromObject=function(t){return e.isParamType(t)?t:new e(a,{name:t.name||null,type:A(t.type),indexed:null==t.indexed?null:!!t.indexed,components:t.components?t.components.map(e.fromObject):null})},e.fromString=function(t,r){return function(t){return e.fromObject({name:t.name,type:t.type,indexed:t.indexed,components:t.components})}(function(e,t){var r=e;function n(e){throw new Error("unexpected character '"+r[e]+"' at position "+e+" in '"+r+"'")}function i(e){var r={type:"",name:"",parent:e,state:{allowType:!0}};return t&&(r.indexed=!1),r}e=e.replace(/\s/g," ");for(var o={type:"",name:"",state:{allowType:!0}},a=o,s=0;s2)throw new Error("invalid signature");if(!r[1].match(/^[0-9]+$/))throw new Error("invalid signature gas");return t.gas=m.BigNumber.from(r[1]),r[0]}return e}function w(e,t){t.constant=!1,t.payable=!1,t.stateMutability="nonpayable",e.split(" ").forEach(function(e){switch(e.trim()){case"constant":t.constant=!0;break;case"payable":t.payable=!0,t.stateMutability="payable";break;case"pure":t.constant=!0,t.stateMutability="pure";break;case"view":t.constant=!0,t.stateMutability="view";break;case"external":case"public":case"":break;default:console.log("unknown modifier: "+e)}})}function _(e){var t={constant:!1,payable:!0,stateMutability:"payable"};if(null!=e.stateMutability){if(t.stateMutability=e.stateMutability,t.constant="view"===t.stateMutability||"pure"===t.stateMutability,null!=e.constant&&!!e.constant!==t.constant)throw new Error("cannot have constant function with mutability "+t.stateMutability);if(t.payable="payable"===t.stateMutability,null!=e.payable&&!!e.payable!==t.payable)throw new Error("cannot have payable function with mutability "+t.stateMutability)}else if(null!=e.payable){if(t.payable=!!e.payable,t.stateMutability=t.payable?"payable":"nonpayable",t.constant=!t.payable,null!=e.constant&&e.constant!==t.constant)throw new Error("cannot have constant payable function")}else null!=e.constant&&(t.constant=!!e.constant,t.payable=!t.constant,t.stateMutability=t.constant?"view":"payable");return t}r.EventFragment=g;var E=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"constructor",stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))})});e===r.FormatTypes.sighash&&o.throwError("cannot format a constructor for sighash",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"format(sighash)"});var t="constructor("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ";return this.stateMutability&&"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isConstructorFragment(e))return e;if("constructor"!==e.type)throw new Error("invalid constructor object - "+e.type);var r=_(e);if(r.constant)throw new Error("constructor cannot be constant");return new t(a,{type:e.type,inputs:e.inputs?e.inputs.map(h.fromObject):[],payable:r.payable,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"constructor"},n=(e=b(e,r)).match(k);if(!n)throw new Error("invalid constructor: "+e);if("constructor"!==n[1].trim())throw new Error("invalid constructor");return r.inputs=d(n[2].trim(),!1),w(n[3].trim(),r),t.fromObject(r)},t.isConstructorFragment=function(e){return e&&e._isFragment&&"constructor"===e.type},t}(p);r.ConstructorFragment=E;var P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.format=function(e){if(e||(e=r.FormatTypes.sighash),r.FormatTypes[e]||o.throwArgumentError("invalid format type","format",e),e===r.FormatTypes.json)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payble:this.payable,gas:this.gas?this.gas.toNumber():void 0,inputs:this.inputs.map(function(t){return JSON.parse(t.format(e))}),ouputs:this.outputs.map(function(t){return JSON.parse(t.format(e))})});var t="";return e!==r.FormatTypes.sighash&&(t+="function "),t+=this.name+"("+this.inputs.map(function(t){return t.format(e)}).join(e===r.FormatTypes.full?", ":",")+") ",e!==r.FormatTypes.sighash&&(this.stateMutability?"nonpayable"!==this.stateMutability&&(t+=this.stateMutability+" "):this.constant&&(t+="view "),this.outputs&&this.outputs.length&&(t+="returns ("+this.outputs.map(function(t){return t.format(e)}).join(", ")+") "),null!=this.gas&&(t+="@"+this.gas.toString()+" ")),t.trim()},t.from=function(e){return"string"==typeof e?t.fromString(e):t.fromObject(e)},t.fromObject=function(e){if(t.isFunctionFragment(e))return e;if("function"!==e.type)throw new Error("invalid function object - "+e.type);var r=_(e);return new t(a,{type:e.type,name:M(e.name),constant:r.constant,inputs:e.inputs?e.inputs.map(h.fromObject):[],outputs:e.outputs?e.outputs.map(h.fromObject):[],payable:r.payable,stateMutability:r.stateMutability,gas:e.gas?m.BigNumber.from(e.gas):null})},t.fromString=function(e){var r={type:"function"},n=(e=b(e,r)).split(" returns ");if(n.length>2)throw new Error("invalid function");var i=n[0].match(k);if(!i)throw new Error("invalid signature");if(r.name=i[1].trim(),!r.name.match(S))throw new Error("invalid identifier: '"+r.name+"'");if(r.inputs=d(i[2],!1),w(i[3].trim(),r),n.length>1){var o=n[1].match(k);if(""!=o[1].trim()||""!=o[3].trim())throw new Error("unexpected tokens");r.outputs=d(o[2],!1)}else r.outputs=[];return t.fromObject(r)},t.isFunctionFragment=function(e){return e&&e._isFragment&&"function"===e.type},t}(E);function A(e){return e.match(/^uint($|[^1-9])/)?e="uint256"+e.substring(4):e.match(/^int($|[^1-9])/)&&(e="int256"+e.substring(3)),e}r.FunctionFragment=P;var S=new RegExp("^[A-Za-z_][A-Za-z0-9_]*$");function M(e){if(!e||!e.match(S))throw new Error("invalid identifier: '"+e+"'");return e}var k=new RegExp("^([^)(]*)\\((.*)\\)([^)(]*)$")})),w=(r(b),b.FormatTypes,b.ParamType,b.Fragment,b.EventFragment,b.ConstructorFragment,b.FunctionFragment,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=function(){function e(e,t,r,n){this.name=e,this.type=t,this.localName=r,this.dynamic=n}return e.prototype._throwError=function(e,t){r.throwArgumentError(e,this.localName,t)},e}();t.Coder=n;var i=function(){function e(e){y.defineReadOnly(this,"wordSize",e||32),this._data=l.arrayify([]),this._padding=new Uint8Array(e)}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),e.prototype._writeData=function(e){return this._data=l.concat([this._data,e]),e.length},e.prototype.writeBytes=function(e){var t=l.arrayify(e);return t.length%this.wordSize&&(t=l.concat([t,this._padding.slice(t.length%this.wordSize)])),this._writeData(t)},e.prototype._getValue=function(e){var t=l.arrayify(m.BigNumber.from(e));return t.length>this.wordSize&&r.throwError("value out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this.wordSize,offset:t.length}),t.length%this.wordSize&&(t=l.concat([this._padding.slice(t.length%this.wordSize),t])),t},e.prototype.writeValue=function(e){return this._writeData(this._getValue(e))},e.prototype.writeUpdatableValue=function(){var e=this,t=this.length;return this.writeValue(0),function(r){e._data.set(e._getValue(r),t)}},e}();t.Writer=i;var o=function(){function e(e,t,r){y.defineReadOnly(this,"_data",l.arrayify(e)),y.defineReadOnly(this,"wordSize",t||32),y.defineReadOnly(this,"_coerceFunc",r),this._offset=0}return Object.defineProperty(e.prototype,"data",{get:function(){return l.hexlify(this._data)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"consumed",{get:function(){return this._offset},enumerable:!0,configurable:!0}),e.coerce=function(e,t){var r=e.match("^u?int([0-9]+)$");return r&&parseInt(r[1])<=48&&(t=t.toNumber()),t},e.prototype.coerce=function(t,r){return this._coerceFunc?this._coerceFunc(t,r):e.coerce(t,r)},e.prototype._peekBytes=function(e,t){var n=Math.ceil(t/this.wordSize)*this.wordSize;return this._offset+n>this._data.length&&r.throwError("data out-of-bounds",f.Logger.errors.BUFFER_OVERRUN,{length:this._data.length,offset:this._offset+n}),this._data.slice(this._offset,this._offset+n)},e.prototype.subReader=function(t){return new e(this._data.slice(this._offset+t),this.wordSize,this._coerceFunc)},e.prototype.readBytes=function(e){var t=this._peekBytes(0,e);return this._offset+=t.length,t.slice(0,e)},e.prototype.readValue=function(){return m.BigNumber.from(this.readBytes(this.wordSize))},e}();t.Reader=o})),_=(r(w),w.Coder,w.Writer,w.Reader,n(function(e){!function(){var r="object"==typeof window?window:{};!r.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node&&(r=t);for(var n=!r.JS_SHA3_NO_COMMON_JS&&e.exports,i="0123456789abcdef".split(""),o=[0,8,16,24],a=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],s=[224,256,384,512],u=["hex","buffer","arrayBuffer","array"],f=function(e,t,r){return function(n){return new w(e,t,e).update(n)[r]()}},c=function(e,t,r){return function(n,i){return new w(e,t,i).update(n)[r]()}},l=function(e,t){var r=f(e,t,"hex");r.create=function(){return new w(e,t,e)},r.update=function(e){return r.create().update(e)};for(var n=0;n>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}w.prototype.update=function(e){var t="string"!=typeof e;t&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e));for(var r,n,i=e.length,a=this.blocks,s=this.byteCount,u=this.blockCount,f=0,c=this.s;f>2]|=e[f]<>2]|=n<>2]|=(192|n>>6)<>2]|=(128|63&n)<=57344?(a[r>>2]|=(224|n>>12)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<>2]|=(240|n>>18)<>2]|=(128|n>>12&63)<>2]|=(128|n>>6&63)<>2]|=(128|63&n)<=s){for(this.start=r-s,this.block=a[u],r=0;r>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t>4&15]+i[15&e]+i[e>>12&15]+i[e>>8&15]+i[e>>20&15]+i[e>>16&15]+i[e>>28&15]+i[e>>24&15];s%t==0&&(_(r),a=0)}return o&&(e=r[a],o>0&&(u+=i[e>>4&15]+i[15&e]),o>1&&(u+=i[e>>12&15]+i[e>>8&15]),o>2&&(u+=i[e>>20&15]+i[e>>16&15])),u},w.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,o=0,a=0,s=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(s);for(var u=new Uint32Array(e);a>8&255,u[e+2]=t>>16&255,u[e+3]=t>>24&255;s%r==0&&_(n)}return o&&(e=s<<2,t=n[a],o>0&&(u[e]=255&t),o>1&&(u[e+1]=t>>8&255),o>2&&(u[e+2]=t>>16&255)),u};var _=function(e){var t,r,n,i,o,s,u,f,c,l,h,d,p,m,g,y,v,b,w,_,E,P,A,S,M,k,x,O,N,T,C,R,B,I,F,L,j,D,U,z,H,K,W,q,G,V,J,Z,X,$,Q,Y,ee,te,re,ne,ie,oe,ae,se,ue,fe,ce;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],o=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],u=e[3]^e[13]^e[23]^e[33]^e[43],f=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|u>>>31),r=(p=e[9]^e[19]^e[29]^e[39]^e[49])^(u<<1|s>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(f<<1|c>>>31),r=o^(c<<1|f>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=s^(l<<1|h>>>31),r=u^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=f^(d<<1|p>>>31),r=c^(p<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|o>>>31),r=h^(o<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,m=e[0],g=e[1],V=e[11]<<4|e[10]>>>28,J=e[10]<<4|e[11]>>>28,O=e[20]<<3|e[21]>>>29,N=e[21]<<3|e[20]>>>29,se=e[31]<<9|e[30]>>>23,ue=e[30]<<9|e[31]>>>23,K=e[40]<<18|e[41]>>>14,W=e[41]<<18|e[40]>>>14,I=e[2]<<1|e[3]>>>31,F=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,v=e[12]<<12|e[13]>>>20,Z=e[22]<<10|e[23]>>>22,X=e[23]<<10|e[22]>>>22,T=e[33]<<13|e[32]>>>19,C=e[32]<<13|e[33]>>>19,fe=e[42]<<2|e[43]>>>30,ce=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,L=e[14]<<6|e[15]>>>26,j=e[15]<<6|e[14]>>>26,b=e[25]<<11|e[24]>>>21,w=e[24]<<11|e[25]>>>21,$=e[34]<<15|e[35]>>>17,Q=e[35]<<15|e[34]>>>17,R=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,S=e[6]<<28|e[7]>>>4,M=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,D=e[26]<<25|e[27]>>>7,U=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Y=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,q=e[8]<<27|e[9]>>>5,G=e[9]<<27|e[8]>>>5,k=e[18]<<20|e[19]>>>12,x=e[19]<<20|e[18]>>>12,oe=e[29]<<7|e[28]>>>25,ae=e[28]<<7|e[29]>>>25,z=e[38]<<8|e[39]>>>24,H=e[39]<<8|e[38]>>>24,P=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=m^~y&b,e[1]=g^~v&w,e[10]=S^~k&O,e[11]=M^~x&N,e[20]=I^~L&D,e[21]=F^~j&U,e[30]=q^~V&Z,e[31]=G^~J&X,e[40]=te^~ne&oe,e[41]=re^~ie&ae,e[2]=y^~b&_,e[3]=v^~w&E,e[12]=k^~O&T,e[13]=x^~N&C,e[22]=L^~D&z,e[23]=j^~U&H,e[32]=V^~Z&$,e[33]=J^~X&Q,e[42]=ne^~oe&se,e[43]=ie^~ae&ue,e[4]=b^~_&P,e[5]=w^~E&A,e[14]=O^~T&R,e[15]=N^~C&B,e[24]=D^~z&K,e[25]=U^~H&W,e[34]=Z^~$&Y,e[35]=X^~Q&ee,e[44]=oe^~se&fe,e[45]=ae^~ue&ce,e[6]=_^~P&m,e[7]=E^~A&g,e[16]=T^~R&S,e[17]=C^~B&M,e[26]=z^~K&I,e[27]=H^~W&F,e[36]=$^~Y&q,e[37]=Q^~ee&G,e[46]=se^~fe&te,e[47]=ue^~ce&re,e[8]=P^~m&y,e[9]=A^~g&v,e[18]=R^~S&k,e[19]=B^~M&x,e[28]=K^~I&L,e[29]=W^~F&j,e[38]=Y^~q&V,e[39]=ee^~G&J,e[48]=fe^~te&ne,e[49]=ce^~re&ie,e[0]^=a[n],e[1]^=a[n+1]};if(n)e.exports=d;else for(m=0;m>=8;return t}function n(e,t,r){for(var n=0,i=0;it+1+n)throw new Error("invalid rlp")}return{consumed:1+n,result:i}}function o(e,t){if(0===e.length)throw new Error("invalid rlp data");if(e[t]>=248){if(t+1+(a=e[t]-247)>e.length)throw new Error("too short");var r=n(e,t+1,a);if(t+1+a+r>e.length)throw new Error("to short");return i(e,t,t+1+a,a+r)}if(e[t]>=192){var o=e[t]-192;if(t+1+o>e.length)throw new Error("invalid rlp data");return i(e,t,t+1,o)}if(e[t]>=184){var a;if(t+1+(a=e[t]-183)>e.length)throw new Error("invalid rlp data");var s=n(e,t+1,a);if(t+1+a+s>e.length)throw new Error("invalid rlp data");return{consumed:1+a+s,result:l.hexlify(e.slice(t+1+a,t+1+a+s))}}if(e[t]>=128){var u=e[t]-128;if(t+1+u>e.length)throw new Error("invlaid rlp data");return{consumed:1+u,result:l.hexlify(e.slice(t+1,t+1+u))}}return{consumed:1,result:l.hexlify(e[t])}}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function(e){return l.hexlify(function e(t){if(Array.isArray(t)){var n=[];if(t.forEach(function(t){n=n.concat(e(t))}),n.length<=55)return n.unshift(192+n.length),n;var i=r(n.length);return i.unshift(247+i.length),i.concat(n)}var o=Array.prototype.slice.call(l.arrayify(t));if(1===o.length&&o[0]<=127)return o;if(o.length<=55)return o.unshift(128+o.length),o;var a=r(o.length);return a.unshift(183+a.length),a.concat(o)}(e))},t.decode=function(e){var t=l.arrayify(e),r=o(t,0);if(r.consumed!==t.length)throw new Error("invalid rlp data");return r.result}})),A=(r(P),P.encode,P.decode,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="address/5.0.0-beta.127"})),S=(r(A),A.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(A.version);function n(e){l.isHexString(e,20)||r.throwArgumentError("invalid address","address",e);for(var t=(e=e.toLowerCase()).substring(2).split(""),n=new Uint8Array(40),i=0;i<40;i++)n[i]=t[i].charCodeAt(0);n=l.arrayify(E.keccak256(n));for(i=0;i<40;i+=2)n[i>>1]>>4>=8&&(t[i]=t[i].toUpperCase()),(15&n[i>>1])>=8&&(t[i+1]=t[i+1].toUpperCase());return"0x"+t.join("")}for(var i={},o=0;o<10;o++)i[String(o)]=String(o);for(o=0;o<26;o++)i[String.fromCharCode(65+o)]=String(10+o);var a,u=Math.floor((a=9007199254740991,Math.log10?Math.log10(a):Math.log(a)/Math.LN10));function c(e){e=(e=e.toUpperCase()).substring(4)+e.substring(0,2)+"00";var t="";for(e.split("").forEach(function(e){t+=i[e]});t.length>=u;){var r=t.substring(0,u);t=parseInt(r,10)%97+t.substring(r.length)}for(var n=String(98-parseInt(t,10)%97);n.length<2;)n="0"+n;return n}function h(e){var t=null;if("string"!=typeof e&&r.throwArgumentError("invalid address","address",e),e.match(/^(0x)?[0-9a-fA-F]{40}$/))"0x"!==e.substring(0,2)&&(e="0x"+e),t=n(e),e.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&t!==e&&r.throwArgumentError("bad address checksum","address",e);else if(e.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(e.substring(2,4)!==c(e)&&r.throwArgumentError("bad icap checksum","address",e),t=new s.BN(e.substring(4),36).toString(16);t.length<40;)t="0"+t;t=n("0x"+t)}else r.throwArgumentError("invalid address","address",e);return t}t.getAddress=h,t.isAddress=function(e){try{return h(e),!0}catch(e){}return!1},t.getIcapAddress=function(e){for(var t=new s.BN(h(e).substring(2),16).toString(36).toUpperCase();t.length<30;)t="0"+t;return"XE"+c("XE00"+t)+t},t.getContractAddress=function(e){var t=null;try{t=h(e.from)}catch(t){r.throwArgumentError("missing from address","transaction",e)}var n=l.stripZeros(l.arrayify(e.nonce));return h(l.hexDataSlice(E.keccak256(P.encode([t,n])),12))}})),M=(r(S),S.getAddress,S.isAddress,S.getIcapAddress,S.getContractAddress,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"address","address",t,!1)||this}return i(t,e),t.prototype.encode=function(e,t){try{S.getAddress(t)}catch(e){this._throwError(e.message,t)}return e.writeValue(t)},t.prototype.decode=function(e){return S.getAddress(l.hexZeroPad(e.readValue().toHexString(),20))},t}(w.Coder);r.AddressCoder=o})),k=(r(M),M.AddressCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){var r=e.call(this,t.name,t.type,void 0,t.dynamic)||this;return r.coder=t,r}return i(t,e),t.prototype.encode=function(e,t){return this.coder.encode(e,t)},t.prototype.decode=function(e){return this.coder.decode(e)},t}(w.Coder);r.AnonymousCoder=o})),x=(r(k),k.AnonymousCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(v.version);function a(e,t,r){if(Array.isArray(r));else if(r&&"object"==typeof r){var n=[];t.forEach(function(e){n.push(r[e.localName])}),r=n}else o.throwArgumentError("invalid tuple value","tuple",r);t.length!==r.length&&o.throwArgumentError("types/value length mismatch","tuple",r);var i=new w.Writer(e.wordSize),a=new w.Writer(e.wordSize),s=[];t.forEach(function(e,t){var n=r[t];if(e.dynamic){var o=a.length;e.encode(a,n);var u=i.writeUpdatableValue();s.push(function(e){u(e+o)})}else e.encode(i,n)}),s.forEach(function(e){e(i.length)});var u=e.writeBytes(i.data);return u+=e.writeBytes(a.data)}function s(e,t){var r=[],n=e.subReader(0),i=0;return t.forEach(function(t){var o=null;if(t.dynamic){var a=e.readValue(),s=n.subReader(a.toNumber());o=t.decode(s),i+=s.consumed}else o=t.decode(e);null!=o&&r.push(o)}),e.readBytes(i),t.forEach(function(e,t){var n=e.localName;n&&("length"===n&&(n="_length"),null==r[n]&&(r[n]=r[t]))}),r}r.pack=a,r.unpack=s;var u=function(e){function t(t,r,n){var i=this,o=t.type+"["+(r>=0?r:"")+"]",a=-1===r||t.dynamic;return(i=e.call(this,"array",o,n,a)||this).coder=t,i.length=r,i}return i(t,e),t.prototype.encode=function(e,t){Array.isArray(t)||this._throwError("expected array value",t);var r=this.length;-1===r&&(r=t.length,e.writeValue(t.length)),o.checkArgumentCount(r,t.length,"coder array"+(this.localName?" "+this.localName:""));for(var n=[],i=0;i>7!=0){var o=null,a=null;if(192==(224&i))o=1,a=127;else if(224==(240&i))o=2,a=2047;else{if(240!=(248&i)){if(!t){if(128==(192&i))throw new Error("invalid utf8 byte sequence; unexpected continuation byte");throw new Error("invalid utf8 byte sequence; invalid prefix")}continue}o=3,a=65535}if(n+o>e.length){if(!t)throw new Error("invalid utf8 byte sequence; too short");for(;n>6==2;n++);}else{for(var s=i&(1<<8-o-1)-1,u=0;u1114111){if(!t)throw new Error("invalid utf8 byte sequence; out-of-range")}else if(s>=55296&&s<=57343){if(!t)throw new Error("invalid utf8 byte sequence; utf-16 surrogate")}else r.push(s);else if(!t)throw new Error("invalid utf8 byte sequence; invalid continuation byte")}}else r.push(i)}return r}function o(e,t){void 0===t&&(t=r.current),t!=r.current&&(n.checkNormalize(),e=e.normalize(t));for(var i=[],o=0;o>6|192),i.push(63&a|128);else if(55296==(64512&a)){o++;var s=e.charCodeAt(o);if(o>=e.length||56320!=(64512&s))throw new Error("invalid utf-8 string");a=65536+((1023&a)<<10)+(1023&s),i.push(a>>18|240),i.push(a>>12&63|128),i.push(a>>6&63|128),i.push(63&a|128)}else i.push(a>>12|224),i.push(a>>6&63|128),i.push(63&a|128)}return l.arrayify(i)}function a(e){var t="0000"+e.toString(16);return"\\u"+t.substring(t.length-4)}function s(e){return e.map(function(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10&1023),56320+(1023&e)))}).join("")}!function(e){e.current="",e.NFC="NFC",e.NFD="NFD",e.NFKC="NFKC",e.NFKD="NFKD"}(r=t.UnicodeNormalizationForm||(t.UnicodeNormalizationForm={})),t.toUtf8Bytes=o,t._toEscapedUtf8String=function(e,t){return'"'+i(e,t).map(function(e){if(e<256){switch(e){case 8:return"\\b";case 9:return"\\t";case 10:return"\\n";case 13:return"\\r";case 34:return'\\"';case 92:return"\\\\"}if(e>=32&&e<127)return String.fromCharCode(e)}return e<=65535?a(e):a(55296+((e-=65536)>>10&1023))+a(56320+(1023&e))}).join("")+'"'},t._toUtf8String=s,t.toUtf8String=function(e,t){return s(i(e,t))},t.toUtf8CodePoints=function(e,t){return void 0===t&&(t=r.current),i(o(e,t))}})),L=(r(F),F.UnicodeNormalizationForm,F.toUtf8Bytes,F._toEscapedUtf8String,F._toUtf8String,F.toUtf8String,F.toUtf8CodePoints,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=function(e){var t=F.toUtf8Bytes(e);if(t.length>31)throw new Error("bytes32 string must be less than 32 bytes");return l.hexlify(l.concat([t,R.HashZero]).slice(0,32))},t.parseBytes32String=function(e){var t=l.arrayify(e);if(32!==t.length)throw new Error("invalid bytes32 - not 32 bytes long");if(0!==t[31])throw new Error("invalid bytes32 string - no null terminator");for(var r=31;0===t[r-1];)r--;return F.toUtf8String(t.slice(0,r))}})),j=(r(L),L.formatBytes32String,L.parseBytes32String,n(function(e,t){function r(e,t){t||(t=function(e){return[parseInt(e,16)]});var r=0,n={};return e.split(",").forEach(function(e){var i=e.split(":");r+=parseInt(i[0],16),n[r]=t(i[1])}),n}function n(e){var t=0;return e.split(",").map(function(e){var r=e.split("-");return 1===r.length?r[1]="0":""===r[1]&&(r[1]="1"),{l:t+parseInt(r[0],16),h:t=parseInt(r[1],16)}})}function i(e,t){for(var r=0,n=0;n=(r+=i.l)&&e<=r+i.h&&(e-r)%(i.d||1)==0){if(i.e&&-1!==i.e.indexOf(e-r))continue;return i}}return null}Object.defineProperty(t,"__esModule",{value:!0});var o=n("221,13-1b,5f-,40-10,51-f,11-3,3-3,2-2,2-4,8,2,15,2d,28-8,88,48,27-,3-5,11-20,27-,8,28,3-5,12,18,b-a,1c-4,6-16,2-d,2-2,2,1b-4,17-9,8f-,10,f,1f-2,1c-34,33-14e,4,36-,13-,6-2,1a-f,4,9-,3-,17,8,2-2,5-,2,8-,3-,4-8,2-3,3,6-,16-6,2-,7-3,3-,17,8,3,3,3-,2,6-3,3-,4-a,5,2-6,10-b,4,8,2,4,17,8,3,6-,b,4,4-,2-e,2-4,b-10,4,9-,3-,17,8,3-,5-,9-2,3-,4-7,3-3,3,4-3,c-10,3,7-2,4,5-2,3,2,3-2,3-2,4-2,9,4-3,6-2,4,5-8,2-e,d-d,4,9,4,18,b,6-3,8,4,5-6,3-8,3-3,b-11,3,9,4,18,b,6-3,8,4,5-6,3-6,2,3-3,b-11,3,9,4,18,11-3,7-,4,5-8,2-7,3-3,b-11,3,13-2,19,a,2-,8-2,2-3,7,2,9-11,4-b,3b-3,1e-24,3,2-,3,2-,2-5,5,8,4,2,2-,3,e,4-,6,2,7-,b-,3-21,49,23-5,1c-3,9,25,10-,2-2f,23,6,3,8-2,5-5,1b-45,27-9,2a-,2-3,5b-4,45-4,53-5,8,40,2,5-,8,2,5-,28,2,5-,20,2,5-,8,2,5-,8,8,18,20,2,5-,8,28,14-5,1d-22,56-b,277-8,1e-2,52-e,e,8-a,18-8,15-b,e,4,3-b,5e-2,b-15,10,b-5,59-7,2b-555,9d-3,5b-5,17-,7-,27-,7-,9,2,2,2,20-,36,10,f-,7,14-,4,a,54-3,2-6,6-5,9-,1c-10,13-1d,1c-14,3c-,10-6,32-b,240-30,28-18,c-14,a0,115-,3,66-,b-76,5,5-,1d,24,2,5-2,2,8-,35-2,19,f-10,1d-3,311-37f,1b,5a-b,d7-19,d-3,41,57-,68-4,29-3,5f,29-37,2e-2,25-c,2c-2,4e-3,30,78-3,64-,20,19b7-49,51a7-59,48e-2,38-738,2ba5-5b,222f-,3c-94,8-b,6-4,1b,6,2,3,3,6d-20,16e-f,41-,37-7,2e-2,11-f,5-b,18-,b,14,5-3,6,88-,2,bf-2,7-,7-,7-,4-2,8,8-9,8-2ff,20,5-b,1c-b4,27-,27-cbb1,f7-9,28-2,b5-221,56,48,3-,2-,3-,5,d,2,5,3,42,5-,9,8,1d,5,6,2-2,8,153-3,123-3,33-27fd,a6da-5128,21f-5df,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3-fffd,3,2-1d,61-ff7d"),a="ad,34f,1806,180b,180c,180d,200b,200c,200d,2060,feff".split(",").map(function(e){return parseInt(e,16)}),s=[{h:25,s:32,l:65},{h:30,s:32,e:[23],l:127},{h:54,s:1,e:[48],l:64,d:2},{h:14,s:1,l:57,d:2},{h:44,s:1,l:17,d:2},{h:10,s:1,e:[2,6,8],l:61,d:2},{h:16,s:1,l:68,d:2},{h:84,s:1,e:[18,24,66],l:19,d:2},{h:26,s:32,e:[17],l:435},{h:22,s:1,l:71,d:2},{h:15,s:80,l:40},{h:31,s:32,l:16},{h:32,s:1,l:80,d:2},{h:52,s:1,l:42,d:2},{h:12,s:1,l:55,d:2},{h:40,s:1,e:[38],l:15,d:2},{h:14,s:1,l:48,d:2},{h:37,s:48,l:49},{h:148,s:1,l:6351,d:2},{h:88,s:1,l:160,d:2},{h:15,s:16,l:704},{h:25,s:26,l:854},{h:25,s:32,l:55915},{h:37,s:40,l:1247},{h:25,s:-119711,l:53248},{h:25,s:-119763,l:52},{h:25,s:-119815,l:52},{h:25,s:-119867,e:[1,4,5,7,8,11,12,17],l:52},{h:25,s:-119919,l:52},{h:24,s:-119971,e:[2,7,8,17],l:52},{h:24,s:-120023,e:[2,7,13,15,16,17],l:52},{h:25,s:-120075,l:52},{h:25,s:-120127,l:52},{h:25,s:-120179,l:52},{h:25,s:-120231,l:52},{h:25,s:-120283,l:52},{h:25,s:-120335,l:52},{h:24,s:-119543,e:[17],l:56},{h:24,s:-119601,e:[17],l:58},{h:24,s:-119659,e:[17],l:58},{h:24,s:-119717,e:[17],l:58},{h:24,s:-119775,e:[17],l:58}],u=r("b5:3bc,c3:ff,7:73,2:253,5:254,3:256,1:257,5:259,1:25b,3:260,1:263,2:269,1:268,5:26f,1:272,2:275,7:280,3:283,5:288,3:28a,1:28b,5:292,3f:195,1:1bf,29:19e,125:3b9,8b:3b2,1:3b8,1:3c5,3:3c6,1:3c0,1a:3ba,1:3c1,1:3c3,2:3b8,1:3b5,1bc9:3b9,1c:1f76,1:1f77,f:1f7a,1:1f7b,d:1f78,1:1f79,1:1f7c,1:1f7d,107:63,5:25b,4:68,1:68,1:68,3:69,1:69,1:6c,3:6e,4:70,1:71,1:72,1:72,1:72,7:7a,2:3c9,2:7a,2:6b,1:e5,1:62,1:63,3:65,1:66,2:6d,b:3b3,1:3c0,6:64,1b574:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3,20:3b8,1a:3c3"),f=r("179:1,2:1,2:1,5:1,2:1,a:4f,a:1,8:1,2:1,2:1,3:1,5:1,3:1,4:1,2:1,3:1,4:1,8:2,1:1,2:2,1:1,2:2,27:2,195:26,2:25,1:25,1:25,2:40,2:3f,1:3f,33:1,11:-6,1:-9,1ac7:-3a,6d:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,b:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,c:-8,2:-8,2:-8,2:-8,9:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,1:-8,49:-8,1:-8,1:-4a,1:-4a,d:-56,1:-56,1:-56,1:-56,d:-8,1:-8,f:-8,1:-8,3:-7"),c=r("df:00730073,51:00690307,19:02BC006E,a7:006A030C,18a:002003B9,16:03B903080301,20:03C503080301,1d7:05650582,190f:00680331,1:00740308,1:0077030A,1:0079030A,1:006102BE,b6:03C50313,2:03C503130300,2:03C503130301,2:03C503130342,2a:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F0003B9,1:1F0103B9,1:1F0203B9,1:1F0303B9,1:1F0403B9,1:1F0503B9,1:1F0603B9,1:1F0703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F2003B9,1:1F2103B9,1:1F2203B9,1:1F2303B9,1:1F2403B9,1:1F2503B9,1:1F2603B9,1:1F2703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,1:1F6003B9,1:1F6103B9,1:1F6203B9,1:1F6303B9,1:1F6403B9,1:1F6503B9,1:1F6603B9,1:1F6703B9,3:1F7003B9,1:03B103B9,1:03AC03B9,2:03B10342,1:03B1034203B9,5:03B103B9,6:1F7403B9,1:03B703B9,1:03AE03B9,2:03B70342,1:03B7034203B9,5:03B703B9,6:03B903080300,1:03B903080301,3:03B90342,1:03B903080342,b:03C503080300,1:03C503080301,1:03C10313,2:03C50342,1:03C503080342,b:1F7C03B9,1:03C903B9,1:03CE03B9,2:03C90342,1:03C9034203B9,5:03C903B9,ac:00720073,5b:00B00063,6:00B00066,d:006E006F,a:0073006D,1:00740065006C,1:0074006D,124f:006800700061,2:00610075,2:006F0076,b:00700061,1:006E0061,1:03BC0061,1:006D0061,1:006B0061,1:006B0062,1:006D0062,1:00670062,3:00700066,1:006E0066,1:03BC0066,4:0068007A,1:006B0068007A,1:006D0068007A,1:00670068007A,1:00740068007A,15:00700061,1:006B00700061,1:006D00700061,1:006700700061,8:00700076,1:006E0076,1:03BC0076,1:006D0076,1:006B0076,1:006D0076,1:00700077,1:006E0077,1:03BC0077,1:006D0077,1:006B0077,1:006D0077,1:006B03C9,1:006D03C9,2:00620071,3:00632215006B0067,1:0063006F002E,1:00640062,1:00670079,2:00680070,2:006B006B,1:006B006D,9:00700068,2:00700070006D,1:00700072,2:00730076,1:00770062,c723:00660066,1:00660069,1:0066006C,1:006600660069,1:00660066006C,1:00730074,1:00730074,d:05740576,1:05740565,1:0574056B,1:057E0576,1:0574056D",function(e){if(e.length%4!=0)throw new Error("bad data");for(var t=[],r=0;r=0)return[];if(e>=65024&&e<=65039)return[];var t=d(e);return t||[e]}),r=t.reduce(function(e,t){return t.forEach(function(t){e.push(t)}),e},[]),(r=F.toUtf8CodePoints(F._toUtf8String(r),F.UnicodeNormalizationForm.NFKC)).forEach(function(e){if(p(e))throw new Error("STRINGPREP_CONTAINS_PROHIBITED")}),r.forEach(function(e){if(h(e))throw new Error("STRINGPREP_CONTAINS_UNASSIGNED")});var n=F._toUtf8String(r);if("-"===n.substring(0,1)||"--"===n.substring(2,4)||"-"===n.substring(n.length-1))throw new Error("invalid hyphen");if(n.length>63)throw new Error("too long");return n}})),D=(r(j),j._nameprepTableA1,j._nameprepTableB2,j._nameprepTableC,j.nameprep,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatBytes32String=L.formatBytes32String,t.parseBytes32String=L.parseBytes32String,t.nameprep=j.nameprep,t._toEscapedUtf8String=F._toEscapedUtf8String,t.toUtf8Bytes=F.toUtf8Bytes,t.toUtf8CodePoints=F.toUtf8CodePoints,t.toUtf8String=F.toUtf8String,t.UnicodeNormalizationForm=F.UnicodeNormalizationForm})),U=(r(D),D.formatBytes32String,D.parseBytes32String,D.nameprep,D._toEscapedUtf8String,D.toUtf8Bytes,D.toUtf8CodePoints,D.toUtf8String,D.UnicodeNormalizationForm,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t){return e.call(this,"string",t)||this}return i(t,e),t.prototype.encode=function(t,r){return e.prototype.encode.call(this,t,D.toUtf8Bytes(r))},t.prototype.decode=function(t){return D.toUtf8String(e.prototype.decode.call(this,t))},t}(N.DynamicBytesCoder);r.StringCoder=o})),z=(r(U),U.StringCoder,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=function(e){function t(t,r){var n=this,i=!1,o=[];t.forEach(function(e){e.dynamic&&(i=!0),o.push(e.type)});var a="tuple("+o.join(",")+")";return(n=e.call(this,"tuple",a,r,i)||this).coders=t,n}return i(t,e),t.prototype.encode=function(e,t){return x.pack(e,this.coders,t)},t.prototype.decode=function(e){return e.coerce(this.name,x.unpack(e,this.coders))},t}(w.Coder);r.TupleCoder=o})),H=(r(z),z.TupleCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(v.version),n=new RegExp(/^bytes([0-9]*)$/),i=new RegExp(/^(u?int)([0-9]*)$/),o=function(){function e(t){var n=this.constructor;r.checkNew(n,e),y.defineReadOnly(this,"coerceFunc",t||null)}return e.prototype._getCoder=function(e){var t=this;switch(e.baseType){case"address":return new M.AddressCoder(e.name);case"bool":return new O.BooleanCoder(e.name);case"string":return new U.StringCoder(e.name);case"bytes":return new N.BytesCoder(e.name);case"array":return new x.ArrayCoder(this._getCoder(e.arrayChildren),e.arrayLength,e.name);case"tuple":return new z.TupleCoder((e.components||[]).map(function(e){return t._getCoder(e)}),e.name);case"":return new C.NullCoder(e.name)}var o,a=e.type.match(i);return a?((0===(o=parseInt(a[2]||"256"))||o>256||o%8!=0)&&r.throwArgumentError("invalid "+a[1]+" bit length","param",e),new B.NumberCoder(o/8,"int"===a[1],e.name)):(a=e.type.match(n))?((0===(o=parseInt(a[1]))||o>32)&&r.throwArgumentError("invalid bytes length","param",e),new T.FixedBytesCoder(o,e.name)):r.throwError("invalid type","type",e.type)},e.prototype._getWordSize=function(){return 32},e.prototype._getReader=function(e){return new w.Reader(e,this._getWordSize(),this.coerceFunc)},e.prototype._getWriter=function(){return new w.Writer(this._getWordSize())},e.prototype.encode=function(e,t){var n=this;e.length!==t.length&&r.throwError("types/values length mismatch",f.Logger.errors.INVALID_ARGUMENT,{count:{types:e.length,values:t.length},value:{types:e,values:t}});var i=e.map(function(e){return n._getCoder(b.ParamType.from(e))}),o=new z.TupleCoder(i,"_"),a=this._getWriter();return o.encode(a,t),a.data},e.prototype.decode=function(e,t){var r=this,n=e.map(function(e){return r._getCoder(b.ParamType.from(e))});return new z.TupleCoder(n,"_").decode(this._getReader(l.arrayify(t)))},e}();t.AbiCoder=o,t.defaultAbiCoder=new o})),K=(r(H),H.AbiCoder,H.defaultAbiCoder,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hash/5.0.0-beta.127"})),W=(r(K),K.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(K.version),n=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i=new RegExp("^((.*)\\.)?([^.]+)$");t.isValidName=function(e){try{for(var t=e.split("."),r=0;re.inputs.length&&o.throwError("too many arguments for "+e.format(),f.Logger.errors.UNEXPECTED_ARGUMENT,{argument:"values",value:t});var n=[];for(e.anonymous||n.push(this.getEventTopic(e)),t.forEach(function(t,i){var a=e.inputs[i];a.indexed?null==t?n.push(null):"string"===a.type?n.push(W.id(t)):"bytes"===a.type?n.push(E.keccak256(l.hexlify(t))):-1!==a.type.indexOf("[")||"tuple"===a.type.substring(0,5)?o.throwArgumentError("filtering with tuples or arrays not supported","contract."+a.name,t):("address"===a.type&&r._abiCoder.encode(["address"],[t]),n.push(l.hexZeroPad(l.hexlify(t),32))):null!=t&&o.throwArgumentError("cannot filter non-indexed parameters; must be null","contract."+a.name,t)});n.length&&null===n[n.length-1];)n.pop();return n},e.prototype.decodeEventLog=function(e,t,r){if("string"==typeof e&&(e=this.getEvent(e)),null!=r&&!e.anonymous){var n=this.getEventTopic(e);l.isHexString(r[0],32)&&r[0].toLowerCase()===n||o.throwError("fragment/topic mismatch",f.Logger.errors.INVALID_ARGUMENT,{argument:"topics[0]",expected:n,value:r[0]}),r=r.slice(1)}var i=[],a=[],s=[];e.inputs.forEach(function(e,t){e.indexed?"string"===e.type||"bytes"===e.type||"tuple"===e.baseType||"array"===e.baseType?(i.push(b.ParamType.fromObject({type:"bytes32",name:e.name})),s.push(!0)):(i.push(e),s.push(!1)):(a.push(e),s.push(!1))});var c=null!=r?this._abiCoder.decode(i,l.concat(r)):null,h=this._abiCoder.decode(a,t),d=[],p=0,m=0;return e.inputs.forEach(function(e,t){e.indexed?null==c?d[t]=new u({_isIndexed:!0,hash:null}):s[t]?d[t]=new u({_isIndexed:!0,hash:c[m++]}):d[t]=c[m++]:d[t]=h[p++]}),d},e.prototype.parseTransaction=function(e){var t=this.getFunction(e.data.substring(0,10).toLowerCase());return t?new s({args:this._abiCoder.decode(t.inputs,"0x"+e.data.substring(10)),functionFragment:t,name:t.name,signature:t.format(),sighash:this.getSighash(t),value:m.BigNumber.from(e.value||"0")}):null},e.prototype.parseLog=function(e){var t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new a({eventFragment:t,name:t.name,signature:t.format(),topic:this.getEventTopic(t),values:this.decodeEventLog(t,e.data,e.topics)})},e.isInterface=function(e){return!(!e||!e._isInterface)},e}();function d(e,t,r){for(var n in r)if(-1!==n.indexOf("(")){var i=r[n];if(t(i)===e)return i}return null}r.Interface=h})),G=(r(q),q.LogDescription,q.TransactionDescription,q.Indexed,q.Result,q.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.ConstructorFragment=b.ConstructorFragment,t.EventFragment=b.EventFragment,t.FormatTypes=b.FormatTypes,t.Fragment=b.Fragment,t.FunctionFragment=b.FunctionFragment,t.ParamType=b.ParamType,t.AbiCoder=H.AbiCoder,t.defaultAbiCoder=H.defaultAbiCoder,t.Indexed=q.Indexed,t.Interface=q.Interface})),V=(r(G),G.ConstructorFragment,G.EventFragment,G.FormatTypes,G.Fragment,G.FunctionFragment,G.ParamType,G.AbiCoder,G.defaultAbiCoder,G.Indexed,G.Interface,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-provider/5.0.0-beta.130"})),J=(r(V),V.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(V.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.isForkEvent=function(e){return!(!e||!e._isForkEvent)},t}(y.Description);r.ForkEvent=a;var s=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid blockhash","blockhash",t),e.call(this,{_isForkEvent:!0,_isBlockForkEvent:!0,expiry:r||0,blockHash:t})||this}return i(t,e),t}(a);r.BlockForkEvent=s;var u=function(e){function t(t,r){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","hash",t),e.call(this,{_isForkEvent:!0,_isTransactionForkEvent:!0,expiry:r||0,hash:t})||this}return i(t,e),t}(a);r.TransactionForkEvent=u;var c=function(e){function t(t,r,n){return l.isHexString(t,32)||o.throwArgumentError("invalid transaction hash","beforeHash",t),l.isHexString(r,32)||o.throwArgumentError("invalid transaction hash","afterHash",r),e.call(this,{_isForkEvent:!0,_isTransactionOrderForkEvent:!0,expiry:n||0,beforeHash:t,afterHash:r})||this}return i(t,e),t}(a);r.TransactionOrderForkEvent=c;var h=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isProvider",!0)}return e.prototype.addListener=function(e,t){return this.on(e,t)},e.prototype.removeListener=function(e,t){return this.off(e,t)},e.isProvider=function(e){return!(!e||!e._isProvider)},e}();r.Provider=h})),Z=(r(J),J.ForkEvent,J.BlockForkEvent,J.TransactionForkEvent,J.TransactionOrderForkEvent,J.Provider,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="abstract-signer/5.0.0-beta.131"})),X=(r(Z),Z.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Z.version),a=["chainId","data","from","gasLimit","gasPrice","nonce","to","value"],s=function(){function e(){var t=this.constructor;o.checkAbstract(t,e),y.defineReadOnly(this,"_isSigner",!0)}return e.prototype.getBalance=function(e){return this._checkProvider("getBalance"),this.provider.getBalance(this.getAddress(),e)},e.prototype.getTransactionCount=function(e){return this._checkProvider("getTransactionCount"),this.provider.getTransactionCount(this.getAddress(),e)},e.prototype.estimateGas=function(e){var t=this;return this._checkProvider("estimateGas"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return t.provider.estimateGas(e)})},e.prototype.call=function(e,t){var r=this;return this._checkProvider("call"),y.resolveProperties(this.checkTransaction(e)).then(function(e){return r.provider.call(e)})},e.prototype.sendTransaction=function(e){var t=this;return this._checkProvider("sendTransaction"),this.populateTransaction(e).then(function(e){return t.signTransaction(e).then(function(e){return t.provider.sendTransaction(e)})})},e.prototype.getChainId=function(){return this._checkProvider("getChainId"),this.provider.getNetwork().then(function(e){return e.chainId})},e.prototype.getGasPrice=function(){return this._checkProvider("getGasPrice"),this.provider.getGasPrice()},e.prototype.resolveName=function(e){return this._checkProvider("resolveName"),this.provider.resolveName(e)},e.prototype.checkTransaction=function(e){for(var t in e)-1===a.indexOf(t)&&o.throwArgumentError("invalid transaction key: "+t,"transaction",e);var r=y.shallowCopy(e);return null==r.from&&(r.from=this.getAddress()),r},e.prototype.populateTransaction=function(e){var t=this;return y.resolveProperties(this.checkTransaction(e)).then(function(r){return null!=r.to&&(r.to=Promise.resolve(r.to).then(function(e){return t.resolveName(e)})),null==r.gasPrice&&(r.gasPrice=t.getGasPrice()),null==r.nonce&&(r.nonce=t.getTransactionCount("pending")),null==r.from?r.from=t.getAddress():r.from=Promise.all([t.getAddress(),t.provider.resolveName(r.from)]).then(function(t){return t[0]!==t[1]&&o.throwArgumentError("from address mismatch","transaction",e),t[0]}),null==r.gasLimit&&(r.gasLimit=t.estimateGas(r).catch(function(e){o.throwError("cannot estimate gas; transaction may fail or may require manual gas limit",f.Logger.errors.UNPREDICTABLE_GAS_LIMIT,{tx:r})})),null==r.chainId&&(r.chainId=t.getChainId()),y.resolveProperties(r)})},e.prototype._checkProvider=function(e){this.provider||o.throwError("missing provider",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:e||"_checkProvider"})},e.isSigner=function(e){return!(!e||!e._isSigner)},e}();r.Signer=s;var u=function(e){function t(r,n){var i,a=this.constructor;return o.checkNew(a,t),i=e.call(this)||this,y.defineReadOnly(i,"address",r),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype._fail=function(e,t){return Promise.resolve().then(function(){o.throwError(e,f.Logger.errors.UNSUPPORTED_OPERATION,{operation:t})})},t.prototype.signMessage=function(e){return this._fail("VoidSigner cannot sign messages","signMessage")},t.prototype.signTransaction=function(e){return this._fail("VoidSigner cannot sign transactions","signTransaction")},t.prototype.connect=function(e){return new t(this.address,e)},t}(s);r.VoidSigner=u})),$=(r(X),X.Signer,X.VoidSigner,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="contracts/5.0.0-beta.136"})),Q=(r($),$.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__spreadArrays||function(){for(var e=0,t=0,r=arguments.length;t0;return this._checkRunningEvents(n),i},e.prototype.listenerCount=function(e){return this.provider?this._getRunningEvent(e).listenerCount():0},e.prototype.listeners=function(e){if(!this.provider)return[];if(null==e){var t=[];for(var r in this._runningEvents)this._runningEvents[r].listeners().forEach(function(e){t.push(e)});return t}return this._getRunningEvent(e).listeners()},e.prototype.removeAllListeners=function(e){if(!this.provider)return this;if(null==e){for(var t in this._runningEvents){var r=this._runningEvents[t];r.removeAllListeners(),this._checkRunningEvents(r)}return this}var n=this._getRunningEvent(e);return n.removeAllListeners(),this._checkRunningEvents(n),this},e.prototype.off=function(e,t){if(!this.provider)return this;var r=this._getRunningEvent(e);return r.removeListener(t),this._checkRunningEvents(r),this},e.prototype.removeListener=function(e,t){return this.off(e,t)},e}();r.Contract=b;var w=function(){function e(e,t,r){var n=this.constructor,i=null;"0x"!==(i="string"==typeof t?t:l.isBytes(t)?l.hexlify(t):t&&"string"==typeof t.object?t.object:"!").substring(0,2)&&(i="0x"+i),(!l.isHexString(i)||i.length%2)&&a.throwArgumentError("invalid bytecode","bytecode",t),r&&!X.Signer.isSigner(r)&&a.throwArgumentError("invalid signer","signer",r),y.defineReadOnly(this,"bytecode",i),y.defineReadOnly(this,"interface",y.getStatic(n,"getInterface")(e)),y.defineReadOnly(this,"signer",r||null)}return e.prototype.getDeployTransaction=function(){for(var e=[],t=0;t0;)r.push(i%this.base),i=i/this.base|0}for(var a="",s=0;0===t[s]&&s=0;--u)a+=this.alphabet[r[u]];return a},e.prototype.decode=function(e){if("string"!=typeof e)throw new TypeError("Expected String");var t=[];if(0===e.length)return new Uint8Array(t);t.push(0);for(var r=0;r>=8;for(;i>0;)t.push(255&i),i>>=8}for(var a=0;e[a]===this._leader&&a>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function ie(e){return 1===e.length?"0"+e:e}function oe(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}var ae={inherits:re,toArray:function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),n=0;n>8,a=255&i;o?r.push(o,a):r.push(a)}else for(n=0;n>>0}return o},split32:function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},rotr32:function(e,t){return e>>>t|e<<32-t},rotl32:function(e,t){return e<>>32-t},sum32:function(e,t){return e+t>>>0},sum32_3:function(e,t,r){return e+t+r>>>0},sum32_4:function(e,t,r,n){return e+t+r+n>>>0},sum32_5:function(e,t,r,n,i){return e+t+r+n+i>>>0},sum64:function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},sum64_hi:function(e,t,r,n){return(t+n>>>0>>0},sum64_lo:function(e,t,r,n){return t+n>>>0},sum64_4_hi:function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},sum64_4_lo:function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},sum64_5_hi:function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},sum64_5_lo:function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},rotr64_hi:function(e,t,r){return(t<<32-r|e>>>r)>>>0},rotr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0},shr64_hi:function(e,t,r){return e>>>r},shr64_lo:function(e,t,r){return(e<<32-r|t>>>r)>>>0}};function se(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var ue=se;se.prototype.update=function(e,t){if(e=ae.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=ae.join32(e,0,e.length-r,this.endian);for(var n=0;n>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o>>3},g1_256:function(e){return ce(e,17)^ce(e,19)^e>>>10}},me=ae.sum32,ge=ae.sum32_4,ye=ae.sum32_5,ve=pe.ch32,be=pe.maj32,we=pe.s0_256,_e=pe.s1_256,Ee=pe.g0_256,Pe=pe.g1_256,Ae=fe.BlockHash,Se=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function Me(){if(!(this instanceof Me))return new Me;Ae.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=Se,this.W=new Array(64)}ae.inherits(Me,Ae);var ke=Me;Me.blockSize=512,Me.outSize=256,Me.hmacStrength=192,Me.padLength=64,Me.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),ee(e.length<=this.blockSize);for(var t=e.length;t>24&255,c[t.length+1]=h>>16&255,c[t.length+2]=h>>8&255,c[t.length+3]=255&h;var d=l.arrayify(_t.computeHmac(i,e,c));o||(o=d.length,s=new Uint8Array(o),a=n-((u=Math.ceil(n/o))-1)*o),s.set(d);for(var p=1;p>8,a=255&i;o?r.push(o,a):r.push(a)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),Mt=n(function(e,t){var r=t;r.assert=ee,r.toArray=St.toArray,r.zero2=St.zero2,r.toHex=St.toHex,r.encode=St.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var o;if(i.isOdd()){var a=i.andln(n-1);o=a>(n>>1)-1?(n>>1)-a:a,i.isubn(o)}else o=0;r.push(o);for(var s=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,u=1;u0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new s(e,"hex","le")}}),kt=function(e){var r=new Uint8Array(e);return(t.crypto||t.msCrypto).getRandomValues(r),r},xt=Mt.getNAF,Ot=Mt.getJSF,Nt=Mt.assert;function Tt(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4);var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Ct=Tt;function Rt(e,t){this.curve=e,this.type=t,this.precomputed=null}Tt.prototype.point=function(){throw new Error("Not implemented")},Tt.prototype.validate=function(){throw new Error("Not implemented")},Tt.prototype._fixedNafMul=function(e,t){Nt(e.precomputed);var r=e._getDoubles(),n=xt(t,1),i=(1<=a;t--)s=(s<<1)+n[t];o.push(s)}for(var u=this.jpoint(null,null,null),f=this.jpoint(null,null,null),c=i;c>0;c--){for(a=0;a=0;s--){for(t=0;s>=0&&0===o[s];s--)t++;if(s>=0&&t++,a=a.dblp(t),s<0)break;var u=o[s];Nt(0!==u),a="affine"===e.type?u>0?a.mixedAdd(i[u-1>>1]):a.mixedAdd(i[-u-1>>1].neg()):u>0?a.add(i[u-1>>1]):a.add(i[-u-1>>1].neg())}return"affine"===e.type?a.toP():a},Tt.prototype._wnafMulAdd=function(e,t,r,n,i){for(var o=this._wnafT1,a=this._wnafT2,s=this._wnafT3,u=0,f=0;f=1;f-=2){var l=f-1,h=f;if(1===o[l]&&1===o[h]){var d=[t[l],null,null,t[h]];0===t[l].y.cmp(t[h].y)?(d[1]=t[l].add(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg())):0===t[l].y.cmp(t[h].y.redNeg())?(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].add(t[h].neg())):(d[1]=t[l].toJ().mixedAdd(t[h]),d[2]=t[l].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],m=Ot(r[l],r[h]);u=Math.max(m[0].length,u),s[l]=new Array(u),s[h]=new Array(u);for(var g=0;g=0;f--){for(var _=0;f>=0;){var E=!0;for(g=0;g=0&&_++,b=b.dblp(_),f<0)break;for(g=0;g0?P=a[g][A-1>>1]:A<0&&(P=a[g][-A-1>>1].neg()),b="affine"===P.type?b.mixedAdd(P):b.add(P))}}for(f=0;f=Math.ceil((e.bitLength()+1)/t.step)},Rt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(o=t,a=r),n.negative&&(n=n.neg(),i=i.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:n,b:i},{a:o,b:a}]},It.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},It.prototype.pointFromX=function(e,t){(e=new s(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},It.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},It.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Lt.prototype.isInfinity=function(){return this.inf},Lt.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Lt.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Lt.prototype.getX=function(){return this.x.fromRed()},Lt.prototype.getY=function(){return this.y.fromRed()},Lt.prototype.mul=function(e){return e=new s(e,16),this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Lt.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Lt.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Lt.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Lt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Lt.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},re(jt,Ct.BasePoint),It.prototype.jpoint=function(e,t,r){return new jt(this,e,t,r)},jt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},jt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},jt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},jt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},jt.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},jt.prototype.inspect=function(){return this.isInfinity()?"":""},jt.prototype.isInfinity=function(){return 0===this.z.cmpn(0)};var Dt={},Ut={},zt=n(function(e,t){var r=t;r.base=Ct,r.short=Ft,r.mont=Dt,r.edwards=Ut}),Ht=n(function(e,t){var r,n=t,i=Mt.assert;function o(e){"short"===e.type?this.curve=new zt.short(e):"edwards"===e.type?this.curve=new zt.edwards(e):this.curve=new zt.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function a(e,t){Object.defineProperty(n,e,{configurable:!0,enumerable:!0,get:function(){var r=new o(t);return Object.defineProperty(n,e,{configurable:!0,enumerable:!0,value:r}),r}})}n.PresetCurve=o,a("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:bt.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),a("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:bt.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),a("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:bt.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),a("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:bt.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),a("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:bt.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),a("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["9"]}),a("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:bt.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=void 0}catch(e){r=void 0}a("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:bt.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})});function Kt(e){if(!(this instanceof Kt))return new Kt(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=St.toArray(e.entropy,e.entropyEnc||"hex"),r=St.toArray(e.nonce,e.nonceEnc||"hex"),n=St.toArray(e.pers,e.persEnc||"hex");ee(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var Wt=Kt;Kt.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},Kt.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=St.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var Jt=Mt.assert;function Zt(e,t){if(e instanceof Zt)return e;this._importDER(e,t)||(Jt(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var Xt=Zt;function $t(){this.place=0}function Qt(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,o=0,a=t.place;o>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Zt.prototype._importDER=function(e,t){e=Mt.toArray(e,t);var r=new $t;if(48!==e[r.place++])return!1;if(Qt(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=Qt(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var o=Qt(e,r);if(e.length!==o+r.place)return!1;var a=e.slice(r.place,o+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===a[0]&&128&a[1]&&(a=a.slice(1)),this.r=new s(i),this.s=new s(a),this.recoveryParam=null,!0},Zt.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=Yt(t),r=Yt(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];er(n,t.length),(n=n.concat(t)).push(2),er(n,r.length);var i=n.concat(r),o=[48];return er(o,i.length),o=o.concat(i),Mt.encode(o,e)};var tr=Mt.assert;function rr(e){if(!(this instanceof rr))return new rr(e);"string"==typeof e&&(tr(Ht.hasOwnProperty(e),"Unknown curve "+e),e=Ht[e]),e instanceof Ht.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var nr=rr;rr.prototype.keyPair=function(e){return new Vt(this,e)},rr.prototype.keyFromPrivate=function(e,t){return Vt.fromPrivate(this,e,t)},rr.prototype.keyFromPublic=function(e,t){return Vt.fromPublic(this,e,t)},rr.prototype.genKeyPair=function(e){e||(e={});for(var t=new Wt({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||kt(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new s(2));;){var i=new s(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},rr.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},rr.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new s(e,16));for(var i=this.n.byteLength(),o=t.getPrivate().toArray("be",i),a=e.toArray("be",i),u=new Wt({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new s(1)),c=0;;c++){var l=n.k?n.k(c):new s(u.generate(this.n.byteLength()));if(!((l=this._truncateToN(l,!0)).cmpn(1)<=0||l.cmp(f)>=0)){var h=this.g.mul(l);if(!h.isInfinity()){var d=h.getX(),p=d.umod(this.n);if(0!==p.cmpn(0)){var m=l.invm(this.n).mul(p.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var g=(h.getY().isOdd()?1:0)|(0!==d.cmp(p)?2:0);return n.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),g^=1),new Xt({r:p,s:m,recoveryParam:g})}}}}}},rr.prototype.verify=function(e,t,r,n){e=this._truncateToN(new s(e,16)),r=this.keyFromPublic(r,n);var i=(t=new Xt(t,"hex")).r,o=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,u=o.invm(this.n),f=u.mul(e).umod(this.n),c=u.mul(i).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(f,r.getPublic(),c)).isInfinity()&&a.eqXToP(i):!(a=this.g.mulAdd(f,r.getPublic(),c)).isInfinity()&&0===a.getX().umod(this.n).cmp(i)},rr.prototype.recoverPubKey=function(e,t,r,n){tr((3&r)===r,"The recovery param is more than two bits"),t=new Xt(t,n);var i=this.n,o=new s(e),a=t.r,u=t.s,f=1&r,c=r>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");a=c?this.curve.pointFromX(a.add(this.curve.n),f):this.curve.pointFromX(a,f);var l=t.r.invm(i),h=i.sub(o).mul(l).umod(i),d=u.mul(l).umod(i);return this.g.mulAdd(h,a,d)},rr.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new Xt(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var ir,or={},ar=i(At),sr=n(function(e,t){var r=t;r.version=ar.version,r.utils=Mt,r.rand=kt,r.curve=zt,r.curves=Ht,r.ec=nr,r.eddsa=or}),ur=(sr.ec,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="signing-key/5.0.0-beta.128"})),fr=(r(ur),ur.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(ur.version),n=null;function i(){return n||(n=new sr.ec("secp256k1")),n}var o=function(){function e(e){y.defineReadOnly(this,"curve","secp256k1"),y.defineReadOnly(this,"privateKey",l.hexlify(e));var t=i().keyFromPrivate(l.arrayify(this.privateKey));y.defineReadOnly(this,"publicKey","0x"+t.getPublic(!1,"hex")),y.defineReadOnly(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),y.defineReadOnly(this,"_isSigningKey",!0)}return e.prototype._addPoint=function(e){var t=i().keyFromPublic(l.arrayify(this.publicKey)),r=i().keyFromPublic(l.arrayify(e));return"0x"+t.pub.add(r.pub).encodeCompressed("hex")},e.prototype.signDigest=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)).sign(l.arrayify(e),{canonical:!0});return l.splitSignature({recoveryParam:t.recoveryParam,r:l.hexZeroPad("0x"+t.r.toString(16),32),s:l.hexZeroPad("0x"+t.s.toString(16),32)})},e.prototype.computeSharedSecret=function(e){var t=i().keyFromPrivate(l.arrayify(this.privateKey)),r=i().keyFromPublic(l.arrayify(a(e)));return l.hexZeroPad("0x"+t.derive(r.getPublic()).toString(16),32)},e.isSigningKey=function(e){return!(!e||!e._isSigningKey)},e}();function a(e,t){var n=l.arrayify(e);if(32===n.length){var a=new o(n);return t?"0x"+i().keyFromPrivate(n).getPublic(!0,"hex"):a.publicKey}return 33===n.length?t?l.hexlify(n):"0x"+i().keyFromPublic(n).getPublic(!1,"hex"):65===n.length?t?"0x"+i().keyFromPublic(n).getPublic(!0,"hex"):l.hexlify(n):r.throwArgumentError("invalid public or private key","key","[REDACTED]")}t.SigningKey=o,t.recoverPublicKey=function(e,t){var r=l.splitSignature(t),n={r:l.arrayify(r.r),s:l.arrayify(r.s)};return"0x"+i().recoverPubKey(l.arrayify(e),n,r.recoveryParam).encode("hex",!1)},t.computePublicKey=a})),cr=(r(fr),fr.SigningKey,fr.recoverPublicKey,fr.computePublicKey,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="transactions/5.0.0-beta.127"})),lr=(r(cr),cr.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(P),o=new f.Logger(cr.version);function a(e){return"0x"===e?R.Zero:m.BigNumber.from(e)}var s=[{name:"nonce",maxLength:32},{name:"gasPrice",maxLength:32},{name:"gasLimit",maxLength:32},{name:"to",length:20},{name:"value",maxLength:32},{name:"data"}],u={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0};function c(e){var t=fr.computePublicKey(e);return S.getAddress(l.hexDataSlice(E.keccak256(l.hexDataSlice(t,1)),12))}function h(e,t){return c(fr.recoverPublicKey(l.arrayify(e),t))}r.computeAddress=c,r.recoverAddress=h,r.serialize=function(e,t){y.checkProperties(e,u);var r=[];s.forEach(function(t){var n=e[t.name]||[];n=l.arrayify(l.hexlify(n)),t.length&&n.length!==t.length&&n.length>0&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),t.maxLength&&(n=l.stripZeros(n)).length>t.maxLength&&o.throwArgumentError("invalid length for "+t.name,"transaction:"+t.name,n),r.push(l.hexlify(n))}),null!=e.chainId&&0!==e.chainId&&(r.push(l.hexlify(e.chainId)),r.push("0x"),r.push("0x"));var n=i.encode(r);if(!t)return n;var a=l.splitSignature(t),f=27+a.recoveryParam;return 9===r.length&&(r.pop(),r.pop(),r.pop(),f+=2*e.chainId+8),r.push(l.hexlify(f)),r.push(l.stripZeros(l.arrayify(a.r))),r.push(l.stripZeros(l.arrayify(a.s))),i.encode(r)},r.parse=function(e){var t=i.decode(e);9!==t.length&&6!==t.length&&o.throwArgumentError("invalid raw transaction","rawTransactin",e);var r,n={nonce:a(t[0]).toNumber(),gasPrice:a(t[1]),gasLimit:a(t[2]),to:(r=t[3],"0x"===r?null:S.getAddress(r)),value:a(t[4]),data:t[5],chainId:0};if(6===t.length)return n;try{n.v=m.BigNumber.from(t[6]).toNumber()}catch(e){return console.log(e),n}if(n.r=l.hexZeroPad(t[7],32),n.s=l.hexZeroPad(t[8],32),m.BigNumber.from(n.r).isZero()&&m.BigNumber.from(n.s).isZero())n.chainId=n.v,n.v=0;else{n.chainId=Math.floor((n.v-35)/2),n.chainId<0&&(n.chainId=0);var s=n.v-27,u=t.slice(0,6);0!==n.chainId&&(u.push(l.hexlify(n.chainId)),u.push("0x"),u.push("0x"),s-=2*n.chainId+8);var f=E.keccak256(i.encode(u));try{n.from=h(f,{r:l.hexlify(n.r),s:l.hexlify(n.s),recoveryParam:s})}catch(e){console.log(e)}n.hash=E.keccak256(e)}return n}})),hr=(r(lr),lr.computeAddress,lr.recoverAddress,lr.serialize,lr.parse,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wordlists/5.0.0-beta.127"})),dr=(r(hr),hr.version,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=!1,i=new f.Logger(hr.version);r.check=function(e){for(var t=[],r=0;r<2048;r++){var n=e.getWord(r);if(r!==e.getWordIndex(n))return"0x";t.push(n)}return W.id(t.join("\n")+"\n")};var o=function(){function e(t){var r=this.constructor;i.checkAbstract(r,e),y.defineReadOnly(this,"locale",t)}return e.prototype.split=function(e){return e.toLowerCase().split(/ +/g)},e.prototype.join=function(e){return e.join(" ")},e}();r.Wordlist=o,r.register=function(e,r){if(r||(r=e.locale),n){var i=t;i.wordlists||y.defineReadOnly(i,"wordlists",{}),i.wordlists[r]||y.defineReadOnly(i.wordlists,r,e),i.ethers&&i.ethers.wordlists&&(i.ethers.wordlists[r]||y.defineReadOnly(i.ethers.wordlists,r,e))}}})),pr=(r(dr),dr.check,dr.Wordlist,dr.register,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o="AbandonAbilityAbleAboutAboveAbsentAbsorbAbstractAbsurdAbuseAccessAccidentAccountAccuseAchieveAcidAcousticAcquireAcrossActActionActorActressActualAdaptAddAddictAddressAdjustAdmitAdultAdvanceAdviceAerobicAffairAffordAfraidAgainAgeAgentAgreeAheadAimAirAirportAisleAlarmAlbumAlcoholAlertAlienAllAlleyAllowAlmostAloneAlphaAlreadyAlsoAlterAlwaysAmateurAmazingAmongAmountAmusedAnalystAnchorAncientAngerAngleAngryAnimalAnkleAnnounceAnnualAnotherAnswerAntennaAntiqueAnxietyAnyApartApologyAppearAppleApproveAprilArchArcticAreaArenaArgueArmArmedArmorArmyAroundArrangeArrestArriveArrowArtArtefactArtistArtworkAskAspectAssaultAssetAssistAssumeAsthmaAthleteAtomAttackAttendAttitudeAttractAuctionAuditAugustAuntAuthorAutoAutumnAverageAvocadoAvoidAwakeAwareAwayAwesomeAwfulAwkwardAxisBabyBachelorBaconBadgeBagBalanceBalconyBallBambooBananaBannerBarBarelyBargainBarrelBaseBasicBasketBattleBeachBeanBeautyBecauseBecomeBeefBeforeBeginBehaveBehindBelieveBelowBeltBenchBenefitBestBetrayBetterBetweenBeyondBicycleBidBikeBindBiologyBirdBirthBitterBlackBladeBlameBlanketBlastBleakBlessBlindBloodBlossomBlouseBlueBlurBlushBoardBoatBodyBoilBombBoneBonusBookBoostBorderBoringBorrowBossBottomBounceBoxBoyBracketBrainBrandBrassBraveBreadBreezeBrickBridgeBriefBrightBringBriskBroccoliBrokenBronzeBroomBrotherBrownBrushBubbleBuddyBudgetBuffaloBuildBulbBulkBulletBundleBunkerBurdenBurgerBurstBusBusinessBusyButterBuyerBuzzCabbageCabinCableCactusCageCakeCallCalmCameraCampCanCanalCancelCandyCannonCanoeCanvasCanyonCapableCapitalCaptainCarCarbonCardCargoCarpetCarryCartCaseCashCasinoCastleCasualCatCatalogCatchCategoryCattleCaughtCauseCautionCaveCeilingCeleryCementCensusCenturyCerealCertainChairChalkChampionChangeChaosChapterChargeChaseChatCheapCheckCheeseChefCherryChestChickenChiefChildChimneyChoiceChooseChronicChuckleChunkChurnCigarCinnamonCircleCitizenCityCivilClaimClapClarifyClawClayCleanClerkCleverClickClientCliffClimbClinicClipClockClogCloseClothCloudClownClubClumpClusterClutchCoachCoastCoconutCodeCoffeeCoilCoinCollectColorColumnCombineComeComfortComicCommonCompanyConcertConductConfirmCongressConnectConsiderControlConvinceCookCoolCopperCopyCoralCoreCornCorrectCostCottonCouchCountryCoupleCourseCousinCoverCoyoteCrackCradleCraftCramCraneCrashCraterCrawlCrazyCreamCreditCreekCrewCricketCrimeCrispCriticCropCrossCrouchCrowdCrucialCruelCruiseCrumbleCrunchCrushCryCrystalCubeCultureCupCupboardCuriousCurrentCurtainCurveCushionCustomCuteCycleDadDamageDampDanceDangerDaringDashDaughterDawnDayDealDebateDebrisDecadeDecemberDecideDeclineDecorateDecreaseDeerDefenseDefineDefyDegreeDelayDeliverDemandDemiseDenialDentistDenyDepartDependDepositDepthDeputyDeriveDescribeDesertDesignDeskDespairDestroyDetailDetectDevelopDeviceDevoteDiagramDialDiamondDiaryDiceDieselDietDifferDigitalDignityDilemmaDinnerDinosaurDirectDirtDisagreeDiscoverDiseaseDishDismissDisorderDisplayDistanceDivertDivideDivorceDizzyDoctorDocumentDogDollDolphinDomainDonateDonkeyDonorDoorDoseDoubleDoveDraftDragonDramaDrasticDrawDreamDressDriftDrillDrinkDripDriveDropDrumDryDuckDumbDuneDuringDustDutchDutyDwarfDynamicEagerEagleEarlyEarnEarthEasilyEastEasyEchoEcologyEconomyEdgeEditEducateEffortEggEightEitherElbowElderElectricElegantElementElephantElevatorEliteElseEmbarkEmbodyEmbraceEmergeEmotionEmployEmpowerEmptyEnableEnactEndEndlessEndorseEnemyEnergyEnforceEngageEngineEnhanceEnjoyEnlistEnoughEnrichEnrollEnsureEnterEntireEntryEnvelopeEpisodeEqualEquipEraEraseErodeErosionErrorEruptEscapeEssayEssenceEstateEternalEthicsEvidenceEvilEvokeEvolveExactExampleExcessExchangeExciteExcludeExcuseExecuteExerciseExhaustExhibitExileExistExitExoticExpandExpectExpireExplainExposeExpressExtendExtraEyeEyebrowFabricFaceFacultyFadeFaintFaithFallFalseFameFamilyFamousFanFancyFantasyFarmFashionFatFatalFatherFatigueFaultFavoriteFeatureFebruaryFederalFeeFeedFeelFemaleFenceFestivalFetchFeverFewFiberFictionFieldFigureFileFilmFilterFinalFindFineFingerFinishFireFirmFirstFiscalFishFitFitnessFixFlagFlameFlashFlatFlavorFleeFlightFlipFloatFlockFloorFlowerFluidFlushFlyFoamFocusFogFoilFoldFollowFoodFootForceForestForgetForkFortuneForumForwardFossilFosterFoundFoxFragileFrameFrequentFreshFriendFringeFrogFrontFrostFrownFrozenFruitFuelFunFunnyFurnaceFuryFutureGadgetGainGalaxyGalleryGameGapGarageGarbageGardenGarlicGarmentGasGaspGateGatherGaugeGazeGeneralGeniusGenreGentleGenuineGestureGhostGiantGiftGiggleGingerGiraffeGirlGiveGladGlanceGlareGlassGlideGlimpseGlobeGloomGloryGloveGlowGlueGoatGoddessGoldGoodGooseGorillaGospelGossipGovernGownGrabGraceGrainGrantGrapeGrassGravityGreatGreenGridGriefGritGroceryGroupGrowGruntGuardGuessGuideGuiltGuitarGunGymHabitHairHalfHammerHamsterHandHappyHarborHardHarshHarvestHatHaveHawkHazardHeadHealthHeartHeavyHedgehogHeightHelloHelmetHelpHenHeroHiddenHighHillHintHipHireHistoryHobbyHockeyHoldHoleHolidayHollowHomeHoneyHoodHopeHornHorrorHorseHospitalHostHotelHourHoverHubHugeHumanHumbleHumorHundredHungryHuntHurdleHurryHurtHusbandHybridIceIconIdeaIdentifyIdleIgnoreIllIllegalIllnessImageImitateImmenseImmuneImpactImposeImproveImpulseInchIncludeIncomeIncreaseIndexIndicateIndoorIndustryInfantInflictInformInhaleInheritInitialInjectInjuryInmateInnerInnocentInputInquiryInsaneInsectInsideInspireInstallIntactInterestIntoInvestInviteInvolveIronIslandIsolateIssueItemIvoryJacketJaguarJarJazzJealousJeansJellyJewelJobJoinJokeJourneyJoyJudgeJuiceJumpJungleJuniorJunkJustKangarooKeenKeepKetchupKeyKickKidKidneyKindKingdomKissKitKitchenKiteKittenKiwiKneeKnifeKnockKnowLabLabelLaborLadderLadyLakeLampLanguageLaptopLargeLaterLatinLaughLaundryLavaLawLawnLawsuitLayerLazyLeaderLeafLearnLeaveLectureLeftLegLegalLegendLeisureLemonLendLengthLensLeopardLessonLetterLevelLiarLibertyLibraryLicenseLifeLiftLightLikeLimbLimitLinkLionLiquidListLittleLiveLizardLoadLoanLobsterLocalLockLogicLonelyLongLoopLotteryLoudLoungeLoveLoyalLuckyLuggageLumberLunarLunchLuxuryLyricsMachineMadMagicMagnetMaidMailMainMajorMakeMammalManManageMandateMangoMansionManualMapleMarbleMarchMarginMarineMarketMarriageMaskMassMasterMatchMaterialMathMatrixMatterMaximumMazeMeadowMeanMeasureMeatMechanicMedalMediaMelodyMeltMemberMemoryMentionMenuMercyMergeMeritMerryMeshMessageMetalMethodMiddleMidnightMilkMillionMimicMindMinimumMinorMinuteMiracleMirrorMiseryMissMistakeMixMixedMixtureMobileModelModifyMomMomentMonitorMonkeyMonsterMonthMoonMoralMoreMorningMosquitoMotherMotionMotorMountainMouseMoveMovieMuchMuffinMuleMultiplyMuscleMuseumMushroomMusicMustMutualMyselfMysteryMythNaiveNameNapkinNarrowNastyNationNatureNearNeckNeedNegativeNeglectNeitherNephewNerveNestNetNetworkNeutralNeverNewsNextNiceNightNobleNoiseNomineeNoodleNormalNorthNoseNotableNoteNothingNoticeNovelNowNuclearNumberNurseNutOakObeyObjectObligeObscureObserveObtainObviousOccurOceanOctoberOdorOffOfferOfficeOftenOilOkayOldOliveOlympicOmitOnceOneOnionOnlineOnlyOpenOperaOpinionOpposeOptionOrangeOrbitOrchardOrderOrdinaryOrganOrientOriginalOrphanOstrichOtherOutdoorOuterOutputOutsideOvalOvenOverOwnOwnerOxygenOysterOzonePactPaddlePagePairPalacePalmPandaPanelPanicPantherPaperParadeParentParkParrotPartyPassPatchPathPatientPatrolPatternPausePavePaymentPeacePeanutPearPeasantPelicanPenPenaltyPencilPeoplePepperPerfectPermitPersonPetPhonePhotoPhrasePhysicalPianoPicnicPicturePiecePigPigeonPillPilotPinkPioneerPipePistolPitchPizzaPlacePlanetPlasticPlatePlayPleasePledgePluckPlugPlungePoemPoetPointPolarPolePolicePondPonyPoolPopularPortionPositionPossiblePostPotatoPotteryPovertyPowderPowerPracticePraisePredictPreferPreparePresentPrettyPreventPricePridePrimaryPrintPriorityPrisonPrivatePrizeProblemProcessProduceProfitProgramProjectPromoteProofPropertyProsperProtectProudProvidePublicPuddingPullPulpPulsePumpkinPunchPupilPuppyPurchasePurityPurposePursePushPutPuzzlePyramidQualityQuantumQuarterQuestionQuickQuitQuizQuoteRabbitRaccoonRaceRackRadarRadioRailRainRaiseRallyRampRanchRandomRangeRapidRareRateRatherRavenRawRazorReadyRealReasonRebelRebuildRecallReceiveRecipeRecordRecycleReduceReflectReformRefuseRegionRegretRegularRejectRelaxReleaseReliefRelyRemainRememberRemindRemoveRenderRenewRentReopenRepairRepeatReplaceReportRequireRescueResembleResistResourceResponseResultRetireRetreatReturnReunionRevealReviewRewardRhythmRibRibbonRiceRichRideRidgeRifleRightRigidRingRiotRippleRiskRitualRivalRiverRoadRoastRobotRobustRocketRomanceRoofRookieRoomRoseRotateRoughRoundRouteRoyalRubberRudeRugRuleRunRunwayRuralSadSaddleSadnessSafeSailSaladSalmonSalonSaltSaluteSameSampleSandSatisfySatoshiSauceSausageSaveSayScaleScanScareScatterSceneSchemeSchoolScienceScissorsScorpionScoutScrapScreenScriptScrubSeaSearchSeasonSeatSecondSecretSectionSecuritySeedSeekSegmentSelectSellSeminarSeniorSenseSentenceSeriesServiceSessionSettleSetupSevenShadowShaftShallowShareShedShellSheriffShieldShiftShineShipShiverShockShoeShootShopShortShoulderShoveShrimpShrugShuffleShySiblingSickSideSiegeSightSignSilentSilkSillySilverSimilarSimpleSinceSingSirenSisterSituateSixSizeSkateSketchSkiSkillSkinSkirtSkullSlabSlamSleepSlenderSliceSlideSlightSlimSloganSlotSlowSlushSmallSmartSmileSmokeSmoothSnackSnakeSnapSniffSnowSoapSoccerSocialSockSodaSoftSolarSoldierSolidSolutionSolveSomeoneSongSoonSorrySortSoulSoundSoupSourceSouthSpaceSpareSpatialSpawnSpeakSpecialSpeedSpellSpendSphereSpiceSpiderSpikeSpinSpiritSplitSpoilSponsorSpoonSportSpotSpraySpreadSpringSpySquareSqueezeSquirrelStableStadiumStaffStageStairsStampStandStartStateStaySteakSteelStemStepStereoStickStillStingStockStomachStoneStoolStoryStoveStrategyStreetStrikeStrongStruggleStudentStuffStumbleStyleSubjectSubmitSubwaySuccessSuchSuddenSufferSugarSuggestSuitSummerSunSunnySunsetSuperSupplySupremeSureSurfaceSurgeSurpriseSurroundSurveySuspectSustainSwallowSwampSwapSwarmSwearSweetSwiftSwimSwingSwitchSwordSymbolSymptomSyrupSystemTableTackleTagTailTalentTalkTankTapeTargetTaskTasteTattooTaxiTeachTeamTellTenTenantTennisTentTermTestTextThankThatThemeThenTheoryThereTheyThingThisThoughtThreeThriveThrowThumbThunderTicketTideTigerTiltTimberTimeTinyTipTiredTissueTitleToastTobaccoTodayToddlerToeTogetherToiletTokenTomatoTomorrowToneTongueTonightToolToothTopTopicToppleTorchTornadoTortoiseTossTotalTouristTowardTowerTownToyTrackTradeTrafficTragicTrainTransferTrapTrashTravelTrayTreatTreeTrendTrialTribeTrickTriggerTrimTripTrophyTroubleTruckTrueTrulyTrumpetTrustTruthTryTubeTuitionTumbleTunaTunnelTurkeyTurnTurtleTwelveTwentyTwiceTwinTwistTwoTypeTypicalUglyUmbrellaUnableUnawareUncleUncoverUnderUndoUnfairUnfoldUnhappyUniformUniqueUnitUniverseUnknownUnlockUntilUnusualUnveilUpdateUpgradeUpholdUponUpperUpsetUrbanUrgeUsageUseUsedUsefulUselessUsualUtilityVacantVacuumVagueValidValleyValveVanVanishVaporVariousVastVaultVehicleVelvetVendorVentureVenueVerbVerifyVersionVeryVesselVeteranViableVibrantViciousVictoryVideoViewVillageVintageViolinVirtualVirusVisaVisitVisualVitalVividVocalVoiceVoidVolcanoVolumeVoteVoyageWageWagonWaitWalkWallWalnutWantWarfareWarmWarriorWashWaspWasteWaterWaveWayWealthWeaponWearWeaselWeatherWebWeddingWeekendWeirdWelcomeWestWetWhaleWhatWheatWheelWhenWhereWhipWhisperWideWidthWifeWildWillWinWindowWineWingWinkWinnerWinterWireWisdomWiseWishWitnessWolfWomanWonderWoodWoolWordWorkWorldWorryWorthWrapWreckWrestleWristWriteWrongYardYearYellowYouYoungYouthZebraZeroZoneZoo",a=null;function s(e){if(null==a&&(a=o.replace(/([A-Z])/g," $1").toLowerCase().substring(1).split(" "),"0x3c8acc1e7b08d8e76f9fda015ef48dc8c710a73cb7e0f77b2c18a9b5a7adde60"!==dr.check(e)))throw a=null,new Error("BIP39 Wordlist for en (English) FAILED")}var u=new(function(e){function t(){return e.call(this,"en")||this}return i(t,e),t.prototype.getWord=function(e){return s(this),a[e]},t.prototype.getWordIndex=function(e){return s(this),a.indexOf(e)},t}(dr.Wordlist));r.langEn=u,dr.register(u)})),mr=(r(pr),pr.langEn,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.Wordlist=dr.Wordlist;var r={en:pr.langEn};t.wordlists=r})),gr=(r(mr),mr.Wordlist,mr.wordlists,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="hdnode/5.0.0-beta.129"})),yr=(r(gr),gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(gr.version),n=m.BigNumber.from("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i=D.toUtf8Bytes("Bitcoin seed");function o(e){return(1<=256)throw new Error("Depth too large!");return s(l.concat([null!=this.privateKey?"0x0488ADE4":"0x0488B21E",l.hexlify(this.depth),this.parentFingerprint,l.hexZeroPad(l.hexlify(this.index),4),this.chainCode,null!=this.privateKey?l.concat(["0x00",this.privateKey]):this.publicKey]))},enumerable:!0,configurable:!0}),e.prototype.neuter=function(){return new e(u,null,this.publicKey,this.parentFingerprint,this.chainCode,this.index,this.depth,null,this.path)},e.prototype._derive=function(t){if(t>4294967295)throw new Error("invalid index - "+String(t));var r=this.path;r&&(r+="/"+(2147483647&t));var i=new Uint8Array(37);if(2147483648&t){if(!this.privateKey)throw new Error("cannot derive child of neutered node");i.set(l.arrayify(this.privateKey),1),r&&(r+="'")}else i.set(l.arrayify(this.publicKey));for(var o=24;o>=0;o-=8)i[33+(o>>3)]=t>>24-o&255;var s=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,this.chainCode,i)),f=s.slice(0,32),c=s.slice(32),h=null,d=null;this.privateKey?h=a(m.BigNumber.from(f).add(this.privateKey).mod(n)):d=new fr.SigningKey(l.hexlify(f))._addPoint(this.publicKey);return new e(u,h,d,this.fingerprint,a(c),t,this.depth+1,this.mnemonic,r)},e.prototype.derivePath=function(e){var t=e.split("/");if(0===t.length||"m"===t[0]&&0!==this.depth)throw new Error("invalid path - "+e);"m"===t[0]&&t.shift();for(var r=this,n=0;n=2147483648)throw new Error("invalid path index - "+i);r=r._derive(2147483648+o)}else{if(!i.match(/^[0-9]+$/))throw new Error("invalid path component - "+i);var o;if((o=parseInt(i))>=2147483648)throw new Error("invalid path index - "+i);r=r._derive(o)}}return r},e._fromSeed=function(t,r){var n=l.arrayify(t);if(n.length<16||n.length>64)throw new Error("invalid seed");var o=l.arrayify(_t.computeHmac(_t.SupportedAlgorithms.sha512,i,n));return new e(u,a(o.slice(0,32)),null,"0x00000000",a(o.slice(32)),0,0,r,"m")},e.fromMnemonic=function(t,r,n){return t=p(d(t,n),n),e._fromSeed(h(t,r),t)},e.fromSeed=function(t){return e._fromSeed(t,null)},e.fromExtendedKey=function(t){var n=Y.Base58.decode(t);82===n.length&&s(n.slice(0,78))===t||r.throwArgumentError("invalid extended key","extendedKey","[REDACTED]");var i=n[4],o=l.hexlify(n.slice(5,9)),a=parseInt(l.hexlify(n.slice(9,13)).substring(2),16),f=l.hexlify(n.slice(13,45)),c=n.slice(45,78);switch(l.hexlify(n.slice(0,4))){case"0x0488b21e":case"0x043587cf":return new e(u,null,l.hexlify(c),o,f,a,i,null,null);case"0x0488ade4":case"0x04358394 ":if(0!==c[0])break;return new e(u,l.hexlify(c.slice(1)),null,o,f,a,i,null,null)}return r.throwError("invalid extended key","extendedKey","[REDACTED]")},e}();function h(e,t){t||(t="");var r=D.toUtf8Bytes("mnemonic"+t,D.UnicodeNormalizationForm.NFKD);return Et.pbkdf2(D.toUtf8Bytes(e,D.UnicodeNormalizationForm.NFKD),r,2048,64,"sha512")}function d(e,t){t||(t=mr.wordlists.en),r.checkNormalize();var n=t.split(e);if(n.length%3!=0)throw new Error("invalid mnemonic");for(var i=l.arrayify(new Uint8Array(Math.ceil(11*n.length/8))),a=0,s=0;s>3]|=1<<7-a%8),a++}var c=32*n.length/3,h=o(n.length/3),d=l.arrayify(_t.sha256(i.slice(0,c/8)))[0];if((d&=h)!==(i[i.length-1]&h))throw new Error("invalid checksum");return l.hexlify(i.slice(0,c/8))}function p(e,t){if((e=l.arrayify(e)).length%4!=0||e.length<16||e.length>32)throw new Error("invalid entropy");for(var r=[0],n=11,i=0;i8?(r[r.length-1]<<=8,r[r.length-1]|=e[i],n-=8):(r[r.length-1]<<=n,r[r.length-1]|=e[i]>>8-n,r.push(e[i]&(1<<8-n)-1),n+=3);var a=l.arrayify(_t.sha256(e))[0],s=e.length/4;return a&=o(s),r[r.length-1]<<=s,r[r.length-1]|=a>>8-s,t||(t=mr.wordlists.en),t.join(r.map(function(e){return t.getWord(e)}))}t.HDNode=c,t.mnemonicToSeed=h,t.mnemonicToEntropy=d,t.entropyToMnemonic=p,t.isValidMnemonic=function(e,t){try{return d(e,t),!0}catch(e){}return!1}})),vr=(r(yr),yr.defaultPath,yr.HDNode,yr.mnemonicToSeed,yr.mnemonicToEntropy,yr.entropyToMnemonic,yr.isValidMnemonic,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="random/5.0.0-beta.127"})),br=(r(vr),vr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.shuffled=function(e){for(var t=(e=e.slice()).length-1;t>0;t--){var r=Math.floor(Math.random()*(t+1)),n=e[t];e[t]=e[r],e[r]=n}return e}})),wr=(r(br),br.shuffled,n(function(e,r){Object.defineProperty(r,"__esModule",{value:!0});var n=new f.Logger(vr.version);r.shuffled=br.shuffled;var i=t.crypto||t.msCrypto;i&&i.getRandomValues||(n.warn("WARNING: Missing strong random number source"),i={getRandomValues:function(e){return n.throwError("no secure random source avaialble",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"crypto.getRandomValues"})}}),r.randomBytes=function(e){(e<=0||e>1024||parseInt(String(e))!=e)&&n.throwArgumentError("invalid length","length",e);var t=new Uint8Array(e);return i.getRandomValues(t),l.arrayify(t)}})),_r=(r(wr),wr.shuffled,wr.randomBytes,n(function(e,t){!function(t){function r(e){return parseInt(e)===e}function n(e){if(!r(e.length))return!1;for(var t=0;t255)return!1;return!0}function i(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!n(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(r(e.length)&&n(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function o(e){return new Uint8Array(e)}function a(e,t,r,n,i){null==n&&null==i||(e=e.slice?e.slice(n,i):Array.prototype.slice.call(e,n,i)),t.set(e,r)}var s,u={toBytes:function(e){var t=[],r=0;for(e=encodeURI(e);r191&&n<224?(t.push(String.fromCharCode((31&n)<<6|63&e[r+1])),r+=2):(t.push(String.fromCharCode((15&n)<<12|(63&e[r+1])<<6|63&e[r+2])),r+=3)}return t.join("")}},f=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],r=0;r>4]+s[15&n])}return t.join("")}}),c={16:10,24:12,32:14},l=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],h=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],d=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],p=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],m=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],g=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],y=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],v=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],b=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],w=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],_=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],P=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],A=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],S=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function M(e){for(var t=[],r=0;r>2,this._Ke[r][t%4]=o[t],this._Kd[e-r][t%4]=o[t];for(var a,s=0,u=i;u>16&255]<<24^h[a>>8&255]<<16^h[255&a]<<8^h[a>>24&255]^l[s]<<24,s+=1,8!=i)for(t=1;t>8&255]<<8^h[a>>16&255]<<16^h[a>>24&255]<<24;for(t=i/2+1;t>2,d=u%4,this._Ke[f][d]=o[t],this._Kd[e-f][d]=o[t++],u++}for(var f=1;f>24&255]^P[a>>16&255]^A[a>>8&255]^S[255&a]},k.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Ke[0][i];for(var a=1;a>24&255]^m[n[(i+1)%4]>>16&255]^g[n[(i+2)%4]>>8&255]^y[255&n[(i+3)%4]]^this._Ke[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Ke[t][i],u[4*i]=255&(h[n[i]>>24&255]^s>>24),u[4*i+1]=255&(h[n[(i+1)%4]>>16&255]^s>>16),u[4*i+2]=255&(h[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(h[255&n[(i+3)%4]]^s);return u},k.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,r=[0,0,0,0],n=M(e),i=0;i<4;i++)n[i]^=this._Kd[0][i];for(var a=1;a>24&255]^b[n[(i+3)%4]>>16&255]^w[n[(i+2)%4]>>8&255]^_[255&n[(i+1)%4]]^this._Kd[a][i];n=r.slice()}var s,u=o(16);for(i=0;i<4;i++)s=this._Kd[t][i],u[4*i]=255&(d[n[i]>>24&255]^s>>24),u[4*i+1]=255&(d[n[(i+3)%4]>>16&255]^s>>16),u[4*i+2]=255&(d[n[(i+2)%4]>>8&255]^s>>8),u[4*i+3]=255&(d[255&n[(i+1)%4]]^s);return u};var x=function(e){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new k(e)};x.prototype.encrypt=function(e){if((e=i(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=o(e.length),r=o(16),n=0;n=0;--t)this._counter[t]=e%256,e>>=8},C.prototype.setBytes=function(e){if(16!=(e=i(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},C.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var R=function(e,t){if(!(this instanceof R))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof C||(t=new C(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new k(e)};R.prototype.encrypt=function(e){for(var t=i(e,!0),r=0;r16)throw new Error("PKCS#7 padding byte out of range");for(var r=e.length-t,n=0;n=64;){var d,p,m,g,y,v=r,b=n,w=i,_=o,E=a,P=s,A=u,S=f;for(p=0;p<16;p++)m=l+4*p,c[p]=(255&e[m])<<24|(255&e[m+1])<<16|(255&e[m+2])<<8|255&e[m+3];for(p=16;p<64;p++)g=((d=c[p-2])>>>17|d<<15)^(d>>>19|d<<13)^d>>>10,y=((d=c[p-15])>>>7|d<<25)^(d>>>18|d<<14)^d>>>3,c[p]=(g+c[p-7]|0)+(y+c[p-16]|0)|0;for(p=0;p<64;p++)g=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&P^~E&A)|0)+(S+(t[p]+c[p]|0)|0)|0,y=((v>>>2|v<<30)^(v>>>13|v<<19)^(v>>>22|v<<10))+(v&b^v&w^b&w)|0,S=A,A=P,P=E,E=_+g|0,_=w,w=b,b=v,v=g+y|0;r=r+v|0,n=n+b|0,i=i+w|0,o=o+_|0,a=a+E|0,s=s+P|0,u=u+A|0,f=f+S|0,l+=64,h-=64}}l(e);var h,d=e.length%64,p=e.length/536870912|0,m=e.length<<3,g=d<56?56:120,y=e.slice(e.length-d,e.length);for(y.push(128),h=d+1;h>>24&255),y.push(p>>>16&255),y.push(p>>>8&255),y.push(p>>>0&255),y.push(m>>>24&255),y.push(m>>>16&255),y.push(m>>>8&255),y.push(m>>>0&255),l(y),[r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255,f>>>24&255,f>>>16&255,f>>>8&255,f>>>0&255]}function i(e,t,r){var i;e=e.length<=64?e:n(e);var o=64+t.length+4,a=new Array(o),s=new Array(64),u=[];for(i=0;i<64;i++)a[i]=54;for(i=0;i=o-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;r>=32;)f(),u=u.concat(n(s.concat(n(a)))),r-=32;return r>0&&(f(),u=u.concat(n(s.concat(n(a))).slice(0,r))),u}function o(e,t,r,n,i){var o;for(f(e,16*(2*r-1),i,0,16),o=0;o<2*r;o++)u(e,16*o,i,16),s(i,n),f(i,0,e,t+16*o,16);for(o=0;o>>32-t}function s(e,t){f(e,0,t,0,16);for(var r=8;r>0;r-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(r=0;r<16;++r)e[r]+=t[r]}function u(e,t,r,n){for(var i=0;i=256)return!1}return!0}function l(e,t){var r=parseInt(e);if(e!=r)throw new Error("invalid "+t);return r}function h(e,t,n,a,s,h,d){if(!d)throw new Error("missing callback");if(n=l(n,"N"),a=l(a,"r"),s=l(s,"p"),h=l(h,"dkLen"),0===n||0!=(n&n-1))throw new Error("N must be power of 2");if(n>r/128/a)throw new Error("N too large");if(a>r/128/s)throw new Error("r too large");if(!c(e))throw new Error("password must be an array or buffer");if(e=Array.prototype.slice.call(e),!c(t))throw new Error("salt must be an array or buffer");t=Array.prototype.slice.call(t);for(var p=i(e,t,128*s*a),m=new Uint32Array(32*s*a),g=0;gT&&(r=T);for(var t=0;tT&&(r=T);for(t=0;t>0&255),p.push(m[t]>>8&255),p.push(m[t]>>16&255),p.push(m[t]>>24&255);var g=i(e,p,h);return d(null,1,g)}C(R)};R()}e.exports=h}()}));if(t.crypto&&crypto.getRandomValues){var kr=new Uint8Array(16);ir=function(){return crypto.getRandomValues(kr),kr}}if(!ir){var xr=new Array(16);ir=function(){for(var e,t=0;t<16;t++)0==(3&t)&&(e=4294967296*Math.random()),xr[t]=e>>>((3&t)<<3)&255;return xr}}for(var Or=ir,Nr=[],Tr={},Cr=0;Cr<256;Cr++)Nr[Cr]=(Cr+256).toString(16).substr(1),Tr[Nr[Cr]]=Cr;function Rr(e,t){var r=t||0,n=Nr;return n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+"-"+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]+n[e[r++]]}var Br=Or(),Ir=[1|Br[0],Br[1],Br[2],Br[3],Br[4],Br[5]],Fr=16383&(Br[6]<<8|Br[7]),Lr=0,jr=0;function Dr(e,t,r){var n=t&&r||0;"string"==typeof e&&(t="binary"==e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||Or)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var o=0;o<16;o++)t[n+o]=i[o];return t||Rr(i)}var Ur=Dr;Ur.v1=function(e,t,r){var n=t&&r||0,i=t||[],o=void 0!==(e=e||{}).clockseq?e.clockseq:Fr,a=void 0!==e.msecs?e.msecs:(new Date).getTime(),s=void 0!==e.nsecs?e.nsecs:jr+1,u=a-Lr+(s-jr)/1e4;if(u<0&&void 0===e.clockseq&&(o=o+1&16383),(u<0||a>Lr)&&void 0===e.nsecs&&(s=0),s>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");Lr=a,jr=s,Fr=o;var f=(1e4*(268435455&(a+=122192928e5))+s)%4294967296;i[n++]=f>>>24&255,i[n++]=f>>>16&255,i[n++]=f>>>8&255,i[n++]=255&f;var c=a/4294967296*1e4&268435455;i[n++]=c>>>8&255,i[n++]=255&c,i[n++]=c>>>24&15|16,i[n++]=c>>>16&255,i[n++]=o>>>8|128,i[n++]=255&o;for(var l=e.node||Ir,h=0;h<6;h++)i[n+h]=l[h];return t||Rr(i)},Ur.v4=Dr,Ur.parse=function(e,t,r){var n=t&&r||0,i=0;for(t=t||[],e.toLowerCase().replace(/[0-9a-f]{2}/g,function(e){i<16&&(t[n+i++]=Tr[e])});i<16;)t[n+i++]=0;return t},Ur.unparse=Rr;var zr=Ur,Hr=n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=t&&t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=o(_r),s=o(Mr),u=o(zr),f=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.isKeystoreAccount=function(e){return!(!e||!e._isKeystoreAccount)},t}(y.Description);r.KeystoreAccount=f,r.decrypt=function(e,t,r){var n=JSON.parse(e),i=Pr.getPassword(t),o=function(e,t){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/ciphertext"));if(l.hexlify(function(e,t){return E.keccak256(l.concat([e,t]))}(e.slice(16,32),r)).substring(2)!==Pr.searchPath(n,"crypto/mac").toLowerCase())return t(new Error("invalid password")),null;var i=function(e,t){if("aes-128-ctr"===Pr.searchPath(n,"crypto/cipher")){var r=Pr.looseArrayify(Pr.searchPath(n,"crypto/cipherparams/iv")),i=new a.default.Counter(r),o=new a.default.ModeOfOperation.ctr(e,i);return l.arrayify(o.decrypt(t))}return null}(e.slice(0,16),r),o=e.slice(32,64);if(!i)return t(new Error("unsupported cipher")),null;var s=lr.computeAddress(i);if(n.address){var u=n.address.toLowerCase();"0x"!==u.substring(0,2)&&(u="0x"+u);try{if(S.getAddress(u)!==s)return t(new Error("address mismatch")),null}catch(e){}}var c={_isKeystoreAccount:!0,address:s,privateKey:l.hexlify(i)};if("0.1"===Pr.searchPath(n,"x-ethers/version")){var h=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCiphertext")),d=Pr.looseArrayify(Pr.searchPath(n,"x-ethers/mnemonicCounter")),p=new a.default.Counter(d),m=new a.default.ModeOfOperation.ctr(o,p),g=Pr.searchPath(n,"x-ethers/path")||yr.defaultPath,y=l.arrayify(m.decrypt(h)),v=yr.entropyToMnemonic(y),b=yr.HDNode.fromMnemonic(v).derivePath(g);if(b.privateKey!=c.privateKey)return t(new Error("mnemonic mismatch")),null;c.mnemonic=b.mnemonic,c.path=b.path}return new f(c)};return new Promise(function(e,t){var a=Pr.searchPath(n,"crypto/kdf");if(a&&"string"==typeof a)if("scrypt"===a.toLowerCase()){var u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt")),f=parseInt(Pr.searchPath(n,"crypto/kdfparams/n")),c=parseInt(Pr.searchPath(n,"crypto/kdfparams/r")),h=parseInt(Pr.searchPath(n,"crypto/kdfparams/p"));if(!f||!c||!h)return void t(new Error("unsupported key-derivation function parameters"));if(0!=(f&f-1))return void t(new Error("unsupported key-derivation function parameter value for N"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));r&&r(0),s.default(i,u,f,c,h,64,function(n,i,a){if(n)n.progress=i,t(n);else if(a){a=l.arrayify(a);var s=o(a,t);if(!s)return;r&&r(1),e(s)}else if(r)return r(i)})}else if("pbkdf2"===a.toLowerCase()){u=Pr.looseArrayify(Pr.searchPath(n,"crypto/kdfparams/salt"));var d=null,p=Pr.searchPath(n,"crypto/kdfparams/prf");if("hmac-sha256"===p)d="sha256";else{if("hmac-sha512"!==p)return void t(new Error("unsupported prf"));d="sha512"}var m,g=parseInt(Pr.searchPath(n,"crypto/kdfparams/c"));if(32!==(m=parseInt(Pr.searchPath(n,"crypto/kdfparams/dklen"))))return void t(new Error("unsupported key-derivation derived-key length"));var y=l.arrayify(Et.pbkdf2(i,u,g,m,d)),v=o(y,t);if(!v)return;e(v)}else t(new Error("unsupported key-derivation function"));else t(new Error("unsupported key-derivation function"))})},r.encrypt=function(e,t,r,n){try{if(S.getAddress(e.address)!==lr.computeAddress(e.privateKey))throw new Error("address/privateKey mismatch");if(null!=e.mnemonic){if(yr.HDNode.fromMnemonic(e.mnemonic).derivePath(e.path||yr.defaultPath).privateKey!=e.privateKey)throw new Error("mnemonic mismatch")}else if(null!=e.path)throw new Error("cannot specify path without mnemonic")}catch(e){return Promise.reject(e)}"function"!=typeof r||n||(n=r,r={}),r||(r={});var i=l.arrayify(e.privateKey),o=Pr.getPassword(t),f=null,c=e.path;e.mnemonic&&(f=l.arrayify(yr.mnemonicToEntropy(e.mnemonic)),c||(c=yr.defaultPath));var h=r.client;h||(h="ethers.js");var d=null;d=r.salt?l.arrayify(r.salt):wr.randomBytes(32);var p=null;if(r.iv){if(16!==(p=l.arrayify(r.iv)).length)throw new Error("invalid iv")}else p=wr.randomBytes(16);var m=null;if(r.uuid){if(16!==(m=l.arrayify(r.uuid)).length)throw new Error("invalid uuid")}else m=wr.randomBytes(16);var g=1<<17,y=8,v=1;return r.scrypt&&(r.scrypt.N&&(g=r.scrypt.N),r.scrypt.r&&(y=r.scrypt.r),r.scrypt.p&&(v=r.scrypt.p)),new Promise(function(t,r){n&&n(0),s.default(o,d,g,y,v,64,function(o,s,b){if(o)o.progress=s,r(o);else if(b){var w=(b=l.arrayify(b)).slice(0,16),_=b.slice(16,32),P=b.slice(32,64),A=new a.default.Counter(p),S=new a.default.ModeOfOperation.ctr(w,A),M=l.arrayify(S.encrypt(i)),k=E.keccak256(l.concat([_,M])),x={address:e.address.substring(2).toLowerCase(),id:u.default.v4({random:m}),version:3,Crypto:{cipher:"aes-128-ctr",cipherparams:{iv:l.hexlify(p).substring(2)},ciphertext:l.hexlify(M).substring(2),kdf:"scrypt",kdfparams:{salt:l.hexlify(d).substring(2),n:g,dklen:32,p:v,r:y},mac:k.substring(2)}};if(f){var O=wr.randomBytes(16),N=new a.default.Counter(O),T=new a.default.ModeOfOperation.ctr(P,N),C=l.arrayify(T.encrypt(f)),R=new Date,B=R.getUTCFullYear()+"-"+Pr.zpad(R.getUTCMonth()+1,2)+"-"+Pr.zpad(R.getUTCDate(),2)+"T"+Pr.zpad(R.getUTCHours(),2)+"-"+Pr.zpad(R.getUTCMinutes(),2)+"-"+Pr.zpad(R.getUTCSeconds(),2)+".0Z";x["x-ethers"]={client:h,gethFilename:"UTC--"+B+"--"+x.address,mnemonicCounter:l.hexlify(O).substring(2),mnemonicCiphertext:l.hexlify(C).substring(2),path:c,version:"0.1"}}n&&n(1),t(JSON.stringify(x))}else if(n)return n(s)})})}}),Kr=(r(Hr),Hr.KeystoreAccount,Hr.decrypt,Hr.encrypt,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decryptCrowdsale=Ar.decrypt,t.getJsonWalletAddress=Sr.getJsonWalletAddress,t.isCrowdsaleWallet=Sr.isCrowdsaleWallet,t.isKeystoreWallet=Sr.isKeystoreWallet,t.decryptKeystore=Hr.decrypt,t.encryptKeystore=Hr.encrypt,t.decryptJsonWallet=function(e,t,r){if(Sr.isCrowdsaleWallet(e)){r&&r(0);var n=Ar.decrypt(e,t);return r&&r(1),Promise.resolve(n)}return Sr.isKeystoreWallet(e)?Hr.decrypt(e,t,r):Promise.reject(new Error("invalid JSON wallet"))}})),Wr=(r(Kr),Kr.decryptCrowdsale,Kr.getJsonWalletAddress,Kr.isCrowdsaleWallet,Kr.isKeystoreWallet,Kr.decryptKeystore,Kr.encryptKeystore,Kr.decryptJsonWallet,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="wallet/5.0.0-beta.129"})),qr=(r(Wr),Wr.version,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Wr.version);var a=function(e){function t(r,n){var i,a,s=this.constructor;if(o.checkNew(s,t),i=e.call(this)||this,null!=(a=r)&&l.isHexString(a.privateKey,32)&&null!=a.address){var u=new fr.SigningKey(r.privateKey);if(y.defineReadOnly(i,"_signingKey",function(){return u}),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey)),i.address!==S.getAddress(r.address)&&o.throwArgumentError("privateKey/address mismatch","privateKey","[REDCACTED]"),null!=r.mnemonic){var f=r.mnemonic,c=r.path||yr.defaultPath;y.defineReadOnly(i,"_mnemonic",function(){return f}),y.defineReadOnly(i,"path",r.path);var h=yr.HDNode.fromMnemonic(f).derivePath(c);lr.computeAddress(h.privateKey)!==i.address&&o.throwArgumentError("mnemonic/address mismatch","privateKey","[REDCACTED]")}else y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null)}else{if(fr.SigningKey.isSigningKey(r))"secp256k1"!==r.curve&&o.throwArgumentError("unsupported curve; must be secp256k1","privateKey","[REDACTED]"),y.defineReadOnly(i,"_signingKey",function(){return r});else{var d=new fr.SigningKey(r);y.defineReadOnly(i,"_signingKey",function(){return d})}y.defineReadOnly(i,"_mnemonic",function(){return null}),y.defineReadOnly(i,"path",null),y.defineReadOnly(i,"address",lr.computeAddress(i.publicKey))}return n&&!J.Provider.isProvider(n)&&o.throwArgumentError("invalid provider","provider",n),y.defineReadOnly(i,"provider",n||null),i}return i(t,e),Object.defineProperty(t.prototype,"mnemonic",{get:function(){return this._mnemonic()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"privateKey",{get:function(){return this._signingKey().privateKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"publicKey",{get:function(){return this._signingKey().publicKey},enumerable:!0,configurable:!0}),t.prototype.getAddress=function(){return Promise.resolve(this.address)},t.prototype.connect=function(e){return new t(this,e)},t.prototype.signTransaction=function(e){var t=this;return y.resolveProperties(e).then(function(e){if(null!=e.from){if(S.getAddress(e.from)!==t.address)throw new Error("transaction from address mismatch");delete e.from}var r=t._signingKey().signDigest(E.keccak256(lr.serialize(e)));return lr.serialize(e,r)})},t.prototype.signMessage=function(e){return Promise.resolve(l.joinSignature(this._signingKey().signDigest(W.hashMessage(e))))},t.prototype.encrypt=function(e,t,r){if("function"!=typeof t||r||(r=t,t={}),r&&"function"!=typeof r)throw new Error("invalid callback");return t||(t={}),Kr.encryptKeystore(this,e,t,r)},t.createRandom=function(e){var r=wr.randomBytes(16);e||(e={}),e.extraEntropy&&(r=l.arrayify(l.hexDataSlice(E.keccak256(l.concat([r,e.extraEntropy])),0,16)));var n=yr.entropyToMnemonic(r,e.locale);return t.fromMnemonic(n,e.path,e.locale)},t.fromEncryptedJson=function(e,r,n){return Kr.decryptJsonWallet(e,r,n).then(function(e){return new t(e)})},t.fromMnemonic=function(e,r,n){return r||(r=yr.defaultPath),new t(yr.HDNode.fromMnemonic(e,null,n).derivePath(r))},t}(X.Signer);r.Wallet=a,r.verifyMessage=function(e,t){return lr.recoverAddress(W.hashMessage(e),t)}})),Gr=(r(qr),qr.Wallet,qr.verifyMessage,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="networks/5.0.0-beta.128"})),Vr=(r(Gr),Gr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Gr.version);function n(e){return function(t,r){null==r&&(r={});var n=[];if(t.InfuraProvider)try{n.push(new t.InfuraProvider(e,r.infura))}catch(e){}if(t.EtherscanProvider)try{n.push(new t.EtherscanProvider(e,r.etherscan))}catch(e){}if(t.NodesmithProvider)try{n.push(new t.NodesmithProvider(e,r.nodesmith))}catch(e){}if(t.AlchemyProvider)try{n.push(new t.AlchemyProvider(e,r.alchemy))}catch(e){}if(t.CloudflareProvider)try{n.push(new t.CloudflareProvider(e))}catch(e){}return 0===n.length?null:t.FallbackProvider?new t.FallbackProvider(n):n[0]}}function i(e,t){return function(r,n){return r.JsonRpcProvider?new r.JsonRpcProvider(e,t):null}}var o={chainId:1,ensAddress:"0x314159265dd8dbb310642f98f50c066173c1259b",name:"homestead",_defaultProvider:n("homestead")},a={chainId:3,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"ropsten",_defaultProvider:n("ropsten")},s={unspecified:{chainId:0,name:"unspecified"},homestead:o,mainnet:o,morden:{chainId:2,name:"morden"},ropsten:a,testnet:a,rinkeby:{chainId:4,ensAddress:"0xe7410170f87102DF0055eB195163A03B7F2Bff4A",name:"rinkeby",_defaultProvider:n("rinkeby")},kovan:{chainId:42,name:"kovan",_defaultProvider:n("kovan")},goerli:{chainId:5,ensAddress:"0x112234455c3a32fd11230c42e7bccd4a84e02010",name:"goerli",_defaultProvider:n("goerli")},classic:{chainId:61,name:"classic",_defaultProvider:i("https://web3.gastracker.io","classic")},classicTestnet:{chainId:62,name:"classicTestnet",_defaultProvider:i("https://web3.gastracker.io/morden","classicTestnet")}};t.getNetwork=function(e){if(null==e)return null;if("number"==typeof e){for(var t in s){var n=s[t];if(n.chainId===e)return{name:n.name,chainId:n.chainId,ensAddress:n.ensAddress||null,_defaultProvider:n._defaultProvider||null}}return{chainId:e,name:"unknown"}}if("string"==typeof e){var i=s[e];return null==i?null:{name:i.name,chainId:i.chainId,ensAddress:i.ensAddress,_defaultProvider:i._defaultProvider||null}}var o=s[e.name];return o?(0!==e.chainId&&e.chainId!==o.chainId&&r.throwArgumentError("network chainId mismatch","network",e),{name:e.name,chainId:o.chainId,ensAddress:e.ensAddress||o.ensAddress||null,_defaultProvider:e._defaultProvider||o._defaultProvider||null}):("number"!=typeof e.chainId&&r.throwArgumentError("invalid network chainId","network",e),e)}})),Jr=(r(Vr),Vr.getNetwork,n(function(e,r){var n=function(e){function t(){this.fetch=!1,this.DOMException=e.DOMException}return t.prototype=e,new t}("undefined"!=typeof self?self:t);!function(e){!function(t){var r={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],i=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function o(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function s(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function u(e){this.map={},e instanceof u?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function f(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function c(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function l(e){var t=new FileReader,r=c(t);return t.readAsArrayBuffer(e),r}function h(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function d(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=h(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||i(e))?this._bodyArrayBuffer=h(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=f(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(l)}),this.text=function(){var e,t,r,n=f(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=c(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function g(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}}),t}function y(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new u(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},d.call(m.prototype),d.call(y.prototype),y.prototype.clone=function(){return new y(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},y.error=function(){var e=new y(null,{status:0,statusText:""});return e.type="error",e};var v=[301,302,303,307,308];y.redirect=function(e,t){if(-1===v.indexOf(t))throw new RangeError("Invalid status code");return new y(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function b(e,n){return new Promise(function(i,o){var a=new m(e,n);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new u,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;i(new y(n,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&r.blob&&(s.responseType="blob"),a.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),a.signal&&(a.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",f)}),s.send(void 0===a._bodyInit?null:a._bodyInit)})}b.polyfill=!0,e.fetch||(e.fetch=b,e.Headers=u,e.Request=m,e.Response=y),t.Headers=u,t.Request=m,t.Response=y,t.fetch=b}({})}(n),delete n.fetch.polyfill,(r=n.fetch).default=n.fetch,r.fetch=n.fetch,r.Headers=n.Headers,r.Request=n.Request,r.Response=n.Response,e.exports=r})),Zr=(Jr.fetch,Jr.Headers,Jr.Request,Jr.Response,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.decode=function(e){e=atob(e);for(var t=[],r=0;r0&&(u=e.timeout),e.headers)for(var c in e.headers)n[c.toLowerCase()]={key:c,value:String(e.headers[c])};if(null!=e.user&&null!=e.password){"https:"!==a.substring(0,6)&&!0!==e.allowInsecureAuthentication&&o.throwError("basic authentication requires a secure https url",f.Logger.errors.INVALID_ARGUMENT,{argument:"url",url:a,user:e.user,password:"[REDACTED]"});var l=e.user+":"+e.password;n.authorization={key:"Authorization",value:"Basic "+Zr.encode(D.toUtf8Bytes(l))}}}return new Promise(function(e,c){var l=null;u&&(l=setTimeout(function(){null!=l&&(l=null,c(o.makeError("timeout",f.Logger.errors.TIMEOUT,{timeout:u})))},u));var h=function(){null!=l&&(clearTimeout(l),l=null)};t&&(s.method="POST",s.body=t,n["content-type"]={key:"Content-Type",value:"application/json"});var d={};return Object.keys(n).forEach(function(e){var t=n[e];d[t.key]=t.value}),s.headers=d,i.default(a,s).then(function(e){return e.text().then(function(t){return e.ok||o.throwError("bad response",f.Logger.errors.SERVER_ERROR,{status:e.status,body:t,type:e.type,url:e.url}),t})}).then(function(e){var t=null;try{t=JSON.parse(e)}catch(t){o.throwError("invalid JSON",f.Logger.errors.SERVER_ERROR,{body:e,error:t,url:a})}if(r)try{t=r(t)}catch(e){o.throwError("processing response error",f.Logger.errors.SERVER_ERROR,{body:t,error:e})}return t},function(e){throw e}).then(function(t){h(),e(t)},function(e){h(),c(e)})})},r.poll=function(e,t){return t||(t={}),null==(t=y.shallowCopy(t)).floor&&(t.floor=0),null==t.ceiling&&(t.ceiling=1e4),null==t.interval&&(t.interval=250),new Promise(function(r,n){var i=null,o=!1,a=function(){return!o&&(o=!0,i&&clearTimeout(i),!0)};t.timeout&&(i=setTimeout(function(){a()&&n(new Error("timeout"))},t.timeout));var s=t.retryLimit,u=0;!function i(){return e().then(function(e){if(void 0!==e)a()&&r(e);else if(t.onceBlock)t.onceBlock.once("block",i);else if(!o){if(++u>s)return void(a()&&n(new Error("retry limit reached")));var f=t.interval*parseInt(String(Math.random()*Math.pow(2,u)));ft.ceiling&&(f=t.ceiling),setTimeout(i,f)}return null},function(e){a()&&n(e)})}()})}})),Qr=(r($r),$r.fetchJson,$r.poll,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="providers/5.0.0-beta.140"})),Yr=(r(Qr),Qr.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(Qr.version),n=function(){function e(){var t=this.constructor;r.checkNew(t,e),this.formats=this.getDefaultFormats()}return e.prototype.getDefaultFormats=function(){var t=this,r={},n=this.address.bind(this),i=this.bigNumber.bind(this),o=this.blockTag.bind(this),a=this.data.bind(this),s=this.hash.bind(this),u=this.hex.bind(this),f=this.number.bind(this);return r.transaction={hash:s,blockHash:e.allowNull(s,null),blockNumber:e.allowNull(f,null),transactionIndex:e.allowNull(f,null),confirmations:e.allowNull(f,null),from:n,gasPrice:i,gasLimit:i,to:e.allowNull(n,null),value:i,nonce:f,data:a,r:e.allowNull(this.uint256),s:e.allowNull(this.uint256),v:e.allowNull(f),creates:e.allowNull(n,null),raw:e.allowNull(a)},r.transactionRequest={from:e.allowNull(n),nonce:e.allowNull(f),gasLimit:e.allowNull(i),gasPrice:e.allowNull(i),to:e.allowNull(n),value:e.allowNull(i),data:e.allowNull(function(e){return t.data(e,!0)})},r.receiptLog={transactionLogIndex:e.allowNull(f),transactionIndex:f,blockNumber:f,transactionHash:s,address:n,topics:e.arrayOf(s),data:a,logIndex:f,blockHash:s},r.receipt={to:e.allowNull(this.address),from:e.allowNull(this.address),contractAddress:e.allowNull(n,null),transactionIndex:f,root:e.allowNull(s),gasUsed:i,logsBloom:e.allowNull(a),blockHash:s,transactionHash:s,logs:e.arrayOf(this.receiptLog.bind(this)),blockNumber:f,confirmations:e.allowNull(f,null),cumulativeGasUsed:i,status:e.allowNull(f)},r.block={hash:s,parentHash:s,number:f,timestamp:f,nonce:e.allowNull(u),difficulty:this.difficulty.bind(this),gasLimit:i,gasUsed:i,miner:n,extraData:a,transactions:e.allowNull(e.arrayOf(s))},r.blockWithTransactions=y.shallowCopy(r.block),r.blockWithTransactions.transactions=e.allowNull(e.arrayOf(this.transactionResponse.bind(this))),r.filter={fromBlock:e.allowNull(o,void 0),toBlock:e.allowNull(o,void 0),blockHash:e.allowNull(s,void 0),address:e.allowNull(n,void 0),topics:e.allowNull(this.topics.bind(this),void 0)},r.filterLog={blockNumber:e.allowNull(f),blockHash:e.allowNull(s),transactionIndex:f,removed:e.allowNull(this.boolean.bind(this)),address:n,data:e.allowFalsish(a,"0x"),topics:e.arrayOf(s),transactionHash:s,logIndex:f},r},e.prototype.number=function(e){return m.BigNumber.from(e).toNumber()},e.prototype.bigNumber=function(e){return m.BigNumber.from(e)},e.prototype.boolean=function(e){if("boolean"==typeof e)return e;if("string"==typeof e){if("true"===(e=e.toLowerCase()))return!0;if("false"===e)return!1}throw new Error("invaid boolean - "+e)},e.prototype.hex=function(e,t){return"string"==typeof e&&(t||"0x"===e.substring(0,2)||(e="0x"+e),l.isHexString(e))?e.toLowerCase():r.throwArgumentError("invalid hash","value",e)},e.prototype.data=function(e,t){var r=this.hex(e,t);if(r.length%2!=0)throw new Error("invalid data; odd-length - "+e);return r},e.prototype.address=function(e){return S.getAddress(e)},e.prototype.callAddress=function(e){if(!l.isHexString(e,32))return null;var t=S.getAddress(l.hexDataSlice(e,12));return t===R.AddressZero?null:t},e.prototype.contractAddress=function(e){return S.getContractAddress(e)},e.prototype.blockTag=function(e){if(null==e)return"latest";if("earliest"===e)return"0x0";if("latest"===e||"pending"===e)return e;if("number"==typeof e||l.isHexString(e))return l.hexValue(e);throw new Error("invalid blockTag")},e.prototype.hash=function(e,t){var n=this.hex(e,t);return 32!==l.hexDataLength(n)?r.throwArgumentError("invalid hash","value",e):n},e.prototype.difficulty=function(e){var t=m.BigNumber.from(e);try{return t.toNumber()}catch(e){}return null},e.prototype.uint256=function(e){if(!l.isHexString(e))throw new Error("invalid uint256");return l.hexZeroPad(e,32)},e.prototype._block=function(t,r){return null!=t.author&&null==t.miner&&(t.miner=t.author),e.check(r,t)},e.prototype.block=function(e){return this._block(e,this.formats.block)},e.prototype.blockWithTransactions=function(e){return this._block(e,this.formats.blockWithTransactions)},e.prototype.transactionRequest=function(t){return e.check(this.formats.transactionRequest,t)},e.prototype.transactionResponse=function(t){null!=t.gas&&null==t.gasLimit&&(t.gasLimit=t.gas),t.to&&m.BigNumber.from(t.to).isZero()&&(t.to="0x0000000000000000000000000000000000000000"),null!=t.input&&null==t.data&&(t.data=t.input),null==t.to&&null==t.creates&&(t.creates=this.contractAddress(t));var r=e.check(this.formats.transaction,t),n=t.networkId;return null!=t.chainId&&null==n&&null==r.v&&(n=t.chainId),l.isHexString(n)&&(n=m.BigNumber.from(n).toNumber()),"number"!=typeof n&&null!=r.v&&((n=(r.v-35)/2)<0&&(n=0),n=parseInt(n)),"number"!=typeof n&&(n=0),r.networkId=n,r.blockHash&&"x"===r.blockHash.replace(/0/g,"")&&(r.blockHash=null),r},e.prototype.transaction=function(e){return lr.parse(e)},e.prototype.receiptLog=function(t){return e.check(this.formats.receiptLog,t)},e.prototype.receipt=function(t){var r=e.check(this.formats.receipt,t);return r.logs.forEach(function(e,t){null==e.transactionLogIndex&&(e.transactionLogIndex=t)}),null!=t.status&&(r.byzantium=!0),r},e.prototype.topics=function(e){var t=this;return Array.isArray(e)?e.map(function(e){return t.topics(e)}):null!=e?this.hash(e,!0):null},e.prototype.filter=function(t){return e.check(this.formats.filter,t)},e.prototype.filterLog=function(t){return e.check(this.formats.filterLog,t)},e.check=function(e,t){var r={};for(var n in e)try{var i=e[n](t[n]);void 0!==i&&(r[n]=i)}catch(e){throw e.checkKey=n,e.checkValue=t[n],e}return r},e.allowNull=function(e,t){return function(r){return null==r?t:e(r)}},e.allowFalsish=function(e,t){return function(r){return r?e(r):t}},e.arrayOf=function(e){return function(t){if(!Array.isArray(t))throw new Error("not an array");var r=[];return t.forEach(function(t){r.push(e(t))}),r}},e}();t.Formatter=n})),en=(r(Yr),Yr.Formatter,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){return null==e?"null":(32!==l.hexDataLength(e)&&o.throwArgumentError("invalid topic","topic",e),e.toLowerCase())}function s(e){for(e=e.slice();null==e[e.length-1];)e.pop();return e.map(function(e){if(Array.isArray(e)){var t={};e.forEach(function(e){t[a(e)]=!0});var r=Object.keys(t);return r.sort(),r.join("|")}return a(e)}).join("&")}function u(e){if("string"==typeof e){if(e=e.toLowerCase(),32===l.hexDataLength(e))return"tx:"+e;if(-1===e.indexOf(":"))return e}else{if(Array.isArray(e))return"filter:*:"+s(e);if(J.ForkEvent.isForkEvent(e))throw o.warn("not implemented"),new Error("not implemented");if(e&&"object"==typeof e)return"filter:"+(e.address||"*")+":"+s(e.topics||[])}throw new Error("invalid event - "+e)}function c(){return(new Date).getTime()}var h=function(){function e(e,t,r){y.defineReadOnly(this,"tag",e),y.defineReadOnly(this,"listener",t),y.defineReadOnly(this,"once",r)}return e.prototype.pollable=function(){return this.tag.indexOf(":")>=0||"block"===this.tag||"pending"===this.tag},e}(),d=null,p=1,g=function(e){function t(t){var r=this.constructor,n=this;if(o.checkNew(r,J.Provider),(n=e.call(this)||this).formatter=r.getFormatter(),t instanceof Promise)y.defineReadOnly(n,"ready",t.then(function(e){return y.defineReadOnly(n,"_network",e),e})),n.ready.catch(function(e){});else{var i=y.getStatic(r,"getNetwork")(t);i?(y.defineReadOnly(n,"_network",i),y.defineReadOnly(n,"ready",Promise.resolve(n._network))):o.throwArgumentError("invalid network","network",t)}return n._lastBlockNumber=-2,n._events=[],n._pollingInterval=4e3,n._emitted={block:-2},n._fastQueryDate=0,n}return i(t,e),t.getFormatter=function(){return null==d&&(d=new Yr.Formatter),d},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.prototype.poll=function(){var e=this,t=p++;this.emit("willPoll",t);var r=[];this.getBlockNumber().then(function(t){if(e._setFastBlockNumber(t),t!==e._lastBlockNumber){-2===e._emitted.block&&(e._emitted.block=t-1);for(var n=e._emitted.block+1;n<=t;n++)e.emit("block",n);return e._emitted.block!==t&&(e._emitted.block=t,Object.keys(e._emitted).forEach(function(r){if("block"!==r){var n=e._emitted[r];"pending"!==n&&t-n>12&&delete e._emitted[r]}})),-2===e._lastBlockNumber&&(e._lastBlockNumber=t-1),e._events.forEach(function(n){var i=n.tag.split(":");switch(i[0]){case"tx":var o=i[1],a=e.getTransactionReceipt(o).then(function(t){return t&&null!=t.blockNumber?(e._emitted["t:"+o]=t.blockNumber,e.emit(o,t),null):null}).catch(function(t){e.emit("error",t)});r.push(a);break;case"filter":var s=i[2].split(/&/g).map(function(e){return e.split("|").map(function(e){return"null"===e?null:e})}),u={address:i[1],fromBlock:e._lastBlockNumber+1,toBlock:t,topics:s};u.address||delete u.address;a=e.getLogs(u).then(function(t){if(0!==t.length)return t.forEach(function(t){e._emitted["b:"+t.blockHash]=t.blockNumber,e._emitted["t:"+t.transactionHash]=t.blockNumber,e.emit(u,t)}),null}).catch(function(t){e.emit("error",t)});r.push(a)}}),e._lastBlockNumber=t,null}}).catch(function(e){}),Promise.all(r).then(function(){e.emit("didPoll",t)})},t.prototype.resetEventsBlock=function(e){this._lastBlockNumber=e-1,this.polling&&this.poll()},Object.defineProperty(t.prototype,"network",{get:function(){return this._network},enumerable:!0,configurable:!0}),t.prototype.getNetwork=function(){return this.ready},Object.defineProperty(t.prototype,"blockNumber",{get:function(){return this._fastBlockNumber},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"polling",{get:function(){return null!=this._poller},set:function(e){var t=this;setTimeout(function(){e&&!t._poller?t._poller=setInterval(t.poll.bind(t),t.pollingInterval):!e&&t._poller&&(clearInterval(t._poller),t._poller=null)},0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pollingInterval",{get:function(){return this._pollingInterval},set:function(e){var t=this;if("number"!=typeof e||e<=0||parseInt(String(e))!=e)throw new Error("invalid polling interval");this._pollingInterval=e,this._poller&&(clearInterval(this._poller),this._poller=setInterval(function(){t.poll()},this._pollingInterval))},enumerable:!0,configurable:!0}),t.prototype._getFastBlockNumber=function(){var e=this,t=c();return t-this._fastQueryDate>2*this._pollingInterval&&(this._fastQueryDate=t,this._fastBlockNumberPromise=this.getBlockNumber().then(function(t){return(null==e._fastBlockNumber||t>e._fastBlockNumber)&&(e._fastBlockNumber=t),e._fastBlockNumber})),this._fastBlockNumberPromise},t.prototype._setFastBlockNumber=function(e){null!=this._fastBlockNumber&&ethis._fastBlockNumber)&&(this._fastBlockNumber=e,this._fastBlockNumberPromise=Promise.resolve(e)))},t.prototype.waitForTransaction=function(e,t){var r=this;return null==t&&(t=1),0===t?this.getTransactionReceipt(e):new Promise(function(n){var i=function(o){o.confirmations(n=n.slice(32)).length)return null;var o=D.toUtf8String(n.slice(0,i));return t.resolveName(o).then(function(t){return t!=e?null:o})})})},t.prototype.perform=function(e,t){return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){console.log("WARNING: this provider does not support pending events")},t.prototype._stopPending=function(){},t.prototype._checkPolling=function(){this.polling=this._events.filter(function(e){return e.pollable()}).length>0},t.prototype._addEventListener=function(e,t,r){return this._events.push(new h(u(e),t,r)),"pending"===e&&this._startPending(),this._checkPolling(),this},t.prototype.on=function(e,t){return this._addEventListener(e,t,!1)},t.prototype.once=function(e,t){return this._addEventListener(e,t,!0)},t.prototype.emit=function(e){for(var t=this,r=[],n=1;n=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{transaction:r}),e.responseText.indexOf("nonce too low")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{transaction:r}),e.responseText.indexOf("replacement transaction underpriced")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{transaction:r})),e})})},t.prototype.signTransaction=function(e){return o.throwError("signing transactions is unsupported",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"signTransaction"})},t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return $r.poll(function(){return t.provider.getTransaction(e).then(function(r){if(null!==r)return t.provider._wrapTransaction(r,e)})},{onceBlock:t.provider}).catch(function(t){throw t.transactionHash=e,t})})},t.prototype.signMessage=function(e){var t=this,r="string"==typeof e?D.toUtf8Bytes(e):e;return this.getAddress().then(function(e){return t.provider.send("eth_sign",[e.toLowerCase(),l.hexlify(r)])})},t.prototype.unlock=function(e){var t=this.provider;return this.getAddress().then(function(r){return t.send("personal_unlockAccount",[r.toLowerCase(),e,null])})},t}(X.Signer);r.JsonRpcSigner=c;var h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.prototype.sendTransaction=function(e){var t=this;return this.sendUncheckedTransaction(e).then(function(e){return{hash:e,nonce:null,gasLimit:null,gasPrice:null,data:null,value:null,chainId:null,confirmations:0,from:null,wait:function(r){return t.provider.waitForTransaction(e,r)}}})},t}(c),d={chainId:!0,data:!0,gasLimit:!0,gasPrice:!0,nonce:!0,to:!0,value:!0},p=function(e){function t(r,n){var i=this.constructor,a=this;if(o.checkNew(i,t),"string"==typeof r&&null===n&&Vr.getNetwork(r)&&(n=r,r=null),n)a=e.call(this,n)||this;else{var s=new Promise(function(e,t){setTimeout(function(){a.send("eth_chainId",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(r){a.send("net_version",[]).then(function(t){e(Vr.getNetwork(m.BigNumber.from(t).toNumber()))}).catch(function(e){t(o.makeError("could not detect network",f.Logger.errors.NETWORK_ERROR))})})})});a=e.call(this,s)||this}return r||(r="http://localhost:8545"),a.connection="string"==typeof r?{url:r}:r,a._nextId=42,a}return i(t,e),t.prototype.getSigner=function(e){return new c(u,this,e)},t.prototype.getUncheckedSigner=function(e){return this.getSigner(e).connectUnchecked()},t.prototype.listAccounts=function(){var e=this;return this.send("eth_accounts",[]).then(function(t){return t.map(function(t){return e.formatter.address(t)})})},t.prototype.send=function(e,t){var r=this,n={method:e,params:t,id:this._nextId++,jsonrpc:"2.0"};return this.emit("debug",{action:"request",request:y.deepCopy(n),provider:this}),$r.fetchJson(this.connection,JSON.stringify(n),a).then(function(e){return r.emit("debug",{action:"response",request:n,response:e,provider:r}),e})},t.prototype.perform=function(e,t){switch(e){case"getBlockNumber":return this.send("eth_blockNumber",[]);case"getGasPrice":return this.send("eth_gasPrice",[]);case"getBalance":return this.send("eth_getBalance",[s(t.address),t.blockTag]);case"getTransactionCount":return this.send("eth_getTransactionCount",[s(t.address),t.blockTag]);case"getCode":return this.send("eth_getCode",[s(t.address),t.blockTag]);case"getStorageAt":return this.send("eth_getStorageAt",[s(t.address),t.position,t.blockTag]);case"sendTransaction":return this.send("eth_sendRawTransaction",[t.signedTransaction]).catch(function(e){throw e.responseText&&(e.responseText.indexOf("insufficient funds")>0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("nonce too low")>0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("replacement transaction underpriced")>0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":return t.blockTag?this.send("eth_getBlockByNumber",[t.blockTag,!!t.includeTransactions]):t.blockHash?this.send("eth_getBlockByHash",[t.blockHash,!!t.includeTransactions]):o.throwArgumentError("invalid block tag or block hash","params",t);case"getTransaction":return this.send("eth_getTransactionByHash",[t.transactionHash]);case"getTransactionReceipt":return this.send("eth_getTransactionReceipt",[t.transactionHash]);case"call":return this.send("eth_call",[this.constructor.hexlifyTransaction(t.transaction,{from:!0}),t.blockTag]);case"estimateGas":return this.send("eth_estimateGas",[this.constructor.hexlifyTransaction(t.transaction,{from:!0})]);case"getLogs":return t.filter&&null!=t.filter.address&&(t.filter.address=s(t.filter.address)),this.send("eth_getLogs",[t.filter])}return o.throwError(e+" not implemented",f.Logger.errors.NOT_IMPLEMENTED,{operation:e})},t.prototype._startPending=function(){if(null==this._pendingFilter){var e=this,t=this.send("eth_newPendingTransactionFilter",[]);this._pendingFilter=t,t.then(function(r){return function n(){e.send("eth_getFilterChanges",[r]).then(function(r){if(e._pendingFilter!=t)return null;var n=Promise.resolve();return r.forEach(function(t){e._emitted["t:"+t.toLowerCase()]="pending",n=n.then(function(){return e.getTransaction(t).then(function(t){return e.emit("pending",t),null})})}),n.then(function(){return e=1e3,new Promise(function(t){setTimeout(function(){t()},e)});var e})}).then(function(){if(e._pendingFilter==t)return setTimeout(function(){n()},0),null;e.send("eth_uninstallFilter",[r])}).catch(function(e){})}(),r}).catch(function(e){})}},t.prototype._stopPending=function(){this._pendingFilter=null},t.hexlifyTransaction=function(e,t){var r=y.shallowCopy(d);if(t)for(var n in t)t[n]&&(r[n]=!0);y.checkProperties(e,r);var i={};return["gasLimit","gasPrice","nonce","value"].forEach(function(t){if(null!=e[t]){var r=l.hexValue(e[t]);"gasLimit"===t&&(t="gas"),i[t]=r}}),["from","to","data"].forEach(function(t){null!=e[t]&&(i[t]=l.hexlify(e[t]))}),i},t}(en.BaseProvider);r.JsonRpcProvider=p})),rn=(r(tn),tn.JsonRpcSigner,tn.JsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(r,n){var i,a=this.constructor;o.checkAbstract(a,t),r=y.getStatic(a,"getNetwork")(r),n=y.getStatic(a,"getApiKey")(n);var s=y.getStatic(a,"getUrl")(r,n);return i=e.call(this,s,r)||this,y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype._startPending=function(){o.warn("WARNING: API provider does not support pending filters")},t.prototype.getSigner=function(e){return o.throwError("API provider does not support signing",f.Logger.errors.UNSUPPORTED_OPERATION,{operation:"getSigner"}),null},t.prototype.listAccounts=function(){return Promise.resolve([])},t.getNetwork=function(e){return Vr.getNetwork(null==e?"homestead":e)},t.getApiKey=function(e){return e},t.getUrl=function(e,t){return o.throwError("not implemented; sub-classes must override getUrl",f.Logger.errors.NOT_IMPLEMENTED,{operation:"getUrl"})},t}(tn.JsonRpcProvider);r.UrlJsonRpcProvider=a})),nn=(r(rn),rn.UrlJsonRpcProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getApiKey=function(e){return null==e?"_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC":e},t.getUrl=function(e,t){var r=null;switch(e.name){case"homestead":r="eth-mainnet.alchemyapi.io/jsonrpc/";break;case"ropsten":r="eth-ropsten.alchemyapi.io/jsonrpc/";break;case"rinkeby":r="eth-rinkeby.alchemyapi.io/jsonrpc/";break;case"kovan":r="eth-kovan.alchemyapi.io/jsonrpc/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return"https://"+r+t},t}(rn.UrlJsonRpcProvider);r.AlchemyProvider=a})),on=(r(nn),nn.AlchemyProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version),a=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i(t,e),t.getUrl=function(e,t){null!=t&&o.throwArgumentError("apiKey not supported for cloudflare","apiKey",t);var r=null;switch(e.name){case"homestead":r="https://cloudflare-eth.com/";break;default:o.throwArgumentError("unsupported network","network",arguments[0])}return r},t}(rn.UrlJsonRpcProvider);r.CloudflareProvider=a})),an=(r(on),on.CloudflareProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(e){var t=[];for(var r in e)if(null!=e[r]){var n=l.hexlify(e[r]);({gasLimit:!0,gasPrice:!0,nonce:!0,value:!0})[r]&&(n=l.hexValue(n)),t.push(r+"="+n)}return t.join("&")}function s(e){if(0==e.status&&("No records found"===e.message||"No transactions found"===e.message))return e.result;if(1!=e.status||"OK"!=e.message){var t=new Error("invalid response");throw t.result=JSON.stringify(e),t}return e.result}function u(e){if("2.0"!=e.jsonrpc)throw(t=new Error("invalid response")).result=JSON.stringify(e),t;if(e.error){var t=new Error(e.error.message||"unknown error");throw e.error.code&&(t.code=e.error.code),e.error.data&&(t.data=e.error.data),t}return e.result}function c(e){if("pending"===e)throw new Error("pending not supported");return"latest"===e?e:parseInt(e.substring(2),16)}var h=function(e){function t(r,n){var i,a=this.constructor;o.checkNew(a,t);var s="invalid";(i=e.call(this,r)||this).network&&(s=i.network.name);var u=null;switch(s){case"homestead":u="https://api.etherscan.io";break;case"ropsten":u="https://api-ropsten.etherscan.io";break;case"rinkeby":u="https://api-rinkeby.etherscan.io";break;case"kovan":u="https://api-kovan.etherscan.io";break;case"goerli":u="https://api-goerli.etherscan.io";break;default:throw new Error("unsupported network")}return y.defineReadOnly(i,"baseUrl",u),y.defineReadOnly(i,"apiKey",n),i}return i(t,e),t.prototype.perform=function(t,r){var n=this,i=this.baseUrl,l="";this.apiKey&&(l+="&apikey="+this.apiKey);var h=function(e,t){return n.emit("debug",{action:"request",request:e,provider:n}),$r.fetchJson(e,null,t||u).then(function(t){return n.emit("debug",{action:"response",request:e,response:y.deepCopy(t),provider:n}),t})};switch(t){case"getBlockNumber":return h(i+="/api?module=proxy&action=eth_blockNumber"+l);case"getGasPrice":return h(i+="/api?module=proxy&action=eth_gasPrice"+l);case"getBalance":return i+="/api?module=account&action=balance&address="+r.address,h(i+="&tag="+r.blockTag+l,s);case"getTransactionCount":return i+="/api?module=proxy&action=eth_getTransactionCount&address="+r.address,h(i+="&tag="+r.blockTag+l);case"getCode":return i+="/api?module=proxy&action=eth_getCode&address="+r.address,h(i+="&tag="+r.blockTag+l,u);case"getStorageAt":return i+="/api?module=proxy&action=eth_getStorageAt&address="+r.address,i+="&position="+r.position,h(i+="&tag="+r.blockTag+l,u);case"sendTransaction":return i+="/api?module=proxy&action=eth_sendRawTransaction&hex="+r.signedTransaction,h(i+=l).catch(function(e){throw e.responseText&&(e.responseText.toLowerCase().indexOf("insufficient funds")>=0&&o.throwError("insufficient funds",f.Logger.errors.INSUFFICIENT_FUNDS,{}),e.responseText.indexOf("same hash was already imported")>=0&&o.throwError("nonce has already been used",f.Logger.errors.NONCE_EXPIRED,{}),e.responseText.indexOf("another transaction with same nonce")>=0&&o.throwError("replacement fee too low",f.Logger.errors.REPLACEMENT_UNDERPRICED,{})),e});case"getBlock":if(r.blockTag)return i+="/api?module=proxy&action=eth_getBlockByNumber&tag="+r.blockTag,r.includeTransactions?i+="&boolean=true":i+="&boolean=false",h(i+=l);throw new Error("getBlock by blockHash not implmeneted");case"getTransaction":return i+="/api?module=proxy&action=eth_getTransactionByHash&txhash="+r.transactionHash,h(i+=l);case"getTransactionReceipt":return i+="/api?module=proxy&action=eth_getTransactionReceipt&txhash="+r.transactionHash,h(i+=l);case"call":if((d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_call"+d,"latest"!==r.blockTag)throw new Error("EtherscanProvider does not support blockTag for call");return h(i+=l);case"estimateGas":var d;return(d=a(r.transaction))&&(d="&"+d),i+="/api?module=proxy&action=eth_estimateGas&"+d,h(i+=l);case"getLogs":i+="/api?module=logs&action=getLogs";try{if(r.filter.fromBlock&&(i+="&fromBlock="+c(r.filter.fromBlock)),r.filter.toBlock&&(i+="&toBlock="+c(r.filter.toBlock)),r.filter.address&&(i+="&address="+r.filter.address),r.filter.topics&&r.filter.topics.length>0){if(r.filter.topics.length>1)throw new Error("unsupported topic format");var p=r.filter.topics[0];if("string"!=typeof p||66!==p.length)throw new Error("unsupported topic0 format");i+="&topic0="+p}}catch(e){return Promise.reject(e)}var m=this;return h(i+=l,s).then(function(e){var t={},r=Promise.resolve();return e.forEach(function(e){r=r.then(function(){return null!=e.blockHash?null:(e.blockHash=t[e.transactionHash],null==e.blockHash?m.getTransaction(e.transactionHash).then(function(r){return t[e.transactionHash]=r.blockHash,e.blockHash=r.blockHash,null}):null)})}),r.then(function(){return e})});case"getEtherPrice":return"homestead"!==this.network.name?Promise.resolve(0):(i+="/api?module=stats&action=ethprice",h(i+=l,s).then(function(e){return parseFloat(e.ethusd)}))}return e.prototype.perform.call(this,t,r)},t.prototype.getHistory=function(e,t,r){var n=this,i=this.baseUrl,o="";return this.apiKey&&(o+="&apikey="+this.apiKey),null==t&&(t=0),null==r&&(r=99999999),this.resolveName(e).then(function(e){return i+="/api?module=account&action=txlist&address="+e,i+="&startblock="+t,i+="&endblock="+r,i+="&sort=asc"+o,n.emit("debug",{action:"request",request:i,provider:n}),$r.fetchJson(i,null,s).then(function(e){n.emit("debug",{action:"response",request:i,response:y.deepCopy(e),provider:n});var t=[];return e.forEach(function(e){["contractAddress","to"].forEach(function(t){""==e[t]&&delete e[t]}),null==e.creates&&null!=e.contractAddress&&(e.creates=e.contractAddress);var r=n.formatter.transactionResponse(e);e.timeStamp&&(r.timestamp=parseInt(e.timeStamp)),t.push(r)}),t})})},t}(en.BaseProvider);r.EtherscanProvider=h})),sn=(r(an),an.EtherscanProvider,n(function(e,r){var n,i=t&&t.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)});Object.defineProperty(r,"__esModule",{value:!0});var o=new f.Logger(Qr.version);function a(){return(new Date).getTime()}function s(e){var t=!0,r=null;return e.forEach(function(n){null!=n?null!=r?r.name===n.name&&r.chainId===n.chainId&&(r.ensAddress===n.ensAddress||null==r.ensAddress&&null==n.ensAddress)||o.throwArgumentError("provider mismatch","networks",e):r=n:t=!1}),t}var u=1,c=function(e){function t(r,n,i){var a=this.constructor,u=this;o.checkNew(a,t),0===r.length&&o.throwArgumentError("missing providers","providers",r),null!=i&&i.length!==r.length?o.throwArgumentError("too many weights","weights",i):i?i.forEach(function(e){(e%1||e>512||e<1)&&o.throwArgumentError("invalid weight; must be integer in [1, 512]","weights",i)}):i=r.map(function(e){return 1});var c=i.reduce(function(e,t){return e+t});if(null==n?n=c/2:n>c&&o.throwArgumentError("quorum will always fail; larger than total weight","quorum",n),s(r.map(function(e){return e.network})))u=e.call(this,r[0].network)||this;else{var l=Promise.all(r.map(function(e){return e.getNetwork()})).then(function(e){return s(e)||o.throwError("getNetwork returned null",f.Logger.errors.UNKNOWN_ERROR),e[0]});u=e.call(this,l)||this}return y.defineReadOnly(u,"providers",Object.freeze(r.slice())),y.defineReadOnly(u,"quorum",n),y.defineReadOnly(u,"weights",Object.freeze(i.slice())),u}return i(t,e),t.doPerform=function(e,t,r){switch(t){case"getBlockNumber":case"getGasPrice":case"getEtherPrice":return e[t]();case"getBalance":case"getTransactionCount":case"getCode":return e[t](r.address,r.blockTag||"latest");case"getStorageAt":return e.getStorageAt(r.address,r.position,r.blockTag||"latest");case"sendTransaction":return e.sendTransaction(r.signedTransaction).then(function(e){return e.hash});case"getBlock":return e[r.includeTransactions?"getBlockWithTransactions":"getBlock"](r.blockTag||r.blockHash);case"call":case"estimateGas":return e[t](r.transaction);case"getTransaction":case"getTransactionReceipt":return e[t](r.transactionHash);case"getLogs":return e.getLogs(r.filter)}return o.throwError("unknown method error",f.Logger.errors.UNKNOWN_ERROR,{method:t,params:r})},t.prototype.perform=function(e,r){var n=this,i=a(),s=wr.shuffled(this.providers).map(function(o,s){var f=n.weights[s],c=u++;return{run:function(){var s=a(),u=s-i;return n.emit("debug",{action:"request",rid:c,backend:{weight:f,start:u,provider:o},request:{method:e,params:y.deepCopy(r)},provider:n}),t.doPerform(o,e,r).then(function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},response:y.deepCopy(t)}),{weight:f,result:t}},function(t){var i=a()-s;return n.emit("debug",{action:"response",rid:c,backend:{weight:f,start:u,duration:i,provider:o},request:{method:e,params:y.deepCopy(r)},error:t}),{weight:f,error:t}})},weight:f}});return"sendTransaction"===e?Promise.all(s.map(function(e){return e.run()})).then(function(e){for(var t=0;t=n.quorum){var y=c[m][0].result;return n.emit("debug","quorum",-1,{weight:g,result:y}),t(y),void(c=null)}}}if(0===s.length&&0===u){if("getGasPrice"===e){var v=[];Object.keys(c).forEach(function(e){c[e].forEach(function(e){e.result&&v.push(e.result)})}),v.sort(function(e,t){return e.lt(t)?-1:e.gt(t)?1:0});var b=parseInt(String(v.length/2));return v.length%2?void t(v[b]):void t(v[b-1].add(v[b]).div(2))}return null===a&&(a=o.makeError("failed to meet quorum",f.Logger.errors.SERVER_ERROR,{results:Object.keys(c).map(function(t){return{method:e,params:r,result:t,weight:c[t].reduce(function(e,t){return e+t.weight},0)}})})),void i(a)}setTimeout(l,0)}}),u256)throw new Error("invalid number type - "+t);return s&&(f=256),a=m.BigNumber.from(a).toTwos(f),l.zeroPad(a,f/8)}if(u=t.match(r)){var f=parseInt(u[1]);if(String(f)!=u[1]||0===f||f>32)throw new Error("invalid number type - "+t);if(l.arrayify(a).byteLength!==f)throw new Error("invalid value for "+t);return s?l.arrayify((a+o).substring(0,66)):a}if((u=t.match(i))&&Array.isArray(a)){var c=u[1];if(parseInt(u[2]||String(a.length))!=a.length)throw new Error("invalid value for "+t);var h=[];return a.forEach(function(t){h.push(e(c,t,!0))}),l.concat(h)}throw new Error("unknown type - "+t)}(e,t[s]))}),l.hexlify(l.concat(a))}t.pack=a,t.keccak256=function(e,t){return E.keccak256(a(e,t))},t.sha256=function(e,t){return _t.sha256(a(e,t))}})),mn=(r(pn),pn.pack,pn.keccak256,pn.sha256,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="units/5.0.0-beta.126"})),gn=(r(mn),mn.version,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=new f.Logger(mn.version),n=["wei","kwei","mwei","gwei","szabo","finney","ether"];function i(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.formatFixed(e,null!=t?t:18)}function o(e,t){if("string"==typeof t){var r=n.indexOf(t);-1!==r&&(t=3*r)}return m.parseFixed(e,null!=t?t:18)}t.commify=function(e){var t=String(e).split(".");(t.length>2||!t[0].match(/^-?[0-9]*$/)||t[1]&&!t[1].match(/^[0-9]*$/)||"."===e||"-."===e)&&r.throwArgumentError("invalid value","value",e);var n=t[0],i="";for("-"===n.substring(0,1)&&(i="-",n=n.substring(1));"0"===n.substring(0,1);)n=n.substring(1);""===n&&(n="0");var o="";2===t.length&&(o="."+(t[1]||"0"));for(var a=[];n.length;){if(n.length<=3){a.unshift(n);break}var s=n.length-3;a.unshift(n.substring(s)),n=n.substring(0,s)}return i+a.join(",")+o},t.formatUnits=i,t.parseUnits=o,t.formatEther=function(e){return i(e,18)},t.parseEther=function(e){return o(e,18)}})),yn=(r(gn),gn.commify,gn.formatUnits,gn.parseUnits,gn.formatEther,gn.parseEther,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.AbiCoder=G.AbiCoder,r.defaultAbiCoder=G.defaultAbiCoder,r.EventFragment=G.EventFragment,r.FormatTypes=G.FormatTypes,r.Fragment=G.Fragment,r.FunctionFragment=G.FunctionFragment,r.Indexed=G.Indexed,r.Interface=G.Interface,r.ParamType=G.ParamType,r.getAddress=S.getAddress,r.getContractAddress=S.getContractAddress,r.getIcapAddress=S.getIcapAddress,r.isAddress=S.isAddress;var i=n(Zr);r.base64=i,r.arrayify=l.arrayify,r.concat=l.concat,r.hexDataSlice=l.hexDataSlice,r.hexDataLength=l.hexDataLength,r.hexlify=l.hexlify,r.hexStripZeros=l.hexStripZeros,r.hexValue=l.hexValue,r.hexZeroPad=l.hexZeroPad,r.isHexString=l.isHexString,r.joinSignature=l.joinSignature,r.zeroPad=l.zeroPad,r.splitSignature=l.splitSignature,r.stripZeros=l.stripZeros,r.hashMessage=W.hashMessage,r.id=W.id,r.isValidName=W.isValidName,r.namehash=W.namehash,r.defaultPath=yr.defaultPath,r.entropyToMnemonic=yr.entropyToMnemonic,r.HDNode=yr.HDNode,r.isValidMnemonic=yr.isValidMnemonic,r.mnemonicToEntropy=yr.mnemonicToEntropy,r.mnemonicToSeed=yr.mnemonicToSeed,r.getJsonWalletAddress=Kr.getJsonWalletAddress,r.keccak256=E.keccak256,r.Logger=f.Logger,r.sha256=_t.sha256,r.solidityKeccak256=pn.keccak256,r.solidityPack=pn.pack,r.soliditySha256=pn.sha256,r.randomBytes=wr.randomBytes,r.checkProperties=y.checkProperties,r.deepCopy=y.deepCopy,r.defineReadOnly=y.defineReadOnly,r.getStatic=y.getStatic,r.resolveProperties=y.resolveProperties,r.shallowCopy=y.shallowCopy;var o=n(P);r.RLP=o,r.computePublicKey=fr.computePublicKey,r.recoverPublicKey=fr.recoverPublicKey,r.SigningKey=fr.SigningKey,r.formatBytes32String=D.formatBytes32String,r.nameprep=D.nameprep,r.parseBytes32String=D.parseBytes32String,r._toEscapedUtf8String=D._toEscapedUtf8String,r.toUtf8Bytes=D.toUtf8Bytes,r.toUtf8CodePoints=D.toUtf8CodePoints,r.toUtf8String=D.toUtf8String,r.computeAddress=lr.computeAddress,r.parseTransaction=lr.parse,r.recoverAddress=lr.recoverAddress,r.serializeTransaction=lr.serialize,r.commify=gn.commify,r.formatEther=gn.formatEther,r.parseEther=gn.parseEther,r.formatUnits=gn.formatUnits,r.parseUnits=gn.parseUnits,r.verifyMessage=qr.verifyMessage,r.fetchJson=$r.fetchJson,r.poll=$r.poll;var a=_t;r.SupportedAlgorithms=a.SupportedAlgorithms;var s=D;r.UnicodeNormalizationForm=s.UnicodeNormalizationForm})),vn=(r(yn),yn.AbiCoder,yn.defaultAbiCoder,yn.EventFragment,yn.FormatTypes,yn.Fragment,yn.FunctionFragment,yn.Indexed,yn.Interface,yn.ParamType,yn.getAddress,yn.getContractAddress,yn.getIcapAddress,yn.isAddress,yn.base64,yn.arrayify,yn.concat,yn.hexDataSlice,yn.hexDataLength,yn.hexlify,yn.hexStripZeros,yn.hexValue,yn.hexZeroPad,yn.isHexString,yn.joinSignature,yn.zeroPad,yn.splitSignature,yn.stripZeros,yn.hashMessage,yn.id,yn.isValidName,yn.namehash,yn.defaultPath,yn.entropyToMnemonic,yn.HDNode,yn.isValidMnemonic,yn.mnemonicToEntropy,yn.mnemonicToSeed,yn.getJsonWalletAddress,yn.keccak256,yn.Logger,yn.sha256,yn.solidityKeccak256,yn.solidityPack,yn.soliditySha256,yn.randomBytes,yn.checkProperties,yn.deepCopy,yn.defineReadOnly,yn.getStatic,yn.resolveProperties,yn.shallowCopy,yn.RLP,yn.computePublicKey,yn.recoverPublicKey,yn.SigningKey,yn.formatBytes32String,yn.nameprep,yn.parseBytes32String,yn._toEscapedUtf8String,yn.toUtf8Bytes,yn.toUtf8CodePoints,yn.toUtf8String,yn.computeAddress,yn.parseTransaction,yn.recoverAddress,yn.serializeTransaction,yn.commify,yn.formatEther,yn.parseEther,yn.formatUnits,yn.parseUnits,yn.verifyMessage,yn.fetchJson,yn.poll,yn.SupportedAlgorithms,yn.UnicodeNormalizationForm,n(function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.version="ethers/5.0.0-beta.155"})),bn=(r(vn),vn.version,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0}),r.Contract=Q.Contract,r.ContractFactory=Q.ContractFactory,r.BigNumber=m.BigNumber,r.FixedNumber=m.FixedNumber,r.Signer=X.Signer,r.VoidSigner=X.VoidSigner,r.Wallet=qr.Wallet;var i=n(R);r.constants=i;var o=n(dn);r.providers=o,r.Wordlist=mr.Wordlist,r.wordlists=mr.wordlists;var a=n(yn);r.utils=a;var s=f.Logger.errors;r.errors=s,r.version=vn.version;var u=new f.Logger(vn.version);r.logger=u,r.getDefaultProvider=function(e,t){null==e&&(e="homestead");var r=o.getNetwork(e);return r&&r._defaultProvider||u.throwError("unsupported getDefaultProvider network",f.Logger.errors.NETWORK_ERROR,{operation:"getDefaultProvider",network:e}),r._defaultProvider(o,t)}})),wn=(r(bn),bn.Contract,bn.ContractFactory,bn.BigNumber,bn.FixedNumber,bn.Signer,bn.VoidSigner,bn.Wallet,bn.constants,bn.providers,bn.Wordlist,bn.wordlists,bn.utils,bn.errors,bn.version,bn.logger,bn.getDefaultProvider,n(function(e,r){var n=t&&t.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t};Object.defineProperty(r,"__esModule",{value:!0});var i=n(bn);r.ethers=i;var o=bn;r.Signer=o.Signer,r.Wallet=o.Wallet,r.VoidSigner=o.VoidSigner,r.getDefaultProvider=o.getDefaultProvider,r.providers=o.providers,r.Contract=o.Contract,r.ContractFactory=o.ContractFactory,r.BigNumber=o.BigNumber,r.FixedNumber=o.FixedNumber,r.constants=o.constants,r.errors=o.errors,r.logger=o.logger,r.utils=o.utils,r.wordlists=o.wordlists,r.version=o.version,r.Wordlist=o.Wordlist})),_n=r(wn),En=wn.ethers,Pn=wn.Signer,An=wn.Wallet,Sn=wn.VoidSigner,Mn=wn.getDefaultProvider,kn=wn.providers,xn=wn.Contract,On=wn.ContractFactory,Nn=wn.BigNumber,Tn=wn.FixedNumber,Cn=wn.constants,Rn=wn.errors,Bn=wn.logger,In=wn.utils,Fn=wn.wordlists,Ln=wn.version,jn=wn.Wordlist;e.BigNumber=Nn,e.Contract=xn,e.ContractFactory=On,e.FixedNumber=Tn,e.Signer=Pn,e.VoidSigner=Sn,e.Wallet=An,e.Wordlist=jn,e.constants=Cn,e.default=_n,e.errors=Rn,e.ethers=En,e.getDefaultProvider=Mn,e.logger=Bn,e.providers=kn,e.utils=In,e.version=Ln,e.wordlists=Fn,Object.defineProperty(e,"__esModule",{value:!0})}); diff --git a/packages/ethers/lib.esm/index.d.ts b/packages/ethers/lib.esm/index.d.ts index 957c0b432..5587c5965 100644 --- a/packages/ethers/lib.esm/index.d.ts +++ b/packages/ethers/lib.esm/index.d.ts @@ -1,3 +1,3 @@ import * as ethers from "./ethers"; export { ethers }; -export * from "./ethers"; +export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, version, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist } from "./ethers"; diff --git a/packages/ethers/lib.esm/index.js b/packages/ethers/lib.esm/index.js index 464f20594..99274ec32 100644 --- a/packages/ethers/lib.esm/index.js +++ b/packages/ethers/lib.esm/index.js @@ -1,4 +1,7 @@ "use strict"; import * as ethers from "./ethers"; export { ethers }; -export * from "./ethers"; +export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, +//////////////////////// +// Compile-Time Constants +version, Wordlist } from "./ethers"; diff --git a/packages/ethers/lib/index.d.ts b/packages/ethers/lib/index.d.ts index 957c0b432..5587c5965 100644 --- a/packages/ethers/lib/index.d.ts +++ b/packages/ethers/lib/index.d.ts @@ -1,3 +1,3 @@ import * as ethers from "./ethers"; export { ethers }; -export * from "./ethers"; +export { Signer, Wallet, VoidSigner, getDefaultProvider, providers, Contract, ContractFactory, BigNumber, FixedNumber, constants, errors, logger, utils, wordlists, version, ContractFunction, ContractReceipt, ContractTransaction, Event, EventFilter, Overrides, PayableOverrides, CallOverrides, ContractInterface, BigNumberish, Bytes, BytesLike, Signature, Transaction, UnsignedTransaction, Wordlist } from "./ethers"; diff --git a/packages/ethers/lib/index.js b/packages/ethers/lib/index.js index 713f5e6ac..07eb1b8d0 100644 --- a/packages/ethers/lib/index.js +++ b/packages/ethers/lib/index.js @@ -1,7 +1,4 @@ "use strict"; -function __export(m) { - for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; -} var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; @@ -12,4 +9,22 @@ var __importStar = (this && this.__importStar) || function (mod) { Object.defineProperty(exports, "__esModule", { value: true }); var ethers = __importStar(require("./ethers")); exports.ethers = ethers; -__export(require("./ethers")); +var ethers_1 = require("./ethers"); +exports.Signer = ethers_1.Signer; +exports.Wallet = ethers_1.Wallet; +exports.VoidSigner = ethers_1.VoidSigner; +exports.getDefaultProvider = ethers_1.getDefaultProvider; +exports.providers = ethers_1.providers; +exports.Contract = ethers_1.Contract; +exports.ContractFactory = ethers_1.ContractFactory; +exports.BigNumber = ethers_1.BigNumber; +exports.FixedNumber = ethers_1.FixedNumber; +exports.constants = ethers_1.constants; +exports.errors = ethers_1.errors; +exports.logger = ethers_1.logger; +exports.utils = ethers_1.utils; +exports.wordlists = ethers_1.wordlists; +//////////////////////// +// Compile-Time Constants +exports.version = ethers_1.version; +exports.Wordlist = ethers_1.Wordlist; diff --git a/packages/ethers/package.json b/packages/ethers/package.json index 00656bdb1..0dd644cfa 100644 --- a/packages/ethers/package.json +++ b/packages/ethers/package.json @@ -53,5 +53,5 @@ }, "module": "./dist/ethers.esm.js", "types": "./lib/index.d.ts", - "tarballHash": "0x745f61434bc7e817efc9b7ab44f3816b24078b664c9c666ec91e0e0af4155908" + "tarballHash": "0xfe021d7af3eef8dfdcd597944ea3928f8e711e0f8d5c1d98cb3b7f55d6b7e51b" } diff --git a/packages/experimental/package.json b/packages/experimental/package.json index 6ad4c8dd7..e51cd2d73 100644 --- a/packages/experimental/package.json +++ b/packages/experimental/package.json @@ -26,5 +26,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x2d128ae608d72a963cd452b60ef6e7de728616a5db5aa3d954563c1e5e5a61dd" + "tarballHash": "0x0fac26c70353824def8f9f61a4460d007a0b2302c2eb800430459bf46e7eec73" } diff --git a/packages/hash/package.json b/packages/hash/package.json index 24674653e..eb9fc1919 100644 --- a/packages/hash/package.json +++ b/packages/hash/package.json @@ -27,5 +27,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xc98b05c98e389f24c4a131d48e699fe8c71fdce6314e08c85771d8105c11a3a6" + "tarballHash": "0xdb811d4593df06454829d34f5b78b8b4c6c7ea9dd10a3b7106b364761cafa783" } diff --git a/packages/hdnode/package.json b/packages/hdnode/package.json index ab5e3a41f..8c369361f 100644 --- a/packages/hdnode/package.json +++ b/packages/hdnode/package.json @@ -35,5 +35,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x9640d4f7336254f291b53454beee842a17fe3d364a333a7ca36d4c0a2f379c4b" + "tarballHash": "0x67a598ee36bc44fdce68567c594121e522f4987684c727bf763fb76e942dc226" } diff --git a/packages/json-wallets/package.json b/packages/json-wallets/package.json index 939b551be..1a7b885f5 100644 --- a/packages/json-wallets/package.json +++ b/packages/json-wallets/package.json @@ -37,5 +37,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x02535f91fea9a0ded1739f635ab6385467386dabfdfd7340c35fdab99e43ce2b" + "tarballHash": "0xe14e107dd9e91c9254e4af6f9b62b46d2d7edd4934dda09a330021002ac1ef3f" } diff --git a/packages/keccak256/package.json b/packages/keccak256/package.json index fbb53ca16..aba60f5b3 100644 --- a/packages/keccak256/package.json +++ b/packages/keccak256/package.json @@ -25,5 +25,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x915c089d5a70dc60d293e190f5ad6f236b71d3db15b1029b2c2f9b93c1c2b874" + "tarballHash": "0x4290caf3668c6796f8e9bf944a912302b98c703bb3a8b7015f76ecbe3117e5e6" } diff --git a/packages/logger/package.json b/packages/logger/package.json index 11d5423e9..59b4bf049 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -21,5 +21,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xe9beae3de0c03fc44a9d89634010f86855ad0623a857951f623ebcc5c9e7ac99" + "tarballHash": "0xc0870c5f3cd179a0d6da7771fcb38c08a62ae1fe846656fbeb8ac89f35139dee" } diff --git a/packages/networks/package.json b/packages/networks/package.json index db3f28d22..5699e4c53 100644 --- a/packages/networks/package.json +++ b/packages/networks/package.json @@ -24,5 +24,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xcad125002afaa15f1dbfc70ee3b38fa76842c1d1cc001e55a655418c1a890356" + "tarballHash": "0xb9c2ffa01f0d13ebae8af13e572e36dbb127f93cbe762b85ae657bf97638b2b9" } diff --git a/packages/pbkdf2/package.json b/packages/pbkdf2/package.json index db1cee4a5..09961c611 100644 --- a/packages/pbkdf2/package.json +++ b/packages/pbkdf2/package.json @@ -27,5 +27,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x93daf28ab8853621286ddd002a1462951f7140322eef402e52fbc8fea6b7b3ed" + "tarballHash": "0x2d139ab6c632757d870af01e0ca9016220828cb07abad2c9b0fe12013b541d69" } diff --git a/packages/properties/package.json b/packages/properties/package.json index 35b614bb4..7667a5318 100644 --- a/packages/properties/package.json +++ b/packages/properties/package.json @@ -26,5 +26,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x52e4e17814611ea28122bb0cd323d0879b59d95fea17acf0ef3829925629a586" + "tarballHash": "0x5dffc79ec051b799619fc5db1ccc6ad0daba266f0490ca9e5763f3dbc6c9c509" } diff --git a/packages/rlp/package.json b/packages/rlp/package.json index f46ad2b2c..f502d44a7 100644 --- a/packages/rlp/package.json +++ b/packages/rlp/package.json @@ -25,5 +25,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x0998523893f5ccc7d3b6029665329ccf09bfcfdea023c5190aaa4a813c8a22cc" + "tarballHash": "0x65dfdcbcc56264c3173522fcee24cd543857370ba45634cebe3c3578629418d1" } diff --git a/packages/sha2/package.json b/packages/sha2/package.json index 399ba4311..7a641b19f 100644 --- a/packages/sha2/package.json +++ b/packages/sha2/package.json @@ -27,5 +27,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xcf4df0c243d91af669cf850c762132a62d8557b0dd9257252c8c91cf28c2ffe1" + "tarballHash": "0x59b2cbcb60cd8521dd062ada3ec70572a3cd13ebdf68199182a5f3e2e55bb180" } diff --git a/packages/signing-key/package.json b/packages/signing-key/package.json index 2c295f765..15caaeb87 100644 --- a/packages/signing-key/package.json +++ b/packages/signing-key/package.json @@ -27,5 +27,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x2c2c7b6d5c1e203010905dc0d6f133c77b23589356e624e8b9aad9efaed3a3e9" + "tarballHash": "0xe447d9bce0f14f138250691b50f37389ea2988664bcf7773ea415c63448d4ed8" } diff --git a/packages/solidity/package.json b/packages/solidity/package.json index a076c20c3..02f4d83b3 100644 --- a/packages/solidity/package.json +++ b/packages/solidity/package.json @@ -28,5 +28,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x70bf6fa88a443007d944e0054cfef78b0423225c96e341afa83ddb62a76faf61" + "tarballHash": "0x85cb1539ac02e0374553e57ec7fa08f773d907ff078d6b495071b4f98a64e516" } diff --git a/packages/strings/package.json b/packages/strings/package.json index 781e6330a..980812b14 100644 --- a/packages/strings/package.json +++ b/packages/strings/package.json @@ -28,5 +28,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x07bc7954dde6fb2e82297f1d68c9586f2587d3a1e3cf7b42f8689c697e6ddc15" + "tarballHash": "0xad6de3522ce3c505a97fa0f8335e22c73752e683f5dd81e28d84269616abd8eb" } diff --git a/packages/testcases/package.json b/packages/testcases/package.json index 7b7c75698..a2681a0b6 100644 --- a/packages/testcases/package.json +++ b/packages/testcases/package.json @@ -38,5 +38,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x1a8a6c09a8ab073c966738bd4307cb6e8a342fea21c607f3084f3193b5c6c3e3" + "tarballHash": "0x810ab7be1edde490752a9e4344216cf85a4871e96b260c0922875a81f7e1c6b6" } diff --git a/packages/tests/lib.esm/reporter.d.ts b/packages/tests/lib.esm/reporter.d.ts new file mode 100644 index 000000000..0a1d1d9dd --- /dev/null +++ b/packages/tests/lib.esm/reporter.d.ts @@ -0,0 +1,5 @@ +interface Runner { + on(event: string, callback: (...args: Array) => void): Runner; +} +export declare function Reporter(runner: Runner): void; +export {}; diff --git a/packages/tests/lib.esm/reporter.js b/packages/tests/lib.esm/reporter.js new file mode 100644 index 000000000..989edaa1c --- /dev/null +++ b/packages/tests/lib.esm/reporter.js @@ -0,0 +1,110 @@ +'use strict'; +function getTime() { + return (new Date()).getTime(); +} +function trunc(value) { + if (value >= 0) { + return Math.floor(value); + } + return Math.ceil(value); +} +function getDelta(t0) { + let ds = trunc((getTime() - t0) / 1000); + let minutes = trunc(ds / 60); + let seconds = String(trunc(ds) % 60); + while (seconds.length < 2) { + seconds = '0' + seconds; + } + return '(' + minutes + ':' + seconds + ')'; +} +export function Reporter(runner) { + let suites = []; + let lastOutput = getTime(); + function getIndent() { + let result = ''; + for (let i = 0; i < suites.length; i++) { + result += ' '; + } + return result; + } + function log(message) { + if (!message) { + message = ''; + } + let indent = getIndent(); + console.log(indent + message); + lastOutput = getTime(); + } + runner.on('suite', function (suite) { + if (!suite.title) { + log('Testing: Found ' + suite.suites.length + ' test suites'); + } + else { + let filename = (suite.file || '').split('/').pop(); + if (filename) { + filename = ' (' + filename + ')'; + } + log('Test Suite: ' + suite.title + filename); + } + suites.push(suite); + suite._t0 = getTime(); + suite._countFail = 0; + suite._countPass = 0; + suite._countTotal = 0; + }); + runner.on('suite end', function () { + let suite = suites.pop(); + let failure = ''; + if (suite._countTotal > suite._countPass) { + failure = ' (' + (suite._countTotal - suite._countPass) + ' failed)'; + } + log(' Total Tests: ' + suite._countPass + '/' + suite._countTotal + ' passed ' + getDelta(suite._t0) + failure); + log(); + if (suites.length > 0) { + let currentSuite = suites[suites.length - 1]; + currentSuite._countFail += suite._countFail; + currentSuite._countPass += suite._countPass; + currentSuite._countTotal += suite._countTotal; + } + }); + runner.on('test', function (test) { + let currentSuite = suites[suites.length - 1]; + if (((getTime() - lastOutput) / 1000) > 60) { + log('[ Still running suite - test #' + currentSuite._countTotal + ' ]'); + lastOutput = getTime(); + } + currentSuite._countTotal++; + }); + runner.on('fail', function (test, error) { + let currentSuite = suites[suites.length - 1]; + currentSuite._countFail++; + let countFail = currentSuite._countFail; + if (countFail > 100) { + if (countFail === 101) { + log('[ Over 100 errors; skipping remaining suite output ]'); + } + return; + } + if (countFail > 25) { + log('Failure: ' + test.title + ' (too many errors; skipping dump)'); + return; + } + log('Failure: ' + test.title); + error.toString().split('\n').forEach((line) => { + log(' ' + line); + }); + Object.keys(error).forEach(function (key) { + log(' ' + key + ': ' + error[key]); + }); + if (error.stack) { + log("Stack Trace:"); + error.stack.split('\n').forEach((line) => { + log(' ' + line); + }); + } + }); + runner.on('pass', function (test) { + let currentSuite = suites[suites.length - 1]; + currentSuite._countPass++; + }); +} diff --git a/packages/tests/lib/reporter.d.ts b/packages/tests/lib/reporter.d.ts index ea695d44c..0a1d1d9dd 100644 --- a/packages/tests/lib/reporter.d.ts +++ b/packages/tests/lib/reporter.d.ts @@ -1,5 +1,5 @@ interface Runner { on(event: string, callback: (...args: Array) => void): Runner; } -declare function Reporter(runner: Runner): void; -export = Reporter; +export declare function Reporter(runner: Runner): void; +export {}; diff --git a/packages/tests/lib/reporter.js b/packages/tests/lib/reporter.js index da9969955..f09500f18 100644 --- a/packages/tests/lib/reporter.js +++ b/packages/tests/lib/reporter.js @@ -1,4 +1,5 @@ 'use strict'; +Object.defineProperty(exports, "__esModule", { value: true }); function getTime() { return (new Date()).getTime(); } @@ -108,4 +109,4 @@ function Reporter(runner) { currentSuite._countPass++; }); } -module.exports = Reporter; +exports.Reporter = Reporter; diff --git a/packages/tests/package.json b/packages/tests/package.json index d17e6877a..8cdf0b635 100644 --- a/packages/tests/package.json +++ b/packages/tests/package.json @@ -38,5 +38,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xab7df0fb51d7584e117b4ed86356f52f0210a3d342dc9e40fce13fdcedc36ce4" + "tarballHash": "0xd72e28c02a5cd93f871f2f57912d31dc1f16fc4b28f063e76670b9f9cee71c61" } diff --git a/packages/tests/reporter.js b/packages/tests/reporter.js new file mode 100644 index 000000000..b221bd3f7 --- /dev/null +++ b/packages/tests/reporter.js @@ -0,0 +1,5 @@ +"use strict"; + +const { Reporter } = require("./lib/reporter"); + +module.exports = Reporter; diff --git a/packages/tests/src.ts/reporter.ts b/packages/tests/src.ts/reporter.ts index 89ec1f95b..c9a52f87f 100644 --- a/packages/tests/src.ts/reporter.ts +++ b/packages/tests/src.ts/reporter.ts @@ -31,7 +31,7 @@ interface Runner { on(event: string, callback: (...args: Array) => void): Runner; } -function Reporter(runner: Runner) { +export function Reporter(runner: Runner) { let suites: Array = []; let lastOutput = getTime(); @@ -128,4 +128,3 @@ function Reporter(runner: Runner) { }); } -export = Reporter; diff --git a/packages/tests/tsconfig.json b/packages/tests/tsconfig.json index f025e9743..0a9d2f16c 100644 --- a/packages/tests/tsconfig.json +++ b/packages/tests/tsconfig.json @@ -8,5 +8,5 @@ "./thirdparty.d.ts", "./src.ts/*" ], - "exclude": [ ] + "exclude": [] } diff --git a/packages/transactions/package.json b/packages/transactions/package.json index 05c9cb7c9..fc65df83d 100644 --- a/packages/transactions/package.json +++ b/packages/transactions/package.json @@ -32,5 +32,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x4ec76541ec348502606265f177e00918c3f6bebaaa9404c8d461f2c0419fa702" + "tarballHash": "0xbe3cf202b55af2257438d47fcf19a160ddc1bb81cde7e358e6138be83e336b32" } diff --git a/packages/units/package.json b/packages/units/package.json index 5cf49bc47..e614390cd 100644 --- a/packages/units/package.json +++ b/packages/units/package.json @@ -28,5 +28,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x87a9c05d77565d21d20960f9726058aa60d7ba073bf398853c44a72e22a0271b" + "tarballHash": "0x0d88da2b7144b9d05c80ce43d95389f659e3774817e2cd7e5c08b41412622f2f" } diff --git a/packages/wallet/package.json b/packages/wallet/package.json index f5e8cbc0e..458738b76 100644 --- a/packages/wallet/package.json +++ b/packages/wallet/package.json @@ -38,5 +38,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xfd9392a01600789cea9c66e20034bb90bf31d68eef45d855ef9d4e515c244e82" + "tarballHash": "0xcb9b02c1a2c4af4e774743092a88536d21b9f3d044b7003d4c5d022f13521131" } diff --git a/packages/web/package.json b/packages/web/package.json index eebe5fef4..02396ddde 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -28,5 +28,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0x2761dff44f2b31971630f4ce8f929365941dbcf7f4a6f050a940466ed9a185de" + "tarballHash": "0x49506a10b060cd81879eee485e99e93cc56f12c407cc87985288c9a15f81317b" } diff --git a/packages/wordlists/package.json b/packages/wordlists/package.json index 5a3b73bcb..37f9f226f 100644 --- a/packages/wordlists/package.json +++ b/packages/wordlists/package.json @@ -29,5 +29,5 @@ }, "module": "./lib.esm/index.js", "types": "./lib/index.d.ts", - "tarballHash": "0xfbae6dfff83852be5f9358b699964cadb286b5cbd6dd073b68cda7356e473af4" + "tarballHash": "0x90c981750f2b47e9e0e2bf612f425918ec8c07b3dbac3c0fcc5d318eb533d6a5" } From f0b2961f08712fc2d491a1b8f2c9595c02417ca4 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 17:58:37 -0400 Subject: [PATCH 10/13] Updated Changelog. --- .gitignore | 4 ++++ CHANGELOG.md | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/.gitignore b/.gitignore index f6ad82e3a..f977a91d6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,7 @@ shims/*.d.ts **/*.tmp-browserify-* lerna-debug.log + +packages/*/tsconfig.tsbuildinfo + +packages/testcases/input/nameprep/** diff --git a/CHANGELOG.md b/CHANGELOG.md index fb00e74e0..c3cb18ce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,20 @@ Changelog This change log is managed by `scripts/cmds/update-versions` but may be manually updated. +ethers/v5.0.0-beta.156 (2019-09-06 17:56) +----------------------------------------- + + - Removed export star to fix UMD dist file. ([4c17c4d](https://github.com/ethers-io/ethers.js/commit/4c17c4db0455e1b89fd597c4c929cdc36aa3d90d)) + - Updated TypeScript version. ([e8028d0](https://github.com/ethers-io/ethers.js/commit/e8028d0e73368257b76b394bb8e2bf63f8aecd71)) + - Fixed test suites and reporter. ([1e0ed4e](https://github.com/ethers-io/ethers.js/commit/1e0ed4e99a22a27fe5057336f8cb320809768f3e)) + - Added lock-versions admin tool. ([2187604](https://github.com/ethers-io/ethers.js/commit/21876049137644af2b3afa31120ee95d032843a8)) + - Updated packages with version lock and moved types. ([85b4db7](https://github.com/ethers-io/ethers.js/commit/85b4db7d6db37b853f11a90cf4648c34404edcf9)) + - Fixed typo in error message. ([#592](https://github.com/ethers-io/ethers.js/issues/592); [019c1fc](https://github.com/ethers-io/ethers.js/commit/019c1fc7089b3da2d7bd41c933b6c6bc35c8dade)) + - Fixed build process to re-target browser field to ES version. ([3a91e91](https://github.com/ethers-io/ethers.js/commit/3a91e91df56c1ef6cf096c0322f74fd5060891e0)) + - Major overhaul in compilation to enable ES6 module generation. ([73a0077](https://github.com/ethers-io/ethers.js/commit/73a0077fd38c6ae79f33a9d4d3cc128a904b4a6c)) + - Updated some of the flatworm docs. ([81fd942](https://github.com/ethers-io/ethers.js/commit/81fd9428cab4be7eee7ddeb564bf91f282cae475)) + - Fixed package descriptions. ([#561](https://github.com/ethers-io/ethers.js/issues/561); [ebfca98](https://github.com/ethers-io/ethers.js/commit/ebfca98dc276d6f6ca6961632635e8203bb17645)) + ethers/v5.0.0-beta.155 (2019-08-22 17:11) ----------------------------------------- From 22a26736cc332fe6e896c9d2707cc99ceee2fb10 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 18:46:34 -0400 Subject: [PATCH 11/13] Fixed typo in error message (#574). --- packages/contracts/src.ts/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/contracts/src.ts/index.ts b/packages/contracts/src.ts/index.ts index d0f150744..cf46a50e4 100644 --- a/packages/contracts/src.ts/index.ts +++ b/packages/contracts/src.ts/index.ts @@ -219,7 +219,7 @@ function runMethod(contract: Contract, functionName: string, options: RunOptions if (options.transaction) { return resolveProperties(tx); } if (!contract.signer) { - logger.throwError("sending a transaction require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }) + logger.throwError("sending a transaction requires a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction" }) } return contract.signer.sendTransaction(tx).then((tx) => { @@ -572,7 +572,7 @@ export class Contract { fallback(overrides?: TransactionRequest): Promise { if (!this.signer) { - logger.throwError("sending a transaction require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }) + logger.throwError("sending a transactions require a signer", Logger.errors.UNSUPPORTED_OPERATION, { operation: "sendTransaction(fallback)" }) } let tx: TransactionRequest = shallowCopy(overrides || {}); From 9c63b4a7535f423a802bb1c17c325ce968987349 Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 18:48:14 -0400 Subject: [PATCH 12/13] Fixed typo in error message (#580). --- packages/providers/src.ts/base-provider.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/providers/src.ts/base-provider.ts b/packages/providers/src.ts/base-provider.ts index 525e66a30..516456922 100644 --- a/packages/providers/src.ts/base-provider.ts +++ b/packages/providers/src.ts/base-provider.ts @@ -807,7 +807,7 @@ export class BaseProvider extends Provider { // No ENS... if (!network.ensAddress) { logger.throwError( - "network does support ENS", + "network does not support ENS", Logger.errors.UNSUPPORTED_OPERATION, { operation: "ENS", network: network.name } ); From 6f4291f65f0ea20c65fef7fd7b09b4d5bf5f0dcd Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Fri, 6 Sep 2019 18:49:36 -0400 Subject: [PATCH 13/13] Fixed typo in error message (#592). --- packages/rlp/src.ts/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/rlp/src.ts/index.ts b/packages/rlp/src.ts/index.ts index 8fd3aa853..1c3cc057f 100644 --- a/packages/rlp/src.ts/index.ts +++ b/packages/rlp/src.ts/index.ts @@ -126,7 +126,7 @@ function _decode(data: Uint8Array, offset: number): { consumed: number, result: } else if (data[offset] >= 0x80) { let length = data[offset] - 0x80; if (offset + 1 + length > data.length) { - throw new Error("invlaid rlp data"); + throw new Error("invalid rlp data"); } let result = hexlify(data.slice(offset + 1, offset + 1 + length));