Merge pull request #16 from poanetwork/adding-token-bridge
Adding token-bridge subrepository
This commit is contained in:
commit
78549e4074
25
.circleci/config.yml
Normal file
25
.circleci/config.yml
Normal file
@ -0,0 +1,25 @@
|
||||
version: 2
|
||||
jobs:
|
||||
lint:
|
||||
docker:
|
||||
- image: circleci/node:10.15
|
||||
steps:
|
||||
- checkout
|
||||
- run: yarn
|
||||
- run: yarn run lint
|
||||
test:
|
||||
docker:
|
||||
- image: circleci/node:10.15
|
||||
environment:
|
||||
HOME_RPC_URL: http://example.com
|
||||
FOREIGN_RPC_URL: http://example.com
|
||||
steps:
|
||||
- checkout
|
||||
- run: yarn
|
||||
- run: yarn run test
|
||||
workflows:
|
||||
version: 2
|
||||
tokenbridge:
|
||||
jobs:
|
||||
- lint
|
||||
- test
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
node_modules
|
||||
.env
|
||||
.idea
|
||||
.nyc_output
|
||||
coverage/
|
||||
logs/
|
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "token-bridge/submodules/poa-bridge-contracts"]
|
||||
path = token-bridge/submodules/poa-bridge-contracts
|
||||
url = https://github.com/poanetwork/poa-bridge-contracts.git
|
@ -1,2 +1,5 @@
|
||||
# tokenbridge
|
||||
Monorepository for the token bridge
|
||||
|
||||
[![CircleCI](https://circleci.com/gh/poanetwork/tokenbridge.svg?style=svg)](https://circleci.com/gh/poanetwork/tokenbridge)
|
||||
|
||||
|
19
package.json
Normal file
19
package.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "tokenbridge",
|
||||
"version": "0.0.1",
|
||||
"description": "Monorepository for token bridge",
|
||||
"repository": "https://github.com/poanetwork/tokenbridge.git",
|
||||
"author": "rzadp <przemek@ethworks.io>",
|
||||
"license": "MIT",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"wsrun": "^3.6.5"
|
||||
},
|
||||
"workspaces": [
|
||||
"token-bridge"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "yarn wsrun lint",
|
||||
"test": "yarn wsrun test"
|
||||
}
|
||||
}
|
12
token-bridge/.dockerignore
Normal file
12
token-bridge/.dockerignore
Normal file
@ -0,0 +1,12 @@
|
||||
CODE_OF_CONDUCT.md
|
||||
CONTRIBUTING.md
|
||||
docker-compose.yml
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docs
|
||||
e2e
|
||||
.env*
|
||||
.git*
|
||||
LICENSE
|
||||
README.md
|
||||
node_modules
|
8
token-bridge/.editorconfig
Normal file
8
token-bridge/.editorconfig
Normal file
@ -0,0 +1,8 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 2
|
39
token-bridge/.env.example
Normal file
39
token-bridge/.env.example
Normal file
@ -0,0 +1,39 @@
|
||||
#BRIDGE_MODE=ERC_TO_ERC
|
||||
HOME_POLLING_INTERVAL=5000
|
||||
FOREIGN_POLLING_INTERVAL=1000
|
||||
ALLOW_HTTP=no
|
||||
HOME_RPC_URL=https://kovan.infura.io/mew
|
||||
FOREIGN_RPC_URL=https://kovan.infura.io/mew
|
||||
HOME_BRIDGE_ADDRESS=0x86b621b839Ff86Bb59fA57015b02318f9a870d80
|
||||
FOREIGN_BRIDGE_ADDRESS=0x8dDCa2eB86D22FcB93342753515986e258A90169
|
||||
ERC20_TOKEN_ADDRESS=0x7AA0A62497B5f4120fbe5D26c95bC612c2b96C14
|
||||
|
||||
VALIDATOR_ADDRESS_PRIVATE_KEY=
|
||||
|
||||
HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
HOME_GAS_PRICE_FALLBACK=1000000000
|
||||
HOME_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
|
||||
FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
FOREIGN_GAS_PRICE_SPEED_TYPE=standard
|
||||
FOREIGN_GAS_PRICE_FALLBACK=1000000000
|
||||
FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
|
||||
QUEUE_URL=amqp://rabbit
|
||||
REDIS_URL=redis://redis
|
||||
REDIS_LOCK_TTL=1000
|
||||
|
||||
HOME_START_BLOCK=
|
||||
FOREIGN_START_BLOCK=
|
||||
|
||||
LOG_LEVEL=debug
|
||||
MAX_PROCESSING_TIME=20000
|
||||
|
||||
#Uncomment these lines only if you are going to send transaction by testing scripts
|
||||
#USER_ADDRESS=0x59c4474184579b9c31b5e51445b6eef91cebf370
|
||||
#USER_ADDRESS_PRIVATE_KEY=
|
||||
#HOME_MIN_AMOUNT_PER_TX=0.001
|
||||
#FOREIGN_MIN_AMOUNT_PER_TX=0.001
|
||||
#HOME_TEST_TX_GAS_PRICE=1000000000
|
||||
#FOREIGN_TEST_TX_GAS_PRICE=1000000000
|
3
token-bridge/.eslintignore
Normal file
3
token-bridge/.eslintignore
Normal file
@ -0,0 +1,3 @@
|
||||
node_modules
|
||||
submodules
|
||||
coverage
|
21
token-bridge/.eslintrc
Normal file
21
token-bridge/.eslintrc
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": [
|
||||
"plugin:node/recommended",
|
||||
"airbnb-base",
|
||||
"plugin:prettier/recommended"
|
||||
],
|
||||
"plugins": ["node"],
|
||||
"rules": {
|
||||
"arrow-body-style": "off",
|
||||
"func-names": "off",
|
||||
"no-await-in-loop": "off",
|
||||
"no-console": "off",
|
||||
"no-else-return": "off",
|
||||
"no-param-reassign": "off",
|
||||
"no-plusplus": "off",
|
||||
"no-restricted-syntax": "off",
|
||||
"no-shadow": "off",
|
||||
"no-use-before-define": ["error", { "functions": false }],
|
||||
"import/no-dynamic-require": "off"
|
||||
}
|
||||
}
|
1
token-bridge/.nvmrc
Normal file
1
token-bridge/.nvmrc
Normal file
@ -0,0 +1 @@
|
||||
v8.9
|
6
token-bridge/.nycrc
Normal file
6
token-bridge/.nycrc
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"all": true,
|
||||
"include": [
|
||||
"src/**/*.js"
|
||||
]
|
||||
}
|
5
token-bridge/.prettierrc
Normal file
5
token-bridge/.prettierrc
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"printWidth": 100
|
||||
}
|
20
token-bridge/.travis.yml
Normal file
20
token-bridge/.travis.yml
Normal file
@ -0,0 +1,20 @@
|
||||
sudo: required
|
||||
|
||||
language: node_js
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- cd e2e
|
||||
- docker build -t parity parity
|
||||
- docker build -t e2e .
|
||||
- cd ..
|
||||
|
||||
script:
|
||||
- npm run lint
|
||||
- npm test
|
||||
- cd e2e && ./run-tests.sh
|
||||
|
||||
env:
|
||||
- HOME_RPC_URL=http://example.com FOREIGN_RPC_URL=http://example.com
|
73
token-bridge/CODE_OF_CONDUCT.md
Normal file
73
token-bridge/CODE_OF_CONDUCT.md
Normal file
@ -0,0 +1,73 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, gender identity and expression, level of experience,
|
||||
education, socio-economic status, nationality, personal appearance, race,
|
||||
religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at ziggy@poa.network. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
28
token-bridge/CONTRIBUTING.md
Normal file
28
token-bridge/CONTRIBUTING.md
Normal file
@ -0,0 +1,28 @@
|
||||
## Contributing
|
||||
|
||||
Thank your for contributing to this project! We welcome collaborators and expect users to follow our [code of conduct](CODE_OF_CONDUCT.md) when submitting code or comments.
|
||||
|
||||
1. Fork the repo ( https://github.com/poanetwork/bridge-nodejs/fork ).
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`).
|
||||
3. Write tests that cover your work.
|
||||
4. Commit your changes (`git commit -am 'Add some feature'`).
|
||||
5. Push to your branch (`git push origin my-new-feature`).
|
||||
6. Create a new PR (Pull Request).
|
||||
|
||||
### General
|
||||
|
||||
* Commits should be one logical change that still allows all tests to pass. We prefer smaller commits if there could be two levels of logic grouping. The goal is to provide future contributors (including your future self) the reasoning behind your changes and allow them to cherry-pick, patch or port those changes in isolation to other branches or forks.
|
||||
* If during your PR you reveal a pre-existing bug and know how to fix it:
|
||||
1. If you can isolate the bug, fix it in a separate PR.
|
||||
2. If the fix depends on your other commits, add it in a separate commit to the same PR.
|
||||
|
||||
In either case, try to write a regression test that fails because of the bug but passes with your fix.
|
||||
|
||||
### Issues
|
||||
Creating and discussing [Issues](https://github.com/poanetwork/bridge-nodejs/issues) provides significant value to the project. If you find a bug you can report it in an Issue.
|
||||
|
||||
### Pull Requests
|
||||
All pull requests should include:
|
||||
* A clear, readable description of the purpose of the PR
|
||||
* A clear, readable description of changes
|
||||
* Any additional concerns or comments (optional)
|
16
token-bridge/Dockerfile
Normal file
16
token-bridge/Dockerfile
Normal file
@ -0,0 +1,16 @@
|
||||
FROM node:8
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y build-essential
|
||||
RUN apt-get install -y libc6-dev
|
||||
RUN apt-get install -y libc6-dev-i386
|
||||
RUN apt-get install -y wget
|
||||
RUN apt-get clean
|
||||
|
||||
WORKDIR /bridge
|
||||
COPY package.json .
|
||||
COPY package-lock.json .
|
||||
RUN npm install
|
||||
COPY . .
|
||||
CMD echo "To start a bridge process run:" \
|
||||
"VALIDATOR_ADDRESS=<validator address> VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up -d --build"
|
BIN
token-bridge/ERC-to-ERC.png
Normal file
BIN
token-bridge/ERC-to-ERC.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
674
token-bridge/LICENSE
Normal file
674
token-bridge/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
BIN
token-bridge/Native-to-ERC.png
Normal file
BIN
token-bridge/Native-to-ERC.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
297
token-bridge/README.md
Normal file
297
token-bridge/README.md
Normal file
@ -0,0 +1,297 @@
|
||||
|
||||
# POA TokenBridge
|
||||
|
||||
[![Build Status](https://travis-ci.org/poanetwork/token-bridge.svg)](https://travis-ci.org/poanetwork/token-bridge)
|
||||
[![Gitter](https://badges.gitter.im/poanetwork/poa-bridge.svg)](https://gitter.im/poanetwork/poa-bridge?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
The TokenBridge is deployed on specified validator nodes (only nodes whose private keys correspond to addresses specified in the smart contracts) in the network. It connects to two chains via a Remote Procedure Call (RPC) and is responsible for:
|
||||
- listening to events related to bridge contracts
|
||||
- sending transactions to authorize asset transfers
|
||||
|
||||
Following is an overview of the TokenBridge and [instructions for getting started](#how-to-use).
|
||||
|
||||
## POA General Bridge Overview
|
||||
|
||||
A POA Bridge allows users to transfer assets between two chains in the Ethereum ecosystem. It is composed of several elements located in different POA Network repositories:
|
||||
|
||||
**Bridge Elements**
|
||||
1. The TokenBridge contained in this repository.
|
||||
2. [Solidity smart contracts](https://github.com/poanetwork/poa-bridge-contracts). Used to manage bridge validators, collect signatures, and confirm asset relay and disposal.
|
||||
3. [Bridge UI Application](https://github.com/poanetwork/bridge-ui). A DApp interface to transfer tokens and coins between chains.
|
||||
4. [Bridge Monitor](https://github.com/poanetwork/bridge-monitor). A tool for checking balances and unprocessed events in bridged networks.
|
||||
5. [Bridge Deployment Playbooks](https://github.com/poanetwork/deployment-bridge). Manages configuration instructions for remote deployments.
|
||||
|
||||
## Network Definitions
|
||||
|
||||
Bridging occurs between two networks.
|
||||
|
||||
* **Home** - or **Native** - is a network with fast and inexpensive operations. All bridge operations to collect validator confirmations are performed on this side of the bridge.
|
||||
|
||||
* **Foreign** can be any chain; generally it refers to the Ethereum mainnet.
|
||||
|
||||
## Operational Modes
|
||||
|
||||
The POA TokenBridge provides three operational modes:
|
||||
|
||||
- [x] `Native-to-ERC20` **Coins** on a Home network can be converted to ERC20-compatible **tokens** on a Foreign network. Coins are locked on the Home side and the corresponding amount of ERC20 tokens are minted on the Foreign side. When the operation is reversed, tokens are burnt on the Foreign side and unlocked in the Home network. **More Information: [POA-to-POA20 Bridge](https://medium.com/poa-network/introducing-poa-bridge-and-poa20-55d8b78058ac)**
|
||||
- [x] `ERC20-to-ERC20` ERC20-compatible tokens on the Foreign network are locked and minted as ERC20-compatible tokens (ERC677 tokens) on the Home network. When transferred from Home to Foreign, they are burnt on the Home side and unlocked in the Foreign network. This can be considered a form of atomic swap when a user swaps the token "X" in network "A" to the token "Y" in network "B". **More Information: [ERC20-to-ERC20](https://medium.com/poa-network/introducing-the-erc20-to-erc20-tokenbridge-ce266cc1a2d0)**
|
||||
- [x] `ERC20-to-Native`: Pre-existing **tokens** in the Foreign network are locked and **coins** are minted in the `Home` network. In this mode, the Home network consensus engine invokes [Parity's Block Reward contract](https://wiki.parity.io/Block-Reward-Contract.html) to mint coins per the bridge contract request. **More Information: [xDai Chain](https://medium.com/poa-network/poa-network-partners-with-makerdao-on-xdai-chain-the-first-ever-usd-stable-blockchain-65a078c41e6a)**
|
||||
|
||||
## Architecture
|
||||
|
||||
### Native-to-ERC20
|
||||
|
||||
![Native-to-ERC](Native-to-ERC.png)
|
||||
|
||||
### ERC20-to-ERC20 and ERC20-to-Native
|
||||
|
||||
![ERC-to-ERC](ERC-to-ERC.png)
|
||||
|
||||
### Watcher
|
||||
A watcher listens for a certain event and creates proper jobs in the queue. These jobs contain the transaction data (without the nonce) and the transaction hash for the related event. The watcher runs on a given frequency, keeping track of the last processed block.
|
||||
|
||||
If the watcher observes that the transaction data cannot be prepared, which generally means that the corresponding method of the bridge contract cannot be invoked, it inspects the contract state to identify the potential reason for failure and records this in the logs.
|
||||
|
||||
There are three Watchers:
|
||||
- **Signature Request Watcher**: Listens to `UserRequestForSignature` events on the Home network.
|
||||
- **Collected Signatures Watcher**: Listens to `CollectedSignatures` events on the Home network.
|
||||
- **Affirmation Request Watcher**: Depends on the bridge mode.
|
||||
- `Native-to-ERC20`: Listens to `UserRequestForAffirmation` raised by the bridge contract.
|
||||
- `ERC20-to-ERC20` and `ERC20-to-Native`: Listens to `Transfer` events raised by the token contract.
|
||||
|
||||
### Sender
|
||||
A sender subscribes to the queue and keeps track of the nonce. It takes jobs from the queue, extracts transaction data, adds the proper nonce, and sends it to the network.
|
||||
|
||||
There are two Senders:
|
||||
- **Home Sender**: Sends a transaction to the `Home` network.
|
||||
- **Foreign Sender**: Sends a transaction to the `Foreign` network.
|
||||
|
||||
### RabbitMQ
|
||||
|
||||
[RabbitMQ](https://www.rabbitmq.com/) is used to transmit jobs from watchers to senders.
|
||||
|
||||
### Redis DB
|
||||
|
||||
Redis is used to store the number of blocks that were already inspected by watchers, and the NOnce (Number of Operation) which was used previously by the sender to send a transaction.
|
||||
|
||||
For more information on the Redis/RabbitMQ requirements, see [#90](/../../issues/90). We also provide [useful commands for development](#useful-commands-for-development).
|
||||
|
||||
# How to Use
|
||||
|
||||
## Installation and Deployment
|
||||
|
||||
**Note:** The following steps detail the bridge deployment process for development and testing. For deployment in a production environment we recommend using the [Bridge Deployment Playbooks](https://github.com/poanetwork/deployment-bridge/tree/master/bridge-nodejs).
|
||||
|
||||
#### Deploy the Bridge Contracts
|
||||
|
||||
1. [Deploy the bridge contracts](https://github.com/poanetwork/poa-bridge-contracts/blob/master/deploy/README.md)
|
||||
|
||||
2. Open `bridgeDeploymentResults.json` or copy the JSON output generated by the bridge contract deployment process.
|
||||
|
||||
`Native-to-ERC20` mode example:
|
||||
```json
|
||||
{
|
||||
"homeBridge": {
|
||||
"address": "0xc60daff55ec5b5ce5c3d2105a77e287ff638c35e",
|
||||
"deployedBlockNumber": 123321
|
||||
},
|
||||
"foreignBridge": {
|
||||
"address": "0x3f5ce5fbfe3e9af3971dd833d26ba9b5c936f0be",
|
||||
"deployedBlockNumber": 456654,
|
||||
"erc677": {
|
||||
"address": "0x41a29780309dc2582f080f6af89953be3435679a"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
`ERC20-to-ERC20` mode example:
|
||||
```json
|
||||
{
|
||||
"homeBridge": {
|
||||
"address": "0x765a0d90e5a5773deacbd94b2dc941cbb163bdab",
|
||||
"deployedBlockNumber": 789987,
|
||||
"erc677": {
|
||||
"address": "0x269f57f5ae5421d084686f9e353f5b7ee6af54c2"
|
||||
}
|
||||
},
|
||||
"foreignBridge": {
|
||||
"address": "0x7ae703ea88b0545eef1f0bf8f91d5276e39be2f7",
|
||||
"deployedBlockNumber": 567765
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
1. Create a `.env` file: `cp .env.example .env`
|
||||
|
||||
2. Fill in the required information using the JSON output data. Check the tables with the [set of parameters](#configuration-parameters) below to see their explanation.
|
||||
|
||||
## Run the Processes
|
||||
|
||||
There are two options to run the TokenBridge processes:
|
||||
1. Docker containers. This requires [Docker](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/). If you are on Linux, it's also recommended that you [create a docker group and add your user to it](https://docs.docker.com/install/linux/linux-postinstall/), so that you can use the CLI without sudo.
|
||||
2. NodeJs Package Manager (NPM).
|
||||
|
||||
### Docker
|
||||
|
||||
- While running the bridge containers for the first time use `VALIDATOR_ADDRESS=<validator address> VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up -d --build`
|
||||
- For further launches use `VALIDATOR_ADDRESS=<validator address> VALIDATOR_ADDRESS_PRIVATE_KEY=<validator address private key> docker-compose up --detach`
|
||||
|
||||
All [watcher](#watcher) & [sender](#sender) services launch when `docker-compose` is called.
|
||||
|
||||
**Note**: To view the Docker logs:
|
||||
* `chdir` to the directory containing the `docker-compose.yml` file used to run the bridge instance
|
||||
* [View the logs](https://docs.docker.com/v17.09/compose/reference/logs/) : `docker-compose logs`
|
||||
|
||||
|
||||
### NPM
|
||||
|
||||
- `redis-server` starts Redis. redis-cli ping will return a pong if Redis is running.
|
||||
- `rabbitmq-server` starts RabbitMQ. Use rabbitmqctl status to check if RabbitMQ is running.
|
||||
- `npm run watcher:signature-request`
|
||||
- `npm run watcher:collected-signatures`
|
||||
- `npm run watcher:affirmation-request`
|
||||
- `npm run sender:home`
|
||||
- `npm run sender:foreign`
|
||||
|
||||
### Bridge UI
|
||||
|
||||
See the [Bridge UI installation instructions](https://github.com/poanetwork/bridge-ui/) to configure and use the optional Bridge UI.
|
||||
|
||||
## Rollback the Last Processed Block in Redis
|
||||
|
||||
If the bridge does not handle an event properly (i.e. a transaction stalls due to a low gas price), the Redis DB can be rolled back. You must identify which watcher needs to re-run. For example, if the validator signatures were collected but the transaction with signatures was not sent to the Foreign network, the `collected-signatures` watcher must look at the block where the corresponding `CollectedSignatures` event was raised.
|
||||
|
||||
Execute this command in the bridge root directory:
|
||||
|
||||
for NPM installation:
|
||||
```shell
|
||||
bash ./reset-lastBlock.sh <watcher> <block num>
|
||||
```
|
||||
for Docker installation:
|
||||
```shell
|
||||
docker-compose exec bridge_affirmation bash ./reset-lastBlock.sh <watcher> <block num>
|
||||
```
|
||||
where the _watcher_ could be one of:
|
||||
|
||||
- `signature-request`
|
||||
- `collected-signatures`
|
||||
- `affirmation-request`
|
||||
|
||||
## Configuration parameters
|
||||
|
||||
| Variable | Description | Values |
|
||||
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------|
|
||||
| `BRIDGE_MODE` | The bridge mode. The bridge starts listening to a different set of events based on this parameter. | `NATIVE_TO_ERC` / `ERC_TO_ERC` / `ERC_TO_NATIVE` |
|
||||
| `HOME_RPC_URL` | The HTTPS URL(s) used to communicate to the RPC nodes in the Home network. Several URLs can be specified, delimited by spaces. If the connection to one of these nodes is lost the next URL is used for connection. | URL(s) |
|
||||
| `HOME_BRIDGE_ADDRESS` | The address of the bridge contract address in the Home network. It is used to listen to events from and send validators' transactions to the Home network. | hexidecimal beginning with "0x" |
|
||||
| `HOME_POLLING_INTERVAL` | The interval in milliseconds used to request the RPC node in the Home network for new blocks. The interval should match the average production time for a new block. | integer |
|
||||
| `FOREIGN_RPC_URL` | The HTTPS URL(s) used to communicate to the RPC nodes in the Foreign network. Several URLs can be specified, delimited by spaces. If the connection to one of these nodes is lost the next URL is used for connection. | URL(s) |
|
||||
| `FOREIGN_BRIDGE_ADDRESS` | The address of the bridge contract address in the Foreign network. It is used to listen to events from and send validators' transactions to the Foreign network. | hexidecimal beginning with "0x" |
|
||||
| `ERC20_TOKEN_ADDRESS` | Used with the `ERC_TO_ERC` bridge mode, this parameter specifies the ERC20-compatible token contract address. The token contract address is used to identify transactions that transfer tokens to the Foreign Bridge account address. Omit this parameter with other bridge modes. | hexidecimal beginning with "0x" |
|
||||
| `FOREIGN_POLLING_INTERVAL` | The interval in milliseconds used to request the RPC node in the Foreign network for new blocks. The interval should match the average production time for a new block. | integer |
|
||||
| `HOME_GAS_PRICE_ORACLE_URL` | The URL used to get a JSON response from the gas price prediction oracle for the Home network. The gas price provided by the oracle is used to send the validator's transactions to the RPC node. Since it is assumed that the Home network has a predefined gas price (e.g. the gas price in the Core of POA.Network is `1 GWei`), the gas price oracle parameter can be omitted for such networks. | URL |
|
||||
| `HOME_GAS_PRICE_SPEED_TYPE` | Assuming the gas price oracle responds with the following JSON structure: `{"fast": 20.0, "block_time": 12.834, "health": true, "standard": 6.0, "block_number": 6470469, "instant": 71.0, "slow": 1.889}`, this parameter specifies the desirable transaction speed. The speed type can be omitted when `HOME_GAS_PRICE_ORACLE_URL` is not used. | `instant` / `fast` / `standard` / `slow` |
|
||||
| `HOME_GAS_PRICE_FALLBACK` | The gas price (in Wei) that is used if both the oracle and the fall back gas price specified in the Home Bridge contract are not available. | integer |
|
||||
| `HOME_GAS_PRICE_UPDATE_INTERVAL` | An interval in milliseconds used to get the updated gas price value either from the oracle or from the Home Bridge contract. | integer |
|
||||
| `FOREIGN_GAS_PRICE_ORACLE_URL` | The URL used to get a JSON response from the gas price prediction oracle for the Foreign network. The provided gas price is used to send the validator's transactions to the RPC node. If the Foreign network is Ethereum Foundation mainnet, the oracle URL can be: https://gasprice.poa.network. Otherwise this parameter can be omitted. | URL |
|
||||
| `FOREIGN_GAS_PRICE_SPEED_TYPE` | Assuming the gas price oracle responds with the following JSON structure: `{"fast": 20.0, "block_time": 12.834, "health": true, "standard": 6.0, "block_number": 6470469, "instant": 71.0, "slow": 1.889}`, this parameter specifies the desirable transaction speed. The speed type can be omitted when `FOREIGN_GAS_PRICE_ORACLE_URL`is not used. | `instant` / `fast` / `standard` / `slow` |
|
||||
| `FOREIGN_GAS_PRICE_FALLBACK` | The gas price (in Wei) used if both the oracle and fall back gas price specified in the Foreign Bridge contract are not available. | integer |
|
||||
| `FOREIGN_GAS_PRICE_UPDATE_INTERVAL` | The interval in milliseconds used to get the updated gas price value either from the oracle or from the Foreign Bridge contract. | integer |
|
||||
| `VALIDATOR_ADDRESS_PRIVATE_KEY` | The private key of the bridge validator used to sign confirmations before sending transactions to the bridge contracts. The validator account is calculated automatically from the private key. Every bridge instance (set of watchers and senders) must have its own unique private key. The specified private key is used to sign transactions on both sides of the bridge. | hexidecimal without "0x" |
|
||||
| `HOME_START_BLOCK` | The block number in the Home network used to start watching for events when the bridge instance is run for the first time. Usually this is the same block where the Home Bridge contract is deployed. If a new validator instance is being deployed for an existing set of validators, the block number could be the latest block in the chain. | integer |
|
||||
| `FOREIGN_START_BLOCK` | The block number in the Foreign network used to start watching for events when the bridge instance runs for the first time. Usually this is the same block where the Foreign Bridge contract was deployed to. If a new validator instance is being deployed for an existing set of validators, the block number could be the latest block in the chain. | integer |
|
||||
| `QUEUE_URL` | RabbitMQ URL used by watchers and senders to communicate to the message queue. Typically set to: `amqp://127.0.0.1`. | local URL |
|
||||
| `REDIS_URL` | Redis DB URL used by watchers and senders to communicate to the database. Typically set to: `redis://127.0.0.1:6379`. | local URL |
|
||||
| `REDIS_LOCK_TTL` | Threshold in milliseconds for locking a resource in the Redis DB. Until the threshold is exceeded, the resource is unlocked. Usually it is `1000`. | integer |
|
||||
| `ALLOW_HTTP` | **Only use in test environments - must be omitted in production environments.**. If this parameter is specified and set to `yes`, RPC URLs can be specified in form of HTTP links. A warning that the connection is insecure will be written to the logs. | `yes` / `no` |
|
||||
| `LOG_LEVEL` | Set the level of details in the logs. | `trace` / `debug` / `info` / `warn` / `error` / `fatal` |
|
||||
| `MAX_PROCESSING_TIME` | The workers processes will be killed if this amount of time (in milliseconds) is ellapsed before they finish processing. It is recommended to set this value to 4 times the value of the longest polling time (set with the `HOME_POLLING_INTERVAL` and `FOREIGN_POLLING_INTERVAL` variables). To disable this, set the time to 0. | integer |
|
||||
|
||||
## Useful Commands for Development
|
||||
|
||||
### RabbitMQ
|
||||
Command | Description
|
||||
--- | ---
|
||||
`rabbitmqctl list_queues` | List all queues
|
||||
`rabbitmqctl purge_queue home` | Remove all messages from `home` queue
|
||||
`rabbitmqctl status` | check if rabbitmq server is currently running
|
||||
`rabbitmq-server` | start rabbitMQ server
|
||||
|
||||
### Redis
|
||||
Use `redis-cli`
|
||||
|
||||
Command | Description
|
||||
--- | ---
|
||||
`KEYS *` | Returns all keys
|
||||
`SET signature-request:lastProcessedBlock 1234` | Set key to hold the string value.
|
||||
`GET signature-request:lastProcessedBlock` | Get the key value.
|
||||
`DEL signature-request:lastProcessedBlock` | Removes the specified key.
|
||||
`FLUSHALL` | Delete all the keys in all existing databases.
|
||||
`redis-cli ping` | check if redis is running.
|
||||
`redis-server` | start redis server.
|
||||
|
||||
## Testing
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
### E2E tests
|
||||
|
||||
See the [E2E README](/e2e) for instructions.
|
||||
|
||||
*Notice*: for docker-based installations do not forget to add `docker-compose exec bridge_affirmation` before the test commands listed below.
|
||||
|
||||
### Native-to-ERC20 Mode Testing
|
||||
|
||||
When running the processes, the following commands can be used to test functionality.
|
||||
|
||||
- To send deposits to a home contract run `node scripts/native_to_erc20/sendHome.js <tx num>`, where `<tx num>` is how many tx will be sent out to deposit.
|
||||
|
||||
- To send withdrawals to a foreign contract run `node scripts/native_to_erc20/sendForeign.js <tx num>`, where `<tx num>` is how many tx will be sent out to withdraw.
|
||||
|
||||
### ERC20-to-ERC20 Mode Testing
|
||||
|
||||
- To deposit from a Foreign to a Home contract run `node scripts/erc20_to_erc20/sendForeign.js <tx num>`.
|
||||
|
||||
- To make withdrawal to Home from a Foreign contract run `node scripts/erc20_to_erc20/sendHome.js <tx num>`.
|
||||
|
||||
### ERC20-to-Native Mode Testing
|
||||
|
||||
- To deposit from a Foreign to a Home contract run `node scripts/erc20_to_native/sendForeign.js <tx num>`.
|
||||
|
||||
- To make withdrawal to Home from a Foreign contract run `node scripts/erc20_to_native/sendHome.js <tx num>`.
|
||||
|
||||
### Configuration parameters for testing
|
||||
|
||||
| Variable | Description |
|
||||
|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `HOME_RPC_URL` | The HTTPS URL(s) used to communicate to the RPC nodes in the Home network. |
|
||||
| `FOREIGN_RPC_URL` | The HTTPS URL(s) used to communicate to the RPC nodes in the Foreign network. |
|
||||
| `USER_ADDRESS` | An account - the current owner of coins/tokens. |
|
||||
| `USER_ADDRESS_PRIVATE_KEY` | A private key belonging to the account. |
|
||||
| `HOME_BRIDGE_ADDRESS` | Address of the bridge in the Home network to send transactions. |
|
||||
| `HOME_MIN_AMOUNT_PER_TX` | Value (in _eth_ or tokens) to be sent in one transaction for the Home network. This should be greater than or equal to the value specified in the `poa-bridge-contracts/deploy/.env` file. The default value in that file is 500000000000000000, which is equivalent to 0.5. |
|
||||
| `HOME_TEST_TX_GAS_PRICE` | The gas price (in Wei) that is used to send transactions in the Home network . |
|
||||
| `FOREIGN_BRIDGE_ADDRESS` | Address of the bridge in the Foreign network to send transactions. |
|
||||
| `FOREIGN_MIN_AMOUNT_PER_TX` | Value (in _eth_ or tokens) to be sent in one transaction for the Foreign network. This should be greater than or equal to the value specified in the `poa-bridge-contracts/deploy/.env` file. The default value in that file is 500000000000000000, which is equivalent to 0.5. |
|
||||
| `FOREIGN_TEST_TX_GAS_PRICE` | The gas price (in Wei) that is used to send transactions in the Foreign network . |
|
||||
|
||||
## Contributing
|
||||
|
||||
See the [CONTRIBUTING](CONTRIBUTING.md) document for contribution, testing and pull request protocol.
|
||||
|
||||
## License
|
||||
|
||||
[![License: LGPL v3.0](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
|
||||
|
||||
This project is licensed under the GNU Lesser General Public License v3.0. See the [LICENSE](LICENSE) file for details.
|
||||
|
||||
## References
|
||||
|
||||
* [Additional Documentation](https://forum.poa.network/c/tokenbridge)
|
||||
* [POA Bridge FAQ](https://poanet.zendesk.com/hc/en-us/categories/360000349273-POA-Bridge)
|
||||
|
246
token-bridge/abis/BridgeValidators.abi.json
Normal file
246
token-bridge/abis/BridgeValidators.abi.json
Normal file
@ -0,0 +1,246 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "validator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "ValidatorAdded",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "validator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "ValidatorRemoved",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredSignatures",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredSignaturesChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "previousOwner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnershipTransferred",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_requiredSignatures",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_initialValidators",
|
||||
"type": "address[]"
|
||||
},
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "addValidator",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "removeValidator",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_requiredSignatures",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredSignatures",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorCount",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "validators",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validator",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isValidator",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
175
token-bridge/abis/ERC20.abi.json
Normal file
175
token-bridge/abis/ERC20.abi.json
Normal file
@ -0,0 +1,175 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "who",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
597
token-bridge/abis/ERC677BridgeToken.abi.json
Normal file
597
token-bridge/abis/ERC677BridgeToken.abi.json
Normal file
@ -0,0 +1,597 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "mintingFinished",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "name",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "approve",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalSupply",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transferFrom",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "decimals",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "mint",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "burn",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_subtractedValue",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "decreaseApproval",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "balanceOf",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "symbol",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "bridgeContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_addedValue",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "increaseApproval",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_spender",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "allowance",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_name",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_symbol",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "_decimals",
|
||||
"type": "uint8"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "constructor"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "ContractFallbackCallFailed",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Mint",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [],
|
||||
"name": "MintFinished",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "previousOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnershipRenounced",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "previousOwner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnershipTransferred",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "burner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Burn",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "owner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "spender",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Approval",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "Transfer",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_bridgeContract",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setBridgeContract",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_data",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "transferAndCall",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getTokenInterfacesVersion",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "major",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "minor",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "patch",
|
||||
"type": "uint64"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "transfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [],
|
||||
"name": "finishMinting",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [],
|
||||
"name": "renounceOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
699
token-bridge/abis/ForeignBridgeErc677ToErc677.abi.json
Normal file
699
token-bridge/abis/ForeignBridgeErc677ToErc677.abi.json
Normal file
@ -0,0 +1,699 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "erc677token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_txHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "relayedMessages",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "vs",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "rs",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "ss",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "executeSignatures",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setExecutionDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getBridgeMode",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "_data",
|
||||
"type": "bytes4"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "executionDailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalExecutedPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinExecutionLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "executionMaxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "owner",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getBridgeInterfacesVersion",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "major",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "minor",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "patch",
|
||||
"type": "uint64"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "onTokenTransfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "upgradeabilityAdmin",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setExecutionMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "transferOwnership",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UserRequestForAffirmation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "RelayedMessage",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "ExecutionDailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "previousOwner",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newOwner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "OwnershipTransferred",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_erc20token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_homeDailyLimit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_homeMaxPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_owner",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "erc20token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
409
token-bridge/abis/ForeignBridgeErcToErc.abi.json
Normal file
409
token-bridge/abis/ForeignBridgeErcToErc.abi.json
Normal file
@ -0,0 +1,409 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_txHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "relayedMessages",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "vs",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "rs",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "ss",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "executeSignatures",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "RelayedMessage",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_erc20token",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "erc20token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
||||
|
452
token-bridge/abis/ForeignBridgeErcToNative.abi.json
Normal file
452
token-bridge/abis/ForeignBridgeErcToNative.abi.json
Normal file
@ -0,0 +1,452 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_txHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "relayedMessages",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "vs",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "rs",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "ss",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "executeSignatures",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getBridgeInterfacesVersion",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "major",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "minor",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "patch",
|
||||
"type": "uint64"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "RelayedMessage",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_erc20token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getBridgeMode",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "_data",
|
||||
"type": "bytes4"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "erc20token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
490
token-bridge/abis/ForeignBridgeNativeToErc.abi.json
Normal file
490
token-bridge/abis/ForeignBridgeNativeToErc.abi.json
Normal file
@ -0,0 +1,490 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "erc677token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_txHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "relayedMessages",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "vs",
|
||||
"type": "uint8[]"
|
||||
},
|
||||
{
|
||||
"name": "rs",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "ss",
|
||||
"type": "bytes32[]"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "executeSignatures",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "onTokenTransfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UserRequestForAffirmation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "RelayedMessage",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_erc677token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_foreignGasPrice",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokensFromErc677",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
679
token-bridge/abis/HomeBridgeErcToErc.abi.json
Normal file
679
token-bridge/abis/HomeBridgeErcToErc.abi.json
Normal file
@ -0,0 +1,679 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_message",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "numMessagesSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_hash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "_index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "signature",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "erc677token",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredMessageLength",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_hash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "message",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "submitSignature",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_withdrawal",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "numAffirmationsSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_withdrawal",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "affirmationsSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_message",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "messagesSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "executeAffirmation",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_from",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "onTokenTransfer",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_number",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "isAlreadyProcessed",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "fallback"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UserRequestForSignature",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "AffirmationCompleted",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "messageHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "SignedForUserRequest",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "SignedForAffirmation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "authorityResponsibleForRelay",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "messageHash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "NumberOfCollectedSignatures",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "CollectedSignatures",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_homeGasPrice",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_erc677token",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
716
token-bridge/abis/HomeBridgeErcToNative.abi.json
Normal file
716
token-bridge/abis/HomeBridgeErcToNative.abi.json
Normal file
@ -0,0 +1,716 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_message",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "numMessagesSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_hash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "_index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "signature",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredMessageLength",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_hash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "message",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "submitSignature",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_withdrawal",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "numAffirmationsSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_withdrawal",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "affirmationsSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_message",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "messagesSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "executeAffirmation",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getBridgeInterfacesVersion",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "major",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "minor",
|
||||
"type": "uint64"
|
||||
},
|
||||
{
|
||||
"name": "patch",
|
||||
"type": "uint64"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_number",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "isAlreadyProcessed",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"payable": true,
|
||||
"stateMutability": "payable",
|
||||
"type": "fallback"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UserRequestForSignature",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "AffirmationCompleted",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "messageHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "SignedForUserRequest",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "SignedForAffirmation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "authorityResponsibleForRelay",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "messageHash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "NumberOfCollectedSignatures",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "CollectedSignatures",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_homeGasPrice",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_blockReward",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getBridgeMode",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "_data",
|
||||
"type": "bytes4"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "blockRewardContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "totalBurntCoins",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockReward",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "setBlockRewardContract",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
634
token-bridge/abis/HomeBridgeNativeToErc.abi.json
Normal file
634
token-bridge/abis/HomeBridgeNativeToErc.abi.json
Normal file
@ -0,0 +1,634 @@
|
||||
[
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_message",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "numMessagesSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_hash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"name": "_index",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "signature",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_day",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "totalSpentPerDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "isInitialized",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "getCurrentDay",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredBlockConfirmations",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredMessageLength",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_hash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "message",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "signature",
|
||||
"type": "bytes"
|
||||
},
|
||||
{
|
||||
"name": "message",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "submitSignature",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "dailyLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_token",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_to",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "claimTokens",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_withdrawal",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "numAffirmationsSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_withdrawal",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "affirmationsSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "requiredSignatures",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_message",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "messagesSigned",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "validatorContract",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "executeAffirmation",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "deployedAtBlock",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMinPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_blockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setRequiredBlockConfirmations",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setDailyLimit",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setGasPrice",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "setMaxPerTx",
|
||||
"outputs": [],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "minPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_amount",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "withinLimit",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "maxPerTx",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [],
|
||||
"name": "gasPrice",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"constant": true,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_number",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "isAlreadyProcessed",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "pure",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"payable": true,
|
||||
"stateMutability": "payable",
|
||||
"type": "fallback"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "UserRequestForSignature",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "recipient",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "value",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "AffirmationCompleted",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "messageHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "SignedForUserRequest",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "transactionHash",
|
||||
"type": "bytes32"
|
||||
}
|
||||
],
|
||||
"name": "SignedForAffirmation",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "authorityResponsibleForRelay",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "messageHash",
|
||||
"type": "bytes32"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "NumberOfCollectedSignatures",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "CollectedSignatures",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "gasPrice",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "GasPriceChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "RequiredBlockConfirmationChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": false,
|
||||
"name": "newLimit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "DailyLimitChanged",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"constant": false,
|
||||
"inputs": [
|
||||
{
|
||||
"name": "_validatorContract",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"name": "_dailyLimit",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_maxPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_minPerTx",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_homeGasPrice",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"name": "_requiredBlockConfirmations",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "initialize",
|
||||
"outputs": [
|
||||
{
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"payable": false,
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
BIN
token-bridge/audit/peppersec/POA-Network-Token-bridge-security-assessment-report.pdf
Normal file
BIN
token-bridge/audit/peppersec/POA-Network-Token-bridge-security-assessment-report.pdf
Normal file
Binary file not shown.
46
token-bridge/config/affirmation-request-watcher.config.js
Normal file
46
token-bridge/config/affirmation-request-watcher.config.js
Normal file
@ -0,0 +1,46 @@
|
||||
require('dotenv').config()
|
||||
const baseConfig = require('./base.config')
|
||||
const erc20Abi = require('../abis/ERC20.abi')
|
||||
const { ERC_TYPES } = require('../src/utils/constants')
|
||||
|
||||
const initialChecksJson = process.argv[3]
|
||||
|
||||
if (!initialChecksJson) {
|
||||
throw new Error('initial check parameter was not provided.')
|
||||
}
|
||||
|
||||
let initialChecks
|
||||
try {
|
||||
initialChecks = JSON.parse(initialChecksJson)
|
||||
} catch (e) {
|
||||
throw new Error('Error on decoding values from initial checks.')
|
||||
}
|
||||
|
||||
if (baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC677) {
|
||||
baseConfig.id = 'erc677-erc677'
|
||||
}
|
||||
|
||||
const id = `${baseConfig.id}-affirmation-request`
|
||||
|
||||
module.exports =
|
||||
(baseConfig.id === 'erc-erc' && initialChecks.foreignERC === ERC_TYPES.ERC20) ||
|
||||
baseConfig.id === 'erc-native'
|
||||
? {
|
||||
...baseConfig.bridgeConfig,
|
||||
...baseConfig.foreignConfig,
|
||||
event: 'Transfer',
|
||||
eventContractAddress: process.env.ERC20_TOKEN_ADDRESS,
|
||||
eventAbi: erc20Abi,
|
||||
eventFilter: { to: process.env.FOREIGN_BRIDGE_ADDRESS },
|
||||
queue: 'home',
|
||||
name: `watcher-${id}`,
|
||||
id
|
||||
}
|
||||
: {
|
||||
...baseConfig.bridgeConfig,
|
||||
...baseConfig.foreignConfig,
|
||||
event: 'UserRequestForAffirmation',
|
||||
queue: 'home',
|
||||
name: `watcher-${id}`,
|
||||
id
|
||||
}
|
93
token-bridge/config/base.config.js
Normal file
93
token-bridge/config/base.config.js
Normal file
@ -0,0 +1,93 @@
|
||||
require('dotenv').config()
|
||||
|
||||
const { toBN } = require('web3').utils
|
||||
const { web3Home, web3Foreign } = require('../src/services/web3')
|
||||
const { privateKeyToAddress } = require('../src/utils/utils')
|
||||
|
||||
const homeNativeErcAbi = require('../abis/HomeBridgeNativeToErc.abi')
|
||||
const foreignNativeErcAbi = require('../abis/ForeignBridgeNativeToErc.abi')
|
||||
|
||||
const homeErcErcAbi = require('../abis/HomeBridgeErcToErc.abi')
|
||||
const foreignErc677Erc677Abi = require('../abis/ForeignBridgeErc677ToErc677.abi')
|
||||
|
||||
const homeErcNativeAbi = require('../abis/HomeBridgeErcToNative.abi')
|
||||
const foreignErcNativeAbi = require('../abis/ForeignBridgeErcToNative.abi')
|
||||
|
||||
const { VALIDATOR_ADDRESS, VALIDATOR_ADDRESS_PRIVATE_KEY } = process.env
|
||||
|
||||
let homeAbi
|
||||
let foreignAbi
|
||||
let id
|
||||
|
||||
switch (process.env.BRIDGE_MODE) {
|
||||
case 'NATIVE_TO_ERC':
|
||||
homeAbi = homeNativeErcAbi
|
||||
foreignAbi = foreignNativeErcAbi
|
||||
id = 'native-erc'
|
||||
break
|
||||
case 'ERC_TO_ERC':
|
||||
homeAbi = homeErcErcAbi
|
||||
foreignAbi = foreignErc677Erc677Abi
|
||||
id = 'erc-erc'
|
||||
break
|
||||
case 'ERC_TO_NATIVE':
|
||||
homeAbi = homeErcNativeAbi
|
||||
foreignAbi = foreignErcNativeAbi
|
||||
id = 'erc-native'
|
||||
break
|
||||
default:
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
throw new Error(`Bridge Mode: ${process.env.BRIDGE_MODE} not supported.`)
|
||||
} else {
|
||||
homeAbi = homeErcNativeAbi
|
||||
foreignAbi = foreignErcNativeAbi
|
||||
id = 'erc-native'
|
||||
}
|
||||
}
|
||||
|
||||
let maxProcessingTime = null
|
||||
if (String(process.env.MAX_PROCESSING_TIME) === '0') {
|
||||
maxProcessingTime = 0
|
||||
} else if (!process.env.MAX_PROCESSING_TIME) {
|
||||
maxProcessingTime =
|
||||
4 * Math.max(process.env.HOME_POLLING_INTERVAL, process.env.FOREIGN_POLLING_INTERVAL)
|
||||
} else {
|
||||
maxProcessingTime = Number(process.env.MAX_PROCESSING_TIME)
|
||||
}
|
||||
|
||||
const bridgeConfig = {
|
||||
homeBridgeAddress: process.env.HOME_BRIDGE_ADDRESS,
|
||||
homeBridgeAbi: homeAbi,
|
||||
foreignBridgeAddress: process.env.FOREIGN_BRIDGE_ADDRESS,
|
||||
foreignBridgeAbi: foreignAbi,
|
||||
eventFilter: {},
|
||||
validatorAddress: VALIDATOR_ADDRESS || privateKeyToAddress(VALIDATOR_ADDRESS_PRIVATE_KEY),
|
||||
maxProcessingTime
|
||||
}
|
||||
|
||||
const homeConfig = {
|
||||
eventContractAddress: process.env.HOME_BRIDGE_ADDRESS,
|
||||
eventAbi: homeAbi,
|
||||
bridgeContractAddress: process.env.HOME_BRIDGE_ADDRESS,
|
||||
bridgeAbi: homeAbi,
|
||||
pollingInterval: process.env.HOME_POLLING_INTERVAL,
|
||||
startBlock: toBN(process.env.HOME_START_BLOCK || 0),
|
||||
web3: web3Home
|
||||
}
|
||||
|
||||
const foreignConfig = {
|
||||
eventContractAddress: process.env.FOREIGN_BRIDGE_ADDRESS,
|
||||
eventAbi: foreignAbi,
|
||||
bridgeContractAddress: process.env.FOREIGN_BRIDGE_ADDRESS,
|
||||
bridgeAbi: foreignAbi,
|
||||
pollingInterval: process.env.FOREIGN_POLLING_INTERVAL,
|
||||
startBlock: toBN(process.env.FOREIGN_START_BLOCK || 0),
|
||||
web3: web3Foreign
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
bridgeConfig,
|
||||
homeConfig,
|
||||
foreignConfig,
|
||||
id
|
||||
}
|
12
token-bridge/config/collected-signatures-watcher.config.js
Normal file
12
token-bridge/config/collected-signatures-watcher.config.js
Normal file
@ -0,0 +1,12 @@
|
||||
const baseConfig = require('./base.config')
|
||||
|
||||
const id = `${baseConfig.id}-collected-signatures`
|
||||
|
||||
module.exports = {
|
||||
...baseConfig.bridgeConfig,
|
||||
...baseConfig.homeConfig,
|
||||
event: 'CollectedSignatures',
|
||||
queue: 'foreign',
|
||||
name: `watcher-${id}`,
|
||||
id
|
||||
}
|
12
token-bridge/config/foreign-sender.config.js
Normal file
12
token-bridge/config/foreign-sender.config.js
Normal file
@ -0,0 +1,12 @@
|
||||
require('dotenv').config()
|
||||
const baseConfig = require('./base.config')
|
||||
|
||||
const { web3Foreign } = require('../src/services/web3')
|
||||
|
||||
module.exports = {
|
||||
...baseConfig.bridgeConfig,
|
||||
queue: 'foreign',
|
||||
id: 'foreign',
|
||||
name: 'sender-foreign',
|
||||
web3: web3Foreign
|
||||
}
|
12
token-bridge/config/home-sender.config.js
Normal file
12
token-bridge/config/home-sender.config.js
Normal file
@ -0,0 +1,12 @@
|
||||
require('dotenv').config()
|
||||
const baseConfig = require('./base.config')
|
||||
|
||||
const { web3Home } = require('../src/services/web3')
|
||||
|
||||
module.exports = {
|
||||
...baseConfig.bridgeConfig,
|
||||
queue: 'home',
|
||||
id: 'home',
|
||||
name: 'sender-home',
|
||||
web3: web3Home
|
||||
}
|
12
token-bridge/config/signature-request-watcher.config.js
Normal file
12
token-bridge/config/signature-request-watcher.config.js
Normal file
@ -0,0 +1,12 @@
|
||||
const baseConfig = require('./base.config')
|
||||
|
||||
const id = `${baseConfig.id}-signature-request`
|
||||
|
||||
module.exports = {
|
||||
...baseConfig.bridgeConfig,
|
||||
...baseConfig.homeConfig,
|
||||
event: 'UserRequestForSignature',
|
||||
queue: 'home',
|
||||
name: `watcher-${id}`,
|
||||
id
|
||||
}
|
122
token-bridge/docker-compose.yml
Normal file
122
token-bridge/docker-compose.yml
Normal file
@ -0,0 +1,122 @@
|
||||
version: '2.4'
|
||||
services:
|
||||
rabbit:
|
||||
cpus: 0.3
|
||||
mem_limit: 500m
|
||||
environment: ['RABBITMQ_NODENAME=node@rabbit']
|
||||
hostname: rabbit
|
||||
image: rabbitmq:3
|
||||
networks:
|
||||
- net_rabbit_bridge_request
|
||||
- net_rabbit_bridge_collected
|
||||
- net_rabbit_bridge_affirmation
|
||||
- net_rabbit_bridge_senderhome
|
||||
- net_rabbit_bridge_senderforeign
|
||||
restart: unless-stopped
|
||||
volumes: ['~/bridge_data/rabbitmq:/var/lib/rabbitmq/mnesia']
|
||||
redis:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
command: [redis-server, --appendonly, 'yes']
|
||||
hostname: redis
|
||||
image: redis:4
|
||||
networks:
|
||||
- net_db_bridge_request
|
||||
- net_db_bridge_collected
|
||||
- net_db_bridge_affirmation
|
||||
- net_db_bridge_senderhome
|
||||
- net_db_bridge_senderforeign
|
||||
restart: unless-stopped
|
||||
volumes: ['~/bridge_data/redis:/data']
|
||||
bridge_request:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
build: .
|
||||
command: 'true'
|
||||
env_file: ./.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- VALIDATOR_ADDRESS_PRIVATE_KEY=${VALIDATOR_ADDRESS_PRIVATE_KEY}
|
||||
restart: unless-stopped
|
||||
entrypoint: npm run watcher:signature-request
|
||||
networks:
|
||||
- net_db_bridge_request
|
||||
- net_rabbit_bridge_request
|
||||
bridge_collected:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
build: .
|
||||
command: 'true'
|
||||
env_file: ./.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- VALIDATOR_ADDRESS=${VALIDATOR_ADDRESS}
|
||||
restart: unless-stopped
|
||||
entrypoint: npm run watcher:collected-signatures
|
||||
networks:
|
||||
- net_db_bridge_collected
|
||||
- net_rabbit_bridge_collected
|
||||
bridge_affirmation:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
build: .
|
||||
command: 'true'
|
||||
env_file: ./.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- VALIDATOR_ADDRESS=${VALIDATOR_ADDRESS}
|
||||
restart: unless-stopped
|
||||
entrypoint: npm run watcher:affirmation-request
|
||||
networks:
|
||||
- net_db_bridge_affirmation
|
||||
- net_rabbit_bridge_affirmation
|
||||
bridge_senderhome:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
build: .
|
||||
command: 'true'
|
||||
env_file: ./.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- VALIDATOR_ADDRESS_PRIVATE_KEY=${VALIDATOR_ADDRESS_PRIVATE_KEY}
|
||||
restart: unless-stopped
|
||||
entrypoint: npm run sender:home
|
||||
networks:
|
||||
- net_db_bridge_senderhome
|
||||
- net_rabbit_bridge_senderhome
|
||||
bridge_senderforeign:
|
||||
cpus: 0.1
|
||||
mem_limit: 500m
|
||||
build: .
|
||||
command: 'true'
|
||||
env_file: ./.env
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- VALIDATOR_ADDRESS_PRIVATE_KEY=${VALIDATOR_ADDRESS_PRIVATE_KEY}
|
||||
restart: unless-stopped
|
||||
entrypoint: npm run sender:foreign
|
||||
networks:
|
||||
- net_db_bridge_senderforeign
|
||||
- net_rabbit_bridge_senderforeign
|
||||
|
||||
networks:
|
||||
net_db_bridge_request:
|
||||
driver: bridge
|
||||
net_db_bridge_collected:
|
||||
driver: bridge
|
||||
net_db_bridge_affirmation:
|
||||
driver: bridge
|
||||
net_db_bridge_senderhome:
|
||||
driver: bridge
|
||||
net_db_bridge_senderforeign:
|
||||
driver: bridge
|
||||
net_rabbit_bridge_request:
|
||||
driver: bridge
|
||||
net_rabbit_bridge_collected:
|
||||
driver: bridge
|
||||
net_rabbit_bridge_affirmation:
|
||||
driver: bridge
|
||||
net_rabbit_bridge_senderhome:
|
||||
driver: bridge
|
||||
net_rabbit_bridge_senderforeign:
|
||||
driver: bridge
|
108
token-bridge/docs/stress-testing.md
Normal file
108
token-bridge/docs/stress-testing.md
Normal file
@ -0,0 +1,108 @@
|
||||
# Stress testing
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Geth](https://geth.ethereum.org/)
|
||||
- [Parity](https://www.parity.io/)
|
||||
|
||||
## Geth (home) setup
|
||||
|
||||
In one terminal, initialize the geth chain using this `genesis.json`
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"chainId": 15,
|
||||
"homesteadBlock": 0,
|
||||
"eip155Block": 0,
|
||||
"eip158Block": 0,
|
||||
"eip160Block": 0,
|
||||
"byzantiumBlock": 0
|
||||
},
|
||||
"difficulty": "100000",
|
||||
"gasLimit": "0x1000000000",
|
||||
"alloc": {
|
||||
"0xaaB52d66283F7A1D5978bcFcB55721ACB467384b": { "balance": "1000000000000000000000" },
|
||||
"0xbb140FbA6242a1c3887A7823F7750a73101383e3": { "balance": "1000000000000000000000" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
and run this command:
|
||||
|
||||
```
|
||||
geth --datadir ./data init genesis.json
|
||||
```
|
||||
|
||||
Then start the node:
|
||||
|
||||
```
|
||||
geth --datadir ./data --networkid 15 --rpc --rpcapi eth,web3,net
|
||||
```
|
||||
|
||||
After doing this, you can enable the mining mode by doing:
|
||||
|
||||
```
|
||||
geth attach --datadir ./data --exec "miner.setEtherbase('0xaaB52d66283F7A1D5978bcFcB55721ACB467384b'); miner.start(1)"
|
||||
```
|
||||
|
||||
And you can disable it by doing:
|
||||
|
||||
```
|
||||
geth attach --datadir ./data --exec "miner.stop()"
|
||||
```
|
||||
|
||||
## Parity (foreign) setup
|
||||
|
||||
Start a parity node using the docker image in the `e2e/parity` directory.
|
||||
Assuming that this image has been built and that the image name is `my-parity`,
|
||||
run:
|
||||
|
||||
```
|
||||
docker run -p 8546:8545 my-parity
|
||||
```
|
||||
|
||||
## Deploy contracts and start the bridge
|
||||
|
||||
Set the geth node in mining mode. Set `http://localhost:8545` as the home RPC
|
||||
URL, `http://localhost:8546` as the foreign RPC URL and
|
||||
`0xaaB52d66283F7A1D5978bcFcB55721ACB467384b` as the deployer and validator.
|
||||
Deploy the contracts.
|
||||
|
||||
To start the bridge, you can do `npm run dev`, or you can start all the scripts
|
||||
separately.
|
||||
|
||||
## Generate a block with several transactions
|
||||
|
||||
Stop the mining in the node. Then, generate 1000 transactions by doing
|
||||
`node scripts/sendUserTxToHome.js 1000`. After checking that the node received
|
||||
all the transactions, start the mining again.
|
||||
|
||||
This will generate a block with 1000 transactions that the bridge will process.
|
||||
|
||||
## Generate statistics
|
||||
|
||||
After doing all of this, run `node scripts/compute-stats.js`. This will print
|
||||
some statistics about the processed transactions.
|
||||
|
||||
### Statistics results
|
||||
|
||||
**Signature Requests**
|
||||
|
||||
Tests |1|2|3|4|5|AVG
|
||||
---|---|---|---|---|---|---
|
||||
count|1000|1000|1000|1000|1000|1000
|
||||
mean|12112|17714|15377|16468|15745|15483
|
||||
median|11968|17925|15518|16994|15931|15667
|
||||
min|5584|6423|5803|6121|6090|6004
|
||||
max|18685|27554|23844|25310|24198|23918
|
||||
|
||||
**Collected Signatures**
|
||||
|
||||
Tests |1|2|3|4|5|AVG
|
||||
---|---|---|---|---|---|---
|
||||
count|1000|1000|1000|1000|1000|1000
|
||||
mean|8564|5399|6653|9684|9605|7981
|
||||
median|8771|5971|7295|9854|10056|8389
|
||||
min|7301|2783|3003|8331|7165|5716
|
||||
max|9156|7453|9492|10889|10687|9535
|
5
token-bridge/e2e/.dockerignore
Normal file
5
token-bridge/e2e/.dockerignore
Normal file
@ -0,0 +1,5 @@
|
||||
node_modules
|
||||
submodules
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
docker-compose.yml
|
7
token-bridge/e2e/.eslintrc
Normal file
7
token-bridge/e2e/.eslintrc
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../.eslintrc",
|
||||
"globals": {
|
||||
"describe": false,
|
||||
"it": false
|
||||
}
|
||||
}
|
2
token-bridge/e2e/.gitignore
vendored
Normal file
2
token-bridge/e2e/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
data/
|
1
token-bridge/e2e/.nvmrc
Normal file
1
token-bridge/e2e/.nvmrc
Normal file
@ -0,0 +1 @@
|
||||
8
|
28
token-bridge/e2e/Dockerfile
Normal file
28
token-bridge/e2e/Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
FROM node:8
|
||||
|
||||
RUN mkdir /stuff
|
||||
WORKDIR /stuff
|
||||
|
||||
COPY package.json .
|
||||
COPY package-lock.json .
|
||||
|
||||
RUN git clone https://github.com/poanetwork/poa-bridge-contracts.git
|
||||
|
||||
RUN mkdir submodules && \
|
||||
mv poa-bridge-contracts submodules && \
|
||||
cd submodules/poa-bridge-contracts && \
|
||||
git fetch && \
|
||||
git checkout 2.2.0
|
||||
|
||||
RUN npm install --unsafe-perm
|
||||
|
||||
RUN cd submodules/poa-bridge-contracts && \
|
||||
npm install && \
|
||||
./node_modules/.bin/truffle compile && \
|
||||
cd deploy && \
|
||||
npm install
|
||||
|
||||
ADD . .
|
||||
|
||||
|
||||
CMD ["npm", "start"]
|
674
token-bridge/e2e/LICENSE
Normal file
674
token-bridge/e2e/LICENSE
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
55
token-bridge/e2e/README.md
Normal file
55
token-bridge/e2e/README.md
Normal file
@ -0,0 +1,55 @@
|
||||
# bridge-e2e
|
||||
|
||||
End to end tests for the NodeJS Bridge.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
To run the tests you need to have
|
||||
[Docker](https://www.docker.com/community-edition) and
|
||||
[Docker Compose](https://docs.docker.com/compose/install/) installed.
|
||||
If you are on Linux, it's also recommended that you [create a docker group and
|
||||
add your user to it](https://docs.docker.com/install/linux/linux-postinstall/),
|
||||
so that you can use the CLI without sudo.
|
||||
|
||||
## Running
|
||||
|
||||
To run the bridge end-to-end tests, you just have to go to the `e2e` directory
|
||||
and run:
|
||||
|
||||
```
|
||||
$ ./run-tests.sh
|
||||
```
|
||||
|
||||
If this is the first time that you do this, it will take some time to build the
|
||||
docker images, but the next time they will be cached.
|
||||
|
||||
## How it works
|
||||
|
||||
The script starts several containers and then use them to run the tests. These
|
||||
services are:
|
||||
|
||||
- Two parity nodes with the InstanSeal engine, representing the home and foreign
|
||||
chains.
|
||||
- A Redis container.
|
||||
- A RabbitMQ container.
|
||||
- The bridge (without doing anything at first)
|
||||
- The container for the end-to-end tests (also without doing anything)
|
||||
|
||||
Afterwards, contracts will be deployed to the respective chains, all the bridge
|
||||
scripts will be executed (using the bridge service) and tests (using the e2e
|
||||
service) will be executed. The last process exit code will be used as the result
|
||||
of the testing suite.
|
||||
|
||||
## Debugging
|
||||
|
||||
Sometimes you may need to look into what happened in each service after running
|
||||
the tests. For doing this, comment out the `docker-compose down` line in the
|
||||
`run-tests.sh` file, and all the containers will be kept running after the
|
||||
script finishes. Some things you can do:
|
||||
|
||||
- Connect to the home chain using `http://localhost:8541` as the URL.
|
||||
- Connect to the foreign chain using `http://localhost:8542` as the URL.
|
||||
- Open the RabbitMQ Management service (go to `http://localhost:15672` in the
|
||||
browser and log in with username/password `guest/guest`).
|
||||
- Inspect the logs using `docker logs CONTAINER`. You can obtain the container
|
||||
name with the `docker ps` command.
|
14
token-bridge/e2e/constants.json
Normal file
14
token-bridge/e2e/constants.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"temp": {
|
||||
"address": "0xcca2fb44C8C36E51f743269d6F484Fd027B9F9Aa",
|
||||
"privateKey": "0xcf954e07e6a439faf392eb474e95ddb444c2ca444847f2ad6ecc79e1a585e2b8"
|
||||
},
|
||||
"user": {
|
||||
"address": "0xbb140FbA6242a1c3887A7823F7750a73101383e3",
|
||||
"privateKey": "0x63e48a8ba0b99e0377c6b483af4a072cbca5ffbcfdac77be72e69f4960125800"
|
||||
},
|
||||
"validator": {
|
||||
"address": "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b",
|
||||
"privateKey": "0x8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||
}
|
||||
}
|
23
token-bridge/e2e/deploy.js
Normal file
23
token-bridge/e2e/deploy.js
Normal file
@ -0,0 +1,23 @@
|
||||
const path = require('path')
|
||||
const shell = require('shelljs')
|
||||
|
||||
const envsDir = path.join(__dirname, 'envs')
|
||||
const deployContractsDir = path.join(__dirname, 'submodules/poa-bridge-contracts/deploy')
|
||||
const erc20ScriptDir = path.join(__dirname, 'scripts')
|
||||
|
||||
shell.cp(path.join(envsDir, 'contracts-deploy.env'), path.join(deployContractsDir, '.env'))
|
||||
shell.cd(deployContractsDir)
|
||||
shell.exec('node deploy.js')
|
||||
shell.cd(erc20ScriptDir)
|
||||
shell.exec('node deployERC20.js')
|
||||
shell.cd(deployContractsDir)
|
||||
shell.rm('.env')
|
||||
shell.cp(path.join(envsDir, 'erc-contracts-deploy.env'), path.join(deployContractsDir, '.env'))
|
||||
shell.exec('node deploy.js')
|
||||
shell.rm('.env')
|
||||
shell.cp(
|
||||
path.join(envsDir, 'erc-native-contracts-deploy.env'),
|
||||
path.join(deployContractsDir, '.env')
|
||||
)
|
||||
shell.exec('node src/utils/deployBlockReward.js')
|
||||
shell.exec('node deploy.js')
|
102
token-bridge/e2e/docker-compose.yml
Normal file
102
token-bridge/e2e/docker-compose.yml
Normal file
@ -0,0 +1,102 @@
|
||||
version: '3'
|
||||
services:
|
||||
parity1:
|
||||
build: parity
|
||||
ports:
|
||||
- "8541:8545"
|
||||
parity2:
|
||||
build: parity
|
||||
ports:
|
||||
- "8542:8545"
|
||||
redis:
|
||||
image: "redis:4"
|
||||
rabbit:
|
||||
image: "rabbitmq:3-management"
|
||||
ports:
|
||||
- "15672:15672"
|
||||
bridge:
|
||||
build: ..
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- BRIDGE_MODE=NATIVE_TO_ERC
|
||||
- QUEUE_URL=amqp://rabbit
|
||||
- REDIS_URL=redis://redis
|
||||
- HOME_RPC_URL=http://parity1:8545
|
||||
- FOREIGN_RPC_URL=http://parity2:8545
|
||||
- HOME_BRIDGE_ADDRESS=0x32198D570fffC7033641F8A9094FFDCaAEF42624
|
||||
- FOREIGN_BRIDGE_ADDRESS=0x2B6871b9B02F73fa24F4864322CdC78604207769
|
||||
- ERC20_TOKEN_ADDRESS=0xdbeE25CbE97e4A5CC6c499875774dc7067E9426B
|
||||
- VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
- VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
- REDIS_LOCK_TTL=1000
|
||||
- HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
- HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
- HOME_GAS_PRICE_FALLBACK=1000000000
|
||||
- HOME_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
- FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
- FOREIGN_GAS_PRICE_SPEED_TYPE=standard
|
||||
- FOREIGN_GAS_PRICE_FALLBACK=10000000000
|
||||
- FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
- HOME_POLLING_INTERVAL=500
|
||||
- FOREIGN_POLLING_INTERVAL=500
|
||||
- ALLOW_HTTP=yes
|
||||
command: "true"
|
||||
bridge-erc:
|
||||
build: ..
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- BRIDGE_MODE=ERC_TO_ERC
|
||||
- QUEUE_URL=amqp://rabbit
|
||||
- REDIS_URL=redis://redis
|
||||
- HOME_RPC_URL=http://parity1:8545
|
||||
- FOREIGN_RPC_URL=http://parity2:8545
|
||||
- HOME_BRIDGE_ADDRESS=0x1feB40aD9420b186F019A717c37f5546165d411E
|
||||
- FOREIGN_BRIDGE_ADDRESS=0x4a58D6d8D416a5fBCAcf3dC52eb8bE8948E25127
|
||||
- ERC20_TOKEN_ADDRESS=0x3C665A31199694Bf723fD08844AD290207B5797f
|
||||
- BRIDGEABLE_TOKEN_ADDRESS=0x792455a6bCb62Ed4C4362D323E0590654CA4765c
|
||||
- VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
- VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
- REDIS_LOCK_TTL=1000
|
||||
- HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
- HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
- HOME_GAS_PRICE_FALLBACK=1000000000
|
||||
- HOME_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
- FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
- FOREIGN_GAS_PRICE_SPEED_TYPE=standard
|
||||
- FOREIGN_GAS_PRICE_FALLBACK=10000000000
|
||||
- FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
- HOME_POLLING_INTERVAL=500
|
||||
- FOREIGN_POLLING_INTERVAL=500
|
||||
- ALLOW_HTTP=yes
|
||||
command: "true"
|
||||
bridge-erc-native:
|
||||
build: ..
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- BRIDGE_MODE=ERC_TO_NATIVE
|
||||
- QUEUE_URL=amqp://rabbit
|
||||
- REDIS_URL=redis://redis
|
||||
- HOME_RPC_URL=http://parity1:8545
|
||||
- FOREIGN_RPC_URL=http://parity2:8545
|
||||
- HOME_BRIDGE_ADDRESS=0x488Af810997eD1730cB3a3918cD83b3216E6eAda
|
||||
- FOREIGN_BRIDGE_ADDRESS=0x488Af810997eD1730cB3a3918cD83b3216E6eAda
|
||||
- ERC20_TOKEN_ADDRESS=0x3C665A31199694Bf723fD08844AD290207B5797f
|
||||
- BRIDGEABLE_TOKEN_ADDRESS=0x792455a6bCb62Ed4C4362D323E0590654CA4765c
|
||||
- VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
- VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
- REDIS_LOCK_TTL=1000
|
||||
- HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
- HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
- HOME_GAS_PRICE_FALLBACK=1000000000
|
||||
- HOME_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
- FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
- FOREIGN_GAS_PRICE_SPEED_TYPE=standard
|
||||
- FOREIGN_GAS_PRICE_FALLBACK=10000000000
|
||||
- FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
- HOME_POLLING_INTERVAL=500
|
||||
- FOREIGN_POLLING_INTERVAL=500
|
||||
- ALLOW_HTTP=yes
|
||||
command: "true"
|
||||
e2e:
|
||||
build: .
|
||||
command: "true"
|
26
token-bridge/e2e/envs/bridge.env
Normal file
26
token-bridge/e2e/envs/bridge.env
Normal file
@ -0,0 +1,26 @@
|
||||
HOME_RPC_URL=http://parity1:8545
|
||||
FOREIGN_RPC_URL=http://parity2:8545
|
||||
HOME_BRIDGE_ADDRESS=0x32198D570fffC7033641F8A9094FFDCaAEF42624
|
||||
FOREIGN_BRIDGE_ADDRESS=0x2B6871b9B02F73fa24F4864322CdC78604207769
|
||||
ERC20_TOKEN_ADDRESS=0xdbeE25CbE97e4A5CC6c499875774dc7067E9426B
|
||||
|
||||
VALIDATOR_ADDRESS=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
VALIDATOR_ADDRESS_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
|
||||
HOME_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
HOME_GAS_PRICE_SPEED_TYPE=standard
|
||||
HOME_GAS_PRICE_FALLBACK=1
|
||||
HOME_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
|
||||
FOREIGN_GAS_PRICE_ORACLE_URL=https://gasprice.poa.network/
|
||||
FOREIGN_GAS_PRICE_SPEED_TYPE=standard
|
||||
FOREIGN_GAS_PRICE_FALLBACK=1
|
||||
FOREIGN_GAS_PRICE_UPDATE_INTERVAL=600000
|
||||
|
||||
#testing accs
|
||||
NUMBER_OF_WITHDRAWALS_TO_SEND=3
|
||||
NUMBER_OF_DEPOSITS_TO_SEND=3
|
||||
USER_ADDRESS=0xbb140FbA6242a1c3887A7823F7750a73101383e3
|
||||
USER_ADDRESS_PRIVATE_KEY=63e48a8ba0b99e0377c6b483af4a072cbca5ffbcfdac77be72e69f4960125800
|
||||
HOME_MIN_AMOUNT_PER_TX=0.01
|
||||
FOREIGN_MIN_AMOUNT_PER_TX=0.01
|
33
token-bridge/e2e/envs/contracts-deploy.env
Normal file
33
token-bridge/e2e/envs/contracts-deploy.env
Normal file
@ -0,0 +1,33 @@
|
||||
BRIDGE_MODE=NATIVE_TO_ERC
|
||||
DEPLOYMENT_ACCOUNT_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
DEPLOYMENT_GAS_LIMIT=4600000
|
||||
HOME_DEPLOYMENT_GAS_PRICE=10000000000
|
||||
FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000
|
||||
GET_RECEIPT_INTERVAL_IN_MILLISECONDS=50
|
||||
|
||||
BRIDGEABLE_TOKEN_NAME="Your New Bridged Token"
|
||||
BRIDGEABLE_TOKEN_SYMBOL="TEST"
|
||||
BRIDGEABLE_TOKEN_DECIMALS="18"
|
||||
|
||||
HOME_RPC_URL=http://parity1:8545
|
||||
HOME_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_DAILY_LIMIT=30000000000000000000000000
|
||||
HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000
|
||||
HOME_MIN_AMOUNT_PER_TX=10000000000000000
|
||||
HOME_REQUIRED_BLOCK_CONFIRMATIONS=1
|
||||
HOME_GAS_PRICE=1000000000
|
||||
|
||||
FOREIGN_RPC_URL=http://parity2:8545
|
||||
FOREIGN_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_DAILY_LIMIT=15000000000000000000000000
|
||||
FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000
|
||||
FOREIGN_MIN_AMOUNT_PER_TX=10000000000000000
|
||||
FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS=1
|
||||
FOREIGN_GAS_PRICE=10000000000
|
||||
|
||||
REQUIRED_NUMBER_OF_VALIDATORS=1
|
||||
VALIDATORS="0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
34
token-bridge/e2e/envs/erc-contracts-deploy.env
Normal file
34
token-bridge/e2e/envs/erc-contracts-deploy.env
Normal file
@ -0,0 +1,34 @@
|
||||
BRIDGE_MODE=ERC_TO_ERC
|
||||
DEPLOYMENT_ACCOUNT_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
DEPLOYMENT_GAS_LIMIT=4600000
|
||||
HOME_DEPLOYMENT_GAS_PRICE=10000000000
|
||||
FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000
|
||||
GET_RECEIPT_INTERVAL_IN_MILLISECONDS=50
|
||||
|
||||
BRIDGEABLE_TOKEN_NAME="Your New Bridged Token"
|
||||
BRIDGEABLE_TOKEN_SYMBOL="TEST"
|
||||
BRIDGEABLE_TOKEN_DECIMALS="18"
|
||||
|
||||
HOME_RPC_URL=http://parity1:8545
|
||||
HOME_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_DAILY_LIMIT=30000000000000000000000000
|
||||
HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000
|
||||
HOME_MIN_AMOUNT_PER_TX=10000000000000000
|
||||
HOME_REQUIRED_BLOCK_CONFIRMATIONS=1
|
||||
HOME_GAS_PRICE=1000000000
|
||||
|
||||
FOREIGN_RPC_URL=http://parity2:8545
|
||||
FOREIGN_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_DAILY_LIMIT=15000000000000000000000000
|
||||
FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000
|
||||
FOREIGN_MIN_AMOUNT_PER_TX=10000000000000000
|
||||
FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS=1
|
||||
FOREIGN_GAS_PRICE=10000000000
|
||||
ERC20_TOKEN_ADDRESS=0x3C665A31199694Bf723fD08844AD290207B5797f
|
||||
|
||||
REQUIRED_NUMBER_OF_VALIDATORS=1
|
||||
VALIDATORS="0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
36
token-bridge/e2e/envs/erc-native-contracts-deploy.env
Normal file
36
token-bridge/e2e/envs/erc-native-contracts-deploy.env
Normal file
@ -0,0 +1,36 @@
|
||||
BRIDGE_MODE=ERC_TO_NATIVE
|
||||
DEPLOYMENT_ACCOUNT_PRIVATE_KEY=8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9
|
||||
DEPLOYMENT_GAS_LIMIT=4600000
|
||||
HOME_DEPLOYMENT_GAS_PRICE=10000000000
|
||||
FOREIGN_DEPLOYMENT_GAS_PRICE=10000000000
|
||||
GET_RECEIPT_INTERVAL_IN_MILLISECONDS=50
|
||||
|
||||
BRIDGEABLE_TOKEN_NAME="Your New Bridged Token"
|
||||
BRIDGEABLE_TOKEN_SYMBOL="TEST"
|
||||
BRIDGEABLE_TOKEN_DECIMALS="18"
|
||||
|
||||
HOME_RPC_URL=http://parity1:8545
|
||||
HOME_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
HOME_DAILY_LIMIT=30000000000000000000000000
|
||||
HOME_MAX_AMOUNT_PER_TX=1500000000000000000000000
|
||||
HOME_MIN_AMOUNT_PER_TX=10000000000000000
|
||||
HOME_REQUIRED_BLOCK_CONFIRMATIONS=1
|
||||
HOME_GAS_PRICE=1000000000
|
||||
|
||||
FOREIGN_RPC_URL=http://parity2:8545
|
||||
FOREIGN_BRIDGE_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_VALIDATORS_OWNER=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_UPGRADEABLE_ADMIN=0xaaB52d66283F7A1D5978bcFcB55721ACB467384b
|
||||
FOREIGN_DAILY_LIMIT=15000000000000000000000000
|
||||
FOREIGN_MAX_AMOUNT_PER_TX=750000000000000000000000
|
||||
FOREIGN_MIN_AMOUNT_PER_TX=10000000000000000
|
||||
FOREIGN_REQUIRED_BLOCK_CONFIRMATIONS=1
|
||||
FOREIGN_GAS_PRICE=10000000000
|
||||
|
||||
BLOCK_REWARD_ADDRESS=0xF9698Eb93702dfdd0e2d802088d4c21822a8A977
|
||||
ERC20_TOKEN_ADDRESS=0x3C665A31199694Bf723fD08844AD290207B5797f
|
||||
|
||||
REQUIRED_NUMBER_OF_VALIDATORS=1
|
||||
VALIDATORS="0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
2680
token-bridge/e2e/package-lock.json
generated
Normal file
2680
token-bridge/e2e/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
token-bridge/e2e/package.json
Normal file
26
token-bridge/e2e/package.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "bridge-e2e",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"deploy": "node deploy.js",
|
||||
"start": "mocha"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"chalk": "^2.4.1",
|
||||
"dotenv": "^6.0.0",
|
||||
"mocha": "^5.2.0",
|
||||
"promise-retry": "^1.1.1",
|
||||
"shelljs": "^0.8.2",
|
||||
"tree-kill": "^1.2.0",
|
||||
"web3": "1.0.0-beta.34",
|
||||
"websocket": "^1.0.28"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.9"
|
||||
},
|
||||
"devDependencies": {}
|
||||
}
|
7
token-bridge/e2e/parity/Dockerfile
Normal file
7
token-bridge/e2e/parity/Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM parity/parity:v2.3.3
|
||||
|
||||
WORKDIR /stuff
|
||||
|
||||
COPY . .
|
||||
|
||||
CMD ["--chain", "chain.json", "--jsonrpc-interface", "all"]
|
52
token-bridge/e2e/parity/chain.json
Normal file
52
token-bridge/e2e/parity/chain.json
Normal file
File diff suppressed because one or more lines are too long
17
token-bridge/e2e/run-tests.sh
Executable file
17
token-bridge/e2e/run-tests.sh
Executable file
@ -0,0 +1,17 @@
|
||||
docker-compose up -d --build --force-recreate
|
||||
docker-compose run e2e npm run deploy
|
||||
docker-compose run -d bridge npm run watcher:signature-request
|
||||
docker-compose run -d bridge npm run watcher:collected-signatures
|
||||
docker-compose run -d bridge npm run watcher:affirmation-request
|
||||
docker-compose run -d bridge-erc npm run watcher:signature-request
|
||||
docker-compose run -d bridge-erc npm run watcher:collected-signatures
|
||||
docker-compose run -d bridge-erc npm run watcher:affirmation-request
|
||||
docker-compose run -d bridge-erc-native npm run watcher:signature-request
|
||||
docker-compose run -d bridge-erc-native npm run watcher:collected-signatures
|
||||
docker-compose run -d bridge-erc-native npm run watcher:affirmation-request
|
||||
docker-compose run -d bridge npm run sender:home
|
||||
docker-compose run -d bridge npm run sender:foreign
|
||||
docker-compose run e2e npm start
|
||||
rc=$?
|
||||
docker-compose down
|
||||
exit $rc
|
49
token-bridge/e2e/scripts/deployERC20.js
Normal file
49
token-bridge/e2e/scripts/deployERC20.js
Normal file
@ -0,0 +1,49 @@
|
||||
/* eslint import/no-unresolved: 0 node/no-missing-require: 0 */
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../submodules/poa-bridge-contracts/deploy/.env')
|
||||
})
|
||||
|
||||
const {
|
||||
deployContract,
|
||||
sendRawTx,
|
||||
privateKeyToAddress
|
||||
} = require('../submodules/poa-bridge-contracts/deploy/src/deploymentUtils')
|
||||
const {
|
||||
web3Foreign,
|
||||
deploymentPrivateKey
|
||||
} = require('../submodules/poa-bridge-contracts/deploy/src/web3')
|
||||
const POA20 = require('../submodules/poa-bridge-contracts/build/contracts/ERC677BridgeToken.json')
|
||||
const { user } = require('../constants.json')
|
||||
|
||||
const { DEPLOYMENT_ACCOUNT_PRIVATE_KEY } = process.env
|
||||
const DEPLOYMENT_ACCOUNT_ADDRESS = privateKeyToAddress(DEPLOYMENT_ACCOUNT_PRIVATE_KEY)
|
||||
|
||||
async function deployErc20() {
|
||||
try {
|
||||
let foreignNonce = await web3Foreign.eth.getTransactionCount(DEPLOYMENT_ACCOUNT_ADDRESS)
|
||||
console.log('\n[Foreign] Deploying POA20 Test token')
|
||||
const poa20foreign = await deployContract(POA20, ['POA ERC20 Test', 'POA20', 18], {
|
||||
from: DEPLOYMENT_ACCOUNT_ADDRESS,
|
||||
network: 'foreign',
|
||||
nonce: foreignNonce
|
||||
})
|
||||
foreignNonce++
|
||||
console.log('[Foreign] POA20 Test: ', poa20foreign.options.address)
|
||||
|
||||
const mintData = await poa20foreign.methods
|
||||
.mint(user.address, '1000000000000000000')
|
||||
.encodeABI({ from: DEPLOYMENT_ACCOUNT_ADDRESS })
|
||||
await sendRawTx({
|
||||
data: mintData,
|
||||
nonce: foreignNonce,
|
||||
to: poa20foreign.options.address,
|
||||
privateKey: deploymentPrivateKey,
|
||||
url: process.env.FOREIGN_RPC_URL
|
||||
})
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
deployErc20()
|
107
token-bridge/e2e/test/ercToErc.js
Normal file
107
token-bridge/e2e/test/ercToErc.js
Normal file
@ -0,0 +1,107 @@
|
||||
const path = require('path')
|
||||
const Web3 = require('web3')
|
||||
const assert = require('assert')
|
||||
const promiseRetry = require('promise-retry')
|
||||
const { user } = require('../constants.json')
|
||||
const { generateNewBlock } = require('../utils/utils')
|
||||
|
||||
const abisDir = path.join(__dirname, '..', 'submodules/poa-bridge-contracts/build/contracts')
|
||||
|
||||
const homeWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity1:8545'))
|
||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity2:8545'))
|
||||
|
||||
const HOME_BRIDGE_ADDRESS = '0x1feB40aD9420b186F019A717c37f5546165d411E'
|
||||
const FOREIGN_BRIDGE_ADDRESS = '0x4a58D6d8D416a5fBCAcf3dC52eb8bE8948E25127'
|
||||
|
||||
const { toBN } = foreignWeb3.utils
|
||||
|
||||
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||
|
||||
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
||||
const erc20Token = new foreignWeb3.eth.Contract(
|
||||
tokenAbi,
|
||||
'0x3C665A31199694Bf723fD08844AD290207B5797f'
|
||||
)
|
||||
const erc677Token = new homeWeb3.eth.Contract(
|
||||
tokenAbi,
|
||||
'0x792455a6bCb62Ed4C4362D323E0590654CA4765c'
|
||||
)
|
||||
|
||||
describe('erc to erc', () => {
|
||||
it('should convert tokens in foreign to tokens in home', async () => {
|
||||
const balance = await erc20Token.methods.balanceOf(user.address).call()
|
||||
assert(!toBN(balance).isZero(), 'Account should have tokens')
|
||||
|
||||
// send tokens to foreign bridge
|
||||
await erc20Token.methods
|
||||
.transfer(FOREIGN_BRIDGE_ADDRESS, homeWeb3.utils.toWei('0.01'))
|
||||
.send({
|
||||
from: user.address,
|
||||
gas: '1000000'
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
|
||||
// Send a trivial transaction to generate a new block since the watcher
|
||||
// is configured to wait 1 confirmation block
|
||||
await generateNewBlock(foreignWeb3, user.address)
|
||||
|
||||
// check that balance increases
|
||||
await promiseRetry(async retry => {
|
||||
const balance = await erc677Token.methods.balanceOf(user.address).call()
|
||||
if (toBN(balance).isZero()) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
it('should convert tokens in home to tokens in foreign', async () => {
|
||||
const originalBalance = await erc20Token.methods.balanceOf(user.address).call()
|
||||
|
||||
// check that account has tokens in home chain
|
||||
const balance = await erc677Token.methods.balanceOf(user.address).call()
|
||||
assert(!toBN(balance).isZero(), 'Account should have tokens')
|
||||
|
||||
// send transaction to home bridge
|
||||
const depositTx = await erc677Token.methods
|
||||
.transferAndCall(HOME_BRIDGE_ADDRESS, homeWeb3.utils.toWei('0.01'), '0x')
|
||||
.send({
|
||||
from: user.address,
|
||||
gas: '1000000'
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
|
||||
// Send a trivial transaction to generate a new block since the watcher
|
||||
// is configured to wait 1 confirmation block
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
|
||||
// The bridge should create a new transaction with a CollectedSignatures
|
||||
// event so we generate another trivial transaction
|
||||
await promiseRetry(
|
||||
async retry => {
|
||||
const lastBlockNumber = await homeWeb3.eth.getBlockNumber()
|
||||
if (lastBlockNumber >= depositTx.blockNumber + 2) {
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
} else {
|
||||
retry()
|
||||
}
|
||||
},
|
||||
{
|
||||
forever: true,
|
||||
factor: 1,
|
||||
minTimeout: 500
|
||||
}
|
||||
)
|
||||
|
||||
// check that balance increases
|
||||
await promiseRetry(async retry => {
|
||||
const balance = await erc20Token.methods.balanceOf(user.address).call()
|
||||
if (toBN(balance).lte(toBN(originalBalance))) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
102
token-bridge/e2e/test/ercToNative.js
Normal file
102
token-bridge/e2e/test/ercToNative.js
Normal file
@ -0,0 +1,102 @@
|
||||
const path = require('path')
|
||||
const Web3 = require('web3')
|
||||
const assert = require('assert')
|
||||
const promiseRetry = require('promise-retry')
|
||||
const { user } = require('../constants.json')
|
||||
const { generateNewBlock } = require('../utils/utils')
|
||||
|
||||
const abisDir = path.join(__dirname, '..', 'submodules/poa-bridge-contracts/build/contracts')
|
||||
|
||||
const homeWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity1:8545'))
|
||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity2:8545'))
|
||||
|
||||
const HOME_BRIDGE_ADDRESS = '0x488Af810997eD1730cB3a3918cD83b3216E6eAda'
|
||||
const FOREIGN_BRIDGE_ADDRESS = '0x488Af810997eD1730cB3a3918cD83b3216E6eAda'
|
||||
|
||||
const { toBN } = foreignWeb3.utils
|
||||
|
||||
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||
|
||||
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
||||
const erc20Token = new foreignWeb3.eth.Contract(
|
||||
tokenAbi,
|
||||
'0x3C665A31199694Bf723fD08844AD290207B5797f'
|
||||
)
|
||||
|
||||
describe('erc to native', () => {
|
||||
it('should convert tokens in foreign to coins in home', async () => {
|
||||
const balance = await erc20Token.methods.balanceOf(user.address).call()
|
||||
const originalBalanceOnHome = await homeWeb3.eth.getBalance(user.address)
|
||||
assert(!toBN(balance).isZero(), 'Account should have tokens')
|
||||
|
||||
// send tokens to foreign bridge
|
||||
await erc20Token.methods
|
||||
.transfer(FOREIGN_BRIDGE_ADDRESS, homeWeb3.utils.toWei('0.01'))
|
||||
.send({
|
||||
from: user.address,
|
||||
gas: '1000000'
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
|
||||
// Send a trivial transaction to generate a new block since the watcher
|
||||
// is configured to wait 1 confirmation block
|
||||
await generateNewBlock(foreignWeb3, user.address)
|
||||
|
||||
// check that balance increases
|
||||
await promiseRetry(async retry => {
|
||||
const balance = await homeWeb3.eth.getBalance(user.address)
|
||||
if (toBN(balance).lte(toBN(originalBalanceOnHome))) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
it('should convert coins in home to tokens in foreign', async () => {
|
||||
const originalBalance = await erc20Token.methods.balanceOf(user.address).call()
|
||||
|
||||
// check that account has tokens in home chain
|
||||
const balance = await homeWeb3.eth.getBalance(user.address)
|
||||
assert(!toBN(balance).isZero(), 'Account should have tokens')
|
||||
|
||||
// send transaction to home bridge
|
||||
const depositTx = await homeWeb3.eth.sendTransaction({
|
||||
from: user.address,
|
||||
to: HOME_BRIDGE_ADDRESS,
|
||||
gasPrice: '1',
|
||||
gas: '1000000',
|
||||
value: homeWeb3.utils.toWei('0.01')
|
||||
})
|
||||
|
||||
// Send a trivial transaction to generate a new block since the watcher
|
||||
// is configured to wait 1 confirmation block
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
|
||||
// The bridge should create a new transaction with a CollectedSignatures
|
||||
// event so we generate another trivial transaction
|
||||
await promiseRetry(
|
||||
async retry => {
|
||||
const lastBlockNumber = await homeWeb3.eth.getBlockNumber()
|
||||
if (lastBlockNumber >= depositTx.blockNumber + 2) {
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
} else {
|
||||
retry()
|
||||
}
|
||||
},
|
||||
{
|
||||
forever: true,
|
||||
factor: 1,
|
||||
minTimeout: 500
|
||||
}
|
||||
)
|
||||
|
||||
// check that balance increases
|
||||
await promiseRetry(async retry => {
|
||||
const balance = await erc20Token.methods.balanceOf(user.address).call()
|
||||
if (toBN(balance).lte(toBN(originalBalance))) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
1
token-bridge/e2e/test/mocha.opts
Normal file
1
token-bridge/e2e/test/mocha.opts
Normal file
@ -0,0 +1 @@
|
||||
--timeout 30000
|
225
token-bridge/e2e/test/nativeToErc.js
Normal file
225
token-bridge/e2e/test/nativeToErc.js
Normal file
@ -0,0 +1,225 @@
|
||||
const path = require('path')
|
||||
const Web3 = require('web3')
|
||||
const assert = require('assert')
|
||||
const promiseRetry = require('promise-retry')
|
||||
const { user, validator, temp } = require('../constants.json')
|
||||
const { generateNewBlock } = require('../utils/utils')
|
||||
|
||||
const abisDir = path.join(__dirname, '..', 'submodules/poa-bridge-contracts/build/contracts')
|
||||
|
||||
const homeWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity1:8545'))
|
||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider('http://parity2:8545'))
|
||||
|
||||
const HOME_BRIDGE_ADDRESS = '0x32198D570fffC7033641F8A9094FFDCaAEF42624'
|
||||
const FOREIGN_BRIDGE_ADDRESS = '0x2B6871b9B02F73fa24F4864322CdC78604207769'
|
||||
|
||||
const { toBN } = foreignWeb3.utils
|
||||
|
||||
homeWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||
homeWeb3.eth.accounts.wallet.add(validator.privateKey)
|
||||
homeWeb3.eth.accounts.wallet.add(temp.privateKey)
|
||||
foreignWeb3.eth.accounts.wallet.add(user.privateKey)
|
||||
foreignWeb3.eth.accounts.wallet.add(validator.privateKey)
|
||||
foreignWeb3.eth.accounts.wallet.add(temp.privateKey)
|
||||
|
||||
const tokenAbi = require(path.join(abisDir, 'ERC677BridgeToken.json')).abi
|
||||
const token = new foreignWeb3.eth.Contract(tokenAbi, '0xdbeE25CbE97e4A5CC6c499875774dc7067E9426B')
|
||||
|
||||
const sleep = timeout => new Promise(res => setTimeout(res, timeout))
|
||||
|
||||
describe('native to erc', () => {
|
||||
it('should convert eth in home to tokens in foreign', async () => {
|
||||
// check that account has zero tokens in the foreign chain
|
||||
const balance = await token.methods.balanceOf(user.address).call()
|
||||
assert(toBN(balance).isZero(), 'Account should not have tokens yet')
|
||||
|
||||
// send transaction to home chain
|
||||
const depositTx = await homeWeb3.eth.sendTransaction({
|
||||
from: user.address,
|
||||
to: HOME_BRIDGE_ADDRESS,
|
||||
gasPrice: '1',
|
||||
gas: '50000',
|
||||
value: '1000000000000000000'
|
||||
})
|
||||
|
||||
// Send a trivial transaction to generate a new block since the watcher
|
||||
// is configured to wait 1 confirmation block
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
|
||||
// The bridge should create a new transaction with a CollectedSignatures
|
||||
// event so we generate another trivial transaction
|
||||
await promiseRetry(
|
||||
async retry => {
|
||||
const lastBlockNumber = await homeWeb3.eth.getBlockNumber()
|
||||
if (lastBlockNumber >= depositTx.blockNumber + 2) {
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
} else {
|
||||
retry()
|
||||
}
|
||||
},
|
||||
{
|
||||
forever: true,
|
||||
factor: 1,
|
||||
minTimeout: 500
|
||||
}
|
||||
)
|
||||
|
||||
// check that account has tokens in the foreign chain
|
||||
await promiseRetry(async retry => {
|
||||
const balance = await token.methods.balanceOf(user.address).call()
|
||||
if (toBN(balance).isZero()) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should convert tokens in foreign to eth in home', async () => {
|
||||
const originalBalance = await homeWeb3.eth.getBalance(user.address)
|
||||
|
||||
// send tokens to foreign bridge
|
||||
await token.methods
|
||||
.transferAndCall(FOREIGN_BRIDGE_ADDRESS, homeWeb3.utils.toWei('0.01'), '0x')
|
||||
.send({
|
||||
from: user.address,
|
||||
gas: '1000000'
|
||||
})
|
||||
.catch(e => {
|
||||
console.error(e)
|
||||
})
|
||||
|
||||
// Send a trivial transaction to generate a new block since the watcher
|
||||
// is configured to wait 1 confirmation block
|
||||
await generateNewBlock(foreignWeb3, user.address)
|
||||
|
||||
// check that balance increases
|
||||
await promiseRetry(async retry => {
|
||||
const balance = await homeWeb3.eth.getBalance(user.address)
|
||||
if (toBN(balance).lte(toBN(originalBalance))) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should wait for funds if these are insufficient (Home)', async () => {
|
||||
// check that account has zero tokens in the foreign chain
|
||||
const originalBalance = toBN(await token.methods.balanceOf(user.address).call())
|
||||
|
||||
// empty validator funds
|
||||
await sendAllBalance(homeWeb3, validator.address, temp.address)
|
||||
|
||||
// send transaction to home chain
|
||||
const depositTx = await homeWeb3.eth.sendTransaction({
|
||||
from: user.address,
|
||||
to: HOME_BRIDGE_ADDRESS,
|
||||
gasPrice: '1',
|
||||
gas: '50000',
|
||||
value: '1000000000000000000'
|
||||
})
|
||||
|
||||
// Send a Tx to generate a new block
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
|
||||
// wait two seconds, no new blocks should have been generated
|
||||
await sleep(2000)
|
||||
const lastBlockNumber = await homeWeb3.eth.getBlockNumber()
|
||||
const balance = toBN(await token.methods.balanceOf(user.address).call())
|
||||
assert(lastBlockNumber === depositTx.blockNumber + 1, "Shouldn't have emitted a new block")
|
||||
assert(originalBalance.eq(balance), "Token balance shouldn't have changed")
|
||||
|
||||
// send funds back to validator
|
||||
const sendBalanceBackTx = await sendAllBalance(homeWeb3, temp.address, validator.address)
|
||||
|
||||
// expect Deposit event to be processed
|
||||
await promiseRetry(
|
||||
async retry => {
|
||||
const lastBlockNumber = await homeWeb3.eth.getBlockNumber()
|
||||
// check that a new block was created since the last transaction
|
||||
if (lastBlockNumber === sendBalanceBackTx.blockNumber + 1) {
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
} else {
|
||||
retry()
|
||||
}
|
||||
},
|
||||
{
|
||||
forever: true,
|
||||
factor: 1,
|
||||
minTimeout: 500
|
||||
}
|
||||
)
|
||||
|
||||
// check that token balance was incremented in foreign chain
|
||||
await promiseRetry(async retry => {
|
||||
const balance = toBN(await token.methods.balanceOf(user.address).call())
|
||||
if (!balance.gt(originalBalance)) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
it('should wait for funds if these are insufficient (Foreign)', async () => {
|
||||
// get original tokens balance
|
||||
const originalBalance = toBN(await token.methods.balanceOf(user.address).call())
|
||||
|
||||
// empty foreign validator funds
|
||||
await sendAllBalance(foreignWeb3, validator.address, temp.address)
|
||||
const foreignBlockNumber = await foreignWeb3.eth.getBlockNumber()
|
||||
|
||||
// send transaction to home chain
|
||||
await homeWeb3.eth.sendTransaction({
|
||||
from: user.address,
|
||||
to: HOME_BRIDGE_ADDRESS,
|
||||
gasPrice: '1',
|
||||
gas: '50000',
|
||||
value: '1000000000000000000'
|
||||
})
|
||||
|
||||
// Send a Tx to generate a new block
|
||||
const lastHomeTx = await generateNewBlock(homeWeb3, user.address)
|
||||
|
||||
// wait for the deposit to be processed
|
||||
await promiseRetry(
|
||||
async retry => {
|
||||
const lastBlockNumber = await homeWeb3.eth.getBlockNumber()
|
||||
if (lastBlockNumber === lastHomeTx.blockNumber + 1) {
|
||||
await generateNewBlock(homeWeb3, user.address)
|
||||
} else {
|
||||
retry()
|
||||
}
|
||||
},
|
||||
{
|
||||
forever: true,
|
||||
factor: 1,
|
||||
minTimeout: 500
|
||||
}
|
||||
)
|
||||
|
||||
// tokens shouldn't be generated in the foreign chain because the validator doesn't have funds
|
||||
await sleep(2000)
|
||||
const lastForeignBlockNumber = await foreignWeb3.eth.getBlockNumber()
|
||||
assert(lastForeignBlockNumber === foreignBlockNumber, "Shouldn't have emitted a new block")
|
||||
|
||||
// send funds back to validator
|
||||
await sendAllBalance(foreignWeb3, temp.address, validator.address)
|
||||
|
||||
// check that account has tokens in the foreign chain
|
||||
await promiseRetry(async retry => {
|
||||
const balance = toBN(await token.methods.balanceOf(user.address).call())
|
||||
if (balance.eq(originalBalance)) {
|
||||
retry()
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
async function sendAllBalance(web3, from, to) {
|
||||
const balance = await web3.eth.getBalance(from)
|
||||
const value = toBN(balance).sub(toBN('21000'))
|
||||
|
||||
return web3.eth.sendTransaction({
|
||||
from,
|
||||
to,
|
||||
value,
|
||||
gas: '21000',
|
||||
gasPrice: '1'
|
||||
})
|
||||
}
|
13
token-bridge/e2e/utils/utils.js
Normal file
13
token-bridge/e2e/utils/utils.js
Normal file
@ -0,0 +1,13 @@
|
||||
function generateNewBlock(web3, address) {
|
||||
return web3.eth.sendTransaction({
|
||||
from: address,
|
||||
to: '0x0000000000000000000000000000000000000000',
|
||||
gasPrice: '1',
|
||||
gas: '21000',
|
||||
value: '1'
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
generateNewBlock
|
||||
}
|
6854
token-bridge/package-lock.json
generated
Normal file
6854
token-bridge/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
60
token-bridge/package.json
Normal file
60
token-bridge/package.json
Normal file
@ -0,0 +1,60 @@
|
||||
{
|
||||
"name": "token-bridge",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"watcher:signature-request": "./scripts/start-worker.sh watcher signature-request-watcher",
|
||||
"watcher:collected-signatures": "./scripts/start-worker.sh watcher collected-signatures-watcher",
|
||||
"watcher:affirmation-request": "./scripts/start-worker.sh watcher affirmation-request-watcher",
|
||||
"sender:home": "./scripts/start-worker.sh sender home-sender",
|
||||
"sender:foreign": "./scripts/start-worker.sh sender foreign-sender",
|
||||
"dev": "concurrently -n 'watcher:signature-request,watcher:collected-signatures,watcher:affirmation-request,sender:home,sender:foreign' -c 'red,green,yellow,blue,magenta' 'npm run watcher:signature-request' 'npm run watcher:collected-signatures' 'npm run watcher:affirmation-request' 'npm run sender:home' 'npm run sender:foreign'",
|
||||
"test": "NODE_ENV=test mocha",
|
||||
"test:watch": "NODE_ENV=test mocha --watch --reporter=min",
|
||||
"coverage": "NODE_ENV=test nyc --reporter=text --reporter=html mocha",
|
||||
"postinstall": "npm install --prefix e2e && mkdir -p logs"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"amqp-connection-manager": "^2.0.0",
|
||||
"amqplib": "^0.5.2",
|
||||
"bignumber.js": "^7.2.1",
|
||||
"dotenv": "^5.0.1",
|
||||
"http-list-provider": "0.0.5",
|
||||
"ioredis": "^3.2.2",
|
||||
"lodash": "^4.17.10",
|
||||
"node-fetch": "^2.1.2",
|
||||
"pino": "^4.17.3",
|
||||
"pino-pretty": "^2.0.1",
|
||||
"promise-limit": "^2.7.0",
|
||||
"promise-retry": "^1.1.1",
|
||||
"redlock": "^3.1.2",
|
||||
"web3": "1.0.0-beta.34",
|
||||
"web3-utils": "1.0.0-beta.34"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bn-chai": "^1.0.1",
|
||||
"chai": "^4.1.2",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"concurrently": "^3.6.0",
|
||||
"eslint": "^4.19.1",
|
||||
"eslint-config-airbnb-base": "^12.1.0",
|
||||
"eslint-config-prettier": "^2.9.0",
|
||||
"eslint-plugin-import": "^2.12.0",
|
||||
"eslint-plugin-node": "^6.0.1",
|
||||
"eslint-plugin-prettier": "^2.6.0",
|
||||
"mocha": "^5.2.0",
|
||||
"ndjson": "^1.5.0",
|
||||
"nyc": "^12.0.2",
|
||||
"prettier": "^1.12.1",
|
||||
"proxyquire": "^2.0.1",
|
||||
"simple-statistics": "^6.1.0",
|
||||
"sinon": "^6.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.9"
|
||||
}
|
||||
}
|
1
token-bridge/reset-lastBlock.sh
Executable file
1
token-bridge/reset-lastBlock.sh
Executable file
@ -0,0 +1 @@
|
||||
node scripts/resetLastBlock.js $1 $2
|
7
token-bridge/scripts/.eslintrc
Normal file
7
token-bridge/scripts/.eslintrc
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "../.eslintrc",
|
||||
"rules": {
|
||||
"import/no-extraneous-dependencies": "off",
|
||||
"node/no-unpublished-require": "off"
|
||||
}
|
||||
}
|
76
token-bridge/scripts/compute-stats.js
Normal file
76
token-bridge/scripts/compute-stats.js
Normal file
@ -0,0 +1,76 @@
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const ndjson = require('ndjson')
|
||||
const { mean, median, min, max } = require('simple-statistics')
|
||||
|
||||
const readFile = (...paths) => {
|
||||
const a = []
|
||||
const filename = path.join(...paths)
|
||||
return new Promise(resolve => {
|
||||
fs.createReadStream(filename)
|
||||
.pipe(ndjson.parse())
|
||||
.on('data', obj => a.push(obj))
|
||||
.on('end', () => resolve(a))
|
||||
})
|
||||
}
|
||||
|
||||
function computeSignatureRequestStats(signatureRequests, senderHome) {
|
||||
const processingLogs = signatureRequests.filter(x => x.eventTransactionHash)
|
||||
const txSentMap = senderHome
|
||||
.filter(x => x.eventTransactionHash)
|
||||
.reduce((acc, x) => {
|
||||
acc[x.eventTransactionHash] = x
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
const times = processingLogs.map(x => txSentMap[x.eventTransactionHash].time - x.time)
|
||||
|
||||
return {
|
||||
count: times.length,
|
||||
mean: mean(times),
|
||||
median: median(times),
|
||||
min: min(times),
|
||||
max: max(times)
|
||||
}
|
||||
}
|
||||
|
||||
function computeCollectedSignaturesStats(collectedSignatures, senderForeign) {
|
||||
const processingLogs = collectedSignatures.filter(x => x.eventTransactionHash)
|
||||
const txSentMap = senderForeign
|
||||
.filter(x => x.eventTransactionHash)
|
||||
.reduce((acc, x) => {
|
||||
acc[x.eventTransactionHash] = x
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
const times = processingLogs.map(x => txSentMap[x.eventTransactionHash].time - x.time)
|
||||
|
||||
return {
|
||||
count: times.length,
|
||||
mean: mean(times),
|
||||
median: median(times),
|
||||
min: min(times),
|
||||
max: max(times)
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const signatureRequests = await readFile(__dirname, '../logs/signature-request-watcher.txt')
|
||||
const collectedSignatures = await readFile(__dirname, '../logs/collected-signatures-watcher.txt')
|
||||
// const affirmationRequests = await readFile(__dirname, '../logs/affirmation-request-watcher.txt')
|
||||
const senderHome = await readFile(__dirname, '../logs/home-sender.txt')
|
||||
const senderForeign = await readFile(__dirname, '../logs/foreign-sender.txt')
|
||||
|
||||
const signatureRequestsStats = computeSignatureRequestStats(signatureRequests, senderHome)
|
||||
console.log('Signature Requests')
|
||||
console.log(signatureRequestsStats)
|
||||
|
||||
const collectedSignaturesStats = computeCollectedSignaturesStats(
|
||||
collectedSignatures,
|
||||
senderForeign
|
||||
)
|
||||
console.log('Collected Signatures')
|
||||
console.log(collectedSignaturesStats)
|
||||
}
|
||||
|
||||
main().catch(console.error)
|
74
token-bridge/scripts/erc20_to_erc20/sendForeign.js
Normal file
74
token-bridge/scripts/erc20_to_erc20/sendForeign.js
Normal file
@ -0,0 +1,74 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../../.env')
|
||||
})
|
||||
const Web3 = require('web3')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
USER_ADDRESS_PRIVATE_KEY,
|
||||
FOREIGN_BRIDGE_ADDRESS,
|
||||
FOREIGN_MIN_AMOUNT_PER_TX,
|
||||
FOREIGN_TEST_TX_GAS_PRICE
|
||||
} = process.env
|
||||
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || process.env.NUMBER_OF_DEPOSITS_TO_SEND || 1
|
||||
|
||||
const ERC20_ABI = require('../../abis/ERC20.abi')
|
||||
const BRIDGE_ABI = require('../../abis/ForeignBridgeErcToErc.abi')
|
||||
|
||||
const foreignRpcUrl = rpcUrlsManager.foreignUrls[0]
|
||||
const foreignProvider = new Web3.providers.HttpProvider(foreignRpcUrl)
|
||||
const web3Foreign = new Web3(foreignProvider)
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Foreign.eth.Contract(BRIDGE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const ERC20_TOKEN_ADDRESS = await bridge.methods.erc20token().call()
|
||||
const poa20 = new web3Foreign.eth.Contract(ERC20_ABI, ERC20_TOKEN_ADDRESS)
|
||||
|
||||
try {
|
||||
const foreignChaindId = await sendRawTx({
|
||||
chain: 'foreign',
|
||||
params: [],
|
||||
method: 'net_version'
|
||||
})
|
||||
let nonce = await sendRawTx({
|
||||
chain: 'foreign',
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [USER_ADDRESS, 'latest']
|
||||
})
|
||||
nonce = Web3Utils.hexToNumber(nonce)
|
||||
let actualSent = 0
|
||||
for (let i = 0; i < Number(NUMBER_OF_DEPOSITS_TO_SEND); i++) {
|
||||
const gasLimit = await poa20.methods
|
||||
.transfer(FOREIGN_BRIDGE_ADDRESS, Web3Utils.toWei(FOREIGN_MIN_AMOUNT_PER_TX))
|
||||
.estimateGas({ from: USER_ADDRESS })
|
||||
const data = await poa20.methods
|
||||
.transfer(FOREIGN_BRIDGE_ADDRESS, Web3Utils.toWei(FOREIGN_MIN_AMOUNT_PER_TX))
|
||||
.encodeABI({ from: USER_ADDRESS })
|
||||
const txHash = await sendTx({
|
||||
chain: 'foreign',
|
||||
privateKey: USER_ADDRESS_PRIVATE_KEY,
|
||||
data,
|
||||
nonce,
|
||||
gasPrice: FOREIGN_TEST_TX_GAS_PRICE,
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
to: ERC20_TOKEN_ADDRESS,
|
||||
web3: web3Foreign,
|
||||
chainId: foreignChaindId
|
||||
})
|
||||
if (txHash !== undefined) {
|
||||
nonce++
|
||||
actualSent++
|
||||
console.log(actualSent, ' # ', txHash)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
main()
|
107
token-bridge/scripts/erc20_to_erc20/sendHome.js
Normal file
107
token-bridge/scripts/erc20_to_erc20/sendHome.js
Normal file
@ -0,0 +1,107 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../../.env')
|
||||
})
|
||||
const Web3 = require('web3')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
USER_ADDRESS_PRIVATE_KEY,
|
||||
HOME_BRIDGE_ADDRESS,
|
||||
HOME_MIN_AMOUNT_PER_TX,
|
||||
HOME_TEST_TX_GAS_PRICE
|
||||
} = process.env
|
||||
|
||||
const NUMBER_OF_WITHDRAWALS_TO_SEND =
|
||||
process.argv[2] || process.env.NUMBER_OF_WITHDRAWALS_TO_SEND || 1
|
||||
|
||||
const BRIDGEABLE_TOKEN_ABI = [
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '_to',
|
||||
type: 'address'
|
||||
},
|
||||
{
|
||||
name: '_value',
|
||||
type: 'uint256'
|
||||
},
|
||||
{
|
||||
name: '_data',
|
||||
type: 'bytes'
|
||||
}
|
||||
],
|
||||
name: 'transferAndCall',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'bool'
|
||||
}
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function'
|
||||
}
|
||||
]
|
||||
|
||||
const BRIDGE_ABI = require('../../abis/HomeBridgeErcToErc.abi')
|
||||
|
||||
const homeRpcUrl = rpcUrlsManager.homeUrls[0]
|
||||
const homeProvider = new Web3.providers.HttpProvider(homeRpcUrl)
|
||||
const web3Home = new Web3(homeProvider)
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Home.eth.Contract(BRIDGE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
const BRIDGEABLE_TOKEN_ADDRESS = await bridge.methods.erc677token().call()
|
||||
const erc677 = new web3Home.eth.Contract(BRIDGEABLE_TOKEN_ABI, BRIDGEABLE_TOKEN_ADDRESS)
|
||||
|
||||
try {
|
||||
await isValidAmount(HOME_MIN_AMOUNT_PER_TX, bridge)
|
||||
|
||||
const homeChainId = await sendRawTx({
|
||||
chain: 'home',
|
||||
params: [],
|
||||
method: 'net_version'
|
||||
})
|
||||
let nonce = await sendRawTx({
|
||||
chain: 'home',
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [USER_ADDRESS, 'latest']
|
||||
})
|
||||
nonce = Web3Utils.hexToNumber(nonce)
|
||||
let actualSent = 0
|
||||
for (let i = 0; i < Number(NUMBER_OF_WITHDRAWALS_TO_SEND); i++) {
|
||||
const gasLimit = await erc677.methods
|
||||
.transferAndCall(HOME_BRIDGE_ADDRESS, Web3Utils.toWei(HOME_MIN_AMOUNT_PER_TX), '0x')
|
||||
.estimateGas({ from: USER_ADDRESS })
|
||||
const data = await erc677.methods
|
||||
.transferAndCall(HOME_BRIDGE_ADDRESS, Web3Utils.toWei(HOME_MIN_AMOUNT_PER_TX), '0x')
|
||||
.encodeABI({ from: USER_ADDRESS })
|
||||
const txHash = await sendTx({
|
||||
chain: 'home',
|
||||
privateKey: USER_ADDRESS_PRIVATE_KEY,
|
||||
data,
|
||||
nonce,
|
||||
gasPrice: HOME_TEST_TX_GAS_PRICE,
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
to: BRIDGEABLE_TOKEN_ADDRESS,
|
||||
web3: web3Home,
|
||||
chainId: homeChainId
|
||||
})
|
||||
if (txHash !== undefined) {
|
||||
nonce++
|
||||
actualSent++
|
||||
console.log(actualSent, ' # ', txHash)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
main()
|
74
token-bridge/scripts/erc20_to_native/sendForeign.js
Normal file
74
token-bridge/scripts/erc20_to_native/sendForeign.js
Normal file
@ -0,0 +1,74 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../../.env')
|
||||
})
|
||||
const Web3 = require('web3')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const rpcUrlsManager = require('../../src/services/getRpcUrlsManager')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
USER_ADDRESS_PRIVATE_KEY,
|
||||
FOREIGN_BRIDGE_ADDRESS,
|
||||
FOREIGN_MIN_AMOUNT_PER_TX,
|
||||
FOREIGN_TEST_TX_GAS_PRICE
|
||||
} = process.env
|
||||
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || process.env.NUMBER_OF_DEPOSITS_TO_SEND || 1
|
||||
|
||||
const ERC20_ABI = require('../../abis/ERC20.abi')
|
||||
const BRIDGE_ABI = require('../../abis/ForeignBridgeErcToNative.abi')
|
||||
|
||||
const foreignRpcUrl = rpcUrlsManager.foreignUrls[0]
|
||||
const foreignProvider = new Web3.providers.HttpProvider(foreignRpcUrl)
|
||||
const web3Foreign = new Web3(foreignProvider)
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Foreign.eth.Contract(BRIDGE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const ERC20_TOKEN_ADDRESS = await bridge.methods.erc20token().call()
|
||||
const poa20 = new web3Foreign.eth.Contract(ERC20_ABI, ERC20_TOKEN_ADDRESS)
|
||||
|
||||
try {
|
||||
const foreignChaindId = await sendRawTx({
|
||||
chain: 'foreign',
|
||||
params: [],
|
||||
method: 'net_version'
|
||||
})
|
||||
let nonce = await sendRawTx({
|
||||
chain: 'foreign',
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [USER_ADDRESS, 'latest']
|
||||
})
|
||||
nonce = Web3Utils.hexToNumber(nonce)
|
||||
let actualSent = 0
|
||||
for (let i = 0; i < Number(NUMBER_OF_DEPOSITS_TO_SEND); i++) {
|
||||
const gasLimit = await poa20.methods
|
||||
.transfer(FOREIGN_BRIDGE_ADDRESS, Web3Utils.toWei(FOREIGN_MIN_AMOUNT_PER_TX))
|
||||
.estimateGas({ from: USER_ADDRESS })
|
||||
const data = await poa20.methods
|
||||
.transfer(FOREIGN_BRIDGE_ADDRESS, Web3Utils.toWei(FOREIGN_MIN_AMOUNT_PER_TX))
|
||||
.encodeABI({ from: USER_ADDRESS })
|
||||
const txHash = await sendTx({
|
||||
chain: 'foreign',
|
||||
privateKey: USER_ADDRESS_PRIVATE_KEY,
|
||||
data,
|
||||
nonce,
|
||||
gasPrice: FOREIGN_TEST_TX_GAS_PRICE,
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
to: ERC20_TOKEN_ADDRESS,
|
||||
web3: web3Foreign,
|
||||
chainId: foreignChaindId
|
||||
})
|
||||
if (txHash !== undefined) {
|
||||
nonce++
|
||||
actualSent++
|
||||
console.log(actualSent, ' # ', txHash)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
main()
|
62
token-bridge/scripts/erc20_to_native/sendHome.js
Normal file
62
token-bridge/scripts/erc20_to_native/sendHome.js
Normal file
@ -0,0 +1,62 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../../.env')
|
||||
})
|
||||
const Web3Utils = require('web3-utils')
|
||||
const { web3Home } = require('../../src/services/web3')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
const BRIDGE_ABI = require('../../abis/HomeBridgeErcToNative.abi')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
USER_ADDRESS_PRIVATE_KEY,
|
||||
HOME_BRIDGE_ADDRESS,
|
||||
HOME_MIN_AMOUNT_PER_TX,
|
||||
HOME_TEST_TX_GAS_PRICE
|
||||
} = process.env
|
||||
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || 1
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Home.eth.Contract(BRIDGE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
|
||||
try {
|
||||
await isValidAmount(HOME_MIN_AMOUNT_PER_TX, bridge)
|
||||
|
||||
const homeChaindId = await sendRawTx({
|
||||
chain: 'home',
|
||||
params: [],
|
||||
method: 'net_version'
|
||||
})
|
||||
let nonce = await sendRawTx({
|
||||
chain: 'home',
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [USER_ADDRESS, 'latest']
|
||||
})
|
||||
nonce = Web3Utils.hexToNumber(nonce)
|
||||
let actualSent = 0
|
||||
for (let i = 0; i < Number(NUMBER_OF_DEPOSITS_TO_SEND); i++) {
|
||||
const txHash = await sendTx({
|
||||
chain: 'home',
|
||||
privateKey: USER_ADDRESS_PRIVATE_KEY,
|
||||
data: '0x',
|
||||
nonce,
|
||||
gasPrice: HOME_TEST_TX_GAS_PRICE,
|
||||
amount: HOME_MIN_AMOUNT_PER_TX,
|
||||
gasLimit: 100000,
|
||||
to: HOME_BRIDGE_ADDRESS,
|
||||
web3: web3Home,
|
||||
chainId: homeChaindId
|
||||
})
|
||||
if (txHash !== undefined) {
|
||||
nonce++
|
||||
actualSent++
|
||||
console.log(actualSent, ' # ', txHash)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
main()
|
59
token-bridge/scripts/getValidatorStartBlocks.js
Normal file
59
token-bridge/scripts/getValidatorStartBlocks.js
Normal file
@ -0,0 +1,59 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../.env')
|
||||
})
|
||||
const Web3 = require('web3')
|
||||
const bridgeValidatorsABI = require('../abis/BridgeValidators.abi')
|
||||
|
||||
const rpcUrlsManager = require('../src/services/getRpcUrlsManager')
|
||||
|
||||
const { bridgeConfig } = require('../config/base.config')
|
||||
|
||||
const homeABI = bridgeConfig.homeBridgeAbi
|
||||
const foreignABI = bridgeConfig.foreignBridgeAbi
|
||||
|
||||
async function getStartBlock(rpcUrl, bridgeAddress, bridgeAbi) {
|
||||
try {
|
||||
const web3Provider = new Web3.providers.HttpProvider(rpcUrl)
|
||||
const web3Instance = new Web3(web3Provider)
|
||||
const bridgeContract = new web3Instance.eth.Contract(bridgeAbi, bridgeAddress)
|
||||
|
||||
const deployedAtBlock = await bridgeContract.methods.deployedAtBlock().call()
|
||||
|
||||
const validatorContractAddress = await bridgeContract.methods.validatorContract().call()
|
||||
const validatorContract = new web3Instance.eth.Contract(
|
||||
bridgeValidatorsABI,
|
||||
validatorContractAddress
|
||||
)
|
||||
|
||||
const validatorDeployedAtBlock = await validatorContract.methods.deployedAtBlock().call()
|
||||
|
||||
const validatorAddedEvents = await validatorContract.getPastEvents('ValidatorAdded', {
|
||||
fromBlock: validatorDeployedAtBlock,
|
||||
filter: { validator: process.env.VALIDATOR_ADDRESS }
|
||||
})
|
||||
|
||||
return validatorAddedEvents.length ? validatorAddedEvents[0].blockNumber : deployedAtBlock
|
||||
} catch (e) {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const { HOME_BRIDGE_ADDRESS, FOREIGN_BRIDGE_ADDRESS } = process.env
|
||||
|
||||
const homeRpcUrl = rpcUrlsManager.homeUrls[0]
|
||||
const foreignRpcUrl = rpcUrlsManager.foreignUrls[0]
|
||||
const homeStartBlock = await getStartBlock(homeRpcUrl, HOME_BRIDGE_ADDRESS, homeABI)
|
||||
const foreignStartBlock = await getStartBlock(foreignRpcUrl, FOREIGN_BRIDGE_ADDRESS, foreignABI)
|
||||
const result = {
|
||||
homeStartBlock,
|
||||
foreignStartBlock
|
||||
}
|
||||
console.log(JSON.stringify(result))
|
||||
return result
|
||||
}
|
||||
|
||||
main()
|
||||
|
||||
module.exports = main
|
33
token-bridge/scripts/initialChecks.js
Normal file
33
token-bridge/scripts/initialChecks.js
Normal file
@ -0,0 +1,33 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../.env')
|
||||
})
|
||||
const Web3 = require('web3')
|
||||
const ERC677BridgeTokenABI = require('../abis/ERC677BridgeToken.abi')
|
||||
const { ERC_TYPES } = require('../src/utils/constants')
|
||||
|
||||
async function initialChecks() {
|
||||
const { ERC20_TOKEN_ADDRESS, BRIDGE_MODE, FOREIGN_RPC_URL, FOREIGN_BRIDGE_ADDRESS } = process.env
|
||||
const result = {}
|
||||
|
||||
if (BRIDGE_MODE === 'ERC_TO_ERC') {
|
||||
const foreignWeb3 = new Web3(new Web3.providers.HttpProvider(FOREIGN_RPC_URL))
|
||||
const tokenContract = new foreignWeb3.eth.Contract(ERC677BridgeTokenABI, ERC20_TOKEN_ADDRESS)
|
||||
try {
|
||||
const bridgeContract = await tokenContract.methods.bridgeContract().call()
|
||||
if (bridgeContract === FOREIGN_BRIDGE_ADDRESS) {
|
||||
result.foreignERC = ERC_TYPES.ERC677
|
||||
} else {
|
||||
result.foreignERC = ERC_TYPES.ERC20
|
||||
}
|
||||
} catch (e) {
|
||||
result.foreignERC = ERC_TYPES.ERC20
|
||||
}
|
||||
}
|
||||
console.log(JSON.stringify(result))
|
||||
return result
|
||||
}
|
||||
|
||||
initialChecks()
|
||||
|
||||
module.exports = initialChecks
|
101
token-bridge/scripts/native_to_erc20/sendForeign.js
Normal file
101
token-bridge/scripts/native_to_erc20/sendForeign.js
Normal file
@ -0,0 +1,101 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../../.env')
|
||||
})
|
||||
const Web3Utils = require('web3-utils')
|
||||
const { web3Foreign } = require('../../src/services/web3')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
USER_ADDRESS_PRIVATE_KEY,
|
||||
FOREIGN_BRIDGE_ADDRESS,
|
||||
FOREIGN_MIN_AMOUNT_PER_TX,
|
||||
FOREIGN_TEST_TX_GAS_PRICE
|
||||
} = process.env
|
||||
|
||||
const NUMBER_OF_WITHDRAWALS_TO_SEND =
|
||||
process.argv[2] || process.env.NUMBER_OF_WITHDRAWALS_TO_SEND || 1
|
||||
|
||||
const ERC677_ABI = [
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'address'
|
||||
},
|
||||
{
|
||||
name: '',
|
||||
type: 'uint256'
|
||||
},
|
||||
{
|
||||
name: '',
|
||||
type: 'bytes'
|
||||
}
|
||||
],
|
||||
name: 'transferAndCall',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'bool'
|
||||
}
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function'
|
||||
}
|
||||
]
|
||||
const BRIDGE_ABI = require('../../abis/ForeignBridgeNativeToErc.abi')
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Foreign.eth.Contract(BRIDGE_ABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
const ERC20_TOKEN_ADDRESS = await bridge.methods.erc677token().call()
|
||||
const poa20 = new web3Foreign.eth.Contract(ERC677_ABI, ERC20_TOKEN_ADDRESS)
|
||||
|
||||
try {
|
||||
await isValidAmount(FOREIGN_MIN_AMOUNT_PER_TX, bridge)
|
||||
|
||||
const foreignChaindId = await sendRawTx({
|
||||
chain: 'foreign',
|
||||
params: [],
|
||||
method: 'net_version'
|
||||
})
|
||||
let nonce = await sendRawTx({
|
||||
chain: 'foreign',
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [USER_ADDRESS, 'latest']
|
||||
})
|
||||
nonce = Web3Utils.hexToNumber(nonce)
|
||||
let actualSent = 0
|
||||
for (let i = 0; i < Number(NUMBER_OF_WITHDRAWALS_TO_SEND); i++) {
|
||||
const gasLimit = await poa20.methods
|
||||
.transferAndCall(FOREIGN_BRIDGE_ADDRESS, Web3Utils.toWei(FOREIGN_MIN_AMOUNT_PER_TX), '0x')
|
||||
.estimateGas({ from: USER_ADDRESS })
|
||||
const data = await poa20.methods
|
||||
.transferAndCall(FOREIGN_BRIDGE_ADDRESS, Web3Utils.toWei(FOREIGN_MIN_AMOUNT_PER_TX), '0x')
|
||||
.encodeABI({ from: USER_ADDRESS })
|
||||
const txHash = await sendTx({
|
||||
chain: 'foreign',
|
||||
privateKey: USER_ADDRESS_PRIVATE_KEY,
|
||||
data,
|
||||
nonce,
|
||||
gasPrice: FOREIGN_TEST_TX_GAS_PRICE,
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
to: ERC20_TOKEN_ADDRESS,
|
||||
web3: web3Foreign,
|
||||
chainId: foreignChaindId
|
||||
})
|
||||
if (txHash !== undefined) {
|
||||
nonce++
|
||||
actualSent++
|
||||
console.log(actualSent, ' # ', txHash)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
main()
|
62
token-bridge/scripts/native_to_erc20/sendHome.js
Normal file
62
token-bridge/scripts/native_to_erc20/sendHome.js
Normal file
@ -0,0 +1,62 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../../.env')
|
||||
})
|
||||
const Web3Utils = require('web3-utils')
|
||||
const { web3Home } = require('../../src/services/web3')
|
||||
const { sendTx, sendRawTx } = require('../../src/tx/sendTx')
|
||||
const { isValidAmount } = require('../utils/utils')
|
||||
const BRIDGE_ABI = require('../../abis/HomeBridgeNativeToErc.abi')
|
||||
|
||||
const {
|
||||
USER_ADDRESS,
|
||||
USER_ADDRESS_PRIVATE_KEY,
|
||||
HOME_BRIDGE_ADDRESS,
|
||||
HOME_MIN_AMOUNT_PER_TX,
|
||||
HOME_TEST_TX_GAS_PRICE
|
||||
} = process.env
|
||||
|
||||
const NUMBER_OF_DEPOSITS_TO_SEND = process.argv[2] || 1
|
||||
|
||||
async function main() {
|
||||
const bridge = new web3Home.eth.Contract(BRIDGE_ABI, HOME_BRIDGE_ADDRESS)
|
||||
|
||||
try {
|
||||
await isValidAmount(HOME_MIN_AMOUNT_PER_TX, bridge)
|
||||
|
||||
const homeChaindId = await sendRawTx({
|
||||
chain: 'home',
|
||||
params: [],
|
||||
method: 'net_version'
|
||||
})
|
||||
let nonce = await sendRawTx({
|
||||
chain: 'home',
|
||||
method: 'eth_getTransactionCount',
|
||||
params: [USER_ADDRESS, 'latest']
|
||||
})
|
||||
nonce = Web3Utils.hexToNumber(nonce)
|
||||
let actualSent = 0
|
||||
for (let i = 0; i < Number(NUMBER_OF_DEPOSITS_TO_SEND); i++) {
|
||||
const txHash = await sendTx({
|
||||
chain: 'home',
|
||||
privateKey: USER_ADDRESS_PRIVATE_KEY,
|
||||
data: '0x',
|
||||
nonce,
|
||||
gasPrice: HOME_TEST_TX_GAS_PRICE,
|
||||
amount: HOME_MIN_AMOUNT_PER_TX,
|
||||
gasLimit: 100000,
|
||||
to: HOME_BRIDGE_ADDRESS,
|
||||
web3: web3Home,
|
||||
chainId: homeChaindId
|
||||
})
|
||||
if (txHash !== undefined) {
|
||||
nonce++
|
||||
actualSent++
|
||||
console.log(actualSent, ' # ', txHash)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
main()
|
17
token-bridge/scripts/privateKeyToAddress.js
Normal file
17
token-bridge/scripts/privateKeyToAddress.js
Normal file
@ -0,0 +1,17 @@
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '..', '.env')
|
||||
})
|
||||
const { privateKeyToAddress } = require('../src/utils/utils')
|
||||
const { EXIT_CODES } = require('../src/utils/constants')
|
||||
|
||||
const privateKey = process.env.VALIDATOR_ADDRESS_PRIVATE_KEY
|
||||
|
||||
if (!privateKey) {
|
||||
console.error('Environment variable VALIDATOR_ADDRESS_PRIVATE_KEY is not set')
|
||||
process.exit(EXIT_CODES.GENERAL_ERROR)
|
||||
}
|
||||
|
||||
const address = privateKeyToAddress(privateKey)
|
||||
|
||||
console.log(address)
|
66
token-bridge/scripts/resetLastBlock.js
Normal file
66
token-bridge/scripts/resetLastBlock.js
Normal file
@ -0,0 +1,66 @@
|
||||
const Redis = require('ioredis')
|
||||
const path = require('path')
|
||||
require('dotenv').config({
|
||||
path: path.join(__dirname, '../.env')
|
||||
})
|
||||
const { id } = require('../config/base.config')
|
||||
const { EXIT_CODES } = require('../src/utils/constants')
|
||||
|
||||
const redis = new Redis(process.env.REDIS_URL)
|
||||
|
||||
redis.on('error', () => {
|
||||
logError('Error: Cannot connect to redis')
|
||||
})
|
||||
|
||||
if (process.argv.length < 4) {
|
||||
logError(
|
||||
'Please provide process key and new block value. Example:' +
|
||||
'\n signature-request 12345 ' +
|
||||
'\n collected-signatures 12345 ' +
|
||||
'\n affirmation-request 12345'
|
||||
)
|
||||
}
|
||||
|
||||
function logError(message) {
|
||||
console.log(message)
|
||||
process.exit(EXIT_CODES.GENERAL_ERROR)
|
||||
}
|
||||
|
||||
function getRedisKey(name) {
|
||||
return `${id}-${name}:lastProcessedBlock`
|
||||
}
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
const processName = process.argv[2]
|
||||
const rawBlockValue = process.argv[3]
|
||||
|
||||
const newBlockValue = Number(rawBlockValue)
|
||||
if (!Number.isInteger(newBlockValue)) {
|
||||
logError('Expecting new block value to be an integer!')
|
||||
}
|
||||
|
||||
const lastBlockRedisKey = getRedisKey(processName)
|
||||
|
||||
const value = await redis.get(lastBlockRedisKey)
|
||||
|
||||
if (!value) {
|
||||
logError(
|
||||
'Error: Process key not found on redis. Please provide one of the following:' +
|
||||
'\n signature-request' +
|
||||
'\n collected-signatures' +
|
||||
'\n affirmation-request'
|
||||
)
|
||||
}
|
||||
|
||||
await redis.set(lastBlockRedisKey, newBlockValue)
|
||||
|
||||
console.log(`${processName} last block updated to ${newBlockValue}`)
|
||||
|
||||
redis.disconnect()
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
18
token-bridge/scripts/start-worker.sh
Executable file
18
token-bridge/scripts/start-worker.sh
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -o pipefail
|
||||
|
||||
WORKERS_DIR="src/"
|
||||
LOGS_DIR="logs/"
|
||||
|
||||
WORKER="${WORKERS_DIR}${1}.js"
|
||||
CONFIG="${2}.config.js"
|
||||
LOG="${LOGS_DIR}${2}.txt"
|
||||
|
||||
CHECKS=$(node scripts/initialChecks.js)
|
||||
|
||||
if [ "${NODE_ENV}" = "production" ]; then
|
||||
exec node "${WORKER}" "${CONFIG}" "$CHECKS"
|
||||
else
|
||||
node "${WORKER}" "${CONFIG}" "$CHECKS" | tee -a "${LOG}" | pino-pretty
|
||||
fi
|
18
token-bridge/scripts/utils/utils.js
Normal file
18
token-bridge/scripts/utils/utils.js
Normal file
@ -0,0 +1,18 @@
|
||||
const Web3Utils = require('web3-utils')
|
||||
|
||||
async function getMinPerTxLimit(bridge) {
|
||||
const minPerTx = await bridge.methods.minPerTx().call()
|
||||
return Web3Utils.fromWei(minPerTx)
|
||||
}
|
||||
|
||||
async function isValidAmount(amount, bridge) {
|
||||
const minLimit = await getMinPerTxLimit(bridge)
|
||||
if (amount < minLimit) {
|
||||
throw new Error(`The amount per Tx ${amount} should be at least ${minLimit}`)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getMinPerTxLimit,
|
||||
isValidAmount
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
AlreadySignedError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const logger = require('../../services/logger').child({
|
||||
module: 'processAffirmationRequests:estimateGas'
|
||||
})
|
||||
|
||||
async function estimateGas({
|
||||
web3,
|
||||
homeBridge,
|
||||
validatorContract,
|
||||
recipient,
|
||||
value,
|
||||
txHash,
|
||||
address
|
||||
}) {
|
||||
try {
|
||||
const gasEstimate = await homeBridge.methods
|
||||
.executeAffirmation(recipient, value, txHash)
|
||||
.estimateGas({
|
||||
from: address
|
||||
})
|
||||
|
||||
return gasEstimate
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw e
|
||||
}
|
||||
|
||||
const messageHash = web3.utils.soliditySha3(recipient, value, txHash)
|
||||
const senderHash = web3.utils.soliditySha3(address, messageHash)
|
||||
|
||||
// Check if minimum number of validations was already reached
|
||||
logger.debug('Check if minimum number of validations was already reached')
|
||||
const numAffirmationsSigned = await homeBridge.methods.numAffirmationsSigned(messageHash).call()
|
||||
const alreadyProcessed = await homeBridge.methods
|
||||
.isAlreadyProcessed(numAffirmationsSigned)
|
||||
.call()
|
||||
|
||||
if (alreadyProcessed) {
|
||||
throw new AlreadyProcessedError(e.message)
|
||||
}
|
||||
|
||||
// Check if the message was already signed by this validator
|
||||
logger.debug('Check if the message was already signed')
|
||||
const alreadySigned = await homeBridge.methods.affirmationsSigned(senderHash).call()
|
||||
|
||||
if (alreadySigned) {
|
||||
throw new AlreadySignedError(e.message)
|
||||
}
|
||||
|
||||
// Check if address is validator
|
||||
logger.debug('Check if address is a validator')
|
||||
const isValidator = await validatorContract.methods.isValidator(address).call()
|
||||
|
||||
if (!isValidator) {
|
||||
throw new InvalidValidatorError(`${address} is not a validator`)
|
||||
}
|
||||
|
||||
throw new Error('Unknown error while processing message')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = estimateGas
|
102
token-bridge/src/events/processAffirmationRequests/index.js
Normal file
102
token-bridge/src/events/processAffirmationRequests/index.js
Normal file
@ -0,0 +1,102 @@
|
||||
require('dotenv').config()
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home } = require('../../services/web3')
|
||||
const promiseLimit = require('promise-limit')
|
||||
const bridgeValidatorsABI = require('../../../abis/BridgeValidators.abi')
|
||||
const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
const estimateGas = require('./estimateGas')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
AlreadySignedError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
|
||||
const limit = promiseLimit(MAX_CONCURRENT_EVENTS)
|
||||
|
||||
let validatorContract = null
|
||||
|
||||
function processAffirmationRequestsBuilder(config) {
|
||||
const homeBridge = new web3Home.eth.Contract(config.homeBridgeAbi, config.homeBridgeAddress)
|
||||
|
||||
return async function processAffirmationRequests(affirmationRequests) {
|
||||
const txToSend = []
|
||||
|
||||
if (validatorContract === null) {
|
||||
rootLogger.debug('Getting validator contract address')
|
||||
const validatorContractAddress = await homeBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Home.eth.Contract(bridgeValidatorsABI, validatorContractAddress)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${affirmationRequests.length} AffirmationRequest events`)
|
||||
const callbacks = affirmationRequests.map(affirmationRequest =>
|
||||
limit(async () => {
|
||||
const { recipient, value } = affirmationRequest.returnValues
|
||||
|
||||
const logger = rootLogger.child({
|
||||
eventTransactionHash: affirmationRequest.transactionHash
|
||||
})
|
||||
|
||||
logger.info(
|
||||
{ sender: recipient, value },
|
||||
`Processing affirmationRequest ${affirmationRequest.transactionHash}`
|
||||
)
|
||||
|
||||
let gasEstimate
|
||||
try {
|
||||
logger.debug('Estimate gas')
|
||||
gasEstimate = await estimateGas({
|
||||
web3: web3Home,
|
||||
homeBridge,
|
||||
validatorContract,
|
||||
recipient,
|
||||
value,
|
||||
txHash: affirmationRequest.transactionHash,
|
||||
address: config.validatorAddress
|
||||
})
|
||||
logger.debug({ gasEstimate }, 'Gas estimated')
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw new Error(
|
||||
'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.'
|
||||
)
|
||||
} else if (e instanceof InvalidValidatorError) {
|
||||
logger.fatal({ address: config.validatorAddress }, 'Invalid validator')
|
||||
process.exit(EXIT_CODES.INCOMPATIBILITY)
|
||||
} else if (e instanceof AlreadySignedError) {
|
||||
logger.info(`Already signed affirmationRequest ${affirmationRequest.transactionHash}`)
|
||||
return
|
||||
} else if (e instanceof AlreadyProcessedError) {
|
||||
logger.info(
|
||||
`affirmationRequest ${
|
||||
affirmationRequest.transactionHash
|
||||
} was already processed by other validators`
|
||||
)
|
||||
return
|
||||
} else {
|
||||
logger.error(e, 'Unknown error while processing transaction')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
const data = await homeBridge.methods
|
||||
.executeAffirmation(recipient, value, affirmationRequest.transactionHash)
|
||||
.encodeABI({ from: config.validatorAddress })
|
||||
|
||||
txToSend.push({
|
||||
data,
|
||||
gasEstimate,
|
||||
transactionReference: affirmationRequest.transactionHash,
|
||||
to: config.homeBridgeAddress
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all(callbacks)
|
||||
return txToSend
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = processAffirmationRequestsBuilder
|
@ -0,0 +1,65 @@
|
||||
const Web3 = require('web3')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
IncompatibleContractError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const { parseMessage } = require('../../utils/message')
|
||||
const logger = require('../../services/logger').child({
|
||||
module: 'processCollectedSignatures:estimateGas'
|
||||
})
|
||||
|
||||
const web3 = new Web3()
|
||||
const { toBN } = Web3.utils
|
||||
|
||||
async function estimateGas({
|
||||
foreignBridge,
|
||||
validatorContract,
|
||||
message,
|
||||
numberOfCollectedSignatures,
|
||||
v,
|
||||
r,
|
||||
s
|
||||
}) {
|
||||
try {
|
||||
const gasEstimate = await foreignBridge.methods
|
||||
.executeSignatures(v, r, s, message)
|
||||
.estimateGas()
|
||||
return gasEstimate
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw e
|
||||
}
|
||||
|
||||
// check if the message was already processed
|
||||
logger.debug('Check if the message was already processed')
|
||||
const { txHash } = parseMessage(message)
|
||||
const alreadyProcessed = await foreignBridge.methods.relayedMessages(txHash).call()
|
||||
if (alreadyProcessed) {
|
||||
throw new AlreadyProcessedError()
|
||||
}
|
||||
|
||||
// check if the number of signatures is enough
|
||||
logger.debug('Check if number of signatures is enough')
|
||||
const requiredSignatures = await validatorContract.methods.requiredSignatures().call()
|
||||
if (toBN(requiredSignatures).gt(toBN(numberOfCollectedSignatures))) {
|
||||
throw new IncompatibleContractError('The number of collected signatures does not match')
|
||||
}
|
||||
|
||||
// check if all the signatures were made by validators
|
||||
for (let i = 0; i < v.length; i++) {
|
||||
const address = web3.eth.accounts.recover(message, web3.utils.toHex(v[i]), r[i], s[i])
|
||||
logger.debug({ address }, 'Check that signature is from a validator')
|
||||
const isValidator = await validatorContract.methods.isValidator(address).call()
|
||||
|
||||
if (!isValidator) {
|
||||
throw new InvalidValidatorError(`Message signed by ${address} that is not a validator`)
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Unknown error while processing message')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = estimateGas
|
133
token-bridge/src/events/processCollectedSignatures/index.js
Normal file
133
token-bridge/src/events/processCollectedSignatures/index.js
Normal file
@ -0,0 +1,133 @@
|
||||
require('dotenv').config()
|
||||
const promiseLimit = require('promise-limit')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const bridgeValidatorsABI = require('../../../abis/BridgeValidators.abi')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home, web3Foreign } = require('../../services/web3')
|
||||
const { signatureToVRS } = require('../../utils/message')
|
||||
const estimateGas = require('./estimateGas')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
IncompatibleContractError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const { MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
|
||||
const limit = promiseLimit(MAX_CONCURRENT_EVENTS)
|
||||
|
||||
let validatorContract = null
|
||||
|
||||
function processCollectedSignaturesBuilder(config) {
|
||||
const homeBridge = new web3Home.eth.Contract(config.homeBridgeAbi, config.homeBridgeAddress)
|
||||
|
||||
const foreignBridge = new web3Foreign.eth.Contract(
|
||||
config.foreignBridgeAbi,
|
||||
config.foreignBridgeAddress
|
||||
)
|
||||
|
||||
return async function processCollectedSignatures(signatures) {
|
||||
const txToSend = []
|
||||
|
||||
if (validatorContract === null) {
|
||||
rootLogger.debug('Getting validator contract address')
|
||||
const validatorContractAddress = await foreignBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Foreign.eth.Contract(
|
||||
bridgeValidatorsABI,
|
||||
validatorContractAddress
|
||||
)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${signatures.length} CollectedSignatures events`)
|
||||
const callbacks = signatures.map(colSignature =>
|
||||
limit(async () => {
|
||||
const {
|
||||
authorityResponsibleForRelay,
|
||||
messageHash,
|
||||
NumberOfCollectedSignatures
|
||||
} = colSignature.returnValues
|
||||
|
||||
const logger = rootLogger.child({
|
||||
eventTransactionHash: colSignature.transactionHash
|
||||
})
|
||||
|
||||
if (
|
||||
authorityResponsibleForRelay === web3Home.utils.toChecksumAddress(config.validatorAddress)
|
||||
) {
|
||||
logger.info(`Processing CollectedSignatures ${colSignature.transactionHash}`)
|
||||
const message = await homeBridge.methods.message(messageHash).call()
|
||||
|
||||
const requiredSignatures = []
|
||||
requiredSignatures.length = NumberOfCollectedSignatures
|
||||
requiredSignatures.fill(0)
|
||||
|
||||
const [v, r, s] = [[], [], []]
|
||||
logger.debug('Getting message signatures')
|
||||
const signaturePromises = requiredSignatures.map(async (el, index) => {
|
||||
logger.debug({ index }, 'Getting message signature')
|
||||
const signature = await homeBridge.methods.signature(messageHash, index).call()
|
||||
const recover = signatureToVRS(signature)
|
||||
v.push(recover.v)
|
||||
r.push(recover.r)
|
||||
s.push(recover.s)
|
||||
})
|
||||
|
||||
await Promise.all(signaturePromises)
|
||||
|
||||
let gasEstimate
|
||||
try {
|
||||
logger.debug('Estimate gas')
|
||||
gasEstimate = await estimateGas({
|
||||
foreignBridge,
|
||||
validatorContract,
|
||||
v,
|
||||
r,
|
||||
s,
|
||||
message,
|
||||
numberOfCollectedSignatures: NumberOfCollectedSignatures
|
||||
})
|
||||
logger.debug({ gasEstimate }, 'Gas estimated')
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw new Error(
|
||||
'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.'
|
||||
)
|
||||
} else if (e instanceof AlreadyProcessedError) {
|
||||
logger.info(`Already processed CollectedSignatures ${colSignature.transactionHash}`)
|
||||
return
|
||||
} else if (
|
||||
e instanceof IncompatibleContractError ||
|
||||
e instanceof InvalidValidatorError
|
||||
) {
|
||||
logger.error(`The message couldn't be processed; skipping: ${e.message}`)
|
||||
return
|
||||
} else {
|
||||
logger.error(e, 'Unknown error while processing transaction')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
const data = await foreignBridge.methods.executeSignatures(v, r, s, message).encodeABI()
|
||||
txToSend.push({
|
||||
data,
|
||||
gasEstimate,
|
||||
transactionReference: colSignature.transactionHash,
|
||||
to: config.foreignBridgeAddress
|
||||
})
|
||||
} else {
|
||||
logger.info(
|
||||
`Validator not responsible for relaying CollectedSignatures ${
|
||||
colSignature.transactionHash
|
||||
}`
|
||||
)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all(callbacks)
|
||||
|
||||
return txToSend
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = processCollectedSignaturesBuilder
|
@ -0,0 +1,54 @@
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
AlreadySignedError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const logger = require('../../services/logger').child({
|
||||
module: 'processSignatureRequests:estimateGas'
|
||||
})
|
||||
|
||||
async function estimateGas({ web3, homeBridge, validatorContract, signature, message, address }) {
|
||||
try {
|
||||
const gasEstimate = await homeBridge.methods.submitSignature(signature, message).estimateGas({
|
||||
from: address
|
||||
})
|
||||
return gasEstimate
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw e
|
||||
}
|
||||
|
||||
// Check if minimum number of validations was already reached
|
||||
logger.debug('Check if minimum number of validations was reached')
|
||||
const messageHash = web3.utils.soliditySha3(message)
|
||||
const numMessagesSigned = await homeBridge.methods.numMessagesSigned(messageHash).call()
|
||||
const alreadyProcessed = await homeBridge.methods.isAlreadyProcessed(numMessagesSigned).call()
|
||||
|
||||
if (alreadyProcessed) {
|
||||
throw new AlreadyProcessedError(e.message)
|
||||
}
|
||||
|
||||
// Check if transaction was already signed by this validator
|
||||
logger.debug('Check if transaction was already signed')
|
||||
const validatorMessageHash = web3.utils.soliditySha3(address, web3.utils.soliditySha3(message))
|
||||
const alreadySigned = await homeBridge.methods.messagesSigned(validatorMessageHash).call()
|
||||
|
||||
if (alreadySigned) {
|
||||
throw new AlreadySignedError(e.message)
|
||||
}
|
||||
|
||||
// Check if address is validator
|
||||
logger.debug('Check if address is validator')
|
||||
const isValidator = await validatorContract.methods.isValidator(address).call()
|
||||
|
||||
if (!isValidator) {
|
||||
throw new InvalidValidatorError(`${address} is not a validator`)
|
||||
}
|
||||
|
||||
logger.error('Unrecognized error')
|
||||
throw new Error('Unknown error while processing message')
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = estimateGas
|
119
token-bridge/src/events/processSignatureRequests/index.js
Normal file
119
token-bridge/src/events/processSignatureRequests/index.js
Normal file
@ -0,0 +1,119 @@
|
||||
require('dotenv').config()
|
||||
const promiseLimit = require('promise-limit')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const bridgeValidatorsABI = require('../../../abis/BridgeValidators.abi')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home } = require('../../services/web3')
|
||||
const { createMessage } = require('../../utils/message')
|
||||
const estimateGas = require('./estimateGas')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
AlreadySignedError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
|
||||
const { VALIDATOR_ADDRESS_PRIVATE_KEY } = process.env
|
||||
|
||||
const limit = promiseLimit(MAX_CONCURRENT_EVENTS)
|
||||
|
||||
let expectedMessageLength = null
|
||||
let validatorContract = null
|
||||
|
||||
function processSignatureRequestsBuilder(config) {
|
||||
const homeBridge = new web3Home.eth.Contract(config.homeBridgeAbi, config.homeBridgeAddress)
|
||||
|
||||
return async function processSignatureRequests(signatureRequests) {
|
||||
const txToSend = []
|
||||
|
||||
if (expectedMessageLength === null) {
|
||||
expectedMessageLength = await homeBridge.methods.requiredMessageLength().call()
|
||||
}
|
||||
|
||||
if (validatorContract === null) {
|
||||
rootLogger.debug('Getting validator contract address')
|
||||
const validatorContractAddress = await homeBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Home.eth.Contract(bridgeValidatorsABI, validatorContractAddress)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${signatureRequests.length} SignatureRequest events`)
|
||||
const callbacks = signatureRequests.map(signatureRequest =>
|
||||
limit(async () => {
|
||||
const { recipient, value } = signatureRequest.returnValues
|
||||
|
||||
const logger = rootLogger.child({
|
||||
eventTransactionHash: signatureRequest.transactionHash
|
||||
})
|
||||
|
||||
logger.info(
|
||||
{ sender: recipient, value },
|
||||
`Processing signatureRequest ${signatureRequest.transactionHash}`
|
||||
)
|
||||
|
||||
const message = createMessage({
|
||||
recipient,
|
||||
value,
|
||||
transactionHash: signatureRequest.transactionHash,
|
||||
bridgeAddress: config.foreignBridgeAddress,
|
||||
expectedMessageLength
|
||||
})
|
||||
|
||||
const signature = web3Home.eth.accounts.sign(message, `0x${VALIDATOR_ADDRESS_PRIVATE_KEY}`)
|
||||
|
||||
let gasEstimate
|
||||
try {
|
||||
logger.debug('Estimate gas')
|
||||
gasEstimate = await estimateGas({
|
||||
web3: web3Home,
|
||||
homeBridge,
|
||||
validatorContract,
|
||||
signature: signature.signature,
|
||||
message,
|
||||
address: config.validatorAddress
|
||||
})
|
||||
logger.debug({ gasEstimate }, 'Gas estimated')
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw new Error(
|
||||
'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.'
|
||||
)
|
||||
} else if (e instanceof InvalidValidatorError) {
|
||||
logger.fatal({ address: config.validatorAddress }, 'Invalid validator')
|
||||
process.exit(EXIT_CODES.INCOMPATIBILITY)
|
||||
} else if (e instanceof AlreadySignedError) {
|
||||
logger.info(`Already signed signatureRequest ${signatureRequest.transactionHash}`)
|
||||
return
|
||||
} else if (e instanceof AlreadyProcessedError) {
|
||||
logger.info(
|
||||
`signatureRequest ${
|
||||
signatureRequest.transactionHash
|
||||
} was already processed by other validators`
|
||||
)
|
||||
return
|
||||
} else {
|
||||
logger.error(e, 'Unknown error while processing transaction')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
const data = await homeBridge.methods
|
||||
.submitSignature(signature.signature, message)
|
||||
.encodeABI({ from: config.validatorAddress })
|
||||
|
||||
txToSend.push({
|
||||
data,
|
||||
gasEstimate,
|
||||
transactionReference: signatureRequest.transactionHash,
|
||||
to: config.homeBridgeAddress
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all(callbacks)
|
||||
return txToSend
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = processSignatureRequestsBuilder
|
97
token-bridge/src/events/processTransfers/index.js
Normal file
97
token-bridge/src/events/processTransfers/index.js
Normal file
@ -0,0 +1,97 @@
|
||||
require('dotenv').config()
|
||||
const promiseLimit = require('promise-limit')
|
||||
const { HttpListProviderError } = require('http-list-provider')
|
||||
const bridgeValidatorsABI = require('../../../abis/BridgeValidators.abi')
|
||||
const rootLogger = require('../../services/logger')
|
||||
const { web3Home } = require('../../services/web3')
|
||||
const {
|
||||
AlreadyProcessedError,
|
||||
AlreadySignedError,
|
||||
InvalidValidatorError
|
||||
} = require('../../utils/errors')
|
||||
const { EXIT_CODES, MAX_CONCURRENT_EVENTS } = require('../../utils/constants')
|
||||
const estimateGas = require('../processAffirmationRequests/estimateGas')
|
||||
|
||||
const limit = promiseLimit(MAX_CONCURRENT_EVENTS)
|
||||
|
||||
let validatorContract = null
|
||||
|
||||
function processTransfersBuilder(config) {
|
||||
const homeBridge = new web3Home.eth.Contract(config.homeBridgeAbi, config.homeBridgeAddress)
|
||||
|
||||
return async function processTransfers(transfers) {
|
||||
const txToSend = []
|
||||
|
||||
if (validatorContract === null) {
|
||||
rootLogger.debug('Getting validator contract address')
|
||||
const validatorContractAddress = await homeBridge.methods.validatorContract().call()
|
||||
rootLogger.debug({ validatorContractAddress }, 'Validator contract address obtained')
|
||||
|
||||
validatorContract = new web3Home.eth.Contract(bridgeValidatorsABI, validatorContractAddress)
|
||||
}
|
||||
|
||||
rootLogger.debug(`Processing ${transfers.length} Transfer events`)
|
||||
const callbacks = transfers.map(transfer =>
|
||||
limit(async () => {
|
||||
const { from, value } = transfer.returnValues
|
||||
|
||||
const logger = rootLogger.child({
|
||||
eventTransactionHash: transfer.transactionHash
|
||||
})
|
||||
|
||||
logger.info({ from, value }, `Processing transfer ${transfer.transactionHash}`)
|
||||
|
||||
let gasEstimate
|
||||
try {
|
||||
logger.debug('Estimate gas')
|
||||
gasEstimate = await estimateGas({
|
||||
web3: web3Home,
|
||||
homeBridge,
|
||||
validatorContract,
|
||||
recipient: from,
|
||||
value,
|
||||
txHash: transfer.transactionHash,
|
||||
address: config.validatorAddress
|
||||
})
|
||||
logger.debug({ gasEstimate }, 'Gas estimated')
|
||||
} catch (e) {
|
||||
if (e instanceof HttpListProviderError) {
|
||||
throw new Error(
|
||||
'RPC Connection Error: submitSignature Gas Estimate cannot be obtained.'
|
||||
)
|
||||
} else if (e instanceof InvalidValidatorError) {
|
||||
logger.fatal({ address: config.validatorAddress }, 'Invalid validator')
|
||||
process.exit(EXIT_CODES.INCOMPATIBILITY)
|
||||
} else if (e instanceof AlreadySignedError) {
|
||||
logger.info(`Already signed transfer ${transfer.transactionHash}`)
|
||||
return
|
||||
} else if (e instanceof AlreadyProcessedError) {
|
||||
logger.info(
|
||||
`transfer ${transfer.transactionHash} was already processed by other validators`
|
||||
)
|
||||
return
|
||||
} else {
|
||||
logger.error(e, 'Unknown error while processing transaction')
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
const data = await homeBridge.methods
|
||||
.executeAffirmation(from, value, transfer.transactionHash)
|
||||
.encodeABI({ from: config.validatorAddress })
|
||||
|
||||
txToSend.push({
|
||||
data,
|
||||
gasEstimate,
|
||||
transactionReference: transfer.transactionHash,
|
||||
to: config.homeBridgeAddress
|
||||
})
|
||||
})
|
||||
)
|
||||
|
||||
await Promise.all(callbacks)
|
||||
return txToSend
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = processTransfersBuilder
|
192
token-bridge/src/sender.js
Normal file
192
token-bridge/src/sender.js
Normal file
@ -0,0 +1,192 @@
|
||||
require('dotenv').config()
|
||||
const path = require('path')
|
||||
const { connectSenderToQueue } = require('./services/amqpClient')
|
||||
const { redis, redlock } = require('./services/redisClient')
|
||||
const GasPrice = require('./services/gasPrice')
|
||||
const logger = require('./services/logger')
|
||||
const rpcUrlsManager = require('./services/getRpcUrlsManager')
|
||||
const { sendTx } = require('./tx/sendTx')
|
||||
const { getNonce, getChainId } = require('./tx/web3')
|
||||
const {
|
||||
addExtraGas,
|
||||
checkHTTPS,
|
||||
privateKeyToAddress,
|
||||
syncForEach,
|
||||
waitForFunds,
|
||||
watchdog
|
||||
} = require('./utils/utils')
|
||||
const { EXIT_CODES, EXTRA_GAS_PERCENTAGE } = require('./utils/constants')
|
||||
|
||||
const { VALIDATOR_ADDRESS_PRIVATE_KEY, REDIS_LOCK_TTL } = process.env
|
||||
|
||||
const VALIDATOR_ADDRESS = privateKeyToAddress(VALIDATOR_ADDRESS_PRIVATE_KEY)
|
||||
|
||||
if (process.argv.length < 3) {
|
||||
logger.error('Please check the number of arguments, config file was not provided')
|
||||
process.exit(EXIT_CODES.GENERAL_ERROR)
|
||||
}
|
||||
|
||||
const config = require(path.join('../config/', process.argv[2]))
|
||||
|
||||
const web3Instance = config.web3
|
||||
const nonceLock = `lock:${config.id}:nonce`
|
||||
const nonceKey = `${config.id}:nonce`
|
||||
let chainId = 0
|
||||
|
||||
async function initialize() {
|
||||
try {
|
||||
const checkHttps = checkHTTPS(process.env.ALLOW_HTTP, logger)
|
||||
|
||||
rpcUrlsManager.homeUrls.forEach(checkHttps('home'))
|
||||
rpcUrlsManager.foreignUrls.forEach(checkHttps('foreign'))
|
||||
|
||||
GasPrice.start(config.id)
|
||||
|
||||
chainId = await getChainId(config.id)
|
||||
connectSenderToQueue({
|
||||
queueName: config.queue,
|
||||
cb: options => {
|
||||
if (config.maxProcessingTime) {
|
||||
return watchdog(() => main(options), config.maxProcessingTime, () => {
|
||||
logger.fatal('Max processing time reached')
|
||||
process.exit(EXIT_CODES.MAX_TIME_REACHED)
|
||||
})
|
||||
}
|
||||
|
||||
return main(options)
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
logger.error(e.message)
|
||||
process.exit(EXIT_CODES.GENERAL_ERROR)
|
||||
}
|
||||
}
|
||||
|
||||
function resume(newBalance) {
|
||||
logger.info(
|
||||
`Validator balance changed. New balance is ${newBalance}. Resume messages processing.`
|
||||
)
|
||||
initialize()
|
||||
}
|
||||
|
||||
async function readNonce(forceUpdate) {
|
||||
logger.debug('Reading nonce')
|
||||
if (forceUpdate) {
|
||||
logger.debug('Forcing update of nonce')
|
||||
return getNonce(web3Instance, VALIDATOR_ADDRESS)
|
||||
}
|
||||
|
||||
const nonce = await redis.get(nonceKey)
|
||||
if (nonce) {
|
||||
logger.debug({ nonce }, 'Nonce found in the DB')
|
||||
return Number(nonce)
|
||||
} else {
|
||||
logger.debug("Nonce wasn't found in the DB")
|
||||
return getNonce(web3Instance, VALIDATOR_ADDRESS)
|
||||
}
|
||||
}
|
||||
|
||||
function updateNonce(nonce) {
|
||||
return redis.set(nonceKey, nonce)
|
||||
}
|
||||
|
||||
async function main({ msg, ackMsg, nackMsg, sendToQueue, channel }) {
|
||||
try {
|
||||
if (redis.status !== 'ready') {
|
||||
nackMsg(msg)
|
||||
return
|
||||
}
|
||||
|
||||
const txArray = JSON.parse(msg.content)
|
||||
logger.info(`Msg received with ${txArray.length} Tx to send`)
|
||||
const gasPrice = GasPrice.getPrice()
|
||||
|
||||
const ttl = REDIS_LOCK_TTL * txArray.length
|
||||
|
||||
logger.debug('Acquiring lock')
|
||||
const lock = await redlock.lock(nonceLock, ttl)
|
||||
|
||||
let nonce = await readNonce()
|
||||
let insufficientFunds = false
|
||||
let minimumBalance = null
|
||||
const failedTx = []
|
||||
|
||||
logger.debug(`Sending ${txArray.length} transactions`)
|
||||
await syncForEach(txArray, async job => {
|
||||
const gasLimit = addExtraGas(job.gasEstimate, EXTRA_GAS_PERCENTAGE)
|
||||
|
||||
try {
|
||||
logger.info(`Sending transaction with nonce ${nonce}`)
|
||||
const txHash = await sendTx({
|
||||
chain: config.id,
|
||||
data: job.data,
|
||||
nonce,
|
||||
gasPrice: gasPrice.toString(10),
|
||||
amount: '0',
|
||||
gasLimit,
|
||||
privateKey: VALIDATOR_ADDRESS_PRIVATE_KEY,
|
||||
to: job.to,
|
||||
chainId,
|
||||
web3: web3Instance
|
||||
})
|
||||
|
||||
nonce++
|
||||
logger.info(
|
||||
{ eventTransactionHash: job.transactionReference, generatedTransactionHash: txHash },
|
||||
`Tx generated ${txHash} for event Tx ${job.transactionReference}`
|
||||
)
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
{ eventTransactionHash: job.transactionReference, error: e.message },
|
||||
`Tx Failed for event Tx ${job.transactionReference}.`,
|
||||
e.message
|
||||
)
|
||||
if (!e.message.includes('Transaction with the same hash was already imported')) {
|
||||
failedTx.push(job)
|
||||
}
|
||||
|
||||
if (e.message.includes('Insufficient funds')) {
|
||||
insufficientFunds = true
|
||||
const currentBalance = await web3Instance.eth.getBalance(VALIDATOR_ADDRESS)
|
||||
minimumBalance = gasLimit.multipliedBy(gasPrice)
|
||||
logger.error(
|
||||
`Insufficient funds: ${currentBalance}. Stop processing messages until the balance is at least ${minimumBalance}.`
|
||||
)
|
||||
} else if (
|
||||
e.message.includes('Transaction nonce is too low') ||
|
||||
e.message.includes('transaction with same nonce in the queue')
|
||||
) {
|
||||
nonce = await readNonce(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
logger.debug('Updating nonce')
|
||||
await updateNonce(nonce)
|
||||
|
||||
logger.debug('Releasing lock')
|
||||
await lock.unlock()
|
||||
|
||||
if (failedTx.length) {
|
||||
logger.info(`Sending ${failedTx.length} Failed Tx to Queue`)
|
||||
await sendToQueue(failedTx)
|
||||
}
|
||||
ackMsg(msg)
|
||||
logger.debug(`Finished processing msg`)
|
||||
|
||||
if (insufficientFunds) {
|
||||
logger.warn(
|
||||
'Insufficient funds. Stop sending transactions until the account has the minimum balance'
|
||||
)
|
||||
channel.close()
|
||||
waitForFunds(web3Instance, VALIDATOR_ADDRESS, minimumBalance, resume, logger)
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
nackMsg(msg)
|
||||
}
|
||||
|
||||
logger.debug('Finished')
|
||||
}
|
||||
|
||||
initialize()
|
47
token-bridge/src/services/RpcUrlsManager.js
Normal file
47
token-bridge/src/services/RpcUrlsManager.js
Normal file
@ -0,0 +1,47 @@
|
||||
const _ = require('lodash')
|
||||
const promiseRetry = require('promise-retry')
|
||||
const tryEach = require('../utils/tryEach')
|
||||
const { RETRY_CONFIG } = require('../utils/constants')
|
||||
|
||||
function RpcUrlsManager(homeUrls, foreignUrls) {
|
||||
if (!homeUrls) {
|
||||
throw new Error(`Invalid homeUrls: '${homeUrls}'`)
|
||||
}
|
||||
if (!foreignUrls) {
|
||||
throw new Error(`Invalid foreignUrls: '${foreignUrls}'`)
|
||||
}
|
||||
|
||||
this.homeUrls = homeUrls.split(',')
|
||||
this.foreignUrls = foreignUrls.split(',')
|
||||
}
|
||||
|
||||
RpcUrlsManager.prototype.tryEach = async function(chain, f) {
|
||||
if (chain !== 'home' && chain !== 'foreign') {
|
||||
throw new Error(`Invalid argument chain: '${chain}'`)
|
||||
}
|
||||
|
||||
// save homeUrls to avoid race condition
|
||||
const urls = chain === 'home' ? _.cloneDeep(this.homeUrls) : _.cloneDeep(this.foreignUrls)
|
||||
|
||||
const [result, index] = await promiseRetry(retry =>
|
||||
tryEach(urls, f).catch(() => {
|
||||
retry()
|
||||
}, RETRY_CONFIG)
|
||||
)
|
||||
|
||||
if (index > 0) {
|
||||
// rotate urls
|
||||
const failed = urls.splice(0, index)
|
||||
urls.push(...failed)
|
||||
}
|
||||
|
||||
if (chain === 'home') {
|
||||
this.homeUrls = urls
|
||||
} else {
|
||||
this.foreignUrls = urls
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = RpcUrlsManager
|
52
token-bridge/src/services/amqpClient.js
Normal file
52
token-bridge/src/services/amqpClient.js
Normal file
@ -0,0 +1,52 @@
|
||||
require('dotenv').config()
|
||||
const connection = require('amqp-connection-manager').connect(process.env.QUEUE_URL)
|
||||
const logger = require('./logger')
|
||||
|
||||
connection.on('connect', () => {
|
||||
logger.info('Connected to amqp Broker')
|
||||
})
|
||||
|
||||
connection.on('disconnect', () => {
|
||||
logger.error('Disconnected from amqp Broker')
|
||||
})
|
||||
|
||||
function connectWatcherToQueue({ queueName, cb }) {
|
||||
const channelWrapper = connection.createChannel({
|
||||
json: true,
|
||||
setup(channel) {
|
||||
return Promise.all([channel.assertQueue(queueName, { durable: true })])
|
||||
}
|
||||
})
|
||||
|
||||
const sendToQueue = data => channelWrapper.sendToQueue(queueName, data, { persistent: true })
|
||||
|
||||
cb({ sendToQueue, channel: channelWrapper })
|
||||
}
|
||||
|
||||
function connectSenderToQueue({ queueName, cb }) {
|
||||
const channelWrapper = connection.createChannel({
|
||||
json: true
|
||||
})
|
||||
|
||||
channelWrapper.addSetup(channel => {
|
||||
return Promise.all([
|
||||
channel.assertQueue(queueName, { durable: true }),
|
||||
channel.prefetch(1),
|
||||
channel.consume(queueName, msg =>
|
||||
cb({
|
||||
msg,
|
||||
channel: channelWrapper,
|
||||
ackMsg: job => channelWrapper.ack(job),
|
||||
nackMsg: job => channelWrapper.nack(job, false, true),
|
||||
sendToQueue: data => channelWrapper.sendToQueue(queueName, data, { persistent: true })
|
||||
})
|
||||
)
|
||||
])
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
connectWatcherToQueue,
|
||||
connectSenderToQueue,
|
||||
connection
|
||||
}
|
118
token-bridge/src/services/gasPrice.js
Normal file
118
token-bridge/src/services/gasPrice.js
Normal file
@ -0,0 +1,118 @@
|
||||
require('dotenv').config()
|
||||
const fetch = require('node-fetch')
|
||||
const Web3Utils = require('web3-utils')
|
||||
const { web3Home, web3Foreign } = require('../services/web3')
|
||||
const { bridgeConfig } = require('../../config/base.config')
|
||||
const logger = require('../services/logger').child({
|
||||
module: 'gasPrice'
|
||||
})
|
||||
const { setIntervalAndRun } = require('../utils/utils')
|
||||
const { DEFAULT_UPDATE_INTERVAL, GAS_PRICE_BOUNDARIES } = require('../utils/constants')
|
||||
|
||||
const HomeABI = bridgeConfig.homeBridgeAbi
|
||||
const ForeignABI = bridgeConfig.foreignBridgeAbi
|
||||
|
||||
const {
|
||||
FOREIGN_BRIDGE_ADDRESS,
|
||||
FOREIGN_GAS_PRICE_FALLBACK,
|
||||
FOREIGN_GAS_PRICE_ORACLE_URL,
|
||||
FOREIGN_GAS_PRICE_SPEED_TYPE,
|
||||
FOREIGN_GAS_PRICE_UPDATE_INTERVAL,
|
||||
HOME_BRIDGE_ADDRESS,
|
||||
HOME_GAS_PRICE_FALLBACK,
|
||||
HOME_GAS_PRICE_ORACLE_URL,
|
||||
HOME_GAS_PRICE_SPEED_TYPE,
|
||||
HOME_GAS_PRICE_UPDATE_INTERVAL
|
||||
} = process.env
|
||||
|
||||
const homeBridge = new web3Home.eth.Contract(HomeABI, HOME_BRIDGE_ADDRESS)
|
||||
|
||||
const foreignBridge = new web3Foreign.eth.Contract(ForeignABI, FOREIGN_BRIDGE_ADDRESS)
|
||||
|
||||
let cachedGasPrice = null
|
||||
|
||||
function gasPriceWithinLimits(gasPrice) {
|
||||
if (gasPrice < GAS_PRICE_BOUNDARIES.MIN) {
|
||||
return GAS_PRICE_BOUNDARIES.MIN
|
||||
} else if (gasPrice > GAS_PRICE_BOUNDARIES.MAX) {
|
||||
return GAS_PRICE_BOUNDARIES.MAX
|
||||
} else {
|
||||
return gasPrice
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchGasPriceFromOracle(oracleUrl, speedType) {
|
||||
const response = await fetch(oracleUrl)
|
||||
const json = await response.json()
|
||||
const oracleGasPrice = json[speedType]
|
||||
if (!oracleGasPrice) {
|
||||
throw new Error(`Response from Oracle didn't include gas price for ${speedType} type.`)
|
||||
}
|
||||
const gasPrice = gasPriceWithinLimits(oracleGasPrice)
|
||||
return Web3Utils.toWei(gasPrice.toString(), 'gwei')
|
||||
}
|
||||
|
||||
async function fetchGasPrice({ bridgeContract, oracleFn }) {
|
||||
let gasPrice = null
|
||||
try {
|
||||
gasPrice = await oracleFn()
|
||||
logger.debug({ gasPrice }, 'Gas price updated using the oracle')
|
||||
} catch (e) {
|
||||
logger.error(`Gas Price API is not available. ${e.message}`)
|
||||
|
||||
try {
|
||||
gasPrice = await bridgeContract.methods.gasPrice().call()
|
||||
logger.debug({ gasPrice }, 'Gas price updated using the contracts')
|
||||
} catch (e) {
|
||||
logger.error(`There was a problem getting the gas price from the contract. ${e.message}`)
|
||||
}
|
||||
}
|
||||
return gasPrice
|
||||
}
|
||||
|
||||
let fetchGasPriceInterval = null
|
||||
|
||||
async function start(chainId) {
|
||||
clearInterval(fetchGasPriceInterval)
|
||||
|
||||
let bridgeContract = null
|
||||
let oracleUrl = null
|
||||
let speedType = null
|
||||
let updateInterval = null
|
||||
if (chainId === 'home') {
|
||||
bridgeContract = homeBridge
|
||||
oracleUrl = HOME_GAS_PRICE_ORACLE_URL
|
||||
speedType = HOME_GAS_PRICE_SPEED_TYPE
|
||||
updateInterval = HOME_GAS_PRICE_UPDATE_INTERVAL || DEFAULT_UPDATE_INTERVAL
|
||||
|
||||
cachedGasPrice = HOME_GAS_PRICE_FALLBACK
|
||||
} else if (chainId === 'foreign') {
|
||||
bridgeContract = foreignBridge
|
||||
oracleUrl = FOREIGN_GAS_PRICE_ORACLE_URL
|
||||
speedType = FOREIGN_GAS_PRICE_SPEED_TYPE
|
||||
updateInterval = FOREIGN_GAS_PRICE_UPDATE_INTERVAL || DEFAULT_UPDATE_INTERVAL
|
||||
|
||||
cachedGasPrice = FOREIGN_GAS_PRICE_FALLBACK
|
||||
} else {
|
||||
throw new Error(`Unrecognized chainId '${chainId}'`)
|
||||
}
|
||||
|
||||
fetchGasPriceInterval = setIntervalAndRun(async () => {
|
||||
const gasPrice = await fetchGasPrice({
|
||||
bridgeContract,
|
||||
oracleFn: () => fetchGasPriceFromOracle(oracleUrl, speedType)
|
||||
})
|
||||
cachedGasPrice = gasPrice || cachedGasPrice
|
||||
}, updateInterval)
|
||||
}
|
||||
|
||||
function getPrice() {
|
||||
return cachedGasPrice
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
start,
|
||||
fetchGasPrice,
|
||||
getPrice,
|
||||
gasPriceWithinLimits
|
||||
}
|
3
token-bridge/src/services/getRpcUrlsManager.js
Normal file
3
token-bridge/src/services/getRpcUrlsManager.js
Normal file
@ -0,0 +1,3 @@
|
||||
const RpcUrlsManager = require('./RpcUrlsManager')
|
||||
|
||||
module.exports = new RpcUrlsManager(process.env.HOME_RPC_URL, process.env.FOREIGN_RPC_URL)
|
19
token-bridge/src/services/logger.js
Normal file
19
token-bridge/src/services/logger.js
Normal file
@ -0,0 +1,19 @@
|
||||
const pino = require('pino')
|
||||
const path = require('path')
|
||||
|
||||
const config =
|
||||
process.env.NODE_ENV !== 'test' ? require(path.join('../../config/', process.argv[2])) : {}
|
||||
|
||||
const logger = pino({
|
||||
enabled: process.env.NODE_ENV !== 'test',
|
||||
name: config.name,
|
||||
level: process.env.LOG_LEVEL || 'debug',
|
||||
base:
|
||||
process.env.NODE_ENV === 'production'
|
||||
? {
|
||||
validator: process.env.VALIDATOR_ADDRESS
|
||||
}
|
||||
: {}
|
||||
})
|
||||
|
||||
module.exports = logger
|
24
token-bridge/src/services/redisClient.js
Normal file
24
token-bridge/src/services/redisClient.js
Normal file
@ -0,0 +1,24 @@
|
||||
const Redis = require('ioredis')
|
||||
const Redlock = require('redlock')
|
||||
const logger = require('./logger')
|
||||
|
||||
const redis = new Redis(process.env.REDIS_URL)
|
||||
const redlock = new Redlock([redis], {
|
||||
driftFactor: 0.01,
|
||||
retryCount: 200,
|
||||
retryDelay: 500,
|
||||
retryJitter: 500
|
||||
})
|
||||
|
||||
redis.on('connect', () => {
|
||||
logger.info('Connected to redis')
|
||||
})
|
||||
|
||||
redis.on('error', () => {
|
||||
logger.error('Disconnected from redis')
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
redis,
|
||||
redlock
|
||||
}
|
19
token-bridge/src/services/web3.js
Normal file
19
token-bridge/src/services/web3.js
Normal file
@ -0,0 +1,19 @@
|
||||
const HttpListProvider = require('http-list-provider')
|
||||
const Web3 = require('web3')
|
||||
const rpcUrlsManager = require('./getRpcUrlsManager')
|
||||
const { RETRY_CONFIG } = require('../utils/constants')
|
||||
|
||||
const homeProvider = new HttpListProvider(rpcUrlsManager.homeUrls, {
|
||||
retry: RETRY_CONFIG
|
||||
})
|
||||
const web3Home = new Web3(homeProvider)
|
||||
|
||||
const foreignProvider = new HttpListProvider(rpcUrlsManager.foreignUrls, {
|
||||
retry: RETRY_CONFIG
|
||||
})
|
||||
const web3Foreign = new Web3(foreignProvider)
|
||||
|
||||
module.exports = {
|
||||
web3Home,
|
||||
web3Foreign
|
||||
}
|
72
token-bridge/src/tx/sendTx.js
Normal file
72
token-bridge/src/tx/sendTx.js
Normal file
@ -0,0 +1,72 @@
|
||||
const Web3Utils = require('web3-utils')
|
||||
const fetch = require('node-fetch')
|
||||
const rpcUrlsManager = require('../services/getRpcUrlsManager')
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
async function sendTx({
|
||||
chain,
|
||||
privateKey,
|
||||
data,
|
||||
nonce,
|
||||
gasPrice,
|
||||
amount,
|
||||
gasLimit,
|
||||
to,
|
||||
chainId,
|
||||
web3
|
||||
}) {
|
||||
const serializedTx = await web3.eth.accounts.signTransaction(
|
||||
{
|
||||
nonce: Number(nonce),
|
||||
chainId,
|
||||
to,
|
||||
data,
|
||||
value: Web3Utils.toWei(amount),
|
||||
gasPrice,
|
||||
gas: gasLimit
|
||||
},
|
||||
`0x${privateKey}`
|
||||
)
|
||||
|
||||
return sendRawTx({
|
||||
chain,
|
||||
method: 'eth_sendRawTransaction',
|
||||
params: [serializedTx.rawTransaction]
|
||||
})
|
||||
}
|
||||
|
||||
// eslint-disable-next-line consistent-return
|
||||
async function sendRawTx({ chain, params, method }) {
|
||||
const result = await rpcUrlsManager.tryEach(chain, async url => {
|
||||
// curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":[{see above}],"id":1}'
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
'Content-type': 'application/json'
|
||||
},
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
jsonrpc: '2.0',
|
||||
method,
|
||||
params,
|
||||
id: Math.floor(Math.random() * 100) + 1
|
||||
})
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText)
|
||||
}
|
||||
|
||||
return response
|
||||
})
|
||||
|
||||
const json = await result.json()
|
||||
if (json.error) {
|
||||
throw json.error
|
||||
}
|
||||
return json.result
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
sendTx,
|
||||
sendRawTx
|
||||
}
|
81
token-bridge/src/tx/web3.js
Normal file
81
token-bridge/src/tx/web3.js
Normal file
@ -0,0 +1,81 @@
|
||||
const logger = require('../services/logger').child({
|
||||
module: 'web3'
|
||||
})
|
||||
const { sendRawTx } = require('./sendTx')
|
||||
const { hexToNumber } = require('web3-utils')
|
||||
|
||||
async function getNonce(web3, address) {
|
||||
try {
|
||||
logger.debug({ address }, 'Getting transaction count')
|
||||
const transactionCount = await web3.eth.getTransactionCount(address)
|
||||
logger.debug({ address, transactionCount }, 'Transaction count obtained')
|
||||
return transactionCount
|
||||
} catch (e) {
|
||||
throw new Error(`Nonce cannot be obtained`)
|
||||
}
|
||||
}
|
||||
|
||||
async function getBlockNumber(web3) {
|
||||
try {
|
||||
logger.debug('Getting block number')
|
||||
const blockNumber = await web3.eth.getBlockNumber()
|
||||
logger.debug({ blockNumber }, 'Block number obtained')
|
||||
return blockNumber
|
||||
} catch (e) {
|
||||
throw new Error(`Block Number cannot be obtained`)
|
||||
}
|
||||
}
|
||||
|
||||
async function getChainId(chain) {
|
||||
try {
|
||||
logger.debug('Getting chain id')
|
||||
const chainIdHex = await sendRawTx({
|
||||
chain,
|
||||
method: 'eth_chainId',
|
||||
params: []
|
||||
})
|
||||
const chainId = hexToNumber(chainIdHex)
|
||||
logger.debug({ chainId }, 'Chain id obtained')
|
||||
return chainId
|
||||
} catch (e) {
|
||||
throw new Error(`Chain Id cannot be obtained`)
|
||||
}
|
||||
}
|
||||
|
||||
async function getRequiredBlockConfirmations(contract) {
|
||||
try {
|
||||
const contractAddress = contract.options.address
|
||||
logger.debug({ contractAddress }, 'Getting required block confirmations')
|
||||
const requiredBlockConfirmations = await contract.methods.requiredBlockConfirmations().call()
|
||||
logger.debug(
|
||||
{ contractAddress, requiredBlockConfirmations },
|
||||
'Required block confirmations obtained'
|
||||
)
|
||||
return requiredBlockConfirmations
|
||||
} catch (e) {
|
||||
throw new Error(`Required block confirmations cannot be obtained`)
|
||||
}
|
||||
}
|
||||
|
||||
async function getEvents({ contract, event, fromBlock, toBlock, filter }) {
|
||||
try {
|
||||
const contractAddress = contract.options.address
|
||||
logger.info(
|
||||
{ contractAddress, event, fromBlock: fromBlock.toString(), toBlock: toBlock.toString() },
|
||||
'Getting past events'
|
||||
)
|
||||
const pastEvents = await contract.getPastEvents(event, { fromBlock, toBlock, filter })
|
||||
logger.debug({ contractAddress, event, count: pastEvents.length }, 'Past events obtained')
|
||||
return pastEvents
|
||||
} catch (e) {
|
||||
throw new Error(`${event} events cannot be obtained`)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getNonce,
|
||||
getBlockNumber,
|
||||
getChainId,
|
||||
getRequiredBlockConfirmations,
|
||||
getEvents
|
||||
}
|
24
token-bridge/src/utils/constants.js
Normal file
24
token-bridge/src/utils/constants.js
Normal file
@ -0,0 +1,24 @@
|
||||
module.exports = {
|
||||
EXTRA_GAS_PERCENTAGE: 1,
|
||||
MAX_CONCURRENT_EVENTS: 50,
|
||||
RETRY_CONFIG: {
|
||||
retries: 20,
|
||||
factor: 1.4,
|
||||
maxTimeout: 360000,
|
||||
randomize: true
|
||||
},
|
||||
DEFAULT_UPDATE_INTERVAL: 600000,
|
||||
EXIT_CODES: {
|
||||
GENERAL_ERROR: 1,
|
||||
INCOMPATIBILITY: 10,
|
||||
MAX_TIME_REACHED: 11
|
||||
},
|
||||
GAS_PRICE_BOUNDARIES: {
|
||||
MIN: 1,
|
||||
MAX: 250
|
||||
},
|
||||
ERC_TYPES: {
|
||||
ERC20: 'ERC20',
|
||||
ERC677: 'ERC677'
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user