├── .github └── workflows │ └── tests.yaml ├── .gitignore ├── .gitmodules ├── LICENSE ├── Makefile ├── README.md ├── shell.nix └── src ├── ProxyRegistry.sol └── ProxyRegistry.t.sol /.github/workflows/tests.yaml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | jobs: 4 | tests: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Checkout repository and submodules 8 | uses: actions/checkout@v2 9 | with: 10 | submodules: recursive 11 | 12 | - name: Install nix 2.3.6 13 | uses: cachix/install-nix-action@v13 14 | with: 15 | install_url: https://releases.nixos.org/nix/nix-2.3.6/install 16 | nix_path: nixpkgs=channel:nixos-unstable 17 | 18 | - name: Use maker cachix 19 | uses: cachix/cachix-action@v10 20 | with: 21 | name: maker 22 | 23 | - name: Run tests 24 | run: nix-shell --pure --run 'dapp test' 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /out 2 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "lib/ds-test"] 2 | path = lib/ds-test 3 | url = https://github.com/dapphub/ds-test 4 | [submodule "lib/ds-proxy"] 5 | path = lib/ds-proxy 6 | url = https://github.com/dapphub/ds-proxy 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 2007 3 | 4 | Copyright (C) 2018 Maker Ecosystem Growth Holdings, INC. 5 | 6 | Preamble 7 | 8 | The GNU Affero General Public License is a free, copyleft license for 9 | software and other kinds of works, specifically designed to ensure 10 | cooperation with the community in the case of network server software. 11 | 12 | The licenses for most software and other practical works are designed 13 | to take away your freedom to share and change the works. By contrast, 14 | our General Public Licenses are intended to guarantee your freedom to 15 | share and change all versions of a program--to make sure it remains free 16 | software for all its users. 17 | 18 | When we speak of free software, we are referring to freedom, not 19 | price. Our General Public Licenses are designed to make sure that you 20 | have the freedom to distribute copies of free software (and charge for 21 | them if you wish), that you receive source code or can get it if you 22 | want it, that you can change the software or use pieces of it in new 23 | free programs, and that you know you can do these things. 24 | 25 | Developers that use our General Public Licenses protect your rights 26 | with two steps: (1) assert copyright on the software, and (2) offer 27 | you this License which gives you legal permission to copy, distribute 28 | and/or modify the software. 29 | 30 | A secondary benefit of defending all users' freedom is that 31 | improvements made in alternate versions of the program, if they 32 | receive widespread use, become available for other developers to 33 | incorporate. Many developers of free software are heartened and 34 | encouraged by the resulting cooperation. However, in the case of 35 | software used on network servers, this result may fail to come about. 36 | The GNU General Public License permits making a modified version and 37 | letting the public access it on a server without ever releasing its 38 | source code to the public. 39 | 40 | The GNU Affero General Public License is designed specifically to 41 | ensure that, in such cases, the modified source code becomes available 42 | to the community. It requires the operator of a network server to 43 | provide the source code of the modified version running there to the 44 | users of that server. Therefore, public use of a modified version, on 45 | a publicly accessible server, gives the public access to the source 46 | code of the modified version. 47 | 48 | An older license, called the Affero General Public License and 49 | published by Affero, was designed to accomplish similar goals. This is 50 | a different license, not a version of the Affero GPL, but Affero has 51 | released a new version of the Affero GPL which permits relicensing under 52 | this license. 53 | 54 | The precise terms and conditions for copying, distribution and 55 | modification follow. 56 | 57 | TERMS AND CONDITIONS 58 | 59 | 0. Definitions. 60 | 61 | "This License" refers to version 3 of the GNU Affero General Public License. 62 | 63 | "Copyright" also means copyright-like laws that apply to other kinds of 64 | works, such as semiconductor masks. 65 | 66 | "The Program" refers to any copyrightable work licensed under this 67 | License. Each licensee is addressed as "you". "Licensees" and 68 | "recipients" may be individuals or organizations. 69 | 70 | To "modify" a work means to copy from or adapt all or part of the work 71 | in a fashion requiring copyright permission, other than the making of an 72 | exact copy. The resulting work is called a "modified version" of the 73 | earlier work or a work "based on" the earlier work. 74 | 75 | A "covered work" means either the unmodified Program or a work based 76 | on the Program. 77 | 78 | To "propagate" a work means to do anything with it that, without 79 | permission, would make you directly or secondarily liable for 80 | infringement under applicable copyright law, except executing it on a 81 | computer or modifying a private copy. Propagation includes copying, 82 | distribution (with or without modification), making available to the 83 | public, and in some countries other activities as well. 84 | 85 | To "convey" a work means any kind of propagation that enables other 86 | parties to make or receive copies. Mere interaction with a user through 87 | a computer network, with no transfer of a copy, is not conveying. 88 | 89 | An interactive user interface displays "Appropriate Legal Notices" 90 | to the extent that it includes a convenient and prominently visible 91 | feature that (1) displays an appropriate copyright notice, and (2) 92 | tells the user that there is no warranty for the work (except to the 93 | extent that warranties are provided), that licensees may convey the 94 | work under this License, and how to view a copy of this License. If 95 | the interface presents a list of user commands or options, such as a 96 | menu, a prominent item in the list meets this criterion. 97 | 98 | 1. Source Code. 99 | 100 | The "source code" for a work means the preferred form of the work 101 | for making modifications to it. "Object code" means any non-source 102 | form of a work. 103 | 104 | A "Standard Interface" means an interface that either is an official 105 | standard defined by a recognized standards body, or, in the case of 106 | interfaces specified for a particular programming language, one that 107 | is widely used among developers working in that language. 108 | 109 | The "System Libraries" of an executable work include anything, other 110 | than the work as a whole, that (a) is included in the normal form of 111 | packaging a Major Component, but which is not part of that Major 112 | Component, and (b) serves only to enable use of the work with that 113 | Major Component, or to implement a Standard Interface for which an 114 | implementation is available to the public in source code form. A 115 | "Major Component", in this context, means a major essential component 116 | (kernel, window system, and so on) of the specific operating system 117 | (if any) on which the executable work runs, or a compiler used to 118 | produce the work, or an object code interpreter used to run it. 119 | 120 | The "Corresponding Source" for a work in object code form means all 121 | the source code needed to generate, install, and (for an executable 122 | work) run the object code and to modify the work, including scripts to 123 | control those activities. However, it does not include the work's 124 | System Libraries, or general-purpose tools or generally available free 125 | programs which are used unmodified in performing those activities but 126 | which are not part of the work. For example, Corresponding Source 127 | includes interface definition files associated with source files for 128 | the work, and the source code for shared libraries and dynamically 129 | linked subprograms that the work is specifically designed to require, 130 | such as by intimate data communication or control flow between those 131 | subprograms and other parts of the work. 132 | 133 | The Corresponding Source need not include anything that users 134 | can regenerate automatically from other parts of the Corresponding 135 | Source. 136 | 137 | The Corresponding Source for a work in source code form is that 138 | same work. 139 | 140 | 2. Basic Permissions. 141 | 142 | All rights granted under this License are granted for the term of 143 | copyright on the Program, and are irrevocable provided the stated 144 | conditions are met. This License explicitly affirms your unlimited 145 | permission to run the unmodified Program. The output from running a 146 | covered work is covered by this License only if the output, given its 147 | content, constitutes a covered work. This License acknowledges your 148 | rights of fair use or other equivalent, as provided by copyright law. 149 | 150 | You may make, run and propagate covered works that you do not 151 | convey, without conditions so long as your license otherwise remains 152 | in force. You may convey covered works to others for the sole purpose 153 | of having them make modifications exclusively for you, or provide you 154 | with facilities for running those works, provided that you comply with 155 | the terms of this License in conveying all material for which you do 156 | not control copyright. Those thus making or running the covered works 157 | for you must do so exclusively on your behalf, under your direction 158 | and control, on terms that prohibit them from making any copies of 159 | your copyrighted material outside their relationship with you. 160 | 161 | Conveying under any other circumstances is permitted solely under 162 | the conditions stated below. Sublicensing is not allowed; section 10 163 | makes it unnecessary. 164 | 165 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 166 | 167 | No covered work shall be deemed part of an effective technological 168 | measure under any applicable law fulfilling obligations under article 169 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 170 | similar laws prohibiting or restricting circumvention of such 171 | measures. 172 | 173 | When you convey a covered work, you waive any legal power to forbid 174 | circumvention of technological measures to the extent such circumvention 175 | is effected by exercising rights under this License with respect to 176 | the covered work, and you disclaim any intention to limit operation or 177 | modification of the work as a means of enforcing, against the work's 178 | users, your or third parties' legal rights to forbid circumvention of 179 | technological measures. 180 | 181 | 4. Conveying Verbatim Copies. 182 | 183 | You may convey verbatim copies of the Program's source code as you 184 | receive it, in any medium, provided that you conspicuously and 185 | appropriately publish on each copy an appropriate copyright notice; 186 | keep intact all notices stating that this License and any 187 | non-permissive terms added in accord with section 7 apply to the code; 188 | keep intact all notices of the absence of any warranty; and give all 189 | recipients a copy of this License along with the Program. 190 | 191 | You may charge any price or no price for each copy that you convey, 192 | and you may offer support or warranty protection for a fee. 193 | 194 | 5. Conveying Modified Source Versions. 195 | 196 | You may convey a work based on the Program, or the modifications to 197 | produce it from the Program, in the form of source code under the 198 | terms of section 4, provided that you also meet all of these conditions: 199 | 200 | a) The work must carry prominent notices stating that you modified 201 | it, and giving a relevant date. 202 | 203 | b) The work must carry prominent notices stating that it is 204 | released under this License and any conditions added under section 205 | 7. This requirement modifies the requirement in section 4 to 206 | "keep intact all notices". 207 | 208 | c) You must license the entire work, as a whole, under this 209 | License to anyone who comes into possession of a copy. This 210 | License will therefore apply, along with any applicable section 7 211 | additional terms, to the whole of the work, and all its parts, 212 | regardless of how they are packaged. This License gives no 213 | permission to license the work in any other way, but it does not 214 | invalidate such permission if you have separately received it. 215 | 216 | d) If the work has interactive user interfaces, each must display 217 | Appropriate Legal Notices; however, if the Program has interactive 218 | interfaces that do not display Appropriate Legal Notices, your 219 | work need not make them do so. 220 | 221 | A compilation of a covered work with other separate and independent 222 | works, which are not by their nature extensions of the covered work, 223 | and which are not combined with it such as to form a larger program, 224 | in or on a volume of a storage or distribution medium, is called an 225 | "aggregate" if the compilation and its resulting copyright are not 226 | used to limit the access or legal rights of the compilation's users 227 | beyond what the individual works permit. Inclusion of a covered work 228 | in an aggregate does not cause this License to apply to the other 229 | parts of the aggregate. 230 | 231 | 6. Conveying Non-Source Forms. 232 | 233 | You may convey a covered work in object code form under the terms 234 | of sections 4 and 5, provided that you also convey the 235 | machine-readable Corresponding Source under the terms of this License, 236 | in one of these ways: 237 | 238 | a) Convey the object code in, or embodied in, a physical product 239 | (including a physical distribution medium), accompanied by the 240 | Corresponding Source fixed on a durable physical medium 241 | customarily used for software interchange. 242 | 243 | b) Convey the object code in, or embodied in, a physical product 244 | (including a physical distribution medium), accompanied by a 245 | written offer, valid for at least three years and valid for as 246 | long as you offer spare parts or customer support for that product 247 | model, to give anyone who possesses the object code either (1) a 248 | copy of the Corresponding Source for all the software in the 249 | product that is covered by this License, on a durable physical 250 | medium customarily used for software interchange, for a price no 251 | more than your reasonable cost of physically performing this 252 | conveying of source, or (2) access to copy the 253 | Corresponding Source from a network server at no charge. 254 | 255 | c) Convey individual copies of the object code with a copy of the 256 | written offer to provide the Corresponding Source. This 257 | alternative is allowed only occasionally and noncommercially, and 258 | only if you received the object code with such an offer, in accord 259 | with subsection 6b. 260 | 261 | d) Convey the object code by offering access from a designated 262 | place (gratis or for a charge), and offer equivalent access to the 263 | Corresponding Source in the same way through the same place at no 264 | further charge. You need not require recipients to copy the 265 | Corresponding Source along with the object code. If the place to 266 | copy the object code is a network server, the Corresponding Source 267 | may be on a different server (operated by you or a third party) 268 | that supports equivalent copying facilities, provided you maintain 269 | clear directions next to the object code saying where to find the 270 | Corresponding Source. Regardless of what server hosts the 271 | Corresponding Source, you remain obligated to ensure that it is 272 | available for as long as needed to satisfy these requirements. 273 | 274 | e) Convey the object code using peer-to-peer transmission, provided 275 | you inform other peers where the object code and Corresponding 276 | Source of the work are being offered to the general public at no 277 | charge under subsection 6d. 278 | 279 | A separable portion of the object code, whose source code is excluded 280 | from the Corresponding Source as a System Library, need not be 281 | included in conveying the object code work. 282 | 283 | A "User Product" is either (1) a "consumer product", which means any 284 | tangible personal property which is normally used for personal, family, 285 | or household purposes, or (2) anything designed or sold for incorporation 286 | into a dwelling. In determining whether a product is a consumer product, 287 | doubtful cases shall be resolved in favor of coverage. For a particular 288 | product received by a particular user, "normally used" refers to a 289 | typical or common use of that class of product, regardless of the status 290 | of the particular user or of the way in which the particular user 291 | actually uses, or expects or is expected to use, the product. A product 292 | is a consumer product regardless of whether the product has substantial 293 | commercial, industrial or non-consumer uses, unless such uses represent 294 | the only significant mode of use of the product. 295 | 296 | "Installation Information" for a User Product means any methods, 297 | procedures, authorization keys, or other information required to install 298 | and execute modified versions of a covered work in that User Product from 299 | a modified version of its Corresponding Source. The information must 300 | suffice to ensure that the continued functioning of the modified object 301 | code is in no case prevented or interfered with solely because 302 | modification has been made. 303 | 304 | If you convey an object code work under this section in, or with, or 305 | specifically for use in, a User Product, and the conveying occurs as 306 | part of a transaction in which the right of possession and use of the 307 | User Product is transferred to the recipient in perpetuity or for a 308 | fixed term (regardless of how the transaction is characterized), the 309 | Corresponding Source conveyed under this section must be accompanied 310 | by the Installation Information. But this requirement does not apply 311 | if neither you nor any third party retains the ability to install 312 | modified object code on the User Product (for example, the work has 313 | been installed in ROM). 314 | 315 | The requirement to provide Installation Information does not include a 316 | requirement to continue to provide support service, warranty, or updates 317 | for a work that has been modified or installed by the recipient, or for 318 | the User Product in which it has been modified or installed. Access to a 319 | network may be denied when the modification itself materially and 320 | adversely affects the operation of the network or violates the rules and 321 | protocols for communication across the network. 322 | 323 | Corresponding Source conveyed, and Installation Information provided, 324 | in accord with this section must be in a format that is publicly 325 | documented (and with an implementation available to the public in 326 | source code form), and must require no special password or key for 327 | unpacking, reading or copying. 328 | 329 | 7. Additional Terms. 330 | 331 | "Additional permissions" are terms that supplement the terms of this 332 | License by making exceptions from one or more of its conditions. 333 | Additional permissions that are applicable to the entire Program shall 334 | be treated as though they were included in this License, to the extent 335 | that they are valid under applicable law. If additional permissions 336 | apply only to part of the Program, that part may be used separately 337 | under those permissions, but the entire Program remains governed by 338 | this License without regard to the additional permissions. 339 | 340 | When you convey a copy of a covered work, you may at your option 341 | remove any additional permissions from that copy, or from any part of 342 | it. (Additional permissions may be written to require their own 343 | removal in certain cases when you modify the work.) You may place 344 | additional permissions on material, added by you to a covered work, 345 | for which you have or can give appropriate copyright permission. 346 | 347 | Notwithstanding any other provision of this License, for material you 348 | add to a covered work, you may (if authorized by the copyright holders of 349 | that material) supplement the terms of this License with terms: 350 | 351 | a) Disclaiming warranty or limiting liability differently from the 352 | terms of sections 15 and 16 of this License; or 353 | 354 | b) Requiring preservation of specified reasonable legal notices or 355 | author attributions in that material or in the Appropriate Legal 356 | Notices displayed by works containing it; or 357 | 358 | c) Prohibiting misrepresentation of the origin of that material, or 359 | requiring that modified versions of such material be marked in 360 | reasonable ways as different from the original version; or 361 | 362 | d) Limiting the use for publicity purposes of names of licensors or 363 | authors of the material; or 364 | 365 | e) Declining to grant rights under trademark law for use of some 366 | trade names, trademarks, or service marks; or 367 | 368 | f) Requiring indemnification of licensors and authors of that 369 | material by anyone who conveys the material (or modified versions of 370 | it) with contractual assumptions of liability to the recipient, for 371 | any liability that these contractual assumptions directly impose on 372 | those licensors and authors. 373 | 374 | All other non-permissive additional terms are considered "further 375 | restrictions" within the meaning of section 10. If the Program as you 376 | received it, or any part of it, contains a notice stating that it is 377 | governed by this License along with a term that is a further 378 | restriction, you may remove that term. If a license document contains 379 | a further restriction but permits relicensing or conveying under this 380 | License, you may add to a covered work material governed by the terms 381 | of that license document, provided that the further restriction does 382 | not survive such relicensing or conveying. 383 | 384 | If you add terms to a covered work in accord with this section, you 385 | must place, in the relevant source files, a statement of the 386 | additional terms that apply to those files, or a notice indicating 387 | where to find the applicable terms. 388 | 389 | Additional terms, permissive or non-permissive, may be stated in the 390 | form of a separately written license, or stated as exceptions; 391 | the above requirements apply either way. 392 | 393 | 8. Termination. 394 | 395 | You may not propagate or modify a covered work except as expressly 396 | provided under this License. Any attempt otherwise to propagate or 397 | modify it is void, and will automatically terminate your rights under 398 | this License (including any patent licenses granted under the third 399 | paragraph of section 11). 400 | 401 | However, if you cease all violation of this License, then your 402 | license from a particular copyright holder is reinstated (a) 403 | provisionally, unless and until the copyright holder explicitly and 404 | finally terminates your license, and (b) permanently, if the copyright 405 | holder fails to notify you of the violation by some reasonable means 406 | prior to 60 days after the cessation. 407 | 408 | Moreover, your license from a particular copyright holder is 409 | reinstated permanently if the copyright holder notifies you of the 410 | violation by some reasonable means, this is the first time you have 411 | received notice of violation of this License (for any work) from that 412 | copyright holder, and you cure the violation prior to 30 days after 413 | your receipt of the notice. 414 | 415 | Termination of your rights under this section does not terminate the 416 | licenses of parties who have received copies or rights from you under 417 | this License. If your rights have been terminated and not permanently 418 | reinstated, you do not qualify to receive new licenses for the same 419 | material under section 10. 420 | 421 | 9. Acceptance Not Required for Having Copies. 422 | 423 | You are not required to accept this License in order to receive or 424 | run a copy of the Program. Ancillary propagation of a covered work 425 | occurring solely as a consequence of using peer-to-peer transmission 426 | to receive a copy likewise does not require acceptance. However, 427 | nothing other than this License grants you permission to propagate or 428 | modify any covered work. These actions infringe copyright if you do 429 | not accept this License. Therefore, by modifying or propagating a 430 | covered work, you indicate your acceptance of this License to do so. 431 | 432 | 10. Automatic Licensing of Downstream Recipients. 433 | 434 | Each time you convey a covered work, the recipient automatically 435 | receives a license from the original licensors, to run, modify and 436 | propagate that work, subject to this License. You are not responsible 437 | for enforcing compliance by third parties with this License. 438 | 439 | An "entity transaction" is a transaction transferring control of an 440 | organization, or substantially all assets of one, or subdividing an 441 | organization, or merging organizations. If propagation of a covered 442 | work results from an entity transaction, each party to that 443 | transaction who receives a copy of the work also receives whatever 444 | licenses to the work the party's predecessor in interest had or could 445 | give under the previous paragraph, plus a right to possession of the 446 | Corresponding Source of the work from the predecessor in interest, if 447 | the predecessor has it or can get it with reasonable efforts. 448 | 449 | You may not impose any further restrictions on the exercise of the 450 | rights granted or affirmed under this License. For example, you may 451 | not impose a license fee, royalty, or other charge for exercise of 452 | rights granted under this License, and you may not initiate litigation 453 | (including a cross-claim or counterclaim in a lawsuit) alleging that 454 | any patent claim is infringed by making, using, selling, offering for 455 | sale, or importing the Program or any portion of it. 456 | 457 | 11. Patents. 458 | 459 | A "contributor" is a copyright holder who authorizes use under this 460 | License of the Program or a work on which the Program is based. The 461 | work thus licensed is called the contributor's "contributor version". 462 | 463 | A contributor's "essential patent claims" are all patent claims 464 | owned or controlled by the contributor, whether already acquired or 465 | hereafter acquired, that would be infringed by some manner, permitted 466 | by this License, of making, using, or selling its contributor version, 467 | but do not include claims that would be infringed only as a 468 | consequence of further modification of the contributor version. For 469 | purposes of this definition, "control" includes the right to grant 470 | patent sublicenses in a manner consistent with the requirements of 471 | this License. 472 | 473 | Each contributor grants you a non-exclusive, worldwide, royalty-free 474 | patent license under the contributor's essential patent claims, to 475 | make, use, sell, offer for sale, import and otherwise run, modify and 476 | propagate the contents of its contributor version. 477 | 478 | In the following three paragraphs, a "patent license" is any express 479 | agreement or commitment, however denominated, not to enforce a patent 480 | (such as an express permission to practice a patent or covenant not to 481 | sue for patent infringement). To "grant" such a patent license to a 482 | party means to make such an agreement or commitment not to enforce a 483 | patent against the party. 484 | 485 | If you convey a covered work, knowingly relying on a patent license, 486 | and the Corresponding Source of the work is not available for anyone 487 | to copy, free of charge and under the terms of this License, through a 488 | publicly available network server or other readily accessible means, 489 | then you must either (1) cause the Corresponding Source to be so 490 | available, or (2) arrange to deprive yourself of the benefit of the 491 | patent license for this particular work, or (3) arrange, in a manner 492 | consistent with the requirements of this License, to extend the patent 493 | license to downstream recipients. "Knowingly relying" means you have 494 | actual knowledge that, but for the patent license, your conveying the 495 | covered work in a country, or your recipient's use of the covered work 496 | in a country, would infringe one or more identifiable patents in that 497 | country that you have reason to believe are valid. 498 | 499 | If, pursuant to or in connection with a single transaction or 500 | arrangement, you convey, or propagate by procuring conveyance of, a 501 | covered work, and grant a patent license to some of the parties 502 | receiving the covered work authorizing them to use, propagate, modify 503 | or convey a specific copy of the covered work, then the patent license 504 | you grant is automatically extended to all recipients of the covered 505 | work and works based on it. 506 | 507 | A patent license is "discriminatory" if it does not include within 508 | the scope of its coverage, prohibits the exercise of, or is 509 | conditioned on the non-exercise of one or more of the rights that are 510 | specifically granted under this License. You may not convey a covered 511 | work if you are a party to an arrangement with a third party that is 512 | in the business of distributing software, under which you make payment 513 | to the third party based on the extent of your activity of conveying 514 | the work, and under which the third party grants, to any of the 515 | parties who would receive the covered work from you, a discriminatory 516 | patent license (a) in connection with copies of the covered work 517 | conveyed by you (or copies made from those copies), or (b) primarily 518 | for and in connection with specific products or compilations that 519 | contain the covered work, unless you entered into that arrangement, 520 | or that patent license was granted, prior to 28 March 2007. 521 | 522 | Nothing in this License shall be construed as excluding or limiting 523 | any implied license or other defenses to infringement that may 524 | otherwise be available to you under applicable patent law. 525 | 526 | 12. No Surrender of Others' Freedom. 527 | 528 | If conditions are imposed on you (whether by court order, agreement or 529 | otherwise) that contradict the conditions of this License, they do not 530 | excuse you from the conditions of this License. If you cannot convey a 531 | covered work so as to satisfy simultaneously your obligations under this 532 | License and any other pertinent obligations, then as a consequence you may 533 | not convey it at all. For example, if you agree to terms that obligate you 534 | to collect a royalty for further conveying from those to whom you convey 535 | the Program, the only way you could satisfy both those terms and this 536 | License would be to refrain entirely from conveying the Program. 537 | 538 | 13. Remote Network Interaction; Use with the GNU General Public License. 539 | 540 | Notwithstanding any other provision of this License, if you modify the 541 | Program, your modified version must prominently offer all users 542 | interacting with it remotely through a computer network (if your version 543 | supports such interaction) an opportunity to receive the Corresponding 544 | Source of your version by providing access to the Corresponding Source 545 | from a network server at no charge, through some standard or customary 546 | means of facilitating copying of software. This Corresponding Source 547 | shall include the Corresponding Source for any work covered by version 3 548 | of the GNU General Public License that is incorporated pursuant to the 549 | following paragraph. 550 | 551 | Notwithstanding any other provision of this License, you have 552 | permission to link or combine any covered work with a work licensed 553 | under version 3 of the GNU General Public License into a single 554 | combined work, and to convey the resulting work. The terms of this 555 | License will continue to apply to the part which is the covered work, 556 | but the work with which it is combined will remain governed by version 557 | 3 of the GNU General Public License. 558 | 559 | 14. Revised Versions of this License. 560 | 561 | The Free Software Foundation may publish revised and/or new versions of 562 | the GNU Affero General Public License from time to time. Such new versions 563 | will be similar in spirit to the present version, but may differ in detail to 564 | address new problems or concerns. 565 | 566 | Each version is given a distinguishing version number. If the 567 | Program specifies that a certain numbered version of the GNU Affero General 568 | Public License "or any later version" applies to it, you have the 569 | option of following the terms and conditions either of that numbered 570 | version or of any later version published by the Free Software 571 | Foundation. If the Program does not specify a version number of the 572 | GNU Affero General Public License, you may choose any version ever published 573 | by the Free Software Foundation. 574 | 575 | If the Program specifies that a proxy can decide which future 576 | versions of the GNU Affero General Public License can be used, that proxy's 577 | public statement of acceptance of a version permanently authorizes you 578 | to choose that version for the Program. 579 | 580 | Later license versions may give you additional or different 581 | permissions. However, no additional obligations are imposed on any 582 | author or copyright holder as a result of your choosing to follow a 583 | later version. 584 | 585 | 15. Disclaimer of Warranty. 586 | 587 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 588 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 589 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 590 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 591 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 592 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 593 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 594 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 595 | 596 | 16. Limitation of Liability. 597 | 598 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 599 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 600 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 601 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 602 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 603 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 604 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 605 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 606 | SUCH DAMAGES. 607 | 608 | 17. Interpretation of Sections 15 and 16. 609 | 610 | If the disclaimer of warranty and limitation of liability provided 611 | above cannot be given local legal effect according to their terms, 612 | reviewing courts shall apply local law that most closely approximates 613 | an absolute waiver of all civil liability in connection with the 614 | Program, unless a warranty or assumption of liability accompanies a 615 | copy of the Program in return for a fee. 616 | 617 | END OF TERMS AND CONDITIONS 618 | 619 | How to Apply These Terms to Your New Programs 620 | 621 | If you develop a new program, and you want it to be of the greatest 622 | possible use to the public, the best way to achieve this is to make it 623 | free software which everyone can redistribute and change under these terms. 624 | 625 | To do so, attach the following notices to the program. It is safest 626 | to attach them to the start of each source file to most effectively 627 | state the exclusion of warranty; and each file should have at least 628 | the "copyright" line and a pointer to where the full notice is found. 629 | 630 | 631 | Copyright (C) 632 | 633 | This program is free software: you can redistribute it and/or modify 634 | it under the terms of the GNU Affero General Public License as published 635 | by the Free Software Foundation, either version 3 of the License, or 636 | (at your option) any later version. 637 | 638 | This program is distributed in the hope that it will be useful, 639 | but WITHOUT ANY WARRANTY; without even the implied warranty of 640 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 641 | GNU Affero General Public License for more details. 642 | 643 | You should have received a copy of the GNU Affero General Public License 644 | along with this program. If not, see . 645 | 646 | Also add information on how to contact you by electronic and paper mail. 647 | 648 | If your software can interact with users remotely through a computer 649 | network, you should also make sure that it provides a way for users to 650 | get its source. For example, if your program is a web application, its 651 | interface could display a "Source" link that leads users to an archive 652 | of the code. There are many ways you could offer source, and different 653 | solutions will be better for different programs; see section 13 for the 654 | specific requirements. 655 | 656 | You should also get your employer (if you work as a programmer) or school, 657 | if any, to sign a "copyright disclaimer" for the program, if necessary. 658 | For more information on this, and how to apply and follow the GNU AGPL, see 659 | . 660 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build :; dapp --use solc:0.5.12 build 2 | clean :; dapp clean 3 | test :; dapp --use solc:0.5.12 test -v ${TEST_FLAGS} 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ProxyRegistry 2 | ![Build Status](https://github.com/makerdao/proxy-registry/actions/workflows/.github/workflows/tests.yaml/badge.svg?branch=master) 3 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | { dappPkgs ? ( 2 | import (fetchTarball "https://github.com/makerdao/makerpkgs/tarball/master") {} 3 | ).dappPkgsVersions.hevm-0_43_1 4 | }: with dappPkgs; 5 | 6 | mkShell { 7 | DAPP_SOLC = solc-static-versions.solc_0_5_12 + "/bin/solc-0.5.12"; 8 | # SOLC_FLAGS = "--optimize --optimize-runs=200"; 9 | buildInputs = [ 10 | dapp 11 | ]; 12 | } 13 | -------------------------------------------------------------------------------- /src/ProxyRegistry.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | 3 | /// ProxyRegistry.sol 4 | 5 | // Copyright (C) 2018-2021 Dai Foundation 6 | 7 | // This program is free software: you can redistribute it and/or modify 8 | // it under the terms of the GNU Affero General Public License as published by 9 | // the Free Software Foundation, either version 3 of the License, or 10 | // (at your option) any later version. 11 | // 12 | // This program is distributed in the hope that it will be useful, 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | // GNU Affero General Public License for more details. 16 | // 17 | // You should have received a copy of the GNU Affero General Public License 18 | // along with this program. If not, see . 19 | 20 | pragma solidity >=0.5.0; 21 | 22 | import 'ds-proxy/proxy.sol'; 23 | 24 | // This Registry deploys new proxy instances through DSProxyFactory.build(address) and keeps a registry of owner => proxy 25 | contract ProxyRegistry { 26 | mapping(address => DSProxy) public proxies; 27 | DSProxyFactory factory; 28 | 29 | constructor(address factory_) public { 30 | factory = DSProxyFactory(factory_); 31 | } 32 | 33 | // deploys a new proxy instance 34 | // sets owner of proxy to caller 35 | function build() public returns (address payable proxy) { 36 | proxy = build(msg.sender); 37 | } 38 | 39 | // deploys a new proxy instance 40 | // sets custom owner of proxy 41 | function build(address owner) public returns (address payable proxy) { 42 | require(proxies[owner] == DSProxy(0) || proxies[owner].owner() != owner); // Not allow new proxy if the user already has one and remains being the owner 43 | proxy = factory.build(owner); 44 | proxies[owner] = DSProxy(proxy); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/ProxyRegistry.t.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: AGPL-3.0-or-later 2 | 3 | pragma solidity >=0.5.0; 4 | 5 | import "ds-test/test.sol"; 6 | 7 | import "./ProxyRegistry.sol"; 8 | 9 | contract ProxyRegistryTest is DSTest { 10 | ProxyRegistry registry; 11 | DSProxyFactory factory; 12 | 13 | function setUp() public { 14 | factory = new DSProxyFactory(); 15 | registry = new ProxyRegistry(address(factory)); 16 | } 17 | 18 | function test_ProxyRegistryBuild() public { 19 | address payable proxyAddr = registry.build(); 20 | assertTrue(proxyAddr != address(0)); 21 | DSProxy proxy = DSProxy(proxyAddr); 22 | 23 | uint codeSize; 24 | assembly { 25 | codeSize := extcodesize(proxyAddr) 26 | } 27 | //verify proxy was deployed successfully 28 | assertTrue(codeSize > 0); 29 | 30 | //verify proxy creation was logged 31 | assertTrue(factory.isProxy(proxyAddr)); 32 | 33 | //verify proxy ownership 34 | assertEq(proxy.owner(), address(this)); 35 | 36 | assertEq(address(registry.proxies(address(this))), proxyAddr); 37 | } 38 | 39 | function test_ProxyRegistryBuildOtherOwner() public { 40 | address owner = address(0x123); 41 | address payable proxyAddr = registry.build(owner); 42 | assertTrue(proxyAddr != address(0)); 43 | DSProxy proxy = DSProxy(proxyAddr); 44 | 45 | uint codeSize; 46 | assembly { 47 | codeSize := extcodesize(proxyAddr) 48 | } 49 | //verify proxy was deployed successfully 50 | assertTrue(codeSize > 0); 51 | 52 | //verify proxy creation was logged 53 | assertTrue(factory.isProxy(proxyAddr)); 54 | 55 | //verify proxy ownership 56 | assertEq(proxy.owner(), owner); 57 | 58 | assertEq(address(registry.proxies(owner)), address(proxy)); 59 | } 60 | 61 | function test_ProxyRegistryCreateNewProxy() public { 62 | address payable proxyAddr = registry.build(); 63 | assertTrue(proxyAddr != address(0)); 64 | assertEq(proxyAddr, address(registry.proxies(address(this)))); 65 | DSProxy(proxyAddr).setOwner(address(0)); 66 | address payable proxyAddr2 = registry.build(); 67 | assertTrue(proxyAddr != proxyAddr2); 68 | assertEq(proxyAddr2, address(registry.proxies(address(this)))); 69 | } 70 | 71 | function testFail_ProxyRegistryCreateNewProxy() public { 72 | registry.build(); 73 | registry.build(); 74 | } 75 | 76 | function testFail_ProxyRegistryCreateNewProxy2() public { 77 | address owner = address(0x123); 78 | registry.build(owner); 79 | registry.build(owner); 80 | } 81 | } 82 | --------------------------------------------------------------------------------