[
  {
    "path": ".gitattributes",
    "content": "*.sol linguist-language=Solidity\ncontracts/.dapprc linguist-language=Shell"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n.pnp\n.pnp.js\n\n# testing\ncoverage\n\n# next.js\n.next/\nout/\n\n# production\nbuild\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# local env files\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\n# vercel\n.vercel\n\n# VSCode\n.vscode\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"contracts/lib/ds-test\"]\n\tpath = contracts/lib/ds-test\n\turl = https://github.com/dapphub/ds-test\n[submodule \"contracts/lib/openzeppelin-contracts\"]\n\tpath = contracts/lib/openzeppelin-contracts\n\turl = https://github.com/OpenZeppelin/openzeppelin-contracts\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<https://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "README.md",
    "content": "# MultiFaucet\n\nMultiFaucet drips ETH, tokens, and NFTs across many testnet networks, at once.\n\nREADMEs can be found individual subdirectories:\n\n- [MultiFaucet contracts](https://github.com/Anish-Agnihotri/MultiFaucet/tree/master/contracts)\n- [Associated frontend](https://github.com/Anish-Agnihotri/MultiFaucet/tree/master/frontend)\n\n## License\n\n[GNU Affero GPL v3.0](https://github.com/Anish-Agnihotri/MultiFaucet/blob/master/LICENSE)\n\n## Disclaimer\n\n_These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions or loss of transmitted information. Paradigm is not liable for any of the foregoing. Users should proceed with caution and use at their own risk._\n"
  },
  {
    "path": "contracts/.dapprc",
    "content": "# Make dependencies available\nexport DAPP_REMAPPINGS=$(cat remappings.txt)\n\nexport DAPP_SOLC_VERSION=0.8.0\nexport DAPP_BUILD_OPTIMIZE=1\nexport DAPP_BUILD_OPTIMIZE_RUNS=1000000\nexport DAPP_LINK_TEST_LIBRARIES=0\nexport DAPP_TEST_VERBOSITY=1\nexport DAPP_TEST_SMTTIMEOUT=500000\n\n# Allow using the local network's RPC accounts if `ETH_FROM`\n# is not in the keystore\nexport ETH_RPC_ACCOUNTS=yes\n\nif [ \"$DEEP_FUZZ\" == \"true\" ]\nthen \n  export DAPP_TEST_FUZZ_RUNS=50000 # Fuzz for a long time if DEEP_FUZZ is set to true.\nelse\n  export DAPP_TEST_FUZZ_RUNS=100 # Only fuzz briefly if DEEP_FUZZ is not set to true.\nfi"
  },
  {
    "path": "contracts/Makefile",
    "content": "# install solc version\nSOLC_VERSION := 0_8_0\nsolc:; nix-env -f https://github.com/dapphub/dapptools/archive/master.tar.gz -iA solc-static-versions.solc_${SOLC_VERSION}\n\n# Build & test\nbuild  :; dapp build\ntest   :; dapp test\nclean  :; dapp clean"
  },
  {
    "path": "contracts/README.md",
    "content": "# MultiFaucet\n\n## About\n\nMultiFaucet is a simple [faucet](https://en.wikipedia.org/wiki/History_of_bitcoin#Bitcoin_faucets) that drips `Ether/Matic`, `Wrapped Ether/Wrapped Matic`, `DAI Stablecoin`, and mints ERC721 NFTs to a recipient.\n\nIt enables a super operator to `drip` and `drain` to a recipient, add approved operators, or update the super operator. Approved operators can only `drip` to a recipient.\n\n## Build and Test\n\n```bash\n# Collect repo\ngit clone https://github.com/anish-agnihotri/MultiFaucet\ncd MultiFaucet/contracts\n\n# Run tests\nmake\nmake test\n```\n\n## Installing the toolkit\n\nIf you do not have DappTools already installed, you'll need to run the commands below:\n\n### Install Nix\n\n```bash\n# User must be in sudoers\ncurl -L https://nixos.org/nix/install | sh\n\n# Run this or login again to use Nix\n. \"$HOME/.nix-profile/etc/profile.d/nix.sh\"\n```\n\n### Install DappTools\n\n```bash\ncurl https://dapp.tools/install | sh\n```\n\n## License\n\n[GNU Affero GPL v3.0](https://github.com/Anish-Agnihotri/MultiFaucet/blob/master/LICENSE)\n\n## Credits\n\n- [@gakonst/lootloose](https://github.com/gakonst/lootloose) for DappTools info\n- ds-test, OpenZeppelin for inherited libraries\n"
  },
  {
    "path": "contracts/remappings.txt",
    "content": "ds-test/=lib/ds-test/src/\n@openzeppelin/=lib/openzeppelin-contracts/"
  },
  {
    "path": "contracts/src/MultiFaucet.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/// ============ Imports ============\n\nimport \"./interfaces/IERC20.sol\"; // ERC20 minified interface\nimport \"@openzeppelin/contracts/token/ERC721/ERC721.sol\"; // OZ: ERC721\n\n/// @title MultiFaucet\n/// @author Anish Agnihotri\n/// @notice Drips ETH, DAI, wETH, and mints NFTs\ncontract MultiFaucet is ERC721 {\n\n    /// ============ Immutable storage ============\n\n    /// @notice DAI ERC20 token\n    IERC20 public immutable DAI;\n    /// @notice wETH ERC20 token\n    IERC20 public immutable WETH;\n\n    /// ============ Mutable storage ============\n\n    /// @notice Default NFT uri\n    string public URI;\n    /// @notice Count of minted NFTs\n    uint256 public nftsMinted;\n    /// @notice Number of ERC721 NFTs to mint\n    uint256 public NFT_COUNT = 5;\n    /// @notice ETH to disperse\n    uint256 public ETH_AMOUNT = 5e18;\n    /// @notice DAI to disperse\n    uint256 public DAI_AMOUNT = 5_000e18;\n    /// @notice wETH to disperse\n    uint256 public WETH_AMOUNT = 5e18;\n    /// @notice Addresses of approved operators\n    mapping(address => bool) public approvedOperators;\n    /// @notice Addresses of super operators\n    mapping(address => bool) public superOperators;\n\n    /// ============ Modifiers ============\n\n    /// @notice Requires sender to be contract super operator\n    modifier isSuperOperator() {\n        // Ensure sender is super operator\n        require(superOperators[msg.sender], \"Not super operator\");\n        _;\n    }\n\n    /// @notice Requires sender to be contract approved operator\n    modifier isApprovedOperator() {\n        // Ensure sender is in approved operators or is super operator\n        require(\n            approvedOperators[msg.sender] || superOperators[msg.sender], \n            \"Not approved operator\"\n        );\n        _;\n    }\n\n    /// ============ Events ============\n\n    /// @notice Emitted after faucet drips to a recipient\n    /// @param recipient address dripped to\n    event FaucetDripped(address indexed recipient);\n\n    /// @notice Emitted after faucet drained to a recipient\n    /// @param recipient address drained to\n    event FaucetDrained(address indexed recipient);\n\n    /// @notice Emitted after operator status is updated\n    /// @param operator address being updated\n    /// @param status new operator status\n    event OperatorUpdated(address indexed operator, bool status);\n\n    /// @notice Emitted after super operator is updated\n    /// @param operator address being updated\n    /// @param status new operator status\n    event SuperOperatorUpdated(address indexed operator, bool status);\n\n    /// ============ Constructor ============\n\n    /// @notice Creates a new MultiFaucet contract\n    /// @param _DAI address of DAI contract\n    /// @param _WETH address of wETH contract\n    /// @param _URI string of token URI\n    constructor(address _DAI, address _WETH, string memory _URI) \n        ERC721(\"MultiFaucet NFT\", \"MFNFT\") \n    {\n        DAI = IERC20(_DAI);\n        WETH = IERC20(_WETH);\n        URI = _URI;\n        superOperators[msg.sender] = true;\n    }\n\n    /// ============ Functions ============\n\n    /// @notice Drips and mints tokens to recipient\n    /// @param _recipient to drip tokens to\n    function drip(address _recipient) external isApprovedOperator {\n        // Drip Ether\n        (bool sent,) = _recipient.call{value: ETH_AMOUNT}(\"\");\n        require(sent, \"Failed dripping ETH\");\n\n        // Drip DAI\n        require(DAI.transfer(_recipient, DAI_AMOUNT), \"Failed dripping DAI\");\n\n        // Drip wETH\n        require(WETH.transfer(_recipient, WETH_AMOUNT), \"Failed dripping wETH\");\n\n        // Mint NFTs\n        for (uint256 i = 1; i <= NFT_COUNT; i++) {\n            _mint(_recipient, nftsMinted + i);\n        }\n        nftsMinted += NFT_COUNT;\n\n        emit FaucetDripped(_recipient);\n    }\n\n    /// @notice Returns number of available drips by token\n    /// @return ethDrips — available Ether drips\n    /// @return daiDrips — available DAI drips\n    /// @return wethDrips — available wETH drips\n    function availableDrips() public view \n        returns (uint256 ethDrips, uint256 daiDrips, uint256 wethDrips) \n    {\n        ethDrips = address(this).balance / ETH_AMOUNT;\n        daiDrips = DAI.balanceOf(address(this)) / DAI_AMOUNT;\n        wethDrips = WETH.balanceOf(address(this)) / WETH_AMOUNT;\n    }\n\n    /// @notice Allows super operator to drain contract of tokens\n    /// @param _recipient to send drained tokens to\n    function drain(address _recipient) external isSuperOperator {\n        // Drain all Ether\n        (bool sent,) = _recipient.call{value: address(this).balance}(\"\");\n        require(sent, \"Failed draining ETH\");\n\n        // Drain all DAI\n        uint256 daiBalance = DAI.balanceOf(address(this));\n        require(DAI.transfer(_recipient, daiBalance), \"Failed draining DAI\");\n\n        // Drain all wETH\n        uint256 wethBalance = WETH.balanceOf(address(this));\n        require(WETH.transfer(_recipient, wethBalance), \"Failed dripping wETH\");\n\n        emit FaucetDrained(_recipient);\n    }\n\n    /// @notice Allows super operator to update approved drip operator status\n    /// @param _operator address to update\n    /// @param _status of operator to toggle (true == allowed to drip)\n    function updateApprovedOperator(address _operator, bool _status) \n        external \n        isSuperOperator \n    {\n        approvedOperators[_operator] = _status;\n        emit OperatorUpdated(_operator, _status);\n    }\n\n    /// @notice Allows super operator to update super operator\n    /// @param _operator address to update\n    /// @param _status of operator to toggle (true === is super operator)\n    function updateSuperOperator(address _operator, bool _status) \n        external\n        isSuperOperator\n    {\n        superOperators[_operator] = _status;\n        emit SuperOperatorUpdated(_operator, _status);\n    }\n\n    /// @notice Override internal ERC721 function to return single image per NFT\n    /// @param tokenId of ERC721 NFT\n    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n        // OpenZeppelin check: ensure token exists\n        require(_exists(tokenId), \"ERC721Metadata: URI query for nonexistent token\");\n        return URI;\n    }\n\n    /// @notice Allows super operator to update NFT uri\n    /// @param _URI of collection\n    function updateTokenURI(string memory _URI) external isSuperOperator {\n        URI = _URI;\n    }\n\n    /// @notice Allows super operator to update drip amounts\n    /// @param _nftCount number of NFTs to mint per drip\n    /// @param _ethAmount ETH to drip\n    /// @param _daiAmount DAI to drip\n    /// @param _wethAmount wETH to drip\n    function updateDripAmounts(\n        uint256 _nftCount, \n        uint256 _ethAmount,\n        uint256 _daiAmount,\n        uint256 _wethAmount\n    ) external isSuperOperator {\n        NFT_COUNT = _nftCount;\n        ETH_AMOUNT = _ethAmount;\n        DAI_AMOUNT = _daiAmount;\n        WETH_AMOUNT = _wethAmount;\n    }\n\n    /// @notice Allows receiving ETH\n    receive() external payable {}\n}"
  },
  {
    "path": "contracts/src/interfaces/IERC20.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\ninterface IERC20 {\n  /// @notice ERC0 transfer tokens\n  function transfer(address recipient, uint256 amount) external returns (bool);\n  /// @notice ERC20 balance of address\n  function balanceOf(address account) external view returns (uint256);\n}"
  },
  {
    "path": "contracts/src/test/MultiFaucet.t.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/// ============ Imports ============\n\nimport \"./utils/MultiFaucetTest.sol\"; // MultiFaucet ds-test\n\n/// ============ Libraries ============\n\nlibrary URIs {\n    string constant defaultURI = 'https://test.com';\n    string constant alternativeURI = 'https://alternative.com';\n}\n\nlibrary Errors {\n    string constant NotSuperOperator = 'Not super operator';\n    string constant NotApprovedOperator = 'Not approved operator';\n}\n\n/// ============ Functionality testing ============\n\ncontract Tests is MultiFaucetTest {\n    /// @notice Allow dripping to recipient, if super operator\n    function testDrip() public {\n        // Bob before balances\n        uint256 bobETHBalanceBefore = BOB.ETHBalance();\n        uint256 bobDAIBalanceBefore = BOB.DAIBalance();\n        uint256 bobWETHBalanceBefore = BOB.WETHBalance();\n        uint256 bobNFTCountBefore = BOB.NFTBalance();\n\n        // Alice drips to bob\n        ALICE.drip(address(BOB));\n\n        // Bob after balances\n        assertEq(BOB.ETHBalance(), bobETHBalanceBefore + 5 ether);\n        assertEq(BOB.DAIBalance(), bobDAIBalanceBefore + 5_000e18);\n        assertEq(BOB.WETHBalance(), bobWETHBalanceBefore + 5e18);\n        assertEq(BOB.NFTBalance(), bobNFTCountBefore + 5);\n\n        // Check token uris\n        for (uint256 i = 1; i <= 5; i++) {\n            assertEq(FAUCET.tokenURI(i), URIs.defaultURI);\n        }\n    }\n\n    /// @notice Prevent dripping if not approved operator\n    function testCannotDripIfNotOperator() public {\n        assertErrorFunctionWithAddress(\n            BOB.drip,\n            address(ALICE),\n            Errors.NotApprovedOperator\n        );\n    }\n\n    /// @notice Can add approved operator and they can drip\n    function testAddApprovedOperator() public {\n        // Alice adds Bob as approved operator\n        ALICE.updateApprovedOperator(address(BOB), true);\n\n        // Ensure Bob is an approved operator\n        assertTrue(FAUCET.approvedOperators(address(BOB)));\n\n        // Ensure Bob can drip\n        BOB.drip(address(ALICE));\n    }\n\n    /// @notice Can remove approved operator and they can't drip\n    function testRemoveApprovedOperator() public {\n        // Alice adds Bob as approved operator\n        ALICE.updateApprovedOperator(address(BOB), true);\n        assertTrue(FAUCET.approvedOperators(address(BOB)));\n\n        // Alice removes Bob as approved operator\n        ALICE.updateApprovedOperator(address(BOB), false);\n        assertTrue(!FAUCET.approvedOperators(address(BOB)));\n\n        // Bob can no longer drip\n        assertErrorFunctionWithAddress(\n            BOB.drip,\n            address(ALICE),\n            Errors.NotApprovedOperator\n        );\n    }\n\n    /// @notice Can update super operator\n    function testUpdateSuperOperator() public {\n        // Alice gives super operatorship to BOB\n        ALICE.updateSuperOperator(address(BOB), true);\n\n        // Verify Bob is now a super operator\n        assertTrue(FAUCET.superOperators(address(BOB)));\n\n        // Alice removes her super operatorship\n        ALICE.updateSuperOperator(address(ALICE), false);\n\n        // Alice can no longer drip\n        assertErrorFunctionWithAddress(\n            ALICE.drip,\n            address(BOB),\n            Errors.NotApprovedOperator\n        );\n\n        // Bob can add Alice to super operators\n        BOB.updateApprovedOperator(address(ALICE), true);\n        assertTrue(FAUCET.approvedOperators(address(ALICE)));\n\n        // Alice can now drip\n        ALICE.drip(address(BOB));\n\n        // Alice can still not update super operator\n        assertErrorFunctionWithAddressAndBool(\n            ALICE.updateSuperOperator,\n            address(ALICE),\n            true,\n            Errors.NotSuperOperator\n        );\n    }\n    \n    /// @notice Can drain contract if super operator\n    function testCanDrainFaucet() public {\n        // Bob before balances\n        uint256 bobETHBalanceBefore = BOB.ETHBalance();\n        uint256 bobDAIBalanceBefore = BOB.DAIBalance();\n        uint256 bobWETHBalanceBefore = BOB.WETHBalance();\n\n        // Alice drains to bob\n        ALICE.drain(address(BOB));\n\n        // Bob after balances\n        assertEq(BOB.ETHBalance(), bobETHBalanceBefore + 100 ether);\n        assertEq(BOB.DAIBalance(), bobDAIBalanceBefore + 100_000e18);\n        assertEq(BOB.WETHBalance(), bobWETHBalanceBefore + 100e18);\n    }\n\n    /// @notice Cannot drain contract if not super operator\n    function testCannotDrainIfNotSuperOperator() public {\n        assertErrorFunctionWithAddress(\n            BOB.drain,\n            address(BOB),\n            Errors.NotSuperOperator\n        );\n    }\n\n    /// @notice Returns correct number of available drips\n    function testCorrectDripCount() public {\n        (uint256 ethDrips, uint256 daiDrips, uint256 wethDrips)\n            = FAUCET.availableDrips();\n        assertEq(ethDrips, 20);\n        assertEq(daiDrips, 20);\n        assertEq(wethDrips, 20);\n    }\n\n    /// @notice Allows super operator to update collection URI\n    function testAllowsUpdatingURI() public {\n        // Drip to Bob\n        ALICE.drip(address(BOB));\n\n        // Ensure old URI for bobs tokens\n        for (uint256 i = 1; i <= 5; i++) {\n            assertEq(FAUCET.tokenURI(i), URIs.defaultURI);\n        }\n\n        // Update URI\n        ALICE.updateTokenURI(URIs.alternativeURI);\n\n        // Drip to Bob\n        ALICE.drip(address(BOB));\n\n        // Ensure new URI for bobs tokens\n        for (uint256 i = 1; i <= 10; i++) {\n            assertEq(FAUCET.tokenURI(i), URIs.alternativeURI);\n        }\n    }\n\n    /// @notice Allows super operators to update drip amounts\n    function testAllowsUpdatingDripAmounts() public {\n        // Bob before balances\n        uint256 bobETHBalanceBefore = BOB.ETHBalance();\n        uint256 bobDAIBalanceBefore = BOB.DAIBalance();\n        uint256 bobWETHBalanceBefore = BOB.WETHBalance();\n        uint256 bobNFTCountBefore = BOB.NFTBalance();\n\n        // Alice updates drip amounts\n        ALICE.updateDripAmounts(1, 1e18, 1000e18, 1e18);\n\n        // Alice drips to bob\n        ALICE.drip(address(BOB));\n\n        // Bob after balances\n        assertEq(BOB.ETHBalance(), bobETHBalanceBefore + 1 ether);\n        assertEq(BOB.DAIBalance(), bobDAIBalanceBefore + 1_000e18);\n        assertEq(BOB.WETHBalance(), bobWETHBalanceBefore + 1e18);\n        assertEq(BOB.NFTBalance(), bobNFTCountBefore + 1);\n    }\n}"
  },
  {
    "path": "contracts/src/test/utils/DSTestExtended.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/// ============ Imports ============\n\nimport \"ds-test/test.sol\"; // ds-test\n\n/// @title DSTestExtended\n/// @author Anish Agnihotri\n/// @notice Extends DSTest with more generic assertions for revert checks\ncontract DSTestExtended is DSTest {\n    /// @notice Calls function and checks for matching revert message\n    /// @param erroringFunction to call\n    /// @param param to pass to function\n    /// @param message to check against revert error string\n    function assertErrorFunctionWithAddress(\n        function(address) external erroringFunction,\n        address param,\n        string memory message\n    ) internal {\n        try erroringFunction(param) { \n            fail();\n        } catch Error(string memory error) {\n            // Assert revert error matches expected message\n            assertEq(error, message);\n        }\n    }\n\n    /// @notice Calls function and checks for matching revert message\n    /// @param erroringFunction to call\n    /// @param _addr to pass to function\n    /// @param _bool bool to pass to function\n    /// @param message to check against revert error string\n    function assertErrorFunctionWithAddressAndBool(\n        function(address, bool) external erroringFunction,\n        address _addr,\n        bool _bool,\n        string memory message\n    ) internal {\n        try erroringFunction(_addr, _bool) { \n            fail();\n        } catch Error(string memory error) {\n            // Assert revert error matches expected message\n            assertEq(error, message);\n        }\n    }\n}"
  },
  {
    "path": "contracts/src/test/utils/ERC20Mintable.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/// ============ Imports ============\n\nimport { ERC20 } from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\"; // OZ: ERC20\n\n/// @title ERC20Mintable\n/// @author Anish Agnihotri\n/// @notice Exposes ERC20 minting as external function\ncontract ERC20Mintable is ERC20 {\n    // Initialize ERC20\n    constructor(\n        string memory name_, \n        string memory symbol_\n    ) ERC20(name_, symbol_) {}\n\n    /// @notice Expose ERC20 minting as external function\n    /// @param account to mint to\n    /// @param amount to mint\n    function mint(address account, uint256 amount) external {\n        _mint(account, amount);\n    }\n}"
  },
  {
    "path": "contracts/src/test/utils/MultiFaucetTest.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/// ============ Imports ============\n\nimport \"./DSTestExtended.sol\"; // DSTestExtended\nimport \"./ERC20Mintable.sol\"; // ERC20Mintable\nimport \"./MultiFaucetUser.sol\"; // Faucet user\nimport \"../../MultiFaucet.sol\"; // MultiFaucet\n\ncontract MultiFaucetTest is DSTestExtended {\n\n    /// ============ Storage ============\n\n    /// @dev DAI token\n    ERC20Mintable internal DAI;\n    /// @dev wETH token\n    ERC20Mintable internal WETH;\n    /// @dev MultiFaucet contract\n    MultiFaucet internal FAUCET;\n    /// @dev User: Alice (default super operator)\n    MultiFaucetUser internal ALICE;\n    /// @dev User: Bob\n    MultiFaucetUser internal BOB;\n\n    /// ============ Setup test suite ============\n\n    function setUp() public virtual {\n        // Setup tokens\n        DAI = new ERC20Mintable(\"DAI Stablecoin\", \"DAI\");\n        WETH = new ERC20Mintable(\"Wrapped Ether\", \"wETH\");\n\n        // Create faucet\n        FAUCET = new MultiFaucet(address(DAI), address(WETH), \"https://test.com\");\n\n        // Fund faucet\n        (bool success, ) = payable(address(FAUCET)).call{value: 100 ether}(\"\");\n        require(success, \"Failed funding faucet with ETH\");\n        DAI.mint(address(FAUCET), 100_000e18);\n        WETH.mint(address(FAUCET), 100e18);\n\n        // Setup faucet users\n        ALICE = new MultiFaucetUser(FAUCET, address(DAI), address(WETH));\n        BOB = new MultiFaucetUser(FAUCET, address(DAI), address(WETH));\n\n        // Make Alice superOperator\n        FAUCET.updateSuperOperator(address(ALICE), true);\n    }\n}"
  },
  {
    "path": "contracts/src/test/utils/MultiFaucetUser.sol",
    "content": "// SPDX-License-Identifier: AGPL-3.0-only\npragma solidity ^0.8.0;\n\n/// ============ Imports ============\n\nimport \"../../MultiFaucet.sol\"; // MultiFaucet\nimport \"../../interfaces/IERC20.sol\"; // ERC20 minified interface\nimport \"@openzeppelin/contracts/token/ERC721/utils/ERC721Holder.sol\"; // OZ: ERC721 recipient\n\n/// @title MultiFaucetUser\n/// @author Anish Agnihotri\n/// @notice Mock user to test interacting with MultiFaucet\ncontract MultiFaucetUser is ERC721Holder {\n\n    /// ============ Immutable storage ============\n\n    /// @dev DAI contract\n    IERC20 immutable internal DAI;\n    /// @dev wETH contract\n    IERC20 immutable internal WETH;\n    /// @dev Faucet contract\n    MultiFaucet immutable internal FAUCET;\n\n    /// ============ Constructor ============\n\n    /// @notice Creates a new MultiFaucetUser\n    /// @param _DAI contract address\n    /// @param _WETH contract address\n    /// @param _FAUCET contract\n    constructor(MultiFaucet _FAUCET, address _DAI, address _WETH) {\n        DAI = IERC20(_DAI);\n        WETH = IERC20(_WETH);\n        FAUCET = _FAUCET;\n    }\n\n    /// ============ Helper functions ============\n\n    /// @notice Returns ETH balance of user\n    function ETHBalance() public view returns (uint256) {\n        return address(this).balance;\n    }\n\n    /// @notice Returns DAI balance of user\n    function DAIBalance() public view returns (uint256) {\n        return DAI.balanceOf(address(this));\n    }\n\n    /// @notice Returns wETH balance of user\n    function WETHBalance() public view returns (uint256) {\n        return WETH.balanceOf(address(this));\n    }\n\n    /// @notice Returns NFT count of user\n    function NFTBalance() public view returns (uint256) {\n        return FAUCET.balanceOf(address(this));\n    }\n\n    /// ============ Inherited Functionality ============\n\n    /// @notice Drips from faucet to recipient\n    /// @param _recipient to drip to\n    function drip(address _recipient) public {\n        FAUCET.drip(_recipient);\n    }\n\n    /// @notice Drains faucet to a recipient address\n    /// @param _recipient to drain to\n    function drain(address _recipient) public {\n        FAUCET.drain(_recipient);\n    }\n\n    /// @notice Adds or removes approved operator\n    /// @param _operator address\n    /// @param _status to update for operator (true == allowed to drip)\n    function updateApprovedOperator(\n        address _operator, \n        bool _status\n    ) public {\n        FAUCET.updateApprovedOperator(_operator, _status);\n    }\n\n    /// @notice Updates super operator\n    /// @param _operator address\n    /// @param _status of operator\n    function updateSuperOperator(address _operator, bool _status) public {\n        FAUCET.updateSuperOperator(_operator, _status);\n    }\n\n    /// @notice Updates token collection URI\n    /// @param _URI new collection URI\n    function updateTokenURI(string memory _URI) public {\n        FAUCET.updateTokenURI(_URI);\n    }\n\n    /// @notice Updates drip amounts\n    /// @param _nftCount number of NFTs to mint per drip\n    /// @param _ethAmount ETH to drip\n    /// @param _daiAmount DAI to drip\n    /// @param _wethAmount wETH to drip\n    function updateDripAmounts(\n        uint256 _nftCount, \n        uint256 _ethAmount,\n        uint256 _daiAmount,\n        uint256 _wethAmount\n    ) public {\n        FAUCET.updateDripAmounts(\n            _nftCount, \n            _ethAmount, \n            _daiAmount, \n            _wethAmount\n        );\n    }\n\n    /// @notice Allows receiving ETH\n    receive() external payable {}\n}"
  },
  {
    "path": "frontend/.gitignore",
    "content": ".vercel\n"
  },
  {
    "path": "frontend/README.md",
    "content": "# Frontend\n\n## About\n\nFrontend to accompany [MultiFaucet contracts](https://github.com/Anish-Agnihotri/MultiFaucet/tree/master/contracts). Authenticates user with Twitter OAuth, stores claim for 24h in Redis, calls drip function on contract.\n\n## Run locally\n\n```bash\n# Install dependencies\nnpm install\n\n# Update environment variables\ncp .env.sample .env.local\nvim .env.local\n\n# Run\nnpm run dev\n```\n\n## License\n\n[GNU Affero GPL v3.0](https://github.com/Anish-Agnihotri/MultiFaucet/blob/master/LICENSE)\n"
  },
  {
    "path": "frontend/components/Layout.tsx",
    "content": "import styles from \"styles/Layout.module.scss\"; // Styles\nimport { default as HTMLHead } from \"next/head\"; // Meta\n\n// Page layout\nexport default function Layout({\n  children,\n}: {\n  children: (JSX.Element | null)[];\n}) {\n  return (\n    <div className={styles.layout}>\n      {/* Meta + Head */}\n      <Head />\n\n      {/* Layout sizer */}\n      <div className={styles.layout__content}>{children}</div>\n\n      {/* Footer */}\n      <Footer />\n    </div>\n  );\n}\n\n// Head + Meta\nfunction Head() {\n  return (\n    <HTMLHead>\n      {/* Google Fonts */}\n      <link rel=\"preconnect\" href=\"https://fonts.googleapis.com\" />\n      <link\n        rel=\"preconnect\"\n        href=\"https://fonts.gstatic.com\"\n        crossOrigin=\"true\"\n      />\n      <link\n        href=\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap\"\n        rel=\"stylesheet\"\n      />\n\n      {/* Favicon */}\n      <link rel=\"shortcut icon\" href=\"/favicon.ico\" />\n\n      {/* Primary Meta Tags */}\n      <title>Paradigm MultiFaucet | Bootstrap your testnet wallet</title>\n      <meta\n        name=\"title\"\n        content=\"Paradigm MultiFaucet | Bootstrap your testnet wallet\"\n      />\n      <meta\n        name=\"description\"\n        content=\"MultiFaucet funds a wallet with ETH, wETH, DAI, and NFTs across 8 testnet networks, at once.\"\n      />\n\n      {/* OG + Facebook */}\n      <meta property=\"og:type\" content=\"website\" />\n      <meta property=\"og:url\" content=\"https://faucet.paradigm.xyz\" />\n      <meta\n        property=\"og:title\"\n        content=\"Paradigm MultiFaucet | Bootstrap your testnet wallet\"\n      />\n      <meta\n        property=\"og:description\"\n        content=\"MultiFaucet funds a wallet with ETH, wETH, DAI, and NFTs across 8 testnet networks, at once.\"\n      />\n      <meta\n        property=\"og:image\"\n        content=\"https://faucet.paradigm.xyz/meta.png\"\n      />\n\n      {/* Twitter */}\n      <meta property=\"twitter:card\" content=\"summary_large_image\" />\n      <meta property=\"twitter:url\" content=\"https://faucet.paradigm.xyz\" />\n      <meta\n        property=\"twitter:title\"\n        content=\"Paradigm MultiFaucet | Bootstrap your testnet wallet\"\n      />\n      <meta\n        property=\"twitter:description\"\n        content=\"MultiFaucet funds a wallet with ETH, wETH, DAI, and NFTs across 8 testnet networks, at once.\"\n      />\n      <meta\n        property=\"twitter:image\"\n        content=\"https://faucet.paradigm.xyz/meta.png\"\n      />\n    </HTMLHead>\n  );\n}\n\n// Footer\nfunction Footer() {\n  return (\n    <div className={styles.layout__footer}>\n      {/* Disclaimer */}\n      <p>\n        These smart contracts are being provided as is. No guarantee,\n        representation or warranty is being made, express or implied, as to the\n        safety or correctness of the user interface or the smart contracts. They\n        have not been audited and as such there can be no assurance they will\n        work as intended, and users may experience delays, failures, errors,\n        omissions or loss of transmitted information. Paradigm is not liable for\n        any of the foregoing. Users should proceed with caution and use at their\n        own risk.\n      </p>\n    </div>\n  );\n}\n"
  },
  {
    "path": "frontend/next-env.d.ts",
    "content": "/// <reference types=\"next\" />\n/// <reference types=\"next/types/global\" />\n/// <reference types=\"next/image-types/global\" />\n\n// NOTE: This file should not be edited\n// see https://nextjs.org/docs/basic-features/typescript for more information.\n"
  },
  {
    "path": "frontend/package.json",
    "content": "{\n  \"name\": \"multifaucet\",\n  \"author\": \"Anish Agnihotri\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"license\": \"MIT\",\n  \"scripts\": {\n    \"dev\": \"next dev\",\n    \"build\": \"next build\",\n    \"start\": \"next start\",\n    \"lint\": \"next lint\"\n  },\n  \"dependencies\": {\n    \"@slack/web-api\": \"^6.5.1\",\n    \"axios\": \"^0.24.0\",\n    \"ethers\": \"^5.4.7\",\n    \"ioredis\": \"^4.28.0\",\n    \"next\": \"^12.0.4\",\n    \"next-auth\": \"^3.29.0\",\n    \"react\": \"17.0.2\",\n    \"react-dom\": \"17.0.2\",\n    \"react-toastify\": \"^8.0.3\",\n    \"sass\": \"^1.42.1\"\n  },\n  \"devDependencies\": {\n    \"@types/ioredis\": \"^4.27.7\",\n    \"@types/react\": \"17.0.26\",\n    \"eslint\": \"7.32.0\",\n    \"eslint-config-next\": \"11.1.2\",\n    \"typescript\": \"4.4.3\"\n  }\n}\n"
  },
  {
    "path": "frontend/pages/_app.tsx",
    "content": "import \"styles/global.scss\"; // Global styles\nimport type { AppProps } from \"next/app\"; // Types\nimport { Provider } from \"next-auth/client\"; // Next auth state\nimport \"react-toastify/dist/ReactToastify.css\"; // Toast styles\nimport { ToastContainer } from \"react-toastify\"; // Toast notifications\n\nexport default function MultiFaucet({ Component, pageProps }: AppProps) {\n  return (\n    // Wrap app in auth session provider\n    <Provider session={pageProps.session}>\n      {/* Toast container */}\n      <ToastContainer />\n\n      {/* Site */}\n      <Component {...pageProps} />\n    </Provider>\n  );\n}\n"
  },
  {
    "path": "frontend/pages/api/auth/[...nextauth].ts",
    "content": "import NextAuth from \"next-auth\"; // Next auth\nimport Providers from \"next-auth/providers\"; // Twitter provider\n\nexport default NextAuth({\n  providers: [\n    // Twitter OAuth provider\n    Providers.Twitter({\n      clientId: process.env.TWITTER_CLIENT_ID,\n      clientSecret: process.env.TWITTER_CLIENT_SECRET,\n    }),\n  ],\n  // Custom page:\n  pages: {\n    // On error, throw to home\n    error: \"/\",\n  },\n  // Use JWT\n  session: {\n    jwt: true,\n    // 30 day expiry\n    maxAge: 30 * 24 * 60 * 60,\n    // Refresh JWT on each login\n    updateAge: 0,\n  },\n  jwt: {\n    // JWT secret\n    secret: process.env.NEXTAUTH_JWT_SECRET,\n  },\n  callbacks: {\n    // On signin + signout\n    jwt: async (token, user, account, profile) => {\n      // Check if user is signing in (versus logging out)\n      const isSignIn = user ? true : false;\n\n      // If signing in\n      if (isSignIn) {\n        // Attach additional parameters (twitter id + handle + anti-bot measures)\n        token.twitter_id = account?.id;\n        token.twitter_handle = profile?.screen_name;\n        token.twitter_num_tweets = profile?.statuses_count;\n        token.twitter_num_followers = profile?.followers_count;\n        token.twitter_created_at = profile?.created_at;\n      }\n\n      // Resolve JWT\n      return Promise.resolve(token);\n    },\n    // On session retrieval\n    session: async (session, user) => {\n      // Attach additional params from JWT to session\n      session.twitter_id = user.twitter_id;\n      session.twitter_handle = user.twitter_handle;\n      session.twitter_num_tweets = user.twitter_num_tweets;\n      session.twitter_num_followers = user.twitter_num_followers;\n      session.twitter_created_at = user.twitter_created_at;\n\n      // Resolve session\n      return Promise.resolve(session);\n    },\n  },\n});\n"
  },
  {
    "path": "frontend/pages/api/claim/new.ts",
    "content": "import Redis from \"ioredis\"; // Redis\nimport { ethers } from \"ethers\"; // Ethers\nimport { WebClient } from \"@slack/web-api\"; // Slack\nimport { isValidInput } from \"pages/index\"; // Address check\nimport parseTwitterDate from \"utils/dates\"; // Parse Twitter dates\nimport { getSession } from \"next-auth/client\"; // Session management\nimport { hasClaimed } from \"pages/api/claim/status\"; // Claim status\nimport type { NextApiRequest, NextApiResponse } from \"next\"; // Types\n\n// Setup whitelist (Anish)\nconst whitelist: string[] = [\"1078014622525988864\"];\n\n// Setup redis client\nconst client = new Redis(process.env.REDIS_URL);\n\n// Setup slack client\nconst slack = new WebClient(process.env.SLACK_ACCESS_TOKEN);\nconst slackChannel: string = process.env.SLACK_CHANNEL ?? \"\";\n/**\n * Post message to slack channel\n * @param {string} message to post\n */\nasync function postSlackMessage(message: string): Promise<void> {\n  await slack.chat.postMessage({\n    channel: slackChannel,\n    text: message,\n    // Ping user on error\n    link_names: true,\n  });\n}\n\n/**\n * Generate Alchemy RPC endpoint url from partials\n * @param {string} partial of network\n * @returns {string} full rpc url\n */\nfunction generateAlchemy(partial: string): string {\n  // Combine partial + API key\n  return `https://${partial}/v2/${process.env.ALCHEMY_API_KEY}`;\n}\n\n// Setup networks\nconst ARBITRUM: number = 421611;\nconst mainRpcNetworks: Record<number, string> = {\n  //3: generateAlchemy(\"eth-ropsten.alchemyapi.io\"),\n  4: generateAlchemy(\"eth-rinkeby.alchemyapi.io\"),\n  5: generateAlchemy(\"eth-goerli.alchemyapi.io\"),\n  42: generateAlchemy(\"eth-kovan.alchemyapi.io\"),\n};\nconst secondaryRpcNetworks: Record<number, string> = {\n  69: generateAlchemy(\"opt-kovan.g.alchemy.com\"),\n  //1287: \"https://rpc.api.moonbase.moonbeam.network\",\n  80001: generateAlchemy(\"polygon-mumbai.g.alchemy.com\"),\n  421611: generateAlchemy(\"arb-rinkeby.g.alchemy.com\"),\n  //43113: \"https://api.avax-test.network/ext/bc/C/rpc\",\n};\n\n// Setup faucet interface\nconst iface = new ethers.utils.Interface([\n  \"function drip(address _recipient) external\",\n]);\n\n/**\n * Generates tx input data for drip claim\n * @param {string} recipient address\n * @returns {string} encoded input data\n */\nfunction generateTxData(recipient: string): string {\n  // Encode address for drip function\n  return iface.encodeFunctionData(\"drip\", [recipient]);\n}\n\n/**\n * Collects StaticJsonRpcProvider by network\n * @param {number} network id\n * @returns {ethers.providers.StaticJsonRpcProvider} provider\n */\nfunction getProviderByNetwork(\n  network: number\n): ethers.providers.StaticJsonRpcProvider {\n  // Collect all RPC URLs\n  const rpcNetworks = { ...mainRpcNetworks, ...secondaryRpcNetworks };\n  // Collect alchemy RPC URL\n  const rpcUrl = rpcNetworks[network];\n  // Return static provider\n  return new ethers.providers.StaticJsonRpcProvider(rpcUrl);\n}\n\n/**\n * Collects nonce by network (cache first)\n * @param {number} network id\n * @returns {Promise<number>} network account nonce\n */\nasync function getNonceByNetwork(network: number): Promise<number> {\n  // Collect nonce from redis\n  const redisNonce: string | null = await client.get(`nonce-${network}`);\n\n  // If no redis nonce\n  if (redisNonce == null) {\n    // Update to last network nonce\n    const provider = getProviderByNetwork(network);\n    return await provider.getTransactionCount(\n      // Collect nonce for operator\n      process.env.NEXT_PUBLIC_OPERATOR_ADDRESS ?? \"\"\n    );\n  } else {\n    // Else, return cached nonce\n    return Number(redisNonce);\n  }\n}\n\n/**\n * Returns populated drip transaction for a network\n * @param {ethers.Wallet} wallet without RPC network connected\n * @param {number} network id\n * @param {string} data input for tx\n */\nasync function processDrip(\n  wallet: ethers.Wallet,\n  network: number,\n  data: string\n): Promise<void> {\n  // Collect provider\n  const provider = getProviderByNetwork(network);\n\n  // Connect wallet to network\n  const rpcWallet = wallet.connect(provider);\n  // Collect nonce for network\n  const nonce = await getNonceByNetwork(network);\n  // Collect gas price * 2 for network\n  const gasPrice = (await provider.getGasPrice()).mul(2);\n\n  // Update nonce for network in redis w/ 5m ttl\n  await client.set(`nonce-${network}`, nonce + 1, \"EX\", 300);\n\n  // Return populated transaction\n  try {\n    await rpcWallet.sendTransaction({\n      to: process.env.FAUCET_ADDRESS ?? \"\",\n      from: wallet.address,\n      gasPrice,\n      // Custom gas override for Arbitrum w/ min gas limit\n      gasLimit: network === ARBITRUM ? 5_000_000 : 500_000,\n      data,\n      nonce,\n      type: 0,\n    });\n  } catch (e) {\n    await postSlackMessage(\n      `@anish Error dripping for ${provider.network.chainId}, ${String(\n        (e as any).reason\n      )}`\n    );\n\n    // Delete nonce key to attempt at self-heal\n    const delStatus: number = await client.del(\n      `nonce-${provider.network.chainId}`\n    );\n    await postSlackMessage(`Attempting self heal: ${delStatus}`);\n\n    // Throw error\n    throw new Error(`Error when processing drip for network ${network}`);\n  }\n}\n\nexport default async (req: NextApiRequest, res: NextApiResponse) => {\n  // Collect session (force any for extra twitter params)\n  const session: any = await getSession({ req });\n  // Collect address\n  const { address, others }: { address: string; others: boolean } = req.body;\n\n  if (!session) {\n    // Return unauthed status\n    return res.status(401).send({ error: \"Not authenticated.\" });\n  }\n\n  // Basic anti-bot measures\n  const ONE_MONTH_SECONDS = 2629746;\n  if (\n    // Less than 1 tweet\n    session.twitter_num_tweets == 0 ||\n    // Less than 15 followers\n    session.twitter_num_followers < 15 ||\n    // Less than 1 month old\n    new Date().getTime() -\n      parseTwitterDate(session.twitter_created_at).getTime() <\n      ONE_MONTH_SECONDS\n  ) {\n    // Return invalid Twitter account status\n    return res\n      .status(400)\n      .send({ error: \"Twitter account does not pass anti-bot checks.\" });\n  }\n\n  if (!address || !isValidInput(address)) {\n    // Return invalid address status\n    return res.status(400).send({ error: \"Invalid address.\" });\n  }\n\n  // Collect address\n  let addr: string = address;\n  // If address is ENS name\n  if (~address.toLowerCase().indexOf(\".eth\")) {\n    // Setup custom mainnet provider\n    const provider = new ethers.providers.StaticJsonRpcProvider(\n      `https://eth-mainnet.alchemyapi.io/v2/${process.env.ALCHEMY_API_KEY}`\n    );\n\n    // Collect 0x address from ENS\n    const resolvedAddress = await provider.resolveName(address);\n\n    // If no resolver set\n    if (!resolvedAddress) {\n      // Return invalid ENS status\n      return res\n        .status(400)\n        .send({ error: \"Invalid ENS name. No reverse record.\" });\n    }\n\n    // Else, set address\n    addr = resolvedAddress;\n  }\n\n  const claimed: boolean = await hasClaimed(session.twitter_id);\n  if (claimed) {\n    // Return already claimed status\n    return res.status(400).send({ error: \"Already claimed in 24h window\" });\n  }\n\n  // Setup wallet w/o RPC provider\n  const wallet = new ethers.Wallet(process.env.OPERATOR_PRIVATE_KEY ?? \"\");\n\n  // Generate transaction data\n  const data: string = generateTxData(addr);\n\n  // Networks to claim on (based on others toggle)\n  const otherNetworks: Record<number, string> = others\n    ? secondaryRpcNetworks\n    : {};\n  const claimNetworks: Record<number, string> = {\n    ...mainRpcNetworks,\n    ...otherNetworks,\n  };\n\n  // For each main network\n  for (const networkId of Object.keys(claimNetworks)) {\n    try {\n      // Process faucet claims\n      await processDrip(wallet, Number(networkId), data);\n    } catch (e) {\n      // If not whitelisted, force user to wait 15 minutes\n      if (!whitelist.includes(session.twitter_id)) {\n        // Update 24h claim status\n        await client.set(session.twitter_id, \"true\", \"EX\", 900);\n      }\n\n      // If error in process, revert\n      return res\n        .status(500)\n        .send({ error: \"Error fully claiming, try again in 15 minutes.\" });\n    }\n  }\n\n  // If not whitelisted\n  if (!whitelist.includes(session.twitter_id)) {\n    // Update 24h claim status\n    await client.set(session.twitter_id, \"true\", \"EX\", 86400);\n  }\n\n  return res.status(200).send({ claimed: address });\n};\n"
  },
  {
    "path": "frontend/pages/api/claim/status.ts",
    "content": "import Redis from \"ioredis\"; // Redis\nimport { getSession } from \"next-auth/client\"; // Session management\nimport type { NextApiRequest, NextApiResponse } from \"next\"; // Types\n\n// Setup redis client\nconst client = new Redis(process.env.REDIS_URL);\n\n/**\n * Checks if a twitter id has claimed from faucet in last 24h\n * @param {string} twitter_id to check\n * @returns {Promise<boolean>} claim status\n */\nexport async function hasClaimed(twitter_id: string): Promise<boolean> {\n  // Check if key exists\n  const resp: string | null = await client.get(twitter_id);\n  // If exists, return true, else return false\n  return resp ? true : false;\n}\n\nexport default async (req: NextApiRequest, res: NextApiResponse) => {\n  // Collect session (force any for extra twitter params)\n  const session: any = await getSession({ req });\n\n  if (session) {\n    try {\n      // Collect claim status\n      const claimed: boolean = await hasClaimed(session.twitter_id);\n      res.status(200).send({ claimed });\n    } catch {\n      // If failure, return error checking status\n      res.status(500).send({ error: \"Error checking claim status.\" });\n    }\n  } else {\n    // Return unauthed status\n    res.status(401).send({ error: \"Not authenticated.\" });\n  }\n};\n"
  },
  {
    "path": "frontend/pages/index.tsx",
    "content": "import axios from \"axios\"; // Requests\nimport Image from \"next/image\"; // Image\nimport { ethers } from \"ethers\"; // Address check\nimport { toast } from \"react-toastify\"; // Toast notifications\nimport Layout from \"components/Layout\"; // Layout wrapper\nimport { useRouter } from \"next/router\"; // Router\nimport styles from \"styles/Home.module.scss\"; // Styles\nimport { ReactElement, useState } from \"react\"; // Local state + types\nimport { getAddressDetails } from \"utils/addresses\"; // Faucet addresses\nimport { hasClaimed } from \"pages/api/claim/status\"; // Claim status\nimport { signIn, getSession, signOut } from \"next-auth/client\"; // Auth\n\n/**\n * Check if a provided address is valid\n * @param {string} address to check\n * @returns {boolean} validity\n */\nfunction isValidAddress(address: string): boolean {\n  try {\n    // Check if address is valid + checksum match\n    ethers.utils.getAddress(address);\n  } catch {\n    // If not, return false\n    return false;\n  }\n\n  // Else, return true\n  return true;\n}\n\n/**\n * Checks if a provider address or ENS name is valid\n * @param {string} address to check\n * @returns {boolean} validity\n */\nexport function isValidInput(address: string): boolean {\n  // Check if ENS name\n  if (~address.toLowerCase().indexOf(\".eth\")) {\n    return true;\n  }\n\n  // Else, check if valid general address\n  return isValidAddress(address);\n}\n\nexport default function Home({\n  session,\n  claimed: initialClaimed,\n}: {\n  session: any;\n  claimed: boolean;\n}) {\n  // Collect prefilled address\n  const {\n    query: { addr },\n  } = useRouter();\n  // Fill prefilled address\n  const prefilledAddress: string = addr && typeof addr === \"string\" ? addr : \"\";\n\n  // Claim address\n  const [address, setAddress] = useState<string>(prefilledAddress);\n  // Claimed status\n  const [claimed, setClaimed] = useState<boolean>(initialClaimed);\n  // First claim\n  const [firstClaim, setFirstClaim] = useState<boolean>(false);\n  // Loading status\n  const [loading, setLoading] = useState<boolean>(false);\n  // Claim other\n  const [claimOther, setClaimOther] = useState<boolean>(false);\n\n  // Collect details about addresses\n  const { networkCount, sortedAddresses } = getAddressDetails();\n\n  /**\n   * Processes a claim to the faucet\n   */\n  const processClaim = async () => {\n    // Toggle loading\n    setLoading(true);\n\n    try {\n      // Post new claim with recipient address\n      await axios.post(\"/api/claim/new\", { address, others: claimOther });\n      // Toast if success + toggle claimed\n      toast.success(\"Tokens dispersed—check balances shortly!\");\n      setClaimed(true);\n      setFirstClaim(true);\n    } catch (error: any) {\n      // If error, toast error message\n      toast.error(error.response.data.error);\n    }\n\n    // Toggle loading\n    setLoading(false);\n  };\n\n  return (\n    <Layout>\n      {/* CTA + description */}\n      <div className={styles.home__cta}>\n        <div>\n          <a\n            href=\"https://paradigm.xyz\"\n            target=\"_blank\"\n            rel=\"noopener noreferrer\"\n          >\n            <Image src=\"/logo.svg\" height=\"42.88px\" width=\"180px\" />\n          </a>\n        </div>\n        <h1>Bootstrap your testnet wallet</h1>\n        <span>\n          MultiFaucet funds a wallet with{\" \"}\n          <TokenLogo name=\"ETH\" imageSrc=\"/tokens/eth.png\" />\n          , <TokenLogo name=\"wETH\" imageSrc=\"/tokens/weth.png\" />,\n          <TokenLogo name=\"DAI\" imageSrc=\"/tokens/dai.svg\" />, and{\" \"}\n          <TokenLogo name=\"NFTs\" imageSrc=\"/tokens/punks.png\" /> across{\" \"}\n          {`${networkCount} `}\n          testnet networks, at once.\n        </span>\n      </div>\n\n      {/* Claim from facuet card */}\n      <div className={styles.home__card}>\n        {/* Card title */}\n        <div className={styles.home__card_title}>\n          <h3>Request Tokens</h3>\n        </div>\n\n        {/* Card content */}\n        <div className={styles.home__card_content}>\n          {!session ? (\n            // If user is unauthenticated:\n            <div className={styles.content__unauthenticated}>\n              {/* Reasoning for Twitter OAuth */}\n              <p>\n                To prevent faucet botting, you must sign in with Twitter. We\n                request{\" \"}\n                <a\n                  href=\"https://developer.twitter.com/en/docs/apps/app-permissions\"\n                  target=\"_blank\"\n                  rel=\"noopener noreferrer\"\n                >\n                  read-only\n                </a>{\" \"}\n                access.\n              </p>\n\n              {/* Sign in with Twitter */}\n              <button\n                className={styles.button__main}\n                onClick={() => signIn(\"twitter\")}\n              >\n                Sign In with Twitter\n              </button>\n            </div>\n          ) : (\n            // If user is authenticated:\n            <div className={styles.content__authenticated}>\n              {claimed ? (\n                // If user has already claimed once in 24h\n                <div className={styles.content__claimed}>\n                  <p>\n                    {firstClaim\n                      ? \"You have successfully claimed tokens. You can request again in 24 hours.\"\n                      : \"You have already claimed tokens today. Please try again in 24 hours.\"}\n                  </p>\n\n                  <input\n                    type=\"text\"\n                    placeholder=\"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\"\n                    disabled\n                  />\n                  <button className={styles.button__main} disabled>\n                    Tokens Already Claimed\n                  </button>\n                </div>\n              ) : (\n                // If user has not claimed in 24h\n                <div className={styles.content__unclaimed}>\n                  {/* Claim description */}\n                  <p>Enter your Ethereum address to receive tokens:</p>\n\n                  {/* Address input */}\n                  <input\n                    type=\"text\"\n                    placeholder=\"0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B\"\n                    value={address}\n                    onChange={(e) => setAddress(e.target.value)}\n                  />\n\n                  {/* Other networks checkbox */}\n                  <div className={styles.content__unclaimed_others}>\n                    <input\n                      type=\"checkbox\"\n                      value={claimOther.toString()}\n                      onChange={() => setClaimOther((previous) => !previous)}\n                    />\n                    <label>\n                      Drip on additional networks (besides Rinkeby, Ropsten,\n                      Kovan, and Görli)\n                    </label>\n                  </div>\n\n                  {isValidInput(address) ? (\n                    // If address is valid, allow claiming\n                    <button\n                      className={styles.button__main}\n                      onClick={processClaim}\n                      disabled={loading}\n                    >\n                      {!loading ? \"Claim\" : \"Claiming...\"}\n                    </button>\n                  ) : (\n                    // Else, force fix\n                    <button className={styles.button__main} disabled>\n                      {address === \"\"\n                        ? \"Enter Valid Address\"\n                        : \"Invalid Address\"}\n                    </button>\n                  )}\n                </div>\n              )}\n\n              {/* General among claimed or unclaimed, allow signing out */}\n              <div className={styles.content__twitter}>\n                <button onClick={() => signOut()}>\n                  Sign out @{session.twitter_handle}\n                </button>\n              </div>\n            </div>\n          )}\n        </div>\n      </div>\n\n      {/* Faucet details card */}\n      <div className={styles.home__card}>\n        {/* Card title */}\n        <div className={styles.home__card_title}>\n          <h3>Faucet Details</h3>\n        </div>\n\n        {/* General information */}\n        <div>\n          <div className={styles.home__card_content_section}>\n            <h4>General Information</h4>\n            <p>\n              Your Twitter account must have at least 1 Tweet, 15 followers, and\n              be older than 1 month.\n            </p>\n            <p className={styles.home__card_content_section_lh}>\n              By default, the faucet drips on the Ethereum testnets (Rinkeby,\n              Ropsten, Kovan, Görli). You can choose to receive a drip on other\n              networks when requesting tokens.\n            </p>\n            <p>You can claim from the faucet once every 24 hours.</p>\n          </div>\n        </div>\n\n        {/* Network details */}\n        {sortedAddresses.map((network) => {\n          // For each network\n          return (\n            <div key={network.network}>\n              <div className={styles.home__card_content_section}>\n                {/* Network name */}\n                <h4>\n                  {network.formattedName}\n                  {network.connectionDetails ? (\n                    <span>\n                      {\" \"}\n                      (\n                      <a\n                        href={network.connectionDetails}\n                        target=\"_blank\"\n                        rel=\"noopener noreferrer\"\n                      >\n                        connection details\n                      </a>\n                      ,\n                      {network.autoconnect ? (\n                        // Display network add button if non-default network\n                        <AddNetworkButton autoconnect={network.autoconnect} />\n                      ) : null}\n                      )\n                    </span>\n                  ) : null}\n\n                  {/* Optional depleted status */}\n                  {network.depleted ? (\n                    <span className={styles.home__card_depleted}>\n                      {\" \"}\n                      (maintenance mode)\n                    </span>\n                  ) : null}\n                </h4>\n\n                {/* Optional network disclaimer */}\n                {network.disclaimer ? <span>{network.disclaimer}</span> : null}\n\n                {Object.entries(network.addresses).map(([name, address]) => {\n                  // For each network address\n                  return (\n                    // Address description: address\n                    <p key={name}>\n                      {name}:{\" \"}\n                      <TokenAddress\n                        etherscanPrefix={network.etherscanPrefix}\n                        name={name}\n                        address={address}\n                        ERC20={name != \"NFTs\"}\n                      />\n                    </p>\n                  );\n                })}\n              </div>\n            </div>\n          );\n        })}\n      </div>\n    </Layout>\n  );\n}\n\n/**\n * Returns button to add network to MetaMask\n * @param {temp: any} autoconnect details\n * @returns {ReactElement}\n */\nfunction AddNetworkButton({ autoconnect }: { autoconnect: any }): ReactElement {\n  /**\n   * Adds network to MetaMask\n   */\n  const addToMetaMask = async () => {\n    // @ts-expect-error\n    await window.ethereum.request({\n      method: \"wallet_addEthereumChain\",\n      params: [autoconnect],\n    });\n  };\n\n  return (\n    <button onClick={addToMetaMask} className={styles.addNetworkButton}>\n      Add to MetaMask\n    </button>\n  );\n}\n\n/**\n * Returns token address component\n * @param {string} etherscanPrefix of address\n * @param {string?} name if displaying MM connect\n * @param {string} address to display\n * @param {string} ERC20 if asset is an ERC20\n * @returns {ReactElement}\n */\nfunction TokenAddress({\n  etherscanPrefix,\n  name,\n  address,\n  ERC20,\n}: {\n  etherscanPrefix: string;\n  name?: string;\n  address: string;\n  ERC20: boolean;\n}): ReactElement {\n  /**\n   * Adds token to MetaMask\n   */\n  const addToMetaMask = async () => {\n    // @ts-expect-error\n    await window.ethereum.request({\n      method: \"wallet_watchAsset\",\n      params: {\n        type: \"ERC20\",\n        options: {\n          address: address,\n          symbol: name,\n          decimals: 18,\n        },\n      },\n    });\n  };\n\n  return (\n    <span className={styles.address}>\n      <a\n        href={`https://${etherscanPrefix}/address/${address}`}\n        target=\"_blank\"\n        rel=\"noopener noreferrer\"\n      >\n        {ethers.utils.getAddress(address)}\n      </a>\n      {ERC20 ? <button onClick={addToMetaMask}>Add to MetaMask</button> : null}\n    </span>\n  );\n}\n\n/**\n * Returns token logo component\n * @param {string} name of token\n * @param {string} imageSrc of token image\n * @returns {ReactElement}\n */\nfunction TokenLogo({\n  name,\n  imageSrc,\n}: {\n  name: string;\n  imageSrc: string;\n}): ReactElement {\n  return (\n    <div className={styles.token}>\n      <img src={imageSrc} alt={`${name}`} />\n      <span>{name}</span>\n    </div>\n  );\n}\n\nexport async function getServerSideProps(context: any) {\n  // Collect session\n  const session: any = await getSession(context);\n\n  return {\n    props: {\n      session,\n      // If session exists, collect claim status, else return false\n      claimed: session ? await hasClaimed(session.twitter_id) : false,\n    },\n  };\n}\n"
  },
  {
    "path": "frontend/styles/Home.module.scss",
    "content": "// Top CTA\n.home__cta {\n  text-align: center;\n\n  > div {\n    margin-top: 30px;\n    margin-bottom: 10px;\n\n    > a:hover {\n      opacity: 0.8;\n    }\n  }\n\n  > h1 {\n    font-size: 2.5rem;\n    color: #19232d;\n    margin: 10px 0px;\n  }\n\n  > span {\n    display: block;\n    font-size: 18px;\n    line-height: 28px;\n    max-width: 500px;\n    margin: 0px auto;\n    color: #19232d;\n  }\n}\n\n// Add network button\n.addNetworkButton {\n  padding: 0px;\n  background-color: transparent;\n  border: none;\n  margin-left: 2px;\n  font-weight: 500;\n  font-size: 16px;\n  text-decoration: underline;\n  cursor: pointer;\n\n  &:hover {\n    opacity: 0.8;\n  }\n}\n\n// Individual address containers\n.address {\n  > a {\n    padding: 0.2em 0.4em;\n    font-size: 85%;\n    text-decoration: none;\n    border-radius: 6px;\n    color: inherit;\n    background-color: rgba(175, 184, 193, 0.2);\n\n    &:hover {\n      opacity: 0.8;\n    }\n  }\n\n  > button {\n    padding: 0.2em 0.4em;\n    margin-left: 10px;\n    background-color: rgba(175, 184, 193, 0.2);\n    border: none;\n    border-radius: 6px;\n    color: inherit;\n    cursor: pointer;\n\n    &:hover {\n      opacity: 0.8;\n    }\n  }\n}\n\n// Individual token containers\n.token {\n  background-color: white;\n  padding: 0px 5px;\n  border: 1px solid rgb(236, 237, 239);\n  border-radius: 4px;\n  display: inline-flex;\n  vertical-align: middle;\n  align-items: center;\n\n  img {\n    height: 18px;\n    padding-right: 5px;\n  }\n\n  span {\n    font-size: 16px;\n    font-weight: 500;\n  }\n}\n\n// Claim card\n.home__card {\n  margin-top: 40px;\n  background-color: white;\n  border: 1px solid rgb(236, 237, 239);\n  border-radius: 5px;\n  box-shadow: 0px 6px 10px 1px #eeeeee;\n\n  .home__card_title {\n    border-bottom: 2px solid rgb(237, 238, 240);\n    padding: 15px 20px;\n\n    > h3 {\n      margin: 0px;\n      font-weight: 500;\n      font-size: 18px;\n      transform: translateY(1px);\n    }\n  }\n\n  .home__card_content {\n    padding: 20px;\n\n    > p {\n      line-height: 24px;\n    }\n  }\n}\n\n.home__card_content_section {\n  padding: 20px;\n  border-bottom: 1px solid rgb(237, 238, 240);\n\n  > h4 {\n    font-weight: 500;\n    font-size: 16px;\n    margin: 0px;\n\n    a {\n      text-decoration: none;\n      color: inherit;\n      text-decoration: underline;\n\n      &:hover {\n        opacity: 0.8;\n      }\n    }\n  }\n\n  .home__card_content_section_lh {\n    line-height: 24px;\n  }\n\n  > span {\n    display: block;\n    color: #6e7a85;\n    font-size: 14px;\n    margin: 2px 0px;\n  }\n\n  > p {\n    color: #19232d;\n    margin: 10px 0px;\n\n    &:nth-last-of-type(1) {\n      margin-bottom: 0px;\n    }\n  }\n}\n\n// Depleted section\n.home__card_depleted {\n  color: #e74747;\n}\n\n// Twitter sign-out button\n.content__twitter {\n  margin-top: 20px;\n  width: 100%;\n  display: flex;\n  justify-content: center;\n\n  > button {\n    background-color: transparent;\n    border: none;\n    cursor: pointer;\n    text-decoration: underline;\n    color: rgb(114, 114, 114);\n  }\n}\n\n// Unauthenticated claim status\n.content__unauthenticated {\n  p {\n    margin: 0px;\n\n    a {\n      color: inherit;\n    }\n  }\n}\n\n// Authenticated claim status\n.content__authenticated {\n  > button {\n    display: inline-block;\n    margin: 0px auto;\n  }\n\n  input {\n    display: block;\n    width: calc(100% - 14px);\n    border: 2px solid rgb(234, 234, 234);\n    font-size: 16px;\n    padding: 10px 5px;\n    border-radius: 5px;\n    margin: 20px 0px 10px 0px;\n\n    &:disabled {\n      cursor: not-allowed;\n    }\n  }\n}\n\n// Authenticated claim status — already claimed\n.content__claimed {\n  p {\n    margin: 0px;\n  }\n\n  > button {\n    margin-top: 0px !important;\n  }\n}\n\n// Authenticated claim status — unclaimed\n.content__unclaimed {\n  p {\n    line-height: 24px;\n\n    &:nth-of-type(1) {\n      margin-top: 0px;\n    }\n\n    &:nth-last-of-type(1) {\n      margin-bottom: 0px;\n    }\n  }\n\n  > button {\n    margin-top: 0px !important;\n  }\n}\n\n// Authenticated claim status — unclaimed — other networks\n.content__unclaimed_others {\n  display: flex;\n  padding: 10px 0px 20px 0px;\n  align-items: center;\n\n  > input {\n    width: auto;\n    margin: 0px;\n    transform: scale(1.3);\n    margin-left: 5px;\n    cursor: pointer;\n  }\n\n  > label {\n    padding-left: 10px;\n    display: inline-block;\n    font-size: 14px;\n    color: rgb(114, 114, 114);\n  }\n}\n\n// Contract balance status\n.home__balances {\n  text-align: center;\n\n  > p {\n    font-size: 14px;\n    color: rgb(114, 114, 114);\n  }\n}\n\n// Main blue button\n.button__main {\n  width: 100%;\n  margin-top: 20px;\n  background-color: rgb(25, 35, 45);\n  color: white;\n  padding: 10px 0px;\n  border-radius: 5px;\n  border: none;\n  font-size: 15px;\n  cursor: pointer;\n  transition: 100ms ease-in-out;\n\n  &:hover {\n    opacity: 0.9;\n  }\n\n  &:disabled {\n    background-color: rgb(220, 230, 240);\n    color: #19232d;\n    cursor: not-allowed;\n  }\n\n  &:hover:disabled {\n    opacity: 1;\n    cursor: not-allowed;\n  }\n}\n\n// Responsive\n@media screen and (max-width: 750px) {\n  // Top CTA\n  .home__cta {\n    > h1 {\n      font-size: 2.3rem;\n    }\n\n    > span {\n      font-size: 17px;\n    }\n  }\n\n  // Card\n  .home__card {\n    p {\n      line-height: 24px;\n    }\n  }\n\n  // Individual address containers\n  .address {\n    display: block;\n    margin-top: 5px;\n    padding-bottom: 10px;\n\n    > a {\n      display: block;\n      width: calc(100% - 0.8em);\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis;\n      text-align: center;\n    }\n\n    > button {\n      display: block;\n      padding: 0.4em;\n      margin-left: 0px;\n      margin-top: 5px;\n      width: 100%;\n    }\n  }\n}\n"
  },
  {
    "path": "frontend/styles/Layout.module.scss",
    "content": "// Main container\n.layout {\n  max-width: 800px;\n  padding: 20px;\n  margin: 0px auto;\n  min-height: calc(100vh - 40px);\n\n  display: flex;\n  flex-direction: column;\n\n  > div {\n    width: 100%;\n  }\n}\n\n// Footer\n.layout__footer {\n  margin-top: auto;\n  text-align: center;\n  padding: 30px 0px;\n\n  > p {\n    font-size: 12px;\n    line-height: 18px;\n    color: rgb(93, 93, 93);\n  }\n}\n"
  },
  {
    "path": "frontend/styles/global.scss",
    "content": "// Background colors\n$bg-color: rgb(246, 246, 247);\n$bg-dot-color: rgb(203, 203, 205);\n\n// Background dimensions\n$dot-size: 2px;\n$dot-space: 30px;\n\nhtml {\n  // Scroll background\n  background-color: $bg-color;\n}\n\nbody {\n  // Fix spacing\n  margin: 0px;\n  padding: 0px;\n\n  // Font\n  font-feature-settings: \"ss01\";\n  text-rendering: optimizeLegibility;\n  font-family: \"Inter\", sans-serif;\n\n  // Background\n  min-height: 100vh;\n  min-width: 100vw;\n  background-color: rgb(246, 246, 247);\n  background: linear-gradient(\n        90deg,\n        $bg-color ($dot-space - $dot-size),\n        transparent 1%\n      )\n      center,\n    linear-gradient($bg-color ($dot-space - $dot-size), transparent 1%) center,\n    $bg-dot-color;\n  background-size: $dot-space $dot-space;\n}\n\nbutton,\ninput {\n  // Font override\n  font-feature-settings: \"ss01\";\n  text-rendering: optimizeLegibility;\n  font-family: \"Inter\", sans-serif;\n}\n"
  },
  {
    "path": "frontend/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"es5\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"allowJs\": true,\n    \"skipLibCheck\": true,\n    \"strict\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"noEmit\": true,\n    \"esModuleInterop\": true,\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"jsx\": \"preserve\",\n    \"baseUrl\": \"./\",\n    \"incremental\": true\n  },\n  \"include\": [\"next-env.d.ts\", \"**/*.ts\", \"**/*.tsx\"],\n  \"exclude\": [\"node_modules\"]\n}\n"
  },
  {
    "path": "frontend/utils/addresses.ts",
    "content": "// Export faucet addresses\nexport const ADDRESSES = [\n  {\n    network: \"ropsten\",\n    depleted: true,\n    disclaimer: \"Faucet drips 1 ETH, 1 wETH, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"ropsten.etherscan.io\",\n    formattedName: \"Ropsten\",\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xc778417e063141139fce010982780140aa0cd5ab\",\n    },\n  },\n  {\n    network: \"kovan\",\n    disclaimer: \"Faucet drips 1 ETH, 1 wETH, 500 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"kovan.etherscan.io\",\n    formattedName: \"Kovan\",\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xd0a1e359811322d97991e03f863a0c30c2cf029c\",\n      DAI: \"0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa\",\n    },\n  },\n  {\n    network: \"rinkeby\",\n    disclaimer: \"Faucet drips 0.5 ETH, 0.5 wETH, 50 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"rinkeby.etherscan.io\",\n    formattedName: \"Rinkeby\",\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xc778417E063141139Fce010982780140Aa0cD5Ab\",\n      DAI: \"0x6A9865aDE2B6207dAAC49f8bCba9705dEB0B0e6D\",\n    },\n  },\n  {\n    network: \"goerli\",\n    disclaimer: \"Faucet drips 1 ETH, 1 wETH, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"goerli.etherscan.io\",\n    formattedName: \"Görli\",\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6\",\n    },\n  },\n  {\n    network: \"kovan-optimistic\",\n    disclaimer: \"Faucet drips 1 ETH, 1 wETH, 500 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"kovan-optimistic.etherscan.io\",\n    formattedName: \"Optimistic Kovan\",\n    connectionDetails:\n      \"https://community.optimism.io/docs/useful-tools/networks/#optimism-kovan-testnet\",\n    autoconnect: {\n      chainId: \"0x45\",\n      chainName: \"Optimistic Kovan\",\n      nativeCurrency: {\n        name: \"Ethereum\",\n        symbol: \"ETH\",\n        decimals: 18,\n      },\n      rpcUrls: [\"https://kovan.optimism.io\"],\n      blockExplorerUrls: [\"https://kovan-optimistic.etherscan.io/\"],\n    },\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xbc6f6b680bc61e30db47721c6d1c5cde19c1300d\",\n      DAI: \"0xda10009cbd5d07dd0cecc66161fc93d7c9000da1\",\n    },\n  },\n  {\n    network: \"mumbai\",\n    disclaimer:\n      \"Faucet drips 0.1 MATIC, 0.1 wMATIC, 500 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"mumbai.polygonscan.com\",\n    formattedName: \"Polygon Mumbai\",\n    connectionDetails:\n      \"https://blog.pods.finance/guide-connecting-mumbai-testnet-to-your-metamask-87978071aca8\",\n    autoconnect: {\n      chainId: \"0x13881\",\n      chainName: \"Polygon Mumbai\",\n      nativeCurrency: {\n        name: \"MATIC\",\n        symbol: \"MATIC\",\n        decimals: 18,\n      },\n      rpcUrls: [\"https://rpc-mumbai.maticvigil.com/\"],\n      blockExplorerUrls: [\"https://mumbai.polygonscan.com/\"],\n    },\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0x9c3c9283d3e44854697cd22d3faa240cfb032889\",\n      DAI: \"0x001b3b4d0f3714ca98ba10f6042daebf0b1b7b6f\",\n    },\n  },\n  {\n    network: \"arb-rinkeby\",\n    disclaimer: \"Faucet drips 0.5 ETH, 0.5 wETH, 50 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"testnet.arbiscan.io\",\n    formattedName: \"Arbitrum Rinkeby\",\n    connectionDetails: \"https://developer.offchainlabs.com/docs/public_testnet\",\n    autoconnect: {\n      chainId: \"0x66eeb\",\n      chainName: \"Arbitrum Testnet\",\n      nativeCurrency: {\n        name: \"Ethereum\",\n        symbol: \"ETH\",\n        decimals: 18,\n      },\n      rpcUrls: [\"https://rinkeby.arbitrum.io/rpc\"],\n      blockExplorerUrls: [\"https://testnet.arbiscan.io/\"],\n    },\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xebbc3452cc911591e4f18f3b36727df45d6bd1f9\",\n      DAI: \"0x2f3c1b6a51a469051a22986aa0ddf98466cc8d3c\",\n    },\n  },\n  {\n    network: \"avalanche-fuji\",\n    depleted: true,\n    disclaimer:\n      \"Faucet drips 0.1 AVAX, 0.1 wAVAX, 500 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"testnet.snowtrace.io\",\n    formattedName: \"Avalanche Fuji\",\n    connectionDetails:\n      \"https://docs.avax.network/build/tutorials/smart-contracts/deploy-a-smart-contract-on-avalanche-using-remix-and-metamask#step-1-setting-up-metamask\",\n    autoconnect: {\n      chainId: \"0xa869\",\n      chainName: \"Avalanche FUJI C-Chain\",\n      nativeCurrency: {\n        name: \"Avalanche\",\n        symbol: \"AVAX\",\n        decimals: 18,\n      },\n      rpcUrls: [\"https://api.avax-test.network/ext/bc/C/rpc\"],\n      blockExplorerUrls: [\"https://testnet.snowtrace.io/\"],\n    },\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b\",\n      wETH: \"0xd00ae08403b9bbb9124bb305c09058e32c39a48c\",\n      DAI: \"0xebbc3452cc911591e4f18f3b36727df45d6bd1f9\",\n    },\n  },\n  {\n    network: \"moonbase-alpha\",\n    depleted: true,\n    disclaimer: \"Faucet drips 1 DEV, 1 wDEV, 500 DAI, and 5 NFTs (ERC721).\",\n    etherscanPrefix: \"moonbase.moonscan.io\",\n    formattedName: \"Moonbase Alpha\",\n    connectionDetails:\n      \"https://docs.moonbeam.network/learn/platform/networks/moonbase/\",\n    autoconnect: {\n      chainId: \"0x507\",\n      chainName: \"Moonbase Alpha\",\n      nativeCurrency: {\n        name: \"Dev\",\n        symbol: \"DEV\",\n        decimals: 18,\n      },\n      rpcUrls: [\"https://rpc.api.moonbase.moonbeam.network\"],\n      blockExplorerUrls: [\"https://moonbase.moonscan.io/\"],\n    },\n    addresses: {\n      NFTs: \"0xf5de760f2e916647fd766B4AD9E85ff943cE3A2b\",\n      wETH: \"0xD909178CC99d318e4D46e7E66a972955859670E1\",\n      DAI: \"0x4C153BFaD26628BdbaFECBCD160A0790b1b8F212\",\n    },\n  },\n];\n\n/**\n * Export details about networks\n */\nexport function getAddressDetails() {\n  // Get active networks\n  const activeNetworks: string[] = ADDRESSES.filter(\n    // Filter for non-depleted\n    ({ depleted }) => !depleted\n    // Collect just formatted name\n  ).map(({ formattedName }) => formattedName);\n  // Get number of active networks\n  const networkCount: number = activeNetworks.length;\n\n  // Sort addresses (depleted last)\n  const sortedAddresses = ADDRESSES.sort((a, b) => {\n    const first = a.depleted ?? false;\n    const second = b.depleted ?? false;\n    return Number(first) - Number(second);\n  });\n\n  // Return details\n  return { networkCount, sortedAddresses };\n}\n"
  },
  {
    "path": "frontend/utils/dates.ts",
    "content": "/**\n * Parse Twitter date as JS Date\n * https://stackoverflow.com/questions/13132964/how-to-format-twitter-facebook-feed-date-with-javascript\n * @param {string} dateString from Twitter\n * @returns {Date} parsed\n */\nexport default function parseTwitterDate(dateString: string): Date {\n  const b: string[] = dateString.split(/[: ]/g);\n  const m: Record<string, number> = {\n    jan: 0,\n    feb: 1,\n    mar: 2,\n    apr: 3,\n    may: 4,\n    jun: 5,\n    jul: 6,\n    aug: 7,\n    sep: 8,\n    oct: 9,\n    nov: 10,\n    dec: 11,\n  };\n\n  return new Date(\n    Date.UTC(\n      Number(b[7]),\n      m[b[1].toLowerCase()],\n      Number(b[2]),\n      Number(b[3]),\n      Number(b[4]),\n      Number(b[5])\n    )\n  );\n}\n"
  }
]