Compare commits
12 Commits
ewong_prot
...
feat/proto
Author | SHA1 | Date | |
---|---|---|---|
|
4072724866 | ||
|
74be3d1d96 | ||
|
730b476987 | ||
|
84e353aa38 | ||
|
151915ec46 | ||
|
aa20eaac47 | ||
|
ba7599ad39 | ||
|
5756d7c563 | ||
|
2577caaf5a | ||
|
603813191f | ||
|
0484519e4d | ||
|
275542b6b2 |
@@ -10,6 +10,7 @@ jobs:
|
||||
working_directory: ~/repo
|
||||
steps:
|
||||
- checkout
|
||||
- run: git submodule update --init --recursive
|
||||
- run: echo 'export PATH=$HOME/CIRCLE_PROJECT_REPONAME/node_modules/.bin:$PATH' >> $BASH_ENV
|
||||
- run:
|
||||
name: install-yarn
|
||||
|
9
.gitignore
vendored
9
.gitignore
vendored
@@ -173,6 +173,15 @@ contracts/zero-ex/test/generated-wrappers/
|
||||
contracts/treasury/generated-wrappers/
|
||||
contracts/treasury/test/generated-wrappers/
|
||||
|
||||
# foundry artifacts
|
||||
contracts/zero-ex/foundry-artifacts/
|
||||
|
||||
# foundry cache
|
||||
contracts/zero-ex/foundry-cache/
|
||||
|
||||
# typechain wrappers
|
||||
contracts/zero-ex/typechain-wrappers/
|
||||
|
||||
# Doc README copy
|
||||
packages/*/docs/README.md
|
||||
|
||||
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "contracts/zero-ex/contracts/deps/forge-std"]
|
||||
path = contracts/zero-ex/contracts/deps/forge-std
|
||||
url = https://github.com/foundry-rs/forge-std
|
758
contracts/erc20/contracts/src/v06/WETH9.sol
Normal file
758
contracts/erc20/contracts/src/v06/WETH9.sol
Normal file
@@ -0,0 +1,758 @@
|
||||
// Copyright (C) 2015, 2016, 2017 Dapphub
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// solhint-disable
|
||||
pragma solidity ^0.6.5;
|
||||
|
||||
|
||||
contract WETH9 {
|
||||
string public name = "Wrapped Ether";
|
||||
string public symbol = "WETH";
|
||||
uint8 public decimals = 18;
|
||||
|
||||
event Approval(address indexed _owner, address indexed _spender, uint _value);
|
||||
event Transfer(address indexed _from, address indexed _to, uint _value);
|
||||
event Deposit(address indexed _owner, uint _value);
|
||||
event Withdrawal(address indexed _owner, uint _value);
|
||||
|
||||
mapping (address => uint) public balanceOf;
|
||||
mapping (address => mapping (address => uint)) public allowance;
|
||||
|
||||
receive() external payable {
|
||||
deposit();
|
||||
}
|
||||
function deposit() public payable {
|
||||
balanceOf[msg.sender] += msg.value;
|
||||
emit Deposit(msg.sender, msg.value);
|
||||
}
|
||||
function withdraw(uint wad) public {
|
||||
require(balanceOf[msg.sender] >= wad);
|
||||
balanceOf[msg.sender] -= wad;
|
||||
msg.sender.transfer(wad);
|
||||
emit Withdrawal(msg.sender, wad);
|
||||
}
|
||||
|
||||
function totalSupply() public view returns (uint) {
|
||||
return address(this).balance;
|
||||
}
|
||||
|
||||
function approve(address guy, uint wad) public returns (bool) {
|
||||
allowance[msg.sender][guy] = wad;
|
||||
emit Approval(msg.sender, guy, wad);
|
||||
return true;
|
||||
}
|
||||
|
||||
function transfer(address dst, uint wad) public returns (bool) {
|
||||
return transferFrom(msg.sender, dst, wad);
|
||||
}
|
||||
|
||||
function transferFrom(address src, address dst, uint wad)
|
||||
public
|
||||
returns (bool)
|
||||
{
|
||||
require(balanceOf[src] >= wad);
|
||||
|
||||
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
|
||||
require(allowance[src][msg.sender] >= wad);
|
||||
allowance[src][msg.sender] -= wad;
|
||||
}
|
||||
|
||||
balanceOf[src] -= wad;
|
||||
balanceOf[dst] += wad;
|
||||
|
||||
emit Transfer(src, dst, wad);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
*/
|
1
contracts/zero-ex/contracts/deps/forge-std
Submodule
1
contracts/zero-ex/contracts/deps/forge-std
Submodule
Submodule contracts/zero-ex/contracts/deps/forge-std added at 1680d7fb3e
30
contracts/zero-ex/contracts/test/foundry/ContractTest.sol
Normal file
30
contracts/zero-ex/contracts/test/foundry/ContractTest.sol
Normal file
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
contract ContractTest is Test {
|
||||
function setUp() public {}
|
||||
|
||||
function testExample() public {
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "src/features/OtcOrdersFeature.sol";
|
||||
import "src/features/TransformERC20Feature.sol";
|
||||
import "src/features/UniswapFeature.sol";
|
||||
import "src/features/UniswapV3Feature.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
import "../utils/DeployZeroEx.sol";
|
||||
|
||||
contract Architecture is DeployZeroEx {
|
||||
|
||||
function testFeatureDeployment()
|
||||
public
|
||||
{
|
||||
deployZeroEx();
|
||||
// If we look up the address of the Uniswap Implementation, it will be empty
|
||||
// as it hasn't yet been registered.
|
||||
emit log_named_address("sellToUniswap implementation", ZERO_EX.getFunctionImplementation(UniswapFeature.sellToUniswap.selector));
|
||||
// Try registering the implementation
|
||||
// Technically the constructor argument is the WETH address, which doesn't yet exist in this environment
|
||||
UniswapFeature uniswapFeature = new UniswapFeature(IEtherTokenV06(address(0)));
|
||||
emit log_named_address("UniswapFeature deployed at", address(uniswapFeature));
|
||||
// As part of the migration, the UniswapFeature registers its own selectors
|
||||
IZERO_EX.migrate(address(uniswapFeature), abi.encodePacked(uniswapFeature.migrate.selector), address(this));
|
||||
// You will observe in the logs the following events
|
||||
// ├─ emit ProxyFunctionUpdated(selector: 0xd9627aa4, oldImpl: 0x0000000000000000000000000000000000000000, newImpl: UniswapFeature: [0xf5a2fe45f4f1308502b1c136b9ef8af136141382])
|
||||
// sellToUniswap(address[],uint256,uint256,bool) = 0xd9627aa4
|
||||
// cast keccak 'sellToUniswap(address[],uint256,uint256,bool)'
|
||||
// > 0xd9627aa4...
|
||||
emit log_named_address("sellToUniswap implementation", ZERO_EX.getFunctionImplementation(UniswapFeature.sellToUniswap.selector));
|
||||
// From now on it will be possible to call 0xEP.sellToUniswap which will be registered.
|
||||
|
||||
// Try deploying another Feature such as
|
||||
|
||||
// OtcOrdersFeature
|
||||
// ...
|
||||
emit log_named_address("fillOtcOrder implementation", ZERO_EX.getFunctionImplementation(OtcOrdersFeature.fillOtcOrder.selector));
|
||||
|
||||
// UniswapV3Feature
|
||||
// ...
|
||||
emit log_named_address("sellTokenForTokenToUniswapV3 implementation", ZERO_EX.getFunctionImplementation(UniswapV3Feature.sellTokenForTokenToUniswapV3.selector));
|
||||
|
||||
// Or for extra credit, the TransformERC20Feature
|
||||
emit log_named_address("transformERC20 implementation", ZERO_EX.getFunctionImplementation(TransformERC20Feature.transformERC20.selector));
|
||||
}
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
interface LanguageContract {
|
||||
function hello()
|
||||
external
|
||||
returns (address, string memory);
|
||||
}
|
||||
|
||||
contract ContractA is LanguageContract {
|
||||
function hello()
|
||||
public
|
||||
override
|
||||
returns (address, string memory)
|
||||
{
|
||||
return (address(this), "Why hello there!");
|
||||
}
|
||||
}
|
||||
|
||||
contract ContractB is LanguageContract {
|
||||
function hello()
|
||||
public
|
||||
override
|
||||
returns (address, string memory)
|
||||
{
|
||||
return (address(this), "Protocol Academy was here");
|
||||
}
|
||||
}
|
||||
|
||||
contract DelegateCaller {
|
||||
function delegateCall(address impl)
|
||||
public
|
||||
returns (address addr, string memory str)
|
||||
{
|
||||
(bool success, bytes memory resultData) = impl.delegatecall(abi.encodePacked(LanguageContract.hello.selector));
|
||||
(addr, str) = abi.decode(resultData, (address, string));
|
||||
}
|
||||
}
|
||||
|
||||
contract DelegateCall is Test {
|
||||
LanguageContract A;
|
||||
LanguageContract B;
|
||||
DelegateCaller caller;
|
||||
|
||||
function setUp()
|
||||
public
|
||||
{
|
||||
A = new ContractA();
|
||||
B = new ContractB();
|
||||
caller = new DelegateCaller();
|
||||
}
|
||||
|
||||
|
||||
function testDelegateCall()
|
||||
public
|
||||
returns (uint256 val)
|
||||
{
|
||||
// ← DelegateCaller: [0xefc56627233b02ea95bae7e19f648d7dcd5bb132], "Why hello there!"
|
||||
caller.delegateCall(address(A));
|
||||
|
||||
// ← DelegateCaller: [0xefc56627233b02ea95bae7e19f648d7dcd5bb132], "Protocol Academy was here"
|
||||
caller.delegateCall(address(B));
|
||||
|
||||
// Note how in the above results the context is always the DelegateCaller context
|
||||
// with address 0xefc56627233b02ea95bae7e19f648d7dcd5bb132
|
||||
|
||||
// ← ContractA: [0xce71065d4017f316ec606fe4422e11eb2c47c246], "Why hello there!"
|
||||
A.hello();
|
||||
|
||||
// ← ContractB: [0x185a4dc360ce69bdccee33b3784b0282f7961aea], "Protocol Academy was here"
|
||||
B.hello();
|
||||
|
||||
// Note how in the above results the context is each individual contract
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
import "src/IZeroEx.sol";
|
||||
import "src/ZeroEx.sol";
|
||||
import "src/migrations/InitialMigration.sol";
|
||||
import "src/features/OtcOrdersFeature.sol";
|
||||
import "src/features/OwnableFeature.sol";
|
||||
import "src/features/SimpleFunctionRegistryFeature.sol";
|
||||
import "src/features/TransformERC20Feature.sol";
|
||||
import "src/features/UniswapFeature.sol";
|
||||
import "src/features/UniswapV3Feature.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
|
||||
contract StorageContract {
|
||||
uint256 public storedValue = 0;
|
||||
|
||||
function increase()
|
||||
public
|
||||
returns (uint256)
|
||||
{
|
||||
storedValue++;
|
||||
return storedValue;
|
||||
}
|
||||
}
|
||||
|
||||
contract OpcodeCosts is Test {
|
||||
|
||||
uint256 public storedValue = 0;
|
||||
StorageContract store;
|
||||
|
||||
function setUp()
|
||||
public
|
||||
{
|
||||
store = new StorageContract();
|
||||
}
|
||||
|
||||
|
||||
function testLoadFromStorage()
|
||||
public
|
||||
returns (uint256 val)
|
||||
{
|
||||
// [2306] StorageContract::storedValue() [staticcall]
|
||||
val = store.storedValue();
|
||||
}
|
||||
|
||||
function testLoadAndStore()
|
||||
public
|
||||
returns (uint256 val)
|
||||
{
|
||||
// [22346] StorageContract::increase()
|
||||
val = store.increase();
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
import "src/IZeroEx.sol";
|
||||
import "src/ZeroEx.sol";
|
||||
import "src/features/interfaces/IFeature.sol";
|
||||
import "src/features/TransformERC20Feature.sol";
|
||||
import "../utils/TestUtils.sol";
|
||||
|
||||
|
||||
// TODO: Try running this test on various networks
|
||||
// forge test --match-contract DeployedFeatures --fork-url <rpc_url> -vvv
|
||||
contract DeployedFeatures is TestUtils {
|
||||
ZeroEx public ZERO_EX = ZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF);
|
||||
IZeroEx public IZERO_EX = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF);
|
||||
|
||||
function testLookupFunction()
|
||||
public
|
||||
{
|
||||
uint256 chainId;
|
||||
assembly { chainId := chainid() }
|
||||
// Skip if not in forking mode
|
||||
if (chainId == 31337) {
|
||||
emit log_string("Not in forking mode; skipping test");
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: try swapping out this selector
|
||||
bytes4 selector = TransformERC20Feature.transformERC20.selector;
|
||||
address impl = ZERO_EX.getFunctionImplementation(selector);
|
||||
if (impl == address(0)) {
|
||||
emit log_named_address("v0.0.0", impl);
|
||||
} else {
|
||||
uint256 version = IFeature(impl).FEATURE_VERSION();
|
||||
// NOTE: we used to have a bug where the version was
|
||||
// being incorrectly encoded as 0 lol
|
||||
emit log_named_address(_versionString(version), impl);
|
||||
}
|
||||
|
||||
uint256 rollbackLength = IZERO_EX.getRollbackLength(selector);
|
||||
if (rollbackLength > 1) {
|
||||
for (uint256 i = rollbackLength - 1; i > 0; i--) {
|
||||
address prevImpl = IZERO_EX.getRollbackEntryAtIndex(selector, i);
|
||||
if (prevImpl == address(0)) {
|
||||
emit log_named_address("v0.0.0", prevImpl);
|
||||
} else {
|
||||
uint256 version = IFeature(prevImpl).FEATURE_VERSION();
|
||||
emit log_named_address(_versionString(version), prevImpl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _versionString(uint256 encodedVersion)
|
||||
private
|
||||
pure
|
||||
returns (string memory versionString)
|
||||
{
|
||||
uint32 major = uint32(encodedVersion >> 64);
|
||||
uint32 minor = uint32(encodedVersion >> 32);
|
||||
uint32 revision = uint32(encodedVersion);
|
||||
|
||||
return string(abi.encodePacked(
|
||||
"v",
|
||||
_toString(uint256(major)),
|
||||
".",
|
||||
_toString(uint256(minor)),
|
||||
".",
|
||||
_toString(uint256(revision))
|
||||
));
|
||||
}
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "src/fixins/FixinCommon.sol";
|
||||
import "src/migrations/LibMigrate.sol";
|
||||
import "../utils/DeployZeroEx.sol";
|
||||
|
||||
contract FibonacciFeature is FixinCommon {
|
||||
uint256 private prevFib;
|
||||
uint256 private fib;
|
||||
|
||||
function migrate()
|
||||
external
|
||||
returns (bytes4 success)
|
||||
{
|
||||
_registerFeatureFunction(this.stepFibonacci.selector);
|
||||
_registerFeatureFunction(this.currentFibonacci.selector);
|
||||
return LibMigrate.MIGRATE_SUCCESS;
|
||||
}
|
||||
|
||||
function stepFibonacci() external {
|
||||
if (prevFib == 0 && fib == 0) {
|
||||
fib = 1;
|
||||
return;
|
||||
} else {
|
||||
uint256 nextFib = prevFib + fib;
|
||||
prevFib = fib;
|
||||
fib = nextFib;
|
||||
}
|
||||
}
|
||||
|
||||
function currentFibonacci() external view returns (uint256) {
|
||||
return fib;
|
||||
}
|
||||
}
|
||||
|
||||
contract VoteFeature is FixinCommon {
|
||||
uint256 private good;
|
||||
uint256 private bad;
|
||||
mapping (address => bool) hasVoted;
|
||||
|
||||
function migrate()
|
||||
external
|
||||
returns (bytes4 success)
|
||||
{
|
||||
_registerFeatureFunction(this.pineappleOnPizzaIsGood.selector);
|
||||
_registerFeatureFunction(this.pineappleOnPizzaIsBad.selector);
|
||||
_registerFeatureFunction(this.currentVotes.selector);
|
||||
return LibMigrate.MIGRATE_SUCCESS;
|
||||
}
|
||||
|
||||
function pineappleOnPizzaIsGood() external {
|
||||
require(!hasVoted[msg.sender]);
|
||||
hasVoted[msg.sender] = true;
|
||||
good++;
|
||||
}
|
||||
|
||||
function pineappleOnPizzaIsBad() external {
|
||||
require(!hasVoted[msg.sender]);
|
||||
hasVoted[msg.sender] = true;
|
||||
bad++;
|
||||
}
|
||||
|
||||
function currentVotes() external view returns (uint256, uint256) {
|
||||
return (good, bad);
|
||||
}
|
||||
}
|
||||
|
||||
contract FeatureStorage is DeployZeroEx {
|
||||
|
||||
function setUp() public {
|
||||
deployZeroEx();
|
||||
FibonacciFeature fibonacciFeature = new FibonacciFeature();
|
||||
emit log_named_address("FibonacciFeature deployed at", address(fibonacciFeature));
|
||||
IZERO_EX.migrate(address(fibonacciFeature), abi.encodePacked(fibonacciFeature.migrate.selector), address(this));
|
||||
emit log_named_address("stepFibonacci implementation", ZERO_EX.getFunctionImplementation(FibonacciFeature.stepFibonacci.selector));
|
||||
|
||||
VoteFeature voteFeature = new VoteFeature();
|
||||
emit log_named_address("VoteFeature deployed at", address(voteFeature));
|
||||
IZERO_EX.migrate(address(voteFeature), abi.encodePacked(voteFeature.migrate.selector), address(this));
|
||||
}
|
||||
|
||||
function testFeatureStorage()
|
||||
public
|
||||
{
|
||||
for (uint256 i = 0; i < 10; i++) {
|
||||
emit log_named_uint("fib", FibonacciFeature(address(ZERO_EX)).currentFibonacci());
|
||||
FibonacciFeature(address(ZERO_EX)).stepFibonacci();
|
||||
}
|
||||
|
||||
for (uint256 i = 0; i < 10; i++) {
|
||||
address voter = _pseudoRandomAddress(i);
|
||||
bool likesPineappleOnPizza = (uint160(voter) % 2) == 1;
|
||||
hoax(voter);
|
||||
likesPineappleOnPizza
|
||||
? VoteFeature(address(ZERO_EX)).pineappleOnPizzaIsGood()
|
||||
: VoteFeature(address(ZERO_EX)).pineappleOnPizzaIsBad();
|
||||
}
|
||||
(uint256 good, uint256 bad) = VoteFeature(address(ZERO_EX)).currentVotes();
|
||||
|
||||
emit log_named_uint("good votes", good);
|
||||
emit log_named_uint("bad votes", bad);
|
||||
emit log_named_uint("fib", FibonacciFeature(address(ZERO_EX)).currentFibonacci());
|
||||
|
||||
// TODO: Fix the Fibonacci and Vote features so that their respective storage
|
||||
// variables do not collide. Create LibFibonacciStorage and LibVoteStorage
|
||||
// to do so.
|
||||
}
|
||||
|
||||
function _pseudoRandomAddress(uint256 seed) private pure returns (address) {
|
||||
return address(uint160(uint256(keccak256(abi.encodePacked(seed)))));
|
||||
}
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "src/fixins/FixinCommon.sol";
|
||||
import "src/migrations/LibMigrate.sol";
|
||||
import "../utils/DeployZeroEx.sol";
|
||||
|
||||
contract ZooFeature is FixinCommon {
|
||||
event Meow();
|
||||
event Woof();
|
||||
event SlothNoises();
|
||||
|
||||
function migrate()
|
||||
external
|
||||
returns (bytes4 success)
|
||||
{
|
||||
_registerFeatureFunction(this.cat.selector);
|
||||
_registerFeatureFunction(this.dog.selector);
|
||||
_registerFeatureFunction(this.sloth.selector);
|
||||
return LibMigrate.MIGRATE_SUCCESS;
|
||||
}
|
||||
|
||||
function cat() external {
|
||||
emit Meow();
|
||||
}
|
||||
function dog() external {
|
||||
emit Woof();
|
||||
}
|
||||
function sloth() external {
|
||||
emit SlothNoises();
|
||||
}
|
||||
}
|
||||
|
||||
contract ZooFeatureV2 is FixinCommon {
|
||||
event Meow();
|
||||
event Purr();
|
||||
event Woof();
|
||||
event CapybaraNoises();
|
||||
|
||||
function migrate()
|
||||
external
|
||||
returns (bytes4 success)
|
||||
{
|
||||
_registerFeatureFunction(this.cat.selector);
|
||||
_registerFeatureFunction(this.dog.selector);
|
||||
_registerFeatureFunction(this.capybara.selector);
|
||||
return LibMigrate.MIGRATE_SUCCESS;
|
||||
}
|
||||
|
||||
// NOTE: the function signature for `cat` has changed, so the selectors are different!
|
||||
function cat(bool happy) external {
|
||||
if (happy) {
|
||||
emit Purr();
|
||||
} else {
|
||||
emit Meow();
|
||||
}
|
||||
}
|
||||
// dog is the same
|
||||
function dog() external {
|
||||
emit Woof();
|
||||
}
|
||||
// new!
|
||||
function capybara() external {
|
||||
emit CapybaraNoises();
|
||||
}
|
||||
// sloth is not in V2
|
||||
}
|
||||
|
||||
contract Migration is DeployZeroEx {
|
||||
|
||||
function setUp() public {
|
||||
deployZeroEx();
|
||||
}
|
||||
|
||||
function testMigration()
|
||||
public
|
||||
{
|
||||
ZooFeature zooFeature = new ZooFeature();
|
||||
IZERO_EX.migrate(address(zooFeature), abi.encodePacked(zooFeature.migrate.selector), address(this));
|
||||
|
||||
// The functions in ZooFeature are now registered in the exchange proxy!
|
||||
// Try them out.
|
||||
ZooFeature(address(ZERO_EX)).dog();
|
||||
ZooFeature(address(ZERO_EX)).cat();
|
||||
ZooFeature(address(ZERO_EX)).sloth();
|
||||
}
|
||||
|
||||
function testUpgrade()
|
||||
public
|
||||
{
|
||||
// Original version
|
||||
ZooFeature zooFeature = new ZooFeature();
|
||||
IZERO_EX.migrate(address(zooFeature), abi.encodePacked(zooFeature.migrate.selector), address(this));
|
||||
// Upgrade
|
||||
ZooFeatureV2 zooFeatureV2 = new ZooFeatureV2();
|
||||
IZERO_EX.migrate(address(zooFeatureV2), abi.encodePacked(zooFeatureV2.migrate.selector), address(this));
|
||||
|
||||
// The functions in ZooFeatureV2 are now registered in the exchange proxy!
|
||||
// Try them out.
|
||||
ZooFeatureV2(address(ZERO_EX)).dog();
|
||||
ZooFeatureV2(address(ZERO_EX)).cat(true);
|
||||
ZooFeatureV2(address(ZERO_EX)).cat(false);
|
||||
ZooFeatureV2(address(ZERO_EX)).capybara();
|
||||
|
||||
// `sloth` is still registered
|
||||
ZooFeature(address(ZERO_EX)).sloth();
|
||||
// The old `cat` function is still registered, since it has a different selector
|
||||
emit log_named_bytes('cat()', abi.encodePacked(zooFeature.cat.selector));
|
||||
emit log_named_bytes('cat(bool)', abi.encodePacked(zooFeatureV2.cat.selector));
|
||||
ZooFeature(address(ZERO_EX)).cat();
|
||||
|
||||
// Let's deregister the sloth and old cat functions
|
||||
IZERO_EX.rollback(zooFeature.cat.selector, address(0));
|
||||
IZERO_EX.rollback(zooFeature.sloth.selector, address(0));
|
||||
|
||||
// Now trying to call the old cat or sloth reverts
|
||||
try ZooFeature(address(ZERO_EX)).cat() {}
|
||||
catch (bytes memory e) {
|
||||
emit log_string("cat() reverted");
|
||||
}
|
||||
try ZooFeature(address(ZERO_EX)).sloth() {}
|
||||
catch (bytes memory e) {
|
||||
emit log_string("sloth() reverted");
|
||||
}
|
||||
|
||||
// dog() was upgraded, so it's v1 address is in the `implHistory`
|
||||
emit log_named_uint(
|
||||
"dog() rollback length",
|
||||
IZERO_EX.getRollbackLength(zooFeature.dog.selector)
|
||||
);
|
||||
emit log_named_address(
|
||||
"dog() v1 is in the history",
|
||||
IZERO_EX.getRollbackEntryAtIndex(zooFeature.dog.selector, 1)
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,152 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../utils/ForkUtils.sol";
|
||||
import "../utils/TestUtils.sol";
|
||||
import "src/IZeroEx.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
import "src/features/TransformERC20Feature.sol";
|
||||
import "src/external/TransformerDeployer.sol";
|
||||
import "src/transformers/WethTransformer.sol";
|
||||
import "src/transformers/FillQuoteTransformer.sol";
|
||||
import "src/transformers/bridges/BridgeProtocols.sol";
|
||||
import "src/transformers/bridges/BridgeAdapter.sol";
|
||||
|
||||
/*
|
||||
This test must be run in forked mode
|
||||
e.g forge test -vvvv -m 'testBasicSwap' -f ETH_RPC_URL
|
||||
It is also helpful to have an Etherscan API key exported
|
||||
export ETHERSCAN_API_KEY=
|
||||
as Foundry will fetch source code and names
|
||||
*/
|
||||
|
||||
contract BasicSwapForkedTest is
|
||||
ForkUtils,
|
||||
TestUtils
|
||||
{
|
||||
IZeroEx public IZERO_EX = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF);
|
||||
IEtherTokenV06 WETH = IEtherTokenV06(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
|
||||
|
||||
// These addresses are taken from contract-addresses for Ethereum Mainnet
|
||||
TransformerDeployer transformerDeployer = TransformerDeployer(0x39dCe47a67aD34344EAB877eaE3Ef1FA2a1d50Bb);
|
||||
WethTransformer wethTransformer = WethTransformer(0xb2bc06a4EfB20FC6553a69Dbfa49B7bE938034A7);
|
||||
// Note this may be outdated as it is often updated
|
||||
FillQuoteTransformer fillQuoteTransformer = FillQuoteTransformer(0xADBE39F2988A8Be1C1120F05e28CC888b150c8a6);
|
||||
|
||||
function setUp()
|
||||
public
|
||||
onlyForked()
|
||||
{
|
||||
// HACK we deploy some fake transformers just so Foundry
|
||||
// can detect these contracts for decoding
|
||||
new WethTransformer(IEtherTokenV06(address(0)));
|
||||
vm.label(address(wethTransformer), "WethTransformer");
|
||||
new FillQuoteTransformer(IBridgeAdapter(address(0)), INativeOrdersFeature(address(0)));
|
||||
vm.label(address(fillQuoteTransformer), "FillQuoteTransformer");
|
||||
new BridgeAdapter(IEtherTokenV06(address(0)));
|
||||
vm.label(address(fillQuoteTransformer.bridgeAdapter()), "BridgeAdapter");
|
||||
vm.label(address(IZERO_EX.getTransformWallet()), "FlashWallet");
|
||||
}
|
||||
|
||||
function testBasicSwap()
|
||||
public
|
||||
onlyForked()
|
||||
{
|
||||
IERC20TokenV06 USDC = IERC20TokenV06(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48);
|
||||
// Create our list of transformations, let's do WethTransformer and FillQuoteTransformer
|
||||
ITransformERC20Feature.Transformation[] memory transformations = new ITransformERC20Feature.Transformation[](2);
|
||||
// Use our cheeky search helper to find the nonce rather than hardcode it
|
||||
// hint: it's 6 for WethTransformer and 22 for this FillQuoteTransformer
|
||||
transformations[0].deploymentNonce = _findTransformerNonce(address(wethTransformer), address(transformerDeployer));
|
||||
transformations[1].deploymentNonce = _findTransformerNonce(address(fillQuoteTransformer), address(transformerDeployer));
|
||||
|
||||
emit log_named_uint("WethTransformer nonce", transformations[0].deploymentNonce);
|
||||
emit log_named_uint("FillQuoteTransformer nonce", transformations[1].deploymentNonce);
|
||||
|
||||
// Set the first transformation to transform ETH into WETH
|
||||
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
||||
|
||||
// Set up the FillQuoteTransformer data
|
||||
FillQuoteTransformer.TransformData memory fqtData;
|
||||
fqtData.side = FillQuoteTransformer.Side.Sell;
|
||||
// FQT deals with tokens, not ETH, so it needs a WETH transformer
|
||||
// to be applied beforehand
|
||||
fqtData.sellToken = IERC20TokenV06(address(WETH));
|
||||
fqtData.buyToken = IERC20TokenV06(address(USDC));
|
||||
// the FQT has a sequence, e.g first RFQ then Limit then Bridge
|
||||
// since solidity doesn't support arrays of different types, this is one simple solution
|
||||
// We use a Bridge order type here as we will fill on UniswapV2
|
||||
fqtData.fillSequence = new FillQuoteTransformer.OrderType[](1);
|
||||
fqtData.fillSequence[0] = FillQuoteTransformer.OrderType.Bridge;
|
||||
// The amount to fill
|
||||
fqtData.fillAmount = 1e18;
|
||||
// Now let's set up a UniswapV2 fill
|
||||
fqtData.bridgeOrders = new IBridgeAdapter.BridgeOrder[](1);
|
||||
IBridgeAdapter.BridgeOrder memory order;
|
||||
// The ID is shifted so we can concat <PROTOCOL><NAME>
|
||||
// e.g <UniswapV2Protocol><UniswapV2>
|
||||
// or <UniswapV2Protocol><SushiSwap> for forks
|
||||
order.source = bytes32(uint256(BridgeProtocols.UNISWAPV2) << 128);
|
||||
// How much we want to fill on this order, which can be different to the total
|
||||
// e.g 50/50 split this would be half
|
||||
order.takerTokenAmount = 1e18;
|
||||
// Set this low as the price of ETH/USDC can change
|
||||
order.makerTokenAmount = 1;
|
||||
// The data needed specifically for the source to fill,
|
||||
// e.g for UniswapV2 it is the router contract and a path. See MixinUniswapV2
|
||||
address[] memory uniPath = new address[](2);
|
||||
uniPath[0] = address(WETH);
|
||||
uniPath[1] = address(USDC);
|
||||
order.bridgeData = abi.encode(address(0xf164fC0Ec4E93095b804a4795bBe1e041497b92a), uniPath);
|
||||
fqtData.bridgeOrders[0] = order;
|
||||
// Now encode the FQT data into the transformation
|
||||
transformations[1].data = abi.encode(fqtData);
|
||||
|
||||
|
||||
// Now let's do it!
|
||||
// Give ourselves 1e18 ETH
|
||||
vm.deal(address(this), 1e18);
|
||||
IZERO_EX.transformERC20{value: 1e18}(
|
||||
// input token
|
||||
IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS),
|
||||
// output token
|
||||
IERC20TokenV06(address(USDC)),
|
||||
// input token amount
|
||||
1e18,
|
||||
// min output token amount, set this low as ETH/USDC price will move
|
||||
1,
|
||||
// list of transform
|
||||
transformations
|
||||
);
|
||||
// Hoollly heck we bought some USDC
|
||||
assertGt(USDC.balanceOf(address(this)), 0);
|
||||
emit log_named_uint("USDC bought", USDC.balanceOf(address(this)));
|
||||
|
||||
/*
|
||||
Homework
|
||||
Try the following:
|
||||
* make this UniswapV2 trade go ETH->DAI->USDC
|
||||
* combine multiple trades, e.g Uniswap V2 ETH->USDC and ETH->DAI->USDC
|
||||
* create a UniswapV3 trade
|
||||
*/
|
||||
}
|
||||
}
|
@@ -0,0 +1,191 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "../utils/DeployZeroEx.sol";
|
||||
import "@0x/contracts-erc20/contracts/src/v06/IEtherTokenV06.sol";
|
||||
import "src/features/TransformERC20Feature.sol";
|
||||
import "src/external/TransformerDeployer.sol";
|
||||
import "src/transformers/WethTransformer.sol";
|
||||
import "src/transformers/FillQuoteTransformer.sol";
|
||||
|
||||
import "@0x/contracts-erc20/contracts/src/v06/WETH9.sol";
|
||||
|
||||
contract TransformERC20FeatureTest is DeployZeroEx {
|
||||
IEtherTokenV06 WETH;
|
||||
|
||||
TransformerDeployer transformerDeployer;
|
||||
WethTransformer wethTransformer;
|
||||
TransformERC20Feature transformERC20Feature;
|
||||
|
||||
function setUp() public {
|
||||
deployZeroEx();
|
||||
// Deploy from bytecode as this is Solidity v5
|
||||
WETH = IEtherTokenV06(deployCode("foundry-artifacts/WETH9.sol/WETH9.json"));
|
||||
emit log_named_address("WETH deployed at", address(WETH));
|
||||
}
|
||||
|
||||
function testMigration()
|
||||
public
|
||||
{
|
||||
// Note there is a lot here, so feel free to comment out further sections
|
||||
// so you can read the logs and traces
|
||||
|
||||
/*
|
||||
Deploy TransformERC20Feature
|
||||
*/
|
||||
|
||||
// Create a new TransformerDeployer, which will deploy all future transformers
|
||||
// Owners are typically EOA which are allowed to deploy
|
||||
// For this we will use this current contract address
|
||||
address[] memory owners = new address[](1);
|
||||
owners[0] = address(this);
|
||||
transformerDeployer = new TransformerDeployer(owners);
|
||||
emit log_named_address("TransformerDeployer deployed at", address(transformerDeployer));
|
||||
|
||||
|
||||
transformERC20Feature = new TransformERC20Feature();
|
||||
emit log_named_address("TransformERC20Feature deployed at", address(transformERC20Feature));
|
||||
|
||||
// Migrate 0x EP and initialize the TransformERC20Feature
|
||||
// Remember this performs a delegatecall and registers function selectors
|
||||
// function migrate(address target, bytes calldata data, address newOwner)
|
||||
IZERO_EX.migrate(
|
||||
address(transformERC20Feature),
|
||||
// Use encodeWithSelector to generate low level call data with the required arguments
|
||||
// <function selector><arg1>
|
||||
// The required migration function to call is the following:
|
||||
// function migrate(address transformerDeployer)
|
||||
// e.g ce5494bb00000000000000000000000042997ac9251e5bb0a61f4ff790e5b991ea07fd9b
|
||||
// try: cast calldata 'migrate(address)' '0x42997ac9251e5bb0a61f4ff790e5b991ea07fd9b'
|
||||
abi.encodeWithSelector(transformERC20Feature.migrate.selector, address(transformerDeployer)),
|
||||
address(this)
|
||||
);
|
||||
|
||||
// As part of the migration process a FlashWallet was generated inside of the 0x EP context
|
||||
emit log_named_address("FlashWallet deployed at", address(IZERO_EX.getTransformWallet()));
|
||||
// Homework: Recall why transformERC20Feature.getTransformWallet() returns address(0)
|
||||
|
||||
/*
|
||||
Deploy a WETH transformer
|
||||
*/
|
||||
|
||||
// Typically the code to deployed is passed in off-chain, so we will emulate something similar
|
||||
// by using vm.getCode cheatcode.
|
||||
wethTransformer = WethTransformer(transformerDeployer.deploy(
|
||||
abi.encodePacked(
|
||||
// Deploy the WethTransformer code
|
||||
vm.getCode("foundry-artifacts/WethTransformer.sol/WethTransformer.json"),
|
||||
// WethTransformer takes WETH address as a constructor argument
|
||||
abi.encode(address(WETH))
|
||||
)
|
||||
));
|
||||
assertEq(address(wethTransformer.weth()), address(WETH));
|
||||
emit log_named_address("WethTransformer deployed at", address(IZERO_EX.getTransformWallet()));
|
||||
|
||||
// Not much we can do with just a WethTransformer, I guess we could go ETH->WETH with it
|
||||
// Cheat code to give this contract 1e18 ETH
|
||||
vm.deal(address(this), 1e18);
|
||||
|
||||
// Deployment nonce is 1 as it is the first contract TransformerDeployer deployed
|
||||
// let's assert that is true
|
||||
assertEq(
|
||||
LibERC20Transformer.getDeployedAddress(address(transformerDeployer), 1),
|
||||
address(wethTransformer)
|
||||
);
|
||||
|
||||
/*
|
||||
Perform a ETH->WETH transformation
|
||||
*/
|
||||
|
||||
// Create our list of transformations, this will just have a WethTransformer
|
||||
ITransformERC20Feature.Transformation[] memory transformations = new ITransformERC20Feature.Transformation[](1);
|
||||
transformations[0].deploymentNonce = 1;
|
||||
transformations[0].data = abi.encode(LibERC20Transformer.ETH_TOKEN_ADDRESS, 1e18);
|
||||
|
||||
IZERO_EX.transformERC20{value: 1e18}(
|
||||
// input token
|
||||
IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS),
|
||||
// output token
|
||||
IERC20TokenV06(address(WETH)),
|
||||
// input token amount
|
||||
1e18,
|
||||
// min output token amount
|
||||
1e18,
|
||||
// list of transform
|
||||
transformations
|
||||
);
|
||||
assertEq(WETH.balanceOf(address(this)), 1e18);
|
||||
|
||||
/*
|
||||
Perform a WETH->ETH transformation
|
||||
*/
|
||||
|
||||
// Let's go backwards, remember we need to set the approval of WETH to the 0x EP
|
||||
WETH.approve(address(IZERO_EX), uint256(-1));
|
||||
// Override the data in the previous transformation
|
||||
transformations[0].data = abi.encode(address(WETH), 1e18);
|
||||
// Note: No { value } here as it's a token
|
||||
IZERO_EX.transformERC20(
|
||||
// input token
|
||||
IERC20TokenV06(address(WETH)),
|
||||
// output token
|
||||
IERC20TokenV06(LibERC20Transformer.ETH_TOKEN_ADDRESS),
|
||||
// input token amount
|
||||
1e18,
|
||||
// min output token amount
|
||||
1e18,
|
||||
// list of transform
|
||||
transformations
|
||||
);
|
||||
|
||||
/*
|
||||
Deploy FillQuoteTransformer and BridgeAdapter
|
||||
*/
|
||||
|
||||
// At this time I would show how to do a ETH->USDC trade
|
||||
// but we need to set up more of the world, or to run in forked mode
|
||||
// with an AMM (find this in BasicSwapForked.t.sol)
|
||||
|
||||
// Instead let's just deploy the FQT and BridgeAdapter and as homework
|
||||
// you might explore running in forked mode and using transformations
|
||||
address bridgeAdapter = deployCode("foundry-artifacts/BridgeAdapter.sol/BridgeAdapter.json", abi.encode(address(WETH)));
|
||||
FillQuoteTransformer fillQuoteTransformer = FillQuoteTransformer(transformerDeployer.deploy(
|
||||
abi.encodePacked(
|
||||
// Deploy the FillQuoteTransformer code
|
||||
vm.getCode("foundry-artifacts/FillQuoteTransformer.sol/FillQuoteTransformer.json"),
|
||||
// FillQuoteTransformer takes the BridgeAdapter and ZeroEx address as arguments
|
||||
abi.encode(bridgeAdapter, address(ZERO_EX))
|
||||
)
|
||||
));
|
||||
assertEq(address(fillQuoteTransformer.bridgeAdapter()), bridgeAdapter);
|
||||
assertEq(
|
||||
LibERC20Transformer.getDeployedAddress(address(transformerDeployer), 2),
|
||||
address(fillQuoteTransformer)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
// Note this is needed as the test is a contract, and to receive ETH
|
||||
// it needs to declare a receive function as per the Solidity requirements
|
||||
receive() external payable {}
|
||||
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Receiver {
|
||||
function receivePure() public pure {
|
||||
1 + 1;
|
||||
}
|
||||
|
||||
function receiveImpure() public {
|
||||
1 + 1;
|
||||
}
|
||||
}
|
||||
|
||||
contract Empty {
|
||||
|
||||
}
|
||||
|
||||
contract Call {
|
||||
address empty = address(new Empty());
|
||||
address receiver = address(new Receiver());
|
||||
|
||||
function callUnknown() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Call.t.sol --sig 'callUnknown()' --tc Call
|
||||
|
||||
// Why didn't this contract make a call out to 0x222... ?
|
||||
// Did solidity add a check for us?
|
||||
Receiver(0x2222222222222222222222222222222222222222).receiveImpure();
|
||||
}
|
||||
|
||||
function callEmpty() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Call.t.sol --sig 'callEmpty()' --tc Call
|
||||
|
||||
// Observe how the added Solidity checks "pass"
|
||||
// and ultimately how this results in a REVERT
|
||||
Receiver(empty).receiveImpure();
|
||||
}
|
||||
|
||||
function callEmptyRaw() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Call.t.sol --sig 'callEmptyRaw()' --tc Call
|
||||
|
||||
// Observe this low level call and how it differs from the above
|
||||
// example. Does it revert?
|
||||
empty.call(abi.encodeWithSelector(Receiver.receiveImpure.selector));
|
||||
}
|
||||
|
||||
function callEmptyEOA() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Call.t.sol --sig 'callEmptyEOA()' --tc Call
|
||||
|
||||
// Observe this low level call and how it differs from the above
|
||||
// example. Does it revert?
|
||||
address(msg.sender).call(abi.encodeWithSelector(Receiver.receiveImpure.selector));
|
||||
}
|
||||
|
||||
function callReceiverImpure() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Call.t.sol --sig 'callReceiverImpure()' --tc Call
|
||||
|
||||
// Observe how a CALL is set up and then ultimately made
|
||||
// and any checks prior to making the CALL
|
||||
Receiver(receiver).receiveImpure();
|
||||
}
|
||||
|
||||
function callReceiverPure() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Call.t.sol --sig 'callReceiverPure()' --tc Call
|
||||
|
||||
// Did you notice the different CALL type solidity chose here ?
|
||||
Receiver(receiver).receivePure();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Counter {
|
||||
uint256 private data = 1337;
|
||||
|
||||
function increment(uint256 val) public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Counter.t.sol --sig 'increment(uint256)' 10
|
||||
data += val;
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Hash {
|
||||
bytes data = hex"42";
|
||||
|
||||
function sha3() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Hash.sol --sig 'sha3()'
|
||||
|
||||
// Follow the opcodes:
|
||||
// how does the data get loaded
|
||||
// which one is keccak256
|
||||
keccak256(data);
|
||||
}
|
||||
|
||||
function sha2() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Hash.sol --sig 'sha2()'
|
||||
|
||||
// Follow the opcodes:
|
||||
// why is sha256 so different from keccak256
|
||||
sha256(data);
|
||||
}
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
contract Memory {
|
||||
|
||||
function expand() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Memory.t.sol --sig 'expand()'
|
||||
|
||||
// Observe the free memory pointer increase
|
||||
// when more memory is allocated
|
||||
bytes32[3] memory data;
|
||||
}
|
||||
|
||||
function mstore() public {
|
||||
// forge debug contracts/test/foundry/protocol-academy/8-evm/Memory.t.sol --sig 'mstore()'
|
||||
|
||||
// Observe the free memory pointer increase
|
||||
// when more memory is allocated
|
||||
bytes1[4] memory data;
|
||||
// Observe each value being set in the memory
|
||||
// slots
|
||||
data[1] = 0x42;
|
||||
data[0] = 0x0a;
|
||||
data[2] = 0xff;
|
||||
}
|
||||
}
|
@@ -0,0 +1,70 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
import "src/IZeroEx.sol";
|
||||
import "src/ZeroEx.sol";
|
||||
import "src/migrations/InitialMigration.sol";
|
||||
import "src/features/OwnableFeature.sol";
|
||||
import "src/features/SimpleFunctionRegistryFeature.sol";
|
||||
|
||||
|
||||
contract DeployZeroEx is Test {
|
||||
ZeroEx public ZERO_EX = ZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF);
|
||||
IZeroEx public IZERO_EX = IZeroEx(0xDef1C0ded9bec7F1a1670819833240f027b25EfF);
|
||||
|
||||
function deployZeroEx()
|
||||
internal
|
||||
{
|
||||
// HERE BE DRAGONS, feel free to ignore this for now
|
||||
// We want to deploy the ZeroEx contract, at 0xDef1C0ded9bec7F1a1670819833240f027b25EfF
|
||||
|
||||
// We use a special mechanism to deploy the ZeroEx contract.
|
||||
InitialMigration initialMigration = InitialMigration(deployCode(
|
||||
"foundry-artifacts/InitialMigration.sol/InitialMigration.json",
|
||||
abi.encode(address(this))
|
||||
));
|
||||
// Must occur from this address as the first transaction
|
||||
hoax(0xe750ad66DE350F8110E305fb78Ec6A9f594445E3);
|
||||
// Special Deployer code
|
||||
bytes memory deployerBytecode = hex"608060405234801561001057600080fd5b506040516103da3803806103da83398101604081905261002f91610077565b8060405161003c9061006a565b610046919061011f565b604051809103906000f080158015610062573d6000803e3d6000fd5b505050610198565b6101f5806101e583390190565b600060208284031215610088578081fd5b81516001600160401b038082111561009e578283fd5b818401915084601f8301126100b1578283fd5b8151818111156100c3576100c3610182565b604051601f8201601f19908116603f011681019083821181831017156100eb576100eb610182565b81604052828152876020848701011115610103578586fd5b610114836020830160208801610152565b979650505050505050565b600060208252825180602084015261013e816040850160208701610152565b601f01601f19169190910160400192915050565b60005b8381101561016d578181015183820152602001610155565b8381111561017c576000848401525b50505050565b634e487b7160e01b600052604160045260246000fd5b603f806101a66000396000f3fe6080604052600080fdfea26469706673582212201bd8b1a777b100d67435ca4bb0b2fdccb13a2c2dde019b227bb553ff9a95bd4464736f6c63430008020033608060405234801561001057600080fd5b506040516101f53803806101f583398101604081905261002f916100c9565b60008151602083016000f090506001600160a01b0381166100865760405162461bcd60e51b815260206004820152600d60248201526c1111541313d657d19052531151609a1b604482015260640160405180910390fd5b6040516001600160a01b03821681527ff40fcec21964ffb566044d083b4073f29f7f7929110ea19e1b3ebe375d89055e9060200160405180910390a150506101a8565b600060208083850312156100db578182fd5b82516001600160401b03808211156100f1578384fd5b818501915085601f830112610104578384fd5b81518181111561011657610116610192565b604051601f8201601f19908116603f0116810190838211818310171561013e5761013e610192565b816040528281528886848701011115610155578687fd5b8693505b828410156101765784840186015181850187015292850192610159565b8284111561018657868684830101525b98975050505050505050565b634e487b7160e01b600052604160045260246000fd5b603f806101b66000396000f3fe6080604052600080fdfea2646970667358221220fbca036a163ed7f008cefa7c834d98d25109a456a051d41d9c89d55d7185d12b64736f6c63430008020033";
|
||||
// Grab the bytecode of the ZeroEx artifact
|
||||
bytes memory zeroExBytecode = vm.getCode("foundry-artifacts/ZeroEx.sol/ZeroEx.json");
|
||||
// Append the required ZeroEx constructor arguments (address bootstrapper)
|
||||
bytes memory zeroExDeploycode = abi.encodePacked(zeroExBytecode, abi.encode(initialMigration));
|
||||
// Append the required deployer code constructor arguments (bytes initCode)
|
||||
bytes memory deployerDeploycode = abi.encodePacked(deployerBytecode, abi.encode(zeroExDeploycode));
|
||||
// The address is technically emitted in an event, but we know we did it correctly
|
||||
//│ │ ├─ emit topic 0: 0xf40fcec21964ffb566044d083b4073f29f7f7929110ea19e1b3ebe375d89055e
|
||||
//│ │ │ data: 0x000000000000000000000000def1c0ded9bec7f1a1670819833240f027b25eff
|
||||
assembly {
|
||||
pop(create(0, add(deployerDeploycode, 0x20), mload(deployerDeploycode)))
|
||||
}
|
||||
|
||||
initialMigration.initializeZeroEx(
|
||||
payable(address(this)),
|
||||
ZERO_EX,
|
||||
InitialMigration.BootstrapFeatures({ registry: new SimpleFunctionRegistryFeature(), ownable: new OwnableFeature()})
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
|
||||
contract ForkUtils is Test {
|
||||
/// Only run this function if the block number
|
||||
// is greater than some constant for Ethereum Mainnet
|
||||
modifier onlyForked {
|
||||
if (block.number >= 14206900) {
|
||||
_;
|
||||
} else {
|
||||
emit log_string("Requires fork mode, skipping");
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*
|
||||
|
||||
Copyright 2022 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.6;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import "forge-std/Test.sol";
|
||||
|
||||
import "src/transformers/LibERC20Transformer.sol";
|
||||
|
||||
contract TestUtils is Test {
|
||||
uint256 private constant MAX_UINT256_STRING_LENGTH = 78;
|
||||
uint8 private constant ASCII_DIGIT_OFFSET = 48;
|
||||
|
||||
function _toString(uint256 n)
|
||||
internal
|
||||
pure
|
||||
returns (string memory nstr)
|
||||
{
|
||||
if (n == 0) {
|
||||
return "0";
|
||||
}
|
||||
// Overallocate memory
|
||||
nstr = new string(MAX_UINT256_STRING_LENGTH);
|
||||
uint256 k = MAX_UINT256_STRING_LENGTH;
|
||||
// Populate string from right to left (lsb to msb).
|
||||
while (n != 0) {
|
||||
assembly {
|
||||
let char := add(
|
||||
ASCII_DIGIT_OFFSET,
|
||||
mod(n, 10)
|
||||
)
|
||||
mstore(add(nstr, k), char)
|
||||
k := sub(k, 1)
|
||||
n := div(n, 10)
|
||||
}
|
||||
}
|
||||
assembly {
|
||||
// Shift pointer over to actual start of string.
|
||||
nstr := add(nstr, k)
|
||||
// Store actual string length.
|
||||
mstore(nstr, sub(MAX_UINT256_STRING_LENGTH, k))
|
||||
}
|
||||
return nstr;
|
||||
}
|
||||
|
||||
function _findTransformerNonce(
|
||||
address transformer,
|
||||
address deployer
|
||||
)
|
||||
internal
|
||||
pure
|
||||
returns (uint32)
|
||||
{
|
||||
address current;
|
||||
for (uint32 i = 0; i < 1024; i++) {
|
||||
current = LibERC20Transformer.getDeployedAddress(deployer, i);
|
||||
if (current == transformer) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
contracts/zero-ex/foundry.toml
Normal file
8
contracts/zero-ex/foundry.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[default]
|
||||
src = 'contracts/src'
|
||||
out = 'foundry-artifacts'
|
||||
test = 'contracts/test/foundry'
|
||||
libs = ["../utils/contracts/src/", "contracts/deps/"]
|
||||
remappings = ['@0x/contracts-utils/=../utils/', '@0x/contracts-erc20/=../erc20/', 'src/=./contracts/src']
|
||||
cache_path = 'foundry-cache'
|
||||
optimizer_runs = 1000000
|
@@ -38,7 +38,8 @@
|
||||
"docs:md": "ts-doc-gen --sourceDir='$PROJECT_FILES' --output=$MD_FILE_DIR --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json",
|
||||
"docs:json": "typedoc --excludePrivate --excludeExternals --excludeProtected --ignoreCompilerErrors --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES",
|
||||
"publish:private": "yarn build && gitpkg publish",
|
||||
"rollback": "node ./lib/scripts/rollback.js"
|
||||
"rollback": "node ./lib/scripts/rollback.js",
|
||||
"typechain": "typechain --target=ethers-v5 --out-dir='typechain-wrappers' './foundry-artifacts/**/*.json'"
|
||||
},
|
||||
"config": {
|
||||
"publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature",
|
||||
@@ -65,6 +66,7 @@
|
||||
"@0x/sol-compiler": "^4.8.1",
|
||||
"@0x/ts-doc-gen": "^0.0.28",
|
||||
"@0x/tslint-config": "^4.1.4",
|
||||
"@typechain/ethers-v5": "^10.0.0",
|
||||
"@types/isomorphic-fetch": "^0.0.35",
|
||||
"@types/lodash": "4.14.104",
|
||||
"@types/mocha": "^5.2.7",
|
||||
@@ -78,6 +80,7 @@
|
||||
"solhint": "^1.4.1",
|
||||
"truffle": "^5.0.32",
|
||||
"tslint": "5.11.0",
|
||||
"typechain": "^8.0.0",
|
||||
"typedoc": "~0.16.11",
|
||||
"typescript": "4.6.3"
|
||||
},
|
||||
|
284
yarn.lock
284
yarn.lock
@@ -2683,6 +2683,14 @@
|
||||
dependencies:
|
||||
defer-to-connect "^1.0.1"
|
||||
|
||||
"@typechain/ethers-v5@^10.0.0":
|
||||
version "10.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@typechain/ethers-v5/-/ethers-v5-10.0.0.tgz#1b6e292d2ed9afb0d2f7a4674cc199bb95bad714"
|
||||
integrity sha512-Kot7fwAqnH96ZbI8xrRgj5Kpv9yCEdjo7mxRqrH7bYpEgijT5MmuOo8IVsdhOu7Uog4ONg7k/d5UdbAtTKUgsA==
|
||||
dependencies:
|
||||
lodash "^4.17.15"
|
||||
ts-essentials "^7.0.1"
|
||||
|
||||
"@types/bn.js@^4.11.0", "@types/bn.js@^4.11.3", "@types/bn.js@^4.11.4", "@types/bn.js@^4.11.5":
|
||||
version "4.11.6"
|
||||
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.6.tgz#c306c70d9358aaea33cd4eda092a742b9505967c"
|
||||
@@ -2827,6 +2835,11 @@
|
||||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/prettier@^2.1.1":
|
||||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.6.1.tgz#76e72d8a775eef7ce649c63c8acae1a0824bbaed"
|
||||
integrity sha512-XFjFHmaLVifrAKaZ+EKghFHtHSUonyw8P2Qmy2/+osBnrKbH9UYtlK10zg8/kCt47MFilll/DEDKy3DHfJ0URw==
|
||||
|
||||
"@types/prompts@^2.0.9":
|
||||
version "2.0.9"
|
||||
resolved "https://registry.yarnpkg.com/@types/prompts/-/prompts-2.0.9.tgz#19f419310eaa224a520476b19d4183f6a2b3bd8f"
|
||||
@@ -2934,7 +2947,7 @@ abstract-leveldown@3.0.0:
|
||||
dependencies:
|
||||
xtend "~4.0.0"
|
||||
|
||||
abstract-leveldown@^2.4.1:
|
||||
abstract-leveldown@^2.4.1, abstract-leveldown@~2.7.1:
|
||||
version "2.7.2"
|
||||
resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.7.2.tgz#87a44d7ebebc341d59665204834c8b7e0932cc93"
|
||||
dependencies:
|
||||
@@ -2946,6 +2959,13 @@ abstract-leveldown@^5.0.0, abstract-leveldown@~5.0.0:
|
||||
dependencies:
|
||||
xtend "~4.0.0"
|
||||
|
||||
abstract-leveldown@~2.6.0:
|
||||
version "2.6.3"
|
||||
resolved "https://registry.yarnpkg.com/abstract-leveldown/-/abstract-leveldown-2.6.3.tgz#1c5e8c6a5ef965ae8c35dfb3a8770c476b82c4b8"
|
||||
integrity sha512-2++wDf/DYqkPR3o5tbfdhF96EfMApo1GpPfzOsR/ZYXdkSmELlvOOEAl9iKkRsktMPHdGjO4rtkBpf2I7TiTeA==
|
||||
dependencies:
|
||||
xtend "~4.0.0"
|
||||
|
||||
accepts@~1.3.7:
|
||||
version "1.3.7"
|
||||
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
|
||||
@@ -3128,6 +3148,16 @@ arr-union@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
|
||||
|
||||
array-back@^3.0.1, array-back@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/array-back/-/array-back-3.1.0.tgz#b8859d7a508871c9a7b2cf42f99428f65e96bfb0"
|
||||
integrity sha512-TkuxA4UCOvxuDK6NZYXCalszEzj+TLszyASooky+i742l9TqsOdYCMJJupxRic61hwquNtppB3hgcuq9SVSH1Q==
|
||||
|
||||
array-back@^4.0.1, array-back@^4.0.2:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/array-back/-/array-back-4.0.2.tgz#8004e999a6274586beeb27342168652fdb89fa1e"
|
||||
integrity sha512-NbdMezxqf94cnNfWLL7V/im0Ub+Anbb0IoZhvzie8+4HJ4nMQuzHuy49FkGYCJK2yAloZ3meiB6AVMClbrI1vg==
|
||||
|
||||
array-differ@^2.0.3:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-2.1.0.tgz#4b9c1c3f14b906757082925769e8ab904f4801b1"
|
||||
@@ -3230,7 +3260,7 @@ async-limiter@~1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd"
|
||||
|
||||
async@1.x:
|
||||
async@1.x, async@^1.4.2:
|
||||
version "1.5.2"
|
||||
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"
|
||||
|
||||
@@ -3815,11 +3845,21 @@ bigi@1.4.2, bigi@^1.1.0:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/bigi/-/bigi-1.4.2.tgz#9c665a95f88b8b08fc05cfd731f561859d725825"
|
||||
|
||||
bignumber.js@7.2.1, bignumber.js@^9.0.0, bignumber.js@^9.0.2, bignumber.js@~4.1.0, bignumber.js@~9.0.0, bignumber.js@~9.0.2:
|
||||
bignumber.js@7.2.1:
|
||||
version "7.2.1"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-7.2.1.tgz#80c048759d826800807c4bfd521e50edbba57a5f"
|
||||
integrity sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==
|
||||
|
||||
bignumber.js@^9.0.0, bignumber.js@~9.0.0, bignumber.js@~9.0.2:
|
||||
version "9.0.2"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.2.tgz#71c6c6bed38de64e24a65ebe16cfcf23ae693673"
|
||||
integrity sha512-GAcQvbpsM0pUb0zw1EI0KhQEZ+lRwR5fYaAp3vPOYuP7aDvGy6cVN6XHLauvF8SOga2y0dcLcjt3iQDTSEliyw==
|
||||
|
||||
bignumber.js@~4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1"
|
||||
integrity sha512-eJzYkFYy9L4JzXsbymsFn3p54D+llV27oTQ+ziJG7WFRheJcNZilgVXMG0LoZtlQSKBsJdWtLFqOD0u+U0jZKA==
|
||||
|
||||
binary-extensions@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9"
|
||||
@@ -4326,6 +4366,14 @@ chalk@^4.0.0:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
chalk@^4.1.0:
|
||||
version "4.1.2"
|
||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
|
||||
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
|
||||
dependencies:
|
||||
ansi-styles "^4.1.0"
|
||||
supports-color "^7.1.0"
|
||||
|
||||
change-case@^3.0.2:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/change-case/-/change-case-3.1.0.tgz#0e611b7edc9952df2e8513b27b42de72647dd17e"
|
||||
@@ -4589,6 +4637,26 @@ command-exists@^1.2.8:
|
||||
version "1.2.9"
|
||||
resolved "https://registry.yarnpkg.com/command-exists/-/command-exists-1.2.9.tgz#c50725af3808c8ab0260fd60b01fbfa25b954f69"
|
||||
|
||||
command-line-args@^5.1.1:
|
||||
version "5.2.1"
|
||||
resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-5.2.1.tgz#c44c32e437a57d7c51157696893c5909e9cec42e"
|
||||
integrity sha512-H4UfQhZyakIjC74I9d34fGYDwk3XpSr17QhEd0Q3I9Xq1CETHo4Hcuo87WyWHpAF1aSLjLRf5lD9ZGX2qStUvg==
|
||||
dependencies:
|
||||
array-back "^3.1.0"
|
||||
find-replace "^3.0.0"
|
||||
lodash.camelcase "^4.3.0"
|
||||
typical "^4.0.0"
|
||||
|
||||
command-line-usage@^6.1.0:
|
||||
version "6.1.3"
|
||||
resolved "https://registry.yarnpkg.com/command-line-usage/-/command-line-usage-6.1.3.tgz#428fa5acde6a838779dfa30e44686f4b6761d957"
|
||||
integrity sha512-sH5ZSPr+7UStsloltmDh7Ce5fb8XPlHyoPzTpyyMuYCtervL65+ubVZ6Q61cFtFl62UyJlc8/JwERRbAFPUqgw==
|
||||
dependencies:
|
||||
array-back "^4.0.2"
|
||||
chalk "^2.4.2"
|
||||
table-layout "^1.0.2"
|
||||
typical "^5.2.0"
|
||||
|
||||
commander@2.18.0:
|
||||
version "2.18.0"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970"
|
||||
@@ -5019,6 +5087,13 @@ debug@^4.0.1:
|
||||
dependencies:
|
||||
ms "2.1.2"
|
||||
|
||||
debug@^4.3.1:
|
||||
version "4.3.4"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
|
||||
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
|
||||
dependencies:
|
||||
ms "2.1.2"
|
||||
|
||||
debuglog@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492"
|
||||
@@ -5127,7 +5202,7 @@ deep-equal@~1.1.1:
|
||||
object-keys "^1.1.1"
|
||||
regexp.prototype.flags "^1.2.0"
|
||||
|
||||
deep-extend@^0.6.0:
|
||||
deep-extend@^0.6.0, deep-extend@~0.6.0:
|
||||
version "0.6.0"
|
||||
resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac"
|
||||
|
||||
@@ -5151,6 +5226,13 @@ defer-to-connect@^1.0.1:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591"
|
||||
|
||||
deferred-leveldown@~1.2.1:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-1.2.2.tgz#3acd2e0b75d1669924bc0a4b642851131173e1eb"
|
||||
integrity sha512-uukrWD2bguRtXilKt6cAWKyoXrTSMo5m7crUdLfWQmu8kIm88w3QZoUL+6nhpfKVmhHANER6Re3sKoNoZ3IKMA==
|
||||
dependencies:
|
||||
abstract-leveldown "~2.6.0"
|
||||
|
||||
deferred-leveldown@~4.0.0:
|
||||
version "4.0.2"
|
||||
resolved "https://registry.yarnpkg.com/deferred-leveldown/-/deferred-leveldown-4.0.2.tgz#0b0570087827bf480a23494b398f04c128c19a20"
|
||||
@@ -6484,6 +6566,13 @@ find-cache-dir@^0.1.1:
|
||||
mkdirp "^0.5.1"
|
||||
pkg-dir "^1.0.0"
|
||||
|
||||
find-replace@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/find-replace/-/find-replace-3.0.0.tgz#3e7e23d3b05167a76f770c9fbd5258b0def68c38"
|
||||
integrity sha512-6Tb2myMioCAgv5kfvP5/PkZZ/ntTpVK39fHY7WkWBgvbeE+VHd/tZuZ4mrC+bxh4cfOZeYKVPaJIZtZXV7GNCQ==
|
||||
dependencies:
|
||||
array-back "^3.0.1"
|
||||
|
||||
find-up@3.0.0, find-up@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73"
|
||||
@@ -6638,7 +6727,7 @@ fs-extra@^4.0.2, fs-extra@^4.0.3:
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs-extra@^7.0.1:
|
||||
fs-extra@^7.0.0, fs-extra@^7.0.1:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.1.tgz#4f189c44aa123b895f722804f55ea23eadc348e9"
|
||||
dependencies:
|
||||
@@ -6978,6 +7067,18 @@ glob@7.1.6, glob@^7.0.0, glob@^7.0.3, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2, glo
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
glob@7.1.7:
|
||||
version "7.1.7"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.7.tgz#3b193e9233f01d42d0b3f78294bbeeb418f94a90"
|
||||
integrity sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.4"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
glob@^5.0.15:
|
||||
version "5.0.15"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
|
||||
@@ -7379,6 +7480,11 @@ ignore@^4.0.3, ignore@^4.0.6:
|
||||
version "4.0.6"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc"
|
||||
|
||||
immediate@^3.2.3:
|
||||
version "3.3.0"
|
||||
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.3.0.tgz#1aef225517836bcdf7f2a2de2600c79ff0269266"
|
||||
integrity sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==
|
||||
|
||||
immediate@~3.2.3:
|
||||
version "3.2.3"
|
||||
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.2.3.tgz#d140fa8f614659bd6541233097ddaac25cdd991c"
|
||||
@@ -8239,12 +8345,31 @@ level-codec@^9.0.0:
|
||||
dependencies:
|
||||
buffer "^5.6.0"
|
||||
|
||||
level-codec@~7.0.0:
|
||||
version "7.0.1"
|
||||
resolved "https://registry.yarnpkg.com/level-codec/-/level-codec-7.0.1.tgz#341f22f907ce0f16763f24bddd681e395a0fb8a7"
|
||||
integrity sha512-Ua/R9B9r3RasXdRmOtd+t9TCOEIIlts+TN/7XTT2unhDaL6sJn83S3rUyljbr6lVtw49N3/yA0HHjpV6Kzb2aQ==
|
||||
|
||||
level-errors@^1.0.3:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.1.2.tgz#4399c2f3d3ab87d0625f7e3676e2d807deff404d"
|
||||
integrity sha512-Sw/IJwWbPKF5Ai4Wz60B52yj0zYeqzObLh8k1Tk88jVmD51cJSKWSYpRyhVIvFzZdvsPqlH5wfhp/yxdsaQH4w==
|
||||
dependencies:
|
||||
errno "~0.1.1"
|
||||
|
||||
level-errors@^2.0.0, level-errors@~2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-2.0.1.tgz#2132a677bf4e679ce029f517c2f17432800c05c8"
|
||||
dependencies:
|
||||
errno "~0.1.1"
|
||||
|
||||
level-errors@~1.0.3:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/level-errors/-/level-errors-1.0.5.tgz#83dbfb12f0b8a2516bdc9a31c4876038e227b859"
|
||||
integrity sha512-/cLUpQduF6bNrWuAC4pwtUKA5t669pCsCi2XbmojG2tFeOr9j6ShtdDCtFFQO1DRt+EVZhx9gPzP9G2bUaG4ig==
|
||||
dependencies:
|
||||
errno "~0.1.1"
|
||||
|
||||
level-iterator-stream@^2.0.3:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-2.0.3.tgz#ccfff7c046dcf47955ae9a86f46dfa06a31688b4"
|
||||
@@ -8253,6 +8378,16 @@ level-iterator-stream@^2.0.3:
|
||||
readable-stream "^2.0.5"
|
||||
xtend "^4.0.0"
|
||||
|
||||
level-iterator-stream@~1.3.0:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-1.3.1.tgz#e43b78b1a8143e6fa97a4f485eb8ea530352f2ed"
|
||||
integrity sha1-5Dt4sagUPm+pek9IXrjqUwNS8u0=
|
||||
dependencies:
|
||||
inherits "^2.0.1"
|
||||
level-errors "^1.0.3"
|
||||
readable-stream "^1.0.33"
|
||||
xtend "^4.0.0"
|
||||
|
||||
level-iterator-stream@~3.0.0:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/level-iterator-stream/-/level-iterator-stream-3.0.1.tgz#2c98a4f8820d87cdacab3132506815419077c730"
|
||||
@@ -8296,6 +8431,14 @@ level-sublevel@6.6.4:
|
||||
typewiselite "~1.0.0"
|
||||
xtend "~4.0.0"
|
||||
|
||||
level-ws@0.0.0:
|
||||
version "0.0.0"
|
||||
resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-0.0.0.tgz#372e512177924a00424b0b43aef2bb42496d228b"
|
||||
integrity sha1-Ny5RIXeSSgBCSwtDrvK7QkltIos=
|
||||
dependencies:
|
||||
readable-stream "~1.0.15"
|
||||
xtend "~2.1.1"
|
||||
|
||||
level-ws@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/level-ws/-/level-ws-1.0.0.tgz#19a22d2d4ac57b18cc7c6ecc4bd23d899d8f603b"
|
||||
@@ -8313,6 +8456,19 @@ levelup@3.1.1, levelup@^3.0.0:
|
||||
level-iterator-stream "~3.0.0"
|
||||
xtend "~4.0.0"
|
||||
|
||||
levelup@^1.2.1:
|
||||
version "1.3.9"
|
||||
resolved "https://registry.yarnpkg.com/levelup/-/levelup-1.3.9.tgz#2dbcae845b2bb2b6bea84df334c475533bbd82ab"
|
||||
integrity sha512-VVGHfKIlmw8w1XqpGOAGwq6sZm2WwWLmlDcULkKWQXEA5EopA8OBNJ2Ck2v6bdk8HeEZSbCSEgzXadyQFm76sQ==
|
||||
dependencies:
|
||||
deferred-leveldown "~1.2.1"
|
||||
level-codec "~7.0.0"
|
||||
level-errors "~1.0.3"
|
||||
level-iterator-stream "~1.3.0"
|
||||
prr "~1.0.1"
|
||||
semver "~5.4.1"
|
||||
xtend "~4.0.0"
|
||||
|
||||
levn@^0.3.0, levn@~0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"
|
||||
@@ -8392,6 +8548,11 @@ lodash._reinterpolate@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
|
||||
|
||||
lodash.camelcase@^4.3.0:
|
||||
version "4.3.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
|
||||
integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY=
|
||||
|
||||
lodash.clonedeep@^4.5.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
|
||||
@@ -8679,6 +8840,18 @@ mem@^4.0.0:
|
||||
mimic-fn "^2.0.0"
|
||||
p-is-promise "^2.0.0"
|
||||
|
||||
memdown@^1.0.0:
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/memdown/-/memdown-1.4.1.tgz#b4e4e192174664ffbae41361aa500f3119efe215"
|
||||
integrity sha1-tOThkhdGZP+65BNhqlAPMRnv4hU=
|
||||
dependencies:
|
||||
abstract-leveldown "~2.7.1"
|
||||
functional-red-black-tree "^1.0.1"
|
||||
immediate "^3.2.3"
|
||||
inherits "~2.0.1"
|
||||
ltgt "~2.2.0"
|
||||
safe-buffer "~5.1.1"
|
||||
|
||||
memdown@~3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/memdown/-/memdown-3.0.0.tgz#93aca055d743b20efc37492e9e399784f2958309"
|
||||
@@ -8753,7 +8926,7 @@ merge2@^1.2.3:
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
|
||||
|
||||
merkle-patricia-tree@3.0.0, merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2:
|
||||
merkle-patricia-tree@3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-3.0.0.tgz#448d85415565df72febc33ca362b8b614f5a58f8"
|
||||
dependencies:
|
||||
@@ -8765,6 +8938,20 @@ merkle-patricia-tree@3.0.0, merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2
|
||||
rlp "^2.0.0"
|
||||
semaphore ">=1.0.1"
|
||||
|
||||
merkle-patricia-tree@^2.1.2, merkle-patricia-tree@^2.3.2:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.yarnpkg.com/merkle-patricia-tree/-/merkle-patricia-tree-2.3.2.tgz#982ca1b5a0fde00eed2f6aeed1f9152860b8208a"
|
||||
integrity sha512-81PW5m8oz/pz3GvsAwbauj7Y00rqm81Tzad77tHBwU7pIAtN+TJnMSOJhxBKflSVYhptMMb9RskhqHqrSm1V+g==
|
||||
dependencies:
|
||||
async "^1.4.2"
|
||||
ethereumjs-util "^5.0.0"
|
||||
level-ws "0.0.0"
|
||||
levelup "^1.2.1"
|
||||
memdown "^1.0.0"
|
||||
readable-stream "^2.0.0"
|
||||
rlp "^2.0.0"
|
||||
semaphore ">=1.0.1"
|
||||
|
||||
methods@~1.1.2:
|
||||
version "1.1.2"
|
||||
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
|
||||
@@ -8943,7 +9130,7 @@ mkdirp-promise@^5.0.1:
|
||||
dependencies:
|
||||
mkdirp "*"
|
||||
|
||||
mkdirp@*, mkdirp@^1.0.3:
|
||||
mkdirp@*, mkdirp@^1.0.3, mkdirp@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
||||
|
||||
@@ -10101,6 +10288,11 @@ prettier@^2.0.5:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5"
|
||||
|
||||
prettier@^2.3.1:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.2.tgz#e26d71a18a74c3d0f0597f55f01fb6c06c206032"
|
||||
integrity sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==
|
||||
|
||||
pretty-bytes@^1.0.4:
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-1.0.4.tgz#0a22e8210609ad35542f8c8d5d2159aff0751c84"
|
||||
@@ -10533,7 +10725,7 @@ read@1, read@1.0.x, read@~1.0.1, read@~1.0.5:
|
||||
string_decoder "^1.1.1"
|
||||
util-deprecate "^1.0.1"
|
||||
|
||||
"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.26:
|
||||
"readable-stream@>=1.0.33-1 <1.1.0-0", readable-stream@~1.0.15, readable-stream@~1.0.26:
|
||||
version "1.0.34"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c"
|
||||
dependencies:
|
||||
@@ -10542,7 +10734,7 @@ read@1, read@1.0.x, read@~1.0.1, read@~1.0.5:
|
||||
isarray "0.0.1"
|
||||
string_decoder "~0.10.x"
|
||||
|
||||
readable-stream@~1.1.9:
|
||||
readable-stream@^1.0.33, readable-stream@~1.1.9:
|
||||
version "1.1.14"
|
||||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.1.14.tgz#7cf4c54ef648e3813084c636dd2079e166c081d9"
|
||||
dependencies:
|
||||
@@ -10599,6 +10791,11 @@ redent@^3.0.0:
|
||||
indent-string "^4.0.0"
|
||||
strip-indent "^3.0.0"
|
||||
|
||||
reduce-flatten@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/reduce-flatten/-/reduce-flatten-2.0.0.tgz#734fd84e65f375d7ca4465c69798c25c9d10ae27"
|
||||
integrity sha512-EJ4UNY/U1t2P/2k6oqotuX2Cc3T6nxJwsM0N0asT7dhrtH1ltUxDn4NalSYmPE2rCkVpcf/X6R0wDwcFpzhd4w==
|
||||
|
||||
regenerate@^1.2.1:
|
||||
version "1.4.1"
|
||||
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.1.tgz#cad92ad8e6b591773485fbe05a485caf4f457e6f"
|
||||
@@ -11006,6 +11203,11 @@ semver@^7.3.4:
|
||||
dependencies:
|
||||
lru-cache "^6.0.0"
|
||||
|
||||
semver@~5.4.1:
|
||||
version "5.4.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
||||
integrity sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==
|
||||
|
||||
send@0.17.1:
|
||||
version "0.17.1"
|
||||
resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8"
|
||||
@@ -11474,6 +11676,11 @@ string-editor@^0.1.0:
|
||||
dependencies:
|
||||
editor "^1.0.0"
|
||||
|
||||
string-format@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/string-format/-/string-format-2.0.0.tgz#f2df2e7097440d3b65de31b6d40d54c96eaffb9b"
|
||||
integrity sha512-bbEs3scLeYNXLecRRuk6uJxdXUSj6le/8rNPHChIJTn2V79aXVTR1EH2OH5zLKKoz0V02fOUKZZcw01pLUShZA==
|
||||
|
||||
string-width@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"
|
||||
@@ -11709,6 +11916,16 @@ swarm-js@^0.1.40:
|
||||
tar "^4.0.2"
|
||||
xhr-request "^1.0.1"
|
||||
|
||||
table-layout@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/table-layout/-/table-layout-1.0.2.tgz#c4038a1853b0136d63365a734b6931cf4fad4a04"
|
||||
integrity sha512-qd/R7n5rQTRFi+Zf2sk5XVVd9UQl6ZkduPFC3S7WEGJAmetDTjY3qPN50eSKzwuzEyQKy5TN2TiZdkIjos2L6A==
|
||||
dependencies:
|
||||
array-back "^4.0.1"
|
||||
deep-extend "~0.6.0"
|
||||
typical "^5.2.0"
|
||||
wordwrapjs "^4.0.0"
|
||||
|
||||
table@^5.2.3:
|
||||
version "5.4.6"
|
||||
resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
|
||||
@@ -12034,6 +12251,21 @@ truffle@^5.0.32:
|
||||
mocha "8.1.2"
|
||||
original-require "1.0.1"
|
||||
|
||||
ts-command-line-args@^2.2.0:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/ts-command-line-args/-/ts-command-line-args-2.3.1.tgz#b6188e42efc6cf7a8898e438a873fbb15505ddd6"
|
||||
integrity sha512-FR3y7pLl/fuUNSmnPhfLArGqRrpojQgIEEOVzYx9DhTmfIN7C9RWSfpkJEF4J+Gk7aVx5pak8I7vWZsaN4N84g==
|
||||
dependencies:
|
||||
chalk "^4.1.0"
|
||||
command-line-args "^5.1.1"
|
||||
command-line-usage "^6.1.0"
|
||||
string-format "^2.0.0"
|
||||
|
||||
ts-essentials@^7.0.1:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/ts-essentials/-/ts-essentials-7.0.3.tgz#686fd155a02133eedcc5362dc8b5056cde3e5a38"
|
||||
integrity sha512-8+gr5+lqO3G84KdiTSMRLtuyJ+nTBVRKuCrK4lidMPdVeEp0uqC875uE5NMcaA7YYMN7XsNiFQuMvasF8HT/xQ==
|
||||
|
||||
tslib@1.9.0:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"
|
||||
@@ -12150,6 +12382,22 @@ type@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/type/-/type-2.1.0.tgz#9bdc22c648cf8cf86dd23d32336a41cfb6475e3f"
|
||||
|
||||
typechain@^8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.0.0.tgz#a5dbe754717a7e16247df52b5285903de600e8ff"
|
||||
integrity sha512-rqDfDYc9voVAhmfVfAwzg3VYFvhvs5ck1X9T/iWkX745Cul4t+V/smjnyqrbDzWDbzD93xfld1epg7Y/uFAesQ==
|
||||
dependencies:
|
||||
"@types/prettier" "^2.1.1"
|
||||
debug "^4.3.1"
|
||||
fs-extra "^7.0.0"
|
||||
glob "7.1.7"
|
||||
js-sha3 "^0.8.0"
|
||||
lodash "^4.17.15"
|
||||
mkdirp "^1.0.4"
|
||||
prettier "^2.3.1"
|
||||
ts-command-line-args "^2.2.0"
|
||||
ts-essentials "^7.0.1"
|
||||
|
||||
typedarray-to-buffer@^3.1.5:
|
||||
version "3.1.5"
|
||||
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
|
||||
@@ -12227,6 +12475,16 @@ typewiselite@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/typewiselite/-/typewiselite-1.0.0.tgz#c8882fa1bb1092c06005a97f34ef5c8508e3664e"
|
||||
|
||||
typical@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/typical/-/typical-4.0.0.tgz#cbeaff3b9d7ae1e2bbfaf5a4e6f11eccfde94fc4"
|
||||
integrity sha512-VAH4IvQ7BDFYglMd7BPRDfLgxZZX4O4TFcRDA6EN5X7erNJJq+McIEp8np9aVtxrCJ6qx4GTYVfOWNjcqwZgRw==
|
||||
|
||||
typical@^5.2.0:
|
||||
version "5.2.0"
|
||||
resolved "https://registry.yarnpkg.com/typical/-/typical-5.2.0.tgz#4daaac4f2b5315460804f0acf6cb69c52bb93066"
|
||||
integrity sha512-dvdQgNDNJo+8B2uBQoqdb11eUCE1JQXhvjC/CZtgvZseVd5TYMXnq0+vuUemXbd/Se29cTaUuPX3YIc2xgbvIg==
|
||||
|
||||
u2f-api@0.2.7:
|
||||
version "0.2.7"
|
||||
resolved "https://registry.yarnpkg.com/u2f-api/-/u2f-api-0.2.7.tgz#17bf196b242f6bf72353d9858e6a7566cc192720"
|
||||
@@ -13237,6 +13495,14 @@ wordwrap@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
|
||||
|
||||
wordwrapjs@^4.0.0:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/wordwrapjs/-/wordwrapjs-4.0.1.tgz#d9790bccfb110a0fc7836b5ebce0937b37a8b98f"
|
||||
integrity sha512-kKlNACbvHrkpIw6oPeYDSmdCTu2hdMHoyXLTcUKala++lx5Y+wjJ/e474Jqv5abnVmwxw08DiTuHmw69lJGksA==
|
||||
dependencies:
|
||||
reduce-flatten "^2.0.0"
|
||||
typical "^5.2.0"
|
||||
|
||||
workerpool@6.0.0:
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.0.0.tgz#85aad67fa1a2c8ef9386a1b43539900f61d03d58"
|
||||
|
Reference in New Issue
Block a user