Compare commits
62 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9da1d7ab0a | ||
|
|
78bcd7568b | ||
|
|
429312500a | ||
|
|
59e0bf7565 | ||
|
|
ab51370d5a | ||
|
|
9dfb0510c4 | ||
|
|
f65e8f9244 | ||
|
|
5c8b595382 | ||
|
|
71bf9d5583 | ||
|
|
329ded4beb | ||
|
|
dc70247e2c | ||
|
|
f95beee5dc | ||
|
|
ae83c76be9 | ||
|
|
dc3026e584 | ||
|
|
b6ba0744b9 | ||
|
|
4dba9a50e8 | ||
|
|
818bc4675d | ||
|
|
f93ab330cc | ||
|
|
f64f8b1c91 | ||
|
|
9fd3f6ab82 | ||
|
|
626f9376b2 | ||
|
|
894134ba26 | ||
|
|
e1536755f4 | ||
|
|
0451d6e373 | ||
|
|
409044b8a5 | ||
|
|
5fc52f42d7 | ||
|
|
8a0d9f38b0 | ||
|
|
1aee0a84ef | ||
|
|
811b1a27f1 | ||
|
|
4d468ae107 | ||
|
|
4497a024b1 | ||
|
|
6ce98ff3dd | ||
|
|
04f66b243c | ||
|
|
21581b3c01 | ||
|
|
bbc68f9fa2 | ||
|
|
5327688a20 | ||
|
|
1122daf9a1 | ||
|
|
12269d7426 | ||
|
|
683fa0728d | ||
|
|
dd2075c351 | ||
|
|
ce29b95729 | ||
|
|
eb1069497a | ||
|
|
0228fc7d5f | ||
|
|
f8d85b14de | ||
|
|
5fa9d21246 | ||
|
|
611b8c539d | ||
|
|
389cea3c39 | ||
|
|
fbce0fc035 | ||
|
|
621b20d070 | ||
|
|
48752e8575 | ||
|
|
4efda98f2b | ||
|
|
aff8b777c5 | ||
|
|
74293959f3 | ||
|
|
46daeb6815 | ||
|
|
44ca0d71ce | ||
|
|
fbeb878cdb | ||
|
|
d17ea2ad2b | ||
|
|
4cc87ef61a | ||
|
|
125b66b86d | ||
|
|
7a0ed3f699 | ||
|
|
4e04f2ae1f | ||
|
|
dc377aeb9b |
@@ -8,11 +8,16 @@
|
|||||||
**/docs
|
**/docs
|
||||||
**/*.md
|
**/*.md
|
||||||
|
|
||||||
|
monitor/**/*.env*
|
||||||
|
oracle/**/*.env*
|
||||||
|
!**/.env.example
|
||||||
|
|
||||||
contracts/test
|
contracts/test
|
||||||
contracts/build
|
contracts/build
|
||||||
oracle/test
|
oracle/test
|
||||||
monitor/test
|
monitor/test
|
||||||
monitor/responses
|
monitor/responses
|
||||||
|
monitor/cache/*
|
||||||
commons/test
|
commons/test
|
||||||
oracle/**/*.png
|
oracle/**/*.png
|
||||||
oracle/**/*.jpg
|
oracle/**/*.jpg
|
||||||
|
|||||||
143
.github/workflows/main.yml
vendored
143
.github/workflows/main.yml
vendored
@@ -19,9 +19,11 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- run: git submodule status > submodule.status
|
- name: Set cache key
|
||||||
- id: get_cache_key
|
id: get_cache_key
|
||||||
run: echo "::set-output name=cache_key::cache-repo-${{ hashFiles('yarn.lock', 'package.json', 'submodule.status') }}"
|
run: |
|
||||||
|
git submodule status > submodule.status
|
||||||
|
echo "::set-output name=cache_key::cache-repo-${{ hashFiles('yarn.lock', 'package.json', 'submodule.status') }}"
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
id: cache-repo
|
id: cache-repo
|
||||||
with:
|
with:
|
||||||
@@ -29,7 +31,8 @@ jobs:
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
contracts/build
|
contracts/build
|
||||||
key: ${{ steps.get_cache_key.outputs.cache_key }}
|
key: ${{ steps.get_cache_key.outputs.cache_key }}
|
||||||
- if: ${{ !steps.cache-repo.outputs.cache-hit }}
|
- name: Install dependencies and compile contracts
|
||||||
|
if: ${{ !steps.cache-repo.outputs.cache-hit }}
|
||||||
run: |
|
run: |
|
||||||
yarn install --frozen-lockfile
|
yarn install --frozen-lockfile
|
||||||
yarn run install:deploy
|
yarn run install:deploy
|
||||||
@@ -56,45 +59,23 @@ jobs:
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
contracts/build
|
contracts/build
|
||||||
key: ${{ needs.initialize.outputs.cache_key }}
|
key: ${{ needs.initialize.outputs.cache_key }}
|
||||||
- run: ${{ steps.cache-repo.outputs.cache-hit }} && yarn run ${{ matrix.task }}
|
- name: yarn run ${{ matrix.task }}
|
||||||
ui-coverage:
|
run: ${{ steps.cache-repo.outputs.cache-hit }} && yarn run ${{ matrix.task }}
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs:
|
|
||||||
- initialize
|
|
||||||
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags')
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-node@v1
|
|
||||||
with:
|
|
||||||
node-version: 10
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
submodules: true
|
|
||||||
- uses: actions/cache@v2
|
|
||||||
id: cache-repo
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
contracts/build
|
|
||||||
key: ${{ needs.initialize.outputs.cache_key }}
|
|
||||||
- run: ${{ steps.cache-repo.outputs.cache-hit }} && yarn workspace ui run coverage
|
|
||||||
- uses: coverallsapp/github-action@master
|
|
||||||
with:
|
|
||||||
github-token: ${{ github.token }}
|
|
||||||
path-to-lcov: ./ui/coverage/lcov.info
|
|
||||||
build-e2e-images:
|
build-e2e-images:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- run: |
|
- name: Evaluate e2e docker images tags
|
||||||
|
run: |
|
||||||
git submodule status > submodule.status
|
git submodule status > submodule.status
|
||||||
echo "::set-env name=E2E_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}"
|
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=ORACLE_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}"
|
echo "ORACLE_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=MONITOR_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}"
|
echo "MONITOR_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=UI_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'ui') }}"
|
echo "ALM_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=ALM_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}"
|
- name: Rebuild and push updated images
|
||||||
- run: |
|
run: |
|
||||||
function check_if_image_exists() {
|
function check_if_image_exists() {
|
||||||
curl -fsSlL -H 'Authorization: bearer ${{ github.token }}' "https://${DOCKER_REGISTRY}/v2/${DOCKER_REPO}/tokenbridge-e2e-$1/manifests/$2" > /dev/null
|
curl -fsSlL -H 'Authorization: bearer ${{ github.token }}' "https://${DOCKER_REGISTRY}/v2/${DOCKER_REPO}/tokenbridge-e2e-$1/manifests/$2" > /dev/null
|
||||||
}
|
}
|
||||||
@@ -102,7 +83,6 @@ jobs:
|
|||||||
if ! check_if_image_exists e2e ${E2E_TAG}; then updated+=("e2e"); fi
|
if ! check_if_image_exists e2e ${E2E_TAG}; then updated+=("e2e"); fi
|
||||||
if ! check_if_image_exists oracle ${ORACLE_TAG}; then updated+=("oracle"); fi
|
if ! check_if_image_exists oracle ${ORACLE_TAG}; then updated+=("oracle"); fi
|
||||||
if ! check_if_image_exists monitor ${MONITOR_TAG}; then updated+=("monitor"); fi
|
if ! check_if_image_exists monitor ${MONITOR_TAG}; then updated+=("monitor"); fi
|
||||||
if ! check_if_image_exists ui ${UI_TAG}; then updated+=("ui"); fi
|
|
||||||
if ! check_if_image_exists alm ${ALM_TAG}; then updated+=("alm"); fi
|
if ! check_if_image_exists alm ${ALM_TAG}; then updated+=("alm"); fi
|
||||||
if [ ${#updated[@]} -gt 0 ]; then
|
if [ ${#updated[@]} -gt 0 ]; then
|
||||||
echo "Updated services: ${updated[@]}"
|
echo "Updated services: ${updated[@]}"
|
||||||
@@ -119,8 +99,10 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- run: echo "::set-env name=MOLECULE_RUNNER_TAG::${{ hashFiles('./deployment-e2e/Dockerfile') }}"
|
- name: Evaluate e2e molecule runner tag
|
||||||
- run: |
|
run: echo "MOLECULE_RUNNER_TAG=${{ hashFiles('./deployment-e2e/Dockerfile') }}" >> $GITHUB_ENV
|
||||||
|
- name: Rebuild and push molecule runner e2e image
|
||||||
|
run: |
|
||||||
function check_if_image_exists() {
|
function check_if_image_exists() {
|
||||||
curl -fsSlL -H 'Authorization: bearer ${{ github.token }}' "https://${DOCKER_REGISTRY}/v2/${DOCKER_REPO}/tokenbridge-e2e-$1/manifests/$2" > /dev/null
|
curl -fsSlL -H 'Authorization: bearer ${{ github.token }}' "https://${DOCKER_REGISTRY}/v2/${DOCKER_REPO}/tokenbridge-e2e-$1/manifests/$2" > /dev/null
|
||||||
}
|
}
|
||||||
@@ -140,24 +122,22 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
task: [oracle-e2e, monitor-e2e, alm-e2e, 'ui-e2e:ci']
|
task: [oracle-e2e, monitor-e2e, alm-e2e]
|
||||||
include:
|
include:
|
||||||
- task: alm-e2e
|
- task: alm-e2e
|
||||||
use-cache: true
|
use-cache: true
|
||||||
- task: 'ui-e2e:ci'
|
|
||||||
use-cache: true
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- run: |
|
- name: Evaluate e2e docker images tags
|
||||||
|
run: |
|
||||||
git submodule status > submodule.status
|
git submodule status > submodule.status
|
||||||
echo "::set-env name=E2E_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}"
|
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=ORACLE_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}"
|
echo "ORACLE_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=MONITOR_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}"
|
echo "MONITOR_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=UI_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'ui') }}"
|
echo "ALM_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=ALM_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}"
|
- if: ${{ matrix.use-cache }}
|
||||||
- if: ${{ matrix.use-cache }}
|
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
id: cache-repo
|
id: cache-repo
|
||||||
with:
|
with:
|
||||||
@@ -165,54 +145,50 @@ jobs:
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
contracts/build
|
contracts/build
|
||||||
key: ${{ needs.initialize.outputs.cache_key }}
|
key: ${{ needs.initialize.outputs.cache_key }}
|
||||||
- run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
- name: Login to docker registry
|
||||||
- run: ${{ !matrix.use-cache || steps.cache-repo.outputs.cache-hit }} && yarn run ${{ matrix.task }}
|
run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
||||||
|
- name: yarn run ${{ matrix.task }}
|
||||||
|
run: ${{ !matrix.use-cache || steps.cache-repo.outputs.cache-hit }} && yarn run ${{ matrix.task }}
|
||||||
deployment:
|
deployment:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
|
- build-e2e-images
|
||||||
- build-molecule-runner
|
- build-molecule-runner
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
task: [oracle, ui, monitor, multiple, repo]
|
task: [oracle, monitor, multiple, repo]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- run: echo "::set-env name=MOLECULE_RUNNER_TAG::${{ hashFiles('./deployment-e2e/Dockerfile') }}"
|
- name: Evaluate e2e molecule runner tag
|
||||||
- run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
run: echo "MOLECULE_RUNNER_TAG=${{ hashFiles('./deployment-e2e/Dockerfile') }}" >> $GITHUB_ENV
|
||||||
|
- name: Login to docker registry
|
||||||
|
run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
||||||
- run: deployment-e2e/molecule.sh ${{ matrix.task }}
|
- run: deployment-e2e/molecule.sh ${{ matrix.task }}
|
||||||
ultimate:
|
ultimate:
|
||||||
|
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags') || contains(github.event.head_commit.message, 'ultimate')
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs:
|
needs:
|
||||||
- initialize
|
- initialize
|
||||||
- build-e2e-images
|
- build-e2e-images
|
||||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags')
|
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
task: [amb, erc-to-erc, erc-to-native, native-to-erc, amb-stake-erc-to-erc]
|
task: [amb, erc-to-erc, erc-to-native, native-to-erc]
|
||||||
include:
|
|
||||||
- task: erc-to-erc
|
|
||||||
ui-e2e-grep: 'ERC TO ERC'
|
|
||||||
- task: erc-to-native
|
|
||||||
ui-e2e-grep: 'ERC TO NATIVE'
|
|
||||||
- task: native-to-erc
|
|
||||||
ui-e2e-grep: 'NATIVE TO ERC'
|
|
||||||
- task: amb-stake-erc-to-erc
|
|
||||||
ui-e2e-grep: 'AMB-STAKE-ERC-TO-ERC'
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
submodules: true
|
submodules: true
|
||||||
- run: |
|
- name: Evaluate e2e docker images tags
|
||||||
|
run: |
|
||||||
git submodule status > submodule.status
|
git submodule status > submodule.status
|
||||||
echo "::set-env name=E2E_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}"
|
echo "E2E_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'Dockerfile.e2e', 'commons', 'oracle-e2e', 'monitor-e2e') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=ORACLE_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}"
|
echo "ORACLE_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'oracle') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=MONITOR_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}"
|
echo "MONITOR_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'monitor') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=UI_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'ui') }}"
|
echo "ALM_TAG=${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=ALM_TAG::${{ hashFiles('yarn.lock', 'package.json', 'submodule.status', 'commons', 'alm') }}"
|
echo "MOLECULE_RUNNER_TAG=${{ hashFiles('./deployment-e2e/Dockerfile') }}" >> $GITHUB_ENV
|
||||||
echo "::set-env name=MOLECULE_RUNNER_TAG::${{ hashFiles('./deployment-e2e/Dockerfile') }}"
|
|
||||||
- uses: actions/cache@v2
|
- uses: actions/cache@v2
|
||||||
id: cache-repo
|
id: cache-repo
|
||||||
with:
|
with:
|
||||||
@@ -220,12 +196,17 @@ jobs:
|
|||||||
**/node_modules
|
**/node_modules
|
||||||
contracts/build
|
contracts/build
|
||||||
key: ${{ needs.initialize.outputs.cache_key }}
|
key: ${{ needs.initialize.outputs.cache_key }}
|
||||||
- run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
- name: Login to docker registry
|
||||||
- run: ${{ steps.cache-repo.outputs.cache-hit }} && e2e-commons/up.sh deploy blocks
|
run: docker login ${DOCKER_REGISTRY} -u ${{ github.actor }} -p ${{ github.token }}
|
||||||
- run: docker-compose -f ./e2e-commons/docker-compose.yml pull oracle
|
- name: Deploy contracts
|
||||||
- run: deployment-e2e/molecule.sh ultimate-${{ matrix.task }}
|
run: ${{ steps.cache-repo.outputs.cache-hit }} && e2e-commons/up.sh deploy blocks
|
||||||
- run: sudo chown -R $USER:docker /var/run/docker.sock
|
- name: Pull e2e oracle image
|
||||||
- if: ${{ matrix.ui-e2e-grep }}
|
run: |
|
||||||
run: cd ui-e2e && xvfb-run yarn mocha -g "${{ matrix.ui-e2e-grep }}" -b ./test.js
|
docker-compose -f ./e2e-commons/docker-compose.yml pull oracle
|
||||||
- if: ${{ !matrix.ui-e2e-grep }}
|
docker tag ${DOCKER_IMAGE_BASE}/tokenbridge-e2e-oracle:${ORACLE_TAG} poanetwork/tokenbridge-oracle:latest
|
||||||
run: docker-compose -f ./e2e-commons/docker-compose.yml run e2e yarn workspace oracle-e2e run ${{ matrix.task }}
|
- name: Deploy oracle
|
||||||
|
run: deployment-e2e/molecule.sh ultimate-${{ matrix.task }}
|
||||||
|
- name: Reset docker socket permissions
|
||||||
|
run: sudo chown -R $USER:docker /var/run/docker.sock
|
||||||
|
- name: Run oracle e2e tests
|
||||||
|
run: docker-compose -f ./e2e-commons/docker-compose.yml run -e ULTIMATE=true e2e yarn workspace oracle-e2e run ${{ matrix.task }}
|
||||||
|
|||||||
13
.gitignore
vendored
13
.gitignore
vendored
@@ -10,11 +10,8 @@ dist
|
|||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.env
|
*.env*
|
||||||
.env.local
|
!.env.example
|
||||||
.env.development.local
|
|
||||||
.env.test.local
|
|
||||||
.env.production.local
|
|
||||||
.idea
|
.idea
|
||||||
.nyc_output
|
.nyc_output
|
||||||
logs/
|
logs/
|
||||||
@@ -49,5 +46,9 @@ __pycache__
|
|||||||
|
|
||||||
#monitor
|
#monitor
|
||||||
monitor/responses/*
|
monitor/responses/*
|
||||||
monitor/configs/*.env
|
monitor/cache/*
|
||||||
|
!monitor/cache/.gitkeep
|
||||||
!monitor/.gitkeep
|
!monitor/.gitkeep
|
||||||
|
|
||||||
|
# Local Netlify folder
|
||||||
|
.netlify
|
||||||
@@ -22,7 +22,7 @@ COMMON_FOREIGN_GAS_PRICE_FACTOR | A value that will multiply the gas price of th
|
|||||||
|
|
||||||
name | description | value
|
name | description | value
|
||||||
--- | --- | ---
|
--- | --- | ---
|
||||||
ORACLE_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
|
ORACLE_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 / ARBITRARY_MESSAGE
|
||||||
ORACLE_ALLOW_HTTP_FOR_RPC | **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`
|
ORACLE_ALLOW_HTTP_FOR_RPC | **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`
|
||||||
ORACLE_HOME_RPC_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
|
ORACLE_HOME_RPC_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
|
||||||
ORACLE_FOREIGN_RPC_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
|
ORACLE_FOREIGN_RPC_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
|
||||||
@@ -37,29 +37,20 @@ ORACLE_MAX_PROCESSING_TIME | The workers processes will be killed if this amount
|
|||||||
ORACLE_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"
|
ORACLE_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"
|
||||||
ORACLE_VALIDATOR_ADDRESS | The public address of the bridge validator | hexidecimal with "0x"
|
ORACLE_VALIDATOR_ADDRESS | The public address of the bridge validator | hexidecimal with "0x"
|
||||||
ORACLE_TX_REDUNDANCY | If set to `true`, instructs oracle to send `eth_sendRawTransaction` requests through all available RPC urls defined in `COMMON_HOME_RPC_URL` and `COMMON_FOREIGN_RPC_URL` variables instead of using first available one
|
ORACLE_TX_REDUNDANCY | If set to `true`, instructs oracle to send `eth_sendRawTransaction` requests through all available RPC urls defined in `COMMON_HOME_RPC_URL` and `COMMON_FOREIGN_RPC_URL` variables instead of using first available one
|
||||||
|
ORACLE_HOME_TO_FOREIGN_ALLOWANCE_LIST | Filename with a list of addresses, separated by newlines. If set, determines the privileged set of accounts whose requests will be automatically processed by the CollectedSignatures watcher. | string
|
||||||
|
ORACLE_HOME_TO_FOREIGN_BLOCK_LIST | Filename with a list of addresses, separated by newlines. If set, determines the blocked set of accounts whose requests will not be automatically processed by the CollectedSignatures watcher. Has a lower priority than the `ORACLE_HOME_TO_FOREIGN_ALLOWANCE_LIST` | string
|
||||||
## UI configuration
|
ORACLE_HOME_TO_FOREIGN_CHECK_SENDER | If set to `true`, instructs the oracle to do an extra check for transaction origin in the block/allowance list. `false` by default. | `true` / `false`
|
||||||
|
ORACLE_ALWAYS_RELAY_SIGNATURES | If set to `true`, the oracle will always relay signatures even if it was not the last who finilized the signatures collecting process. The default is `false`. | `true` / `false`
|
||||||
name | description | value
|
ORACLE_RPC_REQUEST_TIMEOUT | Timeout in milliseconds for a single RPC request. Default value is `ORACLE_*_RPC_POLLING_INTERVAL * 2`. | integer
|
||||||
--- | --- | ---
|
ORACLE_HOME_TX_RESEND_INTERVAL | Interval in milliseconds for automatic resending of stuck transactions for Home sender service. Defaults to 20 minutes. | integer
|
||||||
UI_TITLE | The title for the bridge UI page. `%c` will be replaced by the name of the network. | string
|
ORACLE_FOREIGN_TX_RESEND_INTERVAL | Interval in milliseconds for automatic resending of stuck transactions for Foreign sender service. Defaults to 20 minutes. | integer
|
||||||
UI_OG_TITLE | The meta title for the deployed bridge page. | string
|
ORACLE_SHUTDOWN_SERVICE_URL | Optional external URL to some other service/monitor/configuration manager that controls the remote shutdown process. GET request should return `application/json` message with the following schema: `{ shutdown: true/false }`. | URL
|
||||||
UI_DESCRIPTION | The meta description for the deployed bridge page. | string
|
ORACLE_SHUTDOWN_SERVICE_POLLING_INTERVAL | Optional interval in milliseconds used to request the side RPC node or external shutdown service. Default is 120000. | integer
|
||||||
UI_NATIVE_TOKEN_DISPLAY_NAME | name of the home native coin | string
|
ORACLE_SIDE_RPC_URL | Optional HTTPS URL(s) for communication with the external shutdown service or side RPC nodes, used for shutdown manager activities. 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)
|
||||||
UI_HOME_NETWORK_DISPLAY_NAME | name to be displayed for home network | string
|
ORACLE_SHUTDOWN_CONTRACT_ADDRESS | Optional contract address in the side chain accessible through `ORACLE_SIDE_RPC_URL`, where the method passed in `ORACLE_SHUTDOWN_CONTRACT_METHOD` is implemented. | `address`
|
||||||
UI_FOREIGN_NETWORK_DISPLAY_NAME | name to be displayed for foreign network | string
|
ORACLE_SHUTDOWN_CONTRACT_METHOD | Method signature to be used in the side chain to identify the current shutdown status. Method should return boolean. Default value is `isShutdown()`. | `function signature`
|
||||||
UI_HOME_WITHOUT_EVENTS | `true` if home network doesn't support events | true/false
|
ORACLE_FOREIGN_RPC_BLOCK_POLLING_LIMIT | Max length for the block range used in `eth_getLogs` requests for polling contract events for the Foreign chain. Infinite, if not provided. | `integer`
|
||||||
UI_FOREIGN_WITHOUT_EVENTS | `true` if foreign network doesn't support events | true/false
|
ORACLE_HOME_RPC_BLOCK_POLLING_LIMIT | Max length for the block range used in `eth_getLogs` requests for polling contract events for the Home chain. Infinite, if not provided. | `integer`
|
||||||
UI_HOME_EXPLORER_TX_TEMPLATE | template link to transaction on home explorer. `%s` will be replaced by transaction hash | URL template
|
|
||||||
UI_FOREIGN_EXPLORER_TX_TEMPLATE | template link to transaction on foreign explorer. `%s` will be replaced by transaction hash | URL template
|
|
||||||
UI_HOME_EXPLORER_ADDRESS_TEMPLATE | template link to address on home explorer. `%s` will be replaced by address | URL template
|
|
||||||
UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE | template link to address on foreign explorer. `%s` will be replaced by address | URL template
|
|
||||||
UI_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
|
|
||||||
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL | An interval in milliseconds used to get the updated gas price value either from the oracle or from the Foreign Bridge contract. | integer
|
|
||||||
UI_PORT | The port for the UI app. | integer
|
|
||||||
UI_STYLES | The set of styles to render the bridge UI page. | core/classic/stake
|
|
||||||
UI_PUBLIC_URL | The public url for the deployed bridge page | string
|
|
||||||
|
|
||||||
|
|
||||||
## Monitor configuration
|
## Monitor configuration
|
||||||
@@ -73,4 +64,9 @@ MONITOR_VALIDATOR_FOREIGN_TX_LIMIT | Average gas usage of a transaction sent by
|
|||||||
MONITOR_TX_NUMBER_THRESHOLD | If estimated number of transaction is equal to or below this value, the monitor will report that the validator has less funds than it is required. | integer
|
MONITOR_TX_NUMBER_THRESHOLD | If estimated number of transaction is equal to or below this value, the monitor will report that the validator has less funds than it is required. | integer
|
||||||
MONITOR_PORT | The port for the Monitor. | integer
|
MONITOR_PORT | The port for the Monitor. | integer
|
||||||
MONITOR_BRIDGE_NAME | The name to be used in the url path for the bridge | string
|
MONITOR_BRIDGE_NAME | The name to be used in the url path for the bridge | string
|
||||||
MONITOR_CACHE_EVENTS | If set to true, monitor will cache obtained events for other workers runs
|
MONITOR_CACHE_EVENTS | If set to true, monitor will cache obtained events for other workers runs | `true` / `false`
|
||||||
|
MONITOR_HOME_TO_FOREIGN_ALLOWANCE_LIST | File with a list of addresses, separated by newlines. If set, determines the privileged set of accounts whose requests should be automatically processed by the CollectedSignatures watcher. | string
|
||||||
|
MONITOR_HOME_TO_FOREIGN_BLOCK_LIST | File with a list of addresses, separated by newlines. If set, determines the set of accounts whose requests should be marked as unclaimed. Has a lower priority than the `MONITOR_HOME_TO_FOREIGN_ALLOWANCE_LIST`. | string
|
||||||
|
MONITOR_HOME_TO_FOREIGN_CHECK_SENDER | If set to `true`, instructs the oracle to do an extra check for transaction origin in the block/allowance list. `false` by default. | `true` / `false`
|
||||||
|
MONITOR_HOME_VALIDATORS_BALANCE_ENABLE | If set, defines the list of home validator addresses for which balance should be checked. | `string`
|
||||||
|
MONITOR_FOREIGN_VALIDATORS_BALANCE_ENABLE | If set, defines the list of foreign validator addresses for which balance should be checked. | `string`
|
||||||
|
|||||||
@@ -20,12 +20,10 @@ Sub-repositories maintained within this monorepo are listed below.
|
|||||||
| Sub-repository | Description |
|
| Sub-repository | Description |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| [Oracle](oracle/README.md) | Oracle responsible for listening to bridge related events and authorizing asset transfers. |
|
| [Oracle](oracle/README.md) | Oracle responsible for listening to bridge related events and authorizing asset transfers. |
|
||||||
| [UI](ui/README.md) | DApp interface to transfer tokens and coins between chains. |
|
|
||||||
| [Monitor](monitor/README.md) | Tool for checking balances and unprocessed events in bridged networks. |
|
| [Monitor](monitor/README.md) | Tool for checking balances and unprocessed events in bridged networks. |
|
||||||
| [Deployment](deployment/README.md) | Ansible playbooks for deploying cross-chain bridges. |
|
| [Deployment](deployment/README.md) | Ansible playbooks for deploying cross-chain bridges. |
|
||||||
| [Oracle-E2E](oracle-e2e/README.md) | End to end tests for the Oracle |
|
| [Oracle-E2E](oracle-e2e/README.md) | End to end tests for the Oracle |
|
||||||
| [Monitor-E2E](monitor-e2e/README.md) | End to end tests for the Monitor |
|
| [Monitor-E2E](monitor-e2e/README.md) | End to end tests for the Monitor |
|
||||||
| [UI-E2E](ui-e2e/README.md) | End to end tests for the UI |
|
|
||||||
| [Deployment-E2E](deployment-e2e/README.md) | End to end tests for the Deployment |
|
| [Deployment-E2E](deployment-e2e/README.md) | End to end tests for the Deployment |
|
||||||
| [Commons](commons/README.md) | Interfaces, constants and utilities shared between the sub-repositories |
|
| [Commons](commons/README.md) | Interfaces, constants and utilities shared between the sub-repositories |
|
||||||
| [E2E-Commons](e2e-commons/README.md) | Common utilities and configuration used in end to end tests |
|
| [E2E-Commons](e2e-commons/README.md) | Common utilities and configuration used in end to end tests |
|
||||||
@@ -68,7 +66,7 @@ Clone the repository:
|
|||||||
git clone https://github.com/poanetwork/tokenbridge
|
git clone https://github.com/poanetwork/tokenbridge
|
||||||
```
|
```
|
||||||
|
|
||||||
If there is no need to build docker images for the TokenBridge components (oracle, monitor, UI), initialize submodules, install dependencies, compile the Smart Contracts:
|
If there is no need to build docker images for the TokenBridge components (oracle, monitor), initialize submodules, install dependencies, compile the Smart Contracts:
|
||||||
```
|
```
|
||||||
yarn initialize
|
yarn initialize
|
||||||
```
|
```
|
||||||
@@ -91,7 +89,7 @@ Running tests for all projects:
|
|||||||
yarn test
|
yarn test
|
||||||
```
|
```
|
||||||
|
|
||||||
Additionally there are end-to-end tests for [Oracle](oracle-e2e/README.md) and [UI](ui-e2e/README.md).
|
Additionally there are end-to-end tests for [Oracle](oracle-e2e/README.md) and [Monitor](monitor-e2e/README.md).
|
||||||
|
|
||||||
For details on building, running and developing please refer to respective READMEs in sub-repositories.
|
For details on building, running and developing please refer to respective READMEs in sub-repositories.
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,6 @@
|
|||||||
"eslint-plugin-jest": "^23.18.0"
|
"eslint-plugin-jest": "^23.18.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8.9"
|
"node": ">= 10.18"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ COPY --from=contracts /mono/contracts/build ./contracts/build
|
|||||||
COPY commons/package.json ./commons/
|
COPY commons/package.json ./commons/
|
||||||
COPY alm/package.json ./alm/
|
COPY alm/package.json ./alm/
|
||||||
COPY yarn.lock .
|
COPY yarn.lock .
|
||||||
RUN NOYARNPOSTINSTALL=1 yarn install --frozen-lockfile --production
|
RUN NOYARNPOSTINSTALL=1 yarn install --frozen-lockfile
|
||||||
|
|
||||||
COPY ./commons ./commons
|
COPY ./commons ./commons
|
||||||
COPY ./alm ./alm
|
COPY ./alm ./alm
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ethersproject/bignumber": ">=5.0.0-beta.130",
|
||||||
"@react-hook/window-size": "^3.0.6",
|
"@react-hook/window-size": "^3.0.6",
|
||||||
"@testing-library/jest-dom": "^4.2.4",
|
"@testing-library/jest-dom": "^4.2.4",
|
||||||
"@testing-library/react": "^9.3.2",
|
"@testing-library/react": "^9.3.2",
|
||||||
@@ -15,6 +16,8 @@
|
|||||||
"@types/react-router-dom": "^5.1.5",
|
"@types/react-router-dom": "^5.1.5",
|
||||||
"@types/styled-components": "^5.1.0",
|
"@types/styled-components": "^5.1.0",
|
||||||
"@use-it/interval": "^0.1.3",
|
"@use-it/interval": "^0.1.3",
|
||||||
|
"@web3-react/core": "^6.1.1",
|
||||||
|
"@web3-react/injected-connector": "^6.0.7",
|
||||||
"customize-cra": "^1.0.0",
|
"customize-cra": "^1.0.0",
|
||||||
"date-fns": "^2.14.0",
|
"date-fns": "^2.14.0",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.2.0",
|
||||||
@@ -27,8 +30,9 @@
|
|||||||
"react-scripts": "3.0.1",
|
"react-scripts": "3.0.1",
|
||||||
"styled-components": "^5.1.1",
|
"styled-components": "^5.1.1",
|
||||||
"typescript": "^3.5.2",
|
"typescript": "^3.5.2",
|
||||||
"web3": "1.2.7",
|
"web3": "1.2.11",
|
||||||
"web3-eth-contract": "1.2.7"
|
"web3-eth-contract": "1.2.11",
|
||||||
|
"web3-utils": "1.2.11"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "yarn createSnapshots && ./load-env.sh react-app-rewired start",
|
"start": "yarn createSnapshots && ./load-env.sh react-app-rewired start",
|
||||||
@@ -54,6 +58,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint-plugin-prettier": "^3.1.3"
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
|
"node-fetch": "^2.6.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
alm/public/_redirects
Normal file
1
alm/public/_redirects
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/* /index.html 200
|
||||||
@@ -3,6 +3,8 @@ const { BRIDGE_VALIDATORS_ABI, HOME_AMB_ABI } = require('commons')
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
require('dotenv').config()
|
require('dotenv').config()
|
||||||
const Web3 = require('web3')
|
const Web3 = require('web3')
|
||||||
|
const fetch = require('node-fetch')
|
||||||
|
const { URL } = require('url')
|
||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
|
||||||
@@ -10,7 +12,9 @@ const {
|
|||||||
COMMON_HOME_RPC_URL,
|
COMMON_HOME_RPC_URL,
|
||||||
COMMON_HOME_BRIDGE_ADDRESS,
|
COMMON_HOME_BRIDGE_ADDRESS,
|
||||||
COMMON_FOREIGN_RPC_URL,
|
COMMON_FOREIGN_RPC_URL,
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS
|
COMMON_FOREIGN_BRIDGE_ADDRESS,
|
||||||
|
ALM_FOREIGN_EXPLORER_API,
|
||||||
|
ALM_HOME_EXPLORER_API
|
||||||
} = process.env
|
} = process.env
|
||||||
|
|
||||||
const generateSnapshot = async (side, url, bridgeAddress) => {
|
const generateSnapshot = async (side, url, bridgeAddress) => {
|
||||||
@@ -19,6 +23,31 @@ const generateSnapshot = async (side, url, bridgeAddress) => {
|
|||||||
const snapshot = {}
|
const snapshot = {}
|
||||||
|
|
||||||
const web3 = new Web3(new Web3.providers.HttpProvider(url))
|
const web3 = new Web3(new Web3.providers.HttpProvider(url))
|
||||||
|
const api = side === 'home' ? ALM_HOME_EXPLORER_API : ALM_FOREIGN_EXPLORER_API
|
||||||
|
|
||||||
|
const getPastEventsWithFallback = (contract, eventName, options) =>
|
||||||
|
contract.getPastEvents(eventName, options).catch(async e => {
|
||||||
|
if (e.message.includes('exceed maximum block range')) {
|
||||||
|
const abi = contract.options.jsonInterface.find(abi => abi.type === 'event' && abi.name === eventName)
|
||||||
|
|
||||||
|
const url = new URL(api)
|
||||||
|
url.searchParams.append('module', 'logs')
|
||||||
|
url.searchParams.append('action', 'getLogs')
|
||||||
|
url.searchParams.append('address', contract.options.address)
|
||||||
|
url.searchParams.append('fromBlock', options.fromBlock)
|
||||||
|
url.searchParams.append('toBlock', options.toBlock || 'latest')
|
||||||
|
url.searchParams.append('topic0', web3.eth.abi.encodeEventSignature(abi))
|
||||||
|
|
||||||
|
const logs = await fetch(url).then(res => res.json())
|
||||||
|
|
||||||
|
return logs.result.map(log => ({
|
||||||
|
transactionHash: log.transactionHash,
|
||||||
|
blockNumber: parseInt(log.blockNumber.slice(2), 16),
|
||||||
|
returnValues: web3.eth.abi.decodeLog(abi.inputs, log.data, log.topics.slice(1))
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
throw e
|
||||||
|
})
|
||||||
|
|
||||||
const currentBlockNumber = await web3.eth.getBlockNumber()
|
const currentBlockNumber = await web3.eth.getBlockNumber()
|
||||||
snapshot.snapshotBlockNumber = currentBlockNumber
|
snapshot.snapshotBlockNumber = currentBlockNumber
|
||||||
@@ -29,10 +58,14 @@ const generateSnapshot = async (side, url, bridgeAddress) => {
|
|||||||
const bridgeContract = new web3.eth.Contract(HOME_AMB_ABI, bridgeAddress)
|
const bridgeContract = new web3.eth.Contract(HOME_AMB_ABI, bridgeAddress)
|
||||||
|
|
||||||
// Save RequiredBlockConfirmationChanged events
|
// Save RequiredBlockConfirmationChanged events
|
||||||
let requiredBlockConfirmationChangedEvents = await bridgeContract.getPastEvents('RequiredBlockConfirmationChanged', {
|
let requiredBlockConfirmationChangedEvents = await getPastEventsWithFallback(
|
||||||
fromBlock: 0,
|
bridgeContract,
|
||||||
toBlock: currentBlockNumber
|
'RequiredBlockConfirmationChanged',
|
||||||
})
|
{
|
||||||
|
fromBlock: 0,
|
||||||
|
toBlock: currentBlockNumber
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
// In case RequiredBlockConfirmationChanged was not emitted during initialization in early versions of AMB
|
// In case RequiredBlockConfirmationChanged was not emitted during initialization in early versions of AMB
|
||||||
// manually generate an event for this. Example Sokol - Kovan bridge
|
// manually generate an event for this. Example Sokol - Kovan bridge
|
||||||
@@ -59,10 +92,14 @@ const generateSnapshot = async (side, url, bridgeAddress) => {
|
|||||||
const validatorContract = new web3.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorAddress)
|
const validatorContract = new web3.eth.Contract(BRIDGE_VALIDATORS_ABI, validatorAddress)
|
||||||
|
|
||||||
// Save RequiredSignaturesChanged events
|
// Save RequiredSignaturesChanged events
|
||||||
const RequiredSignaturesChangedEvents = await validatorContract.getPastEvents('RequiredSignaturesChanged', {
|
const RequiredSignaturesChangedEvents = await getPastEventsWithFallback(
|
||||||
fromBlock: 0,
|
validatorContract,
|
||||||
toBlock: currentBlockNumber
|
'RequiredSignaturesChanged',
|
||||||
})
|
{
|
||||||
|
fromBlock: 0,
|
||||||
|
toBlock: currentBlockNumber
|
||||||
|
}
|
||||||
|
)
|
||||||
snapshot.RequiredSignaturesChanged = RequiredSignaturesChangedEvents.map(e => ({
|
snapshot.RequiredSignaturesChanged = RequiredSignaturesChangedEvents.map(e => ({
|
||||||
blockNumber: e.blockNumber,
|
blockNumber: e.blockNumber,
|
||||||
returnValues: {
|
returnValues: {
|
||||||
@@ -71,7 +108,7 @@ const generateSnapshot = async (side, url, bridgeAddress) => {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
// Save ValidatorAdded events
|
// Save ValidatorAdded events
|
||||||
const validatorAddedEvents = await validatorContract.getPastEvents('ValidatorAdded', {
|
const validatorAddedEvents = await getPastEventsWithFallback(validatorContract, 'ValidatorAdded', {
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
toBlock: currentBlockNumber
|
toBlock: currentBlockNumber
|
||||||
})
|
})
|
||||||
@@ -85,7 +122,7 @@ const generateSnapshot = async (side, url, bridgeAddress) => {
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
// Save ValidatorRemoved events
|
// Save ValidatorRemoved events
|
||||||
const validatorRemovedEvents = await validatorContract.getPastEvents('ValidatorRemoved', {
|
const validatorRemovedEvents = await getPastEventsWithFallback(validatorContract, 'ValidatorRemoved', {
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
toBlock: currentBlockNumber
|
toBlock: currentBlockNumber
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { BrowserRouter } from 'react-router-dom'
|
import { BrowserRouter } from 'react-router-dom'
|
||||||
|
import { Web3ReactProvider } from '@web3-react/core'
|
||||||
|
import Web3 from 'web3'
|
||||||
import { MainPage } from './components/MainPage'
|
import { MainPage } from './components/MainPage'
|
||||||
import { StateProvider } from './state/StateProvider'
|
import { StateProvider } from './state/StateProvider'
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<StateProvider>
|
<Web3ReactProvider getLibrary={provider => new Web3(provider)}>
|
||||||
<MainPage />
|
<StateProvider>
|
||||||
</StateProvider>
|
<MainPage />
|
||||||
|
</StateProvider>
|
||||||
|
</Web3ReactProvider>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,21 +39,38 @@ export interface ConfirmationsContainerParams {
|
|||||||
message: MessageObject
|
message: MessageObject
|
||||||
receipt: Maybe<TransactionReceipt>
|
receipt: Maybe<TransactionReceipt>
|
||||||
fromHome: boolean
|
fromHome: boolean
|
||||||
timestamp: number
|
homeStartBlock: Maybe<number>
|
||||||
|
foreignStartBlock: Maybe<number>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ConfirmationsContainer = ({ message, receipt, fromHome, timestamp }: ConfirmationsContainerParams) => {
|
export const ConfirmationsContainer = ({
|
||||||
|
message,
|
||||||
|
receipt,
|
||||||
|
fromHome,
|
||||||
|
homeStartBlock,
|
||||||
|
foreignStartBlock
|
||||||
|
}: ConfirmationsContainerParams) => {
|
||||||
const {
|
const {
|
||||||
home: { name: homeName },
|
home: { name: homeName },
|
||||||
foreign: { name: foreignName }
|
foreign: { name: foreignName }
|
||||||
} = useStateProvider()
|
} = useStateProvider()
|
||||||
const { requiredSignatures, validatorList } = useValidatorContract({ fromHome, receipt })
|
const { requiredSignatures, validatorList } = useValidatorContract({ fromHome, receipt })
|
||||||
const { blockConfirmations } = useBlockConfirmations({ fromHome, receipt })
|
const { blockConfirmations } = useBlockConfirmations({ fromHome, receipt })
|
||||||
const { confirmations, status, executionData, signatureCollected, waitingBlocksResolved } = useMessageConfirmations({
|
const {
|
||||||
|
confirmations,
|
||||||
|
status,
|
||||||
|
executionData,
|
||||||
|
signatureCollected,
|
||||||
|
waitingBlocksResolved,
|
||||||
|
setExecutionData,
|
||||||
|
executionEventsFetched,
|
||||||
|
setPendingExecution
|
||||||
|
} = useMessageConfirmations({
|
||||||
message,
|
message,
|
||||||
receipt,
|
receipt,
|
||||||
fromHome,
|
fromHome,
|
||||||
timestamp,
|
homeStartBlock,
|
||||||
|
foreignStartBlock,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
validatorList,
|
validatorList,
|
||||||
blockConfirmations
|
blockConfirmations
|
||||||
@@ -102,7 +119,17 @@ export const ConfirmationsContainer = ({ message, receipt, fromHome, timestamp }
|
|||||||
validatorList={validatorList}
|
validatorList={validatorList}
|
||||||
waitingBlocksResolved={waitingBlocksResolved}
|
waitingBlocksResolved={waitingBlocksResolved}
|
||||||
/>
|
/>
|
||||||
{signatureCollected && <ExecutionConfirmation executionData={executionData} isHome={!fromHome} />}
|
{signatureCollected && (
|
||||||
|
<ExecutionConfirmation
|
||||||
|
messageData={message.data}
|
||||||
|
executionData={executionData}
|
||||||
|
isHome={!fromHome}
|
||||||
|
signatureCollected={signatureCollected}
|
||||||
|
setExecutionData={setExecutionData}
|
||||||
|
executionEventsFetched={executionEventsFetched}
|
||||||
|
setPendingExecution={setPendingExecution}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</StyledConfirmationContainer>
|
</StyledConfirmationContainer>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,24 +1,47 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { formatTimestamp, formatTxHash, getExplorerTxUrl } from '../utils/networks'
|
import { formatTimestamp, formatTxHash, getExplorerTxUrl } from '../utils/networks'
|
||||||
import { useWindowWidth } from '@react-hook/window-size'
|
import { useWindowWidth } from '@react-hook/window-size'
|
||||||
import { SEARCHING_TX, VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
import { SEARCHING_TX, VALIDATOR_CONFIRMATION_STATUS, ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION } from '../config/constants'
|
||||||
import { SimpleLoading } from './commons/Loading'
|
import { SimpleLoading } from './commons/Loading'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { ExecutionData } from '../hooks/useMessageConfirmations'
|
import { ExecutionData } from '../hooks/useMessageConfirmations'
|
||||||
import { GreyLabel, RedLabel, SuccessLabel } from './commons/Labels'
|
import { GreyLabel, RedLabel, SuccessLabel } from './commons/Labels'
|
||||||
import { ExplorerTxLink } from './commons/ExplorerTxLink'
|
import { ExplorerTxLink } from './commons/ExplorerTxLink'
|
||||||
import { Thead, AgeTd, StatusTd } from './commons/Table'
|
import { Thead, AgeTd, StatusTd } from './commons/Table'
|
||||||
|
import { ManualExecutionButton } from './ManualExecutionButton'
|
||||||
|
|
||||||
const StyledExecutionConfirmation = styled.div`
|
const StyledExecutionConfirmation = styled.div`
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
`
|
`
|
||||||
|
|
||||||
export interface ExecutionConfirmationParams {
|
export interface ExecutionConfirmationParams {
|
||||||
|
messageData: string
|
||||||
executionData: ExecutionData
|
executionData: ExecutionData
|
||||||
|
setExecutionData: Function
|
||||||
|
signatureCollected: boolean | string[]
|
||||||
isHome: boolean
|
isHome: boolean
|
||||||
|
executionEventsFetched: boolean
|
||||||
|
setPendingExecution: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ExecutionConfirmation = ({ executionData, isHome }: ExecutionConfirmationParams) => {
|
export const ExecutionConfirmation = ({
|
||||||
|
messageData,
|
||||||
|
executionData,
|
||||||
|
setExecutionData,
|
||||||
|
signatureCollected,
|
||||||
|
isHome,
|
||||||
|
executionEventsFetched,
|
||||||
|
setPendingExecution
|
||||||
|
}: ExecutionConfirmationParams) => {
|
||||||
|
const availableManualExecution =
|
||||||
|
!isHome &&
|
||||||
|
(executionData.status === VALIDATOR_CONFIRMATION_STATUS.WAITING ||
|
||||||
|
executionData.status === VALIDATOR_CONFIRMATION_STATUS.FAILED ||
|
||||||
|
(executionData.status === VALIDATOR_CONFIRMATION_STATUS.UNDEFINED &&
|
||||||
|
executionEventsFetched &&
|
||||||
|
!!executionData.validator))
|
||||||
|
const requiredManualExecution = availableManualExecution && ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION
|
||||||
|
const showAgeColumn = !requiredManualExecution || executionData.status === VALIDATOR_CONFIRMATION_STATUS.FAILED
|
||||||
const windowWidth = useWindowWidth()
|
const windowWidth = useWindowWidth()
|
||||||
|
|
||||||
const txExplorerLink = getExplorerTxUrl(executionData.txHash, isHome)
|
const txExplorerLink = getExplorerTxUrl(executionData.txHash, isHome)
|
||||||
@@ -48,26 +71,47 @@ export const ExecutionConfirmation = ({ executionData, isHome }: ExecutionConfir
|
|||||||
<table>
|
<table>
|
||||||
<Thead>
|
<Thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Executed by</th>
|
<th>{requiredManualExecution ? 'Execution info' : 'Executed by'}</th>
|
||||||
<th className="text-center">Status</th>
|
<th className="text-center">Status</th>
|
||||||
<th className="text-center">Age</th>
|
{showAgeColumn && <th className="text-center">Age</th>}
|
||||||
|
{availableManualExecution && <th className="text-center">Actions</th>}
|
||||||
</tr>
|
</tr>
|
||||||
</Thead>
|
</Thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{formattedValidator ? formattedValidator : <SimpleLoading />}</td>
|
<td>
|
||||||
<StatusTd className="text-center">{getExecutionStatusElement(executionData.status)}</StatusTd>
|
{requiredManualExecution ? (
|
||||||
<AgeTd className="text-center">
|
'Manual user action is required to complete the operation'
|
||||||
{executionData.timestamp > 0 ? (
|
) : formattedValidator ? (
|
||||||
<ExplorerTxLink href={txExplorerLink} target="_blank">
|
formattedValidator
|
||||||
{formatTimestamp(executionData.timestamp)}
|
|
||||||
</ExplorerTxLink>
|
|
||||||
) : executionData.status === VALIDATOR_CONFIRMATION_STATUS.WAITING ? (
|
|
||||||
''
|
|
||||||
) : (
|
) : (
|
||||||
SEARCHING_TX
|
<SimpleLoading />
|
||||||
)}
|
)}
|
||||||
</AgeTd>
|
</td>
|
||||||
|
<StatusTd className="text-center">{getExecutionStatusElement(executionData.status)}</StatusTd>
|
||||||
|
{showAgeColumn && (
|
||||||
|
<AgeTd className="text-center">
|
||||||
|
{executionData.timestamp > 0 ? (
|
||||||
|
<ExplorerTxLink href={txExplorerLink} target="_blank">
|
||||||
|
{formatTimestamp(executionData.timestamp)}
|
||||||
|
</ExplorerTxLink>
|
||||||
|
) : executionData.status === VALIDATOR_CONFIRMATION_STATUS.WAITING ? (
|
||||||
|
''
|
||||||
|
) : (
|
||||||
|
SEARCHING_TX
|
||||||
|
)}
|
||||||
|
</AgeTd>
|
||||||
|
)}
|
||||||
|
{availableManualExecution && (
|
||||||
|
<td>
|
||||||
|
<ManualExecutionButton
|
||||||
|
messageData={messageData}
|
||||||
|
setExecutionData={setExecutionData}
|
||||||
|
signatureCollected={signatureCollected as string[]}
|
||||||
|
setPendingExecution={setPendingExecution}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { TransactionReceipt } from 'web3-eth'
|
|||||||
import { InfoAlert } from './commons/InfoAlert'
|
import { InfoAlert } from './commons/InfoAlert'
|
||||||
import { ExplorerTxLink } from './commons/ExplorerTxLink'
|
import { ExplorerTxLink } from './commons/ExplorerTxLink'
|
||||||
import { FOREIGN_NETWORK_NAME, HOME_NETWORK_NAME } from '../config/constants'
|
import { FOREIGN_NETWORK_NAME, HOME_NETWORK_NAME } from '../config/constants'
|
||||||
|
import { ErrorAlert } from './commons/ErrorAlert'
|
||||||
|
|
||||||
const StyledMainPage = styled.div`
|
const StyledMainPage = styled.div`
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -51,7 +52,7 @@ export interface FormSubmitParams {
|
|||||||
|
|
||||||
export const MainPage = () => {
|
export const MainPage = () => {
|
||||||
const history = useHistory()
|
const history = useHistory()
|
||||||
const { home, foreign } = useStateProvider()
|
const { home, foreign, error, setError } = useStateProvider()
|
||||||
const [networkName, setNetworkName] = useState('')
|
const [networkName, setNetworkName] = useState('')
|
||||||
const [receipt, setReceipt] = useState<Maybe<TransactionReceipt>>(null)
|
const [receipt, setReceipt] = useState<Maybe<TransactionReceipt>>(null)
|
||||||
const [showInfoAlert, setShowInfoAlert] = useState(false)
|
const [showInfoAlert, setShowInfoAlert] = useState(false)
|
||||||
@@ -131,6 +132,7 @@ export const MainPage = () => {
|
|||||||
</AlertP>
|
</AlertP>
|
||||||
</InfoAlert>
|
</InfoAlert>
|
||||||
)}
|
)}
|
||||||
|
{error && <ErrorAlert onClick={() => setError('')} error={error} />}
|
||||||
<Route exact path={['/']} children={<Form onSubmit={onFormSubmit} />} />
|
<Route exact path={['/']} children={<Form onSubmit={onFormSubmit} />} />
|
||||||
<Route
|
<Route
|
||||||
path={['/:chainId/:txHash/:messageIdParam', '/:chainId/:txHash']}
|
path={['/:chainId/:txHash/:messageIdParam', '/:chainId/:txHash']}
|
||||||
|
|||||||
146
alm/src/components/ManualExecutionButton.tsx
Normal file
146
alm/src/components/ManualExecutionButton.tsx
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import React, { useState, useEffect } from 'react'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
import { InjectedConnector } from '@web3-react/injected-connector'
|
||||||
|
import { useWeb3React } from '@web3-react/core'
|
||||||
|
import {
|
||||||
|
DOUBLE_EXECUTION_ATTEMPT_ERROR,
|
||||||
|
EXECUTION_FAILED_ERROR,
|
||||||
|
EXECUTION_OUT_OF_GAS_ERROR,
|
||||||
|
FOREIGN_EXPLORER_API,
|
||||||
|
INCORRECT_CHAIN_ERROR,
|
||||||
|
VALIDATOR_CONFIRMATION_STATUS
|
||||||
|
} from '../config/constants'
|
||||||
|
import { useStateProvider } from '../state/StateProvider'
|
||||||
|
import { signatureToVRS, packSignatures } from '../utils/signatures'
|
||||||
|
import { getSuccessExecutionData } from '../utils/getFinalizationEvent'
|
||||||
|
import { TransactionReceipt } from 'web3-eth'
|
||||||
|
|
||||||
|
const StyledButton = styled.button`
|
||||||
|
color: var(--button-color);
|
||||||
|
border-color: var(--font-color);
|
||||||
|
margin-top: 10px;
|
||||||
|
&:focus {
|
||||||
|
outline: var(--button-color);
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
interface ManualExecutionButtonParams {
|
||||||
|
messageData: string
|
||||||
|
setExecutionData: Function
|
||||||
|
signatureCollected: string[]
|
||||||
|
setPendingExecution: Function
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ManualExecutionButton = ({
|
||||||
|
messageData,
|
||||||
|
setExecutionData,
|
||||||
|
signatureCollected,
|
||||||
|
setPendingExecution
|
||||||
|
}: ManualExecutionButtonParams) => {
|
||||||
|
const { foreign, setError } = useStateProvider()
|
||||||
|
const { library, activate, account, active } = useWeb3React()
|
||||||
|
const [manualExecution, setManualExecution] = useState(false)
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => {
|
||||||
|
if (!manualExecution || !foreign.chainId) return
|
||||||
|
|
||||||
|
if (!active) {
|
||||||
|
activate(new InjectedConnector({ supportedChainIds: [foreign.chainId] }), e => {
|
||||||
|
if (e.message.includes('Unsupported chain id')) {
|
||||||
|
setError(INCORRECT_CHAIN_ERROR)
|
||||||
|
const { ethereum } = window as any
|
||||||
|
|
||||||
|
// remove the error message after chain is correctly changed to the foreign one
|
||||||
|
const listener = (chainId: string) => {
|
||||||
|
if (parseInt(chainId.slice(2), 16) === foreign.chainId) {
|
||||||
|
ethereum.removeListener('chainChanged', listener)
|
||||||
|
setError((error: string) => (error === INCORRECT_CHAIN_ERROR ? '' : error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ethereum.on('chainChanged', listener)
|
||||||
|
} else {
|
||||||
|
setError(e.message)
|
||||||
|
}
|
||||||
|
setManualExecution(false)
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!library || !foreign.bridgeContract || !signatureCollected || !signatureCollected.length) return
|
||||||
|
|
||||||
|
const signatures = packSignatures(signatureCollected.map(signatureToVRS))
|
||||||
|
const messageId = messageData.slice(0, 66)
|
||||||
|
const bridge = foreign.bridgeContract
|
||||||
|
const data = bridge.methods.executeSignatures(messageData, signatures).encodeABI()
|
||||||
|
setManualExecution(false)
|
||||||
|
|
||||||
|
library.eth
|
||||||
|
.sendTransaction({
|
||||||
|
from: account,
|
||||||
|
to: foreign.bridgeAddress,
|
||||||
|
data
|
||||||
|
})
|
||||||
|
.on('transactionHash', (txHash: string) => {
|
||||||
|
setExecutionData({
|
||||||
|
status: VALIDATOR_CONFIRMATION_STATUS.PENDING,
|
||||||
|
validator: account,
|
||||||
|
txHash,
|
||||||
|
timestamp: Math.floor(new Date().getTime() / 1000.0),
|
||||||
|
executionResult: false
|
||||||
|
})
|
||||||
|
setPendingExecution(true)
|
||||||
|
})
|
||||||
|
.on('error', async (e: Error, receipt: TransactionReceipt) => {
|
||||||
|
if (e.message.includes('Transaction has been reverted by the EVM')) {
|
||||||
|
const successExecutionData = await getSuccessExecutionData(
|
||||||
|
bridge,
|
||||||
|
'RelayedMessage',
|
||||||
|
library,
|
||||||
|
messageId,
|
||||||
|
FOREIGN_EXPLORER_API
|
||||||
|
)
|
||||||
|
if (successExecutionData) {
|
||||||
|
setExecutionData(successExecutionData)
|
||||||
|
setError(DOUBLE_EXECUTION_ATTEMPT_ERROR)
|
||||||
|
} else {
|
||||||
|
const { gas } = await library.eth.getTransaction(receipt.transactionHash)
|
||||||
|
setExecutionData({
|
||||||
|
status: VALIDATOR_CONFIRMATION_STATUS.FAILED,
|
||||||
|
validator: account,
|
||||||
|
txHash: receipt.transactionHash,
|
||||||
|
timestamp: Math.floor(new Date().getTime() / 1000.0),
|
||||||
|
executionResult: false
|
||||||
|
})
|
||||||
|
setError(gas === receipt.gasUsed ? EXECUTION_OUT_OF_GAS_ERROR : EXECUTION_FAILED_ERROR)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setError(e.message)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
[
|
||||||
|
manualExecution,
|
||||||
|
library,
|
||||||
|
activate,
|
||||||
|
active,
|
||||||
|
account,
|
||||||
|
foreign.chainId,
|
||||||
|
foreign.bridgeAddress,
|
||||||
|
foreign.bridgeContract,
|
||||||
|
setError,
|
||||||
|
messageData,
|
||||||
|
signatureCollected,
|
||||||
|
setExecutionData,
|
||||||
|
setPendingExecution
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="is-center">
|
||||||
|
<StyledButton className="button outline" onClick={() => setManualExecution(true)}>
|
||||||
|
Execute
|
||||||
|
</StyledButton>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import { ExplorerTxLink } from './commons/ExplorerTxLink'
|
|||||||
import { ConfirmationsContainer } from './ConfirmationsContainer'
|
import { ConfirmationsContainer } from './ConfirmationsContainer'
|
||||||
import { TransactionReceipt } from 'web3-eth'
|
import { TransactionReceipt } from 'web3-eth'
|
||||||
import { BackButton } from './commons/BackButton'
|
import { BackButton } from './commons/BackButton'
|
||||||
|
import { useClosestBlock } from '../hooks/useClosestBlock'
|
||||||
|
|
||||||
export interface StatusContainerParam {
|
export interface StatusContainerParam {
|
||||||
onBackToMain: () => void
|
onBackToMain: () => void
|
||||||
@@ -23,12 +24,15 @@ export const StatusContainer = ({ onBackToMain, setNetworkFromParams, receiptPar
|
|||||||
const { chainId, txHash, messageIdParam } = useParams()
|
const { chainId, txHash, messageIdParam } = useParams()
|
||||||
const validChainId = chainId === home.chainId.toString() || chainId === foreign.chainId.toString()
|
const validChainId = chainId === home.chainId.toString() || chainId === foreign.chainId.toString()
|
||||||
const validParameters = validChainId && validTxHash(txHash)
|
const validParameters = validChainId && validTxHash(txHash)
|
||||||
|
const isHome = chainId === home.chainId.toString()
|
||||||
|
|
||||||
const { messages, receipt, status, description, timestamp, loading } = useTransactionStatus({
|
const { messages, receipt, status, description, timestamp, loading } = useTransactionStatus({
|
||||||
txHash: validParameters ? txHash : '',
|
txHash: validParameters ? txHash : '',
|
||||||
chainId: validParameters ? parseInt(chainId) : 0,
|
chainId: validParameters ? parseInt(chainId) : 0,
|
||||||
receiptParam
|
receiptParam
|
||||||
})
|
})
|
||||||
|
const homeStartBlock = useClosestBlock(true, isHome, receipt, timestamp)
|
||||||
|
const foreignStartBlock = useClosestBlock(false, isHome, receipt, timestamp)
|
||||||
|
|
||||||
const selectedMessageId = messageIdParam === undefined || messages[messageIdParam] === undefined ? -1 : messageIdParam
|
const selectedMessageId = messageIdParam === undefined || messages[messageIdParam] === undefined ? -1 : messageIdParam
|
||||||
|
|
||||||
@@ -64,7 +68,6 @@ export const StatusContainer = ({ onBackToMain, setNetworkFromParams, receiptPar
|
|||||||
const displayReference = multiMessageSelected ? messages[selectedMessageId].id : txHash
|
const displayReference = multiMessageSelected ? messages[selectedMessageId].id : txHash
|
||||||
const formattedMessageId = formatTxHash(displayReference)
|
const formattedMessageId = formatTxHash(displayReference)
|
||||||
|
|
||||||
const isHome = chainId === home.chainId.toString()
|
|
||||||
const txExplorerLink = getExplorerTxUrl(txHash, isHome)
|
const txExplorerLink = getExplorerTxUrl(txHash, isHome)
|
||||||
const displayExplorerLink = status !== TRANSACTION_STATUS.NOT_FOUND
|
const displayExplorerLink = status !== TRANSACTION_STATUS.NOT_FOUND
|
||||||
|
|
||||||
@@ -101,7 +104,13 @@ export const StatusContainer = ({ onBackToMain, setNetworkFromParams, receiptPar
|
|||||||
)}
|
)}
|
||||||
{displayMessageSelector && <MessageSelector messages={messages} onMessageSelected={onMessageSelected} />}
|
{displayMessageSelector && <MessageSelector messages={messages} onMessageSelected={onMessageSelected} />}
|
||||||
{displayConfirmations && (
|
{displayConfirmations && (
|
||||||
<ConfirmationsContainer message={messageToConfirm} receipt={receipt} fromHome={isHome} timestamp={timestamp} />
|
<ConfirmationsContainer
|
||||||
|
message={messageToConfirm}
|
||||||
|
receipt={receipt}
|
||||||
|
fromHome={isHome}
|
||||||
|
homeStartBlock={homeStartBlock}
|
||||||
|
foreignStartBlock={foreignStartBlock}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
<BackButton onBackToMain={onBackToMain} />
|
<BackButton onBackToMain={onBackToMain} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export const CloseIcon = () => (
|
export const CloseIcon = ({ color }: { color?: string }) => (
|
||||||
<svg
|
<svg
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
focusable="false"
|
focusable="false"
|
||||||
@@ -10,12 +10,9 @@ export const CloseIcon = () => (
|
|||||||
role="img"
|
role="img"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
viewBox="0 0 352 512"
|
viewBox="0 0 352 512"
|
||||||
fill="#1890ff"
|
fill={color || '#1890ff'}
|
||||||
height="1em"
|
height="1em"
|
||||||
>
|
>
|
||||||
<path
|
<path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z" />
|
||||||
fill="#1890ff"
|
|
||||||
d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"
|
|
||||||
/>
|
|
||||||
</svg>
|
</svg>
|
||||||
)
|
)
|
||||||
|
|||||||
48
alm/src/components/commons/ErrorAlert.tsx
Normal file
48
alm/src/components/commons/ErrorAlert.tsx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
import { InfoIcon } from './InfoIcon'
|
||||||
|
import { CloseIcon } from './CloseIcon'
|
||||||
|
import { ExplorerTxLink } from './ExplorerTxLink'
|
||||||
|
|
||||||
|
const StyledErrorAlert = styled.div`
|
||||||
|
border: 1px solid var(--failed-color);
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
padding-top: 10px;
|
||||||
|
`
|
||||||
|
|
||||||
|
const CloseIconContainer = styled.div`
|
||||||
|
cursor: pointer;
|
||||||
|
`
|
||||||
|
|
||||||
|
const TextContainer = styled.div`
|
||||||
|
white-space: pre-wrap;
|
||||||
|
flex-direction: column;
|
||||||
|
`
|
||||||
|
|
||||||
|
export const ErrorAlert = ({ onClick, error }: { onClick: () => void; error: string }) => {
|
||||||
|
const errorArray = error.split('%link')
|
||||||
|
const text = errorArray[0]
|
||||||
|
let link
|
||||||
|
if (errorArray.length > 1) {
|
||||||
|
link = (
|
||||||
|
<ExplorerTxLink href={errorArray[1]} target="_blank" rel="noopener noreferrer">
|
||||||
|
{errorArray[1]}
|
||||||
|
</ExplorerTxLink>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="row is-center">
|
||||||
|
<StyledErrorAlert className="col-10 is-vertical-align row">
|
||||||
|
<InfoIcon color="var(--failed-color)" />
|
||||||
|
<TextContainer className="col-10">
|
||||||
|
{text}
|
||||||
|
{link}
|
||||||
|
</TextContainer>
|
||||||
|
<CloseIconContainer className="col-1 is-vertical-align is-center" onClick={onClick}>
|
||||||
|
<CloseIcon color="var(--failed-color)" />
|
||||||
|
</CloseIconContainer>
|
||||||
|
</StyledErrorAlert>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
export const InfoIcon = () => (
|
export const InfoIcon = ({ color }: { color?: string }) => (
|
||||||
<svg
|
<svg
|
||||||
className="col-1 is-left"
|
className="col-1 is-left"
|
||||||
viewBox="64 64 896 896"
|
viewBox="64 64 896 896"
|
||||||
@@ -8,7 +8,7 @@ export const InfoIcon = () => (
|
|||||||
data-icon="info-circle"
|
data-icon="info-circle"
|
||||||
width="1em"
|
width="1em"
|
||||||
height="1em"
|
height="1em"
|
||||||
fill="#1890ff"
|
fill={color || '#1890ff'}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
<path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" />
|
<path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" />
|
||||||
|
|||||||
@@ -13,11 +13,13 @@ export const FOREIGN_EXPLORER_TX_TEMPLATE: string = process.env.REACT_APP_ALM_FO
|
|||||||
export const HOME_EXPLORER_API: string = process.env.REACT_APP_ALM_HOME_EXPLORER_API || ''
|
export const HOME_EXPLORER_API: string = process.env.REACT_APP_ALM_HOME_EXPLORER_API || ''
|
||||||
export const FOREIGN_EXPLORER_API: string = process.env.REACT_APP_ALM_FOREIGN_EXPLORER_API || ''
|
export const FOREIGN_EXPLORER_API: string = process.env.REACT_APP_ALM_FOREIGN_EXPLORER_API || ''
|
||||||
|
|
||||||
|
export const ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION: boolean =
|
||||||
|
(process.env.REACT_APP_ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION || '').toLowerCase() === 'true'
|
||||||
|
|
||||||
export const HOME_RPC_POLLING_INTERVAL: number = 5000
|
export const HOME_RPC_POLLING_INTERVAL: number = 5000
|
||||||
export const FOREIGN_RPC_POLLING_INTERVAL: number = 5000
|
export const FOREIGN_RPC_POLLING_INTERVAL: number = 5000
|
||||||
export const BLOCK_RANGE: number = 50
|
export const BLOCK_RANGE: number = 500
|
||||||
export const ONE_DAY_TIMESTAMP: number = 86400
|
export const MAX_TX_SEARCH_BLOCK_RANGE: number = 10000
|
||||||
export const THREE_DAYS_TIMESTAMP: number = 259200
|
|
||||||
|
|
||||||
export const EXECUTE_AFFIRMATION_HASH = 'e7a2c01f'
|
export const EXECUTE_AFFIRMATION_HASH = 'e7a2c01f'
|
||||||
export const SUBMIT_SIGNATURE_HASH = '630cea8e'
|
export const SUBMIT_SIGNATURE_HASH = '630cea8e'
|
||||||
@@ -61,3 +63,14 @@ export const VALIDATOR_CONFIRMATION_STATUS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SEARCHING_TX = 'Searching Transaction...'
|
export const SEARCHING_TX = 'Searching Transaction...'
|
||||||
|
|
||||||
|
export const INCORRECT_CHAIN_ERROR = `Incorrect chain chosen. Switch to ${FOREIGN_NETWORK_NAME} in the wallet.`
|
||||||
|
|
||||||
|
export const DOUBLE_EXECUTION_ATTEMPT_ERROR = `Your execution transaction has been reverted.
|
||||||
|
However, the execution completed successfully in the transaction sent by a different party.`
|
||||||
|
|
||||||
|
export const EXECUTION_FAILED_ERROR = `Your execution transaction has been reverted.
|
||||||
|
Please, contact the support by messaging on %linkhttps://forum.poa.network/c/support`
|
||||||
|
|
||||||
|
export const EXECUTION_OUT_OF_GAS_ERROR = `Your execution transaction has been reverted due to Out-of-Gas error.
|
||||||
|
Please, resend the transaction and provide more gas to it.`
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// %t will be replaced by the time -> x minutes/hours/days ago
|
// %t will be replaced by the time -> x minutes/hours/days ago
|
||||||
|
import { ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION } from './constants'
|
||||||
|
|
||||||
export const TRANSACTION_STATUS_DESCRIPTION: { [key: string]: string } = {
|
export const TRANSACTION_STATUS_DESCRIPTION: { [key: string]: string } = {
|
||||||
SUCCESS_MULTIPLE_MESSAGES: 'was initiated %t and contains several bridge messages. Specify one of them:',
|
SUCCESS_MULTIPLE_MESSAGES: 'was initiated %t and contains several bridge messages. Specify one of them:',
|
||||||
SUCCESS_ONE_MESSAGE: 'was initiated %t',
|
SUCCESS_ONE_MESSAGE: 'was initiated %t',
|
||||||
@@ -24,7 +26,7 @@ export const CONFIRMATIONS_STATUS_LABEL_HOME: { [key: string]: string } = {
|
|||||||
SUCCESS_MESSAGE_FAILED: 'Success',
|
SUCCESS_MESSAGE_FAILED: 'Success',
|
||||||
EXECUTION_FAILED: 'Execution failed',
|
EXECUTION_FAILED: 'Execution failed',
|
||||||
EXECUTION_PENDING: 'Execution pending',
|
EXECUTION_PENDING: 'Execution pending',
|
||||||
EXECUTION_WAITING: 'Execution waiting',
|
EXECUTION_WAITING: ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION ? 'Manual execution waiting' : 'Execution waiting',
|
||||||
FAILED: 'Confirmation Failed',
|
FAILED: 'Confirmation Failed',
|
||||||
PENDING: 'Confirmation Pending',
|
PENDING: 'Confirmation Pending',
|
||||||
WAITING_VALIDATORS: 'Confirmation Waiting',
|
WAITING_VALIDATORS: 'Confirmation Waiting',
|
||||||
@@ -55,11 +57,12 @@ export const CONFIRMATIONS_STATUS_DESCRIPTION_HOME: { [key: string]: string } =
|
|||||||
SUCCESS_MESSAGE_FAILED:
|
SUCCESS_MESSAGE_FAILED:
|
||||||
'The specified transaction was included in a block,\nthe validators collected signatures and the cross-chain relay was executed correctly,\nbut the contained message execution failed.\nContact the support of the application you used to produce the transaction for the clarifications.',
|
'The specified transaction was included in a block,\nthe validators collected signatures and the cross-chain relay was executed correctly,\nbut the contained message execution failed.\nContact the support of the application you used to produce the transaction for the clarifications.',
|
||||||
EXECUTION_FAILED:
|
EXECUTION_FAILED:
|
||||||
'The specified transaction was included in a block\nand the validators collected signatures. The\nvalidator’s transaction with collected signatures was\nsent but did not succeed. Contact to the validators by messaging\non %linkhttps://forum.poa.network/c/support',
|
'The specified transaction was included in a block\nand the validators collected signatures. The\n transaction with collected signatures was\nsent but did not succeed. Contact to the validators by messaging\non %linkhttps://forum.poa.network/c/support',
|
||||||
EXECUTION_PENDING:
|
EXECUTION_PENDING:
|
||||||
'The specified transaction was included in a block\nand the validators collected signatures. The\nvalidator’s transaction with collected signatures was\nsent but is not yet added to a block.',
|
'The specified transaction was included in a block\nand the validators collected signatures. The\n transaction with collected signatures was\nsent but is not yet added to a block.',
|
||||||
EXECUTION_WAITING:
|
EXECUTION_WAITING: ALM_HOME_TO_FOREIGN_MANUAL_EXECUTION
|
||||||
'The specified transaction was included in a block\nand the validators collected signatures. Either\n1. One of the validators is waiting for chain finalization.\n2. A validator skipped its duty to relay signatures.\nCheck status again after a few blocks. If the issue still persists contact to the validators by messaging on %linkhttps://forum.poa.network/c/support',
|
? 'The specified transaction was included in a block\nand the validators collected signatures.\nNow the manual user action is required to complete message execution.\n Please, press the "Execute" button.'
|
||||||
|
: 'The specified transaction was included in a block\nand the validators collected signatures. Either\n1. One of the validators is waiting for chain finalization.\n2. A validator skipped its duty to relay signatures.\n3. The execution transaction is still pending (e.g. due to the gas price spike).\nCheck status again after a few blocks or force execution by pressing the "Execute" button.\nIf the issue still persists contact to the validators by messaging on %linkhttps://forum.poa.network/c/support',
|
||||||
FAILED:
|
FAILED:
|
||||||
'The specified transaction was included in a block,\nbut transactions with signatures sent by a majority of\nvalidators failed. The cross-chain relay request will\nnot be processed. Contact to the validators by\nmessaging on %linkhttps://forum.poa.network/c/support',
|
'The specified transaction was included in a block,\nbut transactions with signatures sent by a majority of\nvalidators failed. The cross-chain relay request will\nnot be processed. Contact to the validators by\nmessaging on %linkhttps://forum.poa.network/c/support',
|
||||||
PENDING:
|
PENDING:
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { useStateProvider } from '../state/StateProvider'
|
|||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { getRequiredBlockConfirmations } from '../utils/contract'
|
import { getRequiredBlockConfirmations } from '../utils/contract'
|
||||||
import { foreignSnapshotProvider, homeSnapshotProvider, SnapshotProvider } from '../services/SnapshotProvider'
|
import { foreignSnapshotProvider, homeSnapshotProvider, SnapshotProvider } from '../services/SnapshotProvider'
|
||||||
|
import Web3 from 'web3'
|
||||||
|
import { FOREIGN_EXPLORER_API, HOME_EXPLORER_API } from '../config/constants'
|
||||||
|
|
||||||
export interface UseBlockConfirmationsParams {
|
export interface UseBlockConfirmationsParams {
|
||||||
fromHome: boolean
|
fromHome: boolean
|
||||||
@@ -19,9 +21,11 @@ export const useBlockConfirmations = ({ receipt, fromHome }: UseBlockConfirmatio
|
|||||||
contract: Contract,
|
contract: Contract,
|
||||||
receipt: TransactionReceipt,
|
receipt: TransactionReceipt,
|
||||||
setResult: Function,
|
setResult: Function,
|
||||||
snapshotProvider: SnapshotProvider
|
snapshotProvider: SnapshotProvider,
|
||||||
|
web3: Web3,
|
||||||
|
api: string
|
||||||
) => {
|
) => {
|
||||||
const result = await getRequiredBlockConfirmations(contract, receipt.blockNumber, snapshotProvider)
|
const result = await getRequiredBlockConfirmations(contract, receipt.blockNumber, snapshotProvider, web3, api)
|
||||||
setResult(result)
|
setResult(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,10 +33,12 @@ export const useBlockConfirmations = ({ receipt, fromHome }: UseBlockConfirmatio
|
|||||||
() => {
|
() => {
|
||||||
const bridgeContract = fromHome ? home.bridgeContract : foreign.bridgeContract
|
const bridgeContract = fromHome ? home.bridgeContract : foreign.bridgeContract
|
||||||
const snapshotProvider = fromHome ? homeSnapshotProvider : foreignSnapshotProvider
|
const snapshotProvider = fromHome ? homeSnapshotProvider : foreignSnapshotProvider
|
||||||
if (!bridgeContract || !receipt) return
|
const web3 = fromHome ? home.web3 : foreign.web3
|
||||||
callRequireBlockConfirmations(bridgeContract, receipt, setBlockConfirmations, snapshotProvider)
|
const api = fromHome ? HOME_EXPLORER_API : FOREIGN_EXPLORER_API
|
||||||
|
if (!bridgeContract || !receipt || !web3) return
|
||||||
|
callRequireBlockConfirmations(bridgeContract, receipt, setBlockConfirmations, snapshotProvider, web3, api)
|
||||||
},
|
},
|
||||||
[home.bridgeContract, foreign.bridgeContract, receipt, fromHome]
|
[home.bridgeContract, foreign.bridgeContract, receipt, fromHome, home.web3, foreign.web3]
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
68
alm/src/hooks/useClosestBlock.ts
Normal file
68
alm/src/hooks/useClosestBlock.ts
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
import { useEffect, useState } from 'react'
|
||||||
|
import { TransactionReceipt } from 'web3-eth'
|
||||||
|
import { useStateProvider } from '../state/StateProvider'
|
||||||
|
import { FOREIGN_EXPLORER_API, HOME_EXPLORER_API } from '../config/constants'
|
||||||
|
import { getClosestBlockByTimestamp } from '../utils/explorer'
|
||||||
|
|
||||||
|
export function useClosestBlock(
|
||||||
|
searchHome: boolean,
|
||||||
|
fromHome: boolean,
|
||||||
|
receipt: Maybe<TransactionReceipt>,
|
||||||
|
timestamp: number
|
||||||
|
) {
|
||||||
|
const { home, foreign } = useStateProvider()
|
||||||
|
const [blockNumber, setBlockNumber] = useState<number | null>(null)
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => {
|
||||||
|
if (!receipt || blockNumber || !timestamp) return
|
||||||
|
|
||||||
|
if (fromHome === searchHome) {
|
||||||
|
setBlockNumber(receipt.blockNumber)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const web3 = searchHome ? home.web3 : foreign.web3
|
||||||
|
if (!web3) return
|
||||||
|
|
||||||
|
const getBlock = async () => {
|
||||||
|
// try to fast-fetch closest block number from the chain explorer
|
||||||
|
try {
|
||||||
|
const api = searchHome ? HOME_EXPLORER_API : FOREIGN_EXPLORER_API
|
||||||
|
setBlockNumber(await getClosestBlockByTimestamp(api, timestamp))
|
||||||
|
return
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
const lastBlock = await web3.eth.getBlock('latest')
|
||||||
|
if (lastBlock.timestamp <= timestamp) {
|
||||||
|
setBlockNumber(lastBlock.number)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldBlock = await web3.eth.getBlock(Math.max(lastBlock.number - 10000, 1))
|
||||||
|
const blockDiff = lastBlock.number - oldBlock.number
|
||||||
|
const timeDiff = (lastBlock.timestamp as number) - (oldBlock.timestamp as number)
|
||||||
|
const averageBlockTime = timeDiff / blockDiff
|
||||||
|
let currentBlock = lastBlock
|
||||||
|
|
||||||
|
let prevBlockDiff = Infinity
|
||||||
|
while (true) {
|
||||||
|
const timeDiff = (currentBlock.timestamp as number) - timestamp
|
||||||
|
const blockDiff = Math.ceil(timeDiff / averageBlockTime)
|
||||||
|
if (Math.abs(blockDiff) < 5 || Math.abs(blockDiff) >= Math.abs(prevBlockDiff)) {
|
||||||
|
setBlockNumber(currentBlock.number - blockDiff - 5)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
prevBlockDiff = blockDiff
|
||||||
|
currentBlock = await web3.eth.getBlock(currentBlock.number - blockDiff)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getBlock()
|
||||||
|
},
|
||||||
|
[blockNumber, foreign.web3, fromHome, home.web3, receipt, searchHome, timestamp]
|
||||||
|
)
|
||||||
|
|
||||||
|
return blockNumber
|
||||||
|
}
|
||||||
@@ -3,7 +3,6 @@ import { TransactionReceipt } from 'web3-eth'
|
|||||||
import { MessageObject } from '../utils/web3'
|
import { MessageObject } from '../utils/web3'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { EventData } from 'web3-eth-contract'
|
import { EventData } from 'web3-eth-contract'
|
||||||
import { getAffirmationsSigned, getMessagesSigned } from '../utils/contract'
|
|
||||||
import {
|
import {
|
||||||
BLOCK_RANGE,
|
BLOCK_RANGE,
|
||||||
CONFIRMATIONS_STATUS,
|
CONFIRMATIONS_STATUS,
|
||||||
@@ -12,9 +11,6 @@ import {
|
|||||||
VALIDATOR_CONFIRMATION_STATUS
|
VALIDATOR_CONFIRMATION_STATUS
|
||||||
} from '../config/constants'
|
} from '../config/constants'
|
||||||
import { homeBlockNumberProvider, foreignBlockNumberProvider } from '../services/BlockNumberProvider'
|
import { homeBlockNumberProvider, foreignBlockNumberProvider } from '../services/BlockNumberProvider'
|
||||||
import { checkSignaturesWaitingForBLocks } from '../utils/signatureWaitingForBlocks'
|
|
||||||
import { getCollectedSignaturesEvent } from '../utils/getCollectedSignaturesEvent'
|
|
||||||
import { checkWaitingBlocksForExecution } from '../utils/executionWaitingForBlocks'
|
|
||||||
import { getConfirmationsForTx } from '../utils/getConfirmationsForTx'
|
import { getConfirmationsForTx } from '../utils/getConfirmationsForTx'
|
||||||
import { getFinalizationEvent } from '../utils/getFinalizationEvent'
|
import { getFinalizationEvent } from '../utils/getFinalizationEvent'
|
||||||
import {
|
import {
|
||||||
@@ -29,7 +25,8 @@ export interface useMessageConfirmationsParams {
|
|||||||
message: MessageObject
|
message: MessageObject
|
||||||
receipt: Maybe<TransactionReceipt>
|
receipt: Maybe<TransactionReceipt>
|
||||||
fromHome: boolean
|
fromHome: boolean
|
||||||
timestamp: number
|
homeStartBlock: Maybe<number>
|
||||||
|
foreignStartBlock: Maybe<number>
|
||||||
requiredSignatures: number
|
requiredSignatures: number
|
||||||
validatorList: string[]
|
validatorList: string[]
|
||||||
blockConfirmations: number
|
blockConfirmations: number
|
||||||
@@ -57,17 +54,19 @@ export const useMessageConfirmations = ({
|
|||||||
message,
|
message,
|
||||||
receipt,
|
receipt,
|
||||||
fromHome,
|
fromHome,
|
||||||
timestamp,
|
homeStartBlock,
|
||||||
|
foreignStartBlock,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
validatorList,
|
validatorList,
|
||||||
blockConfirmations
|
blockConfirmations
|
||||||
}: useMessageConfirmationsParams) => {
|
}: useMessageConfirmationsParams) => {
|
||||||
const { home, foreign } = useStateProvider()
|
const { home, foreign } = useStateProvider()
|
||||||
const [confirmations, setConfirmations] = useState<Array<ConfirmationParam>>([])
|
const [confirmations, setConfirmations] = useState<ConfirmationParam[]>([])
|
||||||
const [status, setStatus] = useState(CONFIRMATIONS_STATUS.UNDEFINED)
|
const [status, setStatus] = useState(CONFIRMATIONS_STATUS.UNDEFINED)
|
||||||
const [waitingBlocks, setWaitingBlocks] = useState(false)
|
const [waitingBlocks, setWaitingBlocks] = useState(false)
|
||||||
const [waitingBlocksResolved, setWaitingBlocksResolved] = useState(false)
|
const [waitingBlocksResolved, setWaitingBlocksResolved] = useState(false)
|
||||||
const [signatureCollected, setSignatureCollected] = useState(false)
|
const [signatureCollected, setSignatureCollected] = useState<boolean | string[]>(false)
|
||||||
|
const [executionEventsFetched, setExecutionEventsFetched] = useState(false)
|
||||||
const [collectedSignaturesEvent, setCollectedSignaturesEvent] = useState<Maybe<EventData>>(null)
|
const [collectedSignaturesEvent, setCollectedSignaturesEvent] = useState<Maybe<EventData>>(null)
|
||||||
const [executionData, setExecutionData] = useState<ExecutionData>({
|
const [executionData, setExecutionData] = useState<ExecutionData>({
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
||||||
@@ -83,155 +82,188 @@ export const useMessageConfirmations = ({
|
|||||||
const [pendingConfirmations, setPendingConfirmations] = useState(false)
|
const [pendingConfirmations, setPendingConfirmations] = useState(false)
|
||||||
const [pendingExecution, setPendingExecution] = useState(false)
|
const [pendingExecution, setPendingExecution] = useState(false)
|
||||||
|
|
||||||
const existsConfirmation = (confirmationArray: ConfirmationParam[]) => {
|
const existsConfirmation = (confirmationArray: ConfirmationParam[]) =>
|
||||||
const filteredList = confirmationArray.filter(
|
confirmationArray.some(
|
||||||
c => c.status !== VALIDATOR_CONFIRMATION_STATUS.UNDEFINED && c.status !== VALIDATOR_CONFIRMATION_STATUS.WAITING
|
c => c.status !== VALIDATOR_CONFIRMATION_STATUS.UNDEFINED && c.status !== VALIDATOR_CONFIRMATION_STATUS.WAITING
|
||||||
)
|
)
|
||||||
return filteredList.length > 0
|
|
||||||
}
|
// start watching blocks at the start
|
||||||
|
useEffect(
|
||||||
|
() => {
|
||||||
|
if (!home.web3 || !foreign.web3) return
|
||||||
|
|
||||||
|
homeBlockNumberProvider.start(home.web3)
|
||||||
|
foreignBlockNumberProvider.start(foreign.web3)
|
||||||
|
},
|
||||||
|
[foreign.web3, home.web3]
|
||||||
|
)
|
||||||
|
|
||||||
// Check if the validators are waiting for block confirmations to verify the message
|
// Check if the validators are waiting for block confirmations to verify the message
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (!receipt || !blockConfirmations) return
|
if (!receipt || !blockConfirmations || waitingBlocksResolved) return
|
||||||
|
|
||||||
const subscriptions: Array<number> = []
|
let timeoutId: number
|
||||||
|
|
||||||
const unsubscribe = () => {
|
|
||||||
subscriptions.forEach(s => {
|
|
||||||
clearTimeout(s)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const blockProvider = fromHome ? homeBlockNumberProvider : foreignBlockNumberProvider
|
const blockProvider = fromHome ? homeBlockNumberProvider : foreignBlockNumberProvider
|
||||||
const interval = fromHome ? HOME_RPC_POLLING_INTERVAL : FOREIGN_RPC_POLLING_INTERVAL
|
const interval = fromHome ? HOME_RPC_POLLING_INTERVAL : FOREIGN_RPC_POLLING_INTERVAL
|
||||||
const web3 = fromHome ? home.web3 : foreign.web3
|
|
||||||
blockProvider.start(web3)
|
|
||||||
|
|
||||||
const targetBlock = receipt.blockNumber + blockConfirmations
|
const targetBlock = receipt.blockNumber + blockConfirmations
|
||||||
|
const validatorsWaiting = validatorList.map(validator => ({
|
||||||
|
validator,
|
||||||
|
status: VALIDATOR_CONFIRMATION_STATUS.WAITING,
|
||||||
|
txHash: '',
|
||||||
|
timestamp: 0
|
||||||
|
}))
|
||||||
|
|
||||||
checkSignaturesWaitingForBLocks(
|
const checkSignaturesWaitingForBLocks = () => {
|
||||||
targetBlock,
|
const currentBlock = blockProvider.get()
|
||||||
setWaitingBlocks,
|
|
||||||
setWaitingBlocksResolved,
|
|
||||||
validatorList,
|
|
||||||
setConfirmations,
|
|
||||||
blockProvider,
|
|
||||||
interval,
|
|
||||||
subscriptions
|
|
||||||
)
|
|
||||||
|
|
||||||
return () => {
|
if (currentBlock && currentBlock >= targetBlock) {
|
||||||
unsubscribe()
|
setWaitingBlocksResolved(true)
|
||||||
blockProvider.stop()
|
setWaitingBlocks(false)
|
||||||
|
} else if (currentBlock) {
|
||||||
|
setWaitingBlocks(true)
|
||||||
|
setConfirmations(validatorsWaiting)
|
||||||
|
timeoutId = setTimeout(checkSignaturesWaitingForBLocks, interval)
|
||||||
|
} else {
|
||||||
|
timeoutId = setTimeout(checkSignaturesWaitingForBLocks, 500)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkSignaturesWaitingForBLocks()
|
||||||
|
|
||||||
|
return () => clearTimeout(timeoutId)
|
||||||
},
|
},
|
||||||
[blockConfirmations, foreign.web3, fromHome, validatorList, home.web3, receipt]
|
[blockConfirmations, fromHome, receipt, validatorList, waitingBlocksResolved]
|
||||||
)
|
)
|
||||||
|
|
||||||
// The collected signature event is only fetched once the signatures are collected on tx from home to foreign, to calculate if
|
// The collected signature event is only fetched once the signatures are collected on tx from home to foreign, to calculate if
|
||||||
// the execution tx on the foreign network is waiting for block confirmations
|
// the execution tx on the foreign network is waiting for block confirmations
|
||||||
// This is executed if the message is in Home to Foreign direction only
|
// This is executed if the message is in Home to Foreign direction only
|
||||||
|
const hasCollectedSignatures = !!signatureCollected // true or string[]
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (!fromHome || !receipt || !home.web3 || !signatureCollected) return
|
if (!fromHome || !receipt || !home.web3 || !home.bridgeContract || !hasCollectedSignatures) return
|
||||||
|
|
||||||
const subscriptions: Array<number> = []
|
let timeoutId: number
|
||||||
|
let isCancelled = false
|
||||||
|
|
||||||
const unsubscribe = () => {
|
const messageHash = home.web3.utils.soliditySha3Raw(message.data)
|
||||||
subscriptions.forEach(s => {
|
const contract = home.bridgeContract
|
||||||
clearTimeout(s)
|
|
||||||
})
|
const getCollectedSignaturesEvent = async (fromBlock: number, toBlock: number) => {
|
||||||
|
const currentBlock = homeBlockNumberProvider.get()
|
||||||
|
|
||||||
|
if (currentBlock) {
|
||||||
|
// prevent errors if the toBlock parameter is bigger than the latest
|
||||||
|
const securedToBlock = toBlock >= currentBlock ? currentBlock : toBlock
|
||||||
|
const events = await contract.getPastEvents('CollectedSignatures', {
|
||||||
|
fromBlock,
|
||||||
|
toBlock: securedToBlock
|
||||||
|
})
|
||||||
|
const event = events.find(e => e.returnValues.messageHash === messageHash)
|
||||||
|
if (event) {
|
||||||
|
setCollectedSignaturesEvent(event)
|
||||||
|
} else if (!isCancelled) {
|
||||||
|
timeoutId = setTimeout(() => getCollectedSignaturesEvent(securedToBlock, securedToBlock + BLOCK_RANGE), 500)
|
||||||
|
}
|
||||||
|
} else if (!isCancelled) {
|
||||||
|
timeoutId = setTimeout(() => getCollectedSignaturesEvent(fromBlock, toBlock), 500)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
homeBlockNumberProvider.start(home.web3)
|
getCollectedSignaturesEvent(receipt.blockNumber, receipt.blockNumber + BLOCK_RANGE)
|
||||||
|
|
||||||
const fromBlock = receipt.blockNumber
|
|
||||||
const toBlock = fromBlock + BLOCK_RANGE
|
|
||||||
const messageHash = home.web3.utils.soliditySha3Raw(message.data)
|
|
||||||
|
|
||||||
getCollectedSignaturesEvent(
|
|
||||||
home.web3,
|
|
||||||
home.bridgeContract,
|
|
||||||
fromBlock,
|
|
||||||
toBlock,
|
|
||||||
messageHash,
|
|
||||||
setCollectedSignaturesEvent,
|
|
||||||
subscriptions
|
|
||||||
)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
unsubscribe()
|
clearTimeout(timeoutId)
|
||||||
homeBlockNumberProvider.stop()
|
isCancelled = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[fromHome, home.bridgeContract, home.web3, message.data, receipt, signatureCollected]
|
[fromHome, home.bridgeContract, home.web3, message.data, receipt, hasCollectedSignatures]
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check if the responsible validator is waiting for block confirmations to execute the message on foreign network
|
// Check if the responsible validator is waiting for block confirmations to execute the message on foreign network
|
||||||
// This is executed if the message is in Home to Foreign direction only
|
// This is executed if the message is in Home to Foreign direction only
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (!fromHome || !home.web3 || !receipt || !collectedSignaturesEvent || !blockConfirmations) return
|
if (!fromHome || !home.web3 || !collectedSignaturesEvent || !blockConfirmations) return
|
||||||
|
if (waitingBlocksForExecutionResolved) return
|
||||||
|
|
||||||
const subscriptions: Array<number> = []
|
let timeoutId: number
|
||||||
|
|
||||||
const unsubscribe = () => {
|
|
||||||
subscriptions.forEach(s => {
|
|
||||||
clearTimeout(s)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
homeBlockNumberProvider.start(home.web3)
|
|
||||||
const targetBlock = collectedSignaturesEvent.blockNumber + blockConfirmations
|
const targetBlock = collectedSignaturesEvent.blockNumber + blockConfirmations
|
||||||
|
|
||||||
checkWaitingBlocksForExecution(
|
const checkWaitingBlocksForExecution = () => {
|
||||||
homeBlockNumberProvider,
|
const currentBlock = homeBlockNumberProvider.get()
|
||||||
HOME_RPC_POLLING_INTERVAL,
|
|
||||||
targetBlock,
|
|
||||||
collectedSignaturesEvent,
|
|
||||||
setWaitingBlocksForExecution,
|
|
||||||
setWaitingBlocksForExecutionResolved,
|
|
||||||
setExecutionData,
|
|
||||||
subscriptions
|
|
||||||
)
|
|
||||||
|
|
||||||
return () => {
|
if (currentBlock && currentBlock >= targetBlock) {
|
||||||
unsubscribe()
|
const undefinedExecutionState = {
|
||||||
homeBlockNumberProvider.stop()
|
status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
||||||
|
validator: collectedSignaturesEvent.returnValues.authorityResponsibleForRelay,
|
||||||
|
txHash: '',
|
||||||
|
timestamp: 0,
|
||||||
|
executionResult: false
|
||||||
|
}
|
||||||
|
setExecutionData(
|
||||||
|
(data: any) =>
|
||||||
|
data.status === VALIDATOR_CONFIRMATION_STATUS.UNDEFINED ||
|
||||||
|
data.status === VALIDATOR_CONFIRMATION_STATUS.WAITING
|
||||||
|
? undefinedExecutionState
|
||||||
|
: data
|
||||||
|
)
|
||||||
|
setWaitingBlocksForExecutionResolved(true)
|
||||||
|
setWaitingBlocksForExecution(false)
|
||||||
|
} else if (currentBlock) {
|
||||||
|
setWaitingBlocksForExecution(true)
|
||||||
|
const waitingExecutionState = {
|
||||||
|
status: VALIDATOR_CONFIRMATION_STATUS.WAITING,
|
||||||
|
validator: collectedSignaturesEvent.returnValues.authorityResponsibleForRelay,
|
||||||
|
txHash: '',
|
||||||
|
timestamp: 0,
|
||||||
|
executionResult: false
|
||||||
|
}
|
||||||
|
setExecutionData(
|
||||||
|
(data: any) =>
|
||||||
|
data.status === VALIDATOR_CONFIRMATION_STATUS.UNDEFINED ||
|
||||||
|
data.status === VALIDATOR_CONFIRMATION_STATUS.WAITING
|
||||||
|
? waitingExecutionState
|
||||||
|
: data
|
||||||
|
)
|
||||||
|
timeoutId = setTimeout(() => checkWaitingBlocksForExecution(), HOME_RPC_POLLING_INTERVAL)
|
||||||
|
} else {
|
||||||
|
timeoutId = setTimeout(() => checkWaitingBlocksForExecution(), 500)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkWaitingBlocksForExecution()
|
||||||
|
|
||||||
|
return () => clearTimeout(timeoutId)
|
||||||
},
|
},
|
||||||
[collectedSignaturesEvent, fromHome, blockConfirmations, home.web3, receipt]
|
[collectedSignaturesEvent, fromHome, blockConfirmations, home.web3, waitingBlocksForExecutionResolved]
|
||||||
)
|
)
|
||||||
|
|
||||||
// Checks if validators verified the message
|
// Checks if validators verified the message
|
||||||
// To avoid making extra requests, this is only executed when validators finished waiting for blocks confirmations
|
// To avoid making extra requests, this is only executed when validators finished waiting for blocks confirmations
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (!waitingBlocksResolved || !timestamp || !requiredSignatures) return
|
if (!waitingBlocksResolved || !homeStartBlock || !requiredSignatures || !home.web3 || !home.bridgeContract) return
|
||||||
|
if (!validatorList || !validatorList.length) return
|
||||||
|
|
||||||
const subscriptions: Array<number> = []
|
let timeoutId: number
|
||||||
|
let isCancelled = false
|
||||||
const unsubscribe = () => {
|
|
||||||
subscriptions.forEach(s => {
|
|
||||||
clearTimeout(s)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const confirmationContractMethod = fromHome ? getMessagesSigned : getAffirmationsSigned
|
|
||||||
|
|
||||||
getConfirmationsForTx(
|
getConfirmationsForTx(
|
||||||
message.data,
|
message.data,
|
||||||
home.web3,
|
home.web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
home.bridgeContract,
|
home.bridgeContract,
|
||||||
confirmationContractMethod,
|
fromHome,
|
||||||
setConfirmations,
|
setConfirmations,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
id => (timeoutId = id),
|
||||||
subscriptions,
|
() => isCancelled,
|
||||||
timestamp,
|
homeStartBlock,
|
||||||
getValidatorFailedTransactionsForMessage,
|
getValidatorFailedTransactionsForMessage,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
getValidatorPendingTransactionsForMessage,
|
getValidatorPendingTransactionsForMessage,
|
||||||
@@ -240,7 +272,8 @@ export const useMessageConfirmations = ({
|
|||||||
)
|
)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
unsubscribe()
|
clearTimeout(timeoutId)
|
||||||
|
isCancelled = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@@ -251,7 +284,7 @@ export const useMessageConfirmations = ({
|
|||||||
home.bridgeContract,
|
home.bridgeContract,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
waitingBlocksResolved,
|
waitingBlocksResolved,
|
||||||
timestamp
|
homeStartBlock
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -262,38 +295,34 @@ export const useMessageConfirmations = ({
|
|||||||
() => {
|
() => {
|
||||||
if ((fromHome && !waitingBlocksForExecutionResolved) || (!fromHome && !waitingBlocksResolved)) return
|
if ((fromHome && !waitingBlocksForExecutionResolved) || (!fromHome && !waitingBlocksResolved)) return
|
||||||
|
|
||||||
const subscriptions: Array<number> = []
|
|
||||||
|
|
||||||
const unsubscribe = () => {
|
|
||||||
subscriptions.forEach(s => {
|
|
||||||
clearTimeout(s)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const contractEvent = fromHome ? 'RelayedMessage' : 'AffirmationCompleted'
|
|
||||||
const bridgeContract = fromHome ? foreign.bridgeContract : home.bridgeContract
|
const bridgeContract = fromHome ? foreign.bridgeContract : home.bridgeContract
|
||||||
const providedWeb3 = fromHome ? foreign.web3 : home.web3
|
const web3 = fromHome ? foreign.web3 : home.web3
|
||||||
const interval = fromHome ? FOREIGN_RPC_POLLING_INTERVAL : HOME_RPC_POLLING_INTERVAL
|
const startBlock = fromHome ? foreignStartBlock : homeStartBlock
|
||||||
|
if (!startBlock || !bridgeContract || !web3) return
|
||||||
|
|
||||||
|
let timeoutId: number
|
||||||
|
let isCancelled = false
|
||||||
|
|
||||||
getFinalizationEvent(
|
getFinalizationEvent(
|
||||||
|
fromHome,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
contractEvent,
|
web3,
|
||||||
providedWeb3,
|
|
||||||
setExecutionData,
|
setExecutionData,
|
||||||
waitingBlocksResolved,
|
|
||||||
message,
|
message,
|
||||||
interval,
|
id => (timeoutId = id),
|
||||||
subscriptions,
|
() => isCancelled,
|
||||||
timestamp,
|
startBlock,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getExecutionFailedTransactionForMessage,
|
getExecutionFailedTransactionForMessage,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getExecutionPendingTransactionsForMessage,
|
getExecutionPendingTransactionsForMessage,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
|
setExecutionEventsFetched
|
||||||
)
|
)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
unsubscribe()
|
clearTimeout(timeoutId)
|
||||||
|
isCancelled = true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
@@ -305,8 +334,9 @@ export const useMessageConfirmations = ({
|
|||||||
home.web3,
|
home.web3,
|
||||||
waitingBlocksResolved,
|
waitingBlocksResolved,
|
||||||
waitingBlocksForExecutionResolved,
|
waitingBlocksForExecutionResolved,
|
||||||
timestamp,
|
collectedSignaturesEvent,
|
||||||
collectedSignaturesEvent
|
foreignStartBlock,
|
||||||
|
homeStartBlock
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -318,6 +348,9 @@ export const useMessageConfirmations = ({
|
|||||||
? CONFIRMATIONS_STATUS.SUCCESS
|
? CONFIRMATIONS_STATUS.SUCCESS
|
||||||
: CONFIRMATIONS_STATUS.SUCCESS_MESSAGE_FAILED
|
: CONFIRMATIONS_STATUS.SUCCESS_MESSAGE_FAILED
|
||||||
setStatus(newStatus)
|
setStatus(newStatus)
|
||||||
|
|
||||||
|
foreignBlockNumberProvider.stop()
|
||||||
|
homeBlockNumberProvider.stop()
|
||||||
} else if (signatureCollected) {
|
} else if (signatureCollected) {
|
||||||
if (fromHome) {
|
if (fromHome) {
|
||||||
if (waitingBlocksForExecution) {
|
if (waitingBlocksForExecution) {
|
||||||
@@ -369,6 +402,9 @@ export const useMessageConfirmations = ({
|
|||||||
status,
|
status,
|
||||||
signatureCollected,
|
signatureCollected,
|
||||||
executionData,
|
executionData,
|
||||||
waitingBlocksResolved
|
setExecutionData,
|
||||||
|
waitingBlocksResolved,
|
||||||
|
executionEventsFetched,
|
||||||
|
setPendingExecution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,40 +11,23 @@ export const useTransactionFinder = ({ txHash, web3 }: { txHash: string; web3: M
|
|||||||
() => {
|
() => {
|
||||||
if (!txHash || !web3) return
|
if (!txHash || !web3) return
|
||||||
|
|
||||||
const subscriptions: number[] = []
|
let timeoutId: number
|
||||||
|
|
||||||
const unsubscribe = () => {
|
const getReceipt = async () => {
|
||||||
subscriptions.forEach(s => {
|
|
||||||
clearTimeout(s)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const getReceipt = async (
|
|
||||||
web3: Web3,
|
|
||||||
txHash: string,
|
|
||||||
setReceipt: Function,
|
|
||||||
setStatus: Function,
|
|
||||||
subscriptions: number[]
|
|
||||||
) => {
|
|
||||||
const txReceipt = await web3.eth.getTransactionReceipt(txHash)
|
const txReceipt = await web3.eth.getTransactionReceipt(txHash)
|
||||||
setReceipt(txReceipt)
|
setReceipt(txReceipt)
|
||||||
|
|
||||||
if (!txReceipt) {
|
if (!txReceipt) {
|
||||||
setStatus(TRANSACTION_STATUS.NOT_FOUND)
|
setStatus(TRANSACTION_STATUS.NOT_FOUND)
|
||||||
const timeoutId = setTimeout(
|
timeoutId = setTimeout(getReceipt, HOME_RPC_POLLING_INTERVAL)
|
||||||
() => getReceipt(web3, txHash, setReceipt, setStatus, subscriptions),
|
|
||||||
HOME_RPC_POLLING_INTERVAL
|
|
||||||
)
|
|
||||||
subscriptions.push(timeoutId)
|
|
||||||
} else {
|
} else {
|
||||||
setStatus(TRANSACTION_STATUS.FOUND)
|
setStatus(TRANSACTION_STATUS.FOUND)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getReceipt(web3, txHash, setReceipt, setStatus, subscriptions)
|
getReceipt()
|
||||||
return () => {
|
|
||||||
unsubscribe()
|
return () => clearTimeout(timeoutId)
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[txHash, web3]
|
[txHash, web3]
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -31,19 +31,14 @@ export const useTransactionStatus = ({
|
|||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
const subscriptions: Array<number> = []
|
if (!chainId || !txHash || !home.chainId || !foreign.chainId || !home.web3 || !foreign.web3) return
|
||||||
|
const isHome = chainId === home.chainId
|
||||||
|
const web3 = isHome ? home.web3 : foreign.web3
|
||||||
|
|
||||||
const unsubscribe = () => {
|
let timeoutId: number
|
||||||
subscriptions.forEach(s => {
|
|
||||||
clearTimeout(s)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const getReceipt = async () => {
|
const getReceipt = async () => {
|
||||||
if (!chainId || !txHash || !home.chainId || !foreign.chainId || !home.web3 || !foreign.web3) return
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
const isHome = chainId === home.chainId
|
|
||||||
const web3 = isHome ? home.web3 : foreign.web3
|
|
||||||
|
|
||||||
let txReceipt
|
let txReceipt
|
||||||
|
|
||||||
@@ -59,8 +54,7 @@ export const useTransactionStatus = ({
|
|||||||
setStatus(TRANSACTION_STATUS.NOT_FOUND)
|
setStatus(TRANSACTION_STATUS.NOT_FOUND)
|
||||||
setDescription(getTransactionStatusDescription(TRANSACTION_STATUS.NOT_FOUND))
|
setDescription(getTransactionStatusDescription(TRANSACTION_STATUS.NOT_FOUND))
|
||||||
setMessages([{ id: txHash, data: '' }])
|
setMessages([{ id: txHash, data: '' }])
|
||||||
const timeoutId = setTimeout(() => getReceipt(), HOME_RPC_POLLING_INTERVAL)
|
timeoutId = setTimeout(() => getReceipt(), HOME_RPC_POLLING_INTERVAL)
|
||||||
subscriptions.push(timeoutId)
|
|
||||||
} else {
|
} else {
|
||||||
const blockNumber = txReceipt.blockNumber
|
const blockNumber = txReceipt.blockNumber
|
||||||
const block = await getBlock(web3, blockNumber)
|
const block = await getBlock(web3, blockNumber)
|
||||||
@@ -70,9 +64,9 @@ export const useTransactionStatus = ({
|
|||||||
if (txReceipt.status) {
|
if (txReceipt.status) {
|
||||||
let bridgeMessages: Array<MessageObject>
|
let bridgeMessages: Array<MessageObject>
|
||||||
if (isHome) {
|
if (isHome) {
|
||||||
bridgeMessages = getHomeMessagesFromReceipt(txReceipt, home.web3, home.bridgeAddress)
|
bridgeMessages = getHomeMessagesFromReceipt(txReceipt, web3, home.bridgeAddress)
|
||||||
} else {
|
} else {
|
||||||
bridgeMessages = getForeignMessagesFromReceipt(txReceipt, foreign.web3, foreign.bridgeAddress)
|
bridgeMessages = getForeignMessagesFromReceipt(txReceipt, web3, foreign.bridgeAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bridgeMessages.length === 0) {
|
if (bridgeMessages.length === 0) {
|
||||||
@@ -98,14 +92,9 @@ export const useTransactionStatus = ({
|
|||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unsubscribe from previous txHash
|
|
||||||
unsubscribe()
|
|
||||||
|
|
||||||
getReceipt()
|
getReceipt()
|
||||||
return () => {
|
|
||||||
// unsubscribe when unmount component
|
return () => clearTimeout(timeoutId)
|
||||||
unsubscribe()
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
txHash,
|
txHash,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { BRIDGE_VALIDATORS_ABI } from '../abis'
|
|||||||
import { useStateProvider } from '../state/StateProvider'
|
import { useStateProvider } from '../state/StateProvider'
|
||||||
import { TransactionReceipt } from 'web3-eth'
|
import { TransactionReceipt } from 'web3-eth'
|
||||||
import { foreignSnapshotProvider, homeSnapshotProvider, SnapshotProvider } from '../services/SnapshotProvider'
|
import { foreignSnapshotProvider, homeSnapshotProvider, SnapshotProvider } from '../services/SnapshotProvider'
|
||||||
|
import { FOREIGN_EXPLORER_API, HOME_EXPLORER_API } from '../config/constants'
|
||||||
|
|
||||||
export interface useValidatorContractParams {
|
export interface useValidatorContractParams {
|
||||||
fromHome: boolean
|
fromHome: boolean
|
||||||
@@ -30,10 +31,12 @@ export const useValidatorContract = ({ receipt, fromHome }: useValidatorContract
|
|||||||
contract: Maybe<Contract>,
|
contract: Maybe<Contract>,
|
||||||
receipt: TransactionReceipt,
|
receipt: TransactionReceipt,
|
||||||
setResult: Function,
|
setResult: Function,
|
||||||
snapshotProvider: SnapshotProvider
|
snapshotProvider: SnapshotProvider,
|
||||||
|
web3: Web3,
|
||||||
|
api: string
|
||||||
) => {
|
) => {
|
||||||
if (!contract) return
|
if (!contract) return
|
||||||
const result = await getRequiredSignatures(contract, receipt.blockNumber, snapshotProvider)
|
const result = await getRequiredSignatures(contract, receipt.blockNumber, snapshotProvider, web3, api)
|
||||||
setResult(result)
|
setResult(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,32 +44,35 @@ export const useValidatorContract = ({ receipt, fromHome }: useValidatorContract
|
|||||||
contract: Maybe<Contract>,
|
contract: Maybe<Contract>,
|
||||||
receipt: TransactionReceipt,
|
receipt: TransactionReceipt,
|
||||||
setResult: Function,
|
setResult: Function,
|
||||||
snapshotProvider: SnapshotProvider
|
snapshotProvider: SnapshotProvider,
|
||||||
|
web3: Web3,
|
||||||
|
api: string
|
||||||
) => {
|
) => {
|
||||||
if (!contract) return
|
if (!contract) return
|
||||||
const result = await getValidatorList(contract, receipt.blockNumber, snapshotProvider)
|
const result = await getValidatorList(contract, receipt.blockNumber, snapshotProvider, web3, api)
|
||||||
setResult(result)
|
setResult(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const web3 = fromHome ? home.web3 : foreign.web3
|
||||||
|
const api = fromHome ? HOME_EXPLORER_API : FOREIGN_EXPLORER_API
|
||||||
|
const bridgeContract = fromHome ? home.bridgeContract : foreign.bridgeContract
|
||||||
|
const snapshotProvider = fromHome ? homeSnapshotProvider : foreignSnapshotProvider
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
const web3 = fromHome ? home.web3 : foreign.web3
|
|
||||||
const bridgeContract = fromHome ? home.bridgeContract : foreign.bridgeContract
|
|
||||||
|
|
||||||
if (!web3 || !bridgeContract) return
|
if (!web3 || !bridgeContract) return
|
||||||
callValidatorContract(bridgeContract, web3, setValidatorContract)
|
callValidatorContract(bridgeContract, web3, setValidatorContract)
|
||||||
},
|
},
|
||||||
[home.web3, foreign.web3, home.bridgeContract, foreign.bridgeContract, fromHome]
|
[web3, bridgeContract]
|
||||||
)
|
)
|
||||||
|
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (!receipt) return
|
if (!web3 || !receipt) return
|
||||||
const snapshotProvider = fromHome ? homeSnapshotProvider : foreignSnapshotProvider
|
callRequiredSignatures(validatorContract, receipt, setRequiredSignatures, snapshotProvider, web3, api)
|
||||||
callRequiredSignatures(validatorContract, receipt, setRequiredSignatures, snapshotProvider)
|
callValidatorList(validatorContract, receipt, setValidatorList, snapshotProvider, web3, api)
|
||||||
callValidatorList(validatorContract, receipt, setValidatorList, snapshotProvider)
|
|
||||||
},
|
},
|
||||||
[validatorContract, receipt, fromHome]
|
[validatorContract, receipt, web3, snapshotProvider, api]
|
||||||
)
|
)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds'
|
import differenceInMilliseconds from 'date-fns/differenceInMilliseconds'
|
||||||
import { HOME_RPC_POLLING_INTERVAL } from '../config/constants'
|
import { FOREIGN_RPC_POLLING_INTERVAL, HOME_RPC_POLLING_INTERVAL } from '../config/constants'
|
||||||
|
|
||||||
export class BlockNumberProvider {
|
export class BlockNumberProvider {
|
||||||
private running: number
|
private running: number
|
||||||
@@ -61,4 +61,4 @@ export class BlockNumberProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const homeBlockNumberProvider = new BlockNumberProvider(HOME_RPC_POLLING_INTERVAL)
|
export const homeBlockNumberProvider = new BlockNumberProvider(HOME_RPC_POLLING_INTERVAL)
|
||||||
export const foreignBlockNumberProvider = new BlockNumberProvider(HOME_RPC_POLLING_INTERVAL)
|
export const foreignBlockNumberProvider = new BlockNumberProvider(FOREIGN_RPC_POLLING_INTERVAL)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React, { createContext, ReactNode } from 'react'
|
import React, { createContext, ReactNode, useState } from 'react'
|
||||||
import { useNetwork } from '../hooks/useNetwork'
|
import { useNetwork } from '../hooks/useNetwork'
|
||||||
import {
|
import {
|
||||||
HOME_RPC_URL,
|
HOME_RPC_URL,
|
||||||
@@ -25,6 +25,8 @@ export interface StateContext {
|
|||||||
home: BaseNetworkParams
|
home: BaseNetworkParams
|
||||||
foreign: BaseNetworkParams
|
foreign: BaseNetworkParams
|
||||||
loading: boolean
|
loading: boolean
|
||||||
|
error: string
|
||||||
|
setError: Function
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
@@ -42,7 +44,9 @@ const initialState = {
|
|||||||
bridgeAddress: FOREIGN_BRIDGE_ADDRESS,
|
bridgeAddress: FOREIGN_BRIDGE_ADDRESS,
|
||||||
bridgeContract: null
|
bridgeContract: null
|
||||||
},
|
},
|
||||||
loading: true
|
loading: true,
|
||||||
|
error: '',
|
||||||
|
setError: () => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const StateContext = createContext<StateContext>(initialState)
|
const StateContext = createContext<StateContext>(initialState)
|
||||||
@@ -54,6 +58,7 @@ export const StateProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
homeWeb3: homeNetwork.web3,
|
homeWeb3: homeNetwork.web3,
|
||||||
foreignWeb3: foreignNetwork.web3
|
foreignWeb3: foreignNetwork.web3
|
||||||
})
|
})
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
home: {
|
home: {
|
||||||
@@ -68,7 +73,9 @@ export const StateProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
bridgeContract: foreignBridge,
|
bridgeContract: foreignBridge,
|
||||||
...foreignNetwork
|
...foreignNetwork
|
||||||
},
|
},
|
||||||
loading: homeNetwork.loading || foreignNetwork.loading
|
loading: homeNetwork.loading || foreignNetwork.loading,
|
||||||
|
error,
|
||||||
|
setError
|
||||||
}
|
}
|
||||||
|
|
||||||
return <StateContext.Provider value={value}>{children}</StateContext.Provider>
|
return <StateContext.Provider value={value}>{children}</StateContext.Provider>
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ describe('getRequiredBlockConfirmations', () => {
|
|||||||
|
|
||||||
test('Should call requiredBlockConfirmations method if no events present', async () => {
|
test('Should call requiredBlockConfirmations method if no events present', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: () => {
|
getPastEvents: async () => {
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
methods: methodsBuilder('1')
|
methods: methodsBuilder('1')
|
||||||
@@ -37,7 +37,7 @@ describe('getRequiredBlockConfirmations', () => {
|
|||||||
})
|
})
|
||||||
test('Should not call to get events if block number was included in the snapshot', async () => {
|
test('Should not call to get events if block number was included in the snapshot', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => []),
|
getPastEvents: jest.fn().mockImplementation(async () => []),
|
||||||
methods: methodsBuilder('3')
|
methods: methodsBuilder('3')
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ describe('getRequiredBlockConfirmations', () => {
|
|||||||
})
|
})
|
||||||
test('Should call to get events if block number was not included in the snapshot', async () => {
|
test('Should call to get events if block number was not included in the snapshot', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => [
|
getPastEvents: jest.fn().mockImplementation(async () => [
|
||||||
{
|
{
|
||||||
blockNumber: 9,
|
blockNumber: 9,
|
||||||
returnValues: {
|
returnValues: {
|
||||||
@@ -102,7 +102,7 @@ describe('getRequiredBlockConfirmations', () => {
|
|||||||
})
|
})
|
||||||
test('Should use the most updated event', async () => {
|
test('Should use the most updated event', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => [
|
getPastEvents: jest.fn().mockImplementation(async () => [
|
||||||
{
|
{
|
||||||
blockNumber: 9,
|
blockNumber: 9,
|
||||||
returnValues: {
|
returnValues: {
|
||||||
@@ -141,7 +141,7 @@ describe('getRequiredBlockConfirmations', () => {
|
|||||||
describe('getRequiredSignatures', () => {
|
describe('getRequiredSignatures', () => {
|
||||||
test('Should not call to get events if block number was included in the snapshot', async () => {
|
test('Should not call to get events if block number was included in the snapshot', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => [])
|
getPastEvents: jest.fn().mockImplementation(async () => [])
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
|
|
||||||
const snapshotProvider = ({
|
const snapshotProvider = ({
|
||||||
@@ -173,7 +173,7 @@ describe('getRequiredSignatures', () => {
|
|||||||
})
|
})
|
||||||
test('Should call to get events if block number is higher than the snapshot block number', async () => {
|
test('Should call to get events if block number is higher than the snapshot block number', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => [
|
getPastEvents: jest.fn().mockImplementation(async () => [
|
||||||
{
|
{
|
||||||
blockNumber: 15,
|
blockNumber: 15,
|
||||||
returnValues: {
|
returnValues: {
|
||||||
@@ -216,7 +216,7 @@ describe('getRequiredSignatures', () => {
|
|||||||
})
|
})
|
||||||
test('Should use the most updated event before the block number', async () => {
|
test('Should use the most updated event before the block number', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => [
|
getPastEvents: jest.fn().mockImplementation(async () => [
|
||||||
{
|
{
|
||||||
blockNumber: 15,
|
blockNumber: 15,
|
||||||
returnValues: {
|
returnValues: {
|
||||||
@@ -270,7 +270,7 @@ describe('getValidatorList', () => {
|
|||||||
test('Should return the current validator list if no events found', async () => {
|
test('Should return the current validator list if no events found', async () => {
|
||||||
const currentValidators = [validator1, validator2, validator3]
|
const currentValidators = [validator1, validator2, validator3]
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => []),
|
getPastEvents: jest.fn().mockImplementation(async () => []),
|
||||||
methods: methodsBuilder(currentValidators)
|
methods: methodsBuilder(currentValidators)
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
|
|
||||||
@@ -301,7 +301,7 @@ describe('getValidatorList', () => {
|
|||||||
test('If validator was added later from snapshot it should not include it', async () => {
|
test('If validator was added later from snapshot it should not include it', async () => {
|
||||||
const currentValidators = [validator1, validator2, validator3]
|
const currentValidators = [validator1, validator2, validator3]
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => []),
|
getPastEvents: jest.fn().mockImplementation(async () => []),
|
||||||
methods: methodsBuilder(currentValidators)
|
methods: methodsBuilder(currentValidators)
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
|
|
||||||
@@ -340,7 +340,7 @@ describe('getValidatorList', () => {
|
|||||||
test('If validator was added later from chain it should not include it', async () => {
|
test('If validator was added later from chain it should not include it', async () => {
|
||||||
const currentValidators = [validator1, validator2, validator3]
|
const currentValidators = [validator1, validator2, validator3]
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(event => {
|
getPastEvents: jest.fn().mockImplementation(async event => {
|
||||||
if (event === 'ValidatorAdded') {
|
if (event === 'ValidatorAdded') {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@@ -385,7 +385,7 @@ describe('getValidatorList', () => {
|
|||||||
test('If validator was removed later from snapshot it should include it', async () => {
|
test('If validator was removed later from snapshot it should include it', async () => {
|
||||||
const currentValidators = [validator1, validator2]
|
const currentValidators = [validator1, validator2]
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(() => []),
|
getPastEvents: jest.fn().mockImplementation(async () => []),
|
||||||
methods: methodsBuilder(currentValidators)
|
methods: methodsBuilder(currentValidators)
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
|
|
||||||
@@ -424,7 +424,7 @@ describe('getValidatorList', () => {
|
|||||||
test('If validator was removed later from chain it should include it', async () => {
|
test('If validator was removed later from chain it should include it', async () => {
|
||||||
const currentValidators = [validator1, validator2]
|
const currentValidators = [validator1, validator2]
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: jest.fn().mockImplementation(event => {
|
getPastEvents: jest.fn().mockImplementation(async event => {
|
||||||
if (event === 'ValidatorRemoved') {
|
if (event === 'ValidatorRemoved') {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,19 +17,33 @@ const otherAddress = '0xD4075FB57fCf038bFc702c915Ef9592534bED5c1'
|
|||||||
|
|
||||||
describe('getFailedTransactions', () => {
|
describe('getFailedTransactions', () => {
|
||||||
test('should only return failed transactions', async () => {
|
test('should only return failed transactions', async () => {
|
||||||
const transactions = [{ isError: '0' }, { isError: '1' }, { isError: '0' }, { isError: '1' }, { isError: '1' }]
|
const to = otherAddress
|
||||||
|
const transactions = [
|
||||||
|
{ isError: '0', to },
|
||||||
|
{ isError: '1', to },
|
||||||
|
{ isError: '0', to },
|
||||||
|
{ isError: '1', to },
|
||||||
|
{ isError: '1', to }
|
||||||
|
]
|
||||||
|
|
||||||
const fetchAccountTransactions = jest.fn().mockImplementation(() => transactions)
|
const fetchAccountTransactions = jest.fn().mockImplementation(() => transactions)
|
||||||
const result = await getFailedTransactions('', '', 0, 1, '', fetchAccountTransactions)
|
const result = await getFailedTransactions('', to, 0, 1, '', fetchAccountTransactions)
|
||||||
expect(result.length).toEqual(3)
|
expect(result.length).toEqual(3)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('getSuccessTransactions', () => {
|
describe('getSuccessTransactions', () => {
|
||||||
test('should only return success transactions', async () => {
|
test('should only return success transactions', async () => {
|
||||||
const transactions = [{ isError: '0' }, { isError: '1' }, { isError: '0' }, { isError: '1' }, { isError: '1' }]
|
const to = otherAddress
|
||||||
|
const transactions = [
|
||||||
|
{ isError: '0', to },
|
||||||
|
{ isError: '1', to },
|
||||||
|
{ isError: '0', to },
|
||||||
|
{ isError: '1', to },
|
||||||
|
{ isError: '1', to }
|
||||||
|
]
|
||||||
|
|
||||||
const fetchAccountTransactions = jest.fn().mockImplementation(() => transactions)
|
const fetchAccountTransactions = jest.fn().mockImplementation(() => transactions)
|
||||||
const result = await getSuccessTransactions('', '', 0, 1, '', fetchAccountTransactions)
|
const result = await getSuccessTransactions('', to, 0, 1, '', fetchAccountTransactions)
|
||||||
expect(result.length).toEqual(2)
|
expect(result.length).toEqual(2)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -74,8 +88,8 @@ describe('getExecutionFailedTransactionForMessage', () => {
|
|||||||
account: '',
|
account: '',
|
||||||
to: '',
|
to: '',
|
||||||
messageData,
|
messageData,
|
||||||
startTimestamp: 0,
|
startBlock: 0,
|
||||||
endTimestamp: 1
|
endBlock: 1
|
||||||
},
|
},
|
||||||
fetchAccountTransactions
|
fetchAccountTransactions
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { BasicConfirmationParam } from '../../hooks/useMessageConfirmations'
|
|||||||
|
|
||||||
jest.mock('../validatorConfirmationHelpers')
|
jest.mock('../validatorConfirmationHelpers')
|
||||||
|
|
||||||
const getValidatorSuccessTransaction = helpers.getValidatorSuccessTransaction as jest.Mock<any>
|
const getSuccessExecutionTransaction = helpers.getSuccessExecutionTransaction as jest.Mock<any>
|
||||||
const getValidatorConfirmation = helpers.getValidatorConfirmation as jest.Mock<any>
|
const getValidatorConfirmation = helpers.getValidatorConfirmation as jest.Mock<any>
|
||||||
const getValidatorFailedTransaction = helpers.getValidatorFailedTransaction as jest.Mock<any>
|
const getValidatorFailedTransaction = helpers.getValidatorFailedTransaction as jest.Mock<any>
|
||||||
const getValidatorPendingTransaction = helpers.getValidatorPendingTransaction as jest.Mock<any>
|
const getValidatorPendingTransaction = helpers.getValidatorPendingTransaction as jest.Mock<any>
|
||||||
@@ -24,10 +24,17 @@ const validator1 = '0x45b96809336A8b714BFbdAB3E4B5e0fe5d839908'
|
|||||||
const validator2 = '0xAe8bFfc8BBc6AAa9E21ED1E4e4957fe798BEA25f'
|
const validator2 = '0xAe8bFfc8BBc6AAa9E21ED1E4e4957fe798BEA25f'
|
||||||
const validator3 = '0x285A6eB779be4db94dA65e2F3518B1c5F0f71244'
|
const validator3 = '0x285A6eB779be4db94dA65e2F3518B1c5F0f71244'
|
||||||
const validatorList = [validator1, validator2, validator3]
|
const validatorList = [validator1, validator2, validator3]
|
||||||
const bridgeContract = {} as Contract
|
const signature =
|
||||||
const confirmationContractMethod = () => {}
|
'0x519d704bceed17423daa79c20531cc34fc27a4be6e53fc5069a8023019188ca4519d704bceed17423daa79c20531cc34fc27a4be6e53fc5069a8023019188ca4'
|
||||||
|
const bridgeContract = {
|
||||||
|
methods: {
|
||||||
|
signature: () => ({
|
||||||
|
call: () => signature
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} as Contract
|
||||||
const requiredSignatures = 2
|
const requiredSignatures = 2
|
||||||
const waitingBlocksResolved = true
|
const isCancelled = () => false
|
||||||
let subscriptions: Array<number> = []
|
let subscriptions: Array<number> = []
|
||||||
const timestamp = 1594045859
|
const timestamp = 1594045859
|
||||||
const getFailedTransactions = (): Promise<APITransaction[]> => Promise.resolve([])
|
const getFailedTransactions = (): Promise<APITransaction[]> => Promise.resolve([])
|
||||||
@@ -42,7 +49,7 @@ const unsubscribe = () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
// Clear all instances and calls to constructor and all methods:
|
// Clear all instances and calls to constructor and all methods:
|
||||||
getValidatorSuccessTransaction.mockClear()
|
getSuccessExecutionTransaction.mockClear()
|
||||||
getValidatorConfirmation.mockClear()
|
getValidatorConfirmation.mockClear()
|
||||||
getValidatorFailedTransaction.mockClear()
|
getValidatorFailedTransaction.mockClear()
|
||||||
getValidatorPendingTransaction.mockClear()
|
getValidatorPendingTransaction.mockClear()
|
||||||
@@ -54,7 +61,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
validator,
|
validator,
|
||||||
status: validator !== validator3 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
status: validator !== validator3 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
getSuccessExecutionTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: '',
|
txHash: '',
|
||||||
@@ -83,12 +90,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -102,9 +109,10 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(subscriptions.length).toEqual(1)
|
expect(subscriptions.length).toEqual(1)
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(2)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(2)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(true)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(true)
|
||||||
|
expect(setSignatureCollected.mock.calls[1][0]).toEqual([signature, signature])
|
||||||
|
|
||||||
expect(getValidatorFailedTransaction).toBeCalledTimes(1)
|
expect(getValidatorFailedTransaction).toBeCalledTimes(1)
|
||||||
expect(setFailedConfirmations).toBeCalledTimes(1)
|
expect(setFailedConfirmations).toBeCalledTimes(1)
|
||||||
@@ -114,14 +122,16 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations).toBeCalledTimes(1)
|
expect(setPendingConfirmations).toBeCalledTimes(1)
|
||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
expect(setResult.mock.calls[0][0]()).toEqual(
|
const res1 = setResult.mock.calls[0][0]()
|
||||||
|
const res2 = setResult.mock.calls[1][0](res1)
|
||||||
|
expect(res1).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[1][0]).toEqual(
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
@@ -134,7 +144,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
validator,
|
validator,
|
||||||
status: validator === validator3 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
status: validator === validator3 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
getSuccessExecutionTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: '',
|
txHash: '',
|
||||||
@@ -163,12 +173,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -179,9 +189,9 @@ describe('getConfirmationsForTx', () => {
|
|||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(1)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
@@ -198,7 +208,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
validator,
|
validator,
|
||||||
status: validator !== validator3 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
status: validator !== validator3 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
getSuccessExecutionTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: validatorData.validator !== validator3 ? '0x123' : '',
|
txHash: validatorData.validator !== validator3 ? '0x123' : '',
|
||||||
@@ -227,12 +237,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -244,11 +254,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(subscriptions.length).toEqual(0)
|
expect(subscriptions.length).toEqual(0)
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(3)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(2)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(true)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(true)
|
||||||
|
expect(setSignatureCollected.mock.calls[1][0]).toEqual([signature, signature])
|
||||||
|
|
||||||
expect(getValidatorFailedTransaction).toBeCalledTimes(1)
|
expect(getValidatorFailedTransaction).toBeCalledTimes(1)
|
||||||
expect(setFailedConfirmations).toBeCalledTimes(1)
|
expect(setFailedConfirmations).toBeCalledTimes(1)
|
||||||
@@ -258,14 +269,24 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations).toBeCalledTimes(1)
|
expect(setPendingConfirmations).toBeCalledTimes(1)
|
||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
expect(setResult.mock.calls[0][0]()).toEqual(
|
const res1 = setResult.mock.calls[0][0]()
|
||||||
|
const res2 = setResult.mock.calls[1][0](res1)
|
||||||
|
const res3 = setResult.mock.calls[2][0](res2)
|
||||||
|
expect(res1).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[1][0]).toEqual(
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
@@ -283,7 +304,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
? VALIDATOR_CONFIRMATION_STATUS.SUCCESS
|
? VALIDATOR_CONFIRMATION_STATUS.SUCCESS
|
||||||
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
getSuccessExecutionTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: validatorData.validator !== validator3 && validatorData.validator !== validator4 ? '0x123' : '',
|
txHash: validatorData.validator !== validator3 && validatorData.validator !== validator4 ? '0x123' : '',
|
||||||
@@ -315,12 +336,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -332,11 +353,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(subscriptions.length).toEqual(0)
|
expect(subscriptions.length).toEqual(0)
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(4)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(2)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(true)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(true)
|
||||||
|
expect(setSignatureCollected.mock.calls[1][0]).toEqual([signature, signature])
|
||||||
|
|
||||||
expect(getValidatorFailedTransaction).toBeCalledTimes(1)
|
expect(getValidatorFailedTransaction).toBeCalledTimes(1)
|
||||||
expect(setFailedConfirmations).toBeCalledTimes(1)
|
expect(setFailedConfirmations).toBeCalledTimes(1)
|
||||||
@@ -346,7 +368,27 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations).toBeCalledTimes(1)
|
expect(setPendingConfirmations).toBeCalledTimes(1)
|
||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
expect(setResult.mock.calls[0][0]()).toEqual(
|
const res1 = setResult.mock.calls[0][0]()
|
||||||
|
const res2 = setResult.mock.calls[1][0](res1)
|
||||||
|
const res3 = setResult.mock.calls[2][0](res2)
|
||||||
|
const res4 = setResult.mock.calls[3][0](res3)
|
||||||
|
expect(res1).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res2).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
@@ -354,7 +396,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
{ validator: validator4, status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[1][0]).toEqual(
|
expect(res4).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
@@ -372,7 +414,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
validator,
|
validator,
|
||||||
status: validator === validator1 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
status: validator === validator1 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
getSuccessExecutionTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: validatorData.validator === validator1 ? '0x123' : '',
|
txHash: validatorData.validator === validator1 ? '0x123' : '',
|
||||||
@@ -407,12 +449,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -423,9 +465,9 @@ describe('getConfirmationsForTx', () => {
|
|||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(4)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
@@ -437,14 +479,32 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations).toBeCalledTimes(1)
|
expect(setPendingConfirmations).toBeCalledTimes(1)
|
||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(true)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(true)
|
||||||
|
|
||||||
expect(setResult.mock.calls[0][0]()).toEqual(
|
const res1 = setResult.mock.calls[0][0]()
|
||||||
|
const res2 = setResult.mock.calls[1][0](res1)
|
||||||
|
const res3 = setResult.mock.calls[2][0](res2)
|
||||||
|
const res4 = setResult.mock.calls[3][0](res3)
|
||||||
|
expect(res1).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res2).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[1][0]).toEqual(
|
expect(res4).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
@@ -461,7 +521,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
validator,
|
validator,
|
||||||
status: validator === validator1 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
status: validator === validator1 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
getSuccessExecutionTransaction.mockImplementation(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
txHash: validatorData.validator === validator1 ? '0x123' : '',
|
txHash: validatorData.validator === validator1 ? '0x123' : '',
|
||||||
@@ -493,12 +553,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -510,9 +570,9 @@ describe('getConfirmationsForTx', () => {
|
|||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(subscriptions.length).toEqual(0)
|
expect(subscriptions.length).toEqual(0)
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(3)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
@@ -524,14 +584,24 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations).toBeCalledTimes(1)
|
expect(setPendingConfirmations).toBeCalledTimes(1)
|
||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
expect(setResult.mock.calls[0][0]()).toEqual(
|
const res1 = setResult.mock.calls[0][0]()
|
||||||
|
const res2 = setResult.mock.calls[1][0](res1)
|
||||||
|
const res3 = setResult.mock.calls[2][0](res2)
|
||||||
|
expect(res1).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res2).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[1][0]).toEqual(
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
@@ -555,7 +625,7 @@ describe('getConfirmationsForTx', () => {
|
|||||||
status:
|
status:
|
||||||
validator !== validator2 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
validator !== validator2 ? VALIDATOR_CONFIRMATION_STATUS.SUCCESS : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
}))
|
}))
|
||||||
getValidatorSuccessTransaction
|
getSuccessExecutionTransaction
|
||||||
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
.mockImplementationOnce(() => async (validatorData: BasicConfirmationParam) => ({
|
||||||
validator: validatorData.validator,
|
validator: validatorData.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
@@ -604,12 +674,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -620,9 +690,9 @@ describe('getConfirmationsForTx', () => {
|
|||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(setResult).toBeCalledTimes(2)
|
expect(setResult).toBeCalledTimes(4)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
expect(getValidatorConfirmation).toBeCalledTimes(1)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(1)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(1)
|
expect(setSignatureCollected).toBeCalledTimes(1)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
||||||
|
|
||||||
@@ -634,14 +704,32 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations).toBeCalledTimes(1)
|
expect(setPendingConfirmations).toBeCalledTimes(1)
|
||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(true)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(true)
|
||||||
|
|
||||||
expect(setResult.mock.calls[0][0]()).toEqual(
|
const res1 = setResult.mock.calls[0][0]()
|
||||||
|
const res2 = setResult.mock.calls[1][0](res1)
|
||||||
|
const res3 = setResult.mock.calls[2][0](res2)
|
||||||
|
const res4 = setResult.mock.calls[3][0](res3)
|
||||||
|
expect(res1).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res2).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res3).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.PENDING, txHash: '0x123', timestamp: 123 }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[1][0]).toEqual(
|
expect(res4).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
@@ -654,12 +742,12 @@ describe('getConfirmationsForTx', () => {
|
|||||||
web3,
|
web3,
|
||||||
validatorList,
|
validatorList,
|
||||||
bridgeContract,
|
bridgeContract,
|
||||||
confirmationContractMethod,
|
true,
|
||||||
setResult,
|
setResult,
|
||||||
requiredSignatures,
|
requiredSignatures,
|
||||||
setSignatureCollected,
|
setSignatureCollected,
|
||||||
waitingBlocksResolved,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
getFailedTransactions,
|
getFailedTransactions,
|
||||||
setFailedConfirmations,
|
setFailedConfirmations,
|
||||||
@@ -670,12 +758,13 @@ describe('getConfirmationsForTx', () => {
|
|||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|
||||||
expect(setResult).toBeCalledTimes(4)
|
expect(setResult).toBeCalledTimes(7)
|
||||||
expect(getValidatorConfirmation).toBeCalledTimes(2)
|
expect(getValidatorConfirmation).toBeCalledTimes(2)
|
||||||
expect(getValidatorSuccessTransaction).toBeCalledTimes(2)
|
expect(getSuccessExecutionTransaction).toBeCalledTimes(2)
|
||||||
expect(setSignatureCollected).toBeCalledTimes(2)
|
expect(setSignatureCollected).toBeCalledTimes(3)
|
||||||
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
expect(setSignatureCollected.mock.calls[0][0]).toEqual(false)
|
||||||
expect(setSignatureCollected.mock.calls[1][0]).toEqual(true)
|
expect(setSignatureCollected.mock.calls[1][0]).toEqual(true)
|
||||||
|
expect(setSignatureCollected.mock.calls[2][0]).toEqual([signature, signature])
|
||||||
|
|
||||||
expect(getValidatorFailedTransaction).toBeCalledTimes(2)
|
expect(getValidatorFailedTransaction).toBeCalledTimes(2)
|
||||||
expect(setFailedConfirmations).toBeCalledTimes(2)
|
expect(setFailedConfirmations).toBeCalledTimes(2)
|
||||||
@@ -687,14 +776,24 @@ describe('getConfirmationsForTx', () => {
|
|||||||
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(true)
|
expect(setPendingConfirmations.mock.calls[0][0]).toEqual(true)
|
||||||
expect(setPendingConfirmations.mock.calls[1][0]).toEqual(false)
|
expect(setPendingConfirmations.mock.calls[1][0]).toEqual(false)
|
||||||
|
|
||||||
expect(setResult.mock.calls[2][0]()).toEqual(
|
const res5 = setResult.mock.calls[4][0](res4)
|
||||||
|
const res6 = setResult.mock.calls[5][0](res5)
|
||||||
|
const res7 = setResult.mock.calls[6][0](res6)
|
||||||
|
expect(res5).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS }
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS }
|
||||||
])
|
])
|
||||||
)
|
)
|
||||||
expect(setResult.mock.calls[3][0]).toEqual(
|
expect(res6).toEqual(
|
||||||
|
expect.arrayContaining([
|
||||||
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
|
{ validator: validator3, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS }
|
||||||
|
])
|
||||||
|
)
|
||||||
|
expect(res7).toEqual(
|
||||||
expect.arrayContaining([
|
expect.arrayContaining([
|
||||||
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
{ validator: validator1, status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS, txHash: '0x123', timestamp: 123 },
|
||||||
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
{ validator: validator2, status: VALIDATOR_CONFIRMATION_STATUS.FAILED, txHash: '0x123', timestamp: 123 },
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Web3 from 'web3'
|
|||||||
import { getFinalizationEvent } from '../getFinalizationEvent'
|
import { getFinalizationEvent } from '../getFinalizationEvent'
|
||||||
import { VALIDATOR_CONFIRMATION_STATUS } from '../../config/constants'
|
import { VALIDATOR_CONFIRMATION_STATUS } from '../../config/constants'
|
||||||
|
|
||||||
const eventName = 'RelayedMessage'
|
|
||||||
const timestamp = 1594045859
|
const timestamp = 1594045859
|
||||||
const validator1 = '0x45b96809336A8b714BFbdAB3E4B5e0fe5d839908'
|
const validator1 = '0x45b96809336A8b714BFbdAB3E4B5e0fe5d839908'
|
||||||
const txHash = '0xdab36c9210e7e45fb82af10ffe4960461e41661dce0c9cd36b2843adaa1df156'
|
const txHash = '0xdab36c9210e7e45fb82af10ffe4960461e41661dce0c9cd36b2843adaa1df156'
|
||||||
@@ -20,12 +19,11 @@ const web3 = ({
|
|||||||
toChecksumAddress: (a: string) => a
|
toChecksumAddress: (a: string) => a
|
||||||
}
|
}
|
||||||
} as unknown) as Web3
|
} as unknown) as Web3
|
||||||
const waitingBlocksResolved = true
|
|
||||||
const message = {
|
const message = {
|
||||||
id: '0x123',
|
id: '0x123',
|
||||||
data: '0x123456789'
|
data: '0x123456789'
|
||||||
}
|
}
|
||||||
const interval = 10000
|
const isCancelled = () => false
|
||||||
let subscriptions: Array<number> = []
|
let subscriptions: Array<number> = []
|
||||||
|
|
||||||
const event = {
|
const event = {
|
||||||
@@ -50,7 +48,7 @@ beforeEach(() => {
|
|||||||
describe('getFinalizationEvent', () => {
|
describe('getFinalizationEvent', () => {
|
||||||
test('should get finalization event and not try to get failed or pending transactions', async () => {
|
test('should get finalization event and not try to get failed or pending transactions', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: () => {
|
getPastEvents: async () => {
|
||||||
return [event]
|
return [event]
|
||||||
}
|
}
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
@@ -61,22 +59,23 @@ describe('getFinalizationEvent', () => {
|
|||||||
const setFailedExecution = jest.fn()
|
const setFailedExecution = jest.fn()
|
||||||
const getPendingExecution = jest.fn()
|
const getPendingExecution = jest.fn()
|
||||||
const setPendingExecution = jest.fn()
|
const setPendingExecution = jest.fn()
|
||||||
|
const setExecutionEventsFetched = jest.fn()
|
||||||
|
|
||||||
await getFinalizationEvent(
|
await getFinalizationEvent(
|
||||||
|
true,
|
||||||
contract,
|
contract,
|
||||||
eventName,
|
|
||||||
web3,
|
web3,
|
||||||
setResult,
|
setResult,
|
||||||
waitingBlocksResolved,
|
|
||||||
message,
|
message,
|
||||||
interval,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getFailedExecution,
|
getFailedExecution,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getPendingExecution,
|
getPendingExecution,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
|
setExecutionEventsFetched
|
||||||
)
|
)
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
@@ -99,7 +98,7 @@ describe('getFinalizationEvent', () => {
|
|||||||
})
|
})
|
||||||
test('should retry to get finalization event and not try to get failed or pending transactions if foreign to home transaction', async () => {
|
test('should retry to get finalization event and not try to get failed or pending transactions if foreign to home transaction', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: () => {
|
getPastEvents: async () => {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
} as unknown) as Contract
|
} as unknown) as Contract
|
||||||
@@ -110,22 +109,23 @@ describe('getFinalizationEvent', () => {
|
|||||||
const setFailedExecution = jest.fn()
|
const setFailedExecution = jest.fn()
|
||||||
const getPendingExecution = jest.fn()
|
const getPendingExecution = jest.fn()
|
||||||
const setPendingExecution = jest.fn()
|
const setPendingExecution = jest.fn()
|
||||||
|
const setExecutionEventsFetched = jest.fn()
|
||||||
|
|
||||||
await getFinalizationEvent(
|
await getFinalizationEvent(
|
||||||
|
true,
|
||||||
contract,
|
contract,
|
||||||
eventName,
|
|
||||||
web3,
|
web3,
|
||||||
setResult,
|
setResult,
|
||||||
waitingBlocksResolved,
|
|
||||||
message,
|
message,
|
||||||
interval,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getFailedExecution,
|
getFailedExecution,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getPendingExecution,
|
getPendingExecution,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
|
setExecutionEventsFetched
|
||||||
)
|
)
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
@@ -141,7 +141,7 @@ describe('getFinalizationEvent', () => {
|
|||||||
})
|
})
|
||||||
test('should retry to get finalization event and try to get failed and pending transactions if home to foreign transaction', async () => {
|
test('should retry to get finalization event and try to get failed and pending transactions if home to foreign transaction', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: () => {
|
getPastEvents: async () => {
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
@@ -159,22 +159,23 @@ describe('getFinalizationEvent', () => {
|
|||||||
const setFailedExecution = jest.fn()
|
const setFailedExecution = jest.fn()
|
||||||
const getPendingExecution = jest.fn().mockResolvedValue([])
|
const getPendingExecution = jest.fn().mockResolvedValue([])
|
||||||
const setPendingExecution = jest.fn()
|
const setPendingExecution = jest.fn()
|
||||||
|
const setExecutionEventsFetched = jest.fn()
|
||||||
|
|
||||||
await getFinalizationEvent(
|
await getFinalizationEvent(
|
||||||
|
true,
|
||||||
contract,
|
contract,
|
||||||
eventName,
|
|
||||||
web3,
|
web3,
|
||||||
setResult,
|
setResult,
|
||||||
waitingBlocksResolved,
|
|
||||||
message,
|
message,
|
||||||
interval,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getFailedExecution,
|
getFailedExecution,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getPendingExecution,
|
getPendingExecution,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
|
setExecutionEventsFetched
|
||||||
)
|
)
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
@@ -190,7 +191,7 @@ describe('getFinalizationEvent', () => {
|
|||||||
})
|
})
|
||||||
test('should retry to get finalization event and not to try to get failed transaction if pending transactions found if home to foreign transaction', async () => {
|
test('should retry to get finalization event and not to try to get failed transaction if pending transactions found if home to foreign transaction', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: () => {
|
getPastEvents: async () => {
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
@@ -208,22 +209,23 @@ describe('getFinalizationEvent', () => {
|
|||||||
const setFailedExecution = jest.fn()
|
const setFailedExecution = jest.fn()
|
||||||
const getPendingExecution = jest.fn().mockResolvedValue([{ hash: txHash }])
|
const getPendingExecution = jest.fn().mockResolvedValue([{ hash: txHash }])
|
||||||
const setPendingExecution = jest.fn()
|
const setPendingExecution = jest.fn()
|
||||||
|
const setExecutionEventsFetched = jest.fn()
|
||||||
|
|
||||||
await getFinalizationEvent(
|
await getFinalizationEvent(
|
||||||
|
true,
|
||||||
contract,
|
contract,
|
||||||
eventName,
|
|
||||||
web3,
|
web3,
|
||||||
setResult,
|
setResult,
|
||||||
waitingBlocksResolved,
|
|
||||||
message,
|
message,
|
||||||
interval,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getFailedExecution,
|
getFailedExecution,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getPendingExecution,
|
getPendingExecution,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
|
setExecutionEventsFetched
|
||||||
)
|
)
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
@@ -246,7 +248,7 @@ describe('getFinalizationEvent', () => {
|
|||||||
})
|
})
|
||||||
test('should retry to get finalization event even if failed transaction found if home to foreign transaction', async () => {
|
test('should retry to get finalization event even if failed transaction found if home to foreign transaction', async () => {
|
||||||
const contract = ({
|
const contract = ({
|
||||||
getPastEvents: () => {
|
getPastEvents: async () => {
|
||||||
return []
|
return []
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
@@ -264,22 +266,23 @@ describe('getFinalizationEvent', () => {
|
|||||||
const setFailedExecution = jest.fn()
|
const setFailedExecution = jest.fn()
|
||||||
const getPendingExecution = jest.fn().mockResolvedValue([])
|
const getPendingExecution = jest.fn().mockResolvedValue([])
|
||||||
const setPendingExecution = jest.fn()
|
const setPendingExecution = jest.fn()
|
||||||
|
const setExecutionEventsFetched = jest.fn()
|
||||||
|
|
||||||
await getFinalizationEvent(
|
await getFinalizationEvent(
|
||||||
|
true,
|
||||||
contract,
|
contract,
|
||||||
eventName,
|
|
||||||
web3,
|
web3,
|
||||||
setResult,
|
setResult,
|
||||||
waitingBlocksResolved,
|
|
||||||
message,
|
message,
|
||||||
interval,
|
subscriptions.push.bind(subscriptions),
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
timestamp,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getFailedExecution,
|
getFailedExecution,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getPendingExecution,
|
getPendingExecution,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
|
setExecutionEventsFetched
|
||||||
)
|
)
|
||||||
|
|
||||||
unsubscribe()
|
unsubscribe()
|
||||||
|
|||||||
@@ -1,18 +1,33 @@
|
|||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { EventData } from 'web3-eth-contract'
|
import { EventData } from 'web3-eth-contract'
|
||||||
import { SnapshotProvider } from '../services/SnapshotProvider'
|
import { SnapshotProvider } from '../services/SnapshotProvider'
|
||||||
|
import { getLogs } from './explorer'
|
||||||
|
import Web3 from 'web3'
|
||||||
|
|
||||||
|
const getPastEventsWithFallback = (
|
||||||
|
api: string,
|
||||||
|
web3: Web3 | null,
|
||||||
|
contract: Contract,
|
||||||
|
eventName: string,
|
||||||
|
options: any
|
||||||
|
) =>
|
||||||
|
contract
|
||||||
|
.getPastEvents(eventName, options)
|
||||||
|
.catch(() => (api && web3 ? getLogs(api, web3, contract, eventName, options) : []))
|
||||||
|
|
||||||
export const getRequiredBlockConfirmations = async (
|
export const getRequiredBlockConfirmations = async (
|
||||||
contract: Contract,
|
contract: Contract,
|
||||||
blockNumber: number,
|
blockNumber: number,
|
||||||
snapshotProvider: SnapshotProvider
|
snapshotProvider: SnapshotProvider,
|
||||||
|
web3: Web3 | null = null,
|
||||||
|
api: string = ''
|
||||||
) => {
|
) => {
|
||||||
const eventsFromSnapshot = snapshotProvider.requiredBlockConfirmationEvents(blockNumber)
|
const eventsFromSnapshot = snapshotProvider.requiredBlockConfirmationEvents(blockNumber)
|
||||||
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
||||||
|
|
||||||
let contractEvents: EventData[] = []
|
let contractEvents: EventData[] = []
|
||||||
if (blockNumber > snapshotBlockNumber) {
|
if (blockNumber > snapshotBlockNumber) {
|
||||||
contractEvents = await contract.getPastEvents('RequiredBlockConfirmationChanged', {
|
contractEvents = await getPastEventsWithFallback(api, web3, contract, 'RequiredBlockConfirmationChanged', {
|
||||||
fromBlock: snapshotBlockNumber + 1,
|
fromBlock: snapshotBlockNumber + 1,
|
||||||
toBlock: blockNumber
|
toBlock: blockNumber
|
||||||
})
|
})
|
||||||
@@ -38,14 +53,16 @@ export const getValidatorAddress = (contract: Contract) => contract.methods.vali
|
|||||||
export const getRequiredSignatures = async (
|
export const getRequiredSignatures = async (
|
||||||
contract: Contract,
|
contract: Contract,
|
||||||
blockNumber: number,
|
blockNumber: number,
|
||||||
snapshotProvider: SnapshotProvider
|
snapshotProvider: SnapshotProvider,
|
||||||
|
web3: Web3 | null = null,
|
||||||
|
api: string = ''
|
||||||
) => {
|
) => {
|
||||||
const eventsFromSnapshot = snapshotProvider.requiredSignaturesEvents(blockNumber)
|
const eventsFromSnapshot = snapshotProvider.requiredSignaturesEvents(blockNumber)
|
||||||
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
||||||
|
|
||||||
let contractEvents: EventData[] = []
|
let contractEvents: EventData[] = []
|
||||||
if (blockNumber > snapshotBlockNumber) {
|
if (blockNumber > snapshotBlockNumber) {
|
||||||
contractEvents = await contract.getPastEvents('RequiredSignaturesChanged', {
|
contractEvents = await getPastEventsWithFallback(api, web3, contract, 'RequiredSignaturesChanged', {
|
||||||
fromBlock: snapshotBlockNumber + 1,
|
fromBlock: snapshotBlockNumber + 1,
|
||||||
toBlock: blockNumber
|
toBlock: blockNumber
|
||||||
})
|
})
|
||||||
@@ -59,7 +76,13 @@ export const getRequiredSignatures = async (
|
|||||||
return parseInt(requiredSignatures)
|
return parseInt(requiredSignatures)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getValidatorList = async (contract: Contract, blockNumber: number, snapshotProvider: SnapshotProvider) => {
|
export const getValidatorList = async (
|
||||||
|
contract: Contract,
|
||||||
|
blockNumber: number,
|
||||||
|
snapshotProvider: SnapshotProvider,
|
||||||
|
web3: Web3 | null = null,
|
||||||
|
api: string = ''
|
||||||
|
) => {
|
||||||
const addedEventsFromSnapshot = snapshotProvider.validatorAddedEvents(blockNumber)
|
const addedEventsFromSnapshot = snapshotProvider.validatorAddedEvents(blockNumber)
|
||||||
const removedEventsFromSnapshot = snapshotProvider.validatorRemovedEvents(blockNumber)
|
const removedEventsFromSnapshot = snapshotProvider.validatorRemovedEvents(blockNumber)
|
||||||
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
const snapshotBlockNumber = snapshotProvider.snapshotBlockNumber()
|
||||||
@@ -67,10 +90,10 @@ export const getValidatorList = async (contract: Contract, blockNumber: number,
|
|||||||
const fromBlock = snapshotBlockNumber > blockNumber ? snapshotBlockNumber + 1 : blockNumber
|
const fromBlock = snapshotBlockNumber > blockNumber ? snapshotBlockNumber + 1 : blockNumber
|
||||||
const [currentList, added, removed] = await Promise.all([
|
const [currentList, added, removed] = await Promise.all([
|
||||||
contract.methods.validatorList().call(),
|
contract.methods.validatorList().call(),
|
||||||
contract.getPastEvents('ValidatorAdded', {
|
getPastEventsWithFallback(api, web3, contract, 'ValidatorAdded', {
|
||||||
fromBlock
|
fromBlock
|
||||||
}),
|
}),
|
||||||
contract.getPastEvents('ValidatorRemoved', {
|
getPastEventsWithFallback(api, web3, contract, 'ValidatorRemoved', {
|
||||||
fromBlock
|
fromBlock
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
import { BlockNumberProvider } from '../services/BlockNumberProvider'
|
|
||||||
import { VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
|
||||||
import { EventData } from 'web3-eth-contract'
|
|
||||||
|
|
||||||
export const checkWaitingBlocksForExecution = async (
|
|
||||||
blockProvider: BlockNumberProvider,
|
|
||||||
interval: number,
|
|
||||||
targetBlock: number,
|
|
||||||
collectedSignaturesEvent: EventData,
|
|
||||||
setWaitingBlocksForExecution: Function,
|
|
||||||
setWaitingBlocksForExecutionResolved: Function,
|
|
||||||
setExecutionData: Function,
|
|
||||||
subscriptions: number[]
|
|
||||||
) => {
|
|
||||||
const currentBlock = blockProvider.get()
|
|
||||||
|
|
||||||
if (currentBlock && currentBlock >= targetBlock) {
|
|
||||||
setExecutionData({
|
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.UNDEFINED,
|
|
||||||
validator: collectedSignaturesEvent.returnValues.authorityResponsibleForRelay,
|
|
||||||
txHash: '',
|
|
||||||
timestamp: 0,
|
|
||||||
executionResult: false
|
|
||||||
})
|
|
||||||
setWaitingBlocksForExecutionResolved(true)
|
|
||||||
setWaitingBlocksForExecution(false)
|
|
||||||
blockProvider.stop()
|
|
||||||
} else {
|
|
||||||
let nextInterval = interval
|
|
||||||
if (!currentBlock) {
|
|
||||||
nextInterval = 500
|
|
||||||
} else {
|
|
||||||
setWaitingBlocksForExecution(true)
|
|
||||||
setExecutionData({
|
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.WAITING,
|
|
||||||
validator: collectedSignaturesEvent.returnValues.authorityResponsibleForRelay,
|
|
||||||
txHash: '',
|
|
||||||
timestamp: 0,
|
|
||||||
executionResult: false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const timeoutId = setTimeout(
|
|
||||||
() =>
|
|
||||||
checkWaitingBlocksForExecution(
|
|
||||||
blockProvider,
|
|
||||||
interval,
|
|
||||||
targetBlock,
|
|
||||||
collectedSignaturesEvent,
|
|
||||||
setWaitingBlocksForExecution,
|
|
||||||
setWaitingBlocksForExecutionResolved,
|
|
||||||
setExecutionData,
|
|
||||||
subscriptions
|
|
||||||
),
|
|
||||||
nextInterval
|
|
||||||
)
|
|
||||||
subscriptions.push(timeoutId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
|
BLOCK_RANGE,
|
||||||
EXECUTE_AFFIRMATION_HASH,
|
EXECUTE_AFFIRMATION_HASH,
|
||||||
EXECUTE_SIGNATURES_HASH,
|
EXECUTE_SIGNATURES_HASH,
|
||||||
FOREIGN_EXPLORER_API,
|
FOREIGN_EXPLORER_API,
|
||||||
HOME_EXPLORER_API,
|
HOME_EXPLORER_API,
|
||||||
|
MAX_TX_SEARCH_BLOCK_RANGE,
|
||||||
SUBMIT_SIGNATURE_HASH
|
SUBMIT_SIGNATURE_HASH
|
||||||
} from '../config/constants'
|
} from '../config/constants'
|
||||||
|
import { AbiItem } from 'web3-utils'
|
||||||
|
import Web3 from 'web3'
|
||||||
|
import { Contract } from 'web3-eth-contract'
|
||||||
|
|
||||||
export interface APITransaction {
|
export interface APITransaction {
|
||||||
timeStamp: string
|
timeStamp: string
|
||||||
@@ -12,6 +17,7 @@ export interface APITransaction {
|
|||||||
input: string
|
input: string
|
||||||
to: string
|
to: string
|
||||||
hash: string
|
hash: string
|
||||||
|
blockNumber: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface APIPendingTransaction {
|
export interface APIPendingTransaction {
|
||||||
@@ -27,110 +33,54 @@ export interface PendingTransactionsParams {
|
|||||||
|
|
||||||
export interface AccountTransactionsParams {
|
export interface AccountTransactionsParams {
|
||||||
account: string
|
account: string
|
||||||
to: string
|
startBlock: number
|
||||||
startTimestamp: number
|
endBlock: number
|
||||||
endTimestamp: number
|
|
||||||
api: string
|
api: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GetFailedTransactionParams {
|
|
||||||
account: string
|
|
||||||
to: string
|
|
||||||
messageData: string
|
|
||||||
startTimestamp: number
|
|
||||||
endTimestamp: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface GetPendingTransactionParams {
|
export interface GetPendingTransactionParams {
|
||||||
account: string
|
account: string
|
||||||
to: string
|
to: string
|
||||||
messageData: string
|
messageData: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchAccountTransactionsFromBlockscout = async ({
|
export interface GetTransactionParams extends GetPendingTransactionParams {
|
||||||
account,
|
startBlock: number
|
||||||
to,
|
endBlock: number
|
||||||
startTimestamp,
|
|
||||||
endTimestamp,
|
|
||||||
api
|
|
||||||
}: AccountTransactionsParams): Promise<APITransaction[]> => {
|
|
||||||
const url = `${api}?module=account&action=txlist&address=${account}&filterby=from=${account}&to=${to}&starttimestamp=${startTimestamp}&endtimestamp=${endTimestamp}`
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await fetch(url).then(res => res.json())
|
|
||||||
if (result.status === '0') {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.result
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getBlockByTimestampUrl = (api: string, timestamp: number) =>
|
export const fetchAccountTransactions = async ({ account, startBlock, endBlock, api }: AccountTransactionsParams) => {
|
||||||
`${api}&module=block&action=getblocknobytime×tamp=${timestamp}&closest=before`
|
const url = new URL(api)
|
||||||
|
url.searchParams.append('module', 'account')
|
||||||
|
url.searchParams.append('action', 'txlist')
|
||||||
|
url.searchParams.append('address', account)
|
||||||
|
url.searchParams.append('filterby', 'from')
|
||||||
|
url.searchParams.append('startblock', startBlock.toString())
|
||||||
|
url.searchParams.append('endblock', endBlock.toString())
|
||||||
|
|
||||||
export const fetchAccountTransactionsFromEtherscan = async ({
|
const result = await fetch(url.toString()).then(res => res.json())
|
||||||
account,
|
|
||||||
to,
|
|
||||||
startTimestamp,
|
|
||||||
endTimestamp,
|
|
||||||
api
|
|
||||||
}: AccountTransactionsParams): Promise<APITransaction[]> => {
|
|
||||||
const startBlockUrl = getBlockByTimestampUrl(api, startTimestamp)
|
|
||||||
const endBlockUrl = getBlockByTimestampUrl(api, endTimestamp)
|
|
||||||
let fromBlock = 0
|
|
||||||
let toBlock = 9999999999999
|
|
||||||
try {
|
|
||||||
const [fromBlockResult, toBlockResult] = await Promise.all([
|
|
||||||
fetch(startBlockUrl).then(res => res.json()),
|
|
||||||
fetch(endBlockUrl).then(res => res.json())
|
|
||||||
])
|
|
||||||
|
|
||||||
if (fromBlockResult.status !== '0') {
|
if (result.message === 'No transactions found') {
|
||||||
fromBlock = parseInt(fromBlockResult.result)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (toBlockResult.status !== '0') {
|
|
||||||
toBlock = parseInt(toBlockResult.result)
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = `${api}&module=account&action=txlist&address=${account}&startblock=${fromBlock}&endblock=${toBlock}`
|
return result.result
|
||||||
|
|
||||||
try {
|
|
||||||
const result = await fetch(url).then(res => res.json())
|
|
||||||
|
|
||||||
if (result.status === '0') {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
|
|
||||||
const toAddressLowerCase = to.toLowerCase()
|
|
||||||
const transactions: APITransaction[] = result.result
|
|
||||||
return transactions.filter(t => t.to.toLowerCase() === toAddressLowerCase)
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const fetchAccountTransactions = (api: string) => {
|
|
||||||
return api.includes('blockscout') ? fetchAccountTransactionsFromBlockscout : fetchAccountTransactionsFromEtherscan
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const fetchPendingTransactions = async ({
|
export const fetchPendingTransactions = async ({
|
||||||
account,
|
account,
|
||||||
api
|
api
|
||||||
}: PendingTransactionsParams): Promise<APIPendingTransaction[]> => {
|
}: PendingTransactionsParams): Promise<APIPendingTransaction[]> => {
|
||||||
const url = `${api}?module=account&action=pendingtxlist&address=${account}`
|
if (!api.includes('blockscout')) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
const url = new URL(api)
|
||||||
|
url.searchParams.append('module', 'account')
|
||||||
|
url.searchParams.append('action', 'pendingtxlist')
|
||||||
|
url.searchParams.append('address', account)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await fetch(url).then(res => res.json())
|
const result = await fetch(url.toString()).then(res => res.json())
|
||||||
if (result.status === '0') {
|
if (result.status === '0') {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -141,30 +91,135 @@ export const fetchPendingTransactions = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getClosestBlockByTimestamp = async (api: string, timestamp: number): Promise<number> => {
|
||||||
|
if (api.includes('blockscout')) {
|
||||||
|
throw new Error('Blockscout does not support getblocknobytime')
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(api)
|
||||||
|
url.searchParams.append('module', 'block')
|
||||||
|
url.searchParams.append('action', 'getblocknobytime')
|
||||||
|
url.searchParams.append('timestamp', timestamp.toString())
|
||||||
|
url.searchParams.append('closest', 'before')
|
||||||
|
|
||||||
|
const blockNumber = await fetch(url.toString()).then(res => res.json())
|
||||||
|
|
||||||
|
return parseInt(blockNumber.result)
|
||||||
|
}
|
||||||
|
|
||||||
|
// fast version of fetchAccountTransactions
|
||||||
|
// sequentially fetches transactions in small batches
|
||||||
|
// caches the result
|
||||||
|
const transactionsCache: { [key: string]: { lastBlock: number; transactions: APITransaction[] } } = {}
|
||||||
|
export const getAccountTransactions = async ({
|
||||||
|
account,
|
||||||
|
startBlock,
|
||||||
|
endBlock,
|
||||||
|
api
|
||||||
|
}: AccountTransactionsParams): Promise<APITransaction[]> => {
|
||||||
|
const key = `${account}-${startBlock}-${api}`
|
||||||
|
|
||||||
|
// initialize empty cache if it doesn't exist yet
|
||||||
|
if (!transactionsCache[key]) {
|
||||||
|
transactionsCache[key] = { lastBlock: startBlock - 1, transactions: [] }
|
||||||
|
}
|
||||||
|
|
||||||
|
// if cache contains events up to block X,
|
||||||
|
// new batch is fetched for range [X + 1, X + 1 + BLOCK_RANGE]
|
||||||
|
const newStartBlock = transactionsCache[key].lastBlock + 1
|
||||||
|
const newEndBlock = newStartBlock + BLOCK_RANGE
|
||||||
|
|
||||||
|
// search for new transactions only if max allowed block range is not yet exceeded
|
||||||
|
if (newEndBlock <= startBlock + MAX_TX_SEARCH_BLOCK_RANGE) {
|
||||||
|
const newTransactions = await fetchAccountTransactions({
|
||||||
|
account,
|
||||||
|
startBlock: newStartBlock,
|
||||||
|
endBlock: newEndBlock,
|
||||||
|
api
|
||||||
|
})
|
||||||
|
|
||||||
|
const transactions = transactionsCache[key].transactions.concat(...newTransactions)
|
||||||
|
|
||||||
|
// cache updated transactions list
|
||||||
|
transactionsCache[key].transactions = transactions
|
||||||
|
|
||||||
|
// enbBlock is assumed to be the current block number of the chain
|
||||||
|
// if the whole range is finalized, last block can be safely updated to the end of the range
|
||||||
|
// this works even if there are no transactions in the list
|
||||||
|
if (newEndBlock < endBlock) {
|
||||||
|
transactionsCache[key].lastBlock = newEndBlock
|
||||||
|
} else if (transactions.length > 0) {
|
||||||
|
transactionsCache[key].lastBlock = parseInt(transactions[transactions.length - 1].blockNumber, 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
return transactions
|
||||||
|
}
|
||||||
|
|
||||||
|
console.warn(`Reached max transaction searching range, returning previously cached transactions for ${account}`)
|
||||||
|
return transactionsCache[key].transactions
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getLogs = async (
|
||||||
|
api: string,
|
||||||
|
web3: Web3,
|
||||||
|
contract: Contract,
|
||||||
|
event: string,
|
||||||
|
options: { fromBlock: number; toBlock: number | 'latest'; topics: (string | null)[] }
|
||||||
|
) => {
|
||||||
|
const abi = contract.options.jsonInterface.find((abi: AbiItem) => abi.type === 'event' && abi.name === event)!
|
||||||
|
|
||||||
|
const url = new URL(api)
|
||||||
|
url.searchParams.append('module', 'logs')
|
||||||
|
url.searchParams.append('action', 'getLogs')
|
||||||
|
url.searchParams.append('address', contract.options.address)
|
||||||
|
url.searchParams.append('fromBlock', options.fromBlock.toString())
|
||||||
|
url.searchParams.append('toBlock', (options.toBlock || 'latest').toString())
|
||||||
|
|
||||||
|
const topics = [web3.eth.abi.encodeEventSignature(abi), ...(options.topics || [])]
|
||||||
|
for (let i = 0; i < topics.length; i++) {
|
||||||
|
if (topics[i] !== null) {
|
||||||
|
url.searchParams.append(`topic${i}`, topics[i] as string)
|
||||||
|
for (let j = 0; j < i; j++) {
|
||||||
|
url.searchParams.append(`topic${j}_${i}_opr`, 'and')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const logs = await fetch(url.toString()).then(res => res.json())
|
||||||
|
|
||||||
|
return logs.result.map((log: any) => ({
|
||||||
|
transactionHash: log.transactionHash,
|
||||||
|
blockNumber: parseInt(log.blockNumber.slice(2), 16),
|
||||||
|
returnValues: web3.eth.abi.decodeLog(abi.inputs!, log.data, log.topics.slice(1))
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const filterReceiver = (to: string) => (tx: APITransaction) => tx.to.toLowerCase() === to.toLowerCase()
|
||||||
|
|
||||||
export const getFailedTransactions = async (
|
export const getFailedTransactions = async (
|
||||||
account: string,
|
account: string,
|
||||||
to: string,
|
to: string,
|
||||||
startTimestamp: number,
|
startBlock: number,
|
||||||
endTimestamp: number,
|
endBlock: number,
|
||||||
api: string,
|
api: string,
|
||||||
fetchAccountTransactions: (args: AccountTransactionsParams) => Promise<APITransaction[]>
|
getAccountTransactionsMethod = getAccountTransactions
|
||||||
): Promise<APITransaction[]> => {
|
): Promise<APITransaction[]> => {
|
||||||
const transactions = await fetchAccountTransactions({ account, to, startTimestamp, endTimestamp, api })
|
const transactions = await getAccountTransactionsMethod({ account, startBlock, endBlock, api })
|
||||||
|
|
||||||
return transactions.filter(t => t.isError !== '0')
|
return transactions.filter(t => t.isError !== '0').filter(filterReceiver(to))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSuccessTransactions = async (
|
export const getSuccessTransactions = async (
|
||||||
account: string,
|
account: string,
|
||||||
to: string,
|
to: string,
|
||||||
startTimestamp: number,
|
startBlock: number,
|
||||||
endTimestamp: number,
|
endBlock: number,
|
||||||
api: string,
|
api: string,
|
||||||
fetchAccountTransactions: (args: AccountTransactionsParams) => Promise<APITransaction[]>
|
getAccountTransactionsMethod = getAccountTransactions
|
||||||
): Promise<APITransaction[]> => {
|
): Promise<APITransaction[]> => {
|
||||||
const transactions = await fetchAccountTransactions({ account, to, startTimestamp, endTimestamp, api })
|
const transactions = await getAccountTransactionsMethod({ account, startBlock, endBlock, api })
|
||||||
|
|
||||||
return transactions.filter(t => t.isError === '0')
|
return transactions.filter(t => t.isError === '0').filter(filterReceiver(to))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const filterValidatorSignatureTransaction = (
|
export const filterValidatorSignatureTransaction = (
|
||||||
@@ -183,17 +238,10 @@ export const getValidatorFailedTransactionsForMessage = async ({
|
|||||||
account,
|
account,
|
||||||
to,
|
to,
|
||||||
messageData,
|
messageData,
|
||||||
startTimestamp,
|
startBlock,
|
||||||
endTimestamp
|
endBlock
|
||||||
}: GetFailedTransactionParams): Promise<APITransaction[]> => {
|
}: GetTransactionParams): Promise<APITransaction[]> => {
|
||||||
const failedTransactions = await getFailedTransactions(
|
const failedTransactions = await getFailedTransactions(account, to, startBlock, endBlock, HOME_EXPLORER_API)
|
||||||
account,
|
|
||||||
to,
|
|
||||||
startTimestamp,
|
|
||||||
endTimestamp,
|
|
||||||
HOME_EXPLORER_API,
|
|
||||||
fetchAccountTransactionsFromBlockscout
|
|
||||||
)
|
|
||||||
|
|
||||||
return filterValidatorSignatureTransaction(failedTransactions, messageData)
|
return filterValidatorSignatureTransaction(failedTransactions, messageData)
|
||||||
}
|
}
|
||||||
@@ -202,33 +250,19 @@ export const getValidatorSuccessTransactionsForMessage = async ({
|
|||||||
account,
|
account,
|
||||||
to,
|
to,
|
||||||
messageData,
|
messageData,
|
||||||
startTimestamp,
|
startBlock,
|
||||||
endTimestamp
|
endBlock
|
||||||
}: GetFailedTransactionParams): Promise<APITransaction[]> => {
|
}: GetTransactionParams): Promise<APITransaction[]> => {
|
||||||
const transactions = await getSuccessTransactions(
|
const transactions = await getSuccessTransactions(account, to, startBlock, endBlock, HOME_EXPLORER_API)
|
||||||
account,
|
|
||||||
to,
|
|
||||||
startTimestamp,
|
|
||||||
endTimestamp,
|
|
||||||
HOME_EXPLORER_API,
|
|
||||||
fetchAccountTransactionsFromBlockscout
|
|
||||||
)
|
|
||||||
|
|
||||||
return filterValidatorSignatureTransaction(transactions, messageData)
|
return filterValidatorSignatureTransaction(transactions, messageData)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getExecutionFailedTransactionForMessage = async (
|
export const getExecutionFailedTransactionForMessage = async (
|
||||||
{ account, to, messageData, startTimestamp, endTimestamp }: GetFailedTransactionParams,
|
{ account, to, messageData, startBlock, endBlock }: GetTransactionParams,
|
||||||
getFailedTransactionsMethod = getFailedTransactions
|
getFailedTransactionsMethod = getFailedTransactions
|
||||||
): Promise<APITransaction[]> => {
|
): Promise<APITransaction[]> => {
|
||||||
const failedTransactions = await getFailedTransactionsMethod(
|
const failedTransactions = await getFailedTransactionsMethod(account, to, startBlock, endBlock, FOREIGN_EXPLORER_API)
|
||||||
account,
|
|
||||||
to,
|
|
||||||
startTimestamp,
|
|
||||||
endTimestamp,
|
|
||||||
FOREIGN_EXPLORER_API,
|
|
||||||
fetchAccountTransactions(FOREIGN_EXPLORER_API)
|
|
||||||
)
|
|
||||||
|
|
||||||
const messageDataValue = messageData.replace('0x', '')
|
const messageDataValue = messageData.replace('0x', '')
|
||||||
return failedTransactions.filter(t => t.input.includes(EXECUTE_SIGNATURES_HASH) && t.input.includes(messageDataValue))
|
return failedTransactions.filter(t => t.input.includes(EXECUTE_SIGNATURES_HASH) && t.input.includes(messageDataValue))
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import Web3 from 'web3'
|
|
||||||
import { Contract, EventData } from 'web3-eth-contract'
|
|
||||||
import { homeBlockNumberProvider } from '../services/BlockNumberProvider'
|
|
||||||
import { BLOCK_RANGE } from '../config/constants'
|
|
||||||
|
|
||||||
export const getCollectedSignaturesEvent = async (
|
|
||||||
web3: Maybe<Web3>,
|
|
||||||
contract: Maybe<Contract>,
|
|
||||||
fromBlock: number,
|
|
||||||
toBlock: number,
|
|
||||||
messageHash: string,
|
|
||||||
setCollectedSignaturesEvent: Function,
|
|
||||||
subscriptions: number[]
|
|
||||||
) => {
|
|
||||||
if (!web3 || !contract) return
|
|
||||||
const currentBlock = homeBlockNumberProvider.get()
|
|
||||||
|
|
||||||
let events: EventData[] = []
|
|
||||||
let securedToBlock = toBlock
|
|
||||||
if (currentBlock) {
|
|
||||||
// prevent errors if the toBlock parameter is bigger than the latest
|
|
||||||
securedToBlock = toBlock >= currentBlock ? currentBlock : toBlock
|
|
||||||
events = await contract.getPastEvents('CollectedSignatures', {
|
|
||||||
fromBlock,
|
|
||||||
toBlock: securedToBlock
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const filteredEvents = events.filter(e => e.returnValues.messageHash === messageHash)
|
|
||||||
|
|
||||||
if (filteredEvents.length) {
|
|
||||||
const event = filteredEvents[0]
|
|
||||||
setCollectedSignaturesEvent(event)
|
|
||||||
homeBlockNumberProvider.stop()
|
|
||||||
} else {
|
|
||||||
const newFromBlock = currentBlock ? securedToBlock : fromBlock
|
|
||||||
const newToBlock = currentBlock ? toBlock + BLOCK_RANGE : toBlock
|
|
||||||
const timeoutId = setTimeout(
|
|
||||||
() =>
|
|
||||||
getCollectedSignaturesEvent(
|
|
||||||
web3,
|
|
||||||
contract,
|
|
||||||
newFromBlock,
|
|
||||||
newToBlock,
|
|
||||||
messageHash,
|
|
||||||
setCollectedSignaturesEvent,
|
|
||||||
subscriptions
|
|
||||||
),
|
|
||||||
500
|
|
||||||
)
|
|
||||||
subscriptions.push(timeoutId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,82 +1,91 @@
|
|||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { HOME_RPC_POLLING_INTERVAL, VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
import { HOME_RPC_POLLING_INTERVAL, VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
||||||
import {
|
import { GetTransactionParams, APITransaction, APIPendingTransaction, GetPendingTransactionParams } from './explorer'
|
||||||
GetFailedTransactionParams,
|
import { getAffirmationsSigned, getMessagesSigned } from './contract'
|
||||||
APITransaction,
|
|
||||||
APIPendingTransaction,
|
|
||||||
GetPendingTransactionParams
|
|
||||||
} from './explorer'
|
|
||||||
import {
|
import {
|
||||||
getValidatorConfirmation,
|
getValidatorConfirmation,
|
||||||
getValidatorFailedTransaction,
|
getValidatorFailedTransaction,
|
||||||
getValidatorPendingTransaction,
|
getValidatorPendingTransaction,
|
||||||
getValidatorSuccessTransaction
|
getSuccessExecutionTransaction
|
||||||
} from './validatorConfirmationHelpers'
|
} from './validatorConfirmationHelpers'
|
||||||
import { ConfirmationParam } from '../hooks/useMessageConfirmations'
|
import { BasicConfirmationParam, ConfirmationParam } from '../hooks/useMessageConfirmations'
|
||||||
|
|
||||||
|
const mergeConfirmations = (oldConfirmations: BasicConfirmationParam[], newConfirmations: BasicConfirmationParam[]) => {
|
||||||
|
const confirmations = [...oldConfirmations]
|
||||||
|
newConfirmations.forEach(validatorData => {
|
||||||
|
const index = confirmations.findIndex(e => e.validator === validatorData.validator)
|
||||||
|
const currentStatus = confirmations[index].status
|
||||||
|
const newStatus = validatorData.status
|
||||||
|
if (
|
||||||
|
(validatorData as ConfirmationParam).txHash ||
|
||||||
|
(newStatus !== currentStatus && newStatus !== VALIDATOR_CONFIRMATION_STATUS.UNDEFINED)
|
||||||
|
) {
|
||||||
|
confirmations[index] = validatorData
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return confirmations
|
||||||
|
}
|
||||||
|
|
||||||
export const getConfirmationsForTx = async (
|
export const getConfirmationsForTx = async (
|
||||||
messageData: string,
|
messageData: string,
|
||||||
web3: Maybe<Web3>,
|
web3: Web3,
|
||||||
validatorList: string[],
|
validatorList: string[],
|
||||||
bridgeContract: Maybe<Contract>,
|
bridgeContract: Contract,
|
||||||
confirmationContractMethod: Function,
|
fromHome: boolean,
|
||||||
setResult: Function,
|
setResult: Function,
|
||||||
requiredSignatures: number,
|
requiredSignatures: number,
|
||||||
setSignatureCollected: Function,
|
setSignatureCollected: Function,
|
||||||
waitingBlocksResolved: boolean,
|
setTimeoutId: (timeoutId: number) => void,
|
||||||
subscriptions: number[],
|
isCancelled: () => boolean,
|
||||||
timestamp: number,
|
startBlock: number,
|
||||||
getFailedTransactions: (args: GetFailedTransactionParams) => Promise<APITransaction[]>,
|
getFailedTransactions: (args: GetTransactionParams) => Promise<APITransaction[]>,
|
||||||
setFailedConfirmations: Function,
|
setFailedConfirmations: Function,
|
||||||
getPendingTransactions: (args: GetPendingTransactionParams) => Promise<APIPendingTransaction[]>,
|
getPendingTransactions: (args: GetPendingTransactionParams) => Promise<APIPendingTransaction[]>,
|
||||||
setPendingConfirmations: Function,
|
setPendingConfirmations: Function,
|
||||||
getSuccessTransactions: (args: GetFailedTransactionParams) => Promise<APITransaction[]>
|
getSuccessTransactions: (args: GetTransactionParams) => Promise<APITransaction[]>
|
||||||
) => {
|
) => {
|
||||||
if (!web3 || !validatorList || !validatorList.length || !bridgeContract || !waitingBlocksResolved) return
|
const confirmationContractMethod = fromHome ? getMessagesSigned : getAffirmationsSigned
|
||||||
|
|
||||||
// If all the information was not collected, then it should retry
|
|
||||||
let shouldRetry = false
|
|
||||||
const hashMsg = web3.utils.soliditySha3Raw(messageData)
|
const hashMsg = web3.utils.soliditySha3Raw(messageData)
|
||||||
let validatorConfirmations = await Promise.all(
|
let validatorConfirmations = await Promise.all(
|
||||||
validatorList.map(getValidatorConfirmation(web3, hashMsg, bridgeContract, confirmationContractMethod))
|
validatorList.map(getValidatorConfirmation(web3, hashMsg, bridgeContract, confirmationContractMethod))
|
||||||
)
|
)
|
||||||
|
|
||||||
const successConfirmations = validatorConfirmations.filter(c => c.status === VALIDATOR_CONFIRMATION_STATUS.SUCCESS)
|
const updateConfirmations = (confirmations: BasicConfirmationParam[]) => {
|
||||||
|
if (confirmations.length === 0) {
|
||||||
setResult((prevConfirmations: ConfirmationParam[]) => {
|
return
|
||||||
if (prevConfirmations && prevConfirmations.length) {
|
|
||||||
successConfirmations.forEach(validatorData => {
|
|
||||||
const index = prevConfirmations.findIndex(e => e.validator === validatorData.validator)
|
|
||||||
validatorConfirmations[index] = validatorData
|
|
||||||
})
|
|
||||||
return prevConfirmations
|
|
||||||
} else {
|
|
||||||
return validatorConfirmations
|
|
||||||
}
|
}
|
||||||
})
|
validatorConfirmations = mergeConfirmations(validatorConfirmations, confirmations)
|
||||||
|
setResult((currentConfirmations: BasicConfirmationParam[]) => {
|
||||||
|
if (currentConfirmations && currentConfirmations.length) {
|
||||||
|
return mergeConfirmations(currentConfirmations, confirmations)
|
||||||
|
}
|
||||||
|
return confirmations
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const successConfirmations = validatorConfirmations.filter(c => c.status === VALIDATOR_CONFIRMATION_STATUS.SUCCESS)
|
||||||
const notSuccessConfirmations = validatorConfirmations.filter(c => c.status !== VALIDATOR_CONFIRMATION_STATUS.SUCCESS)
|
const notSuccessConfirmations = validatorConfirmations.filter(c => c.status !== VALIDATOR_CONFIRMATION_STATUS.SUCCESS)
|
||||||
|
const hasEnoughSignatures = successConfirmations.length === requiredSignatures
|
||||||
|
|
||||||
|
updateConfirmations(validatorConfirmations)
|
||||||
|
setSignatureCollected(hasEnoughSignatures)
|
||||||
|
|
||||||
// If signatures not collected, look for pending transactions
|
// If signatures not collected, look for pending transactions
|
||||||
let pendingConfirmationsResult = false
|
if (!hasEnoughSignatures) {
|
||||||
if (successConfirmations.length !== requiredSignatures) {
|
|
||||||
// Check if confirmation is pending
|
// Check if confirmation is pending
|
||||||
const validatorPendingConfirmationsChecks = await Promise.all(
|
const validatorPendingConfirmationsChecks = await Promise.all(
|
||||||
notSuccessConfirmations.map(getValidatorPendingTransaction(bridgeContract, messageData, getPendingTransactions))
|
notSuccessConfirmations.map(getValidatorPendingTransaction(bridgeContract, messageData, getPendingTransactions))
|
||||||
)
|
)
|
||||||
|
|
||||||
const validatorPendingConfirmations = validatorPendingConfirmationsChecks.filter(
|
const validatorPendingConfirmations = validatorPendingConfirmationsChecks.filter(
|
||||||
c => c.status === VALIDATOR_CONFIRMATION_STATUS.PENDING
|
c => c.status === VALIDATOR_CONFIRMATION_STATUS.PENDING
|
||||||
)
|
)
|
||||||
|
updateConfirmations(validatorPendingConfirmations)
|
||||||
validatorPendingConfirmations.forEach(validatorData => {
|
setPendingConfirmations(validatorPendingConfirmations.length > 0)
|
||||||
const index = validatorConfirmations.findIndex(e => e.validator === validatorData.validator)
|
} else {
|
||||||
validatorConfirmations[index] = validatorData
|
setPendingConfirmations(false)
|
||||||
})
|
|
||||||
|
|
||||||
if (validatorPendingConfirmations.length > 0) {
|
|
||||||
pendingConfirmationsResult = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const undefinedConfirmations = validatorConfirmations.filter(
|
const undefinedConfirmations = validatorConfirmations.filter(
|
||||||
@@ -84,99 +93,79 @@ export const getConfirmationsForTx = async (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Check if confirmation failed
|
// Check if confirmation failed
|
||||||
let failedConfirmationsResult = false
|
|
||||||
const validatorFailedConfirmationsChecks = await Promise.all(
|
const validatorFailedConfirmationsChecks = await Promise.all(
|
||||||
undefinedConfirmations.map(
|
undefinedConfirmations.map(
|
||||||
getValidatorFailedTransaction(bridgeContract, messageData, timestamp, getFailedTransactions)
|
getValidatorFailedTransaction(bridgeContract, messageData, startBlock, getFailedTransactions)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
const validatorFailedConfirmations = validatorFailedConfirmationsChecks.filter(
|
const validatorFailedConfirmations = validatorFailedConfirmationsChecks.filter(
|
||||||
c => c.status === VALIDATOR_CONFIRMATION_STATUS.FAILED
|
c => c.status === VALIDATOR_CONFIRMATION_STATUS.FAILED
|
||||||
)
|
)
|
||||||
validatorFailedConfirmations.forEach(validatorData => {
|
setFailedConfirmations(validatorFailedConfirmations.length > validatorList.length - requiredSignatures)
|
||||||
const index = validatorConfirmations.findIndex(e => e.validator === validatorData.validator)
|
updateConfirmations(validatorFailedConfirmations)
|
||||||
validatorConfirmations[index] = validatorData
|
|
||||||
})
|
|
||||||
const messageConfirmationsFailed = validatorFailedConfirmations.length > validatorList.length - requiredSignatures
|
|
||||||
if (messageConfirmationsFailed) {
|
|
||||||
failedConfirmationsResult = true
|
|
||||||
}
|
|
||||||
|
|
||||||
const missingConfirmations = validatorConfirmations.filter(
|
const missingConfirmations = validatorConfirmations.filter(
|
||||||
c => c.status === VALIDATOR_CONFIRMATION_STATUS.UNDEFINED || c.status === VALIDATOR_CONFIRMATION_STATUS.PENDING
|
c => c.status === VALIDATOR_CONFIRMATION_STATUS.UNDEFINED || c.status === VALIDATOR_CONFIRMATION_STATUS.PENDING
|
||||||
)
|
)
|
||||||
|
|
||||||
if (successConfirmations.length !== requiredSignatures && missingConfirmations.length > 0) {
|
if (hasEnoughSignatures) {
|
||||||
shouldRetry = true
|
|
||||||
}
|
|
||||||
|
|
||||||
let signatureCollectedResult = false
|
|
||||||
if (successConfirmations.length === requiredSignatures) {
|
|
||||||
// If signatures collected, it should set other signatures not found as not required
|
// If signatures collected, it should set other signatures not found as not required
|
||||||
const notRequiredConfirmations = missingConfirmations.map(c => ({
|
const notRequiredConfirmations = missingConfirmations.map(c => ({
|
||||||
validator: c.validator,
|
validator: c.validator,
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED
|
status: VALIDATOR_CONFIRMATION_STATUS.NOT_REQUIRED
|
||||||
}))
|
}))
|
||||||
|
updateConfirmations(notRequiredConfirmations)
|
||||||
|
|
||||||
notRequiredConfirmations.forEach(validatorData => {
|
if (fromHome) {
|
||||||
const index = validatorConfirmations.findIndex(e => e.validator === validatorData.validator)
|
// fetch collected signatures for possible manual processing
|
||||||
validatorConfirmations[index] = validatorData
|
setSignatureCollected(
|
||||||
})
|
await Promise.all(
|
||||||
signatureCollectedResult = true
|
Array.from(Array(requiredSignatures).keys()).map(i => bridgeContract.methods.signature(hashMsg, i).call())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get transactions from success signatures
|
// get transactions from success signatures
|
||||||
const successConfirmationWithData = await Promise.all(
|
const successConfirmationWithData = await Promise.all(
|
||||||
validatorConfirmations
|
successConfirmations.map(
|
||||||
.filter(c => c.status === VALIDATOR_CONFIRMATION_STATUS.SUCCESS)
|
getSuccessExecutionTransaction(web3, bridgeContract, fromHome, messageData, startBlock, getSuccessTransactions)
|
||||||
.map(getValidatorSuccessTransaction(bridgeContract, messageData, timestamp, getSuccessTransactions))
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
const successConfirmationWithTxFound = successConfirmationWithData.filter(v => v.txHash !== '')
|
const successConfirmationWithTxFound = successConfirmationWithData.filter(v => v.txHash !== '')
|
||||||
|
updateConfirmations(successConfirmationWithTxFound)
|
||||||
|
|
||||||
const updatedValidatorConfirmations = [...validatorConfirmations]
|
// retry if not all signatures are collected and some confirmations are still missing
|
||||||
|
// or some success transactions were not fetched successfully
|
||||||
if (successConfirmationWithTxFound.length > 0) {
|
if (
|
||||||
successConfirmationWithTxFound.forEach(validatorData => {
|
(!hasEnoughSignatures && missingConfirmations.length > 0) ||
|
||||||
const index = updatedValidatorConfirmations.findIndex(e => e.validator === validatorData.validator)
|
successConfirmationWithTxFound.length < successConfirmationWithData.length
|
||||||
updatedValidatorConfirmations[index] = validatorData
|
) {
|
||||||
})
|
if (!isCancelled()) {
|
||||||
}
|
const timeoutId = setTimeout(
|
||||||
|
() =>
|
||||||
// Set results
|
getConfirmationsForTx(
|
||||||
setResult(updatedValidatorConfirmations)
|
messageData,
|
||||||
setFailedConfirmations(failedConfirmationsResult)
|
web3,
|
||||||
setPendingConfirmations(pendingConfirmationsResult)
|
validatorList,
|
||||||
setSignatureCollected(signatureCollectedResult)
|
bridgeContract,
|
||||||
|
fromHome,
|
||||||
// Retry if not all transaction were found for validator confirmations
|
setResult,
|
||||||
if (successConfirmationWithTxFound.length < successConfirmationWithData.length) {
|
requiredSignatures,
|
||||||
shouldRetry = true
|
setSignatureCollected,
|
||||||
}
|
setTimeoutId,
|
||||||
|
isCancelled,
|
||||||
if (shouldRetry) {
|
startBlock,
|
||||||
const timeoutId = setTimeout(
|
getFailedTransactions,
|
||||||
() =>
|
setFailedConfirmations,
|
||||||
getConfirmationsForTx(
|
getPendingTransactions,
|
||||||
messageData,
|
setPendingConfirmations,
|
||||||
web3,
|
getSuccessTransactions
|
||||||
validatorList,
|
),
|
||||||
bridgeContract,
|
HOME_RPC_POLLING_INTERVAL
|
||||||
confirmationContractMethod,
|
)
|
||||||
setResult,
|
setTimeoutId(timeoutId)
|
||||||
requiredSignatures,
|
}
|
||||||
setSignatureCollected,
|
|
||||||
waitingBlocksResolved,
|
|
||||||
subscriptions,
|
|
||||||
timestamp,
|
|
||||||
getFailedTransactions,
|
|
||||||
setFailedConfirmations,
|
|
||||||
getPendingTransactions,
|
|
||||||
setPendingConfirmations,
|
|
||||||
getSuccessTransactions
|
|
||||||
),
|
|
||||||
HOME_RPC_POLLING_INTERVAL
|
|
||||||
)
|
|
||||||
subscriptions.push(timeoutId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,51 @@
|
|||||||
import { Contract, EventData } from 'web3-eth-contract'
|
import { Contract, EventData } from 'web3-eth-contract'
|
||||||
import Web3 from 'web3'
|
import Web3 from 'web3'
|
||||||
import { CACHE_KEY_EXECUTION_FAILED, THREE_DAYS_TIMESTAMP, VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
import {
|
||||||
|
CACHE_KEY_EXECUTION_FAILED,
|
||||||
|
FOREIGN_EXPLORER_API,
|
||||||
|
FOREIGN_RPC_POLLING_INTERVAL,
|
||||||
|
HOME_EXPLORER_API,
|
||||||
|
HOME_RPC_POLLING_INTERVAL,
|
||||||
|
VALIDATOR_CONFIRMATION_STATUS
|
||||||
|
} from '../config/constants'
|
||||||
import { ExecutionData } from '../hooks/useMessageConfirmations'
|
import { ExecutionData } from '../hooks/useMessageConfirmations'
|
||||||
import {
|
import {
|
||||||
APIPendingTransaction,
|
APIPendingTransaction,
|
||||||
APITransaction,
|
APITransaction,
|
||||||
GetFailedTransactionParams,
|
GetTransactionParams,
|
||||||
GetPendingTransactionParams
|
GetPendingTransactionParams,
|
||||||
|
getLogs
|
||||||
} from './explorer'
|
} from './explorer'
|
||||||
import { getBlock, MessageObject } from './web3'
|
import { getBlock, MessageObject } from './web3'
|
||||||
import validatorsCache from '../services/ValidatorsCache'
|
import validatorsCache from '../services/ValidatorsCache'
|
||||||
|
import { foreignBlockNumberProvider, homeBlockNumberProvider } from '../services/BlockNumberProvider'
|
||||||
|
|
||||||
export const getFinalizationEvent = async (
|
const getPastEventsWithFallback = (api: string, web3: Web3, contract: Contract, eventName: string, options: any) =>
|
||||||
contract: Maybe<Contract>,
|
contract.getPastEvents(eventName, options).catch(
|
||||||
|
() =>
|
||||||
|
api
|
||||||
|
? getLogs(api, web3, contract, eventName, {
|
||||||
|
fromBlock: options.fromBlock,
|
||||||
|
toBlock: options.toBlock,
|
||||||
|
topics: [null, null, options.filter.messageId]
|
||||||
|
})
|
||||||
|
: []
|
||||||
|
)
|
||||||
|
|
||||||
|
export const getSuccessExecutionData = async (
|
||||||
|
contract: Contract,
|
||||||
eventName: string,
|
eventName: string,
|
||||||
web3: Maybe<Web3>,
|
web3: Web3,
|
||||||
setResult: React.Dispatch<React.SetStateAction<ExecutionData>>,
|
messageId: string,
|
||||||
waitingBlocksResolved: boolean,
|
api: string = ''
|
||||||
message: MessageObject,
|
|
||||||
interval: number,
|
|
||||||
subscriptions: number[],
|
|
||||||
timestamp: number,
|
|
||||||
collectedSignaturesEvent: Maybe<EventData>,
|
|
||||||
getFailedExecution: (args: GetFailedTransactionParams) => Promise<APITransaction[]>,
|
|
||||||
setFailedExecution: Function,
|
|
||||||
getPendingExecution: (args: GetPendingTransactionParams) => Promise<APIPendingTransaction[]>,
|
|
||||||
setPendingExecution: Function
|
|
||||||
) => {
|
) => {
|
||||||
if (!contract || !web3 || !waitingBlocksResolved) return
|
|
||||||
// Since it filters by the message id, only one event will be fetched
|
// Since it filters by the message id, only one event will be fetched
|
||||||
// so there is no need to limit the range of the block to reduce the network traffic
|
// so there is no need to limit the range of the block to reduce the network traffic
|
||||||
const events: EventData[] = await contract.getPastEvents(eventName, {
|
const events: EventData[] = await getPastEventsWithFallback(api, web3, contract, eventName, {
|
||||||
fromBlock: 0,
|
fromBlock: 0,
|
||||||
toBlock: 'latest',
|
toBlock: 'latest',
|
||||||
filter: {
|
filter: {
|
||||||
messageId: message.id
|
messageId
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (events.length > 0) {
|
if (events.length > 0) {
|
||||||
@@ -47,14 +58,42 @@ export const getFinalizationEvent = async (
|
|||||||
const blockTimestamp = typeof block.timestamp === 'string' ? parseInt(block.timestamp) : block.timestamp
|
const blockTimestamp = typeof block.timestamp === 'string' ? parseInt(block.timestamp) : block.timestamp
|
||||||
const validatorAddress = web3.utils.toChecksumAddress(txReceipt.from)
|
const validatorAddress = web3.utils.toChecksumAddress(txReceipt.from)
|
||||||
|
|
||||||
setResult({
|
return {
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
status: VALIDATOR_CONFIRMATION_STATUS.SUCCESS,
|
||||||
validator: validatorAddress,
|
validator: validatorAddress,
|
||||||
txHash: event.transactionHash,
|
txHash: event.transactionHash,
|
||||||
timestamp: blockTimestamp,
|
timestamp: blockTimestamp,
|
||||||
executionResult: event.returnValues.status
|
executionResult: event.returnValues.status
|
||||||
})
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getFinalizationEvent = async (
|
||||||
|
fromHome: boolean,
|
||||||
|
contract: Contract,
|
||||||
|
web3: Web3,
|
||||||
|
setResult: React.Dispatch<React.SetStateAction<ExecutionData>>,
|
||||||
|
message: MessageObject,
|
||||||
|
setTimeoutId: (timeoutId: number) => void,
|
||||||
|
isCancelled: () => boolean,
|
||||||
|
startBlock: number,
|
||||||
|
collectedSignaturesEvent: Maybe<EventData>,
|
||||||
|
getFailedExecution: (args: GetTransactionParams) => Promise<APITransaction[]>,
|
||||||
|
setFailedExecution: Function,
|
||||||
|
getPendingExecution: (args: GetPendingTransactionParams) => Promise<APIPendingTransaction[]>,
|
||||||
|
setPendingExecution: Function,
|
||||||
|
setExecutionEventsFetched: Function
|
||||||
|
) => {
|
||||||
|
const eventName = fromHome ? 'RelayedMessage' : 'AffirmationCompleted'
|
||||||
|
const api = fromHome ? FOREIGN_EXPLORER_API : HOME_EXPLORER_API
|
||||||
|
|
||||||
|
const successExecutionData = await getSuccessExecutionData(contract, eventName, web3, message.id, api)
|
||||||
|
|
||||||
|
if (successExecutionData) {
|
||||||
|
setResult(successExecutionData)
|
||||||
} else {
|
} else {
|
||||||
|
setExecutionEventsFetched(true)
|
||||||
// If event is defined, it means it is a message from Home to Foreign
|
// If event is defined, it means it is a message from Home to Foreign
|
||||||
if (collectedSignaturesEvent) {
|
if (collectedSignaturesEvent) {
|
||||||
const validator = collectedSignaturesEvent.returnValues.authorityResponsibleForRelay
|
const validator = collectedSignaturesEvent.returnValues.authorityResponsibleForRelay
|
||||||
@@ -82,14 +121,15 @@ export const getFinalizationEvent = async (
|
|||||||
} else {
|
} else {
|
||||||
const validatorExecutionCacheKey = `${CACHE_KEY_EXECUTION_FAILED}${validator}-${message.id}`
|
const validatorExecutionCacheKey = `${CACHE_KEY_EXECUTION_FAILED}${validator}-${message.id}`
|
||||||
const failedFromCache = validatorsCache.get(validatorExecutionCacheKey)
|
const failedFromCache = validatorsCache.get(validatorExecutionCacheKey)
|
||||||
|
const blockProvider = fromHome ? foreignBlockNumberProvider : homeBlockNumberProvider
|
||||||
|
|
||||||
if (!failedFromCache) {
|
if (!failedFromCache) {
|
||||||
const failedTransactions = await getFailedExecution({
|
const failedTransactions = await getFailedExecution({
|
||||||
account: validator,
|
account: validator,
|
||||||
to: contract.options.address,
|
to: contract.options.address,
|
||||||
messageData: message.data,
|
messageData: message.data,
|
||||||
startTimestamp: timestamp,
|
startBlock,
|
||||||
endTimestamp: timestamp + THREE_DAYS_TIMESTAMP
|
endBlock: blockProvider.get() || 0
|
||||||
})
|
})
|
||||||
|
|
||||||
if (failedTransactions.length > 0) {
|
if (failedTransactions.length > 0) {
|
||||||
@@ -112,26 +152,28 @@ export const getFinalizationEvent = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeoutId = setTimeout(
|
if (!isCancelled()) {
|
||||||
() =>
|
const timeoutId = setTimeout(
|
||||||
getFinalizationEvent(
|
() =>
|
||||||
contract,
|
getFinalizationEvent(
|
||||||
eventName,
|
fromHome,
|
||||||
web3,
|
contract,
|
||||||
setResult,
|
web3,
|
||||||
waitingBlocksResolved,
|
setResult,
|
||||||
message,
|
message,
|
||||||
interval,
|
setTimeoutId,
|
||||||
subscriptions,
|
isCancelled,
|
||||||
timestamp,
|
startBlock,
|
||||||
collectedSignaturesEvent,
|
collectedSignaturesEvent,
|
||||||
getFailedExecution,
|
getFailedExecution,
|
||||||
setFailedExecution,
|
setFailedExecution,
|
||||||
getPendingExecution,
|
getPendingExecution,
|
||||||
setPendingExecution
|
setPendingExecution,
|
||||||
),
|
setExecutionEventsFetched
|
||||||
interval
|
),
|
||||||
)
|
fromHome ? FOREIGN_RPC_POLLING_INTERVAL : HOME_RPC_POLLING_INTERVAL
|
||||||
subscriptions.push(timeoutId)
|
)
|
||||||
|
setTimeoutId(timeoutId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
import { VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
|
||||||
import { BlockNumberProvider } from '../services/BlockNumberProvider'
|
|
||||||
|
|
||||||
export const checkSignaturesWaitingForBLocks = async (
|
|
||||||
targetBlock: number,
|
|
||||||
setWaitingStatus: Function,
|
|
||||||
setWaitingBlocksResolved: Function,
|
|
||||||
validatorList: string[],
|
|
||||||
setConfirmations: Function,
|
|
||||||
blockProvider: BlockNumberProvider,
|
|
||||||
interval: number,
|
|
||||||
subscriptions: number[]
|
|
||||||
) => {
|
|
||||||
const currentBlock = blockProvider.get()
|
|
||||||
|
|
||||||
if (currentBlock && currentBlock >= targetBlock) {
|
|
||||||
setWaitingBlocksResolved(true)
|
|
||||||
setWaitingStatus(false)
|
|
||||||
blockProvider.stop()
|
|
||||||
} else {
|
|
||||||
let nextInterval = interval
|
|
||||||
if (!currentBlock) {
|
|
||||||
nextInterval = 500
|
|
||||||
} else {
|
|
||||||
const validatorsWaiting = validatorList.map(validator => {
|
|
||||||
return {
|
|
||||||
validator,
|
|
||||||
status: VALIDATOR_CONFIRMATION_STATUS.WAITING
|
|
||||||
}
|
|
||||||
})
|
|
||||||
setWaitingStatus(true)
|
|
||||||
setConfirmations(validatorsWaiting)
|
|
||||||
}
|
|
||||||
const timeoutId = setTimeout(
|
|
||||||
() =>
|
|
||||||
checkSignaturesWaitingForBLocks(
|
|
||||||
targetBlock,
|
|
||||||
setWaitingStatus,
|
|
||||||
setWaitingBlocksResolved,
|
|
||||||
validatorList,
|
|
||||||
setConfirmations,
|
|
||||||
blockProvider,
|
|
||||||
interval,
|
|
||||||
subscriptions
|
|
||||||
),
|
|
||||||
nextInterval
|
|
||||||
)
|
|
||||||
subscriptions.push(timeoutId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
26
alm/src/utils/signatures.ts
Normal file
26
alm/src/utils/signatures.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import Web3 from 'web3'
|
||||||
|
|
||||||
|
function strip0x(s: string) {
|
||||||
|
return Web3.utils.isHexStrict(s) ? s.substr(2) : s
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Signature {
|
||||||
|
v: string
|
||||||
|
r: string
|
||||||
|
s: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function signatureToVRS(rawSignature: string): Signature {
|
||||||
|
const signature = strip0x(rawSignature)
|
||||||
|
const v = signature.substr(64 * 2)
|
||||||
|
const r = signature.substr(0, 32 * 2)
|
||||||
|
const s = signature.substr(32 * 2, 32 * 2)
|
||||||
|
return { v, r, s }
|
||||||
|
}
|
||||||
|
|
||||||
|
export function packSignatures(array: Array<Signature>): string {
|
||||||
|
const length = strip0x(Web3.utils.toHex(array.length))
|
||||||
|
const msgLength = length.length === 1 ? `0${length}` : length
|
||||||
|
const [v, r, s] = array.reduce(([vs, rs, ss], { v, r, s }) => [vs + v, rs + r, ss + s], ['', '', ''])
|
||||||
|
return `0x${msgLength}${v}${r}${s}`
|
||||||
|
}
|
||||||
@@ -2,18 +2,9 @@ import Web3 from 'web3'
|
|||||||
import { Contract } from 'web3-eth-contract'
|
import { Contract } from 'web3-eth-contract'
|
||||||
import { BasicConfirmationParam, ConfirmationParam } from '../hooks/useMessageConfirmations'
|
import { BasicConfirmationParam, ConfirmationParam } from '../hooks/useMessageConfirmations'
|
||||||
import validatorsCache from '../services/ValidatorsCache'
|
import validatorsCache from '../services/ValidatorsCache'
|
||||||
import {
|
import { CACHE_KEY_FAILED, CACHE_KEY_SUCCESS, VALIDATOR_CONFIRMATION_STATUS } from '../config/constants'
|
||||||
CACHE_KEY_FAILED,
|
import { APIPendingTransaction, APITransaction, GetTransactionParams, GetPendingTransactionParams } from './explorer'
|
||||||
CACHE_KEY_SUCCESS,
|
import { homeBlockNumberProvider } from '../services/BlockNumberProvider'
|
||||||
ONE_DAY_TIMESTAMP,
|
|
||||||
VALIDATOR_CONFIRMATION_STATUS
|
|
||||||
} from '../config/constants'
|
|
||||||
import {
|
|
||||||
APIPendingTransaction,
|
|
||||||
APITransaction,
|
|
||||||
GetFailedTransactionParams,
|
|
||||||
GetPendingTransactionParams
|
|
||||||
} from './explorer'
|
|
||||||
|
|
||||||
export const getValidatorConfirmation = (
|
export const getValidatorConfirmation = (
|
||||||
web3: Web3,
|
web3: Web3,
|
||||||
@@ -45,11 +36,13 @@ export const getValidatorConfirmation = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getValidatorSuccessTransaction = (
|
export const getSuccessExecutionTransaction = (
|
||||||
|
web3: Web3,
|
||||||
bridgeContract: Contract,
|
bridgeContract: Contract,
|
||||||
|
fromHome: boolean,
|
||||||
messageData: string,
|
messageData: string,
|
||||||
timestamp: number,
|
startBlock: number,
|
||||||
getSuccessTransactions: (args: GetFailedTransactionParams) => Promise<APITransaction[]>
|
getSuccessTransactions: (args: GetTransactionParams) => Promise<APITransaction[]>
|
||||||
) => async (validatorData: BasicConfirmationParam): Promise<ConfirmationParam> => {
|
) => async (validatorData: BasicConfirmationParam): Promise<ConfirmationParam> => {
|
||||||
const { validator } = validatorData
|
const { validator } = validatorData
|
||||||
const validatorCacheKey = `${CACHE_KEY_SUCCESS}${validatorData.validator}-${messageData}`
|
const validatorCacheKey = `${CACHE_KEY_SUCCESS}${validatorData.validator}-${messageData}`
|
||||||
@@ -63,8 +56,8 @@ export const getValidatorSuccessTransaction = (
|
|||||||
account: validatorData.validator,
|
account: validatorData.validator,
|
||||||
to: bridgeContract.options.address,
|
to: bridgeContract.options.address,
|
||||||
messageData,
|
messageData,
|
||||||
startTimestamp: timestamp,
|
startBlock,
|
||||||
endTimestamp: timestamp + ONE_DAY_TIMESTAMP
|
endBlock: homeBlockNumberProvider.get() || 0
|
||||||
})
|
})
|
||||||
|
|
||||||
let txHashTimestamp = 0
|
let txHashTimestamp = 0
|
||||||
@@ -96,8 +89,8 @@ export const getValidatorSuccessTransaction = (
|
|||||||
export const getValidatorFailedTransaction = (
|
export const getValidatorFailedTransaction = (
|
||||||
bridgeContract: Contract,
|
bridgeContract: Contract,
|
||||||
messageData: string,
|
messageData: string,
|
||||||
timestamp: number,
|
startBlock: number,
|
||||||
getFailedTransactions: (args: GetFailedTransactionParams) => Promise<APITransaction[]>
|
getFailedTransactions: (args: GetTransactionParams) => Promise<APITransaction[]>
|
||||||
) => async (validatorData: BasicConfirmationParam): Promise<ConfirmationParam> => {
|
) => async (validatorData: BasicConfirmationParam): Promise<ConfirmationParam> => {
|
||||||
const validatorCacheKey = `${CACHE_KEY_FAILED}${validatorData.validator}-${messageData}`
|
const validatorCacheKey = `${CACHE_KEY_FAILED}${validatorData.validator}-${messageData}`
|
||||||
const failedFromCache = validatorsCache.getData(validatorCacheKey)
|
const failedFromCache = validatorsCache.getData(validatorCacheKey)
|
||||||
@@ -110,8 +103,8 @@ export const getValidatorFailedTransaction = (
|
|||||||
account: validatorData.validator,
|
account: validatorData.validator,
|
||||||
to: bridgeContract.options.address,
|
to: bridgeContract.options.address,
|
||||||
messageData,
|
messageData,
|
||||||
startTimestamp: timestamp,
|
startBlock,
|
||||||
endTimestamp: timestamp + ONE_DAY_TIMESTAMP
|
endBlock: homeBlockNumberProvider.get() || 0
|
||||||
})
|
})
|
||||||
const newStatus =
|
const newStatus =
|
||||||
failedTransactions.length > 0 ? VALIDATOR_CONFIRMATION_STATUS.FAILED : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
failedTransactions.length > 0 ? VALIDATOR_CONFIRMATION_STATUS.FAILED : VALIDATOR_CONFIRMATION_STATUS.UNDEFINED
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -2600,6 +2600,11 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
|
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
|
||||||
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
|
||||||
|
|
||||||
|
"@types/mocha@^7.0.2":
|
||||||
|
version "7.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-7.0.2.tgz#b17f16cf933597e10d6d78eae3251e692ce8b0ce"
|
||||||
|
integrity sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w==
|
||||||
|
|
||||||
"@types/node@*", "@types/node@>= 8":
|
"@types/node@*", "@types/node@>= 8":
|
||||||
version "13.11.0"
|
version "13.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b"
|
resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b"
|
||||||
@@ -3215,6 +3220,11 @@ are-we-there-yet@~1.1.2:
|
|||||||
delegates "^1.0.0"
|
delegates "^1.0.0"
|
||||||
readable-stream "^2.0.6"
|
readable-stream "^2.0.6"
|
||||||
|
|
||||||
|
arg@^4.1.0:
|
||||||
|
version "4.1.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
|
||||||
|
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
|
||||||
|
|
||||||
argparse@^1.0.7:
|
argparse@^1.0.7:
|
||||||
version "1.0.10"
|
version "1.0.10"
|
||||||
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
|
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
|
||||||
@@ -3340,6 +3350,11 @@ assert@^1.1.1:
|
|||||||
object-assign "^4.1.1"
|
object-assign "^4.1.1"
|
||||||
util "0.10.3"
|
util "0.10.3"
|
||||||
|
|
||||||
|
assertion-error@^1.1.0:
|
||||||
|
version "1.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
|
||||||
|
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
|
||||||
|
|
||||||
assign-symbols@^1.0.0:
|
assign-symbols@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
|
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
|
||||||
@@ -3435,6 +3450,13 @@ axios@^0.18.0:
|
|||||||
follow-redirects "1.5.10"
|
follow-redirects "1.5.10"
|
||||||
is-buffer "^2.0.2"
|
is-buffer "^2.0.2"
|
||||||
|
|
||||||
|
axios@^0.19.0:
|
||||||
|
version "0.19.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
|
||||||
|
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==
|
||||||
|
dependencies:
|
||||||
|
follow-redirects "1.5.10"
|
||||||
|
|
||||||
axobject-query@^2.0.2:
|
axobject-query@^2.0.2:
|
||||||
version "2.1.2"
|
version "2.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.1.2.tgz#2bdffc0371e643e5f03ba99065d5179b9ca79799"
|
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-2.1.2.tgz#2bdffc0371e643e5f03ba99065d5179b9ca79799"
|
||||||
@@ -3799,6 +3821,11 @@ browser-resolve@^1.11.3:
|
|||||||
dependencies:
|
dependencies:
|
||||||
resolve "1.1.7"
|
resolve "1.1.7"
|
||||||
|
|
||||||
|
browser-stdout@1.3.1:
|
||||||
|
version "1.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60"
|
||||||
|
integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==
|
||||||
|
|
||||||
browserify-aes@^1.0.0, browserify-aes@^1.0.4, browserify-aes@^1.0.6:
|
browserify-aes@^1.0.0, browserify-aes@^1.0.4, browserify-aes@^1.0.6:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48"
|
resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48"
|
||||||
@@ -4188,6 +4215,18 @@ caseless@~0.12.0:
|
|||||||
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
|
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"
|
||||||
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=
|
integrity sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=
|
||||||
|
|
||||||
|
chai@^4.2.0:
|
||||||
|
version "4.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/chai/-/chai-4.2.0.tgz#760aa72cf20e3795e84b12877ce0e83737aa29e5"
|
||||||
|
integrity sha512-XQU3bhBukrOsQCuwZndwGcCVQHyZi53fQ6Ys1Fym7E4olpIqqZZhhoFJoaKVvV17lWQoXYwgWN2nF5crA8J2jw==
|
||||||
|
dependencies:
|
||||||
|
assertion-error "^1.1.0"
|
||||||
|
check-error "^1.0.2"
|
||||||
|
deep-eql "^3.0.1"
|
||||||
|
get-func-name "^2.0.0"
|
||||||
|
pathval "^1.1.0"
|
||||||
|
type-detect "^4.0.5"
|
||||||
|
|
||||||
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.4.1, chalk@^2.4.2:
|
chalk@2.4.2, chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.3.0, chalk@^2.3.1, chalk@^2.4.1, chalk@^2.4.2:
|
||||||
version "2.4.2"
|
version "2.4.2"
|
||||||
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
|
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
|
||||||
@@ -4213,6 +4252,11 @@ chardet@^0.7.0:
|
|||||||
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
|
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"
|
||||||
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
|
integrity sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==
|
||||||
|
|
||||||
|
check-error@^1.0.2:
|
||||||
|
version "1.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
|
||||||
|
integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=
|
||||||
|
|
||||||
check-types@^8.0.3:
|
check-types@^8.0.3:
|
||||||
version "8.0.3"
|
version "8.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552"
|
resolved "https://registry.yarnpkg.com/check-types/-/check-types-8.0.3.tgz#3356cca19c889544f2d7a95ed49ce508a0ecf552"
|
||||||
@@ -4446,6 +4490,11 @@ combined-stream@^1.0.6, combined-stream@~1.0.6:
|
|||||||
dependencies:
|
dependencies:
|
||||||
delayed-stream "~1.0.0"
|
delayed-stream "~1.0.0"
|
||||||
|
|
||||||
|
commander@2.15.1:
|
||||||
|
version "2.15.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f"
|
||||||
|
integrity sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==
|
||||||
|
|
||||||
commander@2.17.x:
|
commander@2.17.x:
|
||||||
version "2.17.1"
|
version "2.17.1"
|
||||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
|
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf"
|
||||||
@@ -5241,6 +5290,13 @@ dedent@^0.7.0:
|
|||||||
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
|
resolved "https://registry.yarnpkg.com/dedent/-/dedent-0.7.0.tgz#2495ddbaf6eb874abb0e1be9df22d2e5a544326c"
|
||||||
integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=
|
integrity sha1-JJXduvbrh0q7Dhvp3yLS5aVEMmw=
|
||||||
|
|
||||||
|
deep-eql@^3.0.1:
|
||||||
|
version "3.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-3.0.1.tgz#dfc9404400ad1c8fe023e7da1df1c147c4b444df"
|
||||||
|
integrity sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==
|
||||||
|
dependencies:
|
||||||
|
type-detect "^4.0.0"
|
||||||
|
|
||||||
deep-equal@^1.0.1:
|
deep-equal@^1.0.1:
|
||||||
version "1.1.1"
|
version "1.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
|
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.1.1.tgz#b5c98c942ceffaf7cb051e24e1434a25a2e6076a"
|
||||||
@@ -5413,6 +5469,16 @@ diff-sequences@^24.9.0:
|
|||||||
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
|
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.9.0.tgz#5715d6244e2aa65f48bba0bc972db0b0b11e95b5"
|
||||||
integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==
|
integrity sha512-Dj6Wk3tWyTE+Fo1rW8v0Xhwk80um6yFYKbuAxc9c3EZxIHFDYwbi34Uk42u1CdnIiVorvt4RmlSDjIPyzGC2ew==
|
||||||
|
|
||||||
|
diff@3.5.0:
|
||||||
|
version "3.5.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
|
||||||
|
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
|
||||||
|
|
||||||
|
diff@^4.0.1:
|
||||||
|
version "4.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
|
||||||
|
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
|
||||||
|
|
||||||
diffie-hellman@^5.0.0:
|
diffie-hellman@^5.0.0:
|
||||||
version "5.0.3"
|
version "5.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
|
resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875"
|
||||||
@@ -7093,6 +7159,11 @@ get-caller-file@^2.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
|
||||||
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
|
||||||
|
|
||||||
|
get-func-name@^2.0.0:
|
||||||
|
version "2.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
|
||||||
|
integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=
|
||||||
|
|
||||||
get-own-enumerable-property-symbols@^3.0.0:
|
get-own-enumerable-property-symbols@^3.0.0:
|
||||||
version "3.0.2"
|
version "3.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz#b5fde77f22cbe35f390b4e089922c50bce6ef664"
|
resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.2.tgz#b5fde77f22cbe35f390b4e089922c50bce6ef664"
|
||||||
@@ -7227,6 +7298,18 @@ glob-to-regexp@^0.3.0:
|
|||||||
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
|
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
|
||||||
integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=
|
integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=
|
||||||
|
|
||||||
|
glob@7.1.2:
|
||||||
|
version "7.1.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"
|
||||||
|
integrity sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==
|
||||||
|
dependencies:
|
||||||
|
fs.realpath "^1.0.0"
|
||||||
|
inflight "^1.0.4"
|
||||||
|
inherits "2"
|
||||||
|
minimatch "^3.0.4"
|
||||||
|
once "^1.3.0"
|
||||||
|
path-is-absolute "^1.0.0"
|
||||||
|
|
||||||
glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4:
|
glob@^7.0.3, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4:
|
||||||
version "7.1.6"
|
version "7.1.6"
|
||||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
|
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
|
||||||
@@ -7360,6 +7443,11 @@ graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.
|
|||||||
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
|
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
|
||||||
integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=
|
integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=
|
||||||
|
|
||||||
|
growl@1.10.5:
|
||||||
|
version "1.10.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
|
||||||
|
integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==
|
||||||
|
|
||||||
growly@^1.3.0:
|
growly@^1.3.0:
|
||||||
version "1.3.0"
|
version "1.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
|
resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081"
|
||||||
@@ -7518,6 +7606,11 @@ hdkey@^1.1.1:
|
|||||||
safe-buffer "^5.1.1"
|
safe-buffer "^5.1.1"
|
||||||
secp256k1 "^3.0.1"
|
secp256k1 "^3.0.1"
|
||||||
|
|
||||||
|
he@1.1.1:
|
||||||
|
version "1.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/he/-/he-1.1.1.tgz#93410fd21b009735151f8868c2f271f3427e23fd"
|
||||||
|
integrity sha1-k0EP0hsAlzUVH4howvJx80J+I/0=
|
||||||
|
|
||||||
he@1.2.x:
|
he@1.2.x:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
||||||
@@ -9592,6 +9685,11 @@ make-dir@^2.0.0, make-dir@^2.1.0:
|
|||||||
pify "^4.0.1"
|
pify "^4.0.1"
|
||||||
semver "^5.6.0"
|
semver "^5.6.0"
|
||||||
|
|
||||||
|
make-error@^1.1.1:
|
||||||
|
version "1.3.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
|
||||||
|
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
|
||||||
|
|
||||||
make-fetch-happen@^5.0.0:
|
make-fetch-happen@^5.0.0:
|
||||||
version "5.0.2"
|
version "5.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-5.0.2.tgz#aa8387104f2687edca01c8687ee45013d02d19bd"
|
resolved "https://registry.yarnpkg.com/make-fetch-happen/-/make-fetch-happen-5.0.2.tgz#aa8387104f2687edca01c8687ee45013d02d19bd"
|
||||||
@@ -9943,6 +10041,11 @@ minimist-options@^3.0.1:
|
|||||||
arrify "^1.0.1"
|
arrify "^1.0.1"
|
||||||
is-plain-obj "^1.1.0"
|
is-plain-obj "^1.1.0"
|
||||||
|
|
||||||
|
minimist@0.0.8:
|
||||||
|
version "0.0.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"
|
||||||
|
integrity sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=
|
||||||
|
|
||||||
minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5:
|
minimist@^1.1.1, minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5:
|
||||||
version "1.2.5"
|
version "1.2.5"
|
||||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602"
|
||||||
@@ -10007,6 +10110,13 @@ mkdirp@*:
|
|||||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
|
||||||
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
|
||||||
|
|
||||||
|
mkdirp@0.5.1:
|
||||||
|
version "0.5.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903"
|
||||||
|
integrity sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=
|
||||||
|
dependencies:
|
||||||
|
minimist "0.0.8"
|
||||||
|
|
||||||
mkdirp@^0.5.0, mkdirp@^0.5.1:
|
mkdirp@^0.5.0, mkdirp@^0.5.1:
|
||||||
version "0.5.5"
|
version "0.5.5"
|
||||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
|
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def"
|
||||||
@@ -10021,6 +10131,23 @@ mkdirp@~0.5.0, mkdirp@~0.5.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
minimist "^1.2.5"
|
minimist "^1.2.5"
|
||||||
|
|
||||||
|
mocha@^5.2.0:
|
||||||
|
version "5.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/mocha/-/mocha-5.2.0.tgz#6d8ae508f59167f940f2b5b3c4a612ae50c90ae6"
|
||||||
|
integrity sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==
|
||||||
|
dependencies:
|
||||||
|
browser-stdout "1.3.1"
|
||||||
|
commander "2.15.1"
|
||||||
|
debug "3.1.0"
|
||||||
|
diff "3.5.0"
|
||||||
|
escape-string-regexp "1.0.5"
|
||||||
|
glob "7.1.2"
|
||||||
|
growl "1.10.5"
|
||||||
|
he "1.1.1"
|
||||||
|
minimatch "3.0.4"
|
||||||
|
mkdirp "0.5.1"
|
||||||
|
supports-color "5.4.0"
|
||||||
|
|
||||||
mock-fs@^4.1.0:
|
mock-fs@^4.1.0:
|
||||||
version "4.11.0"
|
version "4.11.0"
|
||||||
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.11.0.tgz#0828107e4b843a6ba855ecebfe3c6e073b69db92"
|
resolved "https://registry.yarnpkg.com/mock-fs/-/mock-fs-4.11.0.tgz#0828107e4b843a6ba855ecebfe3c6e073b69db92"
|
||||||
@@ -10967,6 +11094,11 @@ path-type@^4.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
|
||||||
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
|
||||||
|
|
||||||
|
pathval@^1.1.0:
|
||||||
|
version "1.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.0.tgz#b942e6d4bde653005ef6b71361def8727d0645e0"
|
||||||
|
integrity sha1-uULm1L3mUwBe9rcTYd74cn0GReA=
|
||||||
|
|
||||||
pbkdf2@^3.0.3:
|
pbkdf2@^3.0.3:
|
||||||
version "3.0.17"
|
version "3.0.17"
|
||||||
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6"
|
resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6"
|
||||||
@@ -13271,6 +13403,14 @@ source-map-support@0.5.6:
|
|||||||
buffer-from "^1.0.0"
|
buffer-from "^1.0.0"
|
||||||
source-map "^0.6.0"
|
source-map "^0.6.0"
|
||||||
|
|
||||||
|
source-map-support@^0.5.17:
|
||||||
|
version "0.5.19"
|
||||||
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61"
|
||||||
|
integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==
|
||||||
|
dependencies:
|
||||||
|
buffer-from "^1.0.0"
|
||||||
|
source-map "^0.6.0"
|
||||||
|
|
||||||
source-map-support@^0.5.6, source-map-support@~0.5.10, source-map-support@~0.5.12:
|
source-map-support@^0.5.6, source-map-support@~0.5.10, source-map-support@~0.5.12:
|
||||||
version "0.5.16"
|
version "0.5.16"
|
||||||
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042"
|
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.16.tgz#0ae069e7fe3ba7538c64c98515e35339eac5a042"
|
||||||
@@ -13712,6 +13852,13 @@ stylis@^3.5.0:
|
|||||||
resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.5.4.tgz#f665f25f5e299cf3d64654ab949a57c768b73fbe"
|
resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.5.4.tgz#f665f25f5e299cf3d64654ab949a57c768b73fbe"
|
||||||
integrity sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q==
|
integrity sha512-8/3pSmthWM7lsPBKv7NXkzn2Uc9W7NotcwGNpJaa3k7WMM1XDCA4MgT5k/8BIexd5ydZdboXtU90XH9Ec4Bv/Q==
|
||||||
|
|
||||||
|
supports-color@5.4.0:
|
||||||
|
version "5.4.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54"
|
||||||
|
integrity sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==
|
||||||
|
dependencies:
|
||||||
|
has-flag "^3.0.0"
|
||||||
|
|
||||||
supports-color@^2.0.0:
|
supports-color@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
|
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
|
||||||
@@ -14076,6 +14223,17 @@ tryer@^1.0.1:
|
|||||||
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
|
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
|
||||||
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
|
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==
|
||||||
|
|
||||||
|
ts-node@^8.8.2:
|
||||||
|
version "8.10.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-8.10.2.tgz#eee03764633b1234ddd37f8db9ec10b75ec7fb8d"
|
||||||
|
integrity sha512-ISJJGgkIpDdBhWVu3jufsWpK3Rzo7bdiIXJjQc0ynKxVOVcg2oIrf2H2cejminGrptVc6q6/uynAHNCuWGbpVA==
|
||||||
|
dependencies:
|
||||||
|
arg "^4.1.0"
|
||||||
|
diff "^4.0.1"
|
||||||
|
make-error "^1.1.1"
|
||||||
|
source-map-support "^0.5.17"
|
||||||
|
yn "3.1.1"
|
||||||
|
|
||||||
ts-pnp@1.1.2:
|
ts-pnp@1.1.2:
|
||||||
version "1.1.2"
|
version "1.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.2.tgz#be8e4bfce5d00f0f58e0666a82260c34a57af552"
|
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.1.2.tgz#be8e4bfce5d00f0f58e0666a82260c34a57af552"
|
||||||
@@ -14122,6 +14280,11 @@ type-check@~0.3.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
prelude-ls "~1.1.2"
|
prelude-ls "~1.1.2"
|
||||||
|
|
||||||
|
type-detect@^4.0.0, type-detect@^4.0.5:
|
||||||
|
version "4.0.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
|
||||||
|
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
|
||||||
|
|
||||||
type-fest@^0.3.0:
|
type-fest@^0.3.0:
|
||||||
version "0.3.1"
|
version "0.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1"
|
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.3.1.tgz#63d00d204e059474fe5e1b7c011112bbd1dc29e1"
|
||||||
@@ -14167,6 +14330,11 @@ typescript@3.5.3:
|
|||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977"
|
||||||
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
|
integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==
|
||||||
|
|
||||||
|
typescript@^3.5.2:
|
||||||
|
version "3.9.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.9.7.tgz#98d600a5ebdc38f40cb277522f12dc800e9e25fa"
|
||||||
|
integrity sha512-BLbiRkiBzAwsjut4x/dsibSTB6yWpwT5qWmC2OfuCg3GgVQCSgMs4vEctYPhsaGtd0AeuuHMkjZ2h2WG8MSzRw==
|
||||||
|
|
||||||
uglify-js@3.4.x:
|
uglify-js@3.4.x:
|
||||||
version "3.4.10"
|
version "3.4.10"
|
||||||
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"
|
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.10.tgz#9ad9563d8eb3acdfb8d38597d2af1d815f6a755f"
|
||||||
@@ -15481,3 +15649,8 @@ yauzl@^2.4.2:
|
|||||||
dependencies:
|
dependencies:
|
||||||
buffer-crc32 "~0.2.3"
|
buffer-crc32 "~0.2.3"
|
||||||
fd-slicer "~1.1.0"
|
fd-slicer "~1.1.0"
|
||||||
|
|
||||||
|
yn@3.1.1:
|
||||||
|
version "3.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
|
||||||
|
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-unused-expressions": "off",
|
"no-unused-expressions": "off",
|
||||||
"import/no-extraneous-dependencies": "off"
|
"import/no-extraneous-dependencies": "off",
|
||||||
|
"no-bitwise": "off"
|
||||||
},
|
},
|
||||||
"env": {
|
"env": {
|
||||||
"mocha": true
|
"mocha": true
|
||||||
|
|||||||
@@ -2,9 +2,15 @@ function strip0x(input) {
|
|||||||
return input.replace(/^0x/, '')
|
return input.replace(/^0x/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function addTxHashToData({ encodedData, transactionHash }) {
|
/**
|
||||||
return encodedData.slice(0, 2) + strip0x(transactionHash) + encodedData.slice(2)
|
* Decodes the datatype byte from the AMB message.
|
||||||
}
|
* First (the most significant bit) denotes if the message should be forwarded to the manual lane.
|
||||||
|
* @param dataType: number datatype of the received AMB message.
|
||||||
|
* @return {{manualLane: boolean}}
|
||||||
|
*/
|
||||||
|
const decodeAMBDataType = dataType => ({
|
||||||
|
manualLane: (dataType & 128) === 128
|
||||||
|
})
|
||||||
|
|
||||||
function parseAMBMessage(message) {
|
function parseAMBMessage(message) {
|
||||||
message = strip0x(message)
|
message = strip0x(message)
|
||||||
@@ -12,16 +18,29 @@ function parseAMBMessage(message) {
|
|||||||
const messageId = `0x${message.slice(0, 64)}`
|
const messageId = `0x${message.slice(0, 64)}`
|
||||||
const sender = `0x${message.slice(64, 104)}`
|
const sender = `0x${message.slice(64, 104)}`
|
||||||
const executor = `0x${message.slice(104, 144)}`
|
const executor = `0x${message.slice(104, 144)}`
|
||||||
|
const dataType = parseInt(message.slice(156, 158), 16)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
sender,
|
sender,
|
||||||
executor,
|
executor,
|
||||||
messageId
|
messageId,
|
||||||
|
dataType,
|
||||||
|
decodedDataType: decodeAMBDataType(dataType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
const normalizeAMBMessageEvent = e => {
|
||||||
addTxHashToData,
|
let msgData = e.returnValues.encodedData
|
||||||
parseAMBMessage,
|
if (!e.returnValues.messageId) {
|
||||||
strip0x
|
// append tx hash to an old message, where message id was not used
|
||||||
|
// for old messages, e.messageId is a corresponding transactionHash
|
||||||
|
msgData = e.transactionHash + msgData.slice(2)
|
||||||
|
}
|
||||||
|
return parseAMBMessage(msgData)
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
strip0x,
|
||||||
|
parseAMBMessage,
|
||||||
|
normalizeAMBMessageEvent
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
const { BN } = require('web3-utils')
|
const { BN } = require('web3-utils')
|
||||||
const { expect } = require('chai').use(require('bn-chai')(BN))
|
const { expect } = require('chai').use(require('bn-chai')(BN))
|
||||||
const { parseAMBMessage, strip0x, addTxHashToData } = require('../message')
|
const { parseAMBMessage, strip0x } = require('../message')
|
||||||
|
|
||||||
describe('strip0x', () => {
|
describe('strip0x', () => {
|
||||||
it('should remove 0x from input', () => {
|
it('should remove 0x from input', () => {
|
||||||
@@ -24,28 +24,6 @@ describe('strip0x', () => {
|
|||||||
expect(result).to.be.equal(input)
|
expect(result).to.be.equal(input)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
describe('addTxHashToData', () => {
|
|
||||||
it('should add txHash to encoded data at position 2', () => {
|
|
||||||
// Given
|
|
||||||
const msgSender = '0x003667154bb32e42bb9e1e6532f19d187fa0082e'
|
|
||||||
const msgExecutor = '0xf4bef13f9f4f2b203faf0c3cbbaabe1afe056955'
|
|
||||||
const msgGasLimit = '000000000000000000000000000000000000000000000000000000005b877705'
|
|
||||||
const msgDataType = '00'
|
|
||||||
const msgData = '0xb1591967aed668a4b27645ff40c444892d91bf5951b382995d4d4f6ee3a2ce03'
|
|
||||||
const encodedData = `0x${strip0x(msgSender)}${strip0x(msgExecutor)}${msgGasLimit}${msgDataType}${strip0x(msgData)}`
|
|
||||||
|
|
||||||
const transactionHash = '0xbdceda9d8c94838aca10c687da1411a07b1390e88239c0638cb9cc264219cc10'
|
|
||||||
const message = `0x${strip0x(transactionHash)}${strip0x(msgSender)}${strip0x(
|
|
||||||
msgExecutor
|
|
||||||
)}${msgGasLimit}${msgDataType}${strip0x(msgData)}`
|
|
||||||
|
|
||||||
// When
|
|
||||||
const result = addTxHashToData({ encodedData, transactionHash })
|
|
||||||
|
|
||||||
// Then
|
|
||||||
expect(result).to.be.equal(message)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe('parseAMBMessage', () => {
|
describe('parseAMBMessage', () => {
|
||||||
it('should parse data type 00', () => {
|
it('should parse data type 00', () => {
|
||||||
const msgSender = '0x003667154bb32e42bb9e1e6532f19d187fa0082e'
|
const msgSender = '0x003667154bb32e42bb9e1e6532f19d187fa0082e'
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
const { toWei, toBN } = require('web3-utils')
|
const { toWei, toBN, BN } = require('web3-utils')
|
||||||
const { GasPriceOracle } = require('gas-price-oracle')
|
const { GasPriceOracle } = require('gas-price-oracle')
|
||||||
const { BRIDGE_MODES, FEE_MANAGER_MODE, ERC_TYPES } = require('./constants')
|
const { BRIDGE_MODES, FEE_MANAGER_MODE, ERC_TYPES } = require('./constants')
|
||||||
const { REWARDABLE_VALIDATORS_ABI } = require('./abis')
|
const { REWARDABLE_VALIDATORS_ABI } = require('./abis')
|
||||||
@@ -150,11 +150,8 @@ const tryCall = async (method, fallbackValue) => {
|
|||||||
|
|
||||||
const getDeployedAtBlock = async contract => tryCall(contract.methods.deployedAtBlock(), 0)
|
const getDeployedAtBlock = async contract => tryCall(contract.methods.deployedAtBlock(), 0)
|
||||||
|
|
||||||
const getPastEvents = async (
|
const getPastEventsOrSplit = async (contract, { event, fromBlock, toBlock, options }) => {
|
||||||
contract,
|
let events = []
|
||||||
{ event = 'allEvents', fromBlock = toBN(0), toBlock = 'latest', options = {} }
|
|
||||||
) => {
|
|
||||||
let events
|
|
||||||
try {
|
try {
|
||||||
events = await contract.getPastEvents(event, {
|
events = await contract.getPastEvents(event, {
|
||||||
...options,
|
...options,
|
||||||
@@ -162,20 +159,20 @@ const getPastEvents = async (
|
|||||||
toBlock
|
toBlock
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e.message.includes('query returned more than') && toBlock !== 'latest') {
|
if (e.message.includes('query returned more than') || e.message.toLowerCase().includes('timeout')) {
|
||||||
const middle = toBN(fromBlock)
|
const middle = toBN(fromBlock)
|
||||||
.add(toBlock)
|
.add(toBN(toBlock))
|
||||||
.divRound(toBN(2))
|
.divRound(toBN(2))
|
||||||
const middlePlusOne = middle.add(toBN(1))
|
const middlePlusOne = middle.add(toBN(1))
|
||||||
|
|
||||||
const firstHalfEvents = await getPastEvents(contract, {
|
const firstHalfEvents = await getPastEventsOrSplit(contract, {
|
||||||
...options,
|
options,
|
||||||
event,
|
event,
|
||||||
fromBlock,
|
fromBlock,
|
||||||
toBlock: middle
|
toBlock: middle
|
||||||
})
|
})
|
||||||
const secondHalfEvents = await getPastEvents(contract, {
|
const secondHalfEvents = await getPastEventsOrSplit(contract, {
|
||||||
...options,
|
options,
|
||||||
event,
|
event,
|
||||||
fromBlock: middlePlusOne,
|
fromBlock: middlePlusOne,
|
||||||
toBlock
|
toBlock
|
||||||
@@ -188,6 +185,31 @@ const getPastEvents = async (
|
|||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getPastEvents = async (
|
||||||
|
contract,
|
||||||
|
{ event = 'allEvents', fromBlock = toBN(0), toBlock = 'latest', options = {} }
|
||||||
|
) => {
|
||||||
|
if (toBlock === 'latest') {
|
||||||
|
return contract.getPastEvents(event, {
|
||||||
|
...options,
|
||||||
|
fromBlock,
|
||||||
|
toBlock
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const batchSize = 1000000
|
||||||
|
const to = toBN(toBlock)
|
||||||
|
const events = []
|
||||||
|
|
||||||
|
for (let from = toBN(fromBlock); from.lte(to); from = from.addn(batchSize + 1)) {
|
||||||
|
const opts = { event, fromBlock: from, toBlock: BN.min(to, from.addn(batchSize)), options }
|
||||||
|
const batch = await getPastEventsOrSplit(contract, opts)
|
||||||
|
events.push(batch)
|
||||||
|
}
|
||||||
|
|
||||||
|
return [].concat(...events)
|
||||||
|
}
|
||||||
|
|
||||||
const getValidatorList = async (address, eth, options) => {
|
const getValidatorList = async (address, eth, options) => {
|
||||||
options.logger && options.logger.debug && options.logger.debug('getting validatorList')
|
options.logger && options.logger.debug && options.logger.debug('getting validatorList')
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,20 @@ const homeV1Abi = [
|
|||||||
payable: false,
|
payable: false,
|
||||||
stateMutability: 'view',
|
stateMutability: 'view',
|
||||||
type: 'function'
|
type: 'function'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
constant: true,
|
||||||
|
inputs: [],
|
||||||
|
name: 'requiredBlockConfirmations',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
name: '',
|
||||||
|
type: 'uint256'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
payable: false,
|
||||||
|
stateMutability: 'view',
|
||||||
|
type: 'function'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -154,6 +168,20 @@ const foreignViAbi = [
|
|||||||
payable: false,
|
payable: false,
|
||||||
stateMutability: 'view',
|
stateMutability: 'view',
|
||||||
type: 'function'
|
type: 'function'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
constant: true,
|
||||||
|
inputs: [],
|
||||||
|
name: 'requiredBlockConfirmations',
|
||||||
|
outputs: [
|
||||||
|
{
|
||||||
|
name: '',
|
||||||
|
type: 'uint256'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
payable: false,
|
||||||
|
stateMutability: 'view',
|
||||||
|
type: 'function'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Submodule contracts updated: dd46135248...c9377114f7
@@ -16,7 +16,7 @@ Alternatively, if there are no changes except the playbooks, you can use the `ma
|
|||||||
./molecule.sh <scenario_name>
|
./molecule.sh <scenario_name>
|
||||||
```
|
```
|
||||||
|
|
||||||
In this case `master` branch will be used as a codebase for Monitor, UI, Oracle and Contracts deployed by your local playbook.
|
In this case `master` branch will be used as a codebase for Monitor, Oracle and Contracts deployed by your local playbook.
|
||||||
|
|
||||||
## Run the tests
|
## Run the tests
|
||||||
|
|
||||||
@@ -29,7 +29,6 @@ Available scenarios:
|
|||||||
Scenario | Description
|
Scenario | Description
|
||||||
--- | ---
|
--- | ---
|
||||||
oracle | Deploys and checks standalone Oracle on Ubuntu host
|
oracle | Deploys and checks standalone Oracle on Ubuntu host
|
||||||
ui | Deploys and checks standalone UI on Ubuntu host
|
|
||||||
|
|
||||||
## Ultimate E2E tests
|
## Ultimate E2E tests
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ platforms:
|
|||||||
children:
|
children:
|
||||||
- oracle
|
- oracle
|
||||||
- monitor
|
- monitor
|
||||||
- ui
|
|
||||||
image: ubuntu:16.04
|
image: ubuntu:16.04
|
||||||
privileged: true
|
privileged: true
|
||||||
network_mode: host
|
network_mode: host
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
|
|
||||||
@pytest.mark.parametrize("service", [
|
@pytest.mark.parametrize("service", [
|
||||||
("poabridge"),
|
("poabridge"),
|
||||||
("tokenbridge-ui"),
|
|
||||||
("tokenbridge-monitor")
|
("tokenbridge-monitor")
|
||||||
])
|
])
|
||||||
def test_services(host, service):
|
def test_services(host, service):
|
||||||
@@ -24,7 +23,7 @@ def test_services(host, service):
|
|||||||
("oracle_bridge_affirmation_1"),
|
("oracle_bridge_affirmation_1"),
|
||||||
("oracle_bridge_senderhome_1"),
|
("oracle_bridge_senderhome_1"),
|
||||||
("oracle_bridge_senderforeign_1"),
|
("oracle_bridge_senderforeign_1"),
|
||||||
("ui_ui_1"),
|
("oracle_bridge_shutdown_1"),
|
||||||
("monitor_monitor_1")
|
("monitor_monitor_1")
|
||||||
])
|
])
|
||||||
def test_docker_containers(host, name):
|
def test_docker_containers(host, name):
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
("oracle_bridge_affirmation_1"),
|
("oracle_bridge_affirmation_1"),
|
||||||
("oracle_bridge_senderhome_1"),
|
("oracle_bridge_senderhome_1"),
|
||||||
("oracle_bridge_senderforeign_1"),
|
("oracle_bridge_senderforeign_1"),
|
||||||
|
("oracle_bridge_shutdown_1"),
|
||||||
])
|
])
|
||||||
def test_docker_containers(host, name):
|
def test_docker_containers(host, name):
|
||||||
container = host.docker(name)
|
container = host.docker(name)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|||||||
("/home/poadocker/bridge/contracts"),
|
("/home/poadocker/bridge/contracts"),
|
||||||
("/home/poadocker/bridge/oracle"),
|
("/home/poadocker/bridge/oracle"),
|
||||||
("/home/poadocker/bridge/monitor"),
|
("/home/poadocker/bridge/monitor"),
|
||||||
("/home/poadocker/bridge/ui"),
|
|
||||||
("/home/poadocker/bridge/parity")
|
("/home/poadocker/bridge/parity")
|
||||||
])
|
])
|
||||||
def test_existing_folders(host, path):
|
def test_existing_folders(host, path):
|
||||||
@@ -28,8 +27,7 @@ def test_existing_folders(host, path):
|
|||||||
("/home/poadocker/bridge/commons/package.json"),
|
("/home/poadocker/bridge/commons/package.json"),
|
||||||
("/home/poadocker/bridge/contracts/package.json"),
|
("/home/poadocker/bridge/contracts/package.json"),
|
||||||
("/home/poadocker/bridge/oracle/package.json"),
|
("/home/poadocker/bridge/oracle/package.json"),
|
||||||
("/home/poadocker/bridge/monitor/package.json"),
|
("/home/poadocker/bridge/monitor/package.json")
|
||||||
("/home/poadocker/bridge/ui/package.json")
|
|
||||||
])
|
])
|
||||||
def test_existing_package_json(host, path):
|
def test_existing_package_json(host, path):
|
||||||
assert host.file(path).exists
|
assert host.file(path).exists
|
||||||
@@ -41,8 +39,7 @@ def test_existing_package_json(host, path):
|
|||||||
("/home/poadocker/bridge/contracts/Dockerfile"),
|
("/home/poadocker/bridge/contracts/Dockerfile"),
|
||||||
("/home/poadocker/bridge/parity/Dockerfile"),
|
("/home/poadocker/bridge/parity/Dockerfile"),
|
||||||
("/home/poadocker/bridge/oracle/Dockerfile"),
|
("/home/poadocker/bridge/oracle/Dockerfile"),
|
||||||
("/home/poadocker/bridge/monitor/Dockerfile"),
|
("/home/poadocker/bridge/monitor/Dockerfile")
|
||||||
("/home/poadocker/bridge/ui/Dockerfile")
|
|
||||||
])
|
])
|
||||||
def test_existing_docker_files(host, path):
|
def test_existing_docker_files(host, path):
|
||||||
assert host.file(path).exists
|
assert host.file(path).exists
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
# Molecule managed
|
|
||||||
|
|
||||||
{% if item.registry is defined %}
|
|
||||||
FROM {{ item.registry.url }}/{{ item.image }}
|
|
||||||
{% else %}
|
|
||||||
FROM {{ item.image }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
|
||||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
|
|
||||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
|
||||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
|
|
||||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
|
||||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
---
|
|
||||||
dependency:
|
|
||||||
name: galaxy
|
|
||||||
driver:
|
|
||||||
name: docker
|
|
||||||
lint:
|
|
||||||
name: yamllint
|
|
||||||
enabled: True
|
|
||||||
options:
|
|
||||||
config-data:
|
|
||||||
ignore: ../../hosts.yml
|
|
||||||
platforms:
|
|
||||||
- name: ui-host
|
|
||||||
groups:
|
|
||||||
- example
|
|
||||||
children:
|
|
||||||
- ui
|
|
||||||
image: ubuntu:16.04
|
|
||||||
privileged: true
|
|
||||||
network_mode: host
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
provisioner:
|
|
||||||
name: ansible
|
|
||||||
lint:
|
|
||||||
name: ansible-lint
|
|
||||||
enabled: True
|
|
||||||
options:
|
|
||||||
r: ["bug"]
|
|
||||||
playbooks:
|
|
||||||
prepare: ../prepare.yml
|
|
||||||
converge: ../../../deployment/site.yml
|
|
||||||
inventory:
|
|
||||||
host_vars:
|
|
||||||
ui-host:
|
|
||||||
syslog_server_port: "udp://127.0.0.1:514"
|
|
||||||
verifier:
|
|
||||||
name: testinfra
|
|
||||||
lint:
|
|
||||||
name: flake8
|
|
||||||
additional_files_or_dirs:
|
|
||||||
- ../../tests/*
|
|
||||||
scenario:
|
|
||||||
name: ui
|
|
||||||
test_sequence:
|
|
||||||
- lint
|
|
||||||
- cleanup
|
|
||||||
- destroy
|
|
||||||
- dependency
|
|
||||||
- syntax
|
|
||||||
- create
|
|
||||||
- prepare
|
|
||||||
- converge
|
|
||||||
- verify
|
|
||||||
- destroy
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
import os
|
|
||||||
import pytest
|
|
||||||
import testinfra.utils.ansible_runner
|
|
||||||
|
|
||||||
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
|
|
||||||
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('ui')
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("name", [
|
|
||||||
("ui_ui_1")
|
|
||||||
])
|
|
||||||
def test_docker_containers(host, name):
|
|
||||||
container = host.docker(name)
|
|
||||||
assert container.is_running
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("service", [
|
|
||||||
("tokenbridge-ui"),
|
|
||||||
("rsyslog")
|
|
||||||
])
|
|
||||||
def test_services(host, service):
|
|
||||||
assert host.service(service).is_enabled
|
|
||||||
assert host.service(service).is_running
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("filename", [
|
|
||||||
("/etc/rsyslog.d/32-ui-docker.conf"),
|
|
||||||
("/etc/rsyslog.d/37-ui-remote-logging.conf")
|
|
||||||
])
|
|
||||||
def test_logging(host, filename):
|
|
||||||
assert host.file(filename).exists
|
|
||||||
assert host.file(filename).mode == 0o0644
|
|
||||||
|
|
||||||
|
|
||||||
def test_index_page_title(host):
|
|
||||||
assert host.run_test(
|
|
||||||
'curl -s http://localhost:3001 | '
|
|
||||||
'grep "<title>" | '
|
|
||||||
'grep -q "TokenBridge UI app"'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_index_page_error(host):
|
|
||||||
assert host.run_expect(
|
|
||||||
[1],
|
|
||||||
'curl -s http://localhost:3001 | '
|
|
||||||
'grep -i -q "error"'
|
|
||||||
)
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
# Molecule managed
|
|
||||||
|
|
||||||
{% if item.registry is defined %}
|
|
||||||
FROM {{ item.registry.url }}/{{ item.image }}
|
|
||||||
{% else %}
|
|
||||||
FROM {{ item.image }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
|
|
||||||
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
|
|
||||||
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
|
|
||||||
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
|
|
||||||
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
|
|
||||||
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
---
|
|
||||||
driver:
|
|
||||||
name: docker
|
|
||||||
platforms:
|
|
||||||
- name: oracle-amb-host
|
|
||||||
groups:
|
|
||||||
- ultimate
|
|
||||||
- amb
|
|
||||||
children:
|
|
||||||
- oracle
|
|
||||||
image: ubuntu:16.04
|
|
||||||
privileged: true
|
|
||||||
network_mode: host
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
- name: ui-amb-stake-erc-to-erc-host
|
|
||||||
groups:
|
|
||||||
- ultimate
|
|
||||||
- amb-stake-erc-to-erc
|
|
||||||
children:
|
|
||||||
- ui
|
|
||||||
image: ubuntu:16.04
|
|
||||||
privileged: true
|
|
||||||
network_mode: host
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
provisioner:
|
|
||||||
name: ansible
|
|
||||||
playbooks:
|
|
||||||
prepare: ../prepare.yml
|
|
||||||
converge: ../ultimate-commons/converge.yml
|
|
||||||
inventory:
|
|
||||||
host_vars:
|
|
||||||
oracle-amb-host:
|
|
||||||
COMMON_HOME_RPC_URL: "http://parity1:8545"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://parity2:8545"
|
|
||||||
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
|
||||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
|
||||||
ui-amb-stake-erc-to-erc-host:
|
|
||||||
COMMON_HOME_RPC_URL: "http://localhost:8541"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://localhost:8542"
|
|
||||||
verifier:
|
|
||||||
name: testinfra
|
|
||||||
lint:
|
|
||||||
name: flake8
|
|
||||||
scenario:
|
|
||||||
name: ultimate-amb-stake-erc-to-erc
|
|
||||||
test_sequence:
|
|
||||||
- cleanup
|
|
||||||
- destroy
|
|
||||||
- syntax
|
|
||||||
- create
|
|
||||||
- prepare
|
|
||||||
- converge
|
|
||||||
@@ -21,8 +21,6 @@ provisioner:
|
|||||||
inventory:
|
inventory:
|
||||||
host_vars:
|
host_vars:
|
||||||
oracle-amb-host:
|
oracle-amb-host:
|
||||||
COMMON_HOME_RPC_URL: "http://parity1:8545"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://parity2:8545"
|
|
||||||
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
||||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||||
verifier:
|
verifier:
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
---
|
---
|
||||||
- import_playbook: ../../../deployment/site.yml
|
|
||||||
# The docker-compose files have to be modified, in order to join the docker containers over network with the parity containers
|
|
||||||
- import_playbook: ./oracle-docker-compose.yml
|
- import_playbook: ./oracle-docker-compose.yml
|
||||||
- import_playbook: ./ui-docker-compose.yml
|
- import_playbook: ../../../deployment/site.yml
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Slurp docker compose file
|
|
||||||
slurp:
|
|
||||||
src: "/home/poadocker/bridge/oracle/{{ file }}.yml"
|
|
||||||
register: docker_compose_slurp
|
|
||||||
- name: Parse docker compose file
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
|
|
||||||
|
|
||||||
- name: Add the external network used to connect to Parity nodes
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_parsed |combine({'networks': {'ultimate': {'external': 'true'}}}, recursive=True) }}"
|
|
||||||
|
|
||||||
- name: Add all Oracle containers to the network
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_parsed | combine({'services': {item: {'networks': docker_compose_parsed.services[item].networks | union(['ultimate'])}}}, recursive=True) }}"
|
|
||||||
with_items: "{{ docker_compose_parsed.services }}"
|
|
||||||
|
|
||||||
- name: Expose Redis port to allow connecting from redis-cli
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_parsed | combine({'services': {'redis': {'ports': ['6379:6379']}}}, recursive=True) }}"
|
|
||||||
|
|
||||||
- name: Write updated docker file
|
|
||||||
copy:
|
|
||||||
content: "{{ docker_compose_parsed | to_yaml }}"
|
|
||||||
dest: "/home/poadocker/bridge/oracle/{{ file }}.yml"
|
|
||||||
@@ -1,33 +1,23 @@
|
|||||||
---
|
---
|
||||||
- name: Overwrite Oracle the docker-compose
|
- name: Prepare Oracle for ultimate tests
|
||||||
hosts: oracle
|
hosts: oracle
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: stop the service
|
- name: Connect parity to oracle networks
|
||||||
shell: service poabridge stop
|
shell: "docker network create {{ item }} && docker network connect {{ item }} parity1 && docker network connect {{ item }} parity2"
|
||||||
|
with_items:
|
||||||
- name: ReTag current oracle image
|
- oracle_net_db_bridge_request
|
||||||
shell: docker tag $(docker images --format '{{ '{{' }}.Repository{{ '}}' }}:{{ '{{' }}.Tag{{ '}}' }}' | grep -m 1 tokenbridge-e2e-oracle) oracle:ultimate-testing
|
- oracle_net_db_bridge_collected
|
||||||
|
- oracle_net_db_bridge_affirmation
|
||||||
|
- oracle_net_db_bridge_transfer
|
||||||
|
- oracle_net_db_bridge_senderhome
|
||||||
|
- oracle_net_db_bridge_senderforeign
|
||||||
|
- oracle_net_rabbit_bridge_request
|
||||||
|
- oracle_net_rabbit_bridge_collected
|
||||||
|
- oracle_net_rabbit_bridge_affirmation
|
||||||
|
- oracle_net_rabbit_bridge_transfer
|
||||||
|
- oracle_net_rabbit_bridge_senderhome
|
||||||
|
- oracle_net_rabbit_bridge_senderforeign
|
||||||
|
- oracle_net_rabbit_bridge_convert_to_chai_worker
|
||||||
delegate_to: 127.0.0.1
|
delegate_to: 127.0.0.1
|
||||||
become: false
|
become: false
|
||||||
|
|
||||||
- name: Replace oracle image
|
|
||||||
replace:
|
|
||||||
path: "/home/poadocker/bridge/oracle/{{ item }}.yml"
|
|
||||||
regexp: 'poanetwork/tokenbridge-oracle:latest'
|
|
||||||
replace: "oracle:ultimate-testing"
|
|
||||||
with_items:
|
|
||||||
- docker-compose
|
|
||||||
- docker-compose-transfer
|
|
||||||
- docker-compose-erc-native
|
|
||||||
|
|
||||||
- include_tasks: oracle-add-docker-external-network.yml
|
|
||||||
with_items:
|
|
||||||
- docker-compose
|
|
||||||
- docker-compose-transfer
|
|
||||||
- docker-compose-erc-native
|
|
||||||
loop_control:
|
|
||||||
loop_var: file
|
|
||||||
|
|
||||||
- name: start the service
|
|
||||||
shell: service poabridge start
|
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Overwrite UI the docker-compose
|
|
||||||
hosts: ui
|
|
||||||
become: true
|
|
||||||
tasks:
|
|
||||||
- name: stop the service
|
|
||||||
shell: service tokenbridge-ui stop
|
|
||||||
|
|
||||||
- name: Slurp docker compose file
|
|
||||||
slurp:
|
|
||||||
src: "/home/poadocker/bridge/ui/docker-compose.yml"
|
|
||||||
register: docker_compose_slurp
|
|
||||||
- name: Parse docker compose file
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
|
|
||||||
|
|
||||||
- name: Add the external network used to connect to Parity nodes
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_parsed |combine({'networks': {'ultimate': {'external': 'true'}}}, recursive=True) }}"
|
|
||||||
|
|
||||||
- name: Add all UI containers to the network
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_parsed | combine({'services': {item: {'networks': ['ultimate']}}}, recursive=True) }}"
|
|
||||||
with_items: "{{ docker_compose_parsed.services }}"
|
|
||||||
|
|
||||||
- name: Write new docker-compose file
|
|
||||||
copy:
|
|
||||||
content: "{{ docker_compose_parsed | to_yaml }}"
|
|
||||||
dest: "/home/poadocker/bridge/ui/docker-compose.yml"
|
|
||||||
|
|
||||||
- name: start the service
|
|
||||||
shell: service tokenbridge-ui start
|
|
||||||
@@ -13,17 +13,6 @@ platforms:
|
|||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- name: ui-erc-to-erc-host
|
|
||||||
groups:
|
|
||||||
- ultimate
|
|
||||||
- erc-to-erc
|
|
||||||
children:
|
|
||||||
- ui
|
|
||||||
image: ubuntu:16.04
|
|
||||||
privileged: true
|
|
||||||
network_mode: host
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
playbooks:
|
playbooks:
|
||||||
@@ -32,13 +21,8 @@ provisioner:
|
|||||||
inventory:
|
inventory:
|
||||||
host_vars:
|
host_vars:
|
||||||
oracle-erc-to-erc-host:
|
oracle-erc-to-erc-host:
|
||||||
COMMON_HOME_RPC_URL: "http://parity1:8545"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://parity2:8545"
|
|
||||||
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
||||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||||
ui-erc-to-erc-host:
|
|
||||||
COMMON_HOME_RPC_URL: "http://localhost:8541"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://localhost:8542"
|
|
||||||
verifier:
|
verifier:
|
||||||
name: testinfra
|
name: testinfra
|
||||||
lint:
|
lint:
|
||||||
|
|||||||
@@ -13,17 +13,6 @@ platforms:
|
|||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- name: ui-erc-to-native-host
|
|
||||||
groups:
|
|
||||||
- ultimate
|
|
||||||
- erc-to-native
|
|
||||||
children:
|
|
||||||
- ui
|
|
||||||
image: ubuntu:16.04
|
|
||||||
privileged: true
|
|
||||||
network_mode: host
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
playbooks:
|
playbooks:
|
||||||
@@ -32,15 +21,10 @@ provisioner:
|
|||||||
inventory:
|
inventory:
|
||||||
host_vars:
|
host_vars:
|
||||||
oracle-erc-to-native-host:
|
oracle-erc-to-native-host:
|
||||||
COMMON_HOME_RPC_URL: "http://parity1:8545"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://parity2:8545"
|
|
||||||
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
||||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||||
ORACLE_HOME_START_BLOCK: 1
|
ORACLE_HOME_START_BLOCK: 1
|
||||||
ORACLE_FOREIGN_START_BLOCK: 1
|
ORACLE_FOREIGN_START_BLOCK: 1
|
||||||
ui-erc-to-native-host:
|
|
||||||
COMMON_HOME_RPC_URL: "http://localhost:8541"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://localhost:8542"
|
|
||||||
verifier:
|
verifier:
|
||||||
name: testinfra
|
name: testinfra
|
||||||
lint:
|
lint:
|
||||||
|
|||||||
@@ -13,17 +13,6 @@ platforms:
|
|||||||
network_mode: host
|
network_mode: host
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- name: ui-native-to-erc-host
|
|
||||||
groups:
|
|
||||||
- ultimate
|
|
||||||
- native-to-erc
|
|
||||||
children:
|
|
||||||
- ui
|
|
||||||
image: ubuntu:16.04
|
|
||||||
privileged: true
|
|
||||||
network_mode: host
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
provisioner:
|
provisioner:
|
||||||
name: ansible
|
name: ansible
|
||||||
playbooks:
|
playbooks:
|
||||||
@@ -32,13 +21,8 @@ provisioner:
|
|||||||
inventory:
|
inventory:
|
||||||
host_vars:
|
host_vars:
|
||||||
oracle-native-to-erc-host:
|
oracle-native-to-erc-host:
|
||||||
COMMON_HOME_RPC_URL: "http://parity1:8545"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://parity2:8545"
|
|
||||||
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
ORACLE_VALIDATOR_ADDRESS: "0xaaB52d66283F7A1D5978bcFcB55721ACB467384b"
|
||||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "8e829f695aed89a154550f30262f1529582cc49dc30eff74a6b491359e0230f9"
|
||||||
ui-native-to-erc-host:
|
|
||||||
COMMON_HOME_RPC_URL: "http://localhost:8541"
|
|
||||||
COMMON_FOREIGN_RPC_URL: "http://localhost:8542"
|
|
||||||
verifier:
|
verifier:
|
||||||
name: testinfra
|
name: testinfra
|
||||||
lint:
|
lint:
|
||||||
|
|||||||
@@ -34,14 +34,6 @@ cp hosts.yml.example hosts.yml
|
|||||||
#syslog_server_port: "<protocol>://<ip>:<port>" # When this parameter is set all bridge logs will be redirected to <ip>:<port> address.
|
#syslog_server_port: "<protocol>://<ip>:<port>" # When this parameter is set all bridge logs will be redirected to <ip>:<port> address.
|
||||||
<host_ip_B>:
|
<host_ip_B>:
|
||||||
# (...)
|
# (...)
|
||||||
ui:
|
|
||||||
hosts:
|
|
||||||
<host_ip_B>:
|
|
||||||
ansible_user: <user>
|
|
||||||
#syslog_server_port: "<protocol>://<ip>:<port>"
|
|
||||||
<host_ip_C>:
|
|
||||||
ansible_user: <user>
|
|
||||||
#syslog_server_port: "<protocol>://<ip>:<port>"
|
|
||||||
monitor:
|
monitor:
|
||||||
hosts:
|
hosts:
|
||||||
<host_ip_B>:
|
<host_ip_B>:
|
||||||
@@ -50,18 +42,7 @@ cp hosts.yml.example hosts.yml
|
|||||||
#monitor_cron_schedule: "*/4 * * * *" # When this parameter is set, it will overwrite default schedule for performing checks
|
#monitor_cron_schedule: "*/4 * * * *" # When this parameter is set, it will overwrite default schedule for performing checks
|
||||||
```
|
```
|
||||||
|
|
||||||
The config above would install the Oracle on `<host_ip_A>`, UI on `<host_ip_C>`, and both Oracle, UI and Monitor on `<host_ip_B>`.
|
The config above would install the Oracle on `<host_ip_A>`, and both Oracle and Monitor on `<host_ip_B>`.
|
||||||
|
|
||||||
Example config for installing only UI:
|
|
||||||
```yaml
|
|
||||||
<bridge_name>:
|
|
||||||
children:
|
|
||||||
oracle:
|
|
||||||
hosts:
|
|
||||||
ui:
|
|
||||||
hosts:
|
|
||||||
<host_ip>:
|
|
||||||
ansible_user: <user>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
| Value | Description |
|
| Value | Description |
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ The deployed components have the following services:
|
|||||||
Component | Service Name
|
Component | Service Name
|
||||||
--- | ---
|
--- | ---
|
||||||
Oracle | poabridge
|
Oracle | poabridge
|
||||||
UI | tokenbridge-ui
|
|
||||||
Monitor | tokenbridge-monitor
|
Monitor | tokenbridge-monitor
|
||||||
|
|
||||||
Use the default `SysVinit` commands to `start`, `stop`, `restart`, and `rebuild` the service and to check the `status` of the service.
|
Use the default `SysVinit` commands to `start`, `stop`, `restart`, and `rebuild` the service and to check the `status` of the service.
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0xc26Aa60Ff574f157616D3aEE70e08aAC129E1dFC"
|
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0xc26Aa60Ff574f157616D3aEE70e08aAC129E1dFC"
|
|
||||||
UI_PORT: 3003
|
|
||||||
@@ -1,19 +1,14 @@
|
|||||||
---
|
---
|
||||||
## General settings
|
## General settings
|
||||||
ORACLE_BRIDGE_MODE: "ERC_TO_NATIVE"
|
ORACLE_BRIDGE_MODE: "ERC_TO_NATIVE"
|
||||||
UI_NATIVE_TOKEN_DISPLAY_NAME: "xDai"
|
|
||||||
|
|
||||||
## Home contract
|
## Home contract
|
||||||
COMMON_HOME_RPC_URL: "https://dai.poa.network"
|
COMMON_HOME_RPC_URL: "https://dai.poa.network"
|
||||||
UI_HOME_NETWORK_DISPLAY_NAME: "xDai chain"
|
|
||||||
UI_HOME_WITHOUT_EVENTS: false
|
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6"
|
COMMON_HOME_BRIDGE_ADDRESS: "0x7301CFA0e1756B71869E93d4e4Dca5c7d0eb0AA6"
|
||||||
ORACLE_HOME_RPC_POLLING_INTERVAL: 5000
|
ORACLE_HOME_RPC_POLLING_INTERVAL: 5000
|
||||||
|
|
||||||
## Foreign contract
|
## Foreign contract
|
||||||
COMMON_FOREIGN_RPC_URL: "https://mainnet.infura.io"
|
COMMON_FOREIGN_RPC_URL: "https://mainnet.infura.io"
|
||||||
UI_FOREIGN_NETWORK_DISPLAY_NAME: "Ethereum Mainnet"
|
|
||||||
UI_FOREIGN_WITHOUT_EVENTS: false
|
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016"
|
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016"
|
||||||
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 5000
|
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 5000
|
||||||
|
|
||||||
@@ -30,20 +25,6 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK: 10000000000
|
|||||||
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
||||||
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
||||||
|
|
||||||
## UI
|
|
||||||
UI_TITLE: "TokenBridge UI app - %c"
|
|
||||||
UI_OG_TITLE: "POA Bridge UI"
|
|
||||||
UI_DESCRIPTION: "The TokenBridge serves as a method of transferring MakerDAO stable tokens between the Ethereum network to xDai chain in a quick and cost-efficient manner."
|
|
||||||
UI_PORT: 3001
|
|
||||||
UI_HOME_EXPLORER_TX_TEMPLATE: https://blockscout.com/poa/dai/tx/%s
|
|
||||||
UI_FOREIGN_EXPLORER_TX_TEMPLATE: https://blockscout.com/eth/mainnet/tx/%s
|
|
||||||
UI_HOME_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/poa/dai/address/%s
|
|
||||||
UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/eth/mainnet/address/%s
|
|
||||||
UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_STYLES: "core"
|
|
||||||
UI_PUBLIC_URL: "https://dai-bridge.poa.network"
|
|
||||||
|
|
||||||
## Monitor
|
## Monitor
|
||||||
MONITOR_BRIDGE_NAME: "xdai"
|
MONITOR_BRIDGE_NAME: "xdai"
|
||||||
MONITOR_PORT: 3003
|
MONITOR_PORT: 3003
|
||||||
|
|||||||
@@ -2,5 +2,4 @@
|
|||||||
ORACLE_BRIDGE_MODE: "ERC_TO_ERC"
|
ORACLE_BRIDGE_MODE: "ERC_TO_ERC"
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0x1feB40aD9420b186F019A717c37f5546165d411E"
|
COMMON_HOME_BRIDGE_ADDRESS: "0x1feB40aD9420b186F019A717c37f5546165d411E"
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x4a58D6d8D416a5fBCAcf3dC52eb8bE8948E25127"
|
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x4a58D6d8D416a5fBCAcf3dC52eb8bE8948E25127"
|
||||||
UI_PORT: 3001
|
|
||||||
MONITOR_PORT: 3011
|
MONITOR_PORT: 3011
|
||||||
|
|||||||
@@ -2,5 +2,4 @@
|
|||||||
ORACLE_BRIDGE_MODE: "ERC_TO_NATIVE"
|
ORACLE_BRIDGE_MODE: "ERC_TO_NATIVE"
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0x488Af810997eD1730cB3a3918cD83b3216E6eAda"
|
COMMON_HOME_BRIDGE_ADDRESS: "0x488Af810997eD1730cB3a3918cD83b3216E6eAda"
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x488Af810997eD1730cB3a3918cD83b3216E6eAda"
|
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x488Af810997eD1730cB3a3918cD83b3216E6eAda"
|
||||||
UI_PORT: 3002
|
|
||||||
MONITOR_PORT: 3012
|
MONITOR_PORT: 3012
|
||||||
|
|||||||
@@ -2,19 +2,14 @@
|
|||||||
## General settings
|
## General settings
|
||||||
ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
|
ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
|
||||||
ORACLE_LOG_LEVEL: debug
|
ORACLE_LOG_LEVEL: debug
|
||||||
UI_NATIVE_TOKEN_DISPLAY_NAME: "POA"
|
|
||||||
|
|
||||||
## Home contract
|
## Home contract
|
||||||
COMMON_HOME_RPC_URL: "https://sokol.poa.network"
|
COMMON_HOME_RPC_URL: "https://sokol.poa.network"
|
||||||
UI_HOME_NETWORK_DISPLAY_NAME: "POA Sokol"
|
|
||||||
UI_HOME_WITHOUT_EVENTS: false
|
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0x98aFdE294f1C46aA0a27Cc4049ED337F879d8976"
|
COMMON_HOME_BRIDGE_ADDRESS: "0x98aFdE294f1C46aA0a27Cc4049ED337F879d8976"
|
||||||
ORACLE_HOME_RPC_POLLING_INTERVAL: 5000
|
ORACLE_HOME_RPC_POLLING_INTERVAL: 5000
|
||||||
|
|
||||||
## Foreign contract
|
## Foreign contract
|
||||||
COMMON_FOREIGN_RPC_URL: "https://sokol.poa.network"
|
COMMON_FOREIGN_RPC_URL: "https://sokol.poa.network"
|
||||||
UI_FOREIGN_NETWORK_DISPLAY_NAME: "Kovan"
|
|
||||||
UI_FOREIGN_WITHOUT_EVENTS: false
|
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x5a584f4C30B36f282848dAc9a2b20E7BEF481981"
|
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x5a584f4C30B36f282848dAc9a2b20E7BEF481981"
|
||||||
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 1000
|
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 1000
|
||||||
|
|
||||||
@@ -32,20 +27,6 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK: 1000000000 # in wei
|
|||||||
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
||||||
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
||||||
|
|
||||||
## UI
|
|
||||||
UI_TITLE: "TokenBridge UI app - %c"
|
|
||||||
UI_OG_TITLE: "POA Bridge UI"
|
|
||||||
UI_DESCRIPTION: "The POA cross-chain bridge serves as a method of transferring POA native tokens from the POA Network to the Ethereum network in a quick and cost-efficient manner."
|
|
||||||
UI_PORT: 3001
|
|
||||||
UI_HOME_EXPLORER_TX_TEMPLATE: https://blockscout.com/poa/sokol/tx/%s
|
|
||||||
UI_FOREIGN_EXPLORER_TX_TEMPLATE: https://blockscout.com/eth/kovan/tx/%s
|
|
||||||
UI_HOME_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/poa/sokol/address/%s
|
|
||||||
UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/eth/kovan/address/%s
|
|
||||||
UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_STYLES: "core"
|
|
||||||
UI_PUBLIC_URL: "http://localhost:3001"
|
|
||||||
|
|
||||||
## Monitor
|
## Monitor
|
||||||
MONITOR_BRIDGE_NAME: "bridge"
|
MONITOR_BRIDGE_NAME: "bridge"
|
||||||
MONITOR_PORT: 3003
|
MONITOR_PORT: 3003
|
||||||
|
|||||||
@@ -2,5 +2,4 @@
|
|||||||
ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
|
ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0x32198D570fffC7033641F8A9094FFDCaAEF42624"
|
COMMON_HOME_BRIDGE_ADDRESS: "0x32198D570fffC7033641F8A9094FFDCaAEF42624"
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x2B6871b9B02F73fa24F4864322CdC78604207769"
|
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x2B6871b9B02F73fa24F4864322CdC78604207769"
|
||||||
UI_PORT: 3000
|
|
||||||
MONITOR_PORT: 3010
|
MONITOR_PORT: 3010
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
---
|
---
|
||||||
## General settings
|
## General settings
|
||||||
UI_NATIVE_TOKEN_DISPLAY_NAME: "POA"
|
|
||||||
ORACLE_ALLOW_HTTP_FOR_RPC: yes
|
ORACLE_ALLOW_HTTP_FOR_RPC: yes
|
||||||
ORACLE_LOG_LEVEL: debug
|
ORACLE_LOG_LEVEL: debug
|
||||||
|
|
||||||
## Home contract
|
## Home contract
|
||||||
COMMON_HOME_RPC_URL: "https://sokol.poa.network"
|
COMMON_HOME_RPC_URL: "http://parity1:8545"
|
||||||
UI_HOME_NETWORK_DISPLAY_NAME: "POA Sokol"
|
|
||||||
UI_HOME_WITHOUT_EVENTS: false
|
|
||||||
ORACLE_HOME_RPC_POLLING_INTERVAL: 5000
|
ORACLE_HOME_RPC_POLLING_INTERVAL: 5000
|
||||||
|
|
||||||
## Foreign contract
|
## Foreign contract
|
||||||
COMMON_FOREIGN_RPC_URL: "https://sokol.poa.network"
|
COMMON_FOREIGN_RPC_URL: "http://parity2:8545"
|
||||||
UI_FOREIGN_NETWORK_DISPLAY_NAME: "Kovan"
|
|
||||||
UI_FOREIGN_WITHOUT_EVENTS: false
|
|
||||||
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 1000
|
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 1000
|
||||||
|
|
||||||
## Home Gasprice
|
## Home Gasprice
|
||||||
@@ -30,20 +25,6 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK: 1000000000 # in wei
|
|||||||
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
||||||
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
||||||
|
|
||||||
|
|
||||||
#ui
|
|
||||||
UI_TITLE: "TokenBridge UI app - %c"
|
|
||||||
UI_OG_TITLE: "POA Bridge UI"
|
|
||||||
UI_DESCRIPTION: "The POA cross-chain bridge serves as a method of transferring POA native tokens from the POA Network to the Ethereum network in a quick and cost-efficient manner."
|
|
||||||
UI_HOME_EXPLORER_TX_TEMPLATE: https://blockscout.com/poa/sokol/tx/%s
|
|
||||||
UI_FOREIGN_EXPLORER_TX_TEMPLATE: https://blockscout.com/eth/kovan/tx/%s
|
|
||||||
UI_HOME_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/poa/sokol/address/%s
|
|
||||||
UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/eth/kovan/address/%s
|
|
||||||
UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_STYLES: "core"
|
|
||||||
UI_PUBLIC_URL: "http://localhost"
|
|
||||||
|
|
||||||
#monitor
|
#monitor
|
||||||
MONITOR_BRIDGE_NAME: "bridge"
|
MONITOR_BRIDGE_NAME: "bridge"
|
||||||
MONITOR_CACHE_EVENTS: "true"
|
MONITOR_CACHE_EVENTS: "true"
|
||||||
@@ -52,3 +33,7 @@ MONITOR_FOREIGN_START_BLOCK: 0
|
|||||||
MONITOR_VALIDATOR_HOME_TX_LIMIT: 300000
|
MONITOR_VALIDATOR_HOME_TX_LIMIT: 300000
|
||||||
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT: 300000
|
MONITOR_VALIDATOR_FOREIGN_TX_LIMIT: 300000
|
||||||
MONITOR_TX_NUMBER_THRESHOLD: 100
|
MONITOR_TX_NUMBER_THRESHOLD: 100
|
||||||
|
|
||||||
|
# disable building and pulling of docker images from the Docker Hub
|
||||||
|
skip_pull: true
|
||||||
|
skip_build: true
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
---
|
---
|
||||||
## General settings
|
## General settings
|
||||||
ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
|
ORACLE_BRIDGE_MODE: "NATIVE_TO_ERC"
|
||||||
UI_NATIVE_TOKEN_DISPLAY_NAME: "ETC"
|
|
||||||
|
|
||||||
## Home contract
|
## Home contract
|
||||||
COMMON_HOME_RPC_URL: "https://www.ethercluster.com/etc"
|
COMMON_HOME_RPC_URL: "https://www.ethercluster.com/etc"
|
||||||
UI_HOME_NETWORK_DISPLAY_NAME: "Ethereum Classic"
|
|
||||||
UI_HOME_WITHOUT_EVENTS: false
|
|
||||||
COMMON_HOME_BRIDGE_ADDRESS: "0x073081832B4Ecdce79d4D6753565c85Ba4b3BeA9"
|
COMMON_HOME_BRIDGE_ADDRESS: "0x073081832B4Ecdce79d4D6753565c85Ba4b3BeA9"
|
||||||
ORACLE_HOME_RPC_POLLING_INTERVAL: 7000
|
ORACLE_HOME_RPC_POLLING_INTERVAL: 7000
|
||||||
|
|
||||||
## Foreign contract
|
## Foreign contract
|
||||||
COMMON_FOREIGN_RPC_URL: "https://mainnet.infura.io/"
|
COMMON_FOREIGN_RPC_URL: "https://mainnet.infura.io/"
|
||||||
UI_FOREIGN_NETWORK_DISPLAY_NAME: "Ethereum Mainnet"
|
|
||||||
UI_FOREIGN_WITHOUT_EVENTS: false
|
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x0cB781EE62F815bdD9CD4c2210aE8600d43e7040"
|
COMMON_FOREIGN_BRIDGE_ADDRESS: "0x0cB781EE62F815bdD9CD4c2210aE8600d43e7040"
|
||||||
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 7000
|
ORACLE_FOREIGN_RPC_POLLING_INTERVAL: 7000
|
||||||
|
|
||||||
@@ -31,20 +26,6 @@ COMMON_FOREIGN_GAS_PRICE_FALLBACK: 10000000000 # in wei
|
|||||||
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
ORACLE_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
||||||
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
COMMON_FOREIGN_GAS_PRICE_FACTOR: 1
|
||||||
|
|
||||||
## UI
|
|
||||||
UI_TITLE: "TokenBridge UI app - %c"
|
|
||||||
UI_OG_TITLE: "POA Bridge UI"
|
|
||||||
UI_DESCRIPTION: "The TokenBridge serves as a method of transferring native tokens from the Ethereum Classic Network to the Ethereum network in a quick and cost-efficient manner."
|
|
||||||
UI_PORT: 3001
|
|
||||||
UI_HOME_EXPLORER_TX_TEMPLATE: https://blockscout.com/etc/mainnet/tx/%s
|
|
||||||
UI_FOREIGN_EXPLORER_TX_TEMPLATE: https://blockscout.com/eth/mainnet/tx/%s
|
|
||||||
UI_HOME_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/etc/mainnet/address/%s
|
|
||||||
UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE: https://blockscout.com/eth/mainnet/address/%s
|
|
||||||
UI_HOME_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL: 600000
|
|
||||||
UI_STYLES: "classic"
|
|
||||||
UI_PUBLIC_URL: "https://wetc.app"
|
|
||||||
|
|
||||||
## Monitor
|
## Monitor
|
||||||
MONITOR_BRIDGE_NAME: "wetc"
|
MONITOR_BRIDGE_NAME: "wetc"
|
||||||
MONITOR_PORT: 3003
|
MONITOR_PORT: 3003
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ sokol-kovan:
|
|||||||
ansible_user: ubuntu
|
ansible_user: ubuntu
|
||||||
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
ORACLE_VALIDATOR_ADDRESS_PRIVATE_KEY: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
|
||||||
#syslog_server_port: "udp://127.0.0.1:514"
|
#syslog_server_port: "udp://127.0.0.1:514"
|
||||||
ui:
|
|
||||||
hosts:
|
|
||||||
127.0.0.1:
|
|
||||||
ansible_user: ubuntu
|
|
||||||
#syslog_server_port: "udp://127.0.0.1:514"
|
|
||||||
monitor:
|
monitor:
|
||||||
hosts:
|
hosts:
|
||||||
127.0.0.1:
|
127.0.0.1:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
mode: "0755"
|
mode: "0755"
|
||||||
|
|
||||||
- name: Upgrade pip version
|
- name: Upgrade pip version
|
||||||
shell: pip3 install --upgrade pip
|
shell: pip3 install --upgrade pip==19.3.1
|
||||||
|
|
||||||
- name: Install python docker library
|
- name: Install python docker library
|
||||||
shell: pip3 install docker docker-compose setuptools
|
shell: pip3 install docker docker-compose setuptools
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
shell: docker-compose pull
|
shell: docker-compose pull
|
||||||
args:
|
args:
|
||||||
chdir: "{{ bridge_path }}/monitor"
|
chdir: "{{ bridge_path }}/monitor"
|
||||||
|
when: skip_pull is undefined
|
||||||
|
|||||||
@@ -3,3 +3,4 @@
|
|||||||
shell: docker-compose pull
|
shell: docker-compose pull
|
||||||
args:
|
args:
|
||||||
chdir: "{{ bridge_path }}/oracle"
|
chdir: "{{ bridge_path }}/oracle"
|
||||||
|
when: skip_pull is undefined
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
---
|
|
||||||
dependencies:
|
|
||||||
- role: common
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Build the containers
|
|
||||||
shell: docker-compose build
|
|
||||||
args:
|
|
||||||
chdir: "{{ bridge_path }}/ui"
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Slurp docker compose file
|
|
||||||
slurp:
|
|
||||||
src: "{{ bridge_path }}/ui/docker-compose.yml"
|
|
||||||
register: docker_compose_slurp
|
|
||||||
|
|
||||||
- name: Parse docker compose file
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_slurp['content'] | b64decode | from_yaml }}"
|
|
||||||
|
|
||||||
- name: Set logger to remote server
|
|
||||||
set_fact:
|
|
||||||
docker_compose_parsed: "{{ docker_compose_parsed |combine({'services': {item: {'logging': {'driver': 'syslog','options': {'tag': '{{.Name}}/{{.ID}}'}}}}}, recursive=True) }}"
|
|
||||||
with_items: "{{ docker_compose_parsed.services }}"
|
|
||||||
|
|
||||||
- name: Write new docker-compose file
|
|
||||||
copy:
|
|
||||||
content: "{{ docker_compose_parsed | to_yaml }}"
|
|
||||||
dest: "{{ bridge_path }}/ui/docker-compose.yml"
|
|
||||||
|
|
||||||
- name: Set the local container logs configuration file
|
|
||||||
template:
|
|
||||||
src: 32-ui-docker.conf.j2
|
|
||||||
dest: /etc/rsyslog.d/32-ui-docker.conf
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
|
|
||||||
- name: Set the log configuration file to send container logs to remote server
|
|
||||||
template:
|
|
||||||
src: 37-ui-remote-logging.conf.j2
|
|
||||||
dest: /etc/rsyslog.d/37-ui-remote-logging.conf
|
|
||||||
owner: root
|
|
||||||
group: root
|
|
||||||
mode: 0644
|
|
||||||
when: syslog_server_port is defined
|
|
||||||
|
|
||||||
- name: restart rsyslog
|
|
||||||
service:
|
|
||||||
name: rsyslog
|
|
||||||
state: restarted
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- include_tasks: pre_config.yml
|
|
||||||
- include_tasks: logging.yml
|
|
||||||
- include_tasks: jumpbox.yml
|
|
||||||
- include_tasks: servinstall.yml
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
- name: Install .env config
|
|
||||||
template:
|
|
||||||
src: .env.j2
|
|
||||||
dest: "{{ bridge_path }}/ui/.env"
|
|
||||||
owner: "{{ compose_service_user }}"
|
|
||||||
mode: '0640'
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
# This role creates a tokenbridge-ui service which is designed to manage docker-compose ui deployment.
|
|
||||||
# /etc/init.d/tokenbridge-ui start, status, stop, restart - does what the services usually do in such cases.
|
|
||||||
# /etc/init.d/tokenbridge-ui rebuild - builds a new ui deployment from scratch.
|
|
||||||
---
|
|
||||||
- name: "Set the service"
|
|
||||||
template:
|
|
||||||
src: tokenbridge-ui.j2
|
|
||||||
dest: "/etc/init.d/tokenbridge-ui"
|
|
||||||
owner: root
|
|
||||||
mode: 755
|
|
||||||
|
|
||||||
- name: "Enable the service"
|
|
||||||
service:
|
|
||||||
name: "tokenbridge-ui"
|
|
||||||
state: started
|
|
||||||
enabled: yes
|
|
||||||
use: service
|
|
||||||
|
|
||||||
- name: Start the service
|
|
||||||
shell: service tokenbridge-ui start
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
COMMON_HOME_BRIDGE_ADDRESS={{ COMMON_HOME_BRIDGE_ADDRESS }}
|
|
||||||
COMMON_FOREIGN_BRIDGE_ADDRESS={{ COMMON_FOREIGN_BRIDGE_ADDRESS }}
|
|
||||||
COMMON_FOREIGN_RPC_URL={{ COMMON_FOREIGN_RPC_URL }}
|
|
||||||
COMMON_HOME_RPC_URL={{ COMMON_HOME_RPC_URL }}
|
|
||||||
|
|
||||||
UI_NATIVE_TOKEN_DISPLAY_NAME={{ UI_NATIVE_TOKEN_DISPLAY_NAME }}
|
|
||||||
|
|
||||||
UI_HOME_NETWORK_DISPLAY_NAME={{ UI_HOME_NETWORK_DISPLAY_NAME }}
|
|
||||||
UI_FOREIGN_NETWORK_DISPLAY_NAME={{ UI_FOREIGN_NETWORK_DISPLAY_NAME }}
|
|
||||||
|
|
||||||
UI_HOME_WITHOUT_EVENTS={{ UI_HOME_WITHOUT_EVENTS }}
|
|
||||||
UI_FOREIGN_WITHOUT_EVENTS={{ UI_FOREIGN_WITHOUT_EVENTS }}
|
|
||||||
|
|
||||||
UI_HOME_EXPLORER_TX_TEMPLATE={{ UI_HOME_EXPLORER_TX_TEMPLATE }}
|
|
||||||
UI_FOREIGN_EXPLORER_TX_TEMPLATE={{ UI_FOREIGN_EXPLORER_TX_TEMPLATE }}
|
|
||||||
UI_HOME_EXPLORER_ADDRESS_TEMPLATE={{ UI_HOME_EXPLORER_ADDRESS_TEMPLATE }}
|
|
||||||
UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE={{ UI_FOREIGN_EXPLORER_ADDRESS_TEMPLATE }}
|
|
||||||
|
|
||||||
{% if COMMON_HOME_GAS_PRICE_SUPPLIER_URL | default('') != '' %}
|
|
||||||
COMMON_HOME_GAS_PRICE_SUPPLIER_URL={{ COMMON_HOME_GAS_PRICE_SUPPLIER_URL }}
|
|
||||||
COMMON_HOME_GAS_PRICE_SPEED_TYPE={{ COMMON_HOME_GAS_PRICE_SPEED_TYPE }}
|
|
||||||
{% endif %}
|
|
||||||
COMMON_HOME_GAS_PRICE_FALLBACK={{ COMMON_HOME_GAS_PRICE_FALLBACK }}
|
|
||||||
UI_HOME_GAS_PRICE_UPDATE_INTERVAL={{ UI_HOME_GAS_PRICE_UPDATE_INTERVAL }}
|
|
||||||
{% if COMMON_HOME_GAS_PRICE_FACTOR | default('') != '' %}
|
|
||||||
COMMON_HOME_GAS_PRICE_FACTOR={{ COMMON_HOME_GAS_PRICE_FACTOR }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL={{ COMMON_FOREIGN_GAS_PRICE_SUPPLIER_URL }}
|
|
||||||
COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE={{ COMMON_FOREIGN_GAS_PRICE_SPEED_TYPE }}
|
|
||||||
COMMON_FOREIGN_GAS_PRICE_FALLBACK={{ COMMON_FOREIGN_GAS_PRICE_FALLBACK }}
|
|
||||||
UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL={{ UI_FOREIGN_GAS_PRICE_UPDATE_INTERVAL }}
|
|
||||||
COMMON_FOREIGN_GAS_PRICE_FACTOR={{ COMMON_FOREIGN_GAS_PRICE_FACTOR }}
|
|
||||||
|
|
||||||
# Default
|
|
||||||
UI_TITLE={{ UI_TITLE }}
|
|
||||||
UI_OG_TITLE={{ UI_OG_TITLE }}
|
|
||||||
UI_DESCRIPTION={{ UI_DESCRIPTION }}
|
|
||||||
UI_PORT={{ UI_PORT }}
|
|
||||||
UI_PUBLIC_URL={{ UI_PUBLIC_URL }}
|
|
||||||
|
|
||||||
UI_STYLES={{ UI_STYLES }}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
$FileCreateMode 0644
|
|
||||||
template(name="DockerLogFileName_UI" type="list") {
|
|
||||||
constant(value="/var/log/docker/")
|
|
||||||
property(name="syslogtag" securepath="replace" regex.type="ERE" regex.submatch="1" regex.expression="ui_(.*)\\/[a-zA-Z0-9]+\\[")
|
|
||||||
constant(value="/docker.log")
|
|
||||||
}
|
|
||||||
|
|
||||||
if $programname startswith 'ui_' then \
|
|
||||||
?DockerLogFileName_UI
|
|
||||||
|
|
||||||
$FileCreateMode 0600
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
if $programname startswith 'ui_' then {
|
|
||||||
action(
|
|
||||||
type="omfwd"
|
|
||||||
protocol="{{ syslog_server_port.split(":")[0] }}"
|
|
||||||
target="{{ (syslog_server_port.split(":")[1])[2:] }}"
|
|
||||||
port="{{ syslog_server_port.split(":")[2] }}"
|
|
||||||
template="RemoteForwardFormat"
|
|
||||||
queue.SpoolDirectory="/var/spool/rsyslog"
|
|
||||||
queue.FileName="remote"
|
|
||||||
queue.MaxDiskSpace="1g"
|
|
||||||
queue.SaveOnShutdown="on"
|
|
||||||
queue.Type="LinkedList"
|
|
||||||
ResendLastMSGOnReconnect="on"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
#! /bin/bash
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: tokenbridge-ui
|
|
||||||
# Required-Start: $remote_fs $syslog
|
|
||||||
# Required-Stop: $remote_fs $syslog
|
|
||||||
# Default-Start: 2 3 4 5
|
|
||||||
# Default-Stop: 0 1 6
|
|
||||||
# Short-Description: Start daemon at boot time
|
|
||||||
# Description: Enable service provided by daemon.
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
WORKDIR="{{ '/home/' + compose_service_user | default('poadocker') + '/' + bridge_path + '/ui' if bridge_path[:1] != "/" else bridge_path + '/ui' }}"
|
|
||||||
|
|
||||||
start(){
|
|
||||||
echo "Starting TokenBridge UI.."
|
|
||||||
cd $WORKDIR
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach
|
|
||||||
}
|
|
||||||
|
|
||||||
stop(){
|
|
||||||
echo "Stopping TokenBridge UI.."
|
|
||||||
cd $WORKDIR
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
|
|
||||||
sleep 2
|
|
||||||
}
|
|
||||||
|
|
||||||
status(){
|
|
||||||
echo "TokenBridge UI status:"
|
|
||||||
cd $WORKDIR
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose ps
|
|
||||||
}
|
|
||||||
|
|
||||||
rebuild(){
|
|
||||||
echo "Rebuild TokenBridge UI.."
|
|
||||||
cd $WORKDIR
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose down -v
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose rm -fv
|
|
||||||
sudo -u "{{ compose_service_user }}" /usr/local/bin/docker-compose up --detach --force-recreate --no-deps --build
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
case "$1" in
|
|
||||||
|
|
||||||
start)
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
|
|
||||||
stop)
|
|
||||||
stop
|
|
||||||
;;
|
|
||||||
|
|
||||||
status)
|
|
||||||
status
|
|
||||||
;;
|
|
||||||
|
|
||||||
restart)
|
|
||||||
echo "Restarting TokenBridge UI.."
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
|
|
||||||
rebuild)
|
|
||||||
rebuild
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
echo $"Usage: $0 {start|stop|restart|rebuild|status}"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
@@ -4,11 +4,6 @@
|
|||||||
become: true
|
become: true
|
||||||
roles:
|
roles:
|
||||||
- { role: oracle }
|
- { role: oracle }
|
||||||
- name: Install UI
|
|
||||||
hosts: ui
|
|
||||||
become: true
|
|
||||||
roles:
|
|
||||||
- { role: ui }
|
|
||||||
- name: Install Monitor
|
- name: Install Monitor
|
||||||
hosts: monitor
|
hosts: monitor
|
||||||
become: true
|
become: true
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
ARG DOCKER_IMAGE_BASE
|
|
||||||
ARG UI_TAG
|
|
||||||
FROM ${DOCKER_IMAGE_BASE}/tokenbridge-e2e-ui:${UI_TAG}
|
|
||||||
|
|
||||||
ARG DOT_ENV_PATH
|
|
||||||
|
|
||||||
COPY ${DOT_ENV_PATH} ./.env
|
|
||||||
@@ -24,14 +24,12 @@ Shut down and cleans up containers, networks, services, running scripts:
|
|||||||
| oracle | Launches Oracle containers |
|
| oracle | Launches Oracle containers |
|
||||||
| oracle-validator-2 | Launches Oracle containers for second validator |
|
| oracle-validator-2 | Launches Oracle containers for second validator |
|
||||||
| oracle-validator-3 | Launches Oracle containers for third validator |
|
| oracle-validator-3 | Launches Oracle containers for third validator |
|
||||||
| ui | Launches UI containers |
|
|
||||||
| blocks | Auto mines blocks |
|
| blocks | Auto mines blocks |
|
||||||
| monitor | Launches Monitor containers |
|
| monitor | Launches Monitor containers |
|
||||||
| native-to-erc | Creates infrastructure for ultimate e2e testing, for native-to-erc type of bridge |
|
| native-to-erc | Creates infrastructure for ultimate e2e testing, for native-to-erc type of bridge |
|
||||||
| erc-to-native | Creates infrastructure for ultimate e2e testing, for erc-to-native type of bridge |
|
| erc-to-native | Creates infrastructure for ultimate e2e testing, for erc-to-native type of bridge |
|
||||||
| erc-to-erc | Creates infrastructure for ultimate e2e testing, for erc-to-erc type of bridge |
|
| erc-to-erc | Creates infrastructure for ultimate e2e testing, for erc-to-erc type of bridge |
|
||||||
| amb | Creates infrastructure for ultimate e2e testing, for arbitrary message type of bridge |
|
| amb | Creates infrastructure for ultimate e2e testing, for arbitrary message type of bridge |
|
||||||
| ultimate-amb-stake-erc-to-erc | Creates infrastructure for ultimate e2e testing, for stake token bridge |
|
|
||||||
|
|
||||||
#### Ultimate e2e testing
|
#### Ultimate e2e testing
|
||||||
|
|
||||||
|
|||||||
@@ -15,13 +15,15 @@ It runs the e2e tests on components deployed using the deployment playbooks.
|
|||||||
Run the Parity nodes, deploy the bridge contracts, deploy Oracle using the deployment playbook.
|
Run the Parity nodes, deploy the bridge contracts, deploy Oracle using the deployment playbook.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./up.sh deploy native-to-erc blocks
|
./e2e-commons/up.sh deploy blocks
|
||||||
|
./deployment-e2e/molecule.sh ultimate-native-to-erc
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2. Run the E2E tests
|
### 2. Run the E2E tests
|
||||||
|
|
||||||
```
|
```bash
|
||||||
cd ui-e2e; yarn mocha -g "NATIVE_TO_ERC" -b ./test.js
|
cd e2e-commons
|
||||||
|
docker-compose run -e ULTIMATE=true e2e yarn workspace oracle-e2e run native-to-erc
|
||||||
```
|
```
|
||||||
|
|
||||||
## Diagram
|
## Diagram
|
||||||
|
|||||||
2
e2e-commons/access-lists/block_list.txt
Normal file
2
e2e-commons/access-lists/block_list.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
0xc9e38bfdB9c635F0796ad83CC8705dc379F41c04
|
||||||
|
0x6f359aC418a5f7538F7755A33C9c7dDf38785524
|
||||||
@@ -8,8 +8,6 @@ while [ "$1" != "" ]; do
|
|||||||
docker-compose build oracle
|
docker-compose build oracle
|
||||||
elif [ "$1" == "monitor" ]; then
|
elif [ "$1" == "monitor" ]; then
|
||||||
docker-compose build monitor
|
docker-compose build monitor
|
||||||
elif [ "$1" == "ui" ]; then
|
|
||||||
docker-compose build ui
|
|
||||||
elif [ "$1" == "alm" ]; then
|
elif [ "$1" == "alm" ]; then
|
||||||
docker-compose build alm
|
docker-compose build alm
|
||||||
fi
|
fi
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user