diff --git a/LICENSE b/LICENSE
index 261eeb9e..331f7cfa 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,201 +1,661 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
- 1. Definitions.
+ Preamble
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
+ The GNU Affero General Public License is a free, copyleft license for
+ software and other kinds of works, specifically designed to ensure
+ cooperation with the community in the case of network server software.
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
+ The licenses for most software and other practical works are designed
+ to take away your freedom to share and change the works. By contrast,
+ our General Public Licenses are 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.
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
+ 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.
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
+ Developers that use our General Public Licenses protect your rights
+ with two steps: (1) assert copyright on the software, and (2) offer
+ you this License which gives you legal permission to copy, distribute
+ and/or modify the software.
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
+ A secondary benefit of defending all users' freedom is that
+ improvements made in alternate versions of the program, if they
+ receive widespread use, become available for other developers to
+ incorporate. Many developers of free software are heartened and
+ encouraged by the resulting cooperation. However, in the case of
+ software used on network servers, this result may fail to come about.
+ The GNU General Public License permits making a modified version and
+ letting the public access it on a server without ever releasing its
+ source code to the public.
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
+ The GNU Affero General Public License is designed specifically to
+ ensure that, in such cases, the modified source code becomes available
+ to the community. It requires the operator of a network server to
+ provide the source code of the modified version running there to the
+ users of that server. Therefore, public use of a modified version, on
+ a publicly accessible server, gives the public access to the source
+ code of the modified version.
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
+ An older license, called the Affero General Public License and
+ published by Affero, was designed to accomplish similar goals. This is
+ a different license, not a version of the Affero GPL, but Affero has
+ released a new version of the Affero GPL which permits relicensing under
+ this license.
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
+ The precise terms and conditions for copying, distribution and
+ modification follow.
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
+ TERMS AND CONDITIONS
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
+ 0. Definitions.
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
+ "This License" refers to version 3 of the GNU Affero General Public License.
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
+ "Copyright" also means copyright-like laws that apply to other kinds of
+ works, such as semiconductor masks.
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
+ "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.
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
+ 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.
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
+ A "covered work" means either the unmodified Program or a work based
+ on the Program.
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
+ 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.
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
+ 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.
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
+ 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.
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
+ 1. Source Code.
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
+ 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.
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
+ 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.
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
+ 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.
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
+ 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.
- END OF TERMS AND CONDITIONS
+ The Corresponding Source need not include anything that users
+ can regenerate automatically from other parts of the Corresponding
+ Source.
- APPENDIX: How to apply the Apache License to your work.
+ The Corresponding Source for a work in source code form is that
+ same work.
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
+ 2. Basic Permissions.
- Copyright [yyyy] [name of copyright owner]
+ 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.
- 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
+ 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.
- http://www.apache.org/licenses/LICENSE-2.0
+ Conveying under any other circumstances is permitted solely under
+ the conditions stated below. Sublicensing is not allowed; section 10
+ makes it unnecessary.
- 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.
+ 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. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+ Program, your modified version must prominently offer all users
+ interacting with it remotely through a computer network (if your version
+ supports such interaction) an opportunity to receive the Corresponding
+ Source of your version by providing access to the Corresponding Source
+ from a network server at no charge, through some standard or customary
+ means of facilitating copying of software. This Corresponding Source
+ shall include the Corresponding Source for any work covered by version 3
+ of the GNU General Public License that is incorporated pursuant to the
+ following paragraph.
+
+ 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 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 work with which it is combined will remain governed by version
+ 3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+ the GNU Affero 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 Affero 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 Affero 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 Affero 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.
+
+
+ Copyright (C)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+ Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+ network, you should also make sure that it provides a way for users to
+ get its source. For example, if your program is a web application, its
+ interface could display a "Source" link that leads users to an archive
+ of the code. There are many ways you could offer source, and different
+ solutions will be better for different programs; see section 13 for the
+ specific requirements.
+
+ 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 AGPL, see
+ .
diff --git a/cmd/coldImport.go b/cmd/coldImport.go
index d7265cb5..d5a4d589 100644
--- a/cmd/coldImport.go
+++ b/cmd/coldImport.go
@@ -1,16 +1,18 @@
+// VulcanizeDB
// Copyright © 2018 Vulcanize
-//
-// 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.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package cmd
diff --git a/cmd/erc20.go b/cmd/erc20.go
index 71d86200..d320793c 100644
--- a/cmd/erc20.go
+++ b/cmd/erc20.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package cmd
@@ -22,7 +24,6 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/spf13/cobra"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/every_block"
"github.com/vulcanize/vulcanizedb/examples/generic"
@@ -32,6 +33,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
// erc20Cmd represents the erc20 command
diff --git a/cmd/lightSync.go b/cmd/lightSync.go
index 242c1e53..cf054fde 100644
--- a/cmd/lightSync.go
+++ b/cmd/lightSync.go
@@ -1,16 +1,18 @@
+// VulcanizeDB
// Copyright © 2018 Vulcanize
-//
-// 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.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package cmd
diff --git a/cmd/omniWatcher.go b/cmd/omniWatcher.go
index d08c3b16..004aac8c 100644
--- a/cmd/omniWatcher.go
+++ b/cmd/omniWatcher.go
@@ -1,22 +1,25 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package cmd
import (
"bufio"
"fmt"
+ "github.com/vulcanize/vulcanizedb/pkg/core"
"log"
"os"
"strings"
@@ -33,7 +36,6 @@ import (
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
"github.com/vulcanize/vulcanizedb/pkg/omni/transformer"
- "github.com/vulcanize/vulcanizedb/pkg/omni/types"
)
// omniWatcherCmd represents the omniWatcher command
@@ -64,20 +66,16 @@ func omniWatcher() {
log.Fatal("Contract address required")
}
- if !methodsOn && !eventsOn {
- log.Fatal("Method polling and event watching turned off- nothing to do!")
- }
-
if len(contractEvents) == 0 || len(contractMethods) == 0 {
var str string
for str != "y" {
reader := bufio.NewReader(os.Stdin)
if len(contractEvents) == 0 && len(contractMethods) == 0 {
- fmt.Print("Warning: no events or methods specified, proceed to watch every event and method? (Y/n)\n> ")
+ fmt.Print("Warning: no events or methods specified.\n Proceed to watch every event and poll no methods? (Y/n)\n> ")
} else if len(contractEvents) == 0 {
- fmt.Print("Warning: no events specified, proceed to watch every event? (Y/n)\n> ")
+ fmt.Print("Warning: no events specified.\n Proceed to watch every event? (Y/n)\n> ")
} else {
- fmt.Print("Warning: no methods specified, proceed to watch every method? (Y/n)\n> ")
+ fmt.Print("Warning: no methods specified.\n Proceed to poll no methods? (Y/n)\n> ")
}
resp, err := reader.ReadBytes('\n')
if err != nil {
@@ -94,37 +92,20 @@ func omniWatcher() {
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()
- rawRpcClient, err := rpc.Dial(ipc)
- if err != nil {
- log.Fatal(fmt.Sprintf("Failed to initialize rpc client\r\nerr: %v\r\n", err))
- }
+ blockChain, db := setupBCandDB()
- rpcClient := client.NewRpcClient(rawRpcClient, ipc)
- ethClient := ethclient.NewClient(rawRpcClient)
- client := client.NewEthClient(ethClient)
- node := node.MakeNode(rpcClient)
- transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
- blockChain := geth.NewBlockChain(client, node, transactionConverter)
- db, err := postgres.NewDB(databaseConfig, blockChain.Node())
- if err != nil {
- log.Fatal(fmt.Sprintf("Failed to initialize database\r\nerr: %v\r\n", err))
- }
-
- con := types.Config{
- DB: db,
- BC: blockChain,
- Network: network,
- }
-
- t := transformer.NewTransformer(&con)
+ t := transformer.NewTransformer(network, blockChain, db)
contractAddresses = append(contractAddresses, contractAddress)
for _, addr := range contractAddresses {
t.SetEvents(addr, contractEvents)
t.SetMethods(addr, contractMethods)
+ t.SetEventAddrs(addr, eventAddrs)
+ t.SetMethodAddrs(addr, methodAddrs)
+ t.SetRange(addr, [2]int64{startingBlockNumber, endingBlockNumber})
}
- err = t.Init()
+ err := t.Init()
if err != nil {
log.Fatal(fmt.Sprintf("Failed to initialized transformer\r\nerr: %v\r\n", err))
}
@@ -141,11 +122,32 @@ func init() {
rootCmd.AddCommand(omniWatcherCmd)
omniWatcherCmd.Flags().StringVarP(&contractAddress, "contract-address", "a", "", "Single address to generate watchers for")
- omniWatcherCmd.Flags().StringArrayVarP(&contractAddresses, "contract-addresses", "l", []string{}, "List of addresses to generate watchers for")
- omniWatcherCmd.Flags().BoolVarP(&eventsOn, "events-on", "o", true, "Set to false to turn off watching of any event")
- omniWatcherCmd.Flags().BoolVarP(&methodsOn, "methods-on", "p", true, "Set to false to turn off polling of any method")
- omniWatcherCmd.Flags().StringVarP(&contractAddress, "methods-off", "a", "", "Single address to generate watchers for")
+ omniWatcherCmd.Flags().StringArrayVarP(&contractAddresses, "contract-addresses", "l", []string{}, "list of addresses to use; warning: watcher targets the same events and methods for each address")
omniWatcherCmd.Flags().StringArrayVarP(&contractEvents, "contract-events", "e", []string{}, "Subset of events to watch; by default all events are watched")
- omniWatcherCmd.Flags().StringArrayVarP(&contractEvents, "contract-methods", "m", []string{}, "Subset of methods to watch; by default all methods are watched")
+ omniWatcherCmd.Flags().StringArrayVarP(&contractEvents, "contract-methods", "m", nil, "Subset of methods to poll; by default no methods are polled")
+ omniWatcherCmd.Flags().StringArrayVarP(&eventAddrs, "event-filter-addresses", "f", []string{}, "Account addresses to persist event data for; default is to persist for all found token holder addresses")
+ omniWatcherCmd.Flags().StringArrayVarP(&methodAddrs, "method-filter-addresses", "g", []string{}, "Account addresses to poll methods with; default is to poll with all found token holder addresses")
omniWatcherCmd.Flags().StringVarP(&network, "network", "n", "", `Network the contract is deployed on; options: "ropsten", "kovan", and "rinkeby"; default is mainnet"`)
+ omniWatcherCmd.Flags().Int64VarP(&startingBlockNumber, "starting-block-number", "s", 0, "Block to begin watching- default is first block the contract exists")
+ omniWatcherCmd.Flags().Int64VarP(&startingBlockNumber, "ending-block-number", "d", -1, "Block to end watching- default is most recent block")
+}
+
+func setupBCandDB() (core.BlockChain, *postgres.DB) {
+ rawRpcClient, err := rpc.Dial(ipc)
+ if err != nil {
+ log.Fatal(fmt.Sprintf("Failed to initialize rpc client\r\nerr: %v\r\n", err))
+ }
+
+ rpcClient := client.NewRpcClient(rawRpcClient, ipc)
+ ethClient := ethclient.NewClient(rawRpcClient)
+ cli := client.NewEthClient(ethClient)
+ n := node.MakeNode(rpcClient)
+ transactionConverter := vRpc.NewRpcTransactionConverter(ethClient)
+ blockChain := geth.NewBlockChain(cli, n, transactionConverter)
+ db, err := postgres.NewDB(databaseConfig, blockChain.Node())
+ if err != nil {
+ log.Fatal(fmt.Sprintf("Failed to initialize database\r\nerr: %v\r\n", err))
+ }
+
+ return blockChain, db
}
diff --git a/cmd/root.go b/cmd/root.go
index 003d0d7a..c906fa73 100644
--- a/cmd/root.go
+++ b/cmd/root.go
@@ -1,16 +1,18 @@
+// VulcanizeDB
// Copyright © 2018 Vulcanize
-//
-// 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.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package cmd
@@ -35,10 +37,10 @@ var (
network string
contractAddress string
contractAddresses []string
- eventsOn bool
- methodsOn bool
contractEvents []string
contractMethods []string
+ eventAddrs []string
+ methodAddrs []string
)
var rootCmd = &cobra.Command{
diff --git a/cmd/sync.go b/cmd/sync.go
index 99d89973..f3ac57eb 100644
--- a/cmd/sync.go
+++ b/cmd/sync.go
@@ -1,16 +1,18 @@
+// VulcanizeDB
// Copyright © 2018 Vulcanize
-//
-// 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.
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package cmd
diff --git a/examples/erc20_watcher/event_triggered/dai/converter.go b/examples/erc20_watcher/event_triggered/dai/converter.go
index 50bc2347..62f3e37e 100644
--- a/examples/erc20_watcher/event_triggered/dai/converter.go
+++ b/examples/erc20_watcher/event_triggered/dai/converter.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai
@@ -18,12 +20,12 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/libraries/shared"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
// Converter converts a raw event log into its corresponding entity
diff --git a/examples/erc20_watcher/event_triggered/dai/converter_test.go b/examples/erc20_watcher/event_triggered/dai/converter_test.go
index 1a100e15..12a89795 100644
--- a/examples/erc20_watcher/event_triggered/dai/converter_test.go
+++ b/examples/erc20_watcher/event_triggered/dai/converter_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai_test
@@ -19,12 +21,12 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
"github.com/vulcanize/vulcanizedb/examples/generic"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
var expectedTransferModel = event_triggered.TransferModel{
diff --git a/examples/erc20_watcher/event_triggered/dai/dai_suite_test.go b/examples/erc20_watcher/event_triggered/dai/dai_suite_test.go
index 277c192d..e766c6a6 100644
--- a/examples/erc20_watcher/event_triggered/dai/dai_suite_test.go
+++ b/examples/erc20_watcher/event_triggered/dai/dai_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai_test
diff --git a/examples/erc20_watcher/event_triggered/dai/entity.go b/examples/erc20_watcher/event_triggered/dai/entity.go
index 8a6c27f3..c35931ac 100644
--- a/examples/erc20_watcher/event_triggered/dai/entity.go
+++ b/examples/erc20_watcher/event_triggered/dai/entity.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai
diff --git a/examples/erc20_watcher/event_triggered/dai/integration_test.go b/examples/erc20_watcher/event_triggered/dai/integration_test.go
index d05852df..9f2aeffd 100644
--- a/examples/erc20_watcher/event_triggered/dai/integration_test.go
+++ b/examples/erc20_watcher/event_triggered/dai/integration_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai_test
@@ -18,13 +20,13 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
"github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var transferLog = core.Log{
diff --git a/examples/erc20_watcher/event_triggered/dai/repository_test.go b/examples/erc20_watcher/event_triggered/dai/repository_test.go
index b809c915..c83bbdb4 100644
--- a/examples/erc20_watcher/event_triggered/dai/repository_test.go
+++ b/examples/erc20_watcher/event_triggered/dai/repository_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai_test
@@ -24,12 +26,12 @@ import (
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
var transferEntity = &dai.TransferEntity{
diff --git a/examples/erc20_watcher/event_triggered/dai/transformer.go b/examples/erc20_watcher/event_triggered/dai/transformer.go
index deaa07e0..558b9a8c 100644
--- a/examples/erc20_watcher/event_triggered/dai/transformer.go
+++ b/examples/erc20_watcher/event_triggered/dai/transformer.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai
@@ -18,7 +20,6 @@ import (
"fmt"
"log"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered"
"github.com/vulcanize/vulcanizedb/libraries/shared"
"github.com/vulcanize/vulcanizedb/pkg/core"
@@ -26,6 +27,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/filters"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
type ERC20EventTransformer struct {
diff --git a/examples/erc20_watcher/event_triggered/dai/transformer_test.go b/examples/erc20_watcher/event_triggered/dai/transformer_test.go
index 722eadd2..9ee27261 100644
--- a/examples/erc20_watcher/event_triggered/dai/transformer_test.go
+++ b/examples/erc20_watcher/event_triggered/dai/transformer_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai_test
@@ -18,10 +20,10 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/event_triggered/dai"
"github.com/vulcanize/vulcanizedb/examples/mocks"
"github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var blockID1 = int64(5428074)
diff --git a/examples/erc20_watcher/event_triggered/dai/transformers.go b/examples/erc20_watcher/event_triggered/dai/transformers.go
index d93e9ed9..665d86d0 100644
--- a/examples/erc20_watcher/event_triggered/dai/transformers.go
+++ b/examples/erc20_watcher/event_triggered/dai/transformers.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package dai
diff --git a/examples/erc20_watcher/event_triggered/model.go b/examples/erc20_watcher/event_triggered/model.go
index cc0d9199..5cc728d1 100644
--- a/examples/erc20_watcher/event_triggered/model.go
+++ b/examples/erc20_watcher/event_triggered/model.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package event_triggered
diff --git a/examples/erc20_watcher/event_triggered/repository.go b/examples/erc20_watcher/event_triggered/repository.go
index d9238a69..d5cf100a 100644
--- a/examples/erc20_watcher/event_triggered/repository.go
+++ b/examples/erc20_watcher/event_triggered/repository.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package event_triggered
diff --git a/examples/erc20_watcher/every_block/every_block_suite_test.go b/examples/erc20_watcher/every_block/every_block_suite_test.go
index dd5aa214..ae7c269a 100644
--- a/examples/erc20_watcher/every_block/every_block_suite_test.go
+++ b/examples/erc20_watcher/every_block/every_block_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
diff --git a/examples/erc20_watcher/every_block/getter.go b/examples/erc20_watcher/every_block/getter.go
index 4574440b..02cb15d1 100644
--- a/examples/erc20_watcher/every_block/getter.go
+++ b/examples/erc20_watcher/every_block/getter.go
@@ -1,23 +1,25 @@
-// Copyright 2018 Vulcanize
-//
-// 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 og 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 Og ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block
import (
+ "github.com/vulcanize/vulcanizedb/examples/generic"
"math/big"
- "github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
@@ -33,13 +35,13 @@ type ERC20GetterInterface interface {
// Getter struct
type ERC20Getter struct {
- fetcher generic.Fetcher
+ generic.Fetcher
}
// Initializes and returns a Getter with the given blockchain
func NewGetter(blockChain core.BlockChain) ERC20Getter {
return ERC20Getter{
- fetcher: generic.Fetcher{
+ Fetcher: generic.Fetcher{
BlockChain: blockChain,
},
}
@@ -47,18 +49,18 @@ func NewGetter(blockChain core.BlockChain) ERC20Getter {
// Public getter methods for calling contract methods
func (g ERC20Getter) GetTotalSupply(contractAbi, contractAddress string, blockNumber int64) (big.Int, error) {
- return g.fetcher.FetchBigInt("totalSupply", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchBigInt("totalSupply", contractAbi, contractAddress, blockNumber, nil)
}
func (g ERC20Getter) GetBalance(contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (big.Int, error) {
- return g.fetcher.FetchBigInt("balanceOf", contractAbi, contractAddress, blockNumber, methodArgs)
+ return g.Fetcher.FetchBigInt("balanceOf", contractAbi, contractAddress, blockNumber, methodArgs)
}
func (g ERC20Getter) GetAllowance(contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (big.Int, error) {
- return g.fetcher.FetchBigInt("allowance", contractAbi, contractAddress, blockNumber, methodArgs)
+ return g.Fetcher.FetchBigInt("allowance", contractAbi, contractAddress, blockNumber, methodArgs)
}
// Method to retrieve the Getter's blockchain
func (g ERC20Getter) GetBlockChain() core.BlockChain {
- return g.fetcher.BlockChain
+ return g.Fetcher.BlockChain
}
diff --git a/examples/erc20_watcher/every_block/getter_test.go b/examples/erc20_watcher/every_block/getter_test.go
index de8edd6a..136aa341 100644
--- a/examples/erc20_watcher/every_block/getter_test.go
+++ b/examples/erc20_watcher/every_block/getter_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
@@ -23,13 +25,13 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/every_block"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var _ = Describe("ERC20 Getter", func() {
diff --git a/examples/erc20_watcher/every_block/integration_test.go b/examples/erc20_watcher/every_block/integration_test.go
index e093e0a8..91181ccb 100644
--- a/examples/erc20_watcher/every_block/integration_test.go
+++ b/examples/erc20_watcher/every_block/integration_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
@@ -21,7 +23,6 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/every_block"
"github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
@@ -29,6 +30,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
func setLastBlockOnChain(blockChain *fakes.MockBlockChain, blockNumber int64) {
diff --git a/examples/erc20_watcher/every_block/model.go b/examples/erc20_watcher/every_block/model.go
index 60492311..a2b5364b 100644
--- a/examples/erc20_watcher/every_block/model.go
+++ b/examples/erc20_watcher/every_block/model.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block
diff --git a/examples/erc20_watcher/every_block/repository.go b/examples/erc20_watcher/every_block/repository.go
index 317186c4..ad5b7441 100644
--- a/examples/erc20_watcher/every_block/repository.go
+++ b/examples/erc20_watcher/every_block/repository.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block
diff --git a/examples/erc20_watcher/every_block/repository_test.go b/examples/erc20_watcher/every_block/repository_test.go
index 3bba610b..c3472209 100644
--- a/examples/erc20_watcher/every_block/repository_test.go
+++ b/examples/erc20_watcher/every_block/repository_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
diff --git a/examples/erc20_watcher/every_block/transformer.go b/examples/erc20_watcher/every_block/transformer.go
index f5be8aba..bdff1afa 100644
--- a/examples/erc20_watcher/every_block/transformer.go
+++ b/examples/erc20_watcher/every_block/transformer.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block
diff --git a/examples/erc20_watcher/every_block/transformer_test.go b/examples/erc20_watcher/every_block/transformer_test.go
index 0caa88a4..78da9e31 100644
--- a/examples/erc20_watcher/every_block/transformer_test.go
+++ b/examples/erc20_watcher/every_block/transformer_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
@@ -22,13 +24,13 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher"
"github.com/vulcanize/vulcanizedb/examples/erc20_watcher/every_block"
"github.com/vulcanize/vulcanizedb/examples/mocks"
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
"github.com/vulcanize/vulcanizedb/libraries/shared"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var testContractConfig = shared.ContractConfig{
diff --git a/examples/erc20_watcher/every_block/transformers.go b/examples/erc20_watcher/every_block/transformers.go
index 58df35a5..8a58c2b7 100644
--- a/examples/erc20_watcher/every_block/transformers.go
+++ b/examples/erc20_watcher/every_block/transformers.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block
diff --git a/examples/erc20_watcher/retriever.go b/examples/erc20_watcher/retriever.go
index eddcf225..02232a5a 100644
--- a/examples/erc20_watcher/retriever.go
+++ b/examples/erc20_watcher/retriever.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package erc20_watcher
diff --git a/examples/generic/config.go b/examples/generic/config.go
index 7419e10e..c5f43f41 100644
--- a/examples/generic/config.go
+++ b/examples/generic/config.go
@@ -1,22 +1,24 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package generic
import (
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/libraries/shared"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var DaiConfig = shared.ContractConfig{
diff --git a/examples/generic/event_triggered/model.go b/examples/generic/event_triggered/model.go
index 680ac2ab..d8a6299e 100644
--- a/examples/generic/event_triggered/model.go
+++ b/examples/generic/event_triggered/model.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package event_triggered
diff --git a/examples/generic/event_triggered/repository.go b/examples/generic/event_triggered/repository.go
index 922589a6..b0904b76 100644
--- a/examples/generic/event_triggered/repository.go
+++ b/examples/generic/event_triggered/repository.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package event_triggered
diff --git a/examples/generic/event_triggered/tusd/converter.go b/examples/generic/event_triggered/tusd/converter.go
index 5e3d77ef..167adc00 100644
--- a/examples/generic/event_triggered/tusd/converter.go
+++ b/examples/generic/event_triggered/tusd/converter.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd
@@ -18,12 +20,12 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/libraries/shared"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
// Converter converts a raw event log into its corresponding entity
diff --git a/examples/generic/event_triggered/tusd/converter_test.go b/examples/generic/event_triggered/tusd/converter_test.go
index e576ced8..cf6d4c34 100644
--- a/examples/generic/event_triggered/tusd/converter_test.go
+++ b/examples/generic/event_triggered/tusd/converter_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd_test
@@ -19,12 +21,12 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
var expectedBurnModel = event_triggered.BurnModel{
diff --git a/examples/generic/event_triggered/tusd/entity.go b/examples/generic/event_triggered/tusd/entity.go
index 0f46f74a..a3e07018 100644
--- a/examples/generic/event_triggered/tusd/entity.go
+++ b/examples/generic/event_triggered/tusd/entity.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd
diff --git a/examples/generic/event_triggered/tusd/integration_test.go b/examples/generic/event_triggered/tusd/integration_test.go
index 919e1dcd..915fe402 100644
--- a/examples/generic/event_triggered/tusd/integration_test.go
+++ b/examples/generic/event_triggered/tusd/integration_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd_test
@@ -18,13 +20,13 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var burnLog = core.Log{
diff --git a/examples/generic/event_triggered/tusd/repository_test.go b/examples/generic/event_triggered/tusd/repository_test.go
index 3b6b15bc..4b7b1bb1 100644
--- a/examples/generic/event_triggered/tusd/repository_test.go
+++ b/examples/generic/event_triggered/tusd/repository_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd_test
@@ -24,12 +26,12 @@ import (
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/examples/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
var burnEntity = &tusd.BurnEntity{
diff --git a/examples/generic/event_triggered/tusd/transformer.go b/examples/generic/event_triggered/tusd/transformer.go
index 1195e004..7e8ca95e 100644
--- a/examples/generic/event_triggered/tusd/transformer.go
+++ b/examples/generic/event_triggered/tusd/transformer.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd
@@ -18,7 +20,6 @@ import (
"fmt"
"log"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered"
"github.com/vulcanize/vulcanizedb/libraries/shared"
"github.com/vulcanize/vulcanizedb/pkg/core"
@@ -26,6 +27,7 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/filters"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
type GenericTransformer struct {
diff --git a/examples/generic/event_triggered/tusd/transformer_test.go b/examples/generic/event_triggered/tusd/transformer_test.go
index 0e94960d..18c4cf16 100644
--- a/examples/generic/event_triggered/tusd/transformer_test.go
+++ b/examples/generic/event_triggered/tusd/transformer_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd_test
@@ -18,10 +20,10 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic/event_triggered/tusd"
"github.com/vulcanize/vulcanizedb/examples/mocks"
"github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var blockID1 = int64(5428074)
diff --git a/examples/generic/event_triggered/tusd/transformers.go b/examples/generic/event_triggered/tusd/transformers.go
index d5612ef3..1bf59f49 100644
--- a/examples/generic/event_triggered/tusd/transformers.go
+++ b/examples/generic/event_triggered/tusd/transformers.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd
diff --git a/examples/generic/event_triggered/tusd/tusd_suite_test.go b/examples/generic/event_triggered/tusd/tusd_suite_test.go
index 81f00eb3..6ab43fa2 100644
--- a/examples/generic/event_triggered/tusd/tusd_suite_test.go
+++ b/examples/generic/event_triggered/tusd/tusd_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package tusd_test
diff --git a/examples/generic/every_block/every_block_suite_test.go b/examples/generic/every_block/every_block_suite_test.go
index e43b72f9..a9228ec9 100644
--- a/examples/generic/every_block/every_block_suite_test.go
+++ b/examples/generic/every_block/every_block_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
diff --git a/examples/generic/every_block/getter.go b/examples/generic/every_block/getter.go
index 2a283024..e8f1e80c 100644
--- a/examples/generic/every_block/getter.go
+++ b/examples/generic/every_block/getter.go
@@ -1,25 +1,27 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block
import (
+ "github.com/vulcanize/vulcanizedb/examples/generic"
"math/big"
"github.com/ethereum/go-ethereum/common"
- "github.com/vulcanize/vulcanizedb/examples/generic"
"github.com/vulcanize/vulcanizedb/pkg/core"
)
@@ -39,13 +41,13 @@ type GenericGetterInterface interface {
// Getter struct
type GenericGetter struct {
- fetcher generic.Fetcher // Underlying Fetcher
+ generic.Fetcher // Underlying Fetcher
}
// Initializes and returns a Getter with the given blockchain
func NewGetter(blockChain core.BlockChain) GenericGetter {
return GenericGetter{
- fetcher: generic.Fetcher{
+ Fetcher: generic.Fetcher{
BlockChain: blockChain,
},
}
@@ -53,34 +55,34 @@ func NewGetter(blockChain core.BlockChain) GenericGetter {
// Public getter methods for calling contract methods
func (g GenericGetter) GetOwner(contractAbi, contractAddress string, blockNumber int64) (common.Address, error) {
- return g.fetcher.FetchAddress("owner", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchAddress("owner", contractAbi, contractAddress, blockNumber, nil)
}
func (g GenericGetter) GetStoppedStatus(contractAbi, contractAddress string, blockNumber int64) (bool, error) {
- return g.fetcher.FetchBool("stopped", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchBool("stopped", contractAbi, contractAddress, blockNumber, nil)
}
func (g GenericGetter) GetStringName(contractAbi, contractAddress string, blockNumber int64) (string, error) {
- return g.fetcher.FetchString("name", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchString("name", contractAbi, contractAddress, blockNumber, nil)
}
func (g GenericGetter) GetHashName(contractAbi, contractAddress string, blockNumber int64) (common.Hash, error) {
- return g.fetcher.FetchHash("name", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchHash("name", contractAbi, contractAddress, blockNumber, nil)
}
func (g GenericGetter) GetStringSymbol(contractAbi, contractAddress string, blockNumber int64) (string, error) {
- return g.fetcher.FetchString("symbol", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchString("symbol", contractAbi, contractAddress, blockNumber, nil)
}
func (g GenericGetter) GetHashSymbol(contractAbi, contractAddress string, blockNumber int64) (common.Hash, error) {
- return g.fetcher.FetchHash("symbol", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchHash("symbol", contractAbi, contractAddress, blockNumber, nil)
}
func (g GenericGetter) GetDecimals(contractAbi, contractAddress string, blockNumber int64) (big.Int, error) {
- return g.fetcher.FetchBigInt("decimals", contractAbi, contractAddress, blockNumber, nil)
+ return g.Fetcher.FetchBigInt("decimals", contractAbi, contractAddress, blockNumber, nil)
}
// Method to retrieve the Getter's blockchain
func (g GenericGetter) GetBlockChain() core.BlockChain {
- return g.fetcher.BlockChain
+ return g.Fetcher.BlockChain
}
diff --git a/examples/generic/every_block/getter_test.go b/examples/generic/every_block/getter_test.go
index d2bc9774..2ea5a2ae 100644
--- a/examples/generic/every_block/getter_test.go
+++ b/examples/generic/every_block/getter_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package every_block_test
@@ -23,13 +25,13 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/examples/generic/every_block"
"github.com/vulcanize/vulcanizedb/pkg/fakes"
"github.com/vulcanize/vulcanizedb/pkg/geth"
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
)
var _ = Describe("every_block Getter", func() {
diff --git a/examples/generic/retriever.go b/examples/generic/retriever.go
index e7a56ee1..a4aa62f0 100644
--- a/examples/generic/retriever.go
+++ b/examples/generic/retriever.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package generic
diff --git a/examples/mocks/converter.go b/examples/mocks/converter.go
index a87aab1c..e5376426 100644
--- a/examples/mocks/converter.go
+++ b/examples/mocks/converter.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package mocks
diff --git a/examples/mocks/event_repo.go b/examples/mocks/event_repo.go
index 23c722b5..1de651aa 100644
--- a/examples/mocks/event_repo.go
+++ b/examples/mocks/event_repo.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package mocks
diff --git a/examples/mocks/every_block_repo.go b/examples/mocks/every_block_repo.go
index cf58f0db..c5bfe39b 100644
--- a/examples/mocks/every_block_repo.go
+++ b/examples/mocks/every_block_repo.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package mocks
diff --git a/examples/mocks/failure_repo.go b/examples/mocks/failure_repo.go
index 315296d4..bd84fa45 100644
--- a/examples/mocks/failure_repo.go
+++ b/examples/mocks/failure_repo.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package mocks
diff --git a/examples/mocks/fetcher.go b/examples/mocks/fetcher.go
index 940039f4..e343582c 100644
--- a/examples/mocks/fetcher.go
+++ b/examples/mocks/fetcher.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package mocks
diff --git a/examples/mocks/getter.go b/examples/mocks/getter.go
index d9106147..084ede25 100644
--- a/examples/mocks/getter.go
+++ b/examples/mocks/getter.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package mocks
diff --git a/examples/test_helpers/database.go b/examples/test_helpers/database.go
index 1b7855d7..60d2d4b0 100644
--- a/examples/test_helpers/database.go
+++ b/examples/test_helpers/database.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package test_helpers
diff --git a/integration_test/block_rewards_test.go b/integration_test/block_rewards_test.go
index c4a09de0..36bcd885 100644
--- a/integration_test/block_rewards_test.go
+++ b/integration_test/block_rewards_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package integration
import (
diff --git a/integration_test/contract_test.go b/integration_test/contract_test.go
index 72c1473e..812f9b85 100644
--- a/integration_test/contract_test.go
+++ b/integration_test/contract_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package integration
import (
diff --git a/integration_test/geth_blockchain_test.go b/integration_test/geth_blockchain_test.go
index a64906c8..8f2dd68b 100644
--- a/integration_test/geth_blockchain_test.go
+++ b/integration_test/geth_blockchain_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package integration_test
import (
diff --git a/integration_test/integration_test_suite_test.go b/integration_test/integration_test_suite_test.go
index 73ecd005..cc2318de 100644
--- a/integration_test/integration_test_suite_test.go
+++ b/integration_test/integration_test_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package integration_test
import (
diff --git a/libraries/shared/contract_config.go b/libraries/shared/contract_config.go
index 8206c321..8eac45a7 100644
--- a/libraries/shared/contract_config.go
+++ b/libraries/shared/contract_config.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package shared
import (
diff --git a/libraries/shared/shared_suite_test.go b/libraries/shared/shared_suite_test.go
index b2c78ef2..a36f747f 100644
--- a/libraries/shared/shared_suite_test.go
+++ b/libraries/shared/shared_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package shared_test
import (
diff --git a/libraries/shared/transformer_interface.go b/libraries/shared/transformer_interface.go
index 565e5813..626c430c 100644
--- a/libraries/shared/transformer_interface.go
+++ b/libraries/shared/transformer_interface.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package shared
import (
diff --git a/libraries/shared/watcher.go b/libraries/shared/watcher.go
index ed2ad4a0..a8866125 100644
--- a/libraries/shared/watcher.go
+++ b/libraries/shared/watcher.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package shared
import (
diff --git a/libraries/shared/watcher_test.go b/libraries/shared/watcher_test.go
index c72415b7..18142339 100644
--- a/libraries/shared/watcher_test.go
+++ b/libraries/shared/watcher_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package shared_test
import (
diff --git a/pkg/config/client.go b/pkg/config/client.go
index 48c57c1a..650bf5b1 100644
--- a/pkg/config/client.go
+++ b/pkg/config/client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package config
type Client struct {
diff --git a/pkg/config/config.go b/pkg/config/config.go
index d53444ea..9b7c9799 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package config
type Config struct {
diff --git a/pkg/config/config_suite_test.go b/pkg/config/config_suite_test.go
index 6508e6da..22df0c6f 100644
--- a/pkg/config/config_suite_test.go
+++ b/pkg/config/config_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package config_test
import (
diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go
index 1059ec45..fe8dc0aa 100644
--- a/pkg/config/config_test.go
+++ b/pkg/config/config_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package config_test
import (
diff --git a/pkg/config/database.go b/pkg/config/database.go
index 84f139fa..62bdd8bf 100644
--- a/pkg/config/database.go
+++ b/pkg/config/database.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package config
import "fmt"
diff --git a/pkg/core/block.go b/pkg/core/block.go
index a81bdec6..cf3eb5e6 100644
--- a/pkg/core/block.go
+++ b/pkg/core/block.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Block struct {
diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go
index 2c1aadab..d6753f5d 100644
--- a/pkg/core/blockchain.go
+++ b/pkg/core/blockchain.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
import "math/big"
diff --git a/pkg/core/contract.go b/pkg/core/contract.go
index 8b881e7d..1ca4dffd 100644
--- a/pkg/core/contract.go
+++ b/pkg/core/contract.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Contract struct {
diff --git a/pkg/core/eth_client.go b/pkg/core/eth_client.go
index 186f222d..2ec6c6bb 100644
--- a/pkg/core/eth_client.go
+++ b/pkg/core/eth_client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
import (
diff --git a/pkg/core/header.go b/pkg/core/header.go
index 21335b6f..e32ca089 100644
--- a/pkg/core/header.go
+++ b/pkg/core/header.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Header struct {
diff --git a/pkg/core/log.go b/pkg/core/log.go
index 984e0432..33ff4146 100644
--- a/pkg/core/log.go
+++ b/pkg/core/log.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Log struct {
diff --git a/pkg/core/node_info.go b/pkg/core/node_info.go
index 56876453..37752897 100644
--- a/pkg/core/node_info.go
+++ b/pkg/core/node_info.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
import (
diff --git a/pkg/core/receipts.go b/pkg/core/receipts.go
index 1d8eaeb0..dad982e6 100644
--- a/pkg/core/receipts.go
+++ b/pkg/core/receipts.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Receipt struct {
diff --git a/pkg/core/rpc_client.go b/pkg/core/rpc_client.go
index d8b99354..5f739383 100644
--- a/pkg/core/rpc_client.go
+++ b/pkg/core/rpc_client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
import "context"
diff --git a/pkg/core/topics.go b/pkg/core/topics.go
index 2f1acb9d..643579b9 100644
--- a/pkg/core/topics.go
+++ b/pkg/core/topics.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Topics [4]string
diff --git a/pkg/core/transaction.go b/pkg/core/transaction.go
index e1d45dde..ca3beb9a 100644
--- a/pkg/core/transaction.go
+++ b/pkg/core/transaction.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type Transaction struct {
diff --git a/pkg/core/watched_event_log.go b/pkg/core/watched_event_log.go
index 04090bcf..fa2a495b 100644
--- a/pkg/core/watched_event_log.go
+++ b/pkg/core/watched_event_log.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package core
type WatchedEvent struct {
diff --git a/pkg/crypto/crypto_suite_test.go b/pkg/crypto/crypto_suite_test.go
index e60462b9..4d08b0b0 100644
--- a/pkg/crypto/crypto_suite_test.go
+++ b/pkg/crypto/crypto_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package crypto_test
import (
diff --git a/pkg/crypto/parser.go b/pkg/crypto/parser.go
index 30db1699..0359fe29 100644
--- a/pkg/crypto/parser.go
+++ b/pkg/crypto/parser.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package crypto
import (
diff --git a/pkg/crypto/parser_test.go b/pkg/crypto/parser_test.go
index 77c1478e..711e9d83 100644
--- a/pkg/crypto/parser_test.go
+++ b/pkg/crypto/parser_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package crypto_test
import (
diff --git a/pkg/datastore/ethereum/config.go b/pkg/datastore/ethereum/config.go
index 039089ac..589ae819 100644
--- a/pkg/datastore/ethereum/config.go
+++ b/pkg/datastore/ethereum/config.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package ethereum
type DatabaseType int
diff --git a/pkg/datastore/ethereum/database.go b/pkg/datastore/ethereum/database.go
index c0676c41..2f4bb577 100644
--- a/pkg/datastore/ethereum/database.go
+++ b/pkg/datastore/ethereum/database.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package ethereum
import (
diff --git a/pkg/datastore/ethereum/level/database.go b/pkg/datastore/ethereum/level/database.go
index 1d32ae8b..6a5f023e 100644
--- a/pkg/datastore/ethereum/level/database.go
+++ b/pkg/datastore/ethereum/level/database.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package level
import (
diff --git a/pkg/datastore/ethereum/level/database_reader.go b/pkg/datastore/ethereum/level/database_reader.go
index 05b1e278..f9281b86 100644
--- a/pkg/datastore/ethereum/level/database_reader.go
+++ b/pkg/datastore/ethereum/level/database_reader.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package level
import (
diff --git a/pkg/datastore/ethereum/level/database_test.go b/pkg/datastore/ethereum/level/database_test.go
index 4d2018da..5e9de31e 100644
--- a/pkg/datastore/ethereum/level/database_test.go
+++ b/pkg/datastore/ethereum/level/database_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package level_test
import (
diff --git a/pkg/datastore/ethereum/level/level_suite_test.go b/pkg/datastore/ethereum/level/level_suite_test.go
index 20e571bd..26c6cb49 100644
--- a/pkg/datastore/ethereum/level/level_suite_test.go
+++ b/pkg/datastore/ethereum/level/level_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package level_test
import (
diff --git a/pkg/datastore/postgres/postgres.go b/pkg/datastore/postgres/postgres.go
index 0dcdfce8..82a1b2ac 100644
--- a/pkg/datastore/postgres/postgres.go
+++ b/pkg/datastore/postgres/postgres.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package postgres
import (
diff --git a/pkg/datastore/postgres/postgres_suite_test.go b/pkg/datastore/postgres/postgres_suite_test.go
index d2b9876e..8a86a397 100644
--- a/pkg/datastore/postgres/postgres_suite_test.go
+++ b/pkg/datastore/postgres/postgres_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package postgres_test
import (
diff --git a/pkg/datastore/postgres/postgres_test.go b/pkg/datastore/postgres/postgres_test.go
index 7c4555a7..38eeda7b 100644
--- a/pkg/datastore/postgres/postgres_test.go
+++ b/pkg/datastore/postgres/postgres_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package postgres_test
import (
diff --git a/pkg/datastore/postgres/repositories/block_repository.go b/pkg/datastore/postgres/repositories/block_repository.go
index 74018296..189ce942 100644
--- a/pkg/datastore/postgres/repositories/block_repository.go
+++ b/pkg/datastore/postgres/repositories/block_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/block_repository_test.go b/pkg/datastore/postgres/repositories/block_repository_test.go
index 93ffe650..b5e780c1 100644
--- a/pkg/datastore/postgres/repositories/block_repository_test.go
+++ b/pkg/datastore/postgres/repositories/block_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/contract_repository.go b/pkg/datastore/postgres/repositories/contract_repository.go
index 1640fd8a..0ff0afdd 100644
--- a/pkg/datastore/postgres/repositories/contract_repository.go
+++ b/pkg/datastore/postgres/repositories/contract_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/contract_repository_test.go b/pkg/datastore/postgres/repositories/contract_repository_test.go
index 0ecaf8bf..394d98c0 100644
--- a/pkg/datastore/postgres/repositories/contract_repository_test.go
+++ b/pkg/datastore/postgres/repositories/contract_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/header_repository.go b/pkg/datastore/postgres/repositories/header_repository.go
index 7aa4deac..cf951f04 100644
--- a/pkg/datastore/postgres/repositories/header_repository.go
+++ b/pkg/datastore/postgres/repositories/header_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/header_repository_test.go b/pkg/datastore/postgres/repositories/header_repository_test.go
index 49a74af3..1a766dc9 100644
--- a/pkg/datastore/postgres/repositories/header_repository_test.go
+++ b/pkg/datastore/postgres/repositories/header_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/log_filter_repository.go b/pkg/datastore/postgres/repositories/log_filter_repository.go
index 6b1d3d7c..faad7ca8 100644
--- a/pkg/datastore/postgres/repositories/log_filter_repository.go
+++ b/pkg/datastore/postgres/repositories/log_filter_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/log_filter_repository_test.go b/pkg/datastore/postgres/repositories/log_filter_repository_test.go
index f7aac44b..a28c855d 100644
--- a/pkg/datastore/postgres/repositories/log_filter_repository_test.go
+++ b/pkg/datastore/postgres/repositories/log_filter_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/logs_repository.go b/pkg/datastore/postgres/repositories/logs_repository.go
index 45d29b88..4886e15f 100644
--- a/pkg/datastore/postgres/repositories/logs_repository.go
+++ b/pkg/datastore/postgres/repositories/logs_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/logs_repository_test.go b/pkg/datastore/postgres/repositories/logs_repository_test.go
index 072f49bc..86a30345 100644
--- a/pkg/datastore/postgres/repositories/logs_repository_test.go
+++ b/pkg/datastore/postgres/repositories/logs_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/receipt_repository.go b/pkg/datastore/postgres/repositories/receipt_repository.go
index 997ee58c..9981559c 100644
--- a/pkg/datastore/postgres/repositories/receipt_repository.go
+++ b/pkg/datastore/postgres/repositories/receipt_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/receipts_repository_test.go b/pkg/datastore/postgres/repositories/receipts_repository_test.go
index 2ba46e05..24cfe45f 100644
--- a/pkg/datastore/postgres/repositories/receipts_repository_test.go
+++ b/pkg/datastore/postgres/repositories/receipts_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/repositories_suite_test.go b/pkg/datastore/postgres/repositories/repositories_suite_test.go
index b222d38c..bf45707e 100644
--- a/pkg/datastore/postgres/repositories/repositories_suite_test.go
+++ b/pkg/datastore/postgres/repositories/repositories_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/postgres/repositories/watched_events_repository.go b/pkg/datastore/postgres/repositories/watched_events_repository.go
index d4682d2a..b5931666 100644
--- a/pkg/datastore/postgres/repositories/watched_events_repository.go
+++ b/pkg/datastore/postgres/repositories/watched_events_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories
import (
diff --git a/pkg/datastore/postgres/repositories/watched_events_repository_test.go b/pkg/datastore/postgres/repositories/watched_events_repository_test.go
index 0192dc31..c0507fef 100644
--- a/pkg/datastore/postgres/repositories/watched_events_repository_test.go
+++ b/pkg/datastore/postgres/repositories/watched_events_repository_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package repositories_test
import (
diff --git a/pkg/datastore/repository.go b/pkg/datastore/repository.go
index fd8b59cd..5c3bde21 100644
--- a/pkg/datastore/repository.go
+++ b/pkg/datastore/repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package datastore
import (
diff --git a/pkg/fakes/data.go b/pkg/fakes/data.go
index 22f1b601..0cb1bd07 100644
--- a/pkg/fakes/data.go
+++ b/pkg/fakes/data.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import "errors"
diff --git a/pkg/fakes/mock_block_repository.go b/pkg/fakes/mock_block_repository.go
index 7c05bfc0..b39a034f 100644
--- a/pkg/fakes/mock_block_repository.go
+++ b/pkg/fakes/mock_block_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_blockchain.go b/pkg/fakes/mock_blockchain.go
index 6dac17d4..cd919011 100644
--- a/pkg/fakes/mock_blockchain.go
+++ b/pkg/fakes/mock_blockchain.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_crypto_parser.go b/pkg/fakes/mock_crypto_parser.go
index 98b21f80..e4de379c 100644
--- a/pkg/fakes/mock_crypto_parser.go
+++ b/pkg/fakes/mock_crypto_parser.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import . "github.com/onsi/gomega"
diff --git a/pkg/fakes/mock_eth_client.go b/pkg/fakes/mock_eth_client.go
index c1e544d3..a08cc175 100644
--- a/pkg/fakes/mock_eth_client.go
+++ b/pkg/fakes/mock_eth_client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_ethereum_database.go b/pkg/fakes/mock_ethereum_database.go
index a25d2b5c..038d04ba 100644
--- a/pkg/fakes/mock_ethereum_database.go
+++ b/pkg/fakes/mock_ethereum_database.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_fs_reader.go b/pkg/fakes/mock_fs_reader.go
index c9a74466..e967a2cd 100644
--- a/pkg/fakes/mock_fs_reader.go
+++ b/pkg/fakes/mock_fs_reader.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import . "github.com/onsi/gomega"
diff --git a/pkg/fakes/mock_header_repository.go b/pkg/fakes/mock_header_repository.go
index e5254e9c..58338538 100644
--- a/pkg/fakes/mock_header_repository.go
+++ b/pkg/fakes/mock_header_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_level_database_reader.go b/pkg/fakes/mock_level_database_reader.go
index 4e2bb118..d0efd9bb 100644
--- a/pkg/fakes/mock_level_database_reader.go
+++ b/pkg/fakes/mock_level_database_reader.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_receipt_repository.go b/pkg/fakes/mock_receipt_repository.go
index b5d379b3..5663eeed 100644
--- a/pkg/fakes/mock_receipt_repository.go
+++ b/pkg/fakes/mock_receipt_repository.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_rpc_client.go b/pkg/fakes/mock_rpc_client.go
index d4cbf9b1..27bc8d87 100644
--- a/pkg/fakes/mock_rpc_client.go
+++ b/pkg/fakes/mock_rpc_client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/fakes/mock_transaction_converter.go b/pkg/fakes/mock_transaction_converter.go
index 8595dec0..b36c390e 100644
--- a/pkg/fakes/mock_transaction_converter.go
+++ b/pkg/fakes/mock_transaction_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fakes
import (
diff --git a/pkg/filters/filter_query.go b/pkg/filters/filter_query.go
index 60956ec8..26e3f428 100644
--- a/pkg/filters/filter_query.go
+++ b/pkg/filters/filter_query.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package filters
import (
diff --git a/pkg/filters/filter_test.go b/pkg/filters/filter_test.go
index 474f0311..ea475f8c 100644
--- a/pkg/filters/filter_test.go
+++ b/pkg/filters/filter_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package filters_test
import (
diff --git a/pkg/filters/query_builder_suite_test.go b/pkg/filters/query_builder_suite_test.go
index 42029812..7f49afb6 100644
--- a/pkg/filters/query_builder_suite_test.go
+++ b/pkg/filters/query_builder_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package filters_test
import (
diff --git a/pkg/fs/reader.go b/pkg/fs/reader.go
index 4029b8a7..fe9df6ac 100644
--- a/pkg/fs/reader.go
+++ b/pkg/fs/reader.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package fs
import "io/ioutil"
diff --git a/pkg/geth/abi.go b/pkg/geth/abi.go
index 5211dd98..d6943597 100644
--- a/pkg/geth/abi.go
+++ b/pkg/geth/abi.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package geth
import (
diff --git a/pkg/geth/abi_test.go b/pkg/geth/abi_test.go
index 8843564e..3e5a78dc 100644
--- a/pkg/geth/abi_test.go
+++ b/pkg/geth/abi_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package geth_test
import (
diff --git a/pkg/geth/blockchain.go b/pkg/geth/blockchain.go
index a6d9193d..9b4e2a6b 100644
--- a/pkg/geth/blockchain.go
+++ b/pkg/geth/blockchain.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package geth
import (
diff --git a/pkg/geth/blockchain_test.go b/pkg/geth/blockchain_test.go
index 69f04e3b..27ff03ab 100644
--- a/pkg/geth/blockchain_test.go
+++ b/pkg/geth/blockchain_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package geth_test
import (
diff --git a/pkg/geth/client/eth_client.go b/pkg/geth/client/eth_client.go
index 21b7cd3d..c4af6009 100644
--- a/pkg/geth/client/eth_client.go
+++ b/pkg/geth/client/eth_client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package client
import (
diff --git a/pkg/geth/client/rpc_client.go b/pkg/geth/client/rpc_client.go
index 46b3f80f..abb74586 100644
--- a/pkg/geth/client/rpc_client.go
+++ b/pkg/geth/client/rpc_client.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package client
import (
diff --git a/pkg/geth/cold_import/cold_import_suite_test.go b/pkg/geth/cold_import/cold_import_suite_test.go
index 8c524782..22f9632c 100644
--- a/pkg/geth/cold_import/cold_import_suite_test.go
+++ b/pkg/geth/cold_import/cold_import_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package cold_import_test
import (
diff --git a/pkg/geth/cold_import/importer.go b/pkg/geth/cold_import/importer.go
index fbf4f90f..9ebeb0dc 100644
--- a/pkg/geth/cold_import/importer.go
+++ b/pkg/geth/cold_import/importer.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package cold_import
import (
diff --git a/pkg/geth/cold_import/importer_test.go b/pkg/geth/cold_import/importer_test.go
index 5f9bf58c..3e50b110 100644
--- a/pkg/geth/cold_import/importer_test.go
+++ b/pkg/geth/cold_import/importer_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package cold_import_test
import (
diff --git a/pkg/geth/cold_import/node_builder.go b/pkg/geth/cold_import/node_builder.go
index f3f79899..4e39bf69 100644
--- a/pkg/geth/cold_import/node_builder.go
+++ b/pkg/geth/cold_import/node_builder.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package cold_import
import (
diff --git a/pkg/geth/cold_import/node_builder_test.go b/pkg/geth/cold_import/node_builder_test.go
index ec19a009..83300078 100644
--- a/pkg/geth/cold_import/node_builder_test.go
+++ b/pkg/geth/cold_import/node_builder_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package cold_import_test
import (
diff --git a/pkg/geth/contract.go b/pkg/geth/contract.go
index a692f410..7fd295cb 100644
--- a/pkg/geth/contract.go
+++ b/pkg/geth/contract.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package geth
import (
diff --git a/pkg/geth/converters/cold_db/transaction_converter.go b/pkg/geth/converters/cold_db/transaction_converter.go
index 044e6226..3b095754 100644
--- a/pkg/geth/converters/cold_db/transaction_converter.go
+++ b/pkg/geth/converters/cold_db/transaction_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package cold_db
import (
diff --git a/pkg/geth/converters/common/block_converter.go b/pkg/geth/converters/common/block_converter.go
index 6e13f474..8976a164 100644
--- a/pkg/geth/converters/common/block_converter.go
+++ b/pkg/geth/converters/common/block_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common
import (
diff --git a/pkg/geth/converters/common/block_converter_test.go b/pkg/geth/converters/common/block_converter_test.go
index ba05826b..e3f04398 100644
--- a/pkg/geth/converters/common/block_converter_test.go
+++ b/pkg/geth/converters/common/block_converter_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common_test
import (
diff --git a/pkg/geth/converters/common/block_rewards.go b/pkg/geth/converters/common/block_rewards.go
index f37a938a..51c967fc 100644
--- a/pkg/geth/converters/common/block_rewards.go
+++ b/pkg/geth/converters/common/block_rewards.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common
import (
diff --git a/pkg/geth/converters/common/common_suite_test.go b/pkg/geth/converters/common/common_suite_test.go
index 690b5549..3d8de4d8 100644
--- a/pkg/geth/converters/common/common_suite_test.go
+++ b/pkg/geth/converters/common/common_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common_test
import (
diff --git a/pkg/geth/converters/common/header_converter.go b/pkg/geth/converters/common/header_converter.go
index 0638f75d..84bdf99b 100644
--- a/pkg/geth/converters/common/header_converter.go
+++ b/pkg/geth/converters/common/header_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common
import (
diff --git a/pkg/geth/converters/common/header_converter_test.go b/pkg/geth/converters/common/header_converter_test.go
index 76ef4fcc..7009c84b 100644
--- a/pkg/geth/converters/common/header_converter_test.go
+++ b/pkg/geth/converters/common/header_converter_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common_test
import (
diff --git a/pkg/geth/converters/common/log_converter.go b/pkg/geth/converters/common/log_converter.go
index 47c0d0e9..11dce787 100644
--- a/pkg/geth/converters/common/log_converter.go
+++ b/pkg/geth/converters/common/log_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common
import (
diff --git a/pkg/geth/converters/common/log_converter_test.go b/pkg/geth/converters/common/log_converter_test.go
index b6e37385..d382aa25 100644
--- a/pkg/geth/converters/common/log_converter_test.go
+++ b/pkg/geth/converters/common/log_converter_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common_test
import (
diff --git a/pkg/geth/converters/common/receipt_converter.go b/pkg/geth/converters/common/receipt_converter.go
index aff58fa1..5d558948 100644
--- a/pkg/geth/converters/common/receipt_converter.go
+++ b/pkg/geth/converters/common/receipt_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common
import (
diff --git a/pkg/geth/converters/common/receipt_converter_test.go b/pkg/geth/converters/common/receipt_converter_test.go
index 585630bf..ed120644 100644
--- a/pkg/geth/converters/common/receipt_converter_test.go
+++ b/pkg/geth/converters/common/receipt_converter_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common_test
import (
diff --git a/pkg/geth/converters/common/transaction_converter.go b/pkg/geth/converters/common/transaction_converter.go
index 6bc1a8fc..320dc975 100644
--- a/pkg/geth/converters/common/transaction_converter.go
+++ b/pkg/geth/converters/common/transaction_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package common
import (
diff --git a/pkg/geth/converters/rpc/transaction_converter.go b/pkg/geth/converters/rpc/transaction_converter.go
index c1dda565..d741f908 100644
--- a/pkg/geth/converters/rpc/transaction_converter.go
+++ b/pkg/geth/converters/rpc/transaction_converter.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package rpc
import (
diff --git a/pkg/geth/geth_suite_test.go b/pkg/geth/geth_suite_test.go
index 2d293f6c..c4078ffc 100644
--- a/pkg/geth/geth_suite_test.go
+++ b/pkg/geth/geth_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package geth_test
import (
diff --git a/pkg/geth/node/node.go b/pkg/geth/node/node.go
index 33459e8f..f1c4780f 100644
--- a/pkg/geth/node/node.go
+++ b/pkg/geth/node/node.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package node
import (
diff --git a/pkg/geth/node/node_suite_test.go b/pkg/geth/node/node_suite_test.go
index 102033dc..27139341 100644
--- a/pkg/geth/node/node_suite_test.go
+++ b/pkg/geth/node/node_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package node_test
import (
diff --git a/pkg/geth/node/node_test.go b/pkg/geth/node/node_test.go
index ec557369..738c673a 100644
--- a/pkg/geth/node/node_test.go
+++ b/pkg/geth/node/node_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package node_test
import (
diff --git a/pkg/geth/testing/helpers.go b/pkg/geth/testing/helpers.go
index 8a683568..145f8fd7 100644
--- a/pkg/geth/testing/helpers.go
+++ b/pkg/geth/testing/helpers.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package testing
import (
diff --git a/pkg/history/block_validator.go b/pkg/history/block_validator.go
index 4f98cbca..6f7791a2 100644
--- a/pkg/history/block_validator.go
+++ b/pkg/history/block_validator.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history
import (
diff --git a/pkg/history/block_validator_test.go b/pkg/history/block_validator_test.go
index e05e6501..a98fad1a 100644
--- a/pkg/history/block_validator_test.go
+++ b/pkg/history/block_validator_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history_test
import (
diff --git a/pkg/history/header_validator.go b/pkg/history/header_validator.go
index b733aaee..23e8ceb0 100644
--- a/pkg/history/header_validator.go
+++ b/pkg/history/header_validator.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history
import (
diff --git a/pkg/history/header_validator_test.go b/pkg/history/header_validator_test.go
index 379f6739..3aaef365 100644
--- a/pkg/history/header_validator_test.go
+++ b/pkg/history/header_validator_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history_test
import (
diff --git a/pkg/history/history_suite_test.go b/pkg/history/history_suite_test.go
index 6bf3894c..0e8706da 100644
--- a/pkg/history/history_suite_test.go
+++ b/pkg/history/history_suite_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history_test
import (
diff --git a/pkg/history/populate_blocks.go b/pkg/history/populate_blocks.go
index 364f1150..1f7806c1 100644
--- a/pkg/history/populate_blocks.go
+++ b/pkg/history/populate_blocks.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history
import (
diff --git a/pkg/history/populate_blocks_test.go b/pkg/history/populate_blocks_test.go
index e80687a3..5ff67a13 100644
--- a/pkg/history/populate_blocks_test.go
+++ b/pkg/history/populate_blocks_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history_test
import (
diff --git a/pkg/history/populate_headers.go b/pkg/history/populate_headers.go
index 1fc1a80d..cd417261 100644
--- a/pkg/history/populate_headers.go
+++ b/pkg/history/populate_headers.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history
import (
diff --git a/pkg/history/populate_headers_test.go b/pkg/history/populate_headers_test.go
index 5d3bf8b5..5f477b71 100644
--- a/pkg/history/populate_headers_test.go
+++ b/pkg/history/populate_headers_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history_test
import (
diff --git a/pkg/history/validation_window.go b/pkg/history/validation_window.go
index e10253c3..fb843907 100644
--- a/pkg/history/validation_window.go
+++ b/pkg/history/validation_window.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history
import (
diff --git a/pkg/history/validation_window_test.go b/pkg/history/validation_window_test.go
index 354af33e..55434f34 100644
--- a/pkg/history/validation_window_test.go
+++ b/pkg/history/validation_window_test.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package history_test
import (
diff --git a/pkg/omni/.DS_Store b/pkg/omni/.DS_Store
new file mode 100644
index 00000000..1150c6cb
Binary files /dev/null and b/pkg/omni/.DS_Store differ
diff --git a/examples/constants/constants.go b/pkg/omni/constants/constants.go
similarity index 96%
rename from examples/constants/constants.go
rename to pkg/omni/constants/constants.go
index f5a47952..c6c16d8a 100644
--- a/examples/constants/constants.go
+++ b/pkg/omni/constants/constants.go
@@ -1,23 +1,25 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package constants
import (
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/filters"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
)
// Event enums
diff --git a/pkg/omni/contract/contract.go b/pkg/omni/contract/contract.go
index 35456e48..ac8d3d38 100644
--- a/pkg/omni/contract/contract.go
+++ b/pkg/omni/contract/contract.go
@@ -1,56 +1,61 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package contract
import (
"errors"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/filters"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
"github.com/vulcanize/vulcanizedb/pkg/omni/types"
)
type Contract struct {
- Name string
- Address string
- StartingBlock int64
- Abi string
- ParsedAbi abi.ABI
- Events map[string]*types.Event // Map of events to their names
- Methods map[string]*types.Method // Map of methods to their names
- Filters map[string]filters.LogFilter // Map of event filters to their names
- Addresses map[string]bool // Map of all contract-associated addresses, populated as events are transformed
+ Name string
+ Address string
+ StartingBlock int64
+ LastBlock int64
+ Abi string
+ ParsedAbi abi.ABI
+ Events map[string]*types.Event // Map of events to their names
+ Methods map[string]*types.Method // Map of methods to their names
+ Filters map[string]filters.LogFilter // Map of event filters to their names
+ EventAddrs map[string]bool // User-input list of account addresses to watch events for
+ MethodAddrs map[string]bool // User-input list of account addresses to poll methods for
+ TknHolderAddrs map[string]bool // List of all contract-associated addresses, populated as events are transformed
}
-func (c *Contract) GenerateFilters(subset []string) error {
+// Use contract info to generate event filters
+func (c *Contract) GenerateFilters() error {
c.Filters = map[string]filters.LogFilter{}
+
for name, event := range c.Events {
- if len(subset) == 0 || stringInSlice(subset, name) {
- c.Filters[name] = filters.LogFilter{
- Name: name,
- FromBlock: c.StartingBlock,
- ToBlock: -1,
- Address: c.Address,
- Topics: core.Topics{helpers.GenerateSignature(event.Sig())},
- }
+ c.Filters[name] = filters.LogFilter{
+ Name: name,
+ FromBlock: c.StartingBlock,
+ ToBlock: -1,
+ Address: c.Address,
+ Topics: core.Topics{helpers.GenerateSignature(event.Sig())}, // move generate signatrue to pkg
}
}
-
+ // If no filters we generated, throw an error (no point in continuing)
if len(c.Filters) == 0 {
return errors.New("error: no filters created")
}
@@ -58,16 +63,50 @@ func (c *Contract) GenerateFilters(subset []string) error {
return nil
}
-func (c *Contract) AddAddress(addr string) {
- c.Addresses[addr] = true
+// Returns true if address is in list of addresses to
+// filter events for or if no filtering is specified
+func (c *Contract) IsEventAddr(addr string) bool {
+ if c.EventAddrs == nil {
+ return false
+ } else if len(c.EventAddrs) == 0 {
+ return true
+ } else if a, ok := c.EventAddrs[addr]; ok {
+ return a
+ }
+
+ return false
}
-func stringInSlice(list []string, s string) bool {
- for _, b := range list {
- if b == s {
+// Returns true if address is in list of addresses to
+// poll methods for or if no filtering is specified
+func (c *Contract) IsMethodAddr(addr string) bool {
+ if c.MethodAddrs == nil {
+ return false
+ } else if len(c.MethodAddrs) == 0 {
+ return true
+ } else if a, ok := c.MethodAddrs[addr]; ok {
+ return a
+ }
+
+ return false
+}
+
+// Returns true if mapping value matches filtered for address or if not filter exists
+// Used to check if an event log name-value mapping should be filtered or not
+func (c *Contract) PassesEventFilter(args map[string]string) bool {
+ for _, arg := range args {
+ if c.IsEventAddr(arg) {
return true
}
}
return false
}
+
+// Used to add an address to the token holder address list
+// if it is on the method polling list or the filter is open
+func (c *Contract) AddTokenHolderAddress(addr string) {
+ if c.TknHolderAddrs != nil && c.IsMethodAddr(addr) {
+ c.TknHolderAddrs[addr] = true
+ }
+}
diff --git a/pkg/omni/contract/contract_suite_test.go b/pkg/omni/contract/contract_suite_test.go
index 6c96c9c7..9ef74e40 100644
--- a/pkg/omni/contract/contract_suite_test.go
+++ b/pkg/omni/contract/contract_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package contract_test
diff --git a/pkg/omni/contract/contract_test.go b/pkg/omni/contract/contract_test.go
index 09e95a6c..e8a6f89f 100644
--- a/pkg/omni/contract/contract_test.go
+++ b/pkg/omni/contract/contract_test.go
@@ -1,70 +1,233 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package contract_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/pkg/core"
- "github.com/vulcanize/vulcanizedb/pkg/filters"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/pkg/omni/contract"
- "github.com/vulcanize/vulcanizedb/pkg/omni/parser"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
)
-var expectedLogFilter = filters.LogFilter{
- Name: "Transfer",
- Address: constants.TusdContractAddress,
- ToBlock: -1,
- FromBlock: 5197514,
- Topics: core.Topics{constants.TransferEvent.Signature()},
-}
-
-var _ = Describe("Contract test", func() {
- var p parser.Parser
+var _ = Describe("Contract", func() {
var err error
+ var info *contract.Contract
+ var wantedEvents = []string{"Transfer", "Approval"}
- BeforeEach(func() {
- p = parser.NewParser("")
- err = p.Parse(constants.TusdContractAddress)
- Expect(err).ToNot(HaveOccurred())
+ Describe("GenerateFilters", func() {
+
+ It("Generates filters from contract data", func() {
+ info = test_helpers.SetupTusdContract(wantedEvents, nil)
+ err = info.GenerateFilters()
+ Expect(err).ToNot(HaveOccurred())
+
+ val, ok := info.Filters["Transfer"]
+ Expect(ok).To(Equal(true))
+ Expect(val).To(Equal(test_helpers.ExpectedTransferFilter))
+
+ val, ok = info.Filters["Approval"]
+ Expect(ok).To(Equal(true))
+ Expect(val).To(Equal(test_helpers.ExpectedApprovalFilter))
+
+ val, ok = info.Filters["Mint"]
+ Expect(ok).To(Equal(false))
+
+ })
+
+ It("Fails with an empty contract", func() {
+ info = &contract.Contract{}
+ err = info.GenerateFilters()
+ Expect(err).To(HaveOccurred())
+ })
})
- It("Creates filters from stored data", func() {
- info := contract.Contract{
- Name: "TrueUSD",
- Address: constants.TusdContractAddress,
- Abi: p.Abi(),
- ParsedAbi: p.ParsedAbi(),
- StartingBlock: 5197514,
- Events: p.GetEvents(),
- Methods: p.GetMethods(),
- Addresses: map[string]bool{},
- }
+ Describe("IsEventAddr", func() {
- err = info.GenerateFilters([]string{"Transfer"})
- Expect(err).ToNot(HaveOccurred())
- val, ok := info.Filters["Transfer"]
- Expect(ok).To(Equal(true))
- Expect(val).To(Equal(expectedLogFilter))
+ BeforeEach(func() {
+ info = &contract.Contract{}
+ info.MethodAddrs = map[string]bool{}
+ info.EventAddrs = map[string]bool{}
+ })
+
+ It("Returns true if address is in event address filter list", func() {
+ info.EventAddrs["testAddress1"] = true
+ info.EventAddrs["testAddress2"] = true
+
+ is := info.IsEventAddr("testAddress1")
+ Expect(is).To(Equal(true))
+ is = info.IsEventAddr("testAddress2")
+ Expect(is).To(Equal(true))
+
+ info.MethodAddrs["testAddress3"] = true
+ is = info.IsEventAddr("testAddress3")
+ Expect(is).To(Equal(false))
+ })
+
+ It("Returns true if event address filter is empty (no filter)", func() {
+ is := info.IsEventAddr("testAddress1")
+ Expect(is).To(Equal(true))
+ is = info.IsEventAddr("testAddress2")
+ Expect(is).To(Equal(true))
+ })
+
+ It("Returns false if address is not in event address filter list", func() {
+ info.EventAddrs["testAddress1"] = true
+ info.EventAddrs["testAddress2"] = true
+
+ is := info.IsEventAddr("testAddress3")
+ Expect(is).To(Equal(false))
+ })
+
+ It("Returns false if event address filter is nil (block all)", func() {
+ info.EventAddrs = nil
+
+ is := info.IsEventAddr("testAddress1")
+ Expect(is).To(Equal(false))
+ is = info.IsEventAddr("testAddress2")
+ Expect(is).To(Equal(false))
+ })
})
- It("Fails with an empty contract", func() {
- info := contract.Contract{}
- err = info.GenerateFilters([]string{"Transfer"})
- Expect(err).To(HaveOccurred())
+ Describe("IsMethodAddr", func() {
+ BeforeEach(func() {
+ info = &contract.Contract{}
+ info.MethodAddrs = map[string]bool{}
+ info.EventAddrs = map[string]bool{}
+ })
+
+ It("Returns true if address is in method address filter list", func() {
+ info.MethodAddrs["testAddress1"] = true
+ info.MethodAddrs["testAddress2"] = true
+
+ is := info.IsMethodAddr("testAddress1")
+ Expect(is).To(Equal(true))
+ is = info.IsMethodAddr("testAddress2")
+ Expect(is).To(Equal(true))
+
+ info.EventAddrs["testAddress3"] = true
+ is = info.IsMethodAddr("testAddress3")
+ Expect(is).To(Equal(false))
+ })
+
+ It("Returns true if method address filter list is empty (no filter)", func() {
+ is := info.IsMethodAddr("testAddress1")
+ Expect(is).To(Equal(true))
+ is = info.IsMethodAddr("testAddress2")
+ Expect(is).To(Equal(true))
+ })
+
+ It("Returns false if address is not in method address filter list", func() {
+ info.MethodAddrs["testAddress1"] = true
+ info.MethodAddrs["testAddress2"] = true
+
+ is := info.IsMethodAddr("testAddress3")
+ Expect(is).To(Equal(false))
+ })
+
+ It("Returns false if method address filter list is nil (block all)", func() {
+ info.MethodAddrs = nil
+
+ is := info.IsMethodAddr("testAddress1")
+ Expect(is).To(Equal(false))
+ is = info.IsMethodAddr("testAddress2")
+ Expect(is).To(Equal(false))
+ })
+ })
+
+ Describe("PassesEventFilter", func() {
+ var mapping map[string]string
+ BeforeEach(func() {
+ info = &contract.Contract{}
+ info.EventAddrs = map[string]bool{}
+ mapping = map[string]string{}
+
+ })
+
+ It("Return true if event log name-value mapping has filtered for address as a value", func() {
+ info.EventAddrs["testAddress1"] = true
+ info.EventAddrs["testAddress2"] = true
+
+ mapping["testInputName1"] = "testAddress1"
+ mapping["testInputName2"] = "testAddress2"
+ mapping["testInputName3"] = "testAddress3"
+
+ pass := info.PassesEventFilter(mapping)
+ Expect(pass).To(Equal(true))
+ })
+
+ It("Return true if event address filter list is empty (no filter)", func() {
+ mapping["testInputName1"] = "testAddress1"
+ mapping["testInputName2"] = "testAddress2"
+ mapping["testInputName3"] = "testAddress3"
+
+ pass := info.PassesEventFilter(mapping)
+ Expect(pass).To(Equal(true))
+ })
+
+ It("Return false if event log name-value mapping does not have filtered for address as a value", func() {
+ info.EventAddrs["testAddress1"] = true
+ info.EventAddrs["testAddress2"] = true
+
+ mapping["testInputName3"] = "testAddress3"
+
+ pass := info.PassesEventFilter(mapping)
+ Expect(pass).To(Equal(false))
+ })
+
+ It("Return false if event address filter list is nil (block all)", func() {
+ info.EventAddrs = nil
+
+ mapping["testInputName1"] = "testAddress1"
+ mapping["testInputName2"] = "testAddress2"
+ mapping["testInputName3"] = "testAddress3"
+
+ pass := info.PassesEventFilter(mapping)
+ Expect(pass).To(Equal(false))
+ })
+ })
+
+ Describe("AddTokenHolderAddress", func() {
+ BeforeEach(func() {
+ info = &contract.Contract{}
+ info.EventAddrs = map[string]bool{}
+ info.MethodAddrs = map[string]bool{}
+ info.TknHolderAddrs = map[string]bool{}
+ })
+
+ It("Adds address to list if it is on the method filter address list", func() {
+ info.MethodAddrs["testAddress2"] = true
+ info.AddTokenHolderAddress("testAddress2")
+ b := info.TknHolderAddrs["testAddress2"]
+ Expect(b).To(Equal(true))
+ })
+
+ It("Adds address to list if method filter is empty", func() {
+ info.AddTokenHolderAddress("testAddress2")
+ b := info.TknHolderAddrs["testAddress2"]
+ Expect(b).To(Equal(true))
+ })
+
+ It("Does not add address to list if both filters are closed (nil)", func() {
+ info.EventAddrs = nil // close both
+ info.MethodAddrs = nil
+ info.AddTokenHolderAddress("testAddress1")
+ b := info.TknHolderAddrs["testAddress1"]
+ Expect(b).To(Equal(false))
+ })
})
})
diff --git a/pkg/omni/converter/converter.go b/pkg/omni/converter/converter.go
index dc18e6b3..bbb38aa1 100644
--- a/pkg/omni/converter/converter.go
+++ b/pkg/omni/converter/converter.go
@@ -1,27 +1,32 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package converter
import (
- "github.com/ethereum/go-ethereum/accounts/abi"
+ "errors"
+ "math/big"
+ "strconv"
+
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
"github.com/vulcanize/vulcanizedb/pkg/omni/types"
)
@@ -29,24 +34,28 @@ import (
// custom logs containing event input name => value maps
type Converter interface {
Convert(watchedEvent core.WatchedEvent, event *types.Event) error
- Update(info contract.Contract)
+ Update(info *contract.Contract)
}
type converter struct {
- contractInfo contract.Contract
+ contractInfo *contract.Contract
}
-func NewConverter(info contract.Contract) *converter {
+func NewConverter(info *contract.Contract) *converter {
return &converter{
contractInfo: info,
}
}
-func (c *converter) Update(info contract.Contract) {
+func (c *converter) Update(info *contract.Contract) {
c.contractInfo = info
}
+func (c *converter) CheckInfo() *contract.Contract {
+ return c.contractInfo
+}
+
// Convert the given watched event log into a types.Log for the given event
func (c *converter) Convert(watchedEvent core.WatchedEvent, event *types.Event) error {
contract := bind.NewBoundContract(common.HexToAddress(c.contractInfo.Address), c.contractInfo.ParsedAbi, nil, nil, nil)
@@ -55,26 +64,6 @@ func (c *converter) Convert(watchedEvent core.WatchedEvent, event *types.Event)
for _, field := range event.Fields {
var i interface{}
values[field.Name] = i
-
- switch field.Type.T {
- case abi.StringTy, abi.HashTy, abi.AddressTy:
- field.PgType = "CHARACTER VARYING(66)"
- case abi.IntTy, abi.UintTy:
- field.PgType = "DECIMAL"
- case abi.BoolTy:
- field.PgType = "BOOLEAN"
- case abi.BytesTy, abi.FixedBytesTy:
- field.PgType = "BYTEA"
- case abi.ArrayTy:
- field.PgType = "TEXT[]"
- case abi.FixedPointTy:
- field.PgType = "MONEY" // use shopspring/decimal for fixed point numbers in go and money type in postgres?
- case abi.FunctionTy:
- field.PgType = "TEXT"
- default:
- field.PgType = "TEXT"
- }
-
}
log := helpers.ConvertToLog(watchedEvent)
@@ -83,13 +72,45 @@ func (c *converter) Convert(watchedEvent core.WatchedEvent, event *types.Event)
return err
}
- eventLog := types.Log{
- Values: values,
- Block: watchedEvent.BlockNumber,
- Tx: watchedEvent.TxHash,
+ strValues := make(map[string]string, len(values))
+
+ for eventName, input := range values {
+ // Postgres cannot handle custom types, resolve to strings
+ switch input.(type) {
+ case *big.Int:
+ var b *big.Int
+ b = input.(*big.Int)
+ strValues[eventName] = b.String()
+ case common.Address:
+ var a common.Address
+ a = input.(common.Address)
+ strValues[eventName] = a.String()
+ c.contractInfo.AddTokenHolderAddress(a.String()) // cache address in a list of contract's token holder addresses
+ case common.Hash:
+ var h common.Hash
+ h = input.(common.Hash)
+ strValues[eventName] = h.String()
+ case string:
+ strValues[eventName] = input.(string)
+ case bool:
+ strValues[eventName] = strconv.FormatBool(input.(bool))
+ default:
+ return errors.New("error: unhandled abi type")
+ }
}
- event.Logs[watchedEvent.LogID] = eventLog
+ // Only hold onto logs that pass our address filter, if any
+ // Persist log here and don't hold onto it
+ if c.contractInfo.PassesEventFilter(strValues) {
+ eventLog := types.Log{
+ Id: watchedEvent.LogID,
+ Values: strValues,
+ Block: watchedEvent.BlockNumber,
+ Tx: watchedEvent.TxHash,
+ }
+
+ event.Logs[watchedEvent.LogID] = eventLog
+ }
return nil
}
diff --git a/pkg/omni/converter/converter_suite_test.go b/pkg/omni/converter/converter_suite_test.go
index b032ea91..0b53b314 100644
--- a/pkg/omni/converter/converter_suite_test.go
+++ b/pkg/omni/converter/converter_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package converter_test
diff --git a/pkg/omni/converter/converter_test.go b/pkg/omni/converter/converter_test.go
index a1a5c18d..d73cb240 100644
--- a/pkg/omni/converter/converter_test.go
+++ b/pkg/omni/converter/converter_test.go
@@ -1,32 +1,32 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package converter_test
import (
- "math/big"
-
"github.com/ethereum/go-ethereum/common"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
- "github.com/vulcanize/vulcanizedb/examples/generic/helpers"
"github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
"github.com/vulcanize/vulcanizedb/pkg/omni/contract"
"github.com/vulcanize/vulcanizedb/pkg/omni/converter"
- "github.com/vulcanize/vulcanizedb/pkg/omni/parser"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
)
var mockEvent = core.WatchedEvent{
@@ -43,50 +43,58 @@ var mockEvent = core.WatchedEvent{
Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
}
-var _ = Describe("Converter Test", func() {
- var p parser.Parser
+var _ = Describe("Converter", func() {
+ var info *contract.Contract
+ var wantedEvents = []string{"Transfer"}
var err error
BeforeEach(func() {
- p = parser.NewParser("")
- err = p.Parse(constants.TusdContractAddress)
- Expect(err).ToNot(HaveOccurred())
+ info = test_helpers.SetupTusdContract(wantedEvents, []string{})
})
- It("Converts watched event log to mapping of event input names to values", func() {
- info := contract.Contract{
- Name: "TrueUSD",
- Address: constants.TusdContractAddress,
- Abi: p.Abi(),
- ParsedAbi: p.ParsedAbi(),
- StartingBlock: 5197514,
- Events: p.GetEvents(),
- Methods: p.GetMethods(),
- Addresses: map[string]bool{},
- }
- event := info.Events["Transfer"]
+ Describe("Update", func() {
+ It("Updates contract info held by the converter", func() {
+ c := converter.NewConverter(info)
+ i := c.CheckInfo()
+ Expect(i).To(Equal(info))
- err = info.GenerateFilters([]string{"Transfer"})
- Expect(err).ToNot(HaveOccurred())
- c := converter.NewConverter(info)
- err = c.Convert(mockEvent, event)
- Expect(err).ToNot(HaveOccurred())
-
- from := common.HexToAddress("0x000000000000000000000000000000000000000000000000000000000000af21")
- to := common.HexToAddress("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391")
- value := helpers.BigFromString("1097077688018008265106216665536940668749033598146")
-
- v := event.Logs[1].Values["value"].(*big.Int)
-
- Expect(event.Logs[1].Values["to"].(common.Address)).To(Equal(to))
- Expect(event.Logs[1].Values["from"].(common.Address)).To(Equal(from))
- Expect(v.String()).To(Equal(value.String()))
+ info := test_helpers.SetupTusdContract([]string{}, []string{})
+ c.Update(info)
+ i = c.CheckInfo()
+ Expect(i).To(Equal(info))
+ })
})
- It("Fails with an empty contract", func() {
- event := p.GetEvents()["Transfer"]
- c := converter.NewConverter(contract.Contract{})
- err = c.Convert(mockEvent, event)
- Expect(err).To(HaveOccurred())
+ Describe("Convert", func() {
+ It("Converts a watched event log to mapping of event input names to values", func() {
+ _, ok := info.Events["Approval"]
+ Expect(ok).To(Equal(false))
+
+ event, ok := info.Events["Transfer"]
+ Expect(ok).To(Equal(true))
+ err = info.GenerateFilters()
+ Expect(err).ToNot(HaveOccurred())
+
+ c := converter.NewConverter(info)
+ err = c.Convert(mockEvent, event)
+ Expect(err).ToNot(HaveOccurred())
+
+ from := common.HexToAddress("0x000000000000000000000000000000000000000000000000000000000000af21")
+ to := common.HexToAddress("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391")
+ value := helpers.BigFromString("1097077688018008265106216665536940668749033598146")
+
+ v := event.Logs[1].Values["value"]
+
+ Expect(event.Logs[1].Values["to"]).To(Equal(to.String()))
+ Expect(event.Logs[1].Values["from"]).To(Equal(from.String()))
+ Expect(v).To(Equal(value.String()))
+ })
+
+ It("Fails with an empty contract", func() {
+ event := info.Events["Transfer"]
+ c := converter.NewConverter(&contract.Contract{})
+ err = c.Convert(mockEvent, event)
+ Expect(err).To(HaveOccurred())
+ })
})
})
diff --git a/pkg/omni/fetcher/fetcher.go b/pkg/omni/fetcher/fetcher.go
deleted file mode 100644
index e2197e71..00000000
--- a/pkg/omni/fetcher/fetcher.go
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
-
-package fetcher
-
-import (
- "fmt"
- "log"
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
-
- "github.com/vulcanize/vulcanizedb/pkg/core"
-)
-
-// Fetcher serves as the lower level data fetcher that calls the underlying
-// blockchain's FetchConctractData method for a given return type
-// Used to collect data from contract public methods
-type Fetcher interface {
- FetchBigInt(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (big.Int, error)
- FetchBool(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (bool, error)
- FetchAddress(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Address, error)
- FetchString(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (string, error)
- FetchHash(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Hash, error)
-}
-
-type fetcher struct {
- BlockChain core.BlockChain // Underyling Blockchain
-}
-
-type fetcherError struct {
- err string
- fetchMethod string
-}
-
-func NewFetcher(blockChain core.BlockChain) *fetcher {
- return &fetcher{
- BlockChain: blockChain,
- }
-}
-
-func (fe *fetcherError) Error() string {
- return fmt.Sprintf("Error fetching %s: %s", fe.fetchMethod, fe.err)
-}
-
-// Used to create a new Fetcher error for a given error and fetch method
-func newFetcherError(err error, fetchMethod string) *fetcherError {
- e := fetcherError{err.Error(), fetchMethod}
- log.Println(e.Error())
- return &e
-}
-
-// Generic Fetcher methods used by Getters to call contract methods
-
-// Method used to fetch big.Int value from contract
-func (f fetcher) FetchBigInt(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (big.Int, error) {
- var result = new(big.Int)
- err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
-
- if err != nil {
- return *result, newFetcherError(err, method)
- }
-
- return *result, nil
-}
-
-// Method used to fetch bool value from contract
-func (f fetcher) FetchBool(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (bool, error) {
- var result = new(bool)
- err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
-
- if err != nil {
- return *result, newFetcherError(err, method)
- }
-
- return *result, nil
-}
-
-// Method used to fetch address value from contract
-func (f fetcher) FetchAddress(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Address, error) {
- var result = new(common.Address)
- err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
-
- if err != nil {
- return *result, newFetcherError(err, method)
- }
-
- return *result, nil
-}
-
-// Method used to fetch string value from contract
-func (f fetcher) FetchString(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (string, error) {
- var result = new(string)
- err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
-
- if err != nil {
- return *result, newFetcherError(err, method)
- }
-
- return *result, nil
-}
-
-// Method used to fetch hash value from contract
-func (f fetcher) FetchHash(method, contractAbi, contractAddress string, blockNumber int64, methodArgs []interface{}) (common.Hash, error) {
- var result = new(common.Hash)
- err := f.BlockChain.FetchContractData(contractAbi, contractAddress, method, methodArgs, &result, blockNumber)
-
- if err != nil {
- return *result, newFetcherError(err, method)
- }
-
- return *result, nil
-}
diff --git a/pkg/omni/fetcher/fetcher_suite_test.go b/pkg/omni/fetcher/fetcher_suite_test.go
deleted file mode 100644
index ac8e9e59..00000000
--- a/pkg/omni/fetcher/fetcher_suite_test.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
-
-package fetcher_test
-
-import (
- "io/ioutil"
- "log"
- "testing"
-
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
-)
-
-func TestFetcher(t *testing.T) {
- RegisterFailHandler(Fail)
- RunSpecs(t, "Fetcher Suite Test")
-}
-
-var _ = BeforeSuite(func() {
- log.SetOutput(ioutil.Discard)
-})
diff --git a/pkg/omni/fetcher/fetcher_test.go b/pkg/omni/fetcher/fetcher_test.go
deleted file mode 100644
index 620bba8b..00000000
--- a/pkg/omni/fetcher/fetcher_test.go
+++ /dev/null
@@ -1,145 +0,0 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
-
-package fetcher_test
-
-import (
- "math/big"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/ethclient"
- "github.com/ethereum/go-ethereum/rpc"
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
-
- "github.com/vulcanize/vulcanizedb/examples/constants"
- "github.com/vulcanize/vulcanizedb/pkg/geth"
- "github.com/vulcanize/vulcanizedb/pkg/geth/client"
- rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
- "github.com/vulcanize/vulcanizedb/pkg/geth/node"
- "github.com/vulcanize/vulcanizedb/pkg/omni/fetcher"
-)
-
-var _ = Describe("Fetcher Test", func() {
- blockNumber := int64(6194634)
- var realFetcher fetcher.Fetcher
-
- BeforeEach(func() {
- infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
- rawRpcClient, err := rpc.Dial(infuraIPC)
- Expect(err).NotTo(HaveOccurred())
- rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
- ethClient := ethclient.NewClient(rawRpcClient)
- blockChainClient := client.NewEthClient(ethClient)
- node := node.MakeNode(rpcClient)
- transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
- blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
- realFetcher = fetcher.NewFetcher(blockChain)
- })
-
- Describe("Fetch big.Int test", func() {
-
- It("fetch totalSupply big.Int", func() {
- bigInt, err := realFetcher.FetchBigInt("totalSupply", constants.DaiAbiString, constants.DaiContractAddress, blockNumber, nil)
- Expect(err).NotTo(HaveOccurred())
- expectedBigInt := big.Int{}
- expectedBigInt.SetString("47327413946297204537985606", 10)
- Expect(bigInt.String()).To(Equal(expectedBigInt.String()))
- })
-
- It("returns an error if the call to the blockchain fails", func() {
- result, err := realFetcher.FetchBigInt("totalSupply", "", "", 0, nil)
-
- Expect(result).To(Equal(big.Int{}))
- Expect(err).To(HaveOccurred())
- Expect(err.Error()).To(ContainSubstring("totalSupply"))
- })
- })
-
- Describe("Fetch bool test", func() {
-
- It("fetch stopped boolean", func() {
- boo, err := realFetcher.FetchBool("stopped", constants.DaiAbiString, constants.DaiContractAddress, blockNumber, nil)
-
- Expect(err).NotTo(HaveOccurred())
- Expect(boo).To(Equal(false))
- })
-
- It("returns an error if the call to the blockchain fails", func() {
- boo, err := realFetcher.FetchBool("stopped", "", "", 0, nil)
-
- Expect(boo).To(Equal(false))
- Expect(err).To(HaveOccurred())
- Expect(err.Error()).To(ContainSubstring("stopped"))
- })
- })
-
- Describe("Fetch address test", func() {
-
- It("fetch owner address", func() {
- expectedAddr := common.HexToAddress("0x0000000000000000000000000000000000000000")
- addr, err := realFetcher.FetchAddress("owner", constants.DaiAbiString, constants.DaiContractAddress, blockNumber, nil)
-
- Expect(err).NotTo(HaveOccurred())
- Expect(addr).To(Equal(expectedAddr))
- })
-
- It("returns an error if the call to the blockchain fails", func() {
- addr, err := realFetcher.FetchAddress("owner", "", "", 0, nil)
-
- Expect(addr).To(Equal(common.Address{}))
- Expect(err).To(HaveOccurred())
- Expect(err.Error()).To(ContainSubstring("owner"))
- })
- })
-
- Describe("Fetch string test", func() {
-
- It("fetch name string", func() {
- expectedStr := "TrueUSD"
- str, err := realFetcher.FetchString("name", constants.TusdAbiString, constants.TusdContractAddress, blockNumber, nil)
-
- Expect(err).NotTo(HaveOccurred())
- Expect(str).To(Equal(expectedStr))
- })
-
- It("returns an error if the call to the blockchain fails", func() {
- str, err := realFetcher.FetchString("name", "", "", 0, nil)
-
- Expect(str).To(Equal(""))
- Expect(err).To(HaveOccurred())
- Expect(err.Error()).To(ContainSubstring("name"))
- })
- })
-
- Describe("Fetch hash test", func() {
-
- It("fetch name hash", func() {
- expectedHash := common.HexToHash("0x44616920537461626c65636f696e2076312e3000000000000000000000000000")
- hash, err := realFetcher.FetchHash("name", constants.DaiAbiString, constants.DaiContractAddress, blockNumber, nil)
-
- Expect(err).NotTo(HaveOccurred())
- Expect(hash).To(Equal(expectedHash))
- })
-
- It("returns an error if the call to the blockchain fails", func() {
- hash, err := realFetcher.FetchHash("name", "", "", 0, nil)
-
- Expect(hash).To(Equal(common.Hash{}))
- Expect(err).To(HaveOccurred())
- Expect(err.Error()).To(ContainSubstring("name"))
- })
- })
-
-})
diff --git a/examples/generic/helpers/helpers.go b/pkg/omni/helpers/helpers.go
similarity index 66%
rename from examples/generic/helpers/helpers.go
rename to pkg/omni/helpers/helpers.go
index 116930af..3c448989 100644
--- a/examples/generic/helpers/helpers.go
+++ b/pkg/omni/helpers/helpers.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package helpers
diff --git a/pkg/omni/helpers/mocks/parser.go b/pkg/omni/helpers/mocks/parser.go
new file mode 100644
index 00000000..54a61229
--- /dev/null
+++ b/pkg/omni/helpers/mocks/parser.go
@@ -0,0 +1,118 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package mocks
+
+import (
+ "github.com/ethereum/go-ethereum/accounts/abi"
+
+ "github.com/vulcanize/vulcanizedb/pkg/geth"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/types"
+)
+
+// Mock parser
+// Is given ABI string instead of address
+// Performs all other functions of the real parser
+type parser struct {
+ abi string
+ parsedAbi abi.ABI
+}
+
+func NewParser(abi string) *parser {
+
+ return &parser{
+ abi: abi,
+ }
+}
+
+func (p *parser) Abi() string {
+ return p.abi
+}
+
+func (p *parser) ParsedAbi() abi.ABI {
+ return p.parsedAbi
+}
+
+// Retrieves and parses the abi string
+// for the given contract address
+func (p *parser) Parse() error {
+ var err error
+ p.parsedAbi, err = geth.ParseAbi(p.abi)
+
+ return err
+}
+
+// Returns wanted methods, if they meet the criteria, as map of types.Methods
+// Only returns specified methods
+func (p *parser) GetMethods(wanted []string) map[string]*types.Method {
+ addrMethods := map[string]*types.Method{}
+
+ for _, m := range p.parsedAbi.Methods {
+ // Only return methods that have less than 3 inputs, 1 output, and wanted
+ if len(m.Inputs) < 3 && len(m.Outputs) == 1 && stringInSlice(wanted, m.Name) {
+ addrsOnly := true
+ for _, input := range m.Inputs {
+ if input.Type.T != abi.AddressTy {
+ addrsOnly = false
+ }
+ }
+
+ // Only return methods if inputs are all of type address and output is of the accepted types
+ if addrsOnly && wantType(m.Outputs[0]) {
+ method := types.NewMethod(m)
+ addrMethods[method.Name] = method
+ }
+ }
+ }
+
+ return addrMethods
+}
+
+// Returns wanted events as map of types.Events
+// If no events are specified, all events are returned
+func (p *parser) GetEvents(wanted []string) map[string]*types.Event {
+ events := map[string]*types.Event{}
+
+ for _, e := range p.parsedAbi.Events {
+ if len(wanted) == 0 || stringInSlice(wanted, e.Name) {
+ event := types.NewEvent(e)
+ events[e.Name] = event
+ }
+ }
+
+ return events
+}
+
+func wantType(arg abi.Argument) bool {
+ wanted := []byte{abi.UintTy, abi.IntTy, abi.BoolTy, abi.StringTy, abi.AddressTy, abi.HashTy}
+ for _, ty := range wanted {
+ if arg.Type.T == ty {
+ return true
+ }
+ }
+
+ return false
+}
+
+func stringInSlice(list []string, s string) bool {
+ for _, b := range list {
+ if b == s {
+ return true
+ }
+ }
+
+ return false
+}
diff --git a/pkg/omni/helpers/test_helpers/database.go b/pkg/omni/helpers/test_helpers/database.go
new file mode 100644
index 00000000..42a392f4
--- /dev/null
+++ b/pkg/omni/helpers/test_helpers/database.go
@@ -0,0 +1,174 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package test_helpers
+
+import (
+ "math/rand"
+
+ "github.com/ethereum/go-ethereum/ethclient"
+ "github.com/ethereum/go-ethereum/rpc"
+ . "github.com/onsi/gomega"
+
+ "github.com/vulcanize/vulcanizedb/pkg/config"
+ "github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
+ "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
+ "github.com/vulcanize/vulcanizedb/pkg/filters"
+ "github.com/vulcanize/vulcanizedb/pkg/geth"
+ "github.com/vulcanize/vulcanizedb/pkg/geth/client"
+ rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
+ "github.com/vulcanize/vulcanizedb/pkg/geth/node"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/parser"
+)
+
+var ExpectedTransferFilter = filters.LogFilter{
+ Name: "Transfer",
+ Address: constants.TusdContractAddress,
+ ToBlock: -1,
+ FromBlock: 5197514,
+ Topics: core.Topics{constants.TransferEvent.Signature()},
+}
+
+var ExpectedApprovalFilter = filters.LogFilter{
+ Name: "Approval",
+ Address: constants.TusdContractAddress,
+ ToBlock: -1,
+ FromBlock: 5197514,
+ Topics: core.Topics{constants.ApprovalEvent.Signature()},
+}
+
+type TransferLog struct {
+ Id int64 `db:"id"`
+ VulvanizeLogId int64 `db:"vulcanize_log_id"`
+ TokenName string `db:"token_name"`
+ TokenAddress string `db:"token_address"`
+ EventName string `db:"event_name"`
+ Block int64 `db:"block"`
+ Tx string `db:"tx"`
+ From string `db:"from_"`
+ To string `db:"to_"`
+ Value string `db:"value_"`
+}
+
+func SetupBC() core.BlockChain {
+ infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
+ rawRpcClient, err := rpc.Dial(infuraIPC)
+ Expect(err).NotTo(HaveOccurred())
+ rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
+ ethClient := ethclient.NewClient(rawRpcClient)
+ blockChainClient := client.NewEthClient(ethClient)
+ node := node.MakeNode(rpcClient)
+ transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
+ blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
+
+ return blockChain
+}
+
+func SetupDBandBC() (*postgres.DB, core.BlockChain) {
+ infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
+ rawRpcClient, err := rpc.Dial(infuraIPC)
+ Expect(err).NotTo(HaveOccurred())
+ rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
+ ethClient := ethclient.NewClient(rawRpcClient)
+ blockChainClient := client.NewEthClient(ethClient)
+ node := node.MakeNode(rpcClient)
+ transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
+ blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
+
+ db, err := postgres.NewDB(config.Database{
+ Hostname: "localhost",
+ Name: "vulcanize_private",
+ Port: 5432,
+ }, blockChain.Node())
+ Expect(err).NotTo(HaveOccurred())
+
+ return db, blockChain
+}
+
+func SetupTusdRepo(vulcanizeLogId *int64, wantedEvents, wantedMethods []string) (*postgres.DB, *contract.Contract) {
+ db, err := postgres.NewDB(config.Database{
+ Hostname: "localhost",
+ Name: "vulcanize_private",
+ Port: 5432,
+ }, core.Node{})
+ Expect(err).NotTo(HaveOccurred())
+
+ receiptRepository := repositories.ReceiptRepository{DB: db}
+ logRepository := repositories.LogRepository{DB: db}
+ blockRepository := *repositories.NewBlockRepository(db)
+
+ blockNumber := rand.Int63()
+ blockId := CreateBlock(blockNumber, blockRepository)
+
+ receipts := []core.Receipt{{Logs: []core.Log{{}}}}
+
+ err = receiptRepository.CreateReceiptsAndLogs(blockId, receipts)
+ Expect(err).ToNot(HaveOccurred())
+
+ err = logRepository.Get(vulcanizeLogId, `SELECT id FROM logs`)
+ Expect(err).ToNot(HaveOccurred())
+
+ info := SetupTusdContract(wantedEvents, wantedMethods)
+
+ return db, info
+}
+
+func SetupTusdContract(wantedEvents, wantedMethods []string) *contract.Contract {
+ p := parser.NewParser("")
+ err := p.Parse(constants.TusdContractAddress)
+ Expect(err).ToNot(HaveOccurred())
+
+ return &contract.Contract{
+ Name: "TrueUSD",
+ Address: constants.TusdContractAddress,
+ Abi: p.Abi(),
+ ParsedAbi: p.ParsedAbi(),
+ StartingBlock: 5197514,
+ LastBlock: 6507323,
+ Events: p.GetEvents(wantedEvents),
+ Methods: p.GetMethods(wantedMethods),
+ EventAddrs: map[string]bool{},
+ MethodAddrs: map[string]bool{},
+ TknHolderAddrs: map[string]bool{},
+ }
+}
+
+func TearDown(db *postgres.DB) {
+ _, err := db.Query(`DELETE FROM blocks`)
+ Expect(err).NotTo(HaveOccurred())
+
+ _, err = db.Query(`DELETE FROM logs`)
+ Expect(err).NotTo(HaveOccurred())
+
+ _, err = db.Query(`DELETE FROM transactions`)
+ Expect(err).NotTo(HaveOccurred())
+
+ _, err = db.Query(`DELETE FROM receipts`)
+ Expect(err).NotTo(HaveOccurred())
+
+ _, err = db.Query(`DROP SCHEMA IF EXISTS c0x8dd5fbCe2F6a956C3022bA3663759011Dd51e73E CASCADE`)
+ Expect(err).NotTo(HaveOccurred())
+}
+
+func CreateBlock(blockNumber int64, repository repositories.BlockRepository) (blockId int64) {
+ blockId, err := repository.CreateOrUpdateBlock(core.Block{Number: blockNumber})
+ Expect(err).NotTo(HaveOccurred())
+
+ return blockId
+}
diff --git a/pkg/omni/parser/parser.go b/pkg/omni/parser/parser.go
index 062629f9..7022d79d 100644
--- a/pkg/omni/parser/parser.go
+++ b/pkg/omni/parser/parser.go
@@ -1,21 +1,24 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package parser
import (
"github.com/ethereum/go-ethereum/accounts/abi"
+
"github.com/vulcanize/vulcanizedb/pkg/geth"
"github.com/vulcanize/vulcanizedb/pkg/omni/types"
)
@@ -26,8 +29,9 @@ type Parser interface {
Parse(contractAddr string) error
Abi() string
ParsedAbi() abi.ABI
- GetMethods() map[string]*types.Method
- GetEvents() map[string]*types.Event
+ GetMethods(wanted []string) map[string]*types.Method
+ GetAddrMethods(wanted []string) map[string]*types.Method
+ GetEvents(wanted []string) map[string]*types.Event
}
type parser struct {
@@ -66,26 +70,91 @@ func (p *parser) Parse(contractAddr string) error {
return err
}
-// Parses methods into our custom method type and returns
-func (p *parser) GetMethods() map[string]*types.Method {
- methods := map[string]*types.Method{}
+// Returns wanted methods, if they meet the criteria, as map of types.Methods
+// Empty wanted array => all methods that fit are returned
+// Nil wanted array => no events are returned
+func (p *parser) GetAddrMethods(wanted []string) map[string]*types.Method {
+ addrMethods := map[string]*types.Method{}
+ if wanted == nil {
+ return addrMethods
+ }
for _, m := range p.parsedAbi.Methods {
- method := types.NewMethod(m)
- methods[m.Name] = method
+ // Only return methods that have less than 3 inputs, 1 output, and wanted
+ if len(m.Inputs) < 3 && len(m.Outputs) == 1 && (len(wanted) == 0 || stringInSlice(wanted, m.Name)) {
+ addrsOnly := true
+ for _, input := range m.Inputs {
+ if input.Type.T != abi.AddressTy {
+ addrsOnly = false
+ }
+ }
+
+ // Only return methods if inputs are all of type address and output is of the accepted types
+ if addrsOnly && wantType(m.Outputs[0]) {
+ method := types.NewMethod(m)
+ addrMethods[method.Name] = method
+ }
+ }
+ }
+
+ return addrMethods
+}
+
+// Returns wanted methods as map of types.Methods
+// Empty wanted array => all events are returned
+// Nil wanted array => no events are returned
+func (p *parser) GetMethods(wanted []string) map[string]*types.Method {
+ methods := map[string]*types.Method{}
+ if wanted == nil {
+ return methods
+ }
+
+ length := len(wanted)
+ for _, m := range p.parsedAbi.Methods {
+ if length == 0 || stringInSlice(wanted, m.Name) {
+ methods[m.Name] = types.NewMethod(m)
+ }
}
return methods
}
-// Parses events into our custom event type and returns
-func (p *parser) GetEvents() map[string]*types.Event {
+// Returns wanted events as map of types.Events
+// Empty wanted array => all events are returned
+// Nil wanted array => no events are returned
+func (p *parser) GetEvents(wanted []string) map[string]*types.Event {
events := map[string]*types.Event{}
+ if wanted == nil {
+ return events
+ }
+ length := len(wanted)
for _, e := range p.parsedAbi.Events {
- event := types.NewEvent(e)
- events[e.Name] = event
+ if length == 0 || stringInSlice(wanted, e.Name) {
+ events[e.Name] = types.NewEvent(e)
+ }
}
return events
}
+
+func wantType(arg abi.Argument) bool {
+ wanted := []byte{abi.UintTy, abi.IntTy, abi.BoolTy, abi.StringTy, abi.AddressTy, abi.HashTy}
+ for _, ty := range wanted {
+ if arg.Type.T == ty {
+ return true
+ }
+ }
+
+ return false
+}
+
+func stringInSlice(list []string, s string) bool {
+ for _, b := range list {
+ if b == s {
+ return true
+ }
+ }
+
+ return false
+}
diff --git a/pkg/omni/parser/parser_suite_test.go b/pkg/omni/parser/parser_suite_test.go
index 35c14be0..ccc11fb2 100644
--- a/pkg/omni/parser/parser_suite_test.go
+++ b/pkg/omni/parser/parser_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package parser_test
diff --git a/pkg/omni/parser/parser_test.go b/pkg/omni/parser/parser_test.go
index 98dde824..14c4c803 100644
--- a/pkg/omni/parser/parser_test.go
+++ b/pkg/omni/parser/parser_test.go
@@ -1,29 +1,33 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package parser_test
import (
+ "github.com/ethereum/go-ethereum/accounts/abi"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
"github.com/vulcanize/vulcanizedb/pkg/geth"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/mocks"
"github.com/vulcanize/vulcanizedb/pkg/omni/parser"
)
-var _ = Describe("Parser Test", func() {
+var _ = Describe("Parser", func() {
var p parser.Parser
var err error
@@ -32,38 +36,182 @@ var _ = Describe("Parser Test", func() {
p = parser.NewParser("")
})
- It("Fetches and parses abi using contract address", func() {
- contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" // dai contract address
- err = p.Parse(contractAddr)
- Expect(err).ToNot(HaveOccurred())
+ Describe("Mock Parse", func() {
+ It("Uses parses given abi string", func() {
+ mp := mocks.NewParser(constants.DaiAbiString)
+ err = mp.Parse()
+ Expect(err).ToNot(HaveOccurred())
- expectedAbi := constants.DaiAbiString
- Expect(p.Abi()).To(Equal(expectedAbi))
+ parsedAbi := mp.ParsedAbi()
+ expectedAbi, err := geth.ParseAbi(constants.DaiAbiString)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(parsedAbi).To(Equal(expectedAbi))
- expectedParsedAbi, err := geth.ParseAbi(expectedAbi)
- Expect(err).ToNot(HaveOccurred())
- Expect(p.ParsedAbi()).To(Equal(expectedParsedAbi))
+ methods := mp.GetMethods([]string{"balanceOf"})
+ _, ok := methods["totalSupply"]
+ Expect(ok).To(Equal(false))
+ m, ok := methods["balanceOf"]
+ Expect(ok).To(Equal(true))
+ Expect(len(m.Inputs)).To(Equal(1))
+ Expect(len(m.Outputs)).To(Equal(1))
+
+ events := mp.GetEvents([]string{"Transfer"})
+ _, ok = events["Mint"]
+ Expect(ok).To(Equal(false))
+ e, ok := events["Transfer"]
+ Expect(ok).To(Equal(true))
+ Expect(len(e.Fields)).To(Equal(3))
+ })
})
- It("Returns parsed methods and events", func() {
- contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
- err = p.Parse(contractAddr)
- Expect(err).ToNot(HaveOccurred())
+ Describe("Parse", func() {
+ It("Fetches and parses abi from etherscan using contract address", func() {
+ contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" // dai contract address
+ err = p.Parse(contractAddr)
+ Expect(err).ToNot(HaveOccurred())
- methods := p.GetMethods()
- events := p.GetEvents()
+ expectedAbi := constants.DaiAbiString
+ Expect(p.Abi()).To(Equal(expectedAbi))
- _, ok := methods["totalSupply"]
- Expect(ok).To(Equal(true))
+ expectedParsedAbi, err := geth.ParseAbi(expectedAbi)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(p.ParsedAbi()).To(Equal(expectedParsedAbi))
+ })
- _, ok = events["Transfer"]
- Expect(ok).To(Equal(true))
+ It("Fails with a normal, non-contract, account address", func() {
+ addr := "0xAb2A8F7cB56D9EC65573BA1bE0f92Fa2Ff7dd165"
+ err = p.Parse(addr)
+ Expect(err).To(HaveOccurred())
+ })
})
- It("Fails with a normal, non-contract, account address", func() {
- addr := "0xAb2A8F7cB56D9EC65573BA1bE0f92Fa2Ff7dd165"
- err = p.Parse(addr)
- Expect(err).To(HaveOccurred())
+ Describe("GetEvents", func() {
+ It("Returns parsed events", func() {
+ contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
+ err = p.Parse(contractAddr)
+ Expect(err).ToNot(HaveOccurred())
+
+ events := p.GetEvents([]string{"Transfer"})
+
+ e, ok := events["Transfer"]
+ Expect(ok).To(Equal(true))
+
+ abiTy := e.Fields[0].Type.T
+ Expect(abiTy).To(Equal(abi.AddressTy))
+
+ pgTy := e.Fields[0].PgType
+ Expect(pgTy).To(Equal("CHARACTER VARYING(66)"))
+
+ abiTy = e.Fields[1].Type.T
+ Expect(abiTy).To(Equal(abi.AddressTy))
+
+ pgTy = e.Fields[1].PgType
+ Expect(pgTy).To(Equal("CHARACTER VARYING(66)"))
+
+ abiTy = e.Fields[2].Type.T
+ Expect(abiTy).To(Equal(abi.UintTy))
+
+ pgTy = e.Fields[2].PgType
+ Expect(pgTy).To(Equal("DECIMAL"))
+
+ _, ok = events["Approval"]
+ Expect(ok).To(Equal(false))
+ })
})
+ Describe("GetMethods", func() {
+ It("Parses and returns only methods specified in passed array", func() {
+ contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
+ err = p.Parse(contractAddr)
+ Expect(err).ToNot(HaveOccurred())
+
+ selectMethods := p.GetMethods([]string{"balanceOf"})
+
+ m, ok := selectMethods["balanceOf"]
+ Expect(ok).To(Equal(true))
+
+ abiTy := m.Inputs[0].Type.T
+ Expect(abiTy).To(Equal(abi.AddressTy))
+
+ pgTy := m.Inputs[0].PgType
+ Expect(pgTy).To(Equal("CHARACTER VARYING(66)"))
+
+ abiTy = m.Outputs[0].Type.T
+ Expect(abiTy).To(Equal(abi.UintTy))
+
+ pgTy = m.Outputs[0].PgType
+ Expect(pgTy).To(Equal("DECIMAL"))
+
+ _, ok = selectMethods["totalSupply"]
+ Expect(ok).To(Equal(false))
+ })
+
+ It("Parses and returns all methods if passed an empty array", func() {
+ contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
+ err = p.Parse(contractAddr)
+ Expect(err).ToNot(HaveOccurred())
+
+ selectMethods := p.GetMethods([]string{})
+
+ _, ok := selectMethods["balanceOf"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["totalSupply"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["allowance"]
+ Expect(ok).To(Equal(true))
+ })
+
+ It("Parses and returns no methods if pass a nil array", func() {
+ contractAddr := "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359"
+ err = p.Parse(contractAddr)
+ Expect(err).ToNot(HaveOccurred())
+
+ selectMethods := p.GetMethods(nil)
+ Expect(len(selectMethods)).To(Equal(0))
+ })
+ })
+
+ Describe("GetAddrMethods", func() {
+ It("Parses and returns only methods whose inputs, if any, are all addresses", func() {
+ contractAddr := "0xDdE2D979e8d39BB8416eAfcFC1758f3CaB2C9C72"
+ err = p.Parse(contractAddr)
+ Expect(err).ToNot(HaveOccurred())
+ wanted := []string{"isApprovedForAll", "supportsInterface", "getApproved", "totalSupply", "balanceOf"}
+
+ methods := p.GetMethods(wanted)
+ selectMethods := p.GetAddrMethods(wanted)
+
+ _, ok := selectMethods["totalSupply"]
+ Expect(ok).To(Equal(true))
+ _, ok = methods["totalSupply"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["balanceOf"]
+ Expect(ok).To(Equal(true))
+ _, ok = methods["balanceOf"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["isApprovedForAll"]
+ Expect(ok).To(Equal(true))
+ _, ok = methods["isApprovedForAll"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["supportsInterface"]
+ Expect(ok).To(Equal(false))
+ _, ok = methods["supportsInterface"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["getApproved"]
+ Expect(ok).To(Equal(false))
+ _, ok = methods["getApproved"]
+ Expect(ok).To(Equal(true))
+
+ _, ok = selectMethods["name"]
+ Expect(ok).To(Equal(false))
+ _, ok = methods["name"]
+ Expect(ok).To(Equal(false))
+ })
+ })
})
diff --git a/pkg/omni/poller/poller.go b/pkg/omni/poller/poller.go
new file mode 100644
index 00000000..a75b3601
--- /dev/null
+++ b/pkg/omni/poller/poller.go
@@ -0,0 +1,153 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package poller
+
+import (
+ "errors"
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+
+ "github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/types"
+)
+
+type Poller interface {
+ PollContract(con *contract.Contract) error
+ PollMethod(contractAbi, contractAddress, method string, methodArgs []interface{}, result interface{}, blockNumber int64) error
+}
+
+type poller struct {
+ bc core.BlockChain
+ contract *contract.Contract
+}
+
+func NewPoller(blockChain core.BlockChain) *poller {
+
+ return &poller{
+ bc: blockChain,
+ }
+}
+
+// Used to call contract's methods found in abi using list of contract-related addresses
+func (p *poller) PollContract(con *contract.Contract) error {
+ p.contract = con
+ // Iterate over each of the contracts methods
+ for _, m := range con.Methods {
+ switch len(m.Inputs) {
+ case 0:
+ if err := p.pollNoArg(m); err != nil {
+ return err
+ }
+ case 1:
+ if err := p.pollSingleArg(m); err != nil {
+ return err
+ }
+ case 2:
+ if err := p.pollDoubleArg(m); err != nil {
+ return err
+ }
+ default:
+ return errors.New("poller error: too many arguments to handle")
+
+ }
+ }
+
+ return nil
+}
+
+// Poll methods that take no arguments
+func (p *poller) pollNoArg(m *types.Method) error {
+ result := &types.Result{
+ Inputs: nil,
+ Outputs: map[int64]interface{}{},
+ PgType: m.Outputs[0].PgType,
+ }
+
+ for i := p.contract.StartingBlock; i <= p.contract.LastBlock; i++ {
+ var res interface{}
+ err := p.bc.FetchContractData(p.contract.Abi, p.contract.Address, m.Name, result.Inputs, &res, i)
+ if err != nil {
+ return err
+ }
+ result.Outputs[i] = res
+ }
+
+ // Persist results now instead of holding onto them
+ m.Results = append(m.Results, result)
+
+ return nil
+}
+
+// Use token holder address to poll methods that take 1 address argument (e.g. balanceOf)
+func (p *poller) pollSingleArg(m *types.Method) error {
+ for addr := range p.contract.TknHolderAddrs {
+ result := &types.Result{
+ Inputs: make([]interface{}, 1),
+ Outputs: map[int64]interface{}{},
+ PgType: m.Outputs[0].PgType,
+ }
+ result.Inputs[0] = common.HexToAddress(addr)
+
+ for i := p.contract.StartingBlock; i <= p.contract.LastBlock; i++ {
+ var res interface{}
+ err := p.bc.FetchContractData(constants.TusdAbiString, p.contract.Address, m.Name, result.Inputs, &res, i)
+ if err != nil {
+ return err
+ }
+ result.Outputs[i] = res
+ }
+
+ m.Results = append(m.Results, result)
+ }
+
+ return nil
+}
+
+// Use token holder address to poll methods that take 2 address arguments (e.g. allowance)
+func (p *poller) pollDoubleArg(m *types.Method) error {
+ // For a large block range and address list this will take a really, really long time- maybe we should only do 1 arg methods
+ for addr1 := range p.contract.TknHolderAddrs {
+ for addr2 := range p.contract.TknHolderAddrs {
+ result := &types.Result{
+ Inputs: make([]interface{}, 2),
+ Outputs: map[int64]interface{}{},
+ PgType: m.Outputs[0].PgType,
+ }
+ result.Inputs[0] = common.HexToAddress(addr1)
+ result.Inputs[1] = common.HexToAddress(addr2)
+
+ for i := p.contract.StartingBlock; i <= p.contract.LastBlock; i++ {
+ var res interface{}
+ err := p.bc.FetchContractData(p.contract.Abi, p.contract.Address, m.Name, result.Inputs, &res, i)
+ if err != nil {
+ return err
+ }
+ result.Outputs[i] = res
+ }
+
+ m.Results = append(m.Results, result)
+ }
+ }
+
+ return nil
+}
+
+// This is just a wrapper around the poller blockchain's FetchContractData method
+func (p *poller) PollMethod(contractAbi, contractAddress, method string, methodArgs []interface{}, result interface{}, blockNumber int64) error {
+ return p.bc.FetchContractData(contractAbi, contractAddress, method, methodArgs, result, blockNumber)
+}
diff --git a/pkg/omni/poller/poller_suite_test.go b/pkg/omni/poller/poller_suite_test.go
new file mode 100644
index 00000000..9a2ea847
--- /dev/null
+++ b/pkg/omni/poller/poller_suite_test.go
@@ -0,0 +1,35 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package poller_test
+
+import (
+ "io/ioutil"
+ "log"
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func TestPoller(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Poller Suite Test")
+}
+
+var _ = BeforeSuite(func() {
+ log.SetOutput(ioutil.Discard)
+})
diff --git a/pkg/omni/poller/poller_test.go b/pkg/omni/poller/poller_test.go
new file mode 100644
index 00000000..19c346c0
--- /dev/null
+++ b/pkg/omni/poller/poller_test.go
@@ -0,0 +1,86 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package poller_test
+
+import (
+ "github.com/ethereum/go-ethereum/common"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers"
+ "math/big"
+
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/poller"
+)
+
+var _ = Describe("Poller", func() {
+
+ var p poller.Poller
+ var con *contract.Contract
+
+ BeforeEach(func() {
+ p = poller.NewPoller(test_helpers.SetupBC())
+ })
+
+ Describe("PollContract", func() {
+ It("Polls contract methods using token holder address list", func() {
+ con = test_helpers.SetupTusdContract(nil, []string{"balanceOf"})
+ Expect(con.Abi).To(Equal(constants.TusdAbiString))
+ con.StartingBlock = 6707322
+ con.LastBlock = 6707323
+ con.TknHolderAddrs = map[string]bool{
+ "0xfE9e8709d3215310075d67E3ed32A380CCf451C8": true,
+ "0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE": true,
+ }
+
+ err := p.PollContract(con)
+ Expect(err).ToNot(HaveOccurred())
+
+ Expect(len(con.Methods["balanceOf"].Results)).To(Equal(2))
+ res1 := con.Methods["balanceOf"].Results[0]
+ res2 := con.Methods["balanceOf"].Results[1]
+ expectedRes11 := helpers.BigFromString("66386309548896882859581786")
+ expectedRes12 := helpers.BigFromString("66386309548896882859581786")
+ expectedRes21 := helpers.BigFromString("17982350181394112023885864")
+ expectedRes22 := helpers.BigFromString("17982350181394112023885864")
+ if res1.Inputs[0].(common.Address).String() == "0xfE9e8709d3215310075d67E3ed32A380CCf451C8" {
+ Expect(res2.Inputs[0].(common.Address).String()).To(Equal("0x3f5CE5FBFe3E9af3971dD833D26bA9b5C936f0bE"))
+ Expect(res1.Outputs[6707322].(*big.Int).String()).To(Equal(expectedRes11.String()))
+ Expect(res1.Outputs[6707323].(*big.Int).String()).To(Equal(expectedRes12.String()))
+ Expect(res2.Outputs[6707322].(*big.Int).String()).To(Equal(expectedRes21.String()))
+ Expect(res2.Outputs[6707323].(*big.Int).String()).To(Equal(expectedRes22.String()))
+ } else {
+ Expect(res2.Inputs[0].(common.Address).String()).To(Equal("0xfE9e8709d3215310075d67E3ed32A380CCf451C8"))
+ Expect(res2.Outputs[6707322].(*big.Int).String()).To(Equal(expectedRes11.String()))
+ Expect(res2.Outputs[6707323].(*big.Int).String()).To(Equal(expectedRes12.String()))
+ Expect(res1.Outputs[6707322].(*big.Int).String()).To(Equal(expectedRes21.String()))
+ Expect(res1.Outputs[6707323].(*big.Int).String()).To(Equal(expectedRes22.String()))
+ }
+ })
+ })
+
+ Describe("PollMethod", func() {
+ It("Polls a single contract method", func() {
+ var name = new(string)
+ err := p.PollMethod(constants.TusdAbiString, constants.TusdContractAddress, "name", nil, &name, 6197514)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(*name).To(Equal("TrueUSD"))
+ })
+ })
+})
diff --git a/pkg/omni/repository/event_repository.go b/pkg/omni/repository/event_repository.go
new file mode 100644
index 00000000..bdcc99f3
--- /dev/null
+++ b/pkg/omni/repository/event_repository.go
@@ -0,0 +1,203 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package repository
+
+import (
+ "errors"
+ "fmt"
+ "strings"
+
+ "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/types"
+)
+
+// Event datastore is used to persist event data into custom tables
+type EventDatastore interface {
+ PersistContractEvents(con *contract.Contract) error
+ CreateEventTable(contractName string, event *types.Event) (bool, error)
+ CreateContractSchema(contractName string) (bool, error)
+}
+
+type eventDatastore struct {
+ *postgres.DB
+}
+
+func NewEventDataStore(db *postgres.DB) *eventDatastore {
+
+ return &eventDatastore{
+ DB: db,
+ }
+}
+
+// Creates a schema for the contract
+// Creates tables for the watched contract events
+// Persists converted event log data into these custom tables
+func (d *eventDatastore) PersistContractEvents(con *contract.Contract) error {
+ _, err := d.CreateContractSchema(con.Address)
+ if err != nil {
+ return err
+ }
+
+ for eventName := range con.Filters {
+ event := con.Events[eventName]
+
+ // Move to next event if there are no logs to process
+ if len(event.Logs) == 0 {
+ break
+ }
+
+ // Create a pg table for the event if one does not already exist
+ _, err = d.CreateEventTable(con.Address, event)
+ if err != nil {
+ return err
+ }
+
+ // Persist event log data in this table
+ err = d.persistLogs(eventName, con)
+ if err != nil {
+ return err
+ }
+
+ // Clear logs when we are done using them
+ event.Logs = map[int64]types.Log{}
+ }
+
+ return nil
+}
+
+// Creates a custom postgres command to persist logs for the given event
+func (d *eventDatastore) persistLogs(eventName string, con *contract.Contract) error {
+ for id, log := range con.Events[eventName].Logs {
+ // Begin postgres string
+ pgStr := fmt.Sprintf("INSERT INTO c%s.%s ", strings.ToLower(con.Address), strings.ToLower(eventName))
+ pgStr = pgStr + "(vulcanize_log_id, token_name, block, tx"
+
+ // Pack the corresponding variables in a slice
+ var data []interface{}
+ data = append(data,
+ id,
+ con.Name,
+ log.Block,
+ log.Tx)
+
+ // Iterate over name-value pairs in the log adding
+ // names to the string and pushing values to the slice
+ counter := 0 // Keep track of number of inputs
+ for inputName, input := range log.Values {
+ counter += 1
+ pgStr = pgStr + fmt.Sprintf(", %s_", strings.ToLower(inputName)) // Add underscore after to avoid any collisions with reserved pg words
+ data = append(data, input)
+ }
+
+ // Finish off the string and execute the command using the packed data
+ // For each input entry we created we add its postgres command variable to the string
+ pgStr = pgStr + ") VALUES ($1, $2, $3, $4"
+ for i := 0; i < counter; i++ {
+ pgStr = pgStr + fmt.Sprintf(", $%d", i+5)
+ }
+ pgStr = pgStr + ") ON CONFLICT (vulcanize_log_id) DO NOTHING"
+
+ _, err := d.DB.Exec(pgStr, data...)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// Checks for event table and creates it if it does not already exist
+func (d *eventDatastore) CreateEventTable(contractName string, event *types.Event) (bool, error) {
+ tableExists, err := d.checkForTable(contractName, event.Name)
+ if err != nil {
+ return false, err
+ }
+
+ if !tableExists {
+ err = d.newEventTable(contractName, event)
+ if err != nil {
+ return false, err
+ }
+ }
+
+ return !tableExists, nil
+}
+
+// Creates a table for the given contract and event
+func (d *eventDatastore) newEventTable(contractAddr string, event *types.Event) error {
+ // Begin pg string
+ pgStr := fmt.Sprintf("CREATE TABLE IF NOT EXISTS c%s.%s ", strings.ToLower(contractAddr), strings.ToLower(event.Name))
+ pgStr = pgStr + "(id SERIAL, vulcanize_log_id INTEGER NOT NULL UNIQUE, token_name CHARACTER VARYING(66) NOT NULL, block INTEGER NOT NULL, tx CHARACTER VARYING(66) NOT NULL,"
+
+ // Iterate over event fields, using their name and pgType to grow the string
+ for _, field := range event.Fields {
+ pgStr = pgStr + fmt.Sprintf(" %s_ %s NOT NULL,", strings.ToLower(field.Name), field.PgType)
+ }
+
+ pgStr = pgStr + " CONSTRAINT log_index_fk FOREIGN KEY (vulcanize_log_id) REFERENCES logs (id) ON DELETE CASCADE)"
+ _, err := d.DB.Exec(pgStr)
+
+ return err
+}
+
+// Checks if a table already exists for the given contract and event
+func (d *eventDatastore) checkForTable(contractAddr string, eventName string) (bool, error) {
+ pgStr := fmt.Sprintf("SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'c%s' AND table_name = '%s')", strings.ToLower(contractAddr), strings.ToLower(eventName))
+
+ var exists bool
+ err := d.DB.Get(&exists, pgStr)
+
+ return exists, err
+}
+
+// Checks for contract schema and creates it if it does not already exist
+func (d *eventDatastore) CreateContractSchema(contractAddr string) (bool, error) {
+ if contractAddr == "" {
+ return false, errors.New("error: no contract address specified")
+ }
+ schemaExists, err := d.checkForSchema(contractAddr)
+ if err != nil {
+ return false, err
+ }
+
+ if !schemaExists {
+ err = d.newContractSchema(contractAddr)
+ if err != nil {
+ return false, err
+ }
+ }
+
+ return !schemaExists, nil
+}
+
+// Creates a schema for the given contract
+func (d *eventDatastore) newContractSchema(contractAddr string) error {
+ _, err := d.DB.Exec("CREATE SCHEMA IF NOT EXISTS c" + strings.ToLower(contractAddr))
+
+ return err
+}
+
+// Checks if a schema already exists for the given contract
+func (d *eventDatastore) checkForSchema(contractAddr string) (bool, error) {
+ pgStr := fmt.Sprintf("SELECT EXISTS (SELECT schema_name FROM information_schema.schemata WHERE schema_name = 'c%s')", strings.ToLower(contractAddr))
+
+ var exists bool
+ err := d.DB.QueryRow(pgStr).Scan(&exists)
+
+ return exists, err
+}
diff --git a/pkg/omni/repository/event_repository_test.go b/pkg/omni/repository/event_repository_test.go
new file mode 100644
index 00000000..b5c343f9
--- /dev/null
+++ b/pkg/omni/repository/event_repository_test.go
@@ -0,0 +1,173 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package repository_test
+
+import (
+ "fmt"
+ "math/rand"
+ "time"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+
+ "github.com/vulcanize/vulcanizedb/pkg/core"
+ "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/converter"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/repository"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/types"
+)
+
+var mockEvent = core.WatchedEvent{
+ Name: constants.TransferEvent.String(),
+ BlockNumber: 5488076,
+ Address: constants.TusdContractAddress,
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ Index: 110,
+ Topic0: constants.TransferEvent.Signature(),
+ Topic1: "0x000000000000000000000000000000000000000000000000000000000000af21",
+ Topic2: "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
+ Topic3: "",
+ Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+}
+
+var _ = Describe("Repository", func() {
+ var db *postgres.DB
+ var dataStore repository.EventDatastore
+ var err error
+ var con *contract.Contract
+ var vulcanizeLogId int64
+ var wantedEvents = []string{"Transfer"}
+ var event *types.Event
+ rand.Seed(time.Now().UnixNano())
+
+ BeforeEach(func() {
+ db, con = test_helpers.SetupTusdRepo(&vulcanizeLogId, wantedEvents, []string{})
+ mockEvent.LogID = vulcanizeLogId
+
+ event = con.Events["Transfer"]
+ err = con.GenerateFilters()
+ Expect(err).ToNot(HaveOccurred())
+
+ c := converter.NewConverter(con)
+ err = c.Convert(mockEvent, event)
+ Expect(err).ToNot(HaveOccurred())
+
+ dataStore = repository.NewEventDataStore(db)
+ })
+
+ AfterEach(func() {
+ test_helpers.TearDown(db)
+ })
+
+ Describe("CreateContractSchema", func() {
+ It("Creates schema if it doesn't exist", func() {
+ created, err := dataStore.CreateContractSchema(con.Address)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(created).To(Equal(true))
+
+ created, err = dataStore.CreateContractSchema(con.Address)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(created).To(Equal(false))
+ })
+ })
+
+ Describe("CreateContractTable", func() {
+ It("Creates table if it doesn't exist", func() {
+ created, err := dataStore.CreateContractSchema(con.Address)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(created).To(Equal(true))
+
+ created, err = dataStore.CreateEventTable(con.Address, event)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(created).To(Equal(true))
+
+ created, err = dataStore.CreateEventTable(con.Address, event)
+ Expect(err).ToNot(HaveOccurred())
+ Expect(created).To(Equal(false))
+ })
+ })
+
+ Describe("PersistContractEvents", func() {
+ It("Persists contract event values into custom tables, adding any addresses to a growing list of contract associated addresses", func() {
+ err = dataStore.PersistContractEvents(con)
+ Expect(err).ToNot(HaveOccurred())
+
+ b, ok := con.TknHolderAddrs["0x000000000000000000000000000000000000Af21"]
+ Expect(ok).To(Equal(true))
+ Expect(b).To(Equal(true))
+
+ b, ok = con.TknHolderAddrs["0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"]
+ Expect(ok).To(Equal(true))
+ Expect(b).To(Equal(true))
+
+ log := test_helpers.TransferLog{}
+
+ err = db.QueryRowx(fmt.Sprintf("SELECT * FROM c%s.Transfer", constants.TusdContractAddress)).StructScan(&log)
+ expectedLog := test_helpers.TransferLog{
+ Id: 1,
+ VulvanizeLogId: vulcanizeLogId,
+ TokenName: "TrueUSD",
+ Block: 5488076,
+ Tx: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ From: "0x000000000000000000000000000000000000Af21",
+ To: "0x09BbBBE21a5975cAc061D82f7b843bCE061BA391",
+ Value: "1097077688018008265106216665536940668749033598146",
+ }
+ Expect(log).To(Equal(expectedLog))
+ })
+
+ It("Doesn't persist duplicate event logs", func() {
+ // Perist once
+ err = dataStore.PersistContractEvents(con)
+ Expect(err).ToNot(HaveOccurred())
+
+ log := test_helpers.TransferLog{}
+
+ err = db.QueryRowx(fmt.Sprintf("SELECT * FROM c%s.Transfer", constants.TusdContractAddress)).StructScan(&log)
+ expectedLog := test_helpers.TransferLog{
+ Id: 1,
+ VulvanizeLogId: vulcanizeLogId,
+ TokenName: "TrueUSD",
+ Block: 5488076,
+ Tx: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ From: "0x000000000000000000000000000000000000Af21",
+ To: "0x09BbBBE21a5975cAc061D82f7b843bCE061BA391",
+ Value: "1097077688018008265106216665536940668749033598146",
+ }
+
+ Expect(log).To(Equal(expectedLog))
+
+ // Attempt to persist the same contract again
+ err = dataStore.PersistContractEvents(con)
+ Expect(err).ToNot(HaveOccurred())
+
+ // Show that no new logs were entered
+ var count int
+ err = db.Get(&count, fmt.Sprintf("SELECT COUNT(*) FROM c%s.Transfer", constants.TusdContractAddress))
+ Expect(err).ToNot(HaveOccurred())
+ Expect(count).To(Equal(1))
+ })
+
+ It("Fails with empty contract", func() {
+ err = dataStore.PersistContractEvents(&contract.Contract{})
+ Expect(err).To(HaveOccurred())
+ })
+ })
+})
diff --git a/pkg/omni/repository/method_repository.go b/pkg/omni/repository/method_repository.go
new file mode 100644
index 00000000..7a9f5eca
--- /dev/null
+++ b/pkg/omni/repository/method_repository.go
@@ -0,0 +1,153 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package repository
+
+import (
+ "fmt"
+ "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/types"
+ "strings"
+)
+
+type MethodDatastore interface {
+ PersistContractMethods(con *contract.Contract) error
+ PersistResults(methodName string, con *contract.Contract) error
+ CreateMethodTable(contractName string, method *types.Method) error
+ CreateContractSchema(contractName string) error
+}
+
+type methodDatastore struct {
+ *postgres.DB
+}
+
+func NewMethodDatastore(db *postgres.DB) *methodDatastore {
+
+ return &methodDatastore{
+ DB: db,
+ }
+}
+
+func (d *methodDatastore) PersistContractMethods(con *contract.Contract) error {
+ err := d.CreateContractSchema(con.Name)
+ if err != nil {
+ return err
+ }
+
+ for _, method := range con.Methods {
+ err = d.CreateMethodTable(con.Name, method)
+ if err != nil {
+ return err
+ }
+
+ //TODO: Persist method data
+
+ }
+
+ return nil
+}
+
+// Creates a custom postgres command to persist logs for the given event
+func (d *methodDatastore) PersistResults(methodName string, con *contract.Contract) error {
+ for _, result := range con.Methods[methodName].Results {
+ println(result)
+ //TODO: Persist result data
+ }
+
+ return nil
+}
+
+// Checks for event table and creates it if it does not already exist
+func (d *methodDatastore) CreateMethodTable(contractAddr string, method *types.Method) error {
+ tableExists, err := d.checkForTable(contractAddr, method.Name)
+ if err != nil {
+ return err
+ }
+
+ if !tableExists {
+ err = d.newMethodTable(contractAddr, method)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// Creates a table for the given contract and event
+func (d *methodDatastore) newMethodTable(contractAddr string, method *types.Method) error {
+ // Begin pg string
+ pgStr := fmt.Sprintf("CREATE TABLE IF NOT EXISTS _%s.%s ", strings.ToLower(contractAddr), strings.ToLower(method.Name))
+ pgStr = pgStr + "(id SERIAL, token_name CHARACTER VARYING(66) NOT NULL, block INTEGER NOT NULL,"
+
+ // Iterate over method inputs and outputs, using their name and pgType to grow the string
+ for _, input := range method.Inputs {
+ pgStr = pgStr + fmt.Sprintf("%s_ %s NOT NULL,", strings.ToLower(input.Name), input.PgType)
+ }
+
+ for _, output := range method.Outputs {
+ pgStr = pgStr + fmt.Sprintf(" %s_ %s NOT NULL,", strings.ToLower(output.Name), output.PgType)
+ }
+
+ pgStr = pgStr[:len(pgStr)-1] + ")"
+ _, err := d.DB.Exec(pgStr)
+
+ return err
+}
+
+// Checks if a table already exists for the given contract and event
+func (d *methodDatastore) checkForTable(contractAddr string, methodName string) (bool, error) {
+ pgStr := fmt.Sprintf("SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = '_%s' AND table_name = '%s')", strings.ToLower(contractAddr), strings.ToLower(methodName))
+ var exists bool
+ err := d.DB.Get(&exists, pgStr)
+
+ return exists, err
+}
+
+// Checks for contract schema and creates it if it does not already exist
+func (d *methodDatastore) CreateContractSchema(contractName string) error {
+ schemaExists, err := d.checkForSchema(contractName)
+ if err != nil {
+ return err
+ }
+
+ if !schemaExists {
+ err = d.newContractSchema(contractName)
+ if err != nil {
+ return err
+ }
+ }
+
+ return nil
+}
+
+// Creates a schema for the given contract
+func (d *methodDatastore) newContractSchema(contractAddr string) error {
+ _, err := d.DB.Exec("CREATE SCHEMA IF NOT EXISTS _" + strings.ToLower(contractAddr))
+
+ return err
+}
+
+// Checks if a schema already exists for the given contract
+func (d *methodDatastore) checkForSchema(contractAddr string) (bool, error) {
+ pgStr := fmt.Sprintf("SELECT EXISTS (SELECT schema_name FROM information_schema.schemata WHERE schema_name = '_%s')", strings.ToLower(contractAddr))
+
+ var exists bool
+ err := d.DB.Get(&exists, pgStr)
+
+ return exists, err
+}
diff --git a/pkg/omni/repository/method_repository_test.go b/pkg/omni/repository/method_repository_test.go
new file mode 100644
index 00000000..49683f17
--- /dev/null
+++ b/pkg/omni/repository/method_repository_test.go
@@ -0,0 +1,17 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+package repository
diff --git a/pkg/omni/repository/repository.go b/pkg/omni/repository/repository.go
deleted file mode 100644
index f4f5d252..00000000
--- a/pkg/omni/repository/repository.go
+++ /dev/null
@@ -1,179 +0,0 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
-
-package repository
-
-import (
- "fmt"
- "math/big"
- "strings"
-
- "github.com/ethereum/go-ethereum/common"
-
- "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
- "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
- "github.com/vulcanize/vulcanizedb/pkg/omni/types"
-)
-
-// Repository is used to
-type DataStore interface {
- PersistEvents(info *contract.Contract) error
-}
-
-type dataStore struct {
- *postgres.DB
-}
-
-func NewDataStore(db *postgres.DB) *dataStore {
-
- return &dataStore{
- DB: db,
- }
-}
-
-// Creates a schema for the contract
-// Creates tables for the watched contract events
-// Persists converted event log data into these custom tables
-func (d *dataStore) PersistEvents(con *contract.Contract) error {
-
- schemaExists, err := d.CheckForSchema(con.Name)
- if err != nil {
- return err
- }
-
- if !schemaExists {
- err = d.CreateContractSchema(con.Name)
- if err != nil {
- return err
- }
- }
-
- for eventName := range con.Filters {
- event := con.Events[eventName]
- if len(event.Logs) == 0 {
- break
- }
-
- tableExists, err := d.CheckForTable(con.Name, eventName)
- if err != nil {
- return err
- }
-
- if !tableExists {
- err = d.CreateEventTable(con.Name, event)
- if err != nil {
- return err
- }
- }
-
- for id, log := range event.Logs {
- // Create postgres command to persist any given event
- pgStr := fmt.Sprintf("INSERT INTO %s.%s ", strings.ToLower(con.Name), strings.ToLower(eventName))
- pgStr = pgStr + "(vulcanize_log_id, token_name, token_address, event_name, block, tx"
- var data []interface{}
- data = append(data,
- id,
- strings.ToLower(con.Name),
- strings.ToLower(con.Address),
- strings.ToLower(eventName),
- log.Block,
- log.Tx)
-
- counter := 0
- for inputName, input := range log.Values {
- // postgres cannot handle custom types, resolve to strings
- switch input.(type) {
- case big.Int:
- var b big.Int
- b = input.(big.Int)
- input = b.String()
- case *big.Int:
- var b *big.Int
- b = input.(*big.Int)
- input = b.String()
- case common.Address:
- var a common.Address
- a = input.(common.Address)
- input = a.String() // this also gives us a chance to add any event emitted address
- con.AddAddress(a.String()) // to a list of token-related addresses, growing it as we go
- case common.Hash:
- var h common.Hash
- h = input.(common.Hash)
- input = h.String()
- }
-
- counter += 1
- pgStr = pgStr + fmt.Sprintf(", _%s", strings.ToLower(inputName))
- data = append(data, input)
- }
-
- appendStr := "VALUES ($1, $2, $3, $4, $5, $6"
-
- for i := 0; i < counter; i++ {
- appendStr = appendStr + fmt.Sprintf(", $%d", i+7)
- }
-
- appendStr = appendStr + ") "
- appendStr = appendStr + "ON CONFLICT (vulcanize_log_id) DO NOTHING"
- pgStr = pgStr + fmt.Sprintf(") %s", appendStr)
-
- _, err := d.DB.Exec(pgStr, data...)
- if err != nil {
- return err
- }
- }
- }
-
- return nil
-}
-
-// Creates a table for the given contract and event
-func (d *dataStore) CreateEventTable(contractName string, event *types.Event) error {
- // Create postgres command to create table for any given event
- pgStr := fmt.Sprintf("CREATE TABLE IF NOT EXISTS %s.%s ", strings.ToLower(contractName), strings.ToLower(event.Name))
- pgStr = pgStr + "(id SERIAL, vulcanize_log_id INTEGER NOT NULL UNIQUE, token_name CHARACTER VARYING(66) NOT NULL, token_address CHARACTER VARYING(66) NOT NULL, event_name CHARACTER VARYING(66) NOT NULL, block INTEGER NOT NULL, tx CHARACTER VARYING(66) NOT NULL,"
- for _, field := range event.Fields {
- pgStr = pgStr + fmt.Sprintf(" _%s %s NOT NULL,", field.Name, field.PgType)
- }
- pgStr = pgStr + " CONSTRAINT log_index_fk FOREIGN KEY (vulcanize_log_id) REFERENCES logs (id) ON DELETE CASCADE)"
- _, err := d.DB.Exec(pgStr)
-
- return err
-}
-
-// Checks if a table already exists for the given contract and event
-func (d *dataStore) CheckForTable(contractName string, eventName string) (bool, error) {
- pgStr := fmt.Sprintf("SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = '%s' AND table_name = '%s')", contractName, eventName)
- var exists bool
- err := d.DB.Get(&exists, pgStr)
-
- return exists, err
-}
-
-// Creates a schema for the given contract
-func (d *dataStore) CreateContractSchema(contractName string) error {
- _, err := d.DB.Exec("CREATE SCHEMA IF NOT EXISTS " + contractName)
-
- return err
-}
-
-// Checks if a schema already exists for the given contract
-func (d *dataStore) CheckForSchema(contractName string) (bool, error) {
- pgStr := fmt.Sprintf("SELECT EXISTS (SELECT schema_name FROM information_schema.schemata WHERE schema_name = '%s')", contractName)
-
- var exists bool
- err := d.DB.Get(&exists, pgStr)
-
- return exists, err
-}
diff --git a/pkg/omni/repository/repository_suite_test.go b/pkg/omni/repository/repository_suite_test.go
index a4102f55..dfc72792 100644
--- a/pkg/omni/repository/repository_suite_test.go
+++ b/pkg/omni/repository/repository_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package repository_test
diff --git a/pkg/omni/repository/repository_test.go b/pkg/omni/repository/repository_test.go
deleted file mode 100644
index f0059b67..00000000
--- a/pkg/omni/repository/repository_test.go
+++ /dev/null
@@ -1,141 +0,0 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
-
-package repository_test
-
-import (
- "math/rand"
- "time"
-
- . "github.com/onsi/ginkgo"
- . "github.com/onsi/gomega"
-
- "github.com/vulcanize/vulcanizedb/examples/constants"
- "github.com/vulcanize/vulcanizedb/examples/test_helpers"
- "github.com/vulcanize/vulcanizedb/pkg/config"
- "github.com/vulcanize/vulcanizedb/pkg/core"
- "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
- "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
- "github.com/vulcanize/vulcanizedb/pkg/omni/contract"
- "github.com/vulcanize/vulcanizedb/pkg/omni/converter"
- "github.com/vulcanize/vulcanizedb/pkg/omni/parser"
- "github.com/vulcanize/vulcanizedb/pkg/omni/repository"
-)
-
-var mockEvent = core.WatchedEvent{
- Name: constants.TransferEvent.String(),
- BlockNumber: 5488076,
- Address: constants.TusdContractAddress,
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- Index: 110,
- Topic0: constants.TransferEvent.Signature(),
- Topic1: "0x000000000000000000000000000000000000000000000000000000000000af21",
- Topic2: "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
- Topic3: "",
- Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
-}
-
-var _ = Describe("Repository Test", func() {
- var db *postgres.DB
- var logRepository repositories.LogRepository
- var blockRepository repositories.BlockRepository
- var receiptRepository repositories.ReceiptRepository
- var dataStore repository.DataStore
- var err error
- var info *contract.Contract
- var blockNumber int64
- var blockId int64
- var vulcanizeLogId int64
- rand.Seed(time.Now().UnixNano())
-
- BeforeEach(func() {
- db, err = postgres.NewDB(config.Database{
- Hostname: "localhost",
- Name: "vulcanize_private",
- Port: 5432,
- }, core.Node{})
- Expect(err).NotTo(HaveOccurred())
-
- receiptRepository = repositories.ReceiptRepository{DB: db}
- logRepository = repositories.LogRepository{DB: db}
- blockRepository = *repositories.NewBlockRepository(db)
-
- blockNumber = rand.Int63()
- blockId = test_helpers.CreateBlock(blockNumber, blockRepository)
-
- log := core.Log{}
- logs := []core.Log{log}
- receipt := core.Receipt{
- Logs: logs,
- }
- receipts := []core.Receipt{receipt}
-
- err = receiptRepository.CreateReceiptsAndLogs(blockId, receipts)
- Expect(err).ToNot(HaveOccurred())
-
- err = logRepository.Get(&vulcanizeLogId, `SELECT id FROM logs`)
- Expect(err).ToNot(HaveOccurred())
-
- p := parser.NewParser("")
- err = p.Parse(constants.TusdContractAddress)
- Expect(err).ToNot(HaveOccurred())
-
- info = &contract.Contract{
- Name: "TrueUSD",
- Address: constants.TusdContractAddress,
- Abi: p.Abi(),
- ParsedAbi: p.ParsedAbi(),
- StartingBlock: 5197514,
- Events: p.GetEvents(),
- Methods: p.GetMethods(),
- Addresses: map[string]bool{},
- }
-
- event := info.Events["Transfer"]
- err = info.GenerateFilters([]string{"Transfer"})
- Expect(err).ToNot(HaveOccurred())
- c := converter.NewConverter(*info)
- mockEvent.LogID = vulcanizeLogId
- err = c.Convert(mockEvent, event)
- Expect(err).ToNot(HaveOccurred())
-
- dataStore = repository.NewDataStore(db)
- })
-
- AfterEach(func() {
- db.Query(`DELETE FROM blocks`)
- db.Query(`DELETE FROM logs`)
- db.Query(`DELETE FROM transactions`)
- db.Query(`DELETE FROM receipts`)
- db.Query(`DROP SCHEMA IF EXISTS trueusd CASCADE`)
- })
-
- It("Persist contract info in custom tables", func() {
- err = dataStore.PersistEvents(info)
- Expect(err).ToNot(HaveOccurred())
-
- b, ok := info.Addresses["0x000000000000000000000000000000000000Af21"]
- Expect(ok).To(Equal(true))
- Expect(b).To(Equal(true))
-
- b, ok = info.Addresses["0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"]
- Expect(ok).To(Equal(true))
- Expect(b).To(Equal(true))
- })
-
- It("Fails with empty contract", func() {
- err = dataStore.PersistEvents(&contract.Contract{})
- Expect(err).To(HaveOccurred())
- })
-})
diff --git a/pkg/omni/retriever/address_retriever.go b/pkg/omni/retriever/address_retriever.go
index 2c71eb60..122edf5f 100644
--- a/pkg/omni/retriever/address_retriever.go
+++ b/pkg/omni/retriever/address_retriever.go
@@ -1,21 +1,24 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package retriever
import (
"fmt"
+ "strings"
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
@@ -74,15 +77,15 @@ func (r *addressRetriever) RetrieveTokenHolderAddresses(info contract.Contract)
return contractAddresses, nil
}
-func (r *addressRetriever) retrieveTransferAddresses(contract contract.Contract) ([]string, error) {
+func (r *addressRetriever) retrieveTransferAddresses(con contract.Contract) ([]string, error) {
transferAddrs := make([]string, 0)
- event := contract.Events["Transfer"]
+ event := con.Events["Transfer"]
for _, field := range event.Fields { // Iterate over event fields, finding the ones with address type
if field.Type.T == abi.AddressTy { // If they have address type, retrieve those addresses
addrs := make([]string, 0)
- pgStr := fmt.Sprintf("SELECT _%s FROM %s.%s", field.Name, contract.Name, event.Name)
+ pgStr := fmt.Sprintf("SELECT %s_ FROM c%s.%s", strings.ToLower(field.Name), strings.ToLower(con.Address), strings.ToLower(event.Name))
err := r.DB.Select(&addrs, pgStr)
if err != nil {
return []string{}, err
@@ -95,15 +98,15 @@ func (r *addressRetriever) retrieveTransferAddresses(contract contract.Contract)
return transferAddrs, nil
}
-func (r *addressRetriever) retrieveTokenMintees(contract contract.Contract) ([]string, error) {
+func (r *addressRetriever) retrieveTokenMintees(con contract.Contract) ([]string, error) {
mintAddrs := make([]string, 0)
- event := contract.Events["Mint"]
+ event := con.Events["Mint"]
for _, field := range event.Fields { // Iterate over event fields, finding the ones with address type
if field.Type.T == abi.AddressTy { // If they have address type, retrieve those addresses
addrs := make([]string, 0)
- pgStr := fmt.Sprintf("SELECT _%s FROM %s.%s", field.Name, contract.Name, event.Name)
+ pgStr := fmt.Sprintf("SELECT %s_ FROM c%s.%s", strings.ToLower(field.Name), strings.ToLower(con.Address), strings.ToLower(event.Name))
err := r.DB.Select(&addrs, pgStr)
if err != nil {
return []string{}, err
diff --git a/pkg/omni/retriever/address_retriever_test.go b/pkg/omni/retriever/address_retriever_test.go
index 65a05fd7..d61627bd 100644
--- a/pkg/omni/retriever/address_retriever_test.go
+++ b/pkg/omni/retriever/address_retriever_test.go
@@ -1,36 +1,32 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package retriever_test
import (
- "math/rand"
- "time"
-
"github.com/ethereum/go-ethereum/common"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
- "github.com/vulcanize/vulcanizedb/examples/test_helpers"
- "github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
- "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
"github.com/vulcanize/vulcanizedb/pkg/omni/contract"
"github.com/vulcanize/vulcanizedb/pkg/omni/converter"
- "github.com/vulcanize/vulcanizedb/pkg/omni/parser"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/omni/repository"
"github.com/vulcanize/vulcanizedb/pkg/omni/retriever"
)
@@ -50,103 +46,60 @@ var mockEvent = core.WatchedEvent{
var _ = Describe("Address Retriever Test", func() {
var db *postgres.DB
- var logRepository repositories.LogRepository
- var blockRepository repositories.BlockRepository
- var receiptRepository repositories.ReceiptRepository
- var dataStore repository.DataStore
+ var dataStore repository.EventDatastore
var err error
var info *contract.Contract
- var blockNumber int64
- var blockId int64
var vulcanizeLogId int64
var r retriever.AddressRetriever
var addresses map[common.Address]bool
- rand.Seed(time.Now().UnixNano())
+ var wantedEvents = []string{"Transfer"}
BeforeEach(func() {
- db, err = postgres.NewDB(config.Database{
- Hostname: "localhost",
- Name: "vulcanize_private",
- Port: 5432,
- }, core.Node{})
- Expect(err).NotTo(HaveOccurred())
-
- receiptRepository = repositories.ReceiptRepository{DB: db}
- logRepository = repositories.LogRepository{DB: db}
- blockRepository = *repositories.NewBlockRepository(db)
-
- blockNumber = rand.Int63()
- blockId = test_helpers.CreateBlock(blockNumber, blockRepository)
-
- log := core.Log{}
- logs := []core.Log{log}
- receipt := core.Receipt{
- Logs: logs,
- }
- receipts := []core.Receipt{receipt}
-
- err = receiptRepository.CreateReceiptsAndLogs(blockId, receipts)
- Expect(err).ToNot(HaveOccurred())
-
- err = logRepository.Get(&vulcanizeLogId, `SELECT id FROM logs`)
- Expect(err).ToNot(HaveOccurred())
-
- p := parser.NewParser("")
- err = p.Parse(constants.TusdContractAddress)
- Expect(err).ToNot(HaveOccurred())
-
- info = &contract.Contract{
- Name: "TrueUSD",
- Address: constants.TusdContractAddress,
- Abi: p.Abi(),
- ParsedAbi: p.ParsedAbi(),
- StartingBlock: 5197514,
- Events: p.GetEvents(),
- Methods: p.GetMethods(),
- Addresses: map[string]bool{},
- }
+ db, info = test_helpers.SetupTusdRepo(&vulcanizeLogId, wantedEvents, []string{})
+ mockEvent.LogID = vulcanizeLogId
event := info.Events["Transfer"]
- err = info.GenerateFilters([]string{"Transfer"})
+ err = info.GenerateFilters()
Expect(err).ToNot(HaveOccurred())
- c := converter.NewConverter(*info)
- mockEvent.LogID = vulcanizeLogId
+
+ c := converter.NewConverter(info)
err = c.Convert(mockEvent, event)
Expect(err).ToNot(HaveOccurred())
- dataStore = repository.NewDataStore(db)
- err = dataStore.PersistEvents(info)
+ dataStore = repository.NewEventDataStore(db)
+ dataStore.PersistContractEvents(info)
Expect(err).ToNot(HaveOccurred())
r = retriever.NewAddressRetriever(db)
})
AfterEach(func() {
- db.Query(`DELETE FROM blocks`)
- db.Query(`DELETE FROM logs`)
- db.Query(`DELETE FROM transactions`)
- db.Query(`DELETE FROM receipts`)
- db.Query(`DROP SCHEMA IF EXISTS trueusd CASCADE`)
+ test_helpers.TearDown(db)
})
- It("Retrieves a list of token holder addresses", func() {
- addresses, err = r.RetrieveTokenHolderAddresses(*info)
- Expect(err).ToNot(HaveOccurred())
+ Describe("RetrieveTokenHolderAddresses", func() {
+ It("Retrieves a list of token holder addresses from persisted event logs", func() {
+ addresses, err = r.RetrieveTokenHolderAddresses(*info)
+ Expect(err).ToNot(HaveOccurred())
- _, ok := addresses[common.HexToAddress("0x000000000000000000000000000000000000000000000000000000000000af21")]
- Expect(ok).To(Equal(true))
+ _, ok := addresses[common.HexToAddress("0x000000000000000000000000000000000000000000000000000000000000af21")]
+ Expect(ok).To(Equal(true))
- _, ok = addresses[common.HexToAddress("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391")]
- Expect(ok).To(Equal(true))
+ _, ok = addresses[common.HexToAddress("0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391")]
+ Expect(ok).To(Equal(true))
- _, ok = addresses[common.HexToAddress("0x")]
- Expect(ok).To(Equal(false))
+ _, ok = addresses[common.HexToAddress("0x")]
+ Expect(ok).To(Equal(false))
- })
+ _, ok = addresses[common.HexToAddress(constants.TusdContractAddress)]
+ Expect(ok).To(Equal(false))
- It("Returns empty list when empty contract info is used", func() {
- addresses, err = r.RetrieveTokenHolderAddresses(contract.Contract{})
- Expect(err).ToNot(HaveOccurred())
- Expect(len(addresses)).To(Equal(0))
+ })
+
+ It("Returns empty list when empty contract info is used", func() {
+ addresses, err = r.RetrieveTokenHolderAddresses(contract.Contract{})
+ Expect(err).ToNot(HaveOccurred())
+ Expect(len(addresses)).To(Equal(0))
+ })
})
})
diff --git a/pkg/omni/retriever/block_retriever.go b/pkg/omni/retriever/block_retriever.go
index 93446371..2854e8ef 100644
--- a/pkg/omni/retriever/block_retriever.go
+++ b/pkg/omni/retriever/block_retriever.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package retriever
diff --git a/pkg/omni/retriever/block_retriever_test.go b/pkg/omni/retriever/block_retriever_test.go
index b8383021..d77bbacc 100644
--- a/pkg/omni/retriever/block_retriever_test.go
+++ b/pkg/omni/retriever/block_retriever_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package retriever_test
@@ -18,186 +20,198 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
- "github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/omni/retriever"
)
-var _ = Describe("Block Retriever Test", func() {
+var _ = Describe("Block Retriever", func() {
var db *postgres.DB
var r retriever.BlockRetriever
var blockRepository repositories.BlockRepository
+ // Contains no contract address
+ var block1 = core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
+ Number: 1,
+ Transactions: []core.Transaction{},
+ }
+
BeforeEach(func() {
- var err error
- db, err = postgres.NewDB(config.Database{
- Hostname: "localhost",
- Name: "vulcanize_private",
- Port: 5432,
- }, core.Node{})
- Expect(err).NotTo(HaveOccurred())
-
+ db, _ = test_helpers.SetupDBandBC()
blockRepository = *repositories.NewBlockRepository(db)
-
r = retriever.NewBlockRetriever(db)
})
AfterEach(func() {
- db.Query(`DELETE FROM blocks`)
- db.Query(`DELETE FROM logs`)
- db.Query(`DELETE FROM transactions`)
- db.Query(`DELETE FROM receipts`)
+ test_helpers.TearDown(db)
})
- It("Retrieve first block number of a contract from receipt if possible", func() {
- log := core.Log{
- BlockNumber: 2,
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- Address: constants.TusdContractAddress,
- Topics: core.Topics{
- constants.TransferEvent.Signature(),
- "0x000000000000000000000000000000000000000000000000000000000000af21",
- "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
- "",
- },
- Index: 1,
- Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
- }
+ Describe("RetrieveFirstBlock", func() {
+ It("Retrieves block number where contract first appears in receipt, if available", func() {
- receipt1 := core.Receipt{
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- ContractAddress: constants.TusdContractAddress,
- Logs: []core.Log{},
- }
+ // Contains the address in the receipt
+ block2 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
+ Number: 2,
+ Transactions: []core.Transaction{{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ Receipt: core.Receipt{
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ ContractAddress: constants.TusdContractAddress,
+ Logs: []core.Log{},
+ },
+ }},
+ }
- receipt2 := core.Receipt{
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- ContractAddress: constants.TusdContractAddress,
- Logs: []core.Log{log},
- }
+ // Contains address in logs
+ block3 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
+ Number: 3,
+ Transactions: []core.Transaction{{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
+ Receipt: core.Receipt{
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
+ ContractAddress: constants.TusdContractAddress,
+ Logs: []core.Log{{
+ BlockNumber: 3,
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
+ Address: constants.TusdContractAddress,
+ Topics: core.Topics{
+ constants.TransferEvent.Signature(),
+ "0x000000000000000000000000000000000000000000000000000000000000af21",
+ "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
+ "",
+ },
+ Index: 1,
+ Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+ }},
+ },
+ }},
+ }
- transaction1 := core.Transaction{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- Receipt: receipt1,
- }
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ blockRepository.CreateOrUpdateBlock(block3)
- transaction2 := core.Transaction{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- Receipt: receipt2,
- }
+ i, err := r.RetrieveFirstBlock(constants.TusdContractAddress)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(i).To(Equal(int64(2)))
+ })
- block1 := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
- Number: 1,
- Transactions: []core.Transaction{transaction1},
- }
+ It("Retrieves block number where contract first appears in event logs if it cannot find the address in a receipt", func() {
- block2 := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
- Number: 2,
- Transactions: []core.Transaction{transaction2},
- }
+ block2 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
+ Number: 2,
+ Transactions: []core.Transaction{{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ Receipt: core.Receipt{
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ ContractAddress: "",
+ Logs: []core.Log{{
+ BlockNumber: 2,
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
+ Address: constants.DaiContractAddress,
+ Topics: core.Topics{
+ constants.TransferEvent.Signature(),
+ "0x000000000000000000000000000000000000000000000000000000000000af21",
+ "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
+ "",
+ },
+ Index: 1,
+ Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+ }},
+ },
+ }},
+ }
- blockRepository.CreateOrUpdateBlock(block1)
- blockRepository.CreateOrUpdateBlock(block2)
+ block3 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
+ Number: 3,
+ Transactions: []core.Transaction{{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
+ Receipt: core.Receipt{
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
+ ContractAddress: "",
+ Logs: []core.Log{{
+ BlockNumber: 3,
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
+ Address: constants.DaiContractAddress,
+ Topics: core.Topics{
+ constants.TransferEvent.Signature(),
+ "0x000000000000000000000000000000000000000000000000000000000000af21",
+ "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
+ "",
+ },
+ Index: 1,
+ Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+ }},
+ },
+ }},
+ }
- i, err := r.RetrieveFirstBlock(constants.TusdContractAddress)
- Expect(err).NotTo(HaveOccurred())
- Expect(i).To(Equal(int64(1)))
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ blockRepository.CreateOrUpdateBlock(block3)
+
+ i, err := r.RetrieveFirstBlock(constants.DaiContractAddress)
+ Expect(err).NotTo(HaveOccurred())
+ Expect(i).To(Equal(int64(2)))
+ })
+
+ It("Fails if the contract address cannot be found in any blocks", func() {
+ block2 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
+ Number: 2,
+ Transactions: []core.Transaction{},
+ }
+
+ block3 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
+ Number: 3,
+ Transactions: []core.Transaction{},
+ }
+
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ blockRepository.CreateOrUpdateBlock(block3)
+
+ _, err := r.RetrieveFirstBlock(constants.DaiContractAddress)
+ Expect(err).To(HaveOccurred())
+ })
})
- It("Retrieves first block number of a contract from event logs", func() {
- log1 := core.Log{
- BlockNumber: 1,
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- Address: constants.DaiContractAddress,
- Topics: core.Topics{
- constants.TransferEvent.Signature(),
- "0x000000000000000000000000000000000000000000000000000000000000af21",
- "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
- "",
- },
- Index: 1,
- Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
- }
+ Describe("RetrieveMostRecentBlock", func() {
+ It("Retrieves the latest block", func() {
+ block2 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
+ Number: 2,
+ Transactions: []core.Transaction{},
+ }
- log2 := core.Log{
- BlockNumber: 2,
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- Address: constants.DaiContractAddress,
- Topics: core.Topics{
- constants.TransferEvent.Signature(),
- "0x000000000000000000000000000000000000000000000000000000000000af21",
- "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
- "",
- },
- Index: 1,
- Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
- }
+ block3 := core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
+ Number: 3,
+ Transactions: []core.Transaction{},
+ }
- receipt1 := core.Receipt{
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- ContractAddress: "",
- Logs: []core.Log{log1},
- }
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ blockRepository.CreateOrUpdateBlock(block3)
- receipt2 := core.Receipt{
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- ContractAddress: "",
- Logs: []core.Log{log2},
- }
+ i, err := r.RetrieveMostRecentBlock()
+ Expect(err).ToNot(HaveOccurred())
+ Expect(i).To(Equal(int64(3)))
+ })
- transaction1 := core.Transaction{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- Receipt: receipt1,
- }
-
- transaction2 := core.Transaction{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- Receipt: receipt2,
- }
-
- block1 := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
- Number: 1,
- Transactions: []core.Transaction{transaction1},
- }
-
- block2 := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
- Number: 2,
- Transactions: []core.Transaction{transaction2},
- }
-
- blockRepository.CreateOrUpdateBlock(block1)
- blockRepository.CreateOrUpdateBlock(block2)
-
- i, err := r.RetrieveFirstBlock(constants.DaiContractAddress)
- Expect(err).NotTo(HaveOccurred())
- Expect(i).To(Equal(int64(1)))
- })
-
- It("Fails if a block cannot be found", func() {
-
- block1 := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
- Number: 1,
- Transactions: []core.Transaction{},
- }
-
- block2 := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad456yui",
- Number: 2,
- Transactions: []core.Transaction{},
- }
-
- blockRepository.CreateOrUpdateBlock(block1)
- blockRepository.CreateOrUpdateBlock(block2)
-
- _, err := r.RetrieveFirstBlock(constants.DaiContractAddress)
- Expect(err).To(HaveOccurred())
+ It("Fails if it cannot retrieve the latest block", func() {
+ i, err := r.RetrieveMostRecentBlock()
+ Expect(err).To(HaveOccurred())
+ Expect(i).To(Equal(int64(0)))
+ })
})
})
diff --git a/pkg/omni/retriever/retriever_suite_test.go b/pkg/omni/retriever/retriever_suite_test.go
index aef54ed2..4f1d878d 100644
--- a/pkg/omni/retriever/retriever_suite_test.go
+++ b/pkg/omni/retriever/retriever_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package retriever_test
diff --git a/pkg/omni/transformer/integration_test.go b/pkg/omni/transformer/integration_test.go
index 00807fd6..bc6e0255 100644
--- a/pkg/omni/transformer/integration_test.go
+++ b/pkg/omni/transformer/integration_test.go
@@ -1,15 +1,17 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package transformer_test
diff --git a/pkg/omni/transformer/transformer.go b/pkg/omni/transformer/transformer.go
index 9fb40ba6..14da2b67 100644
--- a/pkg/omni/transformer/transformer.go
+++ b/pkg/omni/transformer/transformer.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package transformer
@@ -19,15 +21,16 @@ import (
"fmt"
"log"
+ "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore"
+ "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
"github.com/vulcanize/vulcanizedb/pkg/omni/contract"
"github.com/vulcanize/vulcanizedb/pkg/omni/converter"
- "github.com/vulcanize/vulcanizedb/pkg/omni/fetcher"
"github.com/vulcanize/vulcanizedb/pkg/omni/parser"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/poller"
"github.com/vulcanize/vulcanizedb/pkg/omni/repository"
"github.com/vulcanize/vulcanizedb/pkg/omni/retriever"
- "github.com/vulcanize/vulcanizedb/pkg/omni/types"
)
// Omni transformer
@@ -36,114 +39,132 @@ import (
// that requires no prior knowledge of the contract
// other than its address and which network it is on
type Transformer interface {
- Init(contractAddr string) error
+ SetEvents(contractAddr string, filterSet []string)
+ SetEventAddrs(contractAddr string, filterSet []string)
+ SetMethods(contractAddr string, filterSet []string)
+ SetMethodAddrs(contractAddr string, filterSet []string)
+ SetRange(contractAddr string, rng [2]int64)
+ Init() error
+ Execute() error
}
type transformer struct {
- // Network, database, and blockchain config
- *types.Config
+ Network string // Ethereum network name; default/"" is mainnet
- // Underlying databases
- datastore.WatchedEventRepository
- datastore.FilterRepository
- repository.DataStore
+ // Database interfaces
+ datastore.FilterRepository // Holds watched event log filters
+ datastore.WatchedEventRepository // Holds watched event log views, created with the filters
+ repository.EventDatastore // Holds transformed watched event log data
- // Underlying interfaces
+ // Processing interfaces
parser.Parser // Parses events out of contract abi fetched with addr
retriever.BlockRetriever // Retrieves first block with contract addr referenced
retriever.AddressRetriever // Retrieves token holder addresses
- fetcher.Fetcher // Fetches data from public contract methods
converter.Converter // Converts watched event logs into custom log
+ poller.Poller // Polls methods using contract's token holder addresses
// Store contract info as mapping to contract address
Contracts map[string]*contract.Contract
// Targeted subset of events/methods
- // Stored as map of contract address to events/method names of interest
- // Default/empty list means all events/methods are considered for that address
- targetEvents map[string][]string
- targetMethods map[string][]string
+ // Stored as map sof contract address to events/method names of interest
+ WatchedEvents map[string][]string // Default/empty event list means all are watched
+ WantedMethods map[string][]string // Default/empty method list means none are polled
+
+ // Block ranges to watch contracts
+ ContractRanges map[string][2]int64
+
+ // Lists of addresses to filter event or method data
+ // before persisting; if empty no filter is applied
+ EventAddrs map[string][]string
+ MethodAddrs map[string][]string
}
// Transformer takes in config for blockchain, database, and network id
-func NewTransformer(c *types.Config) *transformer {
+func NewTransformer(network string, BC core.BlockChain, DB *postgres.DB) *transformer {
return &transformer{
- Parser: parser.NewParser(c.Network),
- BlockRetriever: retriever.NewBlockRetriever(c.DB),
- Fetcher: fetcher.NewFetcher(c.BC),
- Converter: converter.NewConverter(contract.Contract{}),
+ Poller: poller.NewPoller(BC),
+ Parser: parser.NewParser(network),
+ BlockRetriever: retriever.NewBlockRetriever(DB),
+ Converter: converter.NewConverter(&contract.Contract{}),
Contracts: map[string]*contract.Contract{},
- WatchedEventRepository: repositories.WatchedEventRepository{DB: c.DB},
- FilterRepository: repositories.FilterRepository{DB: c.DB},
- DataStore: repository.NewDataStore(c.DB),
- targetEvents: map[string][]string{},
- targetMethods: map[string][]string{},
+ WatchedEventRepository: repositories.WatchedEventRepository{DB: DB},
+ FilterRepository: repositories.FilterRepository{DB: DB},
+ EventDatastore: repository.NewEventDataStore(DB),
+ WatchedEvents: map[string][]string{},
+ WantedMethods: map[string][]string{},
+ ContractRanges: map[string][2]int64{},
+ EventAddrs: map[string][]string{},
+ MethodAddrs: map[string][]string{},
}
}
-// Used to set which contract addresses and which of their events to watch
-func (t *transformer) SetEvents(contractAddr string, filterSet []string) {
- t.targetEvents[contractAddr] = filterSet
-}
-
-// Used to set which contract addresses and which of their methods to call
-func (t *transformer) SetMethods(contractAddr string, filterSet []string) {
- t.targetMethods[contractAddr] = filterSet
-}
-
// Use after creating and setting transformer
// Loops over all of the addr => filter sets
// Uses parser to pull event info from abi
// Use this info to generate event filters
func (t *transformer) Init() error {
- for contractAddr, subset := range t.targetEvents {
+ for contractAddr, subset := range t.WatchedEvents {
// Get Abi
err := t.Parser.Parse(contractAddr)
if err != nil {
return err
}
- // Get first block for contract
+ // Get first block for contract and most recent block for the chain
firstBlock, err := t.BlockRetriever.RetrieveFirstBlock(contractAddr)
if err != nil {
return err
}
-
- // Get most recent block
lastBlock, err := t.BlockRetriever.RetrieveMostRecentBlock()
if err != nil {
return err
}
+ // Set to specified range if it falls within the contract's bounds
+ if firstBlock < t.ContractRanges[contractAddr][0] {
+ firstBlock = t.ContractRanges[contractAddr][0]
+ }
+ if lastBlock > t.ContractRanges[contractAddr][1] && t.ContractRanges[contractAddr][1] > firstBlock {
+ lastBlock = t.ContractRanges[contractAddr][1]
+ }
+
// Get contract name
- var ctrName string // should change this to check for "name" method and its return type in the abi methods before trying to fetch
- strName, err := t.Fetcher.FetchString("name", t.Parser.Abi(), contractAddr, lastBlock, nil)
- if err != nil || strName == "" {
- hashName, err := t.Fetcher.FetchHash("name", t.Parser.Abi(), contractAddr, lastBlock, nil)
- if err != nil || hashName.String() == "" {
- return errors.New(fmt.Sprintf("unable to fetch contract name: %v\r\n", err)) // provide CLI prompt here for user to input a contract name?
- }
- ctrName = hashName.String()
- } else {
- ctrName = strName
+ var name = new(string)
+ err = t.PollMethod(t.Abi(), contractAddr, "name", nil, &name, lastBlock)
+ if err != nil {
+ return errors.New(fmt.Sprintf("unable to fetch contract name: %v\r\n", err))
+ }
+
+ // Remove any accidental duplicate inputs in filter addresses
+ EventAddrs := map[string]bool{}
+ for _, addr := range t.EventAddrs[contractAddr] {
+ EventAddrs[addr] = true
+ }
+ MethodAddrs := map[string]bool{}
+ for _, addr := range t.MethodAddrs[contractAddr] {
+ MethodAddrs[addr] = true
}
// Aggregate info into contract object
info := &contract.Contract{
- Name: ctrName,
- Address: contractAddr,
- Abi: t.Parser.Abi(),
- ParsedAbi: t.Parser.ParsedAbi(),
- StartingBlock: firstBlock,
- Events: t.Parser.GetEvents(),
- Methods: t.Parser.GetMethods(),
- Addresses: map[string]bool{},
+ Name: *name,
+ Address: contractAddr,
+ Abi: t.Abi(),
+ ParsedAbi: t.ParsedAbi(),
+ StartingBlock: firstBlock,
+ LastBlock: lastBlock,
+ Events: t.GetEvents(subset),
+ Methods: t.GetAddrMethods(t.WantedMethods[contractAddr]),
+ EventAddrs: EventAddrs,
+ MethodAddrs: MethodAddrs,
+ TknHolderAddrs: map[string]bool{},
}
// Use info to create filters
- err = info.GenerateFilters(subset)
+ err = info.GenerateFilters()
if err != nil {
return err
}
@@ -168,7 +189,7 @@ func (tr transformer) Execute() error {
for _, con := range tr.Contracts {
// Update converter with current contract
- tr.Converter.Update(*con)
+ tr.Converter.Update(con)
// Iterate through contract filters and get watched event logs
for eventName, filter := range con.Filters {
@@ -185,11 +206,10 @@ func (tr transformer) Execute() error {
return err
}
}
-
}
// After converting all logs for events of interest, persist all of the data
- err := tr.PersistEvents(con)
+ err := tr.PersistContractEvents(con)
if err != nil {
return err
}
@@ -197,3 +217,28 @@ func (tr transformer) Execute() error {
return nil
}
+
+// Used to set which contract addresses and which of their events to watch
+func (t *transformer) SetEvents(contractAddr string, filterSet []string) {
+ t.WatchedEvents[contractAddr] = filterSet
+}
+
+// Used to set subset of account addresses to watch events for
+func (t *transformer) SetEventAddrs(contractAddr string, filterSet []string) {
+ t.EventAddrs[contractAddr] = filterSet
+}
+
+// Used to set which contract addresses and which of their methods to call
+func (t *transformer) SetMethods(contractAddr string, filterSet []string) {
+ t.WantedMethods[contractAddr] = filterSet
+}
+
+// Used to set subset of account addresses to poll methods on
+func (t *transformer) SetMethodAddrs(contractAddr string, filterSet []string) {
+ t.MethodAddrs[contractAddr] = filterSet
+}
+
+// Used to set the block range to watch for a given address
+func (t *transformer) SetRange(contractAddr string, rng [2]int64) {
+ t.ContractRanges[contractAddr] = rng
+}
diff --git a/pkg/omni/transformer/transformer_suite_test.go b/pkg/omni/transformer/transformer_suite_test.go
index bfa3b204..4569b47a 100644
--- a/pkg/omni/transformer/transformer_suite_test.go
+++ b/pkg/omni/transformer/transformer_suite_test.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package transformer_test
diff --git a/pkg/omni/transformer/transformer_test.go b/pkg/omni/transformer/transformer_test.go
index e3fd80ec..b6ba48dd 100644
--- a/pkg/omni/transformer/transformer_test.go
+++ b/pkg/omni/transformer/transformer_test.go
@@ -1,154 +1,237 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package transformer_test
import (
+ "fmt"
"math/rand"
"time"
- "github.com/ethereum/go-ethereum/ethclient"
- "github.com/ethereum/go-ethereum/rpc"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
- "github.com/vulcanize/vulcanizedb/examples/constants"
- "github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres/repositories"
- "github.com/vulcanize/vulcanizedb/pkg/geth"
- "github.com/vulcanize/vulcanizedb/pkg/geth/client"
- rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
- "github.com/vulcanize/vulcanizedb/pkg/geth/node"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/constants"
+ "github.com/vulcanize/vulcanizedb/pkg/omni/helpers/test_helpers"
"github.com/vulcanize/vulcanizedb/pkg/omni/transformer"
- "github.com/vulcanize/vulcanizedb/pkg/omni/types"
)
-var mockEvent = core.WatchedEvent{
- Name: constants.TransferEvent.String(),
- BlockNumber: 5488076,
- Address: constants.TusdContractAddress,
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- Index: 110,
- Topic0: constants.TransferEvent.Signature(),
- Topic1: "0x000000000000000000000000000000000000000000000000000000000000af21",
- Topic2: "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
- Topic3: "",
- Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+var block1 = core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
+ Number: 5194634,
+ Transactions: []core.Transaction{{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654aaa",
+ Receipt: core.Receipt{
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654aaa",
+ ContractAddress: "",
+ Logs: []core.Log{{
+ BlockNumber: 5194634,
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654aaa",
+ Address: constants.TusdContractAddress,
+ Topics: core.Topics{
+ constants.TransferEvent.Signature(),
+ "0x000000000000000000000000000000000000000000000000000000000000af21",
+ "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
+ "",
+ },
+ Index: 1,
+ Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+ }},
+ },
+ }},
}
-var _ = Describe("Repository Test", func() {
+var block2 = core.Block{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ooo",
+ Number: 6194634,
+ Transactions: []core.Transaction{{
+ Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee",
+ Receipt: core.Receipt{
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee",
+ ContractAddress: "",
+ Logs: []core.Log{{
+ BlockNumber: 6194634,
+ TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee",
+ Address: constants.TusdContractAddress,
+ Topics: core.Topics{
+ constants.TransferEvent.Signature(),
+ "0x000000000000000000000000000000000000000000000000000000000000af21",
+ "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
+ "",
+ },
+ Index: 1,
+ Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
+ }},
+ },
+ }},
+}
+
+var _ = Describe("Transformer", func() {
var db *postgres.DB
var err error
- var con types.Config
+ var blockChain core.BlockChain
var blockRepository repositories.BlockRepository
rand.Seed(time.Now().UnixNano())
BeforeEach(func() {
- infuraIPC := "https://mainnet.infura.io/v3/b09888c1113640cc9ab42750ce750c05"
- rawRpcClient, err := rpc.Dial(infuraIPC)
- Expect(err).NotTo(HaveOccurred())
- rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC)
- ethClient := ethclient.NewClient(rawRpcClient)
- blockChainClient := client.NewEthClient(ethClient)
- node := node.MakeNode(rpcClient)
- transactionConverter := rpc2.NewRpcTransactionConverter(ethClient)
- blockChain := geth.NewBlockChain(blockChainClient, node, transactionConverter)
-
- db, err = postgres.NewDB(config.Database{
- Hostname: "localhost",
- Name: "vulcanize_private",
- Port: 5432,
- }, blockChain.Node())
- Expect(err).NotTo(HaveOccurred())
-
- con = types.Config{
- DB: db,
- BC: blockChain,
- Network: "",
- }
-
+ db, blockChain = test_helpers.SetupDBandBC()
blockRepository = *repositories.NewBlockRepository(db)
})
AfterEach(func() {
- db.Query(`DELETE FROM blocks`)
- db.Query(`DELETE FROM logs`)
- db.Query(`DELETE FROM transactions`)
- db.Query(`DELETE FROM receipts`)
- db.Query(`DROP SCHEMA IF EXISTS trueusd CASCADE`)
+ test_helpers.TearDown(db)
})
- It("Fails to initialize if first and most recent blocks cannot be fetched from vDB", func() {
- t := transformer.NewTransformer(&con)
- t.SetEvents(constants.TusdContractAddress, []string{"Transfer"})
- err = t.Init()
- Expect(err).To(HaveOccurred())
+ Describe("SetEvents", func() {
+ It("Sets which events to watch from the given contract address", func() {
+ watchedEvents := []string{"Transfer", "Mint"}
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetEvents(constants.TusdContractAddress, watchedEvents)
+ Expect(t.WatchedEvents[constants.TusdContractAddress]).To(Equal(watchedEvents))
+ })
})
- It("Initializes and executes successfully if first and most recent blocks can be fetched from vDB", func() {
- log := core.Log{
- BlockNumber: 6194634,
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad234hfs",
- Address: constants.TusdContractAddress,
- Topics: core.Topics{
- constants.TransferEvent.Signature(),
- "0x000000000000000000000000000000000000000000000000000000000000af21",
- "0x9dd48110dcc444fdc242510c09bbbbe21a5975cac061d82f7b843bce061ba391",
- "",
- },
- Index: 1,
- Data: "0x000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc200000000000000000000000089d24a6b4ccb1b6faa2625fe562bdd9a23260359000000000000000000000000000000000000000000000000392d2e2bda9c00000000000000000000000000000000000000000000000000927f41fa0a4a418000000000000000000000000000000000000000000000000000000000005adcfebe",
- }
+ Describe("SetEventAddrs", func() {
+ It("Sets which account addresses to watch events for", func() {
+ eventAddrs := []string{"test1", "test2"}
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetEventAddrs(constants.TusdContractAddress, eventAddrs)
+ Expect(t.EventAddrs[constants.TusdContractAddress]).To(Equal(eventAddrs))
+ })
+ })
- receipt := core.Receipt{
- TxHash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- ContractAddress: constants.TusdContractAddress,
- Logs: []core.Log{log},
- }
+ Describe("SetMethods", func() {
+ It("Sets which methods to poll at the given contract address", func() {
+ watchedMethods := []string{"balanceOf", "totalSupply"}
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetMethods(constants.TusdContractAddress, watchedMethods)
+ Expect(t.WantedMethods[constants.TusdContractAddress]).To(Equal(watchedMethods))
+ })
+ })
- transaction := core.Transaction{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad6546ae",
- Receipt: receipt,
- }
+ Describe("SetMethodAddrs", func() {
+ It("Sets which account addresses to poll methods against", func() {
+ methodAddrs := []string{"test1", "test2"}
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetMethodAddrs(constants.TusdContractAddress, methodAddrs)
+ Expect(t.MethodAddrs[constants.TusdContractAddress]).To(Equal(methodAddrs))
+ })
+ })
- block := core.Block{
- Hash: "0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad123ert",
- Number: 6194634,
- Transactions: []core.Transaction{transaction},
- }
+ Describe("SetRange", func() {
+ It("Sets the block range that the contract should be watched within", func() {
+ rng := [2]int64{1, 100000}
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetRange(constants.TusdContractAddress, rng)
+ Expect(t.ContractRanges[constants.TusdContractAddress]).To(Equal(rng))
+ })
+ })
- blockRepository.CreateOrUpdateBlock(block)
+ Describe("Init", func() {
+ It("Initializes transformer's contract objects", func() {
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetEvents(constants.TusdContractAddress, []string{"Transfer"})
+ err = t.Init()
+ Expect(err).ToNot(HaveOccurred())
- t := transformer.NewTransformer(&con)
- t.SetEvents(constants.TusdContractAddress, []string{"Transfer"})
- err = t.Init()
- Expect(err).ToNot(HaveOccurred())
+ c, ok := t.Contracts[constants.TusdContractAddress]
+ Expect(ok).To(Equal(true))
- c, ok := t.Contracts[constants.TusdContractAddress]
- Expect(ok).To(Equal(true))
+ Expect(c.StartingBlock).To(Equal(int64(5194634)))
+ Expect(c.LastBlock).To(Equal(int64(6194634)))
+ Expect(c.Abi).To(Equal(constants.TusdAbiString))
+ Expect(c.Name).To(Equal("TrueUSD"))
+ Expect(c.Address).To(Equal(constants.TusdContractAddress))
+ })
- err = t.Execute()
- Expect(err).ToNot(HaveOccurred())
+ It("Fails to initialize if first and most recent blocks cannot be fetched from vDB", func() {
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetEvents(constants.TusdContractAddress, []string{"Transfer"})
+ err = t.Init()
+ Expect(err).To(HaveOccurred())
+ })
- b, ok := c.Addresses["0x000000000000000000000000000000000000Af21"]
- Expect(ok).To(Equal(true))
- Expect(b).To(Equal(true))
+ It("Does nothing if watched events are nil", func() {
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ t := transformer.NewTransformer("", blockChain, db)
+ err = t.Init()
+ Expect(err).ToNot(HaveOccurred())
- b, ok = c.Addresses["0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"]
- Expect(ok).To(Equal(true))
- Expect(b).To(Equal(true))
+ _, ok := t.Contracts[constants.TusdContractAddress]
+ Expect(ok).To(Equal(false))
+ })
+ })
+
+ Describe("Execute", func() {
+ BeforeEach(func() {
+ blockRepository.CreateOrUpdateBlock(block1)
+ blockRepository.CreateOrUpdateBlock(block2)
+ })
+
+ It("Transforms watched contract data into custom repositories", func() {
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetEvents(constants.TusdContractAddress, []string{"Transfer"})
+ err = t.Init()
+ Expect(err).ToNot(HaveOccurred())
+
+ err = t.Execute()
+ Expect(err).ToNot(HaveOccurred())
+
+ log := test_helpers.TransferLog{}
+ err = db.QueryRowx(fmt.Sprintf("SELECT * FROM c%s.transfer WHERE block = 6194634", constants.TusdContractAddress)).StructScan(&log)
+
+ // We don't know vulcID, so compare individual fields instead of complete structures
+ Expect(log.Tx).To(Equal("0x135391a0962a63944e5908e6fedfff90fb4be3e3290a21017861099bad654eee"))
+ Expect(log.Block).To(Equal(int64(6194634)))
+ Expect(log.From).To(Equal("0x000000000000000000000000000000000000Af21"))
+ Expect(log.To).To(Equal("0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"))
+ Expect(log.Value).To(Equal("1097077688018008265106216665536940668749033598146"))
+ })
+
+ It("Keeps track of contract-related addresses while transforming event data", func() {
+ t := transformer.NewTransformer("", blockChain, db)
+ t.SetEvents(constants.TusdContractAddress, []string{"Transfer"})
+ err = t.Init()
+ Expect(err).ToNot(HaveOccurred())
+
+ c, ok := t.Contracts[constants.TusdContractAddress]
+ Expect(ok).To(Equal(true))
+
+ err = t.Execute()
+ Expect(err).ToNot(HaveOccurred())
+
+ b, ok := c.TknHolderAddrs["0x000000000000000000000000000000000000Af21"]
+ Expect(ok).To(Equal(true))
+ Expect(b).To(Equal(true))
+
+ b, ok = c.TknHolderAddrs["0x09BbBBE21a5975cAc061D82f7b843bCE061BA391"]
+ Expect(ok).To(Equal(true))
+ Expect(b).To(Equal(true))
+
+ _, ok = c.TknHolderAddrs["0x09BbBBE21a5975cAc061D82f7b843b1234567890"]
+ Expect(ok).To(Equal(false))
+
+ _, ok = c.TknHolderAddrs["0x"]
+ Expect(ok).To(Equal(false))
+ })
})
})
diff --git a/pkg/omni/types/entities.go b/pkg/omni/types/entities.go
index e7fe49c9..520c5a0c 100644
--- a/pkg/omni/types/entities.go
+++ b/pkg/omni/types/entities.go
@@ -1,16 +1,18 @@
-// Copyright 2018 Vulcanize
-//
-// 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.
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
package types
@@ -19,17 +21,8 @@ import (
"strings"
"github.com/ethereum/go-ethereum/accounts/abi"
-
- "github.com/vulcanize/vulcanizedb/pkg/core"
- "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
)
-type Config struct {
- Network string
- BC core.BlockChain
- DB *postgres.DB
-}
-
type Event struct {
Name string
Anonymous bool
@@ -42,19 +35,30 @@ type Method struct {
Const bool
Inputs []*Field
Outputs []*Field
+ Results []*Result
}
type Field struct {
- abi.Argument
- PgType string
+ abi.Argument // Name, Type, Indexed
+ PgType string // Holds type used when committing data held in this field to postgres
}
+// Struct to hold results from method call with given inputs across different blocks
+type Result struct {
+ Inputs []interface{} // Will only use addresses
+ Outputs map[int64]interface{}
+ PgType string // Holds output pg type
+}
+
+// Struct to hold event log data data
type Log struct {
- Values map[string]interface{} // Map of event input names to their values
+ Id int64 // VulcanizeIdLog
+ Values map[string]string // Map of event input names to their values
Block int64
Tx string
}
+// Unpack abi.Event into our custom Event struct
func NewEvent(e abi.Event) *Event {
fields := make([]*Field, len(e.Inputs))
for i, input := range e.Inputs {
@@ -62,6 +66,25 @@ func NewEvent(e abi.Event) *Event {
fields[i].Name = input.Name
fields[i].Type = input.Type
fields[i].Indexed = input.Indexed
+ // Fill in pg type based on abi type
+ switch fields[i].Type.T {
+ case abi.StringTy, abi.HashTy, abi.AddressTy:
+ fields[i].PgType = "CHARACTER VARYING(66)"
+ case abi.IntTy, abi.UintTy:
+ fields[i].PgType = "DECIMAL"
+ case abi.BoolTy:
+ fields[i].PgType = "BOOLEAN"
+ case abi.BytesTy, abi.FixedBytesTy:
+ fields[i].PgType = "BYTEA"
+ case abi.ArrayTy:
+ fields[i].PgType = "TEXT[]"
+ case abi.FixedPointTy:
+ fields[i].PgType = "MONEY" // use shopspring/decimal for fixed point numbers in go and money type in postgres?
+ case abi.FunctionTy:
+ fields[i].PgType = "TEXT"
+ default:
+ fields[i].PgType = "TEXT"
+ }
}
return &Event{
@@ -72,6 +95,7 @@ func NewEvent(e abi.Event) *Event {
}
}
+// Unpack abi.Method into our custom Method struct
func NewMethod(m abi.Method) *Method {
inputs := make([]*Field, len(m.Inputs))
for i, input := range m.Inputs {
@@ -79,6 +103,24 @@ func NewMethod(m abi.Method) *Method {
inputs[i].Name = input.Name
inputs[i].Type = input.Type
inputs[i].Indexed = input.Indexed
+ switch inputs[i].Type.T {
+ case abi.StringTy, abi.HashTy, abi.AddressTy:
+ inputs[i].PgType = "CHARACTER VARYING(66)"
+ case abi.IntTy, abi.UintTy:
+ inputs[i].PgType = "DECIMAL"
+ case abi.BoolTy:
+ inputs[i].PgType = "BOOLEAN"
+ case abi.BytesTy, abi.FixedBytesTy:
+ inputs[i].PgType = "BYTEA"
+ case abi.ArrayTy:
+ inputs[i].PgType = "TEXT[]"
+ case abi.FixedPointTy:
+ inputs[i].PgType = "MONEY" // use shopspring/decimal for fixed point numbers in go and money type in postgres?
+ case abi.FunctionTy:
+ inputs[i].PgType = "TEXT"
+ default:
+ inputs[i].PgType = "TEXT"
+ }
}
outputs := make([]*Field, len(m.Outputs))
@@ -87,6 +129,24 @@ func NewMethod(m abi.Method) *Method {
outputs[i].Name = output.Name
outputs[i].Type = output.Type
outputs[i].Indexed = output.Indexed
+ switch outputs[i].Type.T {
+ case abi.StringTy, abi.HashTy, abi.AddressTy:
+ outputs[i].PgType = "CHARACTER VARYING(66)"
+ case abi.IntTy, abi.UintTy:
+ outputs[i].PgType = "DECIMAL"
+ case abi.BoolTy:
+ outputs[i].PgType = "BOOLEAN"
+ case abi.BytesTy, abi.FixedBytesTy:
+ outputs[i].PgType = "BYTEA"
+ case abi.ArrayTy:
+ outputs[i].PgType = "TEXT[]"
+ case abi.FixedPointTy:
+ outputs[i].PgType = "MONEY" // use shopspring/decimal for fixed point numbers in go and money type in postgres?
+ case abi.FunctionTy:
+ outputs[i].PgType = "TEXT"
+ default:
+ outputs[i].PgType = "TEXT"
+ }
}
return &Method{
@@ -94,6 +154,7 @@ func NewMethod(m abi.Method) *Method {
Const: m.Const,
Inputs: inputs,
Outputs: outputs,
+ Results: make([]*Result, 0),
}
}
diff --git a/test_config/test_config.go b/test_config/test_config.go
index 643908b8..ddf42a59 100644
--- a/test_config/test_config.go
+++ b/test_config/test_config.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package test_config
import (
diff --git a/utils/utils.go b/utils/utils.go
index d1e26060..8f78250b 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -1,3 +1,19 @@
+// VulcanizeDB
+// Copyright © 2018 Vulcanize
+
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero 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 Affero General Public License for more details.
+
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
package utils
import (