diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..bccbbec --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,172 @@ +version: 2.1 +orbs: + bridge: + executors: + node-dev: + docker: + - image: circleci/node:10.15 + environment: + TARGET_NETWORK: development + commands: + fetch_repo: + description: "Checkout and init submodules" + steps: + - checkout + - run: + name: "Initialize submodules" + command: git submodule update --init + setup_docker: + description: "Set up remote docker engine" + steps: + - setup_remote_docker: + version: 18.09.3 + docker_layer_caching: true + restore_tss_image: + description: "Restores tss image from cache" + steps: + - restore_cache: + name: "Restore tss image from cache" + key: "tss-v1-{{ .Branch }}" + - load_tss + save_tss: + description: "Save tss image to workspace" + steps: + - run: + name: "Save tss image to archive" + command: | + mkdir -p ./workspace + docker save tss | gzip > ./workspace/tss.tar.gz + - persist_to_workspace: + name: "Save tss image to workspace" + root: ./workspace + paths: + - tss.tar.gz + - save_cache: + name: "Save tss image to cache" + paths: + - ./workspace/tss.tar.gz + key: "tss-v1-{{ .Branch }}" + load_tss: + description: "Load tss image from workspace" + steps: + - run: + name: "Load tss image from archive" + command: docker load -i ./workspace/tss.tar.gz || true + save_docker_logs: + description: "Save docker logs" + parameters: + validator: + type: integer + default: 1 + steps: + - run: + name: "Saving validator<< parameters.validator >> logs" + command: | + mkdir -p ./artifacts/logs/validator<< parameters.validator >> + docker logs validator<< parameters.validator >>_rabbitmq_1 > ./artifacts/logs/validator<< parameters.validator >>/rabbitmq.log + docker logs validator<< parameters.validator >>_redis_1 > ./artifacts/logs/validator<< parameters.validator >>/redis.log + docker logs validator<< parameters.validator >>_proxy_1 > ./artifacts/logs/validator<< parameters.validator >>/proxy.log + docker logs validator<< parameters.validator >>_eth-watcher_1 > ./artifacts/logs/validator<< parameters.validator >>/eth-watcher.log + docker logs validator<< parameters.validator >>_bnc-watcher_1 > ./artifacts/logs/validator<< parameters.validator >>/bnc-watcher.log + docker logs validator<< parameters.validator >>_signer_1 > ./artifacts/logs/validator<< parameters.validator >>/signer.log + docker logs validator<< parameters.validator >>_keygen_1 > ./artifacts/logs/validator<< parameters.validator >>/keygen.log + when: always + save_artifacts: + description: "Save and upload tests results, save validator logs to artifacts" + steps: + - run: + name: "Save tests results" + command: | + mkdir -p ./artifacts/test_results/mocha + docker cp "tests:/tests/results.xml" "./artifacts/test_results/mocha/results.xml" + when: always + - store_test_results: + path: ./artifacts/test_results/mocha + when: always + - save_docker_logs: + validator: 1 + - save_docker_logs: + validator: 2 + - save_docker_logs: + validator: 3 + - run: + name: "Save ethereum logs" + command: | + mkdir -p ./artifacts/logs/ethereum + docker logs ethereum-testnet_side-oracle_1 > ./artifacts/logs/ethereum/side-oracle.log + docker logs ethereum-testnet_ganache_home_1 > ./artifacts/logs/ethereum/ganache_home.log + docker logs ethereum-testnet_ganache_side_1 > ./artifacts/logs/ethereum/ganache_side.log + when: always + - run: + name: "Save binance logs" + command: | + mkdir -p ./artifacts/logs/binance + docker logs binance-testnet_node_1 > ./artifacts/logs/binance/node.log + docker logs binance-testnet_api-server_1 > ./artifacts/logs/binance/api-server.log + docker logs binance-testnet_http-api_1 > ./artifacts/logs/binance/http-api.log + when: always + - store_artifacts: + path: ./artifacts + destination: artifacts + when: always +jobs: + init_tss: + executor: bridge/node-dev + steps: + - bridge/fetch_repo + - bridge/setup_docker + - bridge/restore_tss_image + - run: + name: "Build tss image" + command: docker build --cache-from tss -t tss ./src/tss || docker build -t tss ./src/tss + - bridge/save_tss + run_tests: + executor: bridge/node-dev + steps: + - bridge/fetch_repo + - bridge/setup_docker + - attach_workspace: + at: ./workspace + - bridge/load_tss + - run: + name: "Init tests environment" + command: | + BLOCK_TIME=3 ./demo/start-ethereum-environment.sh + ./demo/start-binance-environment.sh + N=1 ./demo/validator-demo.sh -d + N=2 ./demo/validator-demo.sh -d + N=3 ./demo/validator-demo.sh -d + - run: + name: "Wait until validator nodes are ready" + command: | + docker run --network validator1_test_network --entrypoint ash appropriate/curl:latest -c "until curl -X GET http://proxy:8002/info > /dev/null 2>&1; do sleep 1; done" + docker run --network validator2_test_network --entrypoint ash appropriate/curl:latest -c "until curl -X GET http://proxy:8002/info > /dev/null 2>&1; do sleep 1; done" + docker run --network validator3_test_network --entrypoint ash appropriate/curl:latest -c "until curl -X GET http://proxy:8002/info > /dev/null 2>&1; do sleep 1; done" + no_output_timeout: 3m + - run: + name: "Build and prepare tests container" + command: | + docker build -t tests ./tests + docker create --env-file ./tests/.env --name tests tests + docker network connect binance_net tests + docker network connect ethereum_side_rpc_net tests + docker network connect ethereum_home_rpc_net tests + docker network connect validator1_test_network tests + docker network connect validator2_test_network tests + docker network connect validator3_test_network tests + - run: + name: "Run tests" + command: docker start -a tests + - run: + name: "Check alive docker containers" + command: docker ps + when: always + - bridge/save_artifacts +workflows: + version: 2 + main: + jobs: + - init_tss + - run_tests: + requires: + - init_tss diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4fd97cc --- /dev/null +++ b/.eslintignore @@ -0,0 +1,8 @@ +node_modules/ +data/ +demo/validator*/development +demo/validator*/staging +src/deploy/deploy/*/build +src/deploy/deploy-home/contracts/openzeppelin-solidity +src/deploy/deploy-test/contracts/openzeppelin-solidity +src/tss/multi-party-ecdsa diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..c0a5fcf --- /dev/null +++ b/.eslintrc @@ -0,0 +1,18 @@ +{ + "extends": [ + "plugin:node/recommended", + "airbnb-base" + ], + "plugins": [ + "node" + ], + "rules": { + "semi": [1, "never"], + "comma-dangle": [1, "never"], + "node/no-missing-require": 0, + "import/no-unresolved": 0, + "no-return-await": 0, + "no-await-in-loop": 0, + "no-constant-condition": 0 + } +} diff --git a/.gitignore b/.gitignore index 1c85941..f9ab79b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,20 +1,13 @@ .idea/ node_modules/ .DS_Store -**/keys*.store -**/signature -**/params data/ demo/validator*/development demo/validator*/staging demo/validator*/.keys.staging -demo/ganache_home_db/ -demo/ganache_side_db/ -demo/*.zip -src/deploy/deploy-home/build/ -src/deploy/deploy-side/build/ -src/deploy/deploy-test/build/ +src/deploy/deploy*/build/ src/deploy/.keys.staging src/test-services/.keys.staging -src/test-services/.keys.development -test.js +src/test.js +tests/results.xml +package-lock.json diff --git a/DEMO.md b/DEMO.md index 8f51cf2..f225671 100644 --- a/DEMO.md +++ b/DEMO.md @@ -13,7 +13,13 @@ This demo supports two ways of dealing with the Ethereum side of a bridge: As part of this demo two EVM-based chains ([ganache](https://github.com/trufflesuite/ganache-cli)) will be started: - **Home chain** - it keeps an ERC20 contract (`0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc`) and the bridge contract (`0x44c158FE850821ae69DaF37AADF5c539e9d0025B`). - **Side chain** - the MPC orchestration contract (`0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc`) is located here -Both chains are run in separate docker containers. +Both chains are run in separate docker containers. +JSON-RPC ports are mapped to the host (7545 - side chain, 8545 - home chain) + +Local Binance network within separate docker container will be used. +In addition, some part of Binance accelerated node [HTTP API](https://docs.binance.org/api-reference/dex-api/paths.html) +will be emulated, since a regular full-node API does not provide all required features. +APIs and NODE RPC ports are mapped to the host (26657 - RPC, 8080 - api-server, 8000 - emulated accelerated node api) #### Staging mode @@ -22,6 +28,9 @@ As part of this demo two EVM-based public chains will be used: - **Side chain** - Sokol POA testnet keeps the MPC orchestration contract. Interaction with chains is done by using public available RPC urls. +Public Binance testnet will be used for demo purposes. +Interaction with chain is done by using a public available HTTP API endpoint. + ### Demo validators Three validators will be run and only two validators are required to confirm the transfer. Every validator node is a set of docker containers (`eth-watcher`, `bnc-watcher`, `signer`, `proxy`, `redis`, `rabbitmq`). @@ -30,161 +39,92 @@ Three validators will be run and only two validators are required to confirm the The public Binance Chain testnet will keep a BEP2 token. -### Running demo +### Running demo in development mode 1. Preparation - * (1.1) Download `tbnbcli` from https://github.com/binance-chain/node-binary/tree/master/cli. - * (1.2) Create a new account through the [web-interface](https://testnet.binance.org/en/create) in the Binance testnet wallet. Copy the private key and mnemonic phrase. The private key will be used to import it in an Ethereum Wallet. The mnemonic phrase is to recover the BNB with `tbnbcli`. - * (1.3) Recover the account in the console with the mnemonic. + * (1.1) Clone the repo and initialize git submodules: ``` - ./tbnbcli keys add test_account1 --recover + git clone --recurse-submodules https://github.com/k1rill-fedoseev/eth-to-bnc-bridge.git ``` - * (1.4) Create few BNB accounts from the console. They will be donors to provide enough funds to issue a BEP2 tokens (500 BNB required). + * (1.2) Build TSS to be used in the bridge oracles: ``` - ./tbnbcli keys add test_account2 - ./tbnbcli keys add test_account3 + docker build -t tss ./src/tss ``` - * (1.5) Register on the Binance site and fund the accounts from the [testnet faucet](https://www.binance.com/en/dex/testnet/address). - * (1.6) Re-arrange funds on the accounts as so the first account will have 550 BNB and others 10-20 BNBs to make transactions. + * (1.3) Generate several private keys for bridge testing. (e. g. `openssl rand -hex 32`) + * (1.4) Get Ethereum and Binance addresses for recently created accounts via running ``` - ./tbnbcli send --from test_account2 --to
\ - --amount 18500000000:BNB --chain-id=Binance-Chain-Nile \ - --node=data-seed-pre-2-s1.binance.org:80 --memo "donate" - ./tbnbcli send --from test_account3 --to
\ - --amount 18500000000:BNB --chain-id=Binance-Chain-Nile - --node=data-seed-pre-2-s1.binance.org:80 --memo "donate" + ./src/test-services/getAddresses/run.sh ``` - * (1.7) Issue the BEP2 token from the first account. `3141500000000000` corresponds to `31415000.0` tokens. +2. Run test environment + * (2.1) Modify `src/deploy/deploy-test/.env.development` and specify the amount of tokens to mint in the parameter `TOKEN_INITIAL_MINT`. + * (2.2) Run Ethereum testnets and deploy contracts ``` - ./tbnbcli token issue --token-name "ERC20toBEP2Bridge" --total-supply 3141500000000000 \ - --symbol ETB0819 --mintable --from test_account1 --chain-id=Binance-Chain-Nile \ - --node=data-seed-pre-2-s1.binance.org:80 --trust-node + TARGET_NETWORK=development ./demo/start-ethereum-environment.sh ``` - In the real deployment most probably the token must not be mintable. - * (1.8) Get the BEP2 token ID in `denom` field (in this example it is `ETB0819-863`). + This command will also mint tokens, the owner of tokens is the address that corresponds to the + private key specified in `HOME_PRIVATE_KEY` of `src/deploy/deploy-test/.env.development` (`0xA374DC09057D6B3253d04fACb15736B43fBc7943`). + * (2.4) Run Binance testnet and api services ``` - ./tbnbcli account
\ - --chain-id=Binance-Chain-Nile --node=data-seed-pre-2-s1.binance.org:80 --trust-node + ./demo/start-binance-environment.sh ``` - * (1.9) Clone the repo and initialize git submodules: + This command will also issue a BEP2 token, the owner of tokens is the address that corresponds to the + private key specified in `FOREIGN_PRIVATE_KEY` of `src/test-services/binanceSend/.env.development` (`tbnb1z7u9f8mcuwxanns9xa6qgjtlka0d392epc0m9x`). + The balance of `tbnb1z7u9f8mcuwxanns9xa6qgjtlka0d392epc0m9x` will contain 10000 BNB and 10000 Test Tokens. + * (2.5) Send few tokens and coins from the current token owner to the first account. Coins are needed to pay transaction fees. ``` - git clone --recurse-submodules https://github.com/k1rill-fedoseev/eth-to-bnc-bridge.git - ``` - * (1.10) Build TSS to be used in the bridge oracles: + ./src/test-services/ethereumSend/run.sh 5 0.5 ``` - docker build -t tss -f ./src/tss/Dockerfile-local ./src/tss + * (2.6) Check that the tokens were transferred properly: ``` -2. Run test environment - * 2.1 Running in development mode (using local ganache networks): - * (2.1.1) Modify `src/deploy/deploy-test/.env.development` and specify the amount of tokens to mint in the parameter `TOKEN_INITIAL_MINT`. - * (2.1.2) Run testnets and deploy contracts - ``` - TARGET_NETWORK=development ./demo/start-environment.sh - ``` - This command will also mint tokens, the owner of tokens is the address that corresponds to the - private key specified in `HOME_PRIVATE_KEY` of `src/deploy/deploy-test/.env.development` (`0xA374DC09057D6B3253d04fACb15736B43fBc7943`). - * 2.2 Running in staging mode (using public test networks): - * (2.2.1) Prepare three private keys for validators. Get the Ethereum account addresses for these keys. - * (2.2.2) Modify `src/deploy/deploy-home/.env.staging` and specify the token contract address in - the Kovan network via `HOME_TOKEN_ADDRESS` (use empty address `0x` if you want to create new - ERC20 contract while deployment). \ - Set `VALIDATOR_ADDRESS_*` to Ethereum addresses obtained in the previous step. - * (2.2.3) Modify `src/deploy/.keys.staging` and specify private keys for prefunded accounts in both networks. - These accounts are used for contract deployment. Use `src/deploy/.keys.staging.example` as an example. - * (2.2.4) Deploy contracts - ``` - TARGET_NETWORK=staging ./demo/start-environment.sh - ``` - This command will deploy ERC20 contract and also mint tokens if you left `HOME_TOKEN_ADDRESS` empty, - the owner of tokens is the address that corresponds to the private key specified in - `HOME_PRIVATE_KEY` of `src/deploy/.keys.staging`.\ - Deployed contract address will be automatically updates in all required validators - and test services configs. - * (2.2.5) Prefund validator accounts in home network (Kovan): - ``` - TARGET_NETWORK=staging ./src/test-services/ethereumSend/run.sh 0 0.5 - ``` - * (2.2.6) Prefund validator accounts in side network (Sokol): - ``` - TARGET_NETWORK=staging ./src/test-services/sidePrefund/run.sh 1 - ``` - * (2.3) Get the Ethereum account address for the first test account from its private key (step 1.2). [NiftyWallet](https://forum.poa.network/c/nifty-wallet) could be used for this. - * (2.4) Send few tokens and coins from the current token owner to the first account. Coins are needed to pay transaction fees. - ``` - TARGET_NETWORK= ./src/test-services/ethereumSend/run.sh 5000000000000000000 0.5 - ``` - * (2.5) Check that the tokens were transferred properly: - ``` - TARGET_NETWORK= ./src/test-services/ethereumBalance/run.sh + ./src/test-services/ethereumBalance/run.sh ``` 3. Run validators nodes: - * (3.1) Modify the parameter `FOREIGN_ASSET` in `demo/validator1/.env.`, `demo/validator2/.env.` - and `demo/validator3/.env.` to specify the identificator of the token (step 1.8) that the oracle will watch. \ - For staging environment additionally specify `VALIDATOR_PRIVATE_KEY` in the `demo/validator/.keys.staging` (step 2.2.1) - * (3.2) Run three validators in separate terminal sessions. + * (3.1) Run three validators in separate terminal sessions. ``` - N=1 TARGET_NETWORK= ./demo/validator-demo.sh - N=2 TARGET_NETWORK= ./demo/validator-demo.sh - N=3 TARGET_NETWORK= ./demo/validator-demo.sh + N=1 ./demo/validator-demo.sh + N=2 ./demo/validator-demo.sh + N=3 ./demo/validator-demo.sh ``` Wait for when the line like the following appears: ``` keygen_1 | Generated multisig account in binance chain: tbnb1mutgnx9n9devmrjh3d0wz332fl8ymgel6tydx6 ``` - The line contains the address of the bridge address in the Bincance Chain. + The line contains the address of the bridge address in the Binance Chain. 4. Initialize the state of the bridge account in the Binance Chain * (4.1) Fill the balance Fund with BNB coins as so the account will be able to make transactions: ``` - ./tbnbcli send --from test_account1 --to
\ - --amount 1000000000:BNB --chain-id=Binance-Chain-Nile \ - --node=data-seed-pre-2-s1.binance.org:80 --memo "initialization" - ``` - * (4.2) Fund the account with bridgeable tokens. **This transaction should have 'funding' in the memo**: - ``` - ./tbnbcli send --from test_account1 --to
\ - --amount 3141500000000000:ETB0819-863 --chain-id=Binance-Chain-Nile \ - --node=data-seed-pre-2-s1.binance.org:80 --memo "funding" + ./src/test-services/binanceSend/run.sh
100 1 ``` - The oracles should catch this transaction but will ignore it: - ``` - bnc-watcher_1 | Fetching new transactions - bnc-watcher_1 | Sending api transactions request - bnc-watcher_1 | Found 1 new transactions - ``` - To check the balance of the bridge account the [Binance Testnet Explorer](https://testnet-explorer.binance.org) could be used. It should report about two assets owned by the account. + To check the balance of the bridge account use `./src/test-services/binanceBalance/run.sh
` 5. Transfer tokens from Ethereum-based chain to the Binance Chain: - * (5.1) Modify the parameter `HOME_PRIVATE_KEY` - (in `src/test-services/ethereumSend/.env.development` or `src/test-services/.keys.staging`) - as so it contains the private key of the first test account (step 1.2) - * (5.2) Send some amount of tokens to the bridge contract: + * (5.1) Send some amount of tokens to the bridge contract, for `PRIVATE_KEY` use some of the keys from step (1.3): ``` - TARGET_NETWORK= ./src/test-services/ethereumSend/run.sh bridge 5000000000000000000 + PRIVATE_KEY= ./src/test-services/ethereumSend/run.sh bridge 5 ``` - * (5.3) The validators will catch the event and start the process to sign the transaction. - * (5.4) As soon as the signature is generated and sent, the balance of the bridge account in both chains will be changed: + * (5.2) The validators will catch the event and start the process to sign the transaction. + * (5.3) As soon as the signature is generated and sent, the balance of the bridge account in both chains will be changed: ``` - TARGET_NETWORK= ./src/test-services/ethereumBalance/run.sh 0x94b40CC641Ed7db241A1f04C8896ba6f6cC36b85 + ./src/test-services/ethereumBalance/run.sh ``` - should report non-zero balance + should report non-zero balance, ``` - ./tbnbcli account
\ - --chain-id=Binance-Chain-Nile --node=data-seed-pre-2-s1.binance.org:80 --trust-node + ./src/test-services/binanceBalance/run.sh ``` should report about the balance reduction. - The balance and transactions related to the bridge account in the Binance Chain could be checked in [Binance Testnet Explorer](https://testnet-explorer.binance.org). - * (5.5) Check that the tokens was transferred to the first test account either by `tbnbcli` or by [Binance Testnet Explorer](https://testnet-explorer.binance.org). + * (5.4) Check that the tokens were transferred properly to the test account: + ``` + ./src/test-services/binanceBalance/run.sh + ``` 6. Transfer tokens from the Binance Chain to Ethereum-based chain: - * Use either `tbnbcli` or the [Binance testnet wallet](https://testnet.binance.org/) to send tokens to the bridge account: + * (6.1) Send some amount of tokens to the bridge account: ``` - ./tbnbcli send --from test_account1 --to
\ - --amount 300000000:ETB0819-863 --chain-id=Binance-Chain-Nile \ - --node=data-seed-pre-2-s1.binance.org:80 --memo "any note" + PRIVATE_KEY= ./src/test-services/binanceSend/run.sh 3 ``` - * Check the balances of the test account on both sides of the bridge to see that the funds were transferred properly. + * (6.2) Check the balances of the test account on both sides of the bridge to see that the funds were transferred properly using commands from (5.3), (5.4). 7. Bridge supports changing the list of validators and required voting threshold via voting process, and then keys regeneration. * (7.0) Obtain information about current epoch, current list validators, upcoming epoch information, bridge state via: ``` - ./curl http://localhost:$PORT/info + curl http://localhost:$PORT/info ``` Where `$PORT` is specific port for some validator oracle. The response object contains lots of useful information about current bridge state. @@ -197,11 +137,11 @@ The public Binance Chain testnet will keep a BEP2 token. "nextEpoch": 3, // threshold number for current epoch, - // threshold + 1 votes are required for any changes in next epoch - "threshold": 1, + // at least threshold votes are required for any changes in next epoch + "threshold": 2, // threshold number for next epoch - "nextThreshold": 1, + "nextThreshold": 2, // current bridge addresses in home and foreign networks "homeBridgeAddress": "0x44c158FE850821ae69DaF37AADF5c539e9d0025B", @@ -239,38 +179,165 @@ The public Binance Chain testnet will keep a BEP2 token. "confirmationsForFundsTransfer": 0 } ``` - * (7.1) Start voting process for next epoch, via sending `$THRESHOLD + 1` requests to `/vote/startVoting` url. Bridge + * (7.1) Start voting process for next epoch, via sending `$THRESHOLD` requests to `/vote/startVoting` url. Bridge state should be successfully changed to `voting`. * 7.2 Changing next epoch bridge validators / threshold - * (7.2.1) Add / remove validator in next validators list, via sending `$THRESHOLD + 1` requests to + * (7.2.1) Add / remove validator in next validators list, via sending `$THRESHOLD` requests to `/vote/addValidator/$ADDRESS` / `/vote/removeValidator/$ADDRESS`. - * (7.2.2) Change threshold for the next epoch, via sending `$THRESHOLD + 1` requests to `/vote/changeThreshold/$THRESHOLD`. - * (7.3) Start keygen process for next epoch, via sending `$THRESHOLD + 1` requests to `/vote/startKeygen` url. Bridge + * (7.2.2) Change threshold for the next epoch, via sending `$THRESHOLD` requests to `/vote/changeThreshold/$THRESHOLD`. + * (7.3) Start keygen process for next epoch, via sending `$THRESHOLD` requests to `/vote/startKeygen` url. Bridge state should be successfully changed to `keygen`, and in some time to `funds_transfer`, and then to `ready`. - * (7.4) If keygen process at some state was stopped(i. e. one validator turned of his oracle), - it can be cancelled via via sending `$THRESHOLD + 1` requests to `/vote/cancelKeygen` url. After + * (7.4) If keygen process at some state was stopped(i. e. one validator turned off his oracle), + it can be cancelled via via sending `$THRESHOLD` requests to `/vote/cancelKeygen` url. After keygen cancellation, bridge state will return to `voting`, and later it can be restarted manually once again. +### Running demo in staging mode + +Staging mode demo is similar to development mode demo, but requires additional manual actions for preparing demo. +Make sure, to first run demo in development mode, before trying to run it in the staging environment. + +1. Preparation + * (1.1) Download `tbnbcli` from https://github.com/binance-chain/node-binary/tree/master/cli. + * (1.2) Create a new account through the [web-interface](https://testnet.binance.org/en/create) in the Binance testnet wallet. Copy the private key and mnemonic phrase. The private key will be used to import it in an Ethereum Wallet. The mnemonic phrase is to recover the BNB with `tbnbcli`. + * (1.3) Recover the account in the console with the mnemonic. + ``` + ./tbnbcli keys add test_account1 --recover + ``` + * (1.4) Create few BNB accounts from the console. They will be donors to provide enough funds to issue a BEP2 tokens (500 BNB required). + ``` + ./tbnbcli keys add test_account2 + ./tbnbcli keys add test_account3 + ``` + * (1.5) Register on the Binance site and fund the accounts from the [testnet faucet](https://www.binance.com/en/dex/testnet/address). + * (1.6) Re-arrange funds on the accounts as so the first account will have 550 BNB and others 10-20 BNBs to make transactions. + ``` + ./tbnbcli send --from test_account2 --to
\ + --amount 18500000000:BNB --chain-id=Binance-Chain-Nile \ + --node=data-seed-pre-2-s1.binance.org:80 --memo "donate" + ./tbnbcli send --from test_account3 --to
\ + --amount 18500000000:BNB --chain-id=Binance-Chain-Nile + --node=data-seed-pre-2-s1.binance.org:80 --memo "donate" + ``` + * (1.7) Issue the BEP2 token from the first account. `3141500000000000` corresponds to `31415000.0` tokens. + ``` + ./tbnbcli token issue --token-name "ERC20toBEP2Bridge" --total-supply 3141500000000000 \ + --symbol ETB0819 --mintable --from test_account1 --chain-id=Binance-Chain-Nile \ + --node=data-seed-pre-2-s1.binance.org:80 --trust-node + ``` + In the real deployment most probably the token must not be mintable. + * (1.8) Get the BEP2 token ID in `denom` field (in this example it is `ETB0819-863`). + ``` + ./tbnbcli account
\ + --chain-id=Binance-Chain-Nile --node=data-seed-pre-2-s1.binance.org:80 --trust-node + ``` + * (1.9) Clone the repo and initialize git submodules: + ``` + git clone --recurse-submodules https://github.com/k1rill-fedoseev/eth-to-bnc-bridge.git + ``` + * (1.10) Build TSS to be used in the bridge oracles: + ``` + docker build -t tss ./src/tss + ``` +2. Run test environment + * (2.1) Prepare three private keys for validators. Get the Ethereum account addresses for these keys. + * (2.2) Modify `src/deploy/deploy-home/.env.staging` and specify the token contract address in + the Kovan network via `HOME_TOKEN_ADDRESS` (use empty address `0x` if you want to create new + ERC20 contract while deployment). \ + Set `VALIDATOR_ADDRESS_*` to Ethereum addresses obtained in the previous step. + * (2.3) Modify `src/deploy/.keys.staging` and specify private keys for prefunded accounts in both networks. + These accounts are used for contract deployment. Use `src/deploy/.keys.staging.example` as an example. + * (2.4) Deploy contracts + ``` + TARGET_NETWORK=staging ./demo/start-ethereum-environment.sh + ``` + This command will deploy ERC20 contract and also mint tokens if you left `HOME_TOKEN_ADDRESS` empty, + the owner of tokens is the address that corresponds to the private key specified in + `HOME_PRIVATE_KEY` of `src/deploy/.keys.staging`.\ + Deployed contract addresses will be automatically updated in all required validators + and test services configs. + * (2.5) Prefund validator accounts in home network (Kovan): + ``` + TARGET_NETWORK=staging ./src/test-services/ethereumSend/run.sh 0 0.5 + ``` + * (2.6) Prefund validator accounts in side network (Sokol): + ``` + TARGET_NETWORK=staging ./src/test-services/sidePrefund/run.sh 1 + ``` + * (2.7) Send few tokens and coins from the current token owner to the first account. Coins are needed to pay transaction fees. + ``` + TARGET_NETWORK=staging ./src/test-services/ethereumSend/run.sh 5 0.5 + ``` + * (2.8) Check that the tokens were transferred properly: + ``` + TARGET_NETWORK=staging ./src/test-services/ethereumBalance/run.sh + ``` +3. Run validators nodes: + * (3.1) Modify the parameter `FOREIGN_ASSET` in `demo/validator1/.env.staging`, `demo/validator2/.env.staging` + and `demo/validator3/.env.staging` to the identificator of the token (step 1.8) that the oracle will track. \ + For staging environment additionally specify `VALIDATOR_PRIVATE_KEY` in the `demo/validator/.keys.staging` (step 2.2.1) + * (3.2) Run three validators in separate terminal sessions. + ``` + N=1 TARGET_NETWORK=staging ./demo/validator-demo.sh + N=2 TARGET_NETWORK=staging ./demo/validator-demo.sh + N=3 TARGET_NETWORK=staging ./demo/validator-demo.sh + ``` + Wait for when the line like the following appears: + ``` + keygen_1 | Generated multisig account in binance chain: tbnb1mutgnx9n9devmrjh3d0wz332fl8ymgel6tydx6 + ``` + The line contains the address of the bridge address in the Binance Chain. +4. Initialize the state of the bridge account in the Binance Chain + * (4.1) Fill the balance Fund with BNB coins as so the account will be able to make transactions: + ``` + ./src/test-services/binanceSend/run.sh
100 1 + ``` + To check the balance of the bridge account use `./src/test-services/binanceBalance/run.sh` + or [Binance Testnet Explorer](https://testnet-explorer.binance.org). It should report about two assets owned by the account. +5. Transfer tokens from Ethereum-based chain to the Binance Chain: + * (5.1) Send some amount of tokens to the bridge contract, for `PRIVATE_KEY` use some of the keys from step (1.3): + ``` + TARGET_NETWORK=staging PRIVATE_KEY= ./src/test-services/ethereumSend/run.sh bridge 5 + ``` + * (5.2) The validators will catch the event and start the process to sign the transaction. + * (5.3) As soon as the signature is generated and sent, the balance of the bridge account in both chains will be changed: + ``` + ./src/test-services/ethereumBalance/run.sh + ``` + should report non-zero balance, + ``` + ./src/test-services/binanceBalance/run.sh + ``` + should report about the balance reduction. + * (5.4) Check that the tokens were transferred properly to the test account: + ``` + ./src/test-services/binanceBalance/run.sh + ``` + The balance and transactions related to the bridge account in the Binance Chain could be checked in + [Binance Testnet Explorer](https://testnet-explorer.binance.org). +6. Transfer tokens from the Binance Chain to Ethereum-based chain: + * (6.1) Send some amount of tokens to the bridge account: + ``` + TARGET_NETWORK=staging PRIVATE_KEY= ./src/test-services/binanceSend/run.sh 3 + ``` + * (6.2) Check the balances of the test account on both sides of the bridge to see that the funds were transferred properly using commands from (5.3), (5.4). +7. Steps for updating validators list are exactly the same for both demo modes. Check the steps from development mode. + ### Finish demo 1. Stop all validator instances by pressing `^C` in the terminal. -2. Stop the local testnets: - ``` - docker kill ganache_home - docker kill ganache_side - ``` -3. Remove virtual networks: +2. Stop the local testnets (if any): ``` - docker network rm blockchain_home - docker network rm blockchain_side - docker network rm validator1_test_network - docker network rm validator2_test_network - docker network rm validator3_test_network + docker kill binance-testnet_http-api_1 + docker kill binance-testnet_node_1 + docker kill binance-testnet_api-server_1 + docker kill ethereum-testnet_ganache_home_1 + docker kill ethereum-testnet_ganache_side_1 + docker kill ethereum-testnet_side-oracle_1 ``` -4. Remove testnets and validators data: +3. Remove testnets and validators data: ``` - TARGET_NETWORK= ./demo/clean.sh + TARGET_NETWORK=development ./demo/clean.sh ``` #### Testing tools for both sides of the bridge diff --git a/README.md b/README.md index fcdf0a2..de70b41 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![CircleCI](https://circleci.com/gh/k1rill-fedoseev/eth-to-bnc-bridge/tree/dev.svg?style=svg)](https://circleci.com/gh/k1rill-fedoseev/eth-to-bnc-bridge/tree/dev) + ## Ethereum to Binance Chain bridge This repository contains a proof-of-concept for ERC20-to-BEP2 bridge. diff --git a/demo/clean.sh b/demo/clean.sh index b6c7c54..bf59570 100755 --- a/demo/clean.sh +++ b/demo/clean.sh @@ -9,13 +9,31 @@ TARGET_NETWORK=${TARGET_NETWORK:=development} echo "Cleaning $TARGET_NETWORK network" +docker kill $(docker ps | grep validator[1-3]_ | awk '{print $1}') > /dev/null 2>&1 || true +docker rm $(docker ps -a | grep validator[1-3]_ | awk '{print $1}') > /dev/null 2>&1 || true +docker kill ganache_home ganache_side > /dev/null 2>&1 || true +docker rm ganache_home ganache_side > /dev/null 2>&1 || true +docker kill $(docker ps | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true +docker rm $(docker ps -a | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true +docker kill $(docker ps | grep ethereum-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true +docker rm $(docker ps -a | grep ethereum-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true + if [[ "$TARGET_NETWORK" == "development" ]]; then - rm -rf ganache_side_db - rm -rf ganache_home_db - mkdir ganache_side_db - mkdir ganache_home_db + docker volume rm ganache_side_data > /dev/null 2>&1 || true + docker volume rm ganache_home_data > /dev/null 2>&1 || true + docker volume rm binance_data > /dev/null 2>&1 || true + docker volume rm binance_marketdata > /dev/null 2>&1 || true + + docker network rm ethereum_side_rpc_net > /dev/null 2>&1 || true + docker network rm ethereum_home_rpc_net > /dev/null 2>&1 || true + docker network rm binance_net > /dev/null 2>&1 || true + docker network rm binance-testnet_binance_rpc_net > /dev/null 2>&1 || true fi +docker network rm validator1_test_network > /dev/null 2>&1 || true +docker network rm validator2_test_network > /dev/null 2>&1 || true +docker network rm validator3_test_network > /dev/null 2>&1 || true + for (( I = 1; I < 4; ++I )); do DIRNAME="validator$I" rm -rf "$DIRNAME/$TARGET_NETWORK" diff --git a/demo/scenarios/macos/main.jxa b/demo/scenarios/macos/main.jxa deleted file mode 100644 index 9b0e127..0000000 --- a/demo/scenarios/macos/main.jxa +++ /dev/null @@ -1,417 +0,0 @@ -ObjC.import('stdlib') - -const terminal = Application('Terminal') -const system = Application('System Events') -const curApp = Application.currentApplication() -curApp.includeStandardAdditions = true - -const validator1 = '0x99Eb3D86663c6Db090eFFdBC20510Ca9f836DCE3' -const validator2 = '0xAa006899B0EC407De930bA8A166DEfe59bBfd3DC' -const validator3 = '0x6352e3e6038e05b9da00C84AE851308f9774F883' - -const userAccounts = [ - { - privateKey: '7ed93ad7753e00b52265a73dfbbcd2296256772965323fcb9a6320b5cd084b89', - ethAddress: '0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa', - bncAddress: 'tbnb14r3z8xk7qsar3vwj05w8cd8gqwk7g6gfurlt5l' - }, - { - privateKey: '2ad6e3a232ad3ea058b61352302118a99085600ff8b6eec4ccf0066a33756231', - ethAddress: '0xf7ca4aed1795e424433498cef43f6a3825c88731', - bncAddress: 'tbnb1efjg7xt98t67ql2cmwjc5860lgayet9l8m55ym' - }, - { - privateKey: 'eb6dd328677b3fa2822fb8e834507e569bda52e8ffa49266df0f2de239c4ec98', - ethAddress: '0xad6c8127143032d843a260c5d379d8d9b3d51f15', - bncAddress: 'tbnb12epcy4p7ktas0nlyrfuektcyh0e83dwzuq73f4' - } -] - -let bridgeBncAddress - -const windows = terminal.windows() - -const wins = [] - -function saveBlockchainData () { - console.log('Saving blockchain data') - curApp.doShellScript('zip -r ./demo/ganache_home_backup.zip ./demo/ganache_home_db') - curApp.doShellScript('zip -r ./demo/ganache_side_backup.zip ./demo/ganache_side_db') -} - -function reloadBlockchainData () { - console.log('Reloading blockchain data') - curApp.doShellScript('unzip -d . ./demo/ganache_home_backup.zip') - curApp.doShellScript('unzip -d . ./demo/ganache_side_backup.zip') -} - -function closeOldWindows () { - for (let i in windows) { - try { - windows[i].selectedTab() - - if (windows[i].selectedTab().customTitle().startsWith('Validator') || windows[i].selectedTab().customTitle() === 'Services') { - windows[i].close() - } - } catch (e) { - } - } -} - -function killValidators () { - terminal.activate() - for (let i = 0; i < 3; i++) { - wins[i].frontmost = true - delay(0.5) - system.keystroke('c', { using: 'control down' }) - } -} - -function openNewWindows () { - for (let i = 0; i < 3; i++) { - // open new terminal - const tab = terminal.doScript() - // get opened window - const winId = terminal.windows[0].id() - wins[i] = terminal.windows.byId(winId) - tab.customTitle = `Validator ${i + 1}` - } - wins[0].bounds = { x: 0, y: 23, width: 558, height: 1027 } - wins[1].bounds = { x: 559, y: 374, width: 560, height: 676 } - wins[2].bounds = { x: 1120, y: 374, width: 560, height: 676 } - // open new terminal - const tab = terminal.doScript() - // get opened window - const winId = terminal.windows[0].id() - wins[3] = terminal.windows.byId(winId) - tab.customTitle = `Services` - wins[3].bounds = { x: 559, y: 23, width: 1120, height: 350 } - - terminal.activate() - delay(0.5) -} - -function apiRequestBackground (url) { - const response = curApp.doShellScript(`curl -s -X GET "${url}"`) - try { - return JSON.parse(response) - } catch (e) { - return response - } -} - -function exec (n, script) { - terminal.doScript(script, { in: wins[n - 1] }) -} - -function wait (n) { - while (wins[n - 1].selectedTab().busy()) { - delay(0.2) - } -} - -function execSync (n, script) { - exec(n, script) - wait(n) -} - -function waitAll () { - wait(1) - wait(2) - wait(3) - wait(4) -} - -function waitLog (n, log) { - do { - const s = wins[n - 1].selectedTab().contents().split('\n').find(x => x.includes(log)) - if (s) { - return s - } - delay(0.2) - } while (true) -} - -function waitApi (n, url, check) { - do { - const res = apiRequestBackground(`http://localhost:500${n}${url}`) - const checkerRes = check ? check(res) : true - if (checkerRes) - return checkerRes - delay(3) - } while (true) -} - -function prefundEthAddresses () { - for (let { ethAddress } of userAccounts) { - execSync(4, `./src/test-services/ethereumSend/run.sh ${ethAddress} 100`) - } -} - -function prefundBncAddresses () { - for (let { bncAddress } of userAccounts) { - execSync(4, `./src/test-services/binanceSend/run.sh ${bncAddress} 100 0.1`) - } -} - -function initBalances () { - userAccounts.forEach(account => { - account.ethBalance = getEthTokenBalance(account.ethAddress) - account.bncBalance = getBncTokenBalance(account.bncAddress) - }) -} - -function getBncTokenBalance (address) { - const res = curApp.doShellScript(`./src/test-services/binanceBalance/run.sh ${address}`) - return parseFloat(/KFT-94F: [0-9.]+/.exec(res)[0].split(' ')[1]) -} - -function waitBncTokenBalance (address, balance) { - while (true) { - const newBalance = getBncTokenBalance(address) - if (Math.abs(newBalance - balance) < 0.0001) - return newBalance - delay(3) - } -} - -function getEthTokenBalance (address) { - const res = curApp.doShellScript(`./src/test-services/ethereumBalance/run.sh ${address}`) - return parseFloat(/[0-9.]+ tokens/.exec(res)[0].split(' ')[0]) -} - -function waitEthTokenBalance (address, balance) { - while (true) { - const newBalance = getEthTokenBalance(address) - if (Math.abs(newBalance - balance) < 0.0001) - return newBalance - delay(3) - } -} - -function apiRequest (n, url, suffix) { - execSync(4, `curl -s -X GET http://localhost:500${n}${url} ${suffix ? suffix : ''}`) -} - -function printState (msg) { - execSync(4, `echo "${msg}"`) - apiRequest(1, '/info', '| jq .') -} - -function initCwd () { - const cwd = $.getenv('PWD') - - for (let i = 1; i <= 4; i++) { - exec(i, `cd "${cwd}"`) - } - waitAll() -} - -function killDockerContainers () { - execSync(4, `docker kill $(docker ps | grep validator | awk '{print $1}') > /dev/null 2>&1 || true`) - execSync(4, `docker kill ganache_side ganache_home > /dev/null 2>&1 || true`) -} - -function clean () { - killDockerContainers() - execSync(4, `./demo/clean.sh`) - - exec(1, `clear`) - exec(2, `clear`) - exec(3, `clear`) - waitAll() -} - -function testEthToBnc () { - console.log('Testing eth => bnc') - // try token transfer in eth => bnc direction - let prevBridgeHomeBalance - let prevBridgeForeignBalance - waitApi(1, '/info', res => { - prevBridgeHomeBalance = res.homeBalance - prevBridgeForeignBalance = res.foreignBalanceTokens - return true - }) - - userAccounts.forEach((account, i) => { - execSync(4, `PRIVATE_KEY=${account.privateKey} ./src/test-services/ethereumSend/run.sh bridge ${5 + i}`) - account.ethBalance -= 5 + i - }) - - const delta = (9 + userAccounts.length) * userAccounts.length / 2 - waitApi(1, '/info', res => res.homeBalance === prevBridgeHomeBalance + delta && res.foreignBalanceTokens === prevBridgeForeignBalance - delta) - - userAccounts.forEach((account, i) => { - account.bncBalance = waitBncTokenBalance(account.bncAddress, account.bncBalance + 5 + i) - }) - - printState(`Token transfer in eth => bnc direction succeed`) - console.log('Testing eth => bnc is OK') -} - -function testBncToEth () { - console.log('Testing bnc => eth') - // try token transfer in bnc => eth direction - let prevBridgeHomeBalance - let prevBridgeForeignBalance - waitApi(1, '/info', res => { - prevBridgeHomeBalance = res.homeBalance - prevBridgeForeignBalance = res.foreignBalanceTokens - return true - }) - - userAccounts.forEach((account , i) => { - execSync(4, `PRIVATE_KEY=${account.privateKey} ./src/test-services/binanceSend/run.sh ${bridgeBncAddress} ${3 + i}`) - account.bncBalance -= 3 + i - }) - - const delta = (5 + userAccounts.length) * userAccounts.length / 2 - - waitApi(1, '/info', res => res.homeBalance === prevBridgeHomeBalance - delta && res.foreignBalanceTokens === prevBridgeForeignBalance + delta) - - userAccounts.forEach((account, i) => { - account.ethBalance = waitEthTokenBalance(account.ethAddress, account.ethBalance + 3 + i) - }) - - printState(`Token transfer in bnc => eth direction succeed`) - console.log('Testing bnc => eth is OK') -} - -function testRemoveValidator () { - console.log('Testing removing validator') - apiRequest(1, '/vote/startVoting') - apiRequest(2, '/vote/startVoting') - waitApi(1, '/info', res => res.bridgeStatus === 'voting') - apiRequest(1, `/vote/removeValidator/${validator2}`) - apiRequest(3, `/vote/removeValidator/${validator2}`) - waitApi(1, '/info', res => res.nextValidators.length === 2) - apiRequest(1, '/vote/startKeygen') - apiRequest(3, '/vote/startKeygen') - waitApi(1, '/info', res => { - if (res.bridgeStatus === 'ready' && res.epoch === 2 && res.validators.length === 2) { - bridgeBncAddress = res.foreignBridgeAddress - return true - } - return false - }) - printState(`Removing validator succeed`) - console.log('Testing removing validator is OK') -} - -function testAddValidator () { - console.log('Testing adding validator') - apiRequest(1, '/vote/startVoting') - apiRequest(3, '/vote/startVoting') - waitApi(1, '/info', res => res.bridgeStatus === 'voting') - apiRequest(1, `/vote/addValidator/${validator2}`) - apiRequest(3, `/vote/addValidator/${validator2}`) - waitApi(1, '/info', res => res.nextValidators.length === 3) - apiRequest(1, '/vote/startKeygen') - apiRequest(3, '/vote/startKeygen') - waitApi(1, '/info', res => { - if (res.bridgeStatus === 'ready' && res.epoch === 3 && res.validators.length === 3) { - bridgeBncAddress = res.foreignBridgeAddress - return true - } - return false - }) - printState(`Adding validator succeed`) - console.log('Testing adding validator is OK') -} - -function testChangeThreshold () { - console.log('Testing changing threshold') - apiRequest(1, '/vote/startVoting') - apiRequest(3, '/vote/startVoting') - waitApi(1, '/info', res => res.bridgeStatus === 'voting') - apiRequest(2, `/vote/changeThreshold/2`) - apiRequest(3, `/vote/changeThreshold/2`) - waitApi(1, '/info', res => res.nextThreshold === 2) - apiRequest(1, '/vote/startKeygen') - apiRequest(2, '/vote/startKeygen') - waitApi(1, '/info', res => { - if (res.bridgeStatus === 'ready' && res.epoch === 4 && res.threshold === 2) { - bridgeBncAddress = res.foreignBridgeAddress - return true - } - return false - }) - printState(`Changing threshold succeed`) - console.log('Testing changing threshold is OK') -} - -function run () { - closeOldWindows() - - openNewWindows() - - initCwd() - - clean() - - if ($.getenv('RELOAD') !== 'true') { - execSync(4, `./demo/start-environment.sh`) - - prefundEthAddresses() - - saveBlockchainData() - } else { - reloadBlockchainData() - - execSync(4, `./demo/start-environment.sh`) - } - - prefundBncAddresses() - - initBalances() - - exec(1, `N=1 ./demo/validator-demo.sh`) - exec(2, `N=2 ./demo/validator-demo.sh`) - exec(3, `N=3 ./demo/validator-demo.sh`) - - // wait until binance account willl be generated - waitLog(1, 'Generated multisig account in binance chain') - waitApi(1, '/info', res => { - if (res.epoch === 1) { - bridgeBncAddress = res.foreignBridgeAddress - return true - } - return false - }) - - // prefund binance account - execSync(4, `./src/test-services/binanceSend/run.sh ${bridgeBncAddress} 100 0.1`) - - // wait until binance prefund transaction will be processed - waitApi(1, '/info', res => res.foreignBalanceTokens === 100) - - printState(`Binance bridge account at ${bridgeBncAddress} for epoch 1 is generated and prefunded`) - - testEthToBnc() - - testBncToEth() - - testRemoveValidator() - - testEthToBnc() - - testBncToEth() - - testAddValidator() - - testEthToBnc() - - testBncToEth() - - testChangeThreshold() - - testEthToBnc() - - testBncToEth() - - console.log('PASSED ALL TESTS') - - killValidators() - - killDockerContainers() -} diff --git a/demo/scenarios/macos/run.sh b/demo/scenarios/macos/run.sh deleted file mode 100755 index 2351b7a..0000000 --- a/demo/scenarios/macos/run.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -RELOAD=${RELOAD:=false} - -RELOAD="$RELOAD" osascript -l JavaScript ./demo/scenarios/macos/main.jxa diff --git a/demo/start-binance-environment.sh b/demo/start-binance-environment.sh new file mode 100755 index 0000000..1b3a121 --- /dev/null +++ b/demo/start-binance-environment.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +set -e + +cd $(dirname "$0") + +tbnbcli() { + echo 12345678 | docker exec -i binance-testnet_node_1 ./tbnbcli $@ --from node0 --node http://node:26657 --chain-id Binance-Dev --json +} + +if [[ "$(docker volume ls | grep binance_data)" ]]; then + echo "Restarting binance test network" +else + echo "Creating new binance test network" + + echo "Removing old environment" + docker kill $(docker ps -a | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true + docker rm $(docker ps -a | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true + docker volume rm binance_marketdata > /dev/null 2>&1 || true + + docker network create binance_net > /dev/null 2>&1 || true + docker volume create binance_marketdata > /dev/null 2>&1 || true + docker volume create binance_data > /dev/null 2>&1 || true + + need_to_deploy=true +fi + +echo "Building required binaries" +docker build -t testnet-binaries ../src/binance-testnet > /dev/null 2>&1 || true + +echo "Running environment" +docker-compose -f ../src/binance-testnet/docker-compose.yml up --build -d + +if [[ -n "$need_to_deploy" ]]; then + echo "Issuing test asset" + TOKEN_SYMBOL='' + while [[ -z "$TOKEN_SYMBOL" ]]; do + sleep 2 + ISSUED_LOG=$(tbnbcli token issue --symbol DEV --total-supply 10000000000000000 --token-name "DEV Token" | jq .Response.log) + TOKEN_SYMBOL=${ISSUED_LOG:(-8):7} + done + + echo "Issued $TOKEN_SYMBOL" + + sed -i 's/FOREIGN_ASSET=.*$/FOREIGN_ASSET='"$TOKEN_SYMBOL"'/' ../src/test-services/binanceBalance/.env.development + sed -i 's/FOREIGN_ASSET=.*$/FOREIGN_ASSET='"$TOKEN_SYMBOL"'/' ../src/test-services/binanceSend/.env.development + sed -i 's/FOREIGN_ASSET=.*$/FOREIGN_ASSET='"$TOKEN_SYMBOL"'/' ../tests/.env + for file in ./validator*/.env.development; do + sed -i 's/FOREIGN_ASSET=.*$/FOREIGN_ASSET='"$TOKEN_SYMBOL"'/' "$file" + done + + sleep 2 + + echo "Sending tokens to controlled address" + tbnbcli token multi-send \ + --transfers '[{"to":"tbnb1z7u9f8mcuwxanns9xa6qgjtlka0d392epc0m9x","amount":"10000000000000000:BNB,10000000000000000:'"$TOKEN_SYMBOL"'"}]' + + sleep 2 +else + echo "Tokens are already issued, run clean.sh first if you want to redeploy everything" +fi diff --git a/demo/start-environment.sh b/demo/start-ethereum-environment.sh similarity index 65% rename from demo/start-environment.sh rename to demo/start-ethereum-environment.sh index 1cf6371..19a3800 100755 --- a/demo/start-environment.sh +++ b/demo/start-ethereum-environment.sh @@ -7,35 +7,14 @@ cd .. # either development or staging TARGET_NETWORK=${TARGET_NETWORK:=development} +BLOCK_TIME=${BLOCK_TIME:=3} DEPLOY_DIR="`pwd`/src/deploy" TEST_SERVICES_DIR="`pwd`/src/test-services" DEMO_DIR="`pwd`/demo" -SIDE_GANACHE_DB="$DEMO_DIR/ganache_side_db" -HOME_GANACHE_DB="$DEMO_DIR/ganache_home_db" - -start_dev_blockchain_networks() { - echo "Starting side test blockchain" - - docker kill ganache_side > /dev/null 2>&1 || true - docker network create blockchain_side > /dev/null 2>&1 || true - docker run -d --network blockchain_side --rm --name ganache_side -v "$SIDE_GANACHE_DB:/app/db" \ - -p "7545:8545" \ - trufflesuite/ganache-cli:latest \ - -m "shrug dwarf easily blade trigger lucky reopen cage lake scatter desk boat" -i 33 -q --db /app/db -b 3 --noVMErrorsOnRPCResponse - - echo "Starting home test blockchain" - - docker kill ganache_home > /dev/null 2>&1 || true - docker network create blockchain_home > /dev/null 2>&1 || true - docker run -d --network blockchain_home --rm --name ganache_home -v "$HOME_GANACHE_DB:/app/db" \ - -p "8545:8545" \ - trufflesuite/ganache-cli:latest \ - -m "shrug dwarf easily blade trigger lucky reopen cage lake scatter desk boat" -i 44 -q --db /app/db -b 3 --noVMErrorsOnRPCResponse - - sleep 4 -} +HOME_NETWORK="ethereum_home_rpc_net" +SIDE_NETWORK="ethereum_side_rpc_net" deploy_token() { echo "Compiling and deploying erc20" @@ -45,13 +24,13 @@ deploy_token() { echo "Deploying" if [[ "$TARGET_NETWORK" == "development" ]]; then - TOKEN_ADDRESS=$(docker run --network blockchain_home --rm -v "$DEPLOY_DIR/deploy-test/build:/build/build" --env-file "$DEPLOY_DIR/deploy-test/.env.$TARGET_NETWORK" \ + TOKEN_ADDRESS=$(docker run --network "$HOME_NETWORK" --rm -v "$DEPLOY_DIR/deploy-test/build:/build/build" --env-file "$DEPLOY_DIR/deploy-test/.env.development" \ deploy_test \ --network home 2>&1 \ | grep "contract address" \ | awk '{print $4}') else - TOKEN_ADDRESS=$(docker run --rm -v "$DEPLOY_DIR/deploy-test/build:/build/build" --env-file "$DEPLOY_DIR/deploy-test/.env.$TARGET_NETWORK" --env-file "$DEPLOY_DIR/.keys.$TARGET_NETWORK" \ + TOKEN_ADDRESS=$(docker run --rm -v "$DEPLOY_DIR/deploy-test/build:/build/build" --env-file "$DEPLOY_DIR/deploy-test/.env.staging" --env-file "$DEPLOY_DIR/.keys.staging" \ deploy_test \ --network home 2>&1 \ | grep "contract address" \ @@ -67,13 +46,13 @@ deploy_bridge() { echo "Deploying" if [[ "$TARGET_NETWORK" == "development" ]]; then - BRIDGE_ADDRESS=$(docker run --network blockchain_home --rm -v "$DEPLOY_DIR/deploy-home/build:/build/build" --env-file "$DEPLOY_DIR/deploy-home/.env.$TARGET_NETWORK" \ + BRIDGE_ADDRESS=$(docker run --network "$HOME_NETWORK" --rm -v "$DEPLOY_DIR/deploy-home/build:/build/build" --env-file "$DEPLOY_DIR/deploy-home/.env.development" \ deploy_home \ --network home 2>&1 \ | grep "contract address" \ | awk '{print $4}') else - BRIDGE_ADDRESS=$(docker run --rm -v "$DEPLOY_DIR/deploy-home/build:/build/build" --env-file "$DEPLOY_DIR/deploy-home/.env.$TARGET_NETWORK" --env-file "$DEPLOY_DIR/.keys.$TARGET_NETWORK" \ + BRIDGE_ADDRESS=$(docker run --rm -v "$DEPLOY_DIR/deploy-home/build:/build/build" --env-file "$DEPLOY_DIR/deploy-home/.env.staging" --env-file "$DEPLOY_DIR/.keys.staging" \ deploy_home \ --network home 2>&1 \ | grep "contract address" \ @@ -89,13 +68,13 @@ deploy_db() { echo "Deploying" if [[ "$TARGET_NETWORK" == "development" ]]; then - SHARED_DB_ADDRESS=$(docker run --network blockchain_side --rm -v "$DEPLOY_DIR/deploy-side/build:/build/build" --env-file "$DEPLOY_DIR/deploy-side/.env.$TARGET_NETWORK" \ + SHARED_DB_ADDRESS=$(docker run --network "$SIDE_NETWORK" --rm -v "$DEPLOY_DIR/deploy-side/build:/build/build" --env-file "$DEPLOY_DIR/deploy-side/.env.development" \ deploy_side \ --network side 2>&1 \ | grep "contract address" \ | awk '{print $4}') else - SHARED_DB_ADDRESS=$(docker run --rm -v "$DEPLOY_DIR/deploy-side/build:/build/build" --env-file "$DEPLOY_DIR/deploy-side/.env.$TARGET_NETWORK" --env-file "$DEPLOY_DIR/.keys.$TARGET_NETWORK" \ + SHARED_DB_ADDRESS=$(docker run --rm -v "$DEPLOY_DIR/deploy-side/build:/build/build" --env-file "$DEPLOY_DIR/deploy-side/.env.staging" --env-file "$DEPLOY_DIR/.keys.staging" \ deploy_side \ --network side 2>&1 \ | grep "contract address" \ @@ -131,33 +110,39 @@ deploy_all() { sed -i 's/HOME_TOKEN_ADDRESS=.*$/HOME_TOKEN_ADDRESS='"$TOKEN_ADDRESS"'/' "$TEST_SERVICES_DIR/ethereumSend/.env.$TARGET_NETWORK" } +if [[ "$TARGET_NETWORK" == "development" ]]; then + if [[ "$(docker volume ls | grep ganache_side_data)" ]] || [[ "$(docker volume ls | grep ganache_home_data)" ]]; then + echo "Restarting ethereum test network" + else + echo "Creating new ethereum test network" + echo "Removing old environment" + docker kill $(docker ps -a | grep ethereum-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true + docker rm $(docker ps -a | grep ethereum-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true + docker volume rm ganache_side_data > /dev/null 2>&1 || true + docker volume rm ganache_home_data > /dev/null 2>&1 || true -if [[ "$TARGET_NETWORK" == "development" ]]; then - if [[ ! -d "$SIDE_GANACHE_DB" ]]; then - mkdir "$SIDE_GANACHE_DB" - fi + docker network create ethereum_side_rpc_net > /dev/null 2>&1 || true + docker network create ethereum_home_rpc_net > /dev/null 2>&1 || true + docker volume create ganache_side_data > /dev/null 2>&1 || true + docker volume create ganache_home_data > /dev/null 2>&1 || true - if [[ ! -d "$HOME_GANACHE_DB" ]]; then - mkdir "$HOME_GANACHE_DB" + need_to_deploy=true fi + echo "Starting ethereum test environment" - if [[ -z "$(ls -A "$SIDE_GANACHE_DB")" ]] || [[ -z "$(ls -A "$HOME_GANACHE_DB")" ]]; then - echo "Starting dev blockchain networks and deploying contracts" - need_to_deploy=true - else - echo "Restarting dev blockchain networks" - fi + BLOCK_TIME="$BLOCK_TIME" docker-compose -f ./src/ethereum-testnet/docker-compose.yml up --build -d - start_dev_blockchain_networks + sleep 4 if [[ -n "$need_to_deploy" ]]; then deploy_all else echo "Contracts are already deployed, run clean.sh first if you want to redeploy everything" fi + else echo "Deploying to the staging blockchain environment" diff --git a/demo/validator-demo.sh b/demo/validator-demo.sh index 52e0592..5ea1730 100755 --- a/demo/validator-demo.sh +++ b/demo/validator-demo.sh @@ -23,4 +23,4 @@ fi # load env for particular environment source ".env.$TARGET_NETWORK" -docker-compose -p "$NAME" -f ../../src/oracle/docker-compose-test.yml up ${DCU_FLAGS} +docker-compose -p "$NAME" -f ../../src/oracle/docker-compose-test.yml up ${DCU_FLAGS} $@ diff --git a/demo/validator1/.env.development b/demo/validator1/.env.development index a79e662..b27189a 100644 --- a/demo/validator1/.env.development +++ b/demo/validator1/.env.development @@ -2,13 +2,24 @@ HOME_RPC_URL=http://ganache_home:8545 HOME_BRIDGE_ADDRESS=0x44c158FE850821ae69DaF37AADF5c539e9d0025B HOME_TOKEN_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc HOME_START_BLOCK=1 +HOME_MAX_FETCH_RANGE_SIZE=10 SIDE_RPC_URL=http://ganache_side:8545 SIDE_SHARED_DB_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc -FOREIGN_URL=https://testnet-dex.binance.org/ -FOREIGN_CHAIN_ID=Binance-Chain-Nile -FOREIGN_ASSET=KFT-94F +FOREIGN_URL=http://http-api:8000 +FOREIGN_CHAIN_ID=Binance-Dev +FOREIGN_ASSET=DEV-9BA +FOREIGN_FETCH_MAX_TIME_INTERVAL=60000 +FOREIGN_FETCH_INTERVAL=5000 +FOREIGN_FETCH_BLOCK_TIME_OFFSET=10000 + +SIGN_ATTEMPT_TIMEOUT=120000 +SIGN_NONCE_CHECK_INTERVAL=10000 +SEND_TIMEOUT=60000 + +KEYGEN_ATTEMPT_TIMEOUT=120000 +KEYGEN_EPOCH_CHECK_INTERVAL=10000 VALIDATOR_PRIVATE_KEY=2be3f252e16541bf1bb2d4a517d2bf173e6d09f2d765d32c64dc50515aec63ea @@ -16,4 +27,6 @@ VOTES_PROXY_PORT=5001 SIGN_RESTART_PORT=6001 -LOG_LEVEL=debug +KEYGEN_RESTART_PORT=7001 + +LOG_LEVEL=trace diff --git a/demo/validator1/.env.staging b/demo/validator1/.env.staging index 5e5e086..b3c1acf 100644 --- a/demo/validator1/.env.staging +++ b/demo/validator1/.env.staging @@ -1,14 +1,25 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0 -HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e -HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc -HOME_START_BLOCK=13276224 +HOME_BRIDGE_ADDRESS=0x01eD0d6350542E7643cB7bba4bccc96FedE0B616 +HOME_TOKEN_ADDRESS=0x7c7daEf752C80A6d229D4a642B9336ceCd7e26b0 +HOME_START_BLOCK=14760000 +HOME_MAX_FETCH_RANGE_SIZE=50 SIDE_RPC_URL=https://sokol.poa.network -SIDE_SHARED_DB_ADDRESS=0xda9a1cA2Fcb18cAB02934269369627D2b4ea8902 +SIDE_SHARED_DB_ADDRESS=0x7B307e73Ba9808BcA7cf24F1E7Ae9372faCeD102 FOREIGN_URL=https://testnet-dex.binance.org/ FOREIGN_CHAIN_ID=Binance-Chain-Nile FOREIGN_ASSET=KFT-94F +FOREIGN_FETCH_MAX_TIME_INTERVAL=60000 +FOREIGN_FETCH_INTERVAL=5000 +FOREIGN_FETCH_BLOCK_TIME_OFFSET=10000 + +SIGN_ATTEMPT_TIMEOUT=120000 +SIGN_NONCE_CHECK_INTERVAL=10000 +SEND_TIMEOUT=60000 + +KEYGEN_ATTEMPT_TIMEOUT=120000 +KEYGEN_EPOCH_CHECK_INTERVAL=10000 #VALIDATOR_PRIVATE_KEY is taken from .keys @@ -16,4 +27,6 @@ VOTES_PROXY_PORT=5001 SIGN_RESTART_PORT=6001 +KEYGEN_RESTART_PORT=7001 + LOG_LEVEL=info diff --git a/demo/validator2/.env.development b/demo/validator2/.env.development index 3e88317..2ac5ed6 100644 --- a/demo/validator2/.env.development +++ b/demo/validator2/.env.development @@ -2,13 +2,24 @@ HOME_RPC_URL=http://ganache_home:8545 HOME_BRIDGE_ADDRESS=0x44c158FE850821ae69DaF37AADF5c539e9d0025B HOME_TOKEN_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc HOME_START_BLOCK=1 +HOME_MAX_FETCH_RANGE_SIZE=10 SIDE_RPC_URL=http://ganache_side:8545 SIDE_SHARED_DB_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc -FOREIGN_URL=https://testnet-dex.binance.org/ -FOREIGN_CHAIN_ID=Binance-Chain-Nile -FOREIGN_ASSET=KFT-94F +FOREIGN_URL=http://http-api:8000 +FOREIGN_CHAIN_ID=Binance-Dev +FOREIGN_ASSET=DEV-9BA +FOREIGN_FETCH_MAX_TIME_INTERVAL=60000 +FOREIGN_FETCH_INTERVAL=5000 +FOREIGN_FETCH_BLOCK_TIME_OFFSET=10000 + +SIGN_ATTEMPT_TIMEOUT=120000 +SIGN_NONCE_CHECK_INTERVAL=10000 +SEND_TIMEOUT=60000 + +KEYGEN_ATTEMPT_TIMEOUT=120000 +KEYGEN_EPOCH_CHECK_INTERVAL=10000 VALIDATOR_PRIVATE_KEY=e59d58c77b791f98f10187117374ae9c589d48a62720ec6a5e142b0cc134f685 @@ -16,4 +27,6 @@ VOTES_PROXY_PORT=5002 SIGN_RESTART_PORT=6002 -LOG_LEVEL=debug +KEYGEN_RESTART_PORT=7002 + +LOG_LEVEL=trace diff --git a/demo/validator2/.env.staging b/demo/validator2/.env.staging index eb851f3..7d0bf69 100644 --- a/demo/validator2/.env.staging +++ b/demo/validator2/.env.staging @@ -1,14 +1,25 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0 -HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e -HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc -HOME_START_BLOCK=13276224 +HOME_BRIDGE_ADDRESS=0x01eD0d6350542E7643cB7bba4bccc96FedE0B616 +HOME_TOKEN_ADDRESS=0x7c7daEf752C80A6d229D4a642B9336ceCd7e26b0 +HOME_START_BLOCK=14760000 +HOME_MAX_FETCH_RANGE_SIZE=50 SIDE_RPC_URL=https://sokol.poa.network -SIDE_SHARED_DB_ADDRESS=0xda9a1cA2Fcb18cAB02934269369627D2b4ea8902 +SIDE_SHARED_DB_ADDRESS=0x7B307e73Ba9808BcA7cf24F1E7Ae9372faCeD102 FOREIGN_URL=https://testnet-dex.binance.org/ FOREIGN_CHAIN_ID=Binance-Chain-Nile FOREIGN_ASSET=KFT-94F +FOREIGN_FETCH_MAX_TIME_INTERVAL=60000 +FOREIGN_FETCH_INTERVAL=5000 +FOREIGN_FETCH_BLOCK_TIME_OFFSET=10000 + +SIGN_ATTEMPT_TIMEOUT=120000 +SIGN_NONCE_CHECK_INTERVAL=10000 +SEND_TIMEOUT=60000 + +KEYGEN_ATTEMPT_TIMEOUT=120000 +KEYGEN_EPOCH_CHECK_INTERVAL=10000 #VALIDATOR_PRIVATE_KEY is taken from .keys @@ -16,4 +27,6 @@ VOTES_PROXY_PORT=5002 SIGN_RESTART_PORT=6002 +KEYGEN_RESTART_PORT=7002 + LOG_LEVEL=info diff --git a/demo/validator3/.env.development b/demo/validator3/.env.development index 3454cd6..2f3f501 100644 --- a/demo/validator3/.env.development +++ b/demo/validator3/.env.development @@ -2,13 +2,24 @@ HOME_RPC_URL=http://ganache_home:8545 HOME_BRIDGE_ADDRESS=0x44c158FE850821ae69DaF37AADF5c539e9d0025B HOME_TOKEN_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc HOME_START_BLOCK=1 +HOME_MAX_FETCH_RANGE_SIZE=10 SIDE_RPC_URL=http://ganache_side:8545 SIDE_SHARED_DB_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc -FOREIGN_URL=https://testnet-dex.binance.org/ -FOREIGN_CHAIN_ID=Binance-Chain-Nile -FOREIGN_ASSET=KFT-94F +FOREIGN_URL=http://http-api:8000 +FOREIGN_CHAIN_ID=Binance-Dev +FOREIGN_ASSET=DEV-9BA +FOREIGN_FETCH_MAX_TIME_INTERVAL=60000 +FOREIGN_FETCH_INTERVAL=5000 +FOREIGN_FETCH_BLOCK_TIME_OFFSET=10000 + +SIGN_ATTEMPT_TIMEOUT=120000 +SIGN_NONCE_CHECK_INTERVAL=10000 +SEND_TIMEOUT=60000 + +KEYGEN_ATTEMPT_TIMEOUT=120000 +KEYGEN_EPOCH_CHECK_INTERVAL=10000 VALIDATOR_PRIVATE_KEY=afaa4d4d6e54d25b0bf0361e3fd6cef562f6311bf6200de2dd0aa4cab63ae3b5 @@ -16,4 +27,6 @@ VOTES_PROXY_PORT=5003 SIGN_RESTART_PORT=6003 -LOG_LEVEL=debug +KEYGEN_RESTART_PORT=7003 + +LOG_LEVEL=trace diff --git a/demo/validator3/.env.staging b/demo/validator3/.env.staging index 73f9f99..5ea48ed 100644 --- a/demo/validator3/.env.staging +++ b/demo/validator3/.env.staging @@ -1,14 +1,25 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0 -HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e -HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc -HOME_START_BLOCK=13276224 +HOME_BRIDGE_ADDRESS=0x01eD0d6350542E7643cB7bba4bccc96FedE0B616 +HOME_TOKEN_ADDRESS=0x7c7daEf752C80A6d229D4a642B9336ceCd7e26b0 +HOME_START_BLOCK=14760000 +HOME_MAX_FETCH_RANGE_SIZE=50 SIDE_RPC_URL=https://sokol.poa.network -SIDE_SHARED_DB_ADDRESS=0xda9a1cA2Fcb18cAB02934269369627D2b4ea8902 +SIDE_SHARED_DB_ADDRESS=0x7B307e73Ba9808BcA7cf24F1E7Ae9372faCeD102 FOREIGN_URL=https://testnet-dex.binance.org/ FOREIGN_CHAIN_ID=Binance-Chain-Nile FOREIGN_ASSET=KFT-94F +FOREIGN_FETCH_MAX_TIME_INTERVAL=60000 +FOREIGN_FETCH_INTERVAL=5000 +FOREIGN_FETCH_BLOCK_TIME_OFFSET=10000 + +SIGN_ATTEMPT_TIMEOUT=120000 +SIGN_NONCE_CHECK_INTERVAL=10000 +SEND_TIMEOUT=60000 + +KEYGEN_ATTEMPT_TIMEOUT=120000 +KEYGEN_EPOCH_CHECK_INTERVAL=10000 #VALIDATOR_PRIVATE_KEY is taken from .keys @@ -16,4 +27,6 @@ VOTES_PROXY_PORT=5003 SIGN_RESTART_PORT=6003 +KEYGEN_RESTART_PORT=7003 + LOG_LEVEL=info diff --git a/package.json b/package.json new file mode 100644 index 0000000..e954bd9 --- /dev/null +++ b/package.json @@ -0,0 +1,14 @@ +{ + "name": "bridge", + "version": "0.0.1", + "devDependencies": { + "eslint": "^6.6.0", + "eslint-config-airbnb": "^18.0.1", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-node": "^10.0.0", + "eslint-plugin-truffle": "0.3.1" + }, + "engines": { + "node": ">=10.6.0" + } +} diff --git a/src/binance-testnet/Dockerfile b/src/binance-testnet/Dockerfile new file mode 100644 index 0000000..b4b0a92 --- /dev/null +++ b/src/binance-testnet/Dockerfile @@ -0,0 +1,19 @@ +FROM ubuntu:19.10 + +ARG BNC_VERSION=0.6.2 + +RUN apt-get update && \ + apt-get install -y git git-lfs + +WORKDIR /binaries + +RUN GIT_LFS_SKIP_SMUDGE=1 git clone --depth 1 https://github.com/binance-chain/node-binary.git . + +RUN git lfs pull -I fullnode/testnet/${BNC_VERSION}/linux +RUN git lfs pull -I cli/testnet/${BNC_VERSION}/linux + +RUN ./fullnode/testnet/${BNC_VERSION}/linux/bnbchaind testnet --acc-prefix tbnb --chain-id Binance-Dev --v 1 + +RUN sed -i "s/publishTransfer = false/publishTransfer = true/" ./mytestnet/node0/gaiad/config/app.toml && \ + sed -i "s/publishLocal = false/publishLocal = true/" ./mytestnet/node0/gaiad/config/app.toml && \ + sed -i "s/BEP12Height = 9223372036854775807/BEP12Height = 1/" ./mytestnet/node0/gaiad/config/app.toml diff --git a/src/binance-testnet/api-server/Dockerfile b/src/binance-testnet/api-server/Dockerfile new file mode 100644 index 0000000..17be5fa --- /dev/null +++ b/src/binance-testnet/api-server/Dockerfile @@ -0,0 +1,13 @@ +FROM alpine:3.9.4 + +ARG BNC_VERSION=0.6.2 + +WORKDIR /api-server + +COPY --from=testnet-binaries /binaries/cli/testnet/${BNC_VERSION}/linux/tbnbcli ./ + +RUN echo 12345678 | ./tbnbcli keys add key --no-backup + +EXPOSE 8080 + +ENTRYPOINT ["./tbnbcli", "api-server", "--chain-id", "Binance-Dev", "--laddr", "tcp://0.0.0.0:8080", "--node"] diff --git a/src/binance-testnet/docker-compose.yml b/src/binance-testnet/docker-compose.yml new file mode 100644 index 0000000..b2ad8f1 --- /dev/null +++ b/src/binance-testnet/docker-compose.yml @@ -0,0 +1,42 @@ +version: '3.0' +services: + node: + build: node + image: bnc-testnet + networks: + - binance_rpc_net + ports: + - '26657:26657' + volumes: + - 'binance_marketdata:/root/.bnbchaind/marketdata' + - 'binance_data:/root/.bnbchaind/data' + api-server: + build: api-server + image: bnc-api-server + networks: + - binance_rpc_net + ports: + - '8080:8080' + command: ["http://node:26657"] + http-api: + build: http-api + image: bnc-http-api + environment: + FOREIGN_RPC_URL: 'http://node:26657' + FOREIGN_API_SERVER_URL: 'http://api-server:8080' + networks: + - binance_net + - binance_rpc_net + ports: + - '8000:8000' + volumes: + - 'binance_marketdata:/http-api/marketdata' +networks: + binance_net: + external: true + binance_rpc_net: +volumes: + binance_marketdata: + external: true + binance_data: + external: true diff --git a/src/binance-testnet/http-api/Dockerfile b/src/binance-testnet/http-api/Dockerfile new file mode 100644 index 0000000..1be9e4c --- /dev/null +++ b/src/binance-testnet/http-api/Dockerfile @@ -0,0 +1,15 @@ +FROM node:10.16.0-alpine + +ARG BNC_VERSION=0.6.2 + +WORKDIR /http-api + +COPY --from=testnet-binaries /binaries/cli/testnet/${BNC_VERSION}/linux/tbnbcli ./ + +COPY ./package.json ./ + +RUN npm install + +COPY ./index.js ./parser.js ./ + +ENTRYPOINT ["node", "./index.js"] diff --git a/src/binance-testnet/http-api/index.js b/src/binance-testnet/http-api/index.js new file mode 100644 index 0000000..60feabb --- /dev/null +++ b/src/binance-testnet/http-api/index.js @@ -0,0 +1,163 @@ +const { execSync } = require('child_process') + +const express = require('express') +const axios = require('axios') +const BN = require('bignumber.js') + +const createParser = require('./parser') + +const rpcClient = axios.create({ + baseURL: process.env.FOREIGN_RPC_URL, + timeout: 10000 +}) + +const apiClient = axios.create({ + baseURL: process.env.FOREIGN_API_SERVER_URL, + timeout: 10000 +}) + +const transfers = [] + +const parser = createParser('/http-api/marketdata/marketdata.json', 20 * 1024) +parser.eventEmitter.on('object', (obj) => { + obj.Transfers.forEach((event) => { + // eslint-disable-next-line no-param-reassign + event.Timestamp = Math.ceil(obj.Timestamp / 10 ** 6) + transfers.push(event) + }) +}) + +const app = express() +app.use('/api/v1/broadcast', (req, res, next) => { + req.rawBody = '' + req.on('data', (chunk) => { + req.rawBody += chunk.toString() + }) + req.on('end', () => { + next() + }) +}) + +function wrap(f) { + return async (req, res) => { + try { + await f(req, res) + } catch (e) { + res.status(404).end() + } + } +} + +async function handleTx(req, res) { + const { + tx, hash, height, result + } = JSON.parse( + execSync(`./tbnbcli tx ${req.params.hash} --node "http://node:26657" --chain-id Binance-Dev`) + ) + res.send({ + code: 0, + hash, + height, + log: result.log, + ok: true, + tx + }) +} + +async function handleTransactions(req, res) { + // eslint-disable-next-line no-empty + while (parser.update()) {} + const { + address, side, txAsset, txType, startTime, endTime + } = req.query + if (txType !== 'TRANSFER' || side !== 'RECEIVE') { + res.status(400).send('Given parameters are not supported') + } + const filtered = transfers.filter((event) => event.Timestamp >= parseInt(startTime, 10) + && event.Timestamp <= parseInt(endTime, 10) + && event.To.length === 1 + && event.To[0].Addr === address + && event.To[0].Coins.length === 1 + && event.To[0].Coins[0].denom === txAsset) + res.send({ + tx: filtered.map((tx) => ({ + txHash: tx.TxHash, + memo: tx.Memo, + value: new BN(tx.To[0].Coins[0].amount).dividedBy(10 ** 8).toFixed(8, 3) + })), + total: filtered.length + }) +} + +async function handleTime(req, res) { + const response = (await rpcClient.get('/status')).data + res.send({ + ap_time: response.result.sync_info.latest_block_time, + block_time: response.result.sync_info.latest_block_time + }) +} + +async function handleAccount(req, res) { + const response = (await apiClient.get(`/api/v1/account/${req.params.account}`)).data + res.send(response) +} + +async function handleAccountSequence(req, res) { + const response = (await apiClient.get(`/api/v1/account/${req.params.account}`)).data + res.send({ sequence: response.sequence }) +} + +async function handleNodeInfo(req, res) { + const response = (await rpcClient.get('/status')).data + res.send(response.result) +} + +async function handleFees(req, res) { + const response = (await apiClient.get('/api/v1/fees')).data + res.send(response) +} + +async function handleBroadcast(req, res) { + if (req.query.sync !== 'true') { + res.status(400).send('Async broadcast is not supported') + } else { + const response = await rpcClient.get('/broadcast_tx_sync', { + params: { + tx: `0x${req.rawBody}` + } + }) + if (response.data.error) { + res.status(500).send({ + code: 500, + failed_tx_index: 0, + message: 'RPC error -32603 - Internal error: Tx already exists in cache', + success_tx_results: [] + }) + } else if (response.data.result.code === 65546) { + res.status(400).send({ + code: 400, + failed_tx_index: 0, + message: '3417218964BNB < 1000DEV-BA6', + success_tx_results: [] + }) + } else if (response.data.result) { + res.send([response.data.result]) + } else { + res.status(400).end() + } + } +} + +app.get('/api/v1/tx/:hash', wrap(handleTx)) +app.get('/api/v1/time', wrap(handleTime)) +app.get('/api/v1/transactions', wrap(handleTransactions)) +app.get('/api/v1/account/:account', wrap(handleAccount)) +app.get('/api/v1/account/:account/sequence', wrap(handleAccountSequence)) +app.get('/api/v1/node-info', wrap(handleNodeInfo)) +app.get('/api/v1/fees', wrap(handleFees)) +app.post('/api/v1/broadcast', wrap(handleBroadcast)) + +app.listen(8000, () => { + // eslint-disable-next-line no-console + console.log('Listening on port 8000') +}) diff --git a/src/binance-testnet/http-api/package.json b/src/binance-testnet/http-api/package.json new file mode 100644 index 0000000..d776fa9 --- /dev/null +++ b/src/binance-testnet/http-api/package.json @@ -0,0 +1,12 @@ +{ + "name": "api-server", + "version": "0.0.1", + "dependencies": { + "express": "4.17.1", + "axios": "0.19.0", + "bignumber.js": "9.0.0" + }, + "engines": { + "node": ">=10.6.0" + } +} diff --git a/src/binance-testnet/http-api/parser.js b/src/binance-testnet/http-api/parser.js new file mode 100644 index 0000000..fc88586 --- /dev/null +++ b/src/binance-testnet/http-api/parser.js @@ -0,0 +1,44 @@ +const events = require('events') +const fs = require('fs') + +function createParser(file, bufferSize) { + const buf = Buffer.alloc(bufferSize) + const eventEmitter = new events.EventEmitter() + let fd + let position = 0 + let end = 0 + + return { + update() { + if (!fd) { + try { + fd = fs.openSync(file, 'r') + } catch (e) { + return 0 + } + } + const bytesRead = fs.readSync(fd, buf, position, buf.length - position, null) + for (let i = position; i < position + bytesRead; i += 1) { + if (buf[i] === 10) { + const obj = buf.slice(end, i) + end = i + 1 + eventEmitter.emit('object', JSON.parse(obj)) + } + } + position += bytesRead + + if (buf.length - position < bufferSize / 2) { + buf.copy(buf, 0, end, position) + position -= end + end = 0 + } + return bytesRead + }, + close() { + fs.closeSync(fd) + }, + eventEmitter + } +} + +module.exports = createParser diff --git a/src/binance-testnet/node/Dockerfile b/src/binance-testnet/node/Dockerfile new file mode 100644 index 0000000..0ee5779 --- /dev/null +++ b/src/binance-testnet/node/Dockerfile @@ -0,0 +1,14 @@ +FROM alpine:3.9.4 + +ARG BNC_VERSION=0.6.2 + +WORKDIR /bnc + +COPY --from=testnet-binaries /binaries/fullnode/testnet/${BNC_VERSION}/linux/bnbchaind ./ +COPY --from=testnet-binaries /binaries/cli/testnet/${BNC_VERSION}/linux/tbnbcli ./ +COPY --from=testnet-binaries /binaries/mytestnet/node0/gaiacli /root/.bnbcli +COPY --from=testnet-binaries /binaries/mytestnet/node0/gaiad /root/.bnbchaind + +EXPOSE 26657 + +ENTRYPOINT ["./bnbchaind", "start"] diff --git a/src/deploy/.eslintrc b/src/deploy/.eslintrc new file mode 100644 index 0000000..8f4829c --- /dev/null +++ b/src/deploy/.eslintrc @@ -0,0 +1,11 @@ +{ + "extends": [ + "../../.eslintrc" + ], + "plugins": [ + "truffle" + ], + "env": { + "truffle/globals": true + } +} diff --git a/src/deploy/deploy-home/.env.development b/src/deploy/deploy-home/.env.development index 000ccbe..b13d306 100644 --- a/src/deploy/deploy-home/.env.development +++ b/src/deploy/deploy-home/.env.development @@ -9,9 +9,11 @@ VALIDATOR_ADDRESS_2=0xaa006899b0ec407de930ba8a166defe59bbfd3dc VALIDATOR_ADDRESS_3=0x6352e3e6038e05b9da00c84ae851308f9774f883 #VALIDATOR_ADDRESS_4=0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa -THRESHOLD=1 +THRESHOLD=2 MIN_TX_LIMIT=10000000000000000 -MAX_TX_LIMIT=100000000000000000000 +MAX_TX_LIMIT=1000000000000000000000 -BLOCKS_RANGE_SIZE=25 +BLOCKS_RANGE_SIZE=10 + +CLOSE_EPOCH_FLAG=true diff --git a/src/deploy/deploy-home/.env.staging b/src/deploy/deploy-home/.env.staging index 5d80c82..7fdaf13 100644 --- a/src/deploy/deploy-home/.env.staging +++ b/src/deploy/deploy-home/.env.staging @@ -3,16 +3,18 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0 #HOME_PRIVATE_KEY is taken from src/deploy/.keys.staging #Set to '0x' for redeployment of token contract in staging environment -HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc +HOME_TOKEN_ADDRESS=0x7c7daEf752C80A6d229D4a642B9336ceCd7e26b0 VALIDATOR_ADDRESS_1=0xaaaaB15630f63cA01bb50943AaAb4008CB53748D VALIDATOR_ADDRESS_2=0xbbbb63D6Fc58bD14dAF9eeF653650c4D10f3dBC8 VALIDATOR_ADDRESS_3=0xcccc27ae510b63E30eC3C68AAD7DdD2578bD62ed #VALIDATOR_ADDRESS_4=0xdddd9300e32fe162bA420f7313651Fd901C2ed71 -THRESHOLD=1 +THRESHOLD=2 MIN_TX_LIMIT=10000000000000000 MAX_TX_LIMIT=100000000000000000000 BLOCKS_RANGE_SIZE=25 + +CLOSE_EPOCH_FLAG=true diff --git a/src/deploy/deploy-home/.solhint.json b/src/deploy/deploy-home/.solhint.json new file mode 100644 index 0000000..d7c3de9 --- /dev/null +++ b/src/deploy/deploy-home/.solhint.json @@ -0,0 +1,3 @@ +{ + "extends": "solhint:default" +} diff --git a/src/deploy/deploy-home/Dockerfile b/src/deploy/deploy-home/Dockerfile index cbdf66a..a769574 100644 --- a/src/deploy/deploy-home/Dockerfile +++ b/src/deploy/deploy-home/Dockerfile @@ -9,8 +9,6 @@ RUN npm install truffle-hdwallet-provider RUN truffle obtain --solc 0.5.9 -COPY truffle-config-build.js /build/truffle-config.js - RUN mkdir temp \ && cd temp \ && truffle init \ @@ -19,6 +17,7 @@ RUN mkdir temp \ && cd .. \ && rm -rf temp +COPY truffle-config-build.js /build/truffle-config.js COPY contracts/openzeppelin-solidity /build/contracts/openzeppelin-solidity RUN truffle compile diff --git a/src/deploy/deploy-home/contracts/BasicBridge.sol b/src/deploy/deploy-home/contracts/BasicBridge.sol new file mode 100644 index 0000000..86a2e08 --- /dev/null +++ b/src/deploy/deploy-home/contracts/BasicBridge.sol @@ -0,0 +1,174 @@ +pragma solidity ^0.5.0; + +import './openzeppelin-solidity/contracts/token/ERC20/IERC20.sol'; + +contract BasicBridge { + uint32 constant UPPER_BOUND = 0xffffffff; + + event EpochEnd(uint16 indexed epoch); + event EpochClose(uint16 indexed epoch); + event ForceSign(); + event NewEpoch(uint16 indexed oldEpoch, uint16 indexed newEpoch); + event NewEpochCancelled(uint16 indexed epoch); + event NewFundsTransfer(uint16 indexed oldEpoch, uint16 indexed newEpoch); + event EpochStart(uint16 indexed epoch, uint x, uint y); + + struct State { + address[] validators; + uint32 startBlock; + uint32 endBlock; + uint32 nonce; + uint16 threshold; + uint16 rangeSize; + bool closeEpoch; + uint x; + uint y; + } + + enum Status { + READY, // bridge is in ready to perform operations + CLOSING_EPOCH, // generating transaction for blocking binance side of the bridge + VOTING, // voting for changing in next epoch, but still ready + KEYGEN, //keygen, can be cancelled + FUNDS_TRANSFER // funds transfer, cannot be cancelled + } + + mapping(uint16 => State) public states; + + Status public status; + + uint16 public epoch; + uint16 public nextEpoch; + + uint96 minTxLimit; + uint96 maxTxLimit; + + IERC20 public tokenContract; + + modifier ready { + require(status == Status.READY, "Not in ready state"); + _; + } + + modifier closingEpoch { + require(status == Status.CLOSING_EPOCH, "Not in closing epoch state"); + _; + } + + modifier voting { + require(status == Status.VOTING, "Not in voting state"); + _; + } + + modifier keygen { + require(status == Status.KEYGEN, "Not in keygen state"); + _; + } + + modifier fundsTransfer { + require(status == Status.FUNDS_TRANSFER, "Not in funds transfer state"); + _; + } + + function getParties() view public returns (uint16) { + return getParties(epoch); + } + + function getNextParties() view public returns (uint16) { + return getParties(nextEpoch); + } + + function getParties(uint16 _epoch) view public returns (uint16) { + return uint16(states[_epoch].validators.length); + } + + function getThreshold() view public returns (uint16) { + return getThreshold(epoch); + } + + function getNextThreshold() view public returns (uint16) { + return getThreshold(nextEpoch); + } + + function getThreshold(uint16 _epoch) view public returns (uint16) { + return states[_epoch].threshold; + } + + function getStartBlock() view public returns (uint32) { + return getStartBlock(epoch); + } + + function getStartBlock(uint16 _epoch) view public returns (uint32) { + return states[_epoch].startBlock; + } + + function getRangeSize() view public returns (uint16) { + return getRangeSize(epoch); + } + + function getNextRangeSize() view public returns (uint16) { + return getRangeSize(nextEpoch); + } + + function getRangeSize(uint16 _epoch) view public returns (uint16) { + return states[_epoch].rangeSize; + } + + function getNonce() view public returns (uint32) { + return getNonce(epoch); + } + + function getNonce(uint16 _epoch) view public returns (uint32) { + return states[_epoch].nonce; + } + + function getX() view public returns (uint) { + return states[epoch].x; + } + + function getY() view public returns (uint) { + return states[epoch].y; + } + + function getCloseEpoch() view public returns (bool) { + return getCloseEpoch(epoch); + } + + function getNextCloseEpoch() view public returns (bool) { + return getCloseEpoch(nextEpoch); + } + + function getCloseEpoch(uint16 _epoch) view public returns (bool) { + return states[_epoch].closeEpoch; + } + + function getPartyId() view public returns (uint16) { + address[] memory validators = getValidators(); + for (uint i = 0; i < getParties(); i++) { + if (validators[i] == msg.sender) + return uint16(i + 1); + } + return 0; + } + + function getNextPartyId(address a) view public returns (uint16) { + address[] memory validators = getNextValidators(); + for (uint i = 0; i < getNextParties(); i++) { + if (validators[i] == a) + return uint16(i + 1); + } + return 0; + } + + function getValidators() view public returns (address[] memory) { + return getValidators(epoch); + } + + function getNextValidators() view public returns (address[] memory) { + return getValidators(nextEpoch); + } + + function getValidators(uint16 _epoch) view public returns (address[] memory) { + return states[_epoch].validators; + } +} diff --git a/src/deploy/deploy-home/contracts/Bridge.sol b/src/deploy/deploy-home/contracts/Bridge.sol index da3fe37..027d53f 100644 --- a/src/deploy/deploy-home/contracts/Bridge.sol +++ b/src/deploy/deploy-home/contracts/Bridge.sol @@ -1,63 +1,23 @@ pragma solidity ^0.5.0; import './openzeppelin-solidity/contracts/token/ERC20/IERC20.sol'; +import "./MessageHandler.sol"; -contract Bridge { - event ExchangeRequest(uint value, uint nonce); - event NewEpoch(uint indexed oldEpoch, uint indexed newEpoch); - event NewEpochCancelled(uint indexed epoch); - event NewFundsTransfer(uint indexed oldEpoch, uint indexed newEpoch); - event EpochStart(uint indexed epoch, uint x, uint y); +contract Bridge is MessageHandler { + event ExchangeRequest(uint96 value, uint32 nonce); - struct State { - address[] validators; - uint threshold; - uint rangeSize; - uint startBlock; - uint nonce; - uint x; - uint y; - } - - enum Status { - READY, // bridge is in ready to perform operations - VOTING, // voting for changing in next epoch, but still ready - KEYGEN, //keygen, can be cancelled - FUNDS_TRANSFER // funds transfer, cannot be cancelled - } - - enum Vote { - CONFIRM_KEYGEN, - CONFIRM_FUNDS_TRANSFER, - START_VOTING, - ADD_VALIDATOR, - REMOVE_VALIDATOR, - CHANGE_THRESHOLD, - CHANGE_RANGE_SIZE, - START_KEYGEN, - CANCEL_KEYGEN, - TRANSFER - } - - mapping(uint => State) states; - - mapping(bytes32 => uint) public dbTransferCount; - mapping(bytes32 => bool) public dbTransfer; - mapping(bytes32 => uint) public votesCount; - mapping(bytes32 => bool) public votes; - mapping(bytes32 => bool) public usedRange; - - Status public status; + mapping(bytes32 => bool) usedExchangeRanges; - uint public epoch; - uint public nextEpoch; - - uint minTxLimit; - uint maxTxLimit; - - constructor(uint threshold, address[] memory validators, address _tokenContract, uint[2] memory limits, uint rangeSize) public { + constructor( + uint16 threshold, + address[] memory validators, + address _tokenContract, + uint96[2] memory limits, + uint16 rangeSize, + bool closeEpoch + ) public { require(validators.length > 0); - require(threshold < validators.length); + require(threshold <= validators.length); tokenContract = IERC20(_tokenContract); @@ -65,7 +25,17 @@ contract Bridge { status = Status.KEYGEN; nextEpoch = 1; - states[nextEpoch] = State(validators, threshold, rangeSize, 0, uint(-1), 0, 0); + states[nextEpoch] = State({ + validators : validators, + threshold : threshold, + rangeSize : rangeSize, + startBlock : 0, + endBlock : UPPER_BOUND, + nonce : UPPER_BOUND, + x : 0, + y : 0, + closeEpoch : closeEpoch + }); minTxLimit = limits[0]; maxTxLimit = limits[1]; @@ -73,299 +43,16 @@ contract Bridge { emit NewEpoch(0, 1); } - IERC20 public tokenContract; - - modifier ready { - require(status == Status.READY, "Not in ready state"); - _; - } - - modifier readyOrVoting { - require(status == Status.READY || status == Status.VOTING, "Not in ready or voting state"); - _; - } - - modifier voting { - require(status == Status.VOTING, "Not in voting state"); - _; - } - - modifier keygen { - require(status == Status.KEYGEN, "Not in keygen state"); - _; - } - - modifier fundsTransfer { - require(status == Status.FUNDS_TRANSFER, "Not in funds transfer state"); - _; - } - - modifier currentValidator { - require(getPartyId() != 0, "Not a current validator"); - _; - } - - function exchange(uint value) public ready { + function exchange(uint96 value) public ready { require(value >= minTxLimit && value >= 10 ** 10 && value <= maxTxLimit); - uint txRange = (block.number - getStartBlock()) / getRangeSize(); - if (!usedRange[keccak256(abi.encodePacked(txRange, epoch))]) { - usedRange[keccak256(abi.encodePacked(txRange, epoch))] = true; + uint32 txRange = (uint32(block.number) - getStartBlock()) / uint32(getRangeSize()); + if (!usedExchangeRanges[keccak256(abi.encodePacked(txRange, epoch))]) { + usedExchangeRanges[keccak256(abi.encodePacked(txRange, epoch))] = true; states[epoch].nonce++; } tokenContract.transferFrom(msg.sender, address(this), value); emit ExchangeRequest(value, getNonce()); } - - function transfer(bytes32 hash, address to, uint value) public readyOrVoting currentValidator { - if (tryVote(Vote.TRANSFER, hash, to, value)) { - tokenContract.transfer(to, value); - } - } - - function confirmKeygen(uint x, uint y) public keygen { - require(getNextPartyId(msg.sender) != 0, "Not a next validator"); - - if (tryConfirm(Vote.CONFIRM_KEYGEN, x, y)) { - states[nextEpoch].x = x; - states[nextEpoch].y = y; - if (nextEpoch == 1) { - status = Status.READY; - states[nextEpoch].startBlock = block.number; - states[nextEpoch].nonce = uint(-1); - epoch = nextEpoch; - emit EpochStart(epoch, x, y); - } - else { - status = Status.FUNDS_TRANSFER; - emit NewFundsTransfer(epoch, nextEpoch); - } - } - } - - function confirmFundsTransfer() public fundsTransfer currentValidator { - require(epoch > 0, "First epoch does not need funds transfer"); - - if (tryConfirm(Vote.CONFIRM_FUNDS_TRANSFER)) { - status = Status.READY; - states[nextEpoch].startBlock = block.number; - states[nextEpoch].nonce = uint(-1); - epoch = nextEpoch; - emit EpochStart(epoch, getX(), getY()); - } - } - - function getParties() view public returns (uint) { - return getParties(epoch); - } - - function getNextParties() view public returns (uint) { - return getParties(nextEpoch); - } - - function getParties(uint _epoch) view public returns (uint) { - return states[_epoch].validators.length; - } - - function getThreshold() view public returns (uint) { - return getThreshold(epoch); - } - - function getNextThreshold() view public returns (uint) { - return getThreshold(nextEpoch); - } - - function getThreshold(uint _epoch) view public returns (uint) { - return states[_epoch].threshold; - } - - function getStartBlock() view public returns (uint) { - return getStartBlock(epoch); - } - - function getStartBlock(uint _epoch) view public returns (uint) { - return states[_epoch].startBlock; - } - - function getRangeSize() view public returns (uint) { - return getRangeSize(epoch); - } - - function getNextRangeSize() view public returns (uint) { - return getRangeSize(nextEpoch); - } - - function getRangeSize(uint _epoch) view public returns (uint) { - return states[_epoch].rangeSize; - } - - function getNonce() view public returns (uint) { - return getNonce(epoch); - } - - function getNonce(uint _epoch) view public returns (uint) { - return states[_epoch].nonce; - } - - function getX() view public returns (uint) { - return states[epoch].x; - } - - function getY() view public returns (uint) { - return states[epoch].y; - } - - function getPartyId() view public returns (uint) { - address[] memory validators = getValidators(); - for (uint i = 0; i < getParties(); i++) { - if (validators[i] == msg.sender) - return i + 1; - } - return 0; - } - - function getNextPartyId(address a) view public returns (uint) { - address[] memory validators = getNextValidators(); - for (uint i = 0; i < getNextParties(); i++) { - if (validators[i] == a) - return i + 1; - } - return 0; - } - - function getValidators() view public returns (address[] memory) { - return states[epoch].validators; - } - - function getNextValidators() view public returns (address[] memory) { - return states[nextEpoch].validators; - } - - function startVoting() public readyOrVoting currentValidator { - if (tryVote(Vote.START_VOTING)) { - nextEpoch++; - status = Status.VOTING; - states[nextEpoch].threshold = getThreshold(); - states[nextEpoch].validators = getValidators(); - states[nextEpoch].rangeSize = getRangeSize(); - } - } - - function voteAddValidator(address validator) public voting currentValidator { - require(getNextPartyId(validator) == 0, "Already a validator"); - - if (tryVote(Vote.ADD_VALIDATOR, validator)) { - states[nextEpoch].validators.push(validator); - } - } - - function voteRemoveValidator(address validator) public voting currentValidator { - require(getNextPartyId(validator) != 0, "Already not a validator"); - - if (tryVote(Vote.REMOVE_VALIDATOR, validator)) { - _removeValidator(validator); - } - } - - function _removeValidator(address validator) private { - for (uint i = 0; i < getNextParties() - 1; i++) { - if (states[nextEpoch].validators[i] == validator) { - states[nextEpoch].validators[i] = getNextValidators()[getNextParties() - 1]; - break; - } - } - delete states[nextEpoch].validators[getNextParties() - 1]; - states[nextEpoch].validators.length--; - } - - function voteChangeThreshold(uint threshold) public voting currentValidator { - if (tryVote(Vote.CHANGE_THRESHOLD, threshold)) { - states[nextEpoch].threshold = threshold; - } - } - - function voteChangeRangeSize(uint rangeSize) public voting currentValidator { - if (tryVote(Vote.CHANGE_RANGE_SIZE, rangeSize)) { - states[nextEpoch].rangeSize = rangeSize; - } - } - - function voteStartKeygen() public voting currentValidator { - if (tryVote(Vote.START_KEYGEN)) { - status = Status.KEYGEN; - - emit NewEpoch(epoch, nextEpoch); - } - } - - function voteCancelKeygen() public keygen currentValidator { - if (tryVote(Vote.CANCEL_KEYGEN)) { - status = Status.VOTING; - - emit NewEpochCancelled(nextEpoch); - } - } - - function tryVote(Vote voteType) private returns (bool) { - bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch)); - return putVote(vote); - } - - function tryVote(Vote voteType, address addr) private returns (bool) { - bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch, addr)); - return putVote(vote); - } - - function tryVote(Vote voteType, uint num) private returns (bool) { - bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch, num)); - return putVote(vote); - } - - function tryVote(Vote voteType, bytes32 hash, address to, uint value) private returns (bool) { - bytes32 vote = keccak256(abi.encodePacked(voteType, hash, to, value)); - return putVote(vote); - } - - function tryConfirm(Vote voteType) private returns (bool) { - bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch)); - return putConfirm(vote); - } - - function tryConfirm(Vote voteType, uint x, uint y) private returns (bool) { - bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch, x, y)); - return putConfirm(vote); - } - - function putVote(bytes32 vote) private returns (bool) { - bytes32 personalVote = personalizeVote(vote); - require(!votes[personalVote], "Voted already"); - - votes[personalVote] = true; - if (votesCount[vote] == getThreshold()) { - votesCount[vote] = 2 ** 255; - return true; - } else { - votesCount[vote]++; - return false; - } - } - - function putConfirm(bytes32 vote) private returns (bool) { - bytes32 personalVote = personalizeVote(vote); - require(!votes[personalVote], "Confirmed already"); - - votes[personalVote] = true; - if (votesCount[vote] == getNextThreshold()) { - votesCount[vote] = 2 ** 255; - return true; - } else { - votesCount[vote]++; - return false; - } - } - - function personalizeVote(bytes32 vote) private view returns (bytes32) { - return keccak256(abi.encodePacked(vote, msg.sender)); - } } diff --git a/src/deploy/deploy-home/contracts/Government.sol b/src/deploy/deploy-home/contracts/Government.sol new file mode 100644 index 0000000..e7fdaf9 --- /dev/null +++ b/src/deploy/deploy-home/contracts/Government.sol @@ -0,0 +1,127 @@ +pragma solidity ^0.5.0; + +import "./BasicBridge.sol"; + +contract Government is BasicBridge { + enum Action { + CONFIRM_KEYGEN, + CONFIRM_FUNDS_TRANSFER, + CONFIRM_CLOSE_EPOCH, + VOTE_START_VOTING, + VOTE_ADD_VALIDATOR, + VOTE_REMOVE_VALIDATOR, + VOTE_CHANGE_THRESHOLD, + VOTE_CHANGE_RANGE_SIZE, + VOTE_CHANGE_CLOSE_EPOCH, + VOTE_START_KEYGEN, + VOTE_CANCEL_KEYGEN, + TRANSFER + } + + function _confirmKeygen(uint x, uint y) internal keygen { + states[nextEpoch].x = x; + states[nextEpoch].y = y; + states[nextEpoch].nonce = UPPER_BOUND; + if (nextEpoch == 1) { + status = Status.READY; + states[nextEpoch].startBlock = uint32(block.number); + epoch = nextEpoch; + emit EpochStart(epoch, x, y); + } + else { + status = Status.FUNDS_TRANSFER; + emit NewFundsTransfer(epoch, nextEpoch); + } + } + + function _confirmFundsTransfer() internal fundsTransfer { + require(epoch > 0, "First epoch does not need funds transfer"); + + status = Status.READY; + states[nextEpoch].startBlock = uint32(block.number); + epoch = nextEpoch; + emit EpochStart(epoch, getX(), getY()); + } + + function _confirmCloseEpoch() internal closingEpoch { + status = Status.VOTING; + emit EpochEnd(epoch); + } + + function _startVoting() internal ready { + states[epoch].endBlock = uint32(block.number); + nextEpoch++; + states[nextEpoch].threshold = getThreshold(); + states[nextEpoch].validators = getValidators(); + states[nextEpoch].rangeSize = getRangeSize(); + states[nextEpoch].closeEpoch = getCloseEpoch(); + + if (getCloseEpoch()) { + status = Status.CLOSING_EPOCH; + emit ForceSign(); + emit EpochClose(epoch); + } else { + status = Status.VOTING; + emit ForceSign(); + emit EpochEnd(epoch); + } + } + + function _addValidator(address validator) internal voting { + require(getNextPartyId(validator) == 0, "Already a validator"); + + states[nextEpoch].validators.push(validator); + } + + function _removeValidator(address validator) internal voting { + require(getNextPartyId(validator) != 0, "Already not a validator"); + + uint16 lastPartyId = getNextParties() - 1; + for (uint i = 0; i < lastPartyId; i++) { + if (states[nextEpoch].validators[i] == validator) { + states[nextEpoch].validators[i] = getNextValidators()[lastPartyId]; + break; + } + } + delete states[nextEpoch].validators[lastPartyId]; + states[nextEpoch].validators.length--; + } + + function _changeThreshold(uint16 threshold) internal voting { + require(threshold > 0, "Invalid threshold value"); + + states[nextEpoch].threshold = threshold; + } + + function _changeRangeSize(uint16 rangeSize) internal voting { + require(rangeSize > 0, "Invalid range size"); + + states[nextEpoch].rangeSize = rangeSize; + } + + function _changeCloseEpoch(bool closeEpoch) internal voting { + states[nextEpoch].closeEpoch = closeEpoch; + } + + function _startKeygen() internal voting { + require(getNextThreshold() <= getNextParties(), "Invalid threshold number"); + + status = Status.KEYGEN; + + emit NewEpoch(epoch, nextEpoch); + } + + function _cancelKeygen() internal keygen { + status = Status.VOTING; + + emit NewEpochCancelled(nextEpoch); + } + + function _transfer(address to, uint96 value) internal { + if (tokenContract.balanceOf(address(this)) >= value) { + tokenContract.transfer(to, value); + } else { + tokenContract.approve(to, value); + } + } +} diff --git a/src/deploy/deploy-home/contracts/MessageDecoder.sol b/src/deploy/deploy-home/contracts/MessageDecoder.sol new file mode 100644 index 0000000..56e94b9 --- /dev/null +++ b/src/deploy/deploy-home/contracts/MessageDecoder.sol @@ -0,0 +1,39 @@ +pragma solidity ^0.5.0; + + +contract MessageDecoder { + // [0] - action type + // [1,2] - epoch + // [3..] - payload + function _decodeUint16(bytes memory message) pure internal returns (uint16 a) { + assembly { + a := mload(add(message, 5)) + } + } + + function _decodeBoolean(bytes memory message) pure internal returns (bool a) { + assembly { + a := and(mload(add(message, 4)), 1) + } + } + + function _decodeAddress(bytes memory message) pure internal returns (address a) { + assembly { + a := mload(add(message, 23)) + } + } + + function _decodeKeygen(bytes memory message) pure internal returns (uint a, uint b) { + assembly { + a := mload(add(message, 35)) + b := mload(add(message, 67)) + } + } + + function _decodeTransfer(bytes memory message) pure internal returns (address a, uint96 b) { + assembly { + a := mload(add(message, 55)) + b := mload(add(message, 67)) + } + } +} diff --git a/src/deploy/deploy-home/contracts/MessageHandler.sol b/src/deploy/deploy-home/contracts/MessageHandler.sol new file mode 100644 index 0000000..0c691e6 --- /dev/null +++ b/src/deploy/deploy-home/contracts/MessageHandler.sol @@ -0,0 +1,131 @@ +pragma solidity ^0.5.0; + +import "./Government.sol"; +import "./MessageDecoder.sol"; + +contract MessageHandler is Government, MessageDecoder { + uint constant SIGNATURE_SIZE = 65; + + mapping(bytes32 => bool) public handledMessages; + + function applyMessage(bytes memory message, bytes memory signatures) public { + (bytes32 msgHash, uint16 msgEpoch) = checkSignedMessage(message, signatures); + handledMessages[msgHash] = true; + + Action msgAction = Action(uint8(message[0])); + + if (msgAction == Action.CONFIRM_KEYGEN || msgAction == Action.VOTE_CANCEL_KEYGEN) { + require(msgEpoch == nextEpoch, "Incorrect message epoch"); + } else if (msgAction == Action.TRANSFER) { + require(msgEpoch <= epoch, "Incorrect message epoch"); + } else { + require(msgEpoch == epoch, "Incorrect message epoch"); + } + + if (msgAction == Action.CONFIRM_KEYGEN) { + // [3,34] - x, [35,66] - y + require(message.length == 67, "Incorrect message length"); + (uint x, uint y) = _decodeKeygen(message); + _confirmKeygen(x, y); + } else if (msgAction == Action.CONFIRM_FUNDS_TRANSFER) { + require(message.length == 3, "Incorrect message length"); + _confirmFundsTransfer(); + } else if (msgAction == Action.CONFIRM_CLOSE_EPOCH) { + require(message.length == 3, "Incorrect message length"); + _confirmCloseEpoch(); + } else if (msgAction == Action.VOTE_START_VOTING) { + require(message.length == 3, "Incorrect message length"); + _startVoting(); + } else if (msgAction == Action.VOTE_ADD_VALIDATOR) { + // [3,22] - address, [23,31] - extra data + require(message.length == 32, "Incorrect message length"); + address validator = _decodeAddress(message); + _addValidator(validator); + } else if (msgAction == Action.VOTE_REMOVE_VALIDATOR) { + // [3,22] - address, [23,31] - extra data + require(message.length == 32, "Incorrect message length"); + address validator = _decodeAddress(message); + _removeValidator(validator); + } else if (msgAction == Action.VOTE_CHANGE_THRESHOLD) { + // [3,4] - threshold, [5,31] - extra data + require(message.length == 32, "Incorrect message length"); + uint16 threshold = _decodeUint16(message); + _changeThreshold(threshold); + } else if (msgAction == Action.VOTE_CHANGE_RANGE_SIZE) { + // [3,4] - rangeSize, [5,31] - extra data + require(message.length == 32, "Incorrect message length"); + uint16 rangeSize = _decodeUint16(message); + _changeRangeSize(rangeSize); + } else if (msgAction == Action.VOTE_CHANGE_CLOSE_EPOCH) { + // [3] - closeEpoch, [4,31] - extra data + require(message.length == 32, "Incorrect message length"); + bool closeEpoch = _decodeBoolean(message); + _changeCloseEpoch(closeEpoch); + } else if (msgAction == Action.VOTE_START_KEYGEN) { + require(message.length == 3, "Incorrect message length"); + _startKeygen(); + } else if (msgAction == Action.VOTE_CANCEL_KEYGEN) { + require(message.length == 3, "Incorrect message length"); + _cancelKeygen(); + } else if (msgAction == Action.TRANSFER) { + // [3,34] - txHash, [35,54] - address, [55,66] - value + require(message.length == 67, "Incorrect message length"); + (address to, uint96 value) = _decodeTransfer(message); + _transfer(to, value); + } else { + revert("Unknown message action"); + } + } + + function checkSignedMessage(bytes memory message, bytes memory signatures) view public returns (bytes32, uint16) { + require(signatures.length % SIGNATURE_SIZE == 0, "Incorrect signatures length"); + + bytes32 msgHash; + if (message.length == 3) { + msgHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n3", message)); + } else if (message.length == 32) { + msgHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", message)); + } else if (message.length == 67) { + msgHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n67", message)); + } else { + revert("Incorrect message length"); + } + require(!handledMessages[msgHash], "Tx was already handled"); + + uint16 msgEpoch; + assembly { + msgEpoch := mload(add(message, 3)) + } + require(msgEpoch <= nextEpoch, "Invalid epoch number"); + + uint signaturesNum = signatures.length / SIGNATURE_SIZE; + require(signaturesNum >= getThreshold(msgEpoch), "Not enough signatures"); + + address[] memory possibleValidators = getValidators(msgEpoch); + + bytes32 r; + bytes32 s; + uint8 v; + + for (uint i = 0; i < signaturesNum; i++) { + uint offset = i * SIGNATURE_SIZE; + + assembly { + r := mload(add(add(signatures, 32), offset)) + s := mload(add(add(signatures, 64), offset)) + v := byte(0, mload(add(add(signatures, 96), offset))) + } + + address signer = ecrecover(msgHash, v, r, s); + uint j; + for (j = 0; j < possibleValidators.length; j++) { + if (possibleValidators[j] == signer) { + delete possibleValidators[j]; + break; + } + } + require(j != possibleValidators.length, "Not a validator signature"); + } + return (msgHash, msgEpoch); + } +} diff --git a/src/deploy/deploy-home/migrations/1_deployment.js b/src/deploy/deploy-home/migrations/1_deployment.js index 5bd4359..05984da 100644 --- a/src/deploy/deploy-home/migrations/1_deployment.js +++ b/src/deploy/deploy-home/migrations/1_deployment.js @@ -1,20 +1,21 @@ const Bridge = artifacts.require('Bridge') const addresses = Object.entries(process.env) - .filter(([ key ]) => key.startsWith('VALIDATOR_ADDRESS')) - .map(([ , value ]) => value) + .filter(([key]) => key.startsWith('VALIDATOR_ADDRESS')) + .map(([, value]) => value) const { - THRESHOLD, HOME_TOKEN_ADDRESS, MIN_TX_LIMIT, MAX_TX_LIMIT, BLOCKS_RANGE_SIZE + THRESHOLD, HOME_TOKEN_ADDRESS, MIN_TX_LIMIT, MAX_TX_LIMIT, BLOCKS_RANGE_SIZE, CLOSE_EPOCH_FLAG } = process.env -module.exports = deployer => { +module.exports = (deployer) => { deployer.deploy( Bridge, THRESHOLD, addresses, HOME_TOKEN_ADDRESS, - [ MIN_TX_LIMIT, MAX_TX_LIMIT ], - BLOCKS_RANGE_SIZE + [MIN_TX_LIMIT, MAX_TX_LIMIT], + BLOCKS_RANGE_SIZE, + CLOSE_EPOCH_FLAG === 'true' ) } diff --git a/src/deploy/deploy-side/.solhint.json b/src/deploy/deploy-side/.solhint.json new file mode 100644 index 0000000..d7c3de9 --- /dev/null +++ b/src/deploy/deploy-side/.solhint.json @@ -0,0 +1,3 @@ +{ + "extends": "solhint:default" +} diff --git a/src/deploy/deploy-side/Dockerfile b/src/deploy/deploy-side/Dockerfile index c94da4c..fce9bf2 100644 --- a/src/deploy/deploy-side/Dockerfile +++ b/src/deploy/deploy-side/Dockerfile @@ -9,8 +9,6 @@ RUN npm install truffle-hdwallet-provider RUN truffle obtain --solc 0.5.9 -COPY truffle-config-build.js /build/truffle-config.js - RUN mkdir temp \ && cd temp \ && truffle init \ @@ -19,6 +17,7 @@ RUN mkdir temp \ && cd .. \ && rm -rf temp +COPY truffle-config-build.js /build/truffle-config.js COPY contracts /build/contracts RUN truffle compile diff --git a/src/deploy/deploy-side/contracts/KeyValueStorage.sol b/src/deploy/deploy-side/contracts/KeyValueStorage.sol new file mode 100644 index 0000000..54cff21 --- /dev/null +++ b/src/deploy/deploy-side/contracts/KeyValueStorage.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.5.0; + +contract KeyValueStorage { + mapping(bytes32 => bytes) public db; + + function setData(bytes32 id, bytes32 key, bytes memory data) public { + db[encodeKey(msg.sender, id, key)] = data; + } + + function getData(address from, bytes32 id, bytes32 key) view public returns (bytes memory) { + return db[encodeKey(from, id, key)]; + } + + function encodeKey(address sender, bytes32 id, bytes32 key) private pure returns (bytes32 hash) { + return keccak256(abi.encodePacked(sender, id, key)); + } +} diff --git a/src/deploy/deploy-side/contracts/SharedDB.sol b/src/deploy/deploy-side/contracts/SharedDB.sol index 16bda1b..9bcfd5c 100644 --- a/src/deploy/deploy-side/contracts/SharedDB.sol +++ b/src/deploy/deploy-side/contracts/SharedDB.sol @@ -1,42 +1,7 @@ pragma solidity ^0.5.0; -contract SharedDB { - mapping(bytes32 => bytes) public db; - mapping(bytes32 => uint) public signupsCount; - mapping(bytes32 => uint) public dbSignups; +import "./KeyValueStorage.sol"; +import "./SignedMessageStorage.sol"; +import "./SignupStorage.sol"; - function signupSign(bytes32 hash) public { - require(dbSignups[keccak256(abi.encodePacked(msg.sender, hash))] == 0, "Already signuped"); - - dbSignups[keccak256(abi.encodePacked(msg.sender, hash))] = ++signupsCount[hash]; - } - - function getSignupNumber(bytes32 hash, address[] memory validators, address validator) view public returns (uint) { - if (dbSignups[keccak256(abi.encodePacked(validator, hash))] == 0) - return 0; - uint id = 1; - for (uint i = 0; i < validators.length; i++) { - uint vid = dbSignups[keccak256(abi.encodePacked(validators[i], hash))]; - if (vid > 0 && vid < dbSignups[keccak256(abi.encodePacked(validator, hash))]) - id++; - } - return id; - } - - function getSignupAddress(bytes32 hash, address[] memory validators, uint signupNumber) view public returns (address) { - for (uint i = 0; i < validators.length; i++) { - if (getSignupNumber(hash, validators, validators[i]) == signupNumber) { - return validators[i]; - } - } - return address(0); - } - - function setData(bytes32 hash, bytes32 key, bytes memory data) public { - db[keccak256(abi.encodePacked(msg.sender, hash, key))] = data; - } - - function getData(address from, bytes32 hash, bytes32 key) view public returns (bytes memory) { - return db[keccak256(abi.encodePacked(from, hash, key))]; - } -} +contract SharedDB is KeyValueStorage, SignedMessageStorage, SignupStorage {} diff --git a/src/deploy/deploy-side/contracts/SignedMessageStorage.sol b/src/deploy/deploy-side/contracts/SignedMessageStorage.sol new file mode 100644 index 0000000..a24dfd4 --- /dev/null +++ b/src/deploy/deploy-side/contracts/SignedMessageStorage.sol @@ -0,0 +1,56 @@ +pragma solidity ^0.5.0; + +contract SignedMessageStorage { + event NewMessage(bytes32 msgHash); + + struct SignedMessage { + bytes message; + mapping(address => bytes) signatures; + } + + mapping(bytes32 => SignedMessage) public signedMessages; + + function addSignature(bytes memory message, bytes memory rsv) public { + require(message.length > 0, "Incorrect message length"); + require(rsv.length == 65, "Incorrect signature length"); + + bytes32 msgHash; + if (message.length == 3) { + msgHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n3", message)); + } else if (message.length == 32) { + msgHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", message)); + } else if (message.length == 67) { + msgHash = keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n67", message)); + } else { + revert("Incorrect message length"); + } + + bytes32 r; + bytes32 s; + uint8 v; + + assembly { + r := mload(add(rsv, 32)) + s := mload(add(rsv, 64)) + v := byte(0, mload(add(rsv, 96))) + } + + require(ecrecover(msgHash, v, r, s) == msg.sender); + + if (signedMessages[msgHash].message.length == 0) { + signedMessages[msgHash].message = message; + + emit NewMessage(msgHash); + } + signedMessages[msgHash].signatures[msg.sender] = rsv; + } + + function getSignatures(bytes32 msgHash, address[] memory validators) public view returns (bytes memory) { + bytes memory result; + for (uint i = 0; i < validators.length; i++) { + result = abi.encodePacked(result, signedMessages[msgHash].signatures[validators[i]]); + } + return result; + } + +} diff --git a/src/deploy/deploy-side/contracts/SignupStorage.sol b/src/deploy/deploy-side/contracts/SignupStorage.sol new file mode 100644 index 0000000..69d1477 --- /dev/null +++ b/src/deploy/deploy-side/contracts/SignupStorage.sol @@ -0,0 +1,52 @@ +pragma solidity ^0.5.0; + +contract SignupStorage { + struct SignupsCounter { + uint16 count; + mapping(address => uint16) id; + } + mapping(bytes32 => SignupsCounter) public signups; + + function signup(bytes32 hash) public { + require(signups[hash].id[msg.sender] == 0, "Already signuped"); + + signups[hash].id[msg.sender] = ++signups[hash].count; + } + + function isSignuped(bytes32 hash) public view returns (bool) { + return isSignuped(hash, msg.sender); + } + + function isSignuped(bytes32 hash, address validator) public view returns (bool) { + return signups[hash].id[validator] > 0; + } + + function getSignupNumber( + bytes32 hash, + address[] memory validators, + address validator + ) view public returns (uint16) { + if (signups[hash].id[validator] == 0) + return 0; + uint16 id = 1; + for (uint i = 0; i < validators.length; i++) { + uint16 vid = signups[hash].id[validators[i]]; + if (vid > 0 && vid < signups[hash].id[validator]) + id++; + } + return id; + } + + function getSignupAddress( + bytes32 hash, + address[] memory validators, + uint16 signupNumber + ) view public returns (address) { + for (uint i = 0; i < validators.length; i++) { + if (getSignupNumber(hash, validators, validators[i]) == signupNumber) { + return validators[i]; + } + } + return address(0); + } +} diff --git a/src/deploy/deploy-side/migrations/1_deployment.js b/src/deploy/deploy-side/migrations/1_deployment.js index bad14cd..7b2ff31 100644 --- a/src/deploy/deploy-side/migrations/1_deployment.js +++ b/src/deploy/deploy-side/migrations/1_deployment.js @@ -1,5 +1,5 @@ const SharedDB = artifacts.require('SharedDB') -module.exports = deployer => { +module.exports = (deployer) => { deployer.deploy(SharedDB) } diff --git a/src/deploy/deploy-test/Dockerfile b/src/deploy/deploy-test/Dockerfile index cbdf66a..a769574 100644 --- a/src/deploy/deploy-test/Dockerfile +++ b/src/deploy/deploy-test/Dockerfile @@ -9,8 +9,6 @@ RUN npm install truffle-hdwallet-provider RUN truffle obtain --solc 0.5.9 -COPY truffle-config-build.js /build/truffle-config.js - RUN mkdir temp \ && cd temp \ && truffle init \ @@ -19,6 +17,7 @@ RUN mkdir temp \ && cd .. \ && rm -rf temp +COPY truffle-config-build.js /build/truffle-config.js COPY contracts/openzeppelin-solidity /build/contracts/openzeppelin-solidity RUN truffle compile diff --git a/src/ethereum-testnet/.eslintrc b/src/ethereum-testnet/.eslintrc new file mode 100644 index 0000000..3703c0a --- /dev/null +++ b/src/ethereum-testnet/.eslintrc @@ -0,0 +1,8 @@ +{ + "extends": [ + "../../.eslintrc" + ], + "rules": { + "no-console": 0 + } +} diff --git a/src/ethereum-testnet/docker-compose.yml b/src/ethereum-testnet/docker-compose.yml new file mode 100644 index 0000000..cb1af7d --- /dev/null +++ b/src/ethereum-testnet/docker-compose.yml @@ -0,0 +1,37 @@ +version: '3.0' +services: + ganache_side: + image: trufflesuite/ganache-cli:latest + command: ["-m", "shrug dwarf easily blade trigger lucky reopen cage lake scatter desk boat", "-i", "33", "--db", "/app/db", "-b", "${BLOCK_TIME}", "--noVMErrorsOnRPCResponse"] + networks: + - ethereum_side_rpc_net + ports: + - '7545:8545' + volumes: + - 'ganache_side_data:/app/db' + ganache_home: + image: trufflesuite/ganache-cli:latest + command: ["-m", "shrug dwarf easily blade trigger lucky reopen cage lake scatter desk boat", "-i", "44", "--db", "/app/db", "-b", "${BLOCK_TIME}", "--noVMErrorsOnRPCResponse"] + networks: + - ethereum_home_rpc_net + ports: + - '8545:8545' + volumes: + - 'ganache_home_data:/app/db' + side-oracle: + build: side-oracle + image: side-oracle + env_file: side-oracle/.env.development + networks: + - ethereum_side_rpc_net + - ethereum_home_rpc_net +networks: + ethereum_side_rpc_net: + external: true + ethereum_home_rpc_net: + external: true +volumes: + ganache_side_data: + external: true + ganache_home_data: + external: true diff --git a/src/ethereum-testnet/side-oracle/.env.development b/src/ethereum-testnet/side-oracle/.env.development new file mode 100644 index 0000000..56f1de7 --- /dev/null +++ b/src/ethereum-testnet/side-oracle/.env.development @@ -0,0 +1,9 @@ +HOME_RPC_URL=http://ganache_home:8545 +HOME_BRIDGE_ADDRESS=0x44c158FE850821ae69DaF37AADF5c539e9d0025B + +HOME_PRIVATE_KEY=fd5c416a8d497a343d4ee1ac7a8f407450ae115b0001cdd6f2dad715baa3bc25 + +SIDE_RPC_URL=http://ganache_side:8545 +SIDE_SHARED_DB_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc +SIDE_MAX_FETCH_RANGE_SIZE=100 + diff --git a/src/ethereum-testnet/side-oracle/Dockerfile b/src/ethereum-testnet/side-oracle/Dockerfile new file mode 100644 index 0000000..ad6c12d --- /dev/null +++ b/src/ethereum-testnet/side-oracle/Dockerfile @@ -0,0 +1,14 @@ +FROM node:10.16.0-alpine + +WORKDIR /side-oracle + +RUN apk update && \ + apk add libssl1.1 libressl-dev curl + +COPY ./package.json /side-oracle/ + +RUN npm install + +COPY ./index.js ./ + +ENTRYPOINT ["node", "index.js"] diff --git a/src/ethereum-testnet/side-oracle/index.js b/src/ethereum-testnet/side-oracle/index.js new file mode 100644 index 0000000..d90ecfc --- /dev/null +++ b/src/ethereum-testnet/side-oracle/index.js @@ -0,0 +1,117 @@ +const ethers = require('ethers') + +const { + HOME_PRIVATE_KEY, HOME_RPC_URL, HOME_BRIDGE_ADDRESS, SIDE_RPC_URL, SIDE_SHARED_DB_ADDRESS +} = process.env +const SIDE_MAX_FETCH_RANGE_SIZE = parseInt(process.env.SIDE_MAX_FETCH_RANGE_SIZE, 10) + +const bridgeAbi = [ + 'function applyMessage(bytes message, bytes signatures)', + 'function getThreshold(uint16 epoch) view returns (uint16)', + 'function getValidators(uint16 epoch) view returns (address[])' +] +const sharedDbAbi = [ + 'event NewMessage(bytes32 msgHash)', + 'function signedMessages(bytes32 hash) view returns (bytes)', + 'function getSignatures(bytes32 msgHash, address[] validators) view returns (bytes)' +] + +let homeProvider +let sideProvider +let bridge +let sharedDb +let homeWallet +let nonce +let blockNumber = 0 + +async function delay(ms) { + await new Promise((res) => setTimeout(res, ms)) +} + +async function handleNewMessage(event) { + const { msgHash } = event.values + const message = await sharedDb.signedMessages(msgHash) + const epoch = parseInt(message.slice(4, 8), 16) + const [threshold, validators] = await Promise.all([ + bridge.getThreshold(epoch), + bridge.getValidators(epoch) + ]) + + while (true) { + const signatures = await sharedDb.getSignatures(msgHash, validators) + if (signatures.length === 2) { + console.log('Skipping event') + break + } + if ((signatures.length - 2) / 130 >= threshold) { + console.log('Sending applyMessage request') + const tx = await bridge.applyMessage(message, signatures, { + gasLimit: 1000000, + nonce + }) + const receipt = await tx.wait() + console.log(`Used gas: ${receipt.gasUsed.toNumber()}`) + nonce += 1 + break + } + } +} + +async function initialize() { + while (true) { + try { + sideProvider = new ethers.providers.JsonRpcProvider(SIDE_RPC_URL) + homeProvider = new ethers.providers.JsonRpcProvider(HOME_RPC_URL) + + homeWallet = new ethers.Wallet(HOME_PRIVATE_KEY, homeProvider) + bridge = new ethers.Contract(HOME_BRIDGE_ADDRESS, bridgeAbi, homeWallet) + sharedDb = new ethers.Contract(SIDE_SHARED_DB_ADDRESS, sharedDbAbi, sideProvider) + + nonce = await homeWallet.getTransactionCount() + break + } catch (e) { + console.log('Cannot create providers') + await delay(1000) + } + } +} + +async function loop() { + const latestBlockNumber = await sideProvider.getBlockNumber() + if (latestBlockNumber < blockNumber) { + console.log(`No block after ${latestBlockNumber}`) + return + } + + const endBlock = Math.min(latestBlockNumber, blockNumber + SIDE_MAX_FETCH_RANGE_SIZE - 1) + + console.log(`Watching events in blocks #${blockNumber}-${endBlock}`) + + const bridgeEvents = (await sideProvider.getLogs({ + address: SIDE_SHARED_DB_ADDRESS, + fromBlock: blockNumber, + toBlock: endBlock, + topics: [ + sharedDb.interface.events.NewMessage.topic + ] + })) + + for (let i = 0; i < bridgeEvents.length; i += 1) { + const event = sharedDb.interface.parseLog(bridgeEvents[i]) + console.log('Consumed event', event) + await handleNewMessage(event) + } + + blockNumber = endBlock + 1 +} + +async function main() { + await initialize() + + while (true) { + await delay(2000) + await loop() + } +} + +main() diff --git a/src/ethereum-testnet/side-oracle/package.json b/src/ethereum-testnet/side-oracle/package.json new file mode 100644 index 0000000..f09b986 --- /dev/null +++ b/src/ethereum-testnet/side-oracle/package.json @@ -0,0 +1,10 @@ +{ + "name": "side-oracle", + "version": "0.0.1", + "dependencies": { + "ethers": "4.0.33" + }, + "engines": { + "node": ">=10.6.0" + } +} diff --git a/src/oracle/bncWatcher/Dockerfile b/src/oracle/bncWatcher/Dockerfile index be3f7c2..af9ce69 100644 --- a/src/oracle/bncWatcher/Dockerfile +++ b/src/oracle/bncWatcher/Dockerfile @@ -9,6 +9,6 @@ COPY ./bncWatcher/package.json /watcher/ RUN npm install -COPY ./bncWatcher/bncWatcher.js ./shared/db.js ./shared/logger.js ./shared/crypto.js /watcher/ +COPY ./bncWatcher/bncWatcher.js ./shared/db.js ./shared/logger.js ./shared/crypto.js ./shared/amqp.js ./shared/wait.js /watcher/ ENTRYPOINT ["node", "bncWatcher.js"] diff --git a/src/oracle/bncWatcher/bncWatcher.js b/src/oracle/bncWatcher/bncWatcher.js index 29fb3cc..c66ba36 100644 --- a/src/oracle/bncWatcher/bncWatcher.js +++ b/src/oracle/bncWatcher/bncWatcher.js @@ -6,90 +6,175 @@ const { computeAddress } = require('ethers').utils const logger = require('./logger') const redis = require('./db') const { publicKeyToAddress } = require('./crypto') +const { delay, retry } = require('./wait') +const { connectRabbit, assertQueue } = require('./amqp') -const { FOREIGN_URL, PROXY_URL, FOREIGN_ASSET } = process.env +const { + FOREIGN_URL, PROXY_URL, FOREIGN_ASSET, RABBITMQ_URL +} = process.env + +const FOREIGN_FETCH_INTERVAL = parseInt(process.env.FOREIGN_FETCH_INTERVAL, 10) +const FOREIGN_FETCH_BLOCK_TIME_OFFSET = parseInt(process.env.FOREIGN_FETCH_BLOCK_TIME_OFFSET, 10) +const FOREIGN_FETCH_MAX_TIME_INTERVAL = parseInt(process.env.FOREIGN_FETCH_MAX_TIME_INTERVAL, 10) const foreignHttpClient = axios.create({ baseURL: FOREIGN_URL }) const proxyHttpClient = axios.create({ baseURL: PROXY_URL }) -async function initialize () { - if (await redis.get('foreignTime') === null) { - logger.info('Set default foreign time') - await redis.set('foreignTime', Date.now() - 2 * 30 * 24 * 60 * 60 * 1000) +let channel +let epochTimeIntervalsQueue + +function getForeignAddress(epoch) { + const keysFile = `/keys/keys${epoch}.store` + try { + const publicKey = JSON.parse(fs.readFileSync(keysFile))[5] + return publicKeyToAddress(publicKey) + } catch (e) { + return null } } -async function main () { - const newTransactions = await fetchNewTransactions() - if (newTransactions === null || newTransactions.length === 0) { +async function getTx(hash) { + const response = await retry(() => foreignHttpClient.get( + `/api/v1/tx/${hash}`, + { + params: { + format: 'json' + } + } + )) + return response.data.tx.value +} - await new Promise(r => setTimeout(r, 5000)) - return +async function getBlockTime() { + const response = await retry(() => foreignHttpClient.get('/api/v1/time')) + return Date.parse(response.data.block_time) - FOREIGN_FETCH_BLOCK_TIME_OFFSET +} + +async function fetchNewTransactions(address, startTime, endTime) { + logger.debug('Fetching new transactions') + const params = { + address, + side: 'RECEIVE', + txAsset: FOREIGN_ASSET, + txType: 'TRANSFER', + startTime, + endTime } - if (newTransactions.length) - logger.info(`Found ${newTransactions.length} new transactions`) - else - logger.debug(`Found 0 new transactions`) + logger.trace('Transactions fetch params %o', params) + return ( + await retry(() => foreignHttpClient.get('/api/v1/transactions', { params })) + ).data.tx +} - for (const tx of newTransactions.reverse()) { - if (tx.memo !== 'funding') { - const publicKeyEncoded = (await getTx(tx.txHash)).signatures[0].pub_key.value - await proxyHttpClient - .post('/transfer', { - to: computeAddress(Buffer.from(publicKeyEncoded, 'base64')), - value: new BN(tx.value).multipliedBy(10 ** 18).integerValue(), - hash: `0x${tx.txHash}` - }) +async function fetchTimeIntervalsQueue() { + let epoch = null + let startTime = null + let endTime = null + const lastBncBlockTime = await getBlockTime() + logger.trace(`Binance last block timestamp ${lastBncBlockTime}`) + while (true) { + const msg = await epochTimeIntervalsQueue.get() + if (msg === false) { + break + } + const data = JSON.parse(msg.content) + let accept = false + logger.trace('Consumed time interval event %o', data) + if (epoch !== null && epoch !== data.epoch) { + logger.warn('Two consequently events have different epochs, should not be like this') + channel.nack(msg, false, true) + break + } + if (data.startTime) { + logger.trace('Set foreign time', data) + await redis.set(`foreignTime${data.epoch}`, data.startTime) + channel.ack(msg) + break + } + if (epoch === null) { + accept = true + epoch = data.epoch + startTime = await redis.get(`foreignTime${epoch}`) + logger.trace(`Retrieved epoch ${epoch} and start time ${startTime} from redis`) + if (startTime === null) { + logger.warn(`Empty foreign time for epoch ${epoch}`) + } + } + if ((data.prolongedTime - startTime < FOREIGN_FETCH_MAX_TIME_INTERVAL || accept) + && data.prolongedTime < lastBncBlockTime) { + endTime = data.prolongedTime + channel.ack(msg) + } else { + logger.trace('Requeuing current queue message') + channel.nack(msg, false, true) + break } - await redis.set('foreignTime', Date.parse(tx.timeStamp)) + } + return { + epoch, + startTime, + endTime } } -function getTx(hash) { - return foreignHttpClient - .get(`/api/v1/tx/${hash}`, { - params: { - format: 'json' - } - }) - .then(res => res.data.tx.value) - .catch(() => getTx(hash)) +async function initialize() { + channel = await connectRabbit(RABBITMQ_URL) + logger.info('Connecting to epoch time intervals queue') + epochTimeIntervalsQueue = await assertQueue(channel, 'epochTimeIntervalsQueue') } -async function fetchNewTransactions () { - logger.debug('Fetching new transactions') - const startTime = parseInt(await redis.get('foreignTime')) + 1 - const address = getLastForeignAddress() - if (address === null) - return null - logger.debug('Sending api transactions request') - return foreignHttpClient - .get('/api/v1/transactions', { - params: { - address, - side: 'RECEIVE', - txAsset: FOREIGN_ASSET, - txType: 'TRANSFER', - startTime, - endTime: startTime + 3 * 30 * 24 * 60 * 60 * 1000, - } - }) - .then(res => res.data.tx) - .catch(() => fetchNewTransactions()) -} +async function loop() { + const { epoch, startTime, endTime } = await fetchTimeIntervalsQueue() -function getLastForeignAddress () { - const epoch = Math.max(0, ...fs.readdirSync('/keys').map(x => parseInt(x.split('.')[0].substr(4)))) - if (epoch === 0) - return null - const keysFile = `/keys/keys${epoch}.store` - const publicKey = JSON.parse(fs.readFileSync(keysFile))[5] - return publicKeyToAddress(publicKey) + if (!startTime || !endTime) { + logger.debug('Nothing to fetch') + await delay(FOREIGN_FETCH_INTERVAL) + return + } + + const address = getForeignAddress(epoch) + + if (!address) { + logger.debug('Validator is not included in current epoch') + await redis.set(`foreignTime${epoch}`, endTime) + await delay(FOREIGN_FETCH_INTERVAL) + return + } + + const transactions = await fetchNewTransactions(address, startTime, endTime) + + if (transactions.length === 0) { + logger.debug('Found 0 new transactions') + await redis.set(`foreignTime${epoch}`, endTime) + await delay(FOREIGN_FETCH_INTERVAL) + return + } + + logger.info(`Found ${transactions.length} new transactions`) + logger.trace('%o', transactions) + + for (let i = transactions.length - 1; i >= 0; i -= 1) { + const tx = transactions[i] + if (tx.memo === '') { + const publicKeyEncoded = (await getTx(tx.txHash)).signatures[0].pub_key.value + await proxyHttpClient.post('/transfer', { + to: computeAddress(Buffer.from(publicKeyEncoded, 'base64')), + value: new BN(tx.value).multipliedBy(10 ** 18).toString(16), + hash: tx.txHash, + epoch + }) + } + } + await redis.set(`foreignTime${epoch}`, endTime) } -initialize().then(async () => { +async function main() { + await initialize() + while (true) { - await main() + await loop() } -}) +} + +main() diff --git a/src/oracle/bncWatcher/package.json b/src/oracle/bncWatcher/package.json index 445edda..08a6559 100644 --- a/src/oracle/bncWatcher/package.json +++ b/src/oracle/bncWatcher/package.json @@ -2,6 +2,7 @@ "name": "watcher", "version": "0.0.1", "dependencies": { + "amqplib": "0.5.3", "ioredis": "4.10.0", "axios": "0.19.0", "bech32": "1.1.3", @@ -9,6 +10,9 @@ "ethers": "4.0.33", "pino": "5.13.4", "pino-pretty": "3.2.1" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/oracle/docker-compose-test.yml b/src/oracle/docker-compose-test.yml index afa2c00..6daadfa 100644 --- a/src/oracle/docker-compose-test.yml +++ b/src/oracle/docker-compose-test.yml @@ -9,26 +9,23 @@ services: - HOME_RPC_URL - HOME_BRIDGE_ADDRESS - HOME_TOKEN_ADDRESS - - HOME_CHAIN_ID - SIDE_RPC_URL - SIDE_SHARED_DB_ADDRESS - - SIDE_CHAIN_ID - VALIDATOR_PRIVATE_KEY - FOREIGN_URL - FOREIGN_ASSET - LOG_LEVEL - - "GAS_LIMIT_FACTOR=3" - - "MAX_GAS_LIMIT=6000000" - volumes: - - '../deploy/deploy-test/build/contracts/IERC20.json:/proxy/contracts_data/IERC20.json' - - '../deploy/deploy-home/build/contracts/Bridge.json:/proxy/contracts_data/Bridge.json' - - '../deploy/deploy-side/build/contracts/SharedDB.json:/proxy/contracts_data/SharedDB.json' + - 'GAS_LIMIT_FACTOR=3' + - 'MAX_GAS_LIMIT=6000000' ports: - '${VOTES_PROXY_PORT}:8002' networks: - - test_network - - blockchain_home - - blockchain_side + test_network: + aliases: + - local_proxy + ethereum_home_rpc_net: + ethereum_side_rpc_net: + binance_net: keygen: image: keygen-client build: @@ -36,10 +33,14 @@ services: context: . environment: - 'RABBITMQ_URL=amqp://rabbitmq:5672' - - 'PROXY_URL=http://proxy:8001' + - 'PROXY_URL=http://local_proxy:8001' + - KEYGEN_ATTEMPT_TIMEOUT + - KEYGEN_EPOCH_CHECK_INTERVAL - LOG_LEVEL volumes: - '${PWD}/${TARGET_NETWORK}/keys:/keys' + ports: + - '${KEYGEN_RESTART_PORT}:8001' networks: - test_network signer: @@ -49,10 +50,13 @@ services: context: . environment: - 'RABBITMQ_URL=amqp://rabbitmq:5672' - - 'PROXY_URL=http://proxy:8001' + - 'PROXY_URL=http://local_proxy:8001' - FOREIGN_CHAIN_ID - FOREIGN_URL - FOREIGN_ASSET + - SIGN_ATTEMPT_TIMEOUT + - SIGN_NONCE_CHECK_INTERVAL + - SEND_TIMEOUT - LOG_LEVEL volumes: - '${PWD}/${TARGET_NETWORK}/keys:/keys' @@ -60,12 +64,14 @@ services: - '${SIGN_RESTART_PORT}:8001' networks: - test_network + - binance_net redis: - image: redis:5.0.5-alpine + image: redis + build: + dockerfile: redis/Dockerfile + context: . volumes: - '${PWD}/${TARGET_NETWORK}/db:/data' - - './configs/redis.conf:/usr/local/etc/redis/redis.conf' - command: ["redis-server", "/usr/local/etc/redis/redis.conf"] networks: - test_network rabbitmq: @@ -86,17 +92,15 @@ services: - HOME_RPC_URL - HOME_BRIDGE_ADDRESS - HOME_TOKEN_ADDRESS - - HOME_CHAIN_ID - HOME_START_BLOCK - BLOCKS_RANGE_SIZE - VALIDATOR_PRIVATE_KEY + - HOME_MAX_FETCH_RANGE_SIZE - 'RABBITMQ_URL=amqp://rabbitmq:5672' - LOG_LEVEL - volumes: - - '../deploy/deploy-home/build/contracts/Bridge.json:/watcher/contracts_data/Bridge.json' networks: - test_network - - blockchain_home + - ethereum_home_rpc_net bnc-watcher: build: dockerfile: bncWatcher/Dockerfile @@ -106,15 +110,21 @@ services: - FOREIGN_URL - FOREIGN_ASSET - 'RABBITMQ_URL=amqp://rabbitmq:5672' - - 'PROXY_URL=http://proxy:8001' + - 'PROXY_URL=http://local_proxy:8001' + - FOREIGN_FETCH_MAX_TIME_INTERVAL + - FOREIGN_FETCH_INTERVAL + - FOREIGN_FETCH_BLOCK_TIME_OFFSET - LOG_LEVEL volumes: - '${PWD}/${TARGET_NETWORK}/keys:/keys' networks: - test_network + - binance_net networks: test_network: - blockchain_side: + ethereum_side_rpc_net: + external: true + ethereum_home_rpc_net: external: true - blockchain_home: + binance_net: external: true diff --git a/src/oracle/docker-compose.yml b/src/oracle/docker-compose.yml index a79b816..3532066 100644 --- a/src/oracle/docker-compose.yml +++ b/src/oracle/docker-compose.yml @@ -9,20 +9,14 @@ services: - HOME_RPC_URL - HOME_BRIDGE_ADDRESS - HOME_TOKEN_ADDRESS - - HOME_CHAIN_ID - SIDE_RPC_URL - SIDE_SHARED_DB_ADDRESS - - SIDE_CHAIN_ID - VALIDATOR_PRIVATE_KEY - FOREIGN_URL - FOREIGN_ASSET - LOG_LEVEL - - "GAS_LIMIT_FACTOR=3" - - "MAX_GAS_LIMIT=6000000" - volumes: - - '../deploy/deploy-test/build/contracts/IERC20.json:/proxy/contracts_data/IERC20.json' - - '../deploy/deploy-home/build/contracts/Bridge.json:/proxy/contracts_data/Bridge.json' - - '../deploy/deploy-side/build/contracts/SharedDB.json:/proxy/contracts_data/SharedDB.json' + - 'GAS_LIMIT_FACTOR=3' + - 'MAX_GAS_LIMIT=6000000' ports: - '${VOTES_PROXY_PORT}:8002' networks: @@ -37,9 +31,13 @@ services: environment: - 'RABBITMQ_URL=amqp://rabbitmq:5672' - 'PROXY_URL=http://proxy:8001' + - KEYGEN_ATTEMPT_TIMEOUT + - KEYGEN_EPOCH_CHECK_INTERVAL - LOG_LEVEL volumes: - '${PWD}/${TARGET_NETWORK}/keys:/keys' + ports: + - '${KEYGEN_RESTART_PORT}:8001' networks: - keygen-proxy-net - rabbit-keygen-net @@ -55,6 +53,9 @@ services: - FOREIGN_CHAIN_ID - FOREIGN_URL - FOREIGN_ASSET + - SIGN_ATTEMPT_TIMEOUT + - SIGN_NONCE_CHECK_INTERVAL + - SEND_TIMEOUT - LOG_LEVEL volumes: - '${PWD}/${TARGET_NETWORK}/keys:/keys' @@ -65,11 +66,12 @@ services: - rabbit-signer-net - redis-signer-net redis: - image: redis:5.0.5-alpine + image: redis + build: + dockerfile: redis/Dockerfile + context: . volumes: - '${PWD}/${TARGET_NETWORK}/db:/data' - - './configs/redis.conf:/usr/local/etc/redis/redis.conf' - command: ["redis-server", "/usr/local/etc/redis/redis.conf"] networks: - redis-signer-net - redis-keygen-net @@ -96,13 +98,11 @@ services: - HOME_RPC_URL - HOME_BRIDGE_ADDRESS - HOME_TOKEN_ADDRESS - - HOME_CHAIN_ID - HOME_START_BLOCK - VALIDATOR_PRIVATE_KEY + - HOME_MAX_FETCH_RANGE_SIZE - 'RABBITMQ_URL=amqp://rabbitmq:5672' - LOG_LEVEL - volumes: - - '../deploy/deploy-home/build/contracts/Bridge.json:/watcher/contracts_data/Bridge.json' networks: - rabbit-ethwatcher-net - redis-ethwatcher-net @@ -116,6 +116,9 @@ services: - FOREIGN_ASSET - 'RABBITMQ_URL=amqp://rabbitmq:5672' - 'PROXY_URL=http://proxy:8001' + - FOREIGN_FETCH_MAX_TIME_INTERVAL + - FOREIGN_FETCH_INTERVAL + - FOREIGN_FETCH_BLOCK_TIME_OFFSET - LOG_LEVEL volumes: - '${PWD}/${TARGET_NETWORK}/keys:/keys' diff --git a/src/oracle/ethWatcher/Dockerfile b/src/oracle/ethWatcher/Dockerfile index 25351a1..9ca8e0f 100644 --- a/src/oracle/ethWatcher/Dockerfile +++ b/src/oracle/ethWatcher/Dockerfile @@ -9,6 +9,6 @@ COPY ./ethWatcher/package.json /watcher/ RUN npm install -COPY ./ethWatcher/ethWatcher.js ./shared/db.js ./shared/logger.js ./shared/amqp.js ./shared/crypto.js /watcher/ +COPY ./ethWatcher/ethWatcher.js ./shared/db.js ./shared/logger.js ./shared/amqp.js ./shared/crypto.js ./shared/wait.js /watcher/ ENTRYPOINT ["node", "ethWatcher.js"] diff --git a/src/oracle/ethWatcher/ethWatcher.js b/src/oracle/ethWatcher/ethWatcher.js index cc4bb4f..e26d430 100644 --- a/src/oracle/ethWatcher/ethWatcher.js +++ b/src/oracle/ethWatcher/ethWatcher.js @@ -1,5 +1,4 @@ -const Web3 = require('web3') -const utils = require('ethers').utils +const ethers = require('ethers') const BN = require('bignumber.js') const axios = require('axios') @@ -7,39 +6,63 @@ const logger = require('./logger') const redis = require('./db') const { connectRabbit, assertQueue } = require('./amqp') const { publicKeyToAddress } = require('./crypto') +const { delay, retry } = require('./wait') -const abiBridge = require('./contracts_data/Bridge.json').abi +const { + HOME_RPC_URL, HOME_BRIDGE_ADDRESS, RABBITMQ_URL, HOME_START_BLOCK, VALIDATOR_PRIVATE_KEY +} = process.env +const HOME_MAX_FETCH_RANGE_SIZE = parseInt(process.env.HOME_MAX_FETCH_RANGE_SIZE, 10) -const { HOME_RPC_URL, HOME_BRIDGE_ADDRESS, RABBITMQ_URL, HOME_START_BLOCK, VALIDATOR_PRIVATE_KEY } = process.env - -const homeWeb3 = new Web3(HOME_RPC_URL) -const bridge = new homeWeb3.eth.Contract(abiBridge, HOME_BRIDGE_ADDRESS) -const validatorAddress = homeWeb3.eth.accounts.privateKeyToAccount(`0x${VALIDATOR_PRIVATE_KEY}`).address +const provider = new ethers.providers.JsonRpcProvider(HOME_RPC_URL) +const bridgeAbi = [ + 'event ExchangeRequest(uint96 value, uint32 nonce)', + 'event EpochEnd(uint16 indexed epoch)', + 'event NewEpoch(uint16 indexed oldEpoch, uint16 indexed newEpoch)', + 'event NewEpochCancelled(uint16 indexed epoch)', + 'event NewFundsTransfer(uint16 indexed oldEpoch, uint16 indexed newEpoch)', + 'event EpochStart(uint16 indexed epoch, uint256 x, uint256 y)', + 'event EpochClose(uint16 indexed epoch)', + 'event ForceSign()', + 'function getThreshold(uint16 epoch) view returns (uint16)', + 'function getParties(uint16 epoch) view returns (uint16)', + 'function getRangeSize(uint16 epoch) view returns (uint16)', + 'function getValidators(uint16 epoch) view returns (address[])' +] +const bridge = new ethers.Contract(HOME_BRIDGE_ADDRESS, bridgeAbi, provider) +const validatorAddress = ethers.utils.computeAddress(`0x${VALIDATOR_PRIVATE_KEY}`) +const foreignNonce = [] let channel let exchangeQueue let signQueue let keygenQueue let cancelKeygenQueue +let epochTimeIntervalsQueue +let chainId let blockNumber -let foreignNonce = [] let epoch let epochStart let redisTx let rangeSize let lastTransactionBlockNumber let isCurrentValidator +let activeEpoch + +async function getBlockTimestamp(n) { + return (await provider.getBlock(n, false)).timestamp +} -async function resetFutureMessages (queue) { +async function resetFutureMessages(queue) { logger.debug(`Resetting future messages in queue ${queue.name}`) const { messageCount } = await channel.checkQueue(queue.name) if (messageCount) { logger.info(`Filtering ${messageCount} reloaded messages from queue ${queue.name}`) const backup = await assertQueue(channel, `${queue.name}.backup`) - do { + while (true) { const message = await queue.get() - if (message === false) + if (message === false) { break + } const data = JSON.parse(message.content) if (data.blockNumber < blockNumber) { logger.debug('Saving message %o', data) @@ -48,173 +71,76 @@ async function resetFutureMessages (queue) { logger.debug('Dropping message %o', data) } channel.ack(message) - } while (true) + } logger.debug('Dropped messages came from future') - do { + while (true) { const message = await backup.get() - if (message === false) + if (message === false) { break + } const data = JSON.parse(message.content) logger.debug('Requeuing message %o', data) queue.send(data) channel.ack(message) - } while (true) - - logger.debug('Redirected messages back to initial queue') - } -} - -async function initialize () { - channel = await connectRabbit(RABBITMQ_URL) - exchangeQueue = await assertQueue(channel, 'exchangeQueue') - signQueue = await assertQueue(channel, 'signQueue') - keygenQueue = await assertQueue(channel, 'keygenQueue') - cancelKeygenQueue = await assertQueue(channel, 'cancelKeygenQueue') - - const events = await bridge.getPastEvents('EpochStart', { - fromBlock: 1 - }) - epoch = events.length ? events[events.length - 1].returnValues.epoch.toNumber() : 0 - logger.info(`Current epoch ${epoch}`) - epochStart = events.length ? events[events.length - 1].blockNumber : 1 - const saved = (parseInt(await redis.get('homeBlock')) + 1) || parseInt(HOME_START_BLOCK) - if (epochStart > saved) { - logger.info(`Data in db is outdated, starting from epoch ${epoch}, block #${epochStart}`) - blockNumber = epochStart - rangeSize = (await bridge.methods.getRangeSize().call()).toNumber() - await redis.multi() - .set('homeBlock', blockNumber - 1) - .set(`foreignNonce${epoch}`, 0) - .exec() - foreignNonce[epoch] = 0 - } else { - logger.info('Restoring epoch and block number from local db') - blockNumber = saved - foreignNonce[epoch] = parseInt(await redis.get(`foreignNonce${epoch}`)) || 0 - } - isCurrentValidator = (await bridge.methods.getValidators().call()).includes(validatorAddress) - if (isCurrentValidator) { - logger.info(`${validatorAddress} is a current validator`) - } else { - logger.info(`${validatorAddress} is not a current validator`) - } - - await resetFutureMessages(keygenQueue) - await resetFutureMessages(cancelKeygenQueue) - await resetFutureMessages(exchangeQueue) - await resetFutureMessages(signQueue) - logger.debug(`Sending start commands`) - await axios.get('http://keygen:8001/start') - await axios.get('http://signer:8001/start') -} - -async function main () { - logger.debug(`Watching events in block #${blockNumber}`) - if (await homeWeb3.eth.getBlock(blockNumber) === null) { - logger.debug('No block') - await new Promise(r => setTimeout(r, 1000)) - return - } - - redisTx = redis.multi() - - const bridgeEvents = await bridge.getPastEvents('allEvents', { - fromBlock: blockNumber, - toBlock: blockNumber - }) - - for (const event of bridgeEvents) { - switch (event.event) { - case 'NewEpoch': - await sendKeygen(event) - break - case 'NewEpochCancelled': - sendKeygenCancellation(event) - break - case 'NewFundsTransfer': - isCurrentValidator && await sendSignFundsTransfer(event) - break - case 'ExchangeRequest': - isCurrentValidator && await sendSign(event) - break - case 'EpochStart': - await processEpochStart(event) - break } - } - if ((blockNumber + 1 - epochStart) % rangeSize === 0) { - logger.info('Reached end of the current block range') - - if (lastTransactionBlockNumber > blockNumber - rangeSize) { - logger.info('Sending message to start signature generation for the ended range') - await sendStartSign() - } + logger.debug('Redirected messages back to initial queue') } - - blockNumber++ - // Exec redis tx - await redisTx.incr('homeBlock').exec() - await redis.save() } -initialize().then(async () => { - while (true) { - await main() - } -}) - -async function sendKeygen (event) { - const newEpoch = event.returnValues.newEpoch.toNumber() +async function sendKeygen(event) { + const { newEpoch } = event.values keygenQueue.send({ epoch: newEpoch, blockNumber, - threshold: (await bridge.methods.getThreshold(newEpoch).call()).toNumber(), - parties: (await bridge.methods.getParties(newEpoch).call()).toNumber() + threshold: await bridge.getThreshold(newEpoch), + parties: await bridge.getParties(newEpoch) }) logger.debug('Sent keygen start event') } -function sendKeygenCancellation (event) { - const epoch = event.returnValues.epoch.toNumber() +function sendKeygenCancellation(event) { + const eventEpoch = event.values.epoch cancelKeygenQueue.send({ - epoch, + epoch: eventEpoch, blockNumber }) logger.debug('Sent keygen cancellation event') } -async function sendSignFundsTransfer (event) { - const newEpoch = event.returnValues.newEpoch.toNumber() - const oldEpoch = event.returnValues.oldEpoch.toNumber() +async function sendSignFundsTransfer(event) { + const { newEpoch, oldEpoch } = event.values signQueue.send({ epoch: oldEpoch, blockNumber, newEpoch, nonce: foreignNonce[oldEpoch], - threshold: (await bridge.methods.getThreshold(oldEpoch).call()).toNumber(), - parties: (await bridge.methods.getParties(oldEpoch).call()).toNumber() + threshold: await bridge.getThreshold(oldEpoch), + parties: await bridge.getParties(oldEpoch) }) logger.debug('Sent sign funds transfer event') - foreignNonce[oldEpoch]++ + foreignNonce[oldEpoch] += 1 redisTx.incr(`foreignNonce${oldEpoch}`) } -async function sendSign (event) { - const tx = await homeWeb3.eth.getTransaction(event.transactionHash) - const msg = utils.serializeTransaction({ +async function sendSign(event, transactionHash) { + const tx = await provider.getTransaction(transactionHash) + const msg = ethers.utils.serializeTransaction({ nonce: tx.nonce, - gasPrice: `0x${new BN(tx.gasPrice).toString(16)}`, - gasLimit: `0x${new BN(tx.gas).toString(16)}`, + gasPrice: tx.gasPrice, + gasLimit: tx.gasLimit, to: tx.to, - value: `0x${new BN(tx.value).toString(16)}`, - data: tx.input, - chainId: await homeWeb3.eth.net.getId() + data: tx.data, + chainId + }) + const hash = ethers.utils.keccak256(msg) + const publicKey = ethers.utils.recoverPublicKey(hash, { + r: tx.r, + s: tx.s, + v: tx.v }) - const hash = homeWeb3.utils.sha3(msg) - const publicKey = utils.recoverPublicKey(hash, { r: tx.r, s: tx.s, v: tx.v }) const msgToQueue = { epoch, blockNumber, @@ -222,8 +148,8 @@ async function sendSign (event) { x: publicKey.substr(4, 64), y: publicKey.substr(68, 64) }), - value: (new BN(event.returnValues.value)).dividedBy(10 ** 18).toFixed(8, 3), - nonce: event.returnValues.nonce.toNumber() + value: (new BN(event.values.value)).dividedBy(10 ** 18).toFixed(8, 3), + nonce: event.values.nonce } exchangeQueue.send(msgToQueue) @@ -234,23 +160,24 @@ async function sendSign (event) { logger.debug(`Set lastTransactionBlockNumber to ${blockNumber}`) } -async function sendStartSign () { - redisTx.incr(`foreignNonce${epoch}`) +async function sendStartSign() { signQueue.send({ epoch, blockNumber, - nonce: foreignNonce[epoch]++, - threshold: (await bridge.methods.getThreshold(epoch).call()).toNumber(), - parties: (await bridge.methods.getParties(epoch).call()).toNumber() + nonce: foreignNonce[epoch], + threshold: await bridge.getThreshold(epoch), + parties: await bridge.getParties(epoch) }) + foreignNonce[epoch] += 1 + redisTx.incr(`foreignNonce${epoch}`) } -async function processEpochStart (event) { - epoch = event.returnValues.epoch.toNumber() +async function processEpochStart(event) { + epoch = event.values.epoch epochStart = blockNumber logger.info(`Epoch ${epoch} started`) - rangeSize = (await bridge.methods.getRangeSize().call()).toNumber() - isCurrentValidator = (await bridge.methods.getValidators().call()).includes(validatorAddress) + rangeSize = await bridge.getRangeSize(epoch) + isCurrentValidator = (await bridge.getValidators(epoch)).includes(validatorAddress) if (isCurrentValidator) { logger.info(`${validatorAddress} is a current validator`) } else { @@ -259,3 +186,195 @@ async function processEpochStart (event) { logger.info(`Updated range size to ${rangeSize}`) foreignNonce[epoch] = 0 } + +async function sendEpochClose() { + logger.debug(`Consumed epoch ${epoch} close event`) + signQueue.send({ + closeEpoch: epoch, + blockNumber, + nonce: foreignNonce[epoch], + threshold: await bridge.getThreshold(epoch), + parties: await bridge.getParties(epoch) + }) + foreignNonce[epoch] += 1 + redisTx.incr(`foreignNonce${epoch}`) +} + +async function initialize() { + channel = await connectRabbit(RABBITMQ_URL) + exchangeQueue = await assertQueue(channel, 'exchangeQueue') + signQueue = await assertQueue(channel, 'signQueue') + keygenQueue = await assertQueue(channel, 'keygenQueue') + cancelKeygenQueue = await assertQueue(channel, 'cancelKeygenQueue') + epochTimeIntervalsQueue = await assertQueue(channel, 'epochTimeIntervalsQueue') + + activeEpoch = !!(await redis.get('activeEpoch')) + + chainId = (await provider.getNetwork()).chainId + + const events = (await provider.getLogs({ + address: HOME_BRIDGE_ADDRESS, + fromBlock: 1, + toBlock: 'latest', + topics: bridge.filters.EpochStart().topics + })).map((log) => bridge.interface.parseLog(log)) + + epoch = events.length ? events[events.length - 1].values.epoch : 0 + logger.info(`Current epoch ${epoch}`) + epochStart = events.length ? events[events.length - 1].blockNumber : 1 + const saved = (parseInt(await redis.get('homeBlock'), 10) + 1) || parseInt(HOME_START_BLOCK, 10) + if (epochStart > saved) { + logger.info(`Data in db is outdated, starting from epoch ${epoch}, block #${epochStart}`) + blockNumber = epochStart + await redis.multi() + .set('homeBlock', blockNumber - 1) + .set(`foreignNonce${epoch}`, 0) + .exec() + foreignNonce[epoch] = 0 + } else { + logger.info('Restoring epoch and block number from local db') + blockNumber = saved + foreignNonce[epoch] = parseInt(await redis.get(`foreignNonce${epoch}`), 10) || 0 + } + rangeSize = await bridge.getRangeSize(epoch) + logger.debug(`Range size ${rangeSize}`) + logger.debug('Checking if current validator') + isCurrentValidator = (await bridge.getValidators(epoch)).includes(validatorAddress) + if (isCurrentValidator) { + logger.info(`${validatorAddress} is a current validator`) + } else { + logger.info(`${validatorAddress} is not a current validator`) + } + + await resetFutureMessages(keygenQueue) + await resetFutureMessages(cancelKeygenQueue) + await resetFutureMessages(exchangeQueue) + await resetFutureMessages(signQueue) + await resetFutureMessages(epochTimeIntervalsQueue) + logger.debug('Sending start commands') + await axios.get('http://keygen:8001/start') + await axios.get('http://signer:8001/start') +} + +async function loop() { + const latestBlockNumber = await provider.getBlockNumber() + if (latestBlockNumber < blockNumber) { + logger.debug(`No block after ${latestBlockNumber}`) + await delay(2000) + return + } + + const endBlock = Math.min(latestBlockNumber, blockNumber + HOME_MAX_FETCH_RANGE_SIZE - 1) + + redisTx = redis.multi() + + logger.debug(`Watching events in blocks #${blockNumber}-${endBlock}`) + + const bridgeEvents = (await provider.getLogs({ + address: HOME_BRIDGE_ADDRESS, + fromBlock: blockNumber, + toBlock: endBlock, + topics: [] + })) + + for (let curBlockNumber = blockNumber, i = 0; curBlockNumber <= endBlock; curBlockNumber += 1) { + const rangeOffset = (curBlockNumber + 1 - epochStart) % rangeSize + const rangeStart = curBlockNumber - (rangeOffset || rangeSize) + let epochTimeUpdated = false + while (i < bridgeEvents.length && bridgeEvents[i].blockNumber === curBlockNumber) { + const event = bridge.interface.parseLog(bridgeEvents[i]) + logger.trace('Consumed event %o %o', event, bridgeEvents[i]) + switch (event.name) { + case 'NewEpoch': + if ((await bridge.getValidators(event.values.newEpoch)).includes(validatorAddress)) { + await sendKeygen(event) + } + break + case 'NewEpochCancelled': + if ((await bridge.getValidators(event.values.epoch)).includes(validatorAddress)) { + sendKeygenCancellation(event) + } + break + case 'NewFundsTransfer': + if (isCurrentValidator) { + await sendSignFundsTransfer(event) + } + break + case 'ExchangeRequest': + if (isCurrentValidator) { + await sendSign(event, bridgeEvents[i].transactionHash) + } + break + case 'EpochStart': + await processEpochStart(event) + await redis.set('activeEpoch', true) + activeEpoch = true + epochTimeIntervalsQueue.send({ + blockNumber: curBlockNumber, + startTime: await retry(() => getBlockTimestamp(curBlockNumber)) * 1000, + epoch + }) + epochTimeUpdated = true + break + case 'EpochEnd': + logger.debug(`Consumed epoch ${epoch} end event`) + await redis.set('activeEpoch', false) + activeEpoch = false + epochTimeIntervalsQueue.send({ + blockNumber: curBlockNumber, + prolongedTime: await retry(() => getBlockTimestamp(curBlockNumber)) * 1000, + epoch + }) + break + case 'EpochClose': + if (isCurrentValidator) { + await sendEpochClose() + } + break + case 'ForceSign': + if (isCurrentValidator && lastTransactionBlockNumber > rangeStart) { + logger.debug('Consumed force sign event') + lastTransactionBlockNumber = 0 + redisTx.set('lastTransactionBlockNumber', 0) + await sendStartSign() + } + break + default: + logger.warn('Unknown event %o', event) + } + i += 1 + } + + if (curBlockNumber === endBlock && !epochTimeUpdated && epoch > 0 && activeEpoch) { + epochTimeIntervalsQueue.send({ + blockNumber: curBlockNumber, + prolongedTime: await retry(() => getBlockTimestamp(curBlockNumber)) * 1000, + epoch + }) + } + + if (rangeOffset === 0) { + logger.info('Reached end of the current block range') + + if (isCurrentValidator && lastTransactionBlockNumber > curBlockNumber - rangeSize) { + logger.info('Sending message to start signature generation for the ended range') + await sendStartSign() + } + } + } + + blockNumber = endBlock + 1 + // Exec redis tx + await redisTx.set('homeBlock', endBlock).exec() + await redis.save() +} + +async function main() { + await initialize() + + while (true) { + await loop() + } +} + +main() diff --git a/src/oracle/ethWatcher/package.json b/src/oracle/ethWatcher/package.json index 027e9de..a7517af 100644 --- a/src/oracle/ethWatcher/package.json +++ b/src/oracle/ethWatcher/package.json @@ -4,12 +4,14 @@ "dependencies": { "ioredis": "4.10.0", "amqplib": "0.5.3", - "web3": "1.0.0-beta.55", "ethers": "4.0.33", "bignumber.js": "9.0.0", "bech32": "1.1.3", "pino": "5.13.4", "pino-pretty": "3.2.1", "axios": "0.19.0" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/oracle/proxy/Dockerfile b/src/oracle/proxy/Dockerfile index e2cac6c..2069f11 100644 --- a/src/oracle/proxy/Dockerfile +++ b/src/oracle/proxy/Dockerfile @@ -6,6 +6,6 @@ COPY ./proxy/package.json /proxy/ RUN npm install -COPY ./proxy/index.js ./proxy/encode.js ./proxy/decode.js ./proxy/sendTx.js ./shared/logger.js ./shared/crypto.js /proxy/ +COPY ./proxy/index.js ./proxy/encode.js ./proxy/decode.js ./proxy/sendTx.js ./proxy/contractsAbi.js ./proxy/utils.js ./shared/logger.js ./shared/crypto.js ./shared/wait.js /proxy/ ENTRYPOINT ["node", "index.js"] diff --git a/src/oracle/proxy/contractsAbi.js b/src/oracle/proxy/contractsAbi.js new file mode 100644 index 0000000..1a63694 --- /dev/null +++ b/src/oracle/proxy/contractsAbi.js @@ -0,0 +1,38 @@ +const tokenAbi = [ + 'function balanceOf(address account) view returns (uint256)' +] +const bridgeAbi = [ + 'function getX() view returns (uint256)', + 'function getY() view returns (uint256)', + 'function epoch() view returns (uint16)', + 'function getRangeSize() view returns (uint16)', + 'function getNextRangeSize() view returns (uint16)', + 'function getStartBlock() view returns (uint32)', + 'function getNonce() view returns (uint16)', + 'function nextEpoch() view returns (uint16)', + 'function getThreshold() view returns (uint16)', + 'function getNextThreshold() view returns (uint16)', + 'function getValidators() view returns (address[])', + 'function getNextValidators() view returns (address[])', + 'function getCloseEpoch() view returns (bool)', + 'function getNextCloseEpoch() view returns (bool)', + 'function status() view returns (uint8)', + 'function votesCount(bytes32) view returns (uint16)', + 'function getNextPartyId(address a) view returns (uint16)' +] +const sharedDbAbi = [ + 'function getSignupAddress(bytes32 hash, address[] validators, uint16 signupNumber) view returns (address)', + 'function getData(address from, bytes32 hash, bytes32 key) view returns (bytes)', + 'function getSignupNumber(bytes32 hash, address[] validators, address validator) view returns (uint16)', + 'function isSignuped(bytes32 hash) view returns (bool)', + 'function setData(bytes32 hash, bytes32 key, bytes data)', + 'function signup(bytes32 hash)', + 'function addSignature(bytes message, bytes rsv)', + 'function getSignatures(bytes32 msgHash, address[] validators) view returns (bytes)' +] + +module.exports = { + tokenAbi, + bridgeAbi, + sharedDbAbi +} diff --git a/src/oracle/proxy/decode.js b/src/oracle/proxy/decode.js index 86faecf..f1d2e2e 100644 --- a/src/oracle/proxy/decode.js +++ b/src/oracle/proxy/decode.js @@ -1,18 +1,19 @@ const BN = require('bn.js') -function Tokenizer (_buffer) { +function Tokenizer(_buffer) { const buffer = _buffer let position = 0 return { - isEmpty: function () { + isEmpty() { return position === buffer.length }, - parse: function (length = 32, base = 16) { + parse(length = 32, base = 16) { const res = new BN(buffer.slice(position, position + length)).toString(base) position += length return res }, - byte: function () { + byte() { + // eslint-disable-next-line no-plusplus return buffer[position++] } } @@ -21,7 +22,7 @@ function Tokenizer (_buffer) { const keygenDecoders = [ null, // round 1 - function (tokenizer) { + (tokenizer) => { const res = { e: { n: tokenizer.parse(256, 10) @@ -37,31 +38,30 @@ const keygenDecoders = [ return res }, // round 2 - function (tokenizer) { - return { - blind_factor: tokenizer.parse(), - y_i: { - x: tokenizer.parse(), - y: tokenizer.parse() - } + (tokenizer) => ({ + blind_factor: tokenizer.parse(), + y_i: { + x: tokenizer.parse(), + y: tokenizer.parse() } - }, + }), // round 3 - function (tokenizer) { + (tokenizer) => { const res = { ciphertext: [], tag: [] } - for (let i = 0; i < 32; i++) { + const ciphertextLength = tokenizer.byte() // probably 32 + for (let i = 0; i < ciphertextLength; i += 1) { res.ciphertext.push(tokenizer.byte()) } - for (let i = 0; i < 16; i++) { + while (!tokenizer.isEmpty()) { res.tag.push(tokenizer.byte()) } return res }, // round 4 - function (tokenizer) { + (tokenizer) => { const res = { parameters: { threshold: tokenizer.byte(), @@ -72,157 +72,139 @@ const keygenDecoders = [ while (!tokenizer.isEmpty()) { res.commitments.push({ x: tokenizer.parse(), - y: tokenizer.parse(), + y: tokenizer.parse() }) } return res }, // round 5 - function (tokenizer) { - return { - pk: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - pk_t_rand_commitment: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - challenge_response: tokenizer.parse() - } - } + (tokenizer) => ({ + pk: { + x: tokenizer.parse(), + y: tokenizer.parse() + }, + pk_t_rand_commitment: { + x: tokenizer.parse(), + y: tokenizer.parse() + }, + challenge_response: tokenizer.parse() + }) ] const signDecoders = [ // round 0 - function (tokenizer) { - return tokenizer.byte() - }, + (tokenizer) => tokenizer.byte(), // round 1 - function (tokenizer) { - return [ - { - com: tokenizer.parse() - }, - { - c: tokenizer.parse(512) - } - ] - }, + (tokenizer) => [ + { + com: tokenizer.parse() + }, + { + c: tokenizer.parse(512) + } + ], // round 2 - function (tokenizer) { + (tokenizer) => { const res = [] - for (let i = 0; i < 2; i++) { + for (let i = 0; i < 2; i += 1) { res[i] = { c: tokenizer.parse(512), b_proof: { pk: { x: tokenizer.parse(), - y: tokenizer.parse(), + y: tokenizer.parse() }, pk_t_rand_commitment: { x: tokenizer.parse(), - y: tokenizer.parse(), + y: tokenizer.parse() }, - challenge_response: tokenizer.parse(), + challenge_response: tokenizer.parse() }, beta_tag_proof: { pk: { x: tokenizer.parse(), - y: tokenizer.parse(), + y: tokenizer.parse() }, pk_t_rand_commitment: { x: tokenizer.parse(), - y: tokenizer.parse(), + y: tokenizer.parse() }, - challenge_response: tokenizer.parse(), + challenge_response: tokenizer.parse() } } } return res }, // round 3 - function (tokenizer) { - return tokenizer.parse() - }, + (tokenizer) => tokenizer.parse(), // round 4 - function (tokenizer) { - return { - blind_factor: tokenizer.parse(), - g_gamma_i: { - x: tokenizer.parse(), - y: tokenizer.parse() - } + (tokenizer) => ({ + blind_factor: tokenizer.parse(), + g_gamma_i: { + x: tokenizer.parse(), + y: tokenizer.parse() } - }, + }), // round 5 - function (tokenizer) { - return { - com: tokenizer.parse() - } - }, + (tokenizer) => ({ + com: tokenizer.parse() + }), // round 6 - function (tokenizer) { - return [ - { - V_i: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - A_i: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - B_i: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - blind_factor: tokenizer.parse() + (tokenizer) => [ + { + V_i: { + x: tokenizer.parse(), + y: tokenizer.parse() }, - { - T: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - A3: { - x: tokenizer.parse(), - y: tokenizer.parse() - }, - z1: tokenizer.parse(), - z2: tokenizer.parse() - } - ] - }, - // round 7 - function (tokenizer) { - return { - com: tokenizer.parse() - } - }, - // round 8 - function (tokenizer) { - return { - u_i: { + A_i: { x: tokenizer.parse(), y: tokenizer.parse() }, - t_i: { + B_i: { x: tokenizer.parse(), y: tokenizer.parse() }, blind_factor: tokenizer.parse() + }, + { + T: { + x: tokenizer.parse(), + y: tokenizer.parse() + }, + A3: { + x: tokenizer.parse(), + y: tokenizer.parse() + }, + z1: tokenizer.parse(), + z2: tokenizer.parse() } - }, + ], + // round 7 + (tokenizer) => ({ + com: tokenizer.parse() + }), + // round 8 + (tokenizer) => ({ + u_i: { + x: tokenizer.parse(), + y: tokenizer.parse() + }, + t_i: { + x: tokenizer.parse(), + y: tokenizer.parse() + }, + blind_factor: tokenizer.parse() + }), // round 9 - function (tokenizer) { - return tokenizer.parse() - }, + (tokenizer) => tokenizer.parse() ] -module.exports = function (isKeygen, round, value) { - value = Buffer.from(value.substr(2), 'hex') - const tokenizer = Tokenizer(value) - const roundNumber = parseInt(round[round.length - 1]) +function decode(isKeygen, round, value) { + const newValue = Buffer.from(value.substr(2), 'hex') + const tokenizer = Tokenizer(newValue) + const roundNumber = parseInt(round[round.length - 1], 10) const decoder = (isKeygen ? keygenDecoders : signDecoders)[roundNumber] return JSON.stringify(decoder(tokenizer)) } + +module.exports = decode diff --git a/src/oracle/proxy/encode.js b/src/oracle/proxy/encode.js index 6499a2d..13361f3 100644 --- a/src/oracle/proxy/encode.js +++ b/src/oracle/proxy/encode.js @@ -2,42 +2,44 @@ const BN = require('bignumber.js') const { padZeros } = require('./crypto') -function makeBuffer (value, length = 32, base = 16) { +function makeBuffer(value, length = 32, base = 16) { return Buffer.from(padZeros(new BN(value, base).toString(16), length * 2), 'hex') } const keygenEncoders = [ null, // round 1 - function * (value) { + function* g(value) { yield makeBuffer(value.e.n, 256, 10) yield makeBuffer(value.com) - for (let x of value.correct_key_proof.sigma_vec) { - yield makeBuffer(x, 256, 10) + for (let i = 0; i < value.correct_key_proof.sigma_vec.length; i += 1) { + yield makeBuffer(value.correct_key_proof.sigma_vec[i], 256, 10) } }, // round 2 - function * (value) { + function* g(value) { yield makeBuffer(value.blind_factor) yield makeBuffer(value.y_i.x) yield makeBuffer(value.y_i.y) }, // round 3 - function * (value) { - yield Buffer.from(value.ciphertext) // 32 bytes - yield Buffer.from(value.tag) // 16 bytes + function* g(value) { + yield Buffer.from([value.ciphertext.length]) + yield Buffer.from(value.ciphertext) // 32 bytes or less + yield Buffer.from(value.tag) // 16 bytes or less }, // round 4 - function * (value) { - yield Buffer.from([ value.parameters.threshold ]) // 1 byte - yield Buffer.from([ value.parameters.share_count ]) // 1 byte - for (let x of value.commitments) { + function* g(value) { + yield Buffer.from([value.parameters.threshold]) // 1 byte + yield Buffer.from([value.parameters.share_count]) // 1 byte + for (let i = 0; i < value.commitments.length; i += 1) { + const x = value.commitments[i] yield makeBuffer(x.x) yield makeBuffer(x.y) } }, // round 5 - function * (value) { + function* g(value) { yield makeBuffer(value.pk.x) yield makeBuffer(value.pk.y) yield makeBuffer(value.pk_t_rand_commitment.x) @@ -48,17 +50,17 @@ const keygenEncoders = [ const signEncoders = [ // round 0 - function * (value) { - yield Buffer.from([ value ]) + function* g(value) { + yield Buffer.from([value]) }, // round 1 - function * (value) { + function* g(value) { yield makeBuffer(value[0].com) yield makeBuffer(value[1].c, 512) }, // round 2 - function * (value) { - for (let i = 0; i < 2; i++) { + function* g(value) { + for (let i = 0; i < 2; i += 1) { yield makeBuffer(value[i].c, 512) yield makeBuffer(value[i].b_proof.pk.x) yield makeBuffer(value[i].b_proof.pk.y) @@ -73,21 +75,21 @@ const signEncoders = [ } }, // round 3 - function * (value) { + function* g(value) { yield makeBuffer(value) }, // round 4 - function * (value) { + function* g(value) { yield makeBuffer(value.blind_factor) yield makeBuffer(value.g_gamma_i.x) yield makeBuffer(value.g_gamma_i.y) }, // round 5 - function * (value) { + function* g(value) { yield makeBuffer(value.com) }, // round 6 - function * (value) { + function* g(value) { yield makeBuffer(value[0].V_i.x) yield makeBuffer(value[0].V_i.y) yield makeBuffer(value[0].A_i.x) @@ -103,11 +105,11 @@ const signEncoders = [ yield makeBuffer(value[1].z2) }, // round 7 - function * (value) { + function* g(value) { yield makeBuffer(value.com) }, // round 8 - function * (value) { + function* g(value) { yield makeBuffer(value.u_i.x) yield makeBuffer(value.u_i.y) yield makeBuffer(value.t_i.x) @@ -115,23 +117,23 @@ const signEncoders = [ yield makeBuffer(value.blind_factor) }, // round 9 - function * (value) { + function* g(value) { yield makeBuffer(value) - }, + } ] -module.exports = function (isKeygen, round, value) { +function encode(isKeygen, round, value) { const parsedValue = JSON.parse(value) - const roundNumber = parseInt(round[round.length - 1]) + const roundNumber = parseInt(round[round.length - 1], 10) const encoder = (isKeygen ? keygenEncoders : signEncoders)[roundNumber] const generator = encoder(parsedValue) const buffers = [] - let next - while (true) { - next = generator.next() - if (next.done) - break + let next = generator.next() + while (!next.done) { buffers.push(next.value) + next = generator.next() } return Buffer.concat(buffers) } + +module.exports = encode diff --git a/src/oracle/proxy/index.js b/src/oracle/proxy/index.js index cc505a6..6a12894 100644 --- a/src/oracle/proxy/index.js +++ b/src/oracle/proxy/index.js @@ -1,114 +1,119 @@ const express = require('express') -const Web3 = require('web3') const AsyncLock = require('async-lock') const axios = require('axios') const BN = require('bignumber.js') -const { utils } = require('ethers') +const ethers = require('ethers') +const { tokenAbi, bridgeAbi, sharedDbAbi } = require('./contractsAbi') +const { + Ok, Err, decodeStatus +} = require('./utils') const encode = require('./encode') const decode = require('./decode') const { createSender, waitForReceipt } = require('./sendTx') const logger = require('./logger') -const { publicKeyToAddress } = require('./crypto') +const { publicKeyToAddress, padZeros } = require('./crypto') const { - HOME_RPC_URL, HOME_BRIDGE_ADDRESS, SIDE_RPC_URL, SIDE_SHARED_DB_ADDRESS, VALIDATOR_PRIVATE_KEY, HOME_CHAIN_ID, - SIDE_CHAIN_ID, HOME_TOKEN_ADDRESS, FOREIGN_URL, FOREIGN_ASSET + HOME_RPC_URL, HOME_BRIDGE_ADDRESS, SIDE_RPC_URL, SIDE_SHARED_DB_ADDRESS, VALIDATOR_PRIVATE_KEY, + HOME_TOKEN_ADDRESS, FOREIGN_URL, FOREIGN_ASSET } = process.env -const abiSharedDb = require('./contracts_data/SharedDB.json').abi -const abiBridge = require('./contracts_data/Bridge.json').abi -const abiToken = require('./contracts_data/IERC20.json').abi -const homeWeb3 = new Web3(HOME_RPC_URL, null, { transactionConfirmationBlocks: 1 }) -const sideWeb3 = new Web3(SIDE_RPC_URL, null, { transactionConfirmationBlocks: 1 }) -const bridge = new homeWeb3.eth.Contract(abiBridge, HOME_BRIDGE_ADDRESS) -const token = new homeWeb3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS) -const sharedDb = new sideWeb3.eth.Contract(abiSharedDb, SIDE_SHARED_DB_ADDRESS) -const validatorAddress = homeWeb3.eth.accounts.privateKeyToAccount(`0x${VALIDATOR_PRIVATE_KEY}`).address +const Action = { + CONFIRM_KEYGEN: 0, + CONFIRM_FUNDS_TRANSFER: 1, + CONFIRM_CLOSE_EPOCH: 2, + VOTE_START_VOTING: 3, + VOTE_ADD_VALIDATOR: 4, + VOTE_REMOVE_VALIDATOR: 5, + VOTE_CHANGE_THRESHOLD: 6, + VOTE_CHANGE_RANGE_SIZE: 7, + VOTE_CHANGE_CLOSE_EPOCH: 8, + VOTE_START_KEYGEN: 9, + VOTE_CANCEL_KEYGEN: 10, + TRANSFER: 11 +} + +const homeProvider = new ethers.providers.JsonRpcProvider(HOME_RPC_URL) +const sideProvider = new ethers.providers.JsonRpcProvider(SIDE_RPC_URL) +const homeWallet = new ethers.Wallet(VALIDATOR_PRIVATE_KEY, homeProvider) +const sideWallet = new ethers.Wallet(VALIDATOR_PRIVATE_KEY, sideProvider) + +const token = new ethers.Contract(HOME_TOKEN_ADDRESS, tokenAbi, homeWallet) +const bridge = new ethers.Contract(HOME_BRIDGE_ADDRESS, bridgeAbi, homeWallet) +const sharedDb = new ethers.Contract(SIDE_SHARED_DB_ADDRESS, sharedDbAbi, sideWallet) + +const validatorAddress = homeWallet.address const httpClient = axios.create({ baseURL: FOREIGN_URL }) const lock = new AsyncLock() -let homeValidatorNonce let sideValidatorNonce -let homeSender let sideSender const app = express() app.use(express.json()) app.use(express.urlencoded({ extended: true })) -app.post('/get', get) -app.post('/set', set) -app.post('/signupkeygen', signupKeygen) -app.post('/signupsign', signupSign) - -app.post('/confirmKeygen', confirmKeygen) -app.post('/confirmFundsTransfer', confirmFundsTransfer) -app.post('/transfer', transfer) - const votesProxyApp = express() -votesProxyApp.use(express.json()) -votesProxyApp.use(express.urlencoded({ extended: true })) - -votesProxyApp.get('/vote/startVoting', voteStartVoting) -votesProxyApp.get('/vote/startKeygen', voteStartKeygen) -votesProxyApp.get('/vote/cancelKeygen', voteCancelKeygen) -votesProxyApp.get('/vote/addValidator/:validator', voteAddValidator) -votesProxyApp.get('/vote/removeValidator/:validator', voteRemoveValidator) -votesProxyApp.get('/vote/changeThreshold/:threshold', voteChangeThreshold) -votesProxyApp.get('/info', info) - -async function main () { - homeValidatorNonce = await homeWeb3.eth.getTransactionCount(validatorAddress) - sideValidatorNonce = await sideWeb3.eth.getTransactionCount(validatorAddress) - - homeSender = await createSender(HOME_RPC_URL, VALIDATOR_PRIVATE_KEY) - sideSender = await createSender(SIDE_RPC_URL, VALIDATOR_PRIVATE_KEY) - - logger.warn(`My validator address in home and side networks is ${validatorAddress}`) - app.listen(8001, () => { - logger.debug('Proxy is listening on port 8001') - }) - - votesProxyApp.listen(8002, () => { - logger.debug('Votes proxy is listening on port 8002') +function sideSendQuery(query) { + return lock.acquire('side', async () => { + logger.debug('Sending side query') + const senderResponse = await sideSender({ + data: query, + to: SIDE_SHARED_DB_ADDRESS, + nonce: sideValidatorNonce + }) + if (senderResponse !== true) { + sideValidatorNonce += 1 + } + return senderResponse }) } -main() - -function Ok (data) { - return { Ok: data } -} - -function Err (data) { - return { Err: data } +async function status(req, res) { + logger.debug('Status call') + const [bridgeEpoch, bridgeStatus] = await Promise.all([ + bridge.epoch(), + bridge.status() + ]) + res.send({ + bridgeEpoch, + bridgeStatus + }) + logger.debug('Status end') } -async function get (req, res) { +async function get(req, res) { logger.debug('Get call, %o', req.body.key) const round = req.body.key.second const uuid = req.body.key.third let from - if (uuid.startsWith('k')) - from = (await bridge.methods.getNextValidators().call())[parseInt(req.body.key.first) - 1] - else { - const validators = await bridge.methods.getValidators().call() - from = await sharedDb.methods.getSignupAddress(uuid, validators, parseInt(req.body.key.first)).call() + if (uuid.startsWith('k')) { + from = (await bridge.getNextValidators())[parseInt(req.body.key.first, 10) - 1] + } else { + const validators = await bridge.getValidators() + from = await sharedDb.getSignupAddress( + uuid, + validators, + parseInt(req.body.key.first, 10) + ) } const to = Number(req.body.key.fourth) // 0 if empty - const key = homeWeb3.utils.sha3(`${round}_${to}`) + const key = ethers.utils.id(`${round}_${to}`) - const data = await sharedDb.methods.getData(from, sideWeb3.utils.sha3(uuid), key).call() + const data = await sharedDb.getData(from, ethers.utils.id(uuid), key) if (data.length > 2) { logger.trace(`Received encoded data: ${data}`) const decoded = decode(uuid[0] === 'k', round, data) logger.trace('Decoded data: %o', decoded) - res.send(Ok({ key: req.body.key, value: decoded })) + res.send(Ok({ + key: req.body.key, + value: decoded + })) } else { setTimeout(() => res.send(Err(null)), 1000) } @@ -116,227 +121,322 @@ async function get (req, res) { logger.debug('Get end') } -async function set (req, res) { +async function set(req, res) { logger.debug('Set call') const round = req.body.key.second const uuid = req.body.key.third const to = Number(req.body.key.fourth) - const key = homeWeb3.utils.sha3(`${round}_${to}`) + const key = ethers.utils.id(`${round}_${to}`) logger.trace('Received data: %o', req.body.value) const encoded = encode(uuid[0] === 'k', round, req.body.value) logger.trace(`Encoded data: ${encoded.toString('hex')}`) logger.trace(`Received data: ${req.body.value.length} bytes, encoded data: ${encoded.length} bytes`) - const query = sharedDb.methods.setData(sideWeb3.utils.sha3(uuid), key, encoded) + const query = sharedDb.interface.functions.setData.encode([ethers.utils.id(uuid), key, encoded]) await sideSendQuery(query) res.send(Ok(null)) logger.debug('Set end') } -async function signupKeygen (req, res) { +async function signupKeygen(req, res) { logger.debug('SignupKeygen call') - const epoch = (await bridge.methods.nextEpoch().call()).toNumber() - const partyId = (await bridge.methods.getNextPartyId(validatorAddress).call()).toNumber() + const epoch = await bridge.nextEpoch() + const partyId = await bridge.getNextPartyId(validatorAddress) + + logger.debug('Checking previous attempts') + let attempt = 1 + let uuid + while (true) { + uuid = `k${epoch}_${attempt}` + const data = await sharedDb.getData(validatorAddress, ethers.utils.id(uuid), ethers.utils.id('round1_0')) + if (data.length === 2) { + break + } + logger.trace(`Attempt ${attempt} is already used`) + attempt += 1 + } + logger.debug(`Using attempt ${attempt}`) if (partyId === 0) { res.send(Err({ message: 'Not a validator' })) logger.debug('Not a validator') } else { - res.send(Ok({ uuid: `k${epoch}`, number: partyId })) + res.send(Ok({ + uuid, + number: partyId + })) logger.debug('SignupKeygen end') } } -async function signupSign (req, res) { +async function signupSign(req, res) { logger.debug('SignupSign call') - const hash = sideWeb3.utils.sha3(`0x${req.body.third}`) - const query = sharedDb.methods.signupSign(hash) + const msgHash = req.body.third + + logger.debug('Checking previous attempts') + let attempt = 1 + let uuid + let hash + while (true) { + uuid = `${msgHash}_${attempt}` + hash = ethers.utils.id(uuid) + const data = await sharedDb.isSignuped(hash) + if (!data) { + break + } + logger.trace(`Attempt ${attempt} is already used`) + attempt += 1 + } + logger.debug(`Using attempt ${attempt}`) + + const query = sharedDb.interface.functions.signup.encode([hash]) const { txHash } = await sideSendQuery(query) const receipt = await waitForReceipt(SIDE_RPC_URL, txHash) // Already have signup if (receipt.status === false) { - res.send(Ok({ uuid: hash, number: 0 })) + res.send(Ok({ + uuid: hash, + number: 0 + })) logger.debug('Already have signup') return } - const validators = await bridge.methods.getValidators().call() - const id = (await sharedDb.methods.getSignupNumber(hash, validators, validatorAddress).call()).toNumber() + const validators = await bridge.getValidators() + const id = await sharedDb.getSignupNumber(hash, validators, validatorAddress) - res.send(Ok({ uuid: hash, number: id })) + res.send(Ok({ + uuid: hash, + number: id + })) logger.debug('SignupSign end') } -async function confirmKeygen (req, res) { - logger.debug('Confirm keygen call') - const { x, y } = req.body[5] - const query = bridge.methods.confirmKeygen(`0x${x}`, `0x${y}`) - await homeSendQuery(query) - res.send() - logger.debug('Confirm keygen end') -} - -async function confirmFundsTransfer (req, res) { - logger.debug('Confirm funds transfer call') - const query = bridge.methods.confirmFundsTransfer() - await homeSendQuery(query) - res.send() - logger.debug('Confirm funds transfer end') +function encodeParam(param) { + switch (typeof param) { + case 'string': + if (param.startsWith('0x')) { + return Buffer.from(param.slice(2), 'hex') + } + return Buffer.from(param, 'hex') + case 'number': + return Buffer.from(padZeros(param.toString(16), 4), 'hex') + case 'boolean': + return Buffer.from([param ? 1 : 0]) + default: + return null + } } -function sideSendQuery (query) { - return lock.acquire('home', async () => { - logger.debug('Sending side query') - const encodedABI = query.encodeABI() - return await sideSender({ - data: encodedABI, - to: SIDE_SHARED_DB_ADDRESS, - nonce: sideValidatorNonce++ - }) - }) +function buildMessage(type, ...params) { + logger.debug(`${type}, %o`, params) + return Buffer.concat([ + Buffer.from([type]), + ...params.map(encodeParam) + ]) } -function homeSendQuery (query) { - return lock.acquire('home', async () => { - logger.debug('Sending home query') - const encodedABI = query.encodeABI() - return await homeSender({ - data: encodedABI, - to: HOME_BRIDGE_ADDRESS, - nonce: homeValidatorNonce++ - }) - }) +async function processMessage(message) { + const signature = await sideWallet.signMessage(message) + logger.debug('Adding signature to shared db contract') + const query = sharedDb.interface.functions.addSignature.encode([`0x${message.toString('hex')}`, signature]) + await sideSendQuery(query) } -function parseReason (message) { - const result = /(?<="reason":").*?(?=")/.exec(message) - return result ? result[0] : '' +async function confirmKeygen(req, res) { + logger.debug('Confirm keygen call') + const { x, y, epoch } = req.body + const message = buildMessage(Action.CONFIRM_KEYGEN, epoch, padZeros(x, 64), padZeros(y, 64)) + await processMessage(message) + res.send() + logger.debug('Confirm keygen end') } -function parseError (message) { - const result = /(?<="error":").*?(?=")/.exec(message) - return result ? result[0] : '' +async function confirmFundsTransfer(req, res) { + logger.debug('Confirm funds transfer call') + const { epoch } = req.body + const message = buildMessage(Action.CONFIRM_FUNDS_TRANSFER, epoch) + await processMessage(message) + res.send() + logger.debug('Confirm funds transfer end') } -async function sendVote (query, req, res, waitFlag = false) { - try { - let { txHash, gasLimit } = await homeSendQuery(query) - if (txHash) { - while (waitFlag) { - const { status, gasUsed } = await waitForReceipt(HOME_RPC_URL, txHash) - if (status === '0x1') { - logger.debug('Receipt status is OK') - break - } - if (gasLimit === gasUsed) { - logger.info('Sending vote failed due to out of gas revert, retrying with more gas') - const nexTx = await homeSendQuery(query) - txHash = nexTx.txHash - gasLimit = nexTx.gasLimit - } else { - logger.warn(`Vote tx was reverted, txHash ${txHash}`) - break - } - } - res.send('Voted\n') - logger.info('Voted successfully') - } else { - res.send('Failed\n') - logger.info('Failed to vote') - } - } catch (e) { - logger.debug(e) - } +async function confirmCloseEpoch(req, res) { + logger.debug('Confirm close epoch call') + const { epoch } = req.body + const message = buildMessage(Action.CONFIRM_CLOSE_EPOCH, epoch) + await processMessage(message) + res.send() + logger.debug('Confirm close epoch end') } -async function voteStartVoting (req, res) { +async function voteStartVoting(req, res) { logger.info('Voting for starting new epoch voting process') - const query = bridge.methods.startVoting() - sendVote(query, req, res, true) + const epoch = await bridge.epoch() + const message = buildMessage(Action.VOTE_START_VOTING, epoch) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') } -async function voteStartKeygen (req, res) { +async function voteStartKeygen(req, res) { logger.info('Voting for starting new epoch keygen') - const query = bridge.methods.voteStartKeygen() - sendVote(query, req, res) + const epoch = await bridge.epoch() + const message = buildMessage(Action.VOTE_START_KEYGEN, epoch) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') } -async function voteCancelKeygen (req, res) { +async function voteCancelKeygen(req, res) { logger.info('Voting for cancelling new epoch keygen') - const query = bridge.methods.voteCancelKeygen() - sendVote(query, req, res) + const epoch = await bridge.nextEpoch() + const message = buildMessage(Action.VOTE_CANCEL_KEYGEN, epoch) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') } -async function voteAddValidator (req, res) { - logger.info('Voting for adding new validator') - const query = bridge.methods.voteAddValidator(req.params.validator) - sendVote(query, req, res) +async function voteAddValidator(req, res) { + if (ethers.utils.isHexString(req.params.validator, 20)) { + logger.info('Voting for adding new validator') + const epoch = await bridge.epoch() + const message = buildMessage( + Action.VOTE_ADD_VALIDATOR, + epoch, + req.params.validator, + padZeros(req.attempt, 18) + ) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') + } } -async function voteChangeThreshold (req, res) { - logger.info('Voting for changing threshold') - const query = bridge.methods.voteChangeThreshold(req.params.threshold) - sendVote(query, req, res) +async function voteChangeThreshold(req, res) { + if (/^[0-9]+$/.test(req.params.threshold)) { + logger.info('Voting for changing threshold') + const epoch = await bridge.epoch() + const message = buildMessage( + Action.VOTE_CHANGE_THRESHOLD, + epoch, + parseInt(req.params.threshold, 10), + padZeros(req.attempt, 54) + ) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') + } } -async function voteRemoveValidator (req, res) { - logger.info('Voting for removing validator') - const query = bridge.methods.voteRemoveValidator(req.params.validator) - sendVote(query, req, res, true) +async function voteChangeRangeSize(req, res) { + if (/^[0-9]+$/.test(req.params.rangeSize)) { + logger.info('Voting for changing range size') + const epoch = await bridge.epoch() + const message = buildMessage( + Action.VOTE_CHANGE_RANGE_SIZE, + epoch, + parseInt(req.params.rangeSize, 10), + padZeros(req.attempt, 54) + ) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') + } } -function decodeStatus (status) { - switch (status) { - case 0: - return 'ready' - case 1: - return 'voting' - case 2: - return 'keygen' - case 3: - return 'funds_transfer' +async function voteChangeCloseEpoch(req, res) { + if (req.params.closeEpoch === 'true' || req.params.closeEpoch === 'false') { + logger.info('Voting for changing close epoch') + const epoch = await bridge.epoch() + const message = buildMessage( + Action.VOTE_CHANGE_CLOSE_EPOCH, + epoch, + req.params.closeEpoch === 'true', + padZeros(req.attempt, 56) + ) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') } } +async function voteRemoveValidator(req, res) { + if (ethers.utils.isHexString(req.params.validator, 20)) { + logger.info('Voting for removing validator') + const epoch = await bridge.epoch() + const message = buildMessage( + Action.VOTE_REMOVE_VALIDATOR, + epoch, + req.params.validator, + padZeros(req.attempt, 18) + ) + await processMessage(message) + res.send('Voted\n') + logger.info('Voted successfully') + } +} -function boundX(x) { - try { - return x.toNumber() - } catch (e) { - return -1 +async function transfer(req, res) { + logger.info('Transfer start') + const { + hash, to, value, epoch + } = req.body + if (ethers.utils.isHexString(to, 20)) { + logger.info(`Calling transfer to ${to}, 0x${value} tokens`) + const message = buildMessage(Action.TRANSFER, epoch, hash, to, padZeros(value, 24)) + logger.info(`Message for sign: ${message.toString('hex')}`) + await processMessage(message) } + res.send() + logger.info('Transfer end') } -async function info (req, res) { +function getForeignBalances(address) { + return httpClient + .get(`/api/v1/account/${address}`) + .then((res) => res.data.balances.reduce((prev, cur) => { + // eslint-disable-next-line no-param-reassign + prev[cur.symbol] = cur.free + return prev + }, {})) + .catch(() => ({})) +} + +async function info(req, res) { logger.debug('Info start') try { - const [ x, y, epoch, rangeSize, nextRangeSize, epochStartBlock, foreignNonce, nextEpoch, threshold, nextThreshold, validators, nextValidators, status, homeBalance ] = await Promise.all([ - bridge.methods.getX().call().then(x => new BN(x).toString(16)), - bridge.methods.getY().call().then(x => new BN(x).toString(16)), - bridge.methods.epoch().call().then(x => x.toNumber()), - bridge.methods.getRangeSize().call().then(x => x.toNumber()), - bridge.methods.getNextRangeSize().call().then(x => x.toNumber()), - bridge.methods.getStartBlock().call().then(x => x.toNumber()), - bridge.methods.getNonce().call().then(boundX), - bridge.methods.nextEpoch().call().then(x => x.toNumber()), - bridge.methods.getThreshold().call().then(x => x.toNumber()), - bridge.methods.getNextThreshold().call().then(x => x.toNumber()), - bridge.methods.getValidators().call(), - bridge.methods.getNextValidators().call(), - bridge.methods.status().call(), - token.methods.balanceOf(HOME_BRIDGE_ADDRESS).call().then(x => parseFloat(new BN(x).dividedBy(10 ** 18).toFixed(8, 3))) - ]) - const [ confirmationsForFundsTransfer, votesForVoting, votesForKeygen, votesForCancelKeygen ] = await Promise.all([ - bridge.methods.votesCount(homeWeb3.utils.sha3(utils.solidityPack([ 'uint8', 'uint256' ], [ 1, nextEpoch ]))).call().then(boundX), - bridge.methods.votesCount(homeWeb3.utils.sha3(utils.solidityPack([ 'uint8', 'uint256' ], [ 2, nextEpoch ]))).call().then(boundX), - bridge.methods.votesCount(homeWeb3.utils.sha3(utils.solidityPack([ 'uint8', 'uint256' ], [ 7, nextEpoch ]))).call().then(boundX), - bridge.methods.votesCount(homeWeb3.utils.sha3(utils.solidityPack([ 'uint8', 'uint256' ], [ 8, nextEpoch ]))).call().then(boundX) + const [ + x, y, epoch, rangeSize, nextRangeSize, closeEpoch, nextCloseEpoch, epochStartBlock, + foreignNonce, nextEpoch, threshold, nextThreshold, validators, nextValidators, bridgeStatus, + homeBalance + ] = await Promise.all([ + bridge.getX().then((value) => new BN(value).toString(16)), + bridge.getY().then((value) => new BN(value).toString(16)), + bridge.epoch(), + bridge.getRangeSize(), + bridge.getNextRangeSize(), + bridge.getCloseEpoch(), + bridge.getNextCloseEpoch(), + bridge.getStartBlock(), + bridge.getNonce(), + bridge.nextEpoch(), + bridge.getThreshold(), + bridge.getNextThreshold(), + bridge.getValidators(), + bridge.getNextValidators(), + bridge.status(), + token.balanceOf(HOME_BRIDGE_ADDRESS) + .then((value) => parseFloat(new BN(value).dividedBy(10 ** 18).toFixed(8, 3))) ]) - const foreignAddress = publicKeyToAddress({ x, y }) + const foreignAddress = publicKeyToAddress({ + x, + y + }) const balances = await getForeignBalances(foreignAddress) - res.send({ + const msg = { epoch, rangeSize, nextRangeSize, @@ -344,6 +444,8 @@ async function info (req, res) { nextEpoch, threshold, nextThreshold, + closeEpoch, + nextCloseEpoch, homeBridgeAddress: HOME_BRIDGE_ADDRESS, foreignBridgeAddress: foreignAddress, foreignNonce, @@ -351,37 +453,70 @@ async function info (req, res) { nextValidators, homeBalance, foreignBalanceTokens: parseFloat(balances[FOREIGN_ASSET]) || 0, - foreignBalanceNative: parseFloat(balances['BNB']) || 0, - bridgeStatus: decodeStatus(status), - votesForVoting, - votesForKeygen, - votesForCancelKeygen, - confirmationsForFundsTransfer - }) + foreignBalanceNative: parseFloat(balances.BNB) || 0, + bridgeStatus: decodeStatus(bridgeStatus) + } + logger.trace('%o', msg) + res.send(msg) } catch (e) { - res.send({ message: 'Something went wrong, resend request', error: e }) + logger.debug('%o', e) + res.send({ + message: 'Something went wrong, resend request', + error: e + }) } logger.debug('Info end') } -async function transfer (req, res) { - logger.info('Transfer start') - const { hash, to, value } = req.body - if (homeWeb3.utils.isAddress(to)) { - logger.info(`Calling transfer to ${to}, ${value} tokens`) - const query = bridge.methods.transfer(hash, to, '0x' + (new BN(value).toString(16))) - await homeSendQuery(query) +app.get('/status', status) + +app.post('/get', get) +app.post('/set', set) +app.post('/signupkeygen', signupKeygen) +app.post('/signupsign', signupSign) + +app.post('/confirmKeygen', confirmKeygen) +app.post('/confirmFundsTransfer', confirmFundsTransfer) +app.post('/confirmCloseEpoch', confirmCloseEpoch) +app.post('/transfer', transfer) + +votesProxyApp.get('/vote/startVoting', voteStartVoting) +votesProxyApp.get('/vote/startKeygen', voteStartKeygen) +votesProxyApp.get('/vote/cancelKeygen', voteCancelKeygen) + +votesProxyApp.use('/vote', (req, res, next) => { + if (/^[0-9]+$/.test(req.query.attempt)) { + req.attempt = parseInt(req.query.attempt, 10).toString(16) + logger.debug(`Vote attempt 0x${req.attempt}`) + next() + } else if (!req.query.attempt) { + req.attempt = '0' + logger.debug('Vote attempt 0x00') + next() } - res.send() - logger.info('Transfer end') -} +}) -function getForeignBalances (address) { - return httpClient - .get(`/api/v1/account/${address}`) - .then(res => res.data.balances.reduce((prev, cur) => { - prev[cur.symbol] = cur.free - return prev - }, {})) - .catch(err => ({})) +votesProxyApp.get('/vote/addValidator/:validator', voteAddValidator) +votesProxyApp.get('/vote/removeValidator/:validator', voteRemoveValidator) +votesProxyApp.get('/vote/changeThreshold/:threshold', voteChangeThreshold) +votesProxyApp.get('/vote/changeRangeSize/:rangeSize', voteChangeRangeSize) +votesProxyApp.get('/vote/changeCloseEpoch/:closeEpoch', voteChangeCloseEpoch) +votesProxyApp.get('/info', info) + +async function main() { + sideValidatorNonce = await sideWallet.getTransactionCount() + + sideSender = await createSender(SIDE_RPC_URL, VALIDATOR_PRIVATE_KEY) + + logger.warn(`My validator address in home and side networks is ${validatorAddress}`) + + app.listen(8001, () => { + logger.debug('Proxy is listening on port 8001') + }) + + votesProxyApp.listen(8002, () => { + logger.debug('Votes proxy is listening on port 8002') + }) } + +main() diff --git a/src/oracle/proxy/package.json b/src/oracle/proxy/package.json index d941190..33c7e10 100644 --- a/src/oracle/proxy/package.json +++ b/src/oracle/proxy/package.json @@ -2,7 +2,6 @@ "name": "proxy", "version": "0.0.1", "dependencies": { - "web3": "1.0.0-beta.55", "bech32": "1.1.3", "express": "4.17.1", "async-lock": "1.2.0", @@ -12,5 +11,8 @@ "ethers": "4.0.37", "pino": "5.13.4", "pino-pretty": "3.2.1" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/oracle/proxy/sendTx.js b/src/oracle/proxy/sendTx.js index aa6b1d5..f73adf3 100644 --- a/src/oracle/proxy/sendTx.js +++ b/src/oracle/proxy/sendTx.js @@ -1,34 +1,31 @@ -const Web3 = require('web3') const axios = require('axios') const ethers = require('ethers') const BN = require('bignumber.js') const logger = require('./logger') +const { delay, retry } = require('./wait') const { GAS_LIMIT_FACTOR, MAX_GAS_LIMIT } = process.env -function sendRpcRequest (url, method, params) { - return axios.post(url, { +async function sendRpcRequest(url, method, params) { + logger.trace(`Request to ${url}, method ${method}, params %o`, params) + const response = await retry(() => axios.post(url, { jsonrpc: '2.0', method, params, id: 1 - }) - .then(res => res.data) - .catch(async e => { - logger.warn(`Request to ${url}, method ${method} failed, retrying`) - await new Promise(res => setTimeout(res, 1000)) - return sendRpcRequest(url, method, params) - }) + })) + logger.trace('Response %o', response.data) + return response.data } -async function createSender (url, privateKey) { - const web3 = new Web3(url, null, { transactionConfirmationBlocks: 1 }) - const signer = new ethers.utils.SigningKey(privateKey) +async function createSender(url, privateKey) { + const provider = new ethers.providers.JsonRpcProvider(url) + const wallet = new ethers.Wallet(privateKey, provider) - const chainId = await web3.eth.net.getId() - return async function (tx) { - tx = { + const { chainId } = await provider.getNetwork() + return async function send(tx) { + const newTx = { data: tx.data, to: tx.to, nonce: tx.nonce, @@ -38,29 +35,30 @@ async function createSender (url, privateKey) { } try { - logger.trace(`Preparing and sending transaction %o on ${url}`, tx) - const estimate = await sendRpcRequest(url, 'eth_estimateGas', [ { - from: signer.address, - to: tx.to, - data: tx.data, - gasPrice: tx.gasPrice, - value: tx.value, + logger.trace(`Preparing and sending transaction %o on ${url}`, newTx) + const estimate = await sendRpcRequest(url, 'eth_estimateGas', [{ + from: wallet.address, + to: newTx.to, + data: newTx.data, + gasPrice: newTx.gasPrice, + value: newTx.value, gas: `0x${new BN(MAX_GAS_LIMIT).toString(16)}` - } ]) + }]) if (estimate.error) { - logger.debug('Gas estimate failed %o', estimate.error) - return false + logger.debug('Gas estimate failed %o, skipping tx, reverting nonce', estimate.error) + return true } - const gasLimit = BN.min(new BN(estimate.result, 16).multipliedBy(GAS_LIMIT_FACTOR), MAX_GAS_LIMIT) - tx.gasLimit = `0x${new BN(gasLimit).toString(16)}` + const gasLimit = BN.min( + new BN(estimate.result, 16).multipliedBy(GAS_LIMIT_FACTOR), + MAX_GAS_LIMIT + ) + newTx.gasLimit = `0x${new BN(gasLimit).toString(16)}` logger.trace(`Estimated gas to ${gasLimit}`) - const hash = web3.utils.sha3(ethers.utils.serializeTransaction(tx)) - const signature = signer.signDigest(hash) - const signedTx = ethers.utils.serializeTransaction(tx, signature) + const signedTx = await wallet.sign(newTx) - const { result, error } = await sendRpcRequest(url, 'eth_sendRawTransaction', [ signedTx ]) + const { result, error } = await sendRpcRequest(url, 'eth_sendRawTransaction', [signedTx]) // handle nonce error // handle insufficient funds error if (error) { @@ -68,7 +66,10 @@ async function createSender (url, privateKey) { return false } - return { txHash: result, gasLimit: tx.gasLimit } + return { + txHash: result, + gasLimit: newTx.gasLimit + } } catch (e) { logger.warn('Something failed, %o', e) return false @@ -76,16 +77,20 @@ async function createSender (url, privateKey) { } } -async function waitForReceipt (url, txHash) { +async function waitForReceipt(url, txHash) { + const provider = new ethers.providers.JsonRpcProvider(url) while (true) { - const { result, error } = await sendRpcRequest(url, 'eth_getTransactionReceipt', [ txHash ]) + const receipt = await provider.getTransactionReceipt(txHash) - if (result === null || error) { - await new Promise(res => setTimeout(res, 1000)) - } else { - return result + if (receipt) { + return receipt } + + await delay(1000) } } -module.exports = { createSender, waitForReceipt } +module.exports = { + createSender, + waitForReceipt +} diff --git a/src/oracle/proxy/utils.js b/src/oracle/proxy/utils.js new file mode 100644 index 0000000..2ae74d1 --- /dev/null +++ b/src/oracle/proxy/utils.js @@ -0,0 +1,30 @@ +function Ok(data) { + return { Ok: data } +} + +function Err(data) { + return { Err: data } +} + +function decodeStatus(status) { + switch (status) { + case 0: + return 'ready' + case 1: + return 'closing_epoch' + case 2: + return 'voting' + case 3: + return 'keygen' + case 4: + return 'funds_transfer' + default: + return 'unknown_state' + } +} + +module.exports = { + Ok, + Err, + decodeStatus +} diff --git a/src/oracle/redis/Dockerfile b/src/oracle/redis/Dockerfile new file mode 100644 index 0000000..1c50b38 --- /dev/null +++ b/src/oracle/redis/Dockerfile @@ -0,0 +1,5 @@ +FROM redis:5.0.5-alpine + +COPY ./redis/redis.conf /usr/local/etc/redis/ + +CMD ["redis-server", "/usr/local/etc/redis/redis.conf"] diff --git a/src/oracle/configs/redis.conf b/src/oracle/redis/redis.conf similarity index 100% rename from src/oracle/configs/redis.conf rename to src/oracle/redis/redis.conf diff --git a/src/oracle/scripts/.eslintrc b/src/oracle/scripts/.eslintrc new file mode 100644 index 0000000..252c81a --- /dev/null +++ b/src/oracle/scripts/.eslintrc @@ -0,0 +1,8 @@ +{ + "extends": [ + "../../../.eslintrc" + ], + "rules": { + "no-console": 0 + } +} diff --git a/src/oracle/scripts/resetToBlock/.dockerignore b/src/oracle/scripts/resetToBlock/.dockerignore new file mode 100644 index 0000000..4635bd2 --- /dev/null +++ b/src/oracle/scripts/resetToBlock/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +run.sh diff --git a/src/oracle/scripts/resetToBlock/package.json b/src/oracle/scripts/resetToBlock/package.json index f4546c1..3a3d820 100644 --- a/src/oracle/scripts/resetToBlock/package.json +++ b/src/oracle/scripts/resetToBlock/package.json @@ -3,5 +3,8 @@ "version": "0.0.1", "dependencies": { "ioredis": "4.14.1" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/oracle/scripts/resetToBlock/resetToBlock.js b/src/oracle/scripts/resetToBlock/resetToBlock.js index bcbaddf..a7d540d 100644 --- a/src/oracle/scripts/resetToBlock/resetToBlock.js +++ b/src/oracle/scripts/resetToBlock/resetToBlock.js @@ -12,7 +12,7 @@ redis.on('error', () => { }) redis.on('connect', async () => { - await redis.set('homeBlock', parseInt(process.argv[2])) + await redis.set('homeBlock', parseInt(process.argv[2], 10)) await redis.save() redis.disconnect() }) diff --git a/src/oracle/shared/.eslintrc b/src/oracle/shared/.eslintrc new file mode 100644 index 0000000..54d0153 --- /dev/null +++ b/src/oracle/shared/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": [ + "../../../.eslintrc" + ], + "rules": { + "import/no-extraneous-dependencies": 0, + "node/no-extraneous-require": 0 + } +} diff --git a/src/oracle/shared/amqp.js b/src/oracle/shared/amqp.js index 8bc751e..e05c37f 100644 --- a/src/oracle/shared/amqp.js +++ b/src/oracle/shared/amqp.js @@ -1,31 +1,26 @@ const amqp = require('amqplib') const logger = require('./logger') - -function _connectRabbit (url) { - return amqp.connect(url).catch(() => { - logger.debug('Failed to connect to rabbitmqServer, reconnecting') - return new Promise(resolve => - setTimeout(() => resolve(_connectRabbit(url)), 2000) - ) - }) -} +const { retry } = require('./wait') async function connectRabbit(url) { - const connection = await _connectRabbit(url) - return await connection.createChannel() + logger.info('Connecting to RabbitMQ server') + return (await retry(() => amqp.connect(url))).createChannel() } -async function assertQueue (channel, name) { +async function assertQueue(channel, name) { const queue = await channel.assertQueue(name) return { name: queue.queue, - send: msg => channel.sendToQueue(queue.queue, Buffer.from(JSON.stringify(msg)), { + send: (msg) => channel.sendToQueue(queue.queue, Buffer.from(JSON.stringify(msg)), { persistent: true }), - get: consumer => channel.get(queue.queue, consumer), - consume: consumer => channel.consume(queue.queue, consumer) + get: (consumer) => channel.get(queue.queue, consumer), + consume: (consumer) => channel.consume(queue.queue, consumer) } } -module.exports = { connectRabbit, assertQueue } +module.exports = { + connectRabbit, + assertQueue +} diff --git a/src/oracle/shared/crypto.js b/src/oracle/shared/crypto.js index 16c0fd8..358e61c 100644 --- a/src/oracle/shared/crypto.js +++ b/src/oracle/shared/crypto.js @@ -1,26 +1,36 @@ const crypto = require('crypto') const bech32 = require('bech32') -function publicKeyToAddress ({ x, y }) { - const compact = (parseInt(y[y.length - 1], 16) % 2 ? '03' : '02') + padZeros(x, 64) - const sha256Hash = sha256(Buffer.from(compact, 'hex')) - const hash = ripemd160(Buffer.from(sha256Hash, 'hex')) - const words = bech32.toWords(Buffer.from(hash, 'hex')) - return bech32.encode('tbnb', words) +function padZeros(s, len) { + while (s.length < len) { + // eslint-disable-next-line no-param-reassign + s = `0${s}` + } + return s } -function padZeros (s, len) { - while (s.length < len) - s = '0' + s - return s +function sha256(bytes) { + return crypto.createHash('sha256') + .update(bytes) + .digest('hex') } -function sha256 (bytes) { - return crypto.createHash('sha256').update(bytes).digest('hex') +function ripemd160(bytes) { + return crypto.createHash('ripemd160') + .update(bytes) + .digest('hex') } -function ripemd160 (bytes) { - return crypto.createHash('ripemd160').update(bytes).digest('hex') +function publicKeyToAddress({ x, y }) { + const compact = (parseInt(y[y.length - 1], 16) % 2 ? '03' : '02') + padZeros(x, 64) + const sha256Hash = sha256(Buffer.from(compact, 'hex')) + const hash = ripemd160(Buffer.from(sha256Hash, 'hex')) + const words = bech32.toWords(Buffer.from(hash, 'hex')) + return bech32.encode('tbnb', words) } -module.exports = { publicKeyToAddress, padZeros, sha256 } +module.exports = { + publicKeyToAddress, + padZeros, + sha256 +} diff --git a/src/oracle/shared/db.js b/src/oracle/shared/db.js index a6732f7..1faf6fc 100644 --- a/src/oracle/shared/db.js +++ b/src/oracle/shared/db.js @@ -1,6 +1,7 @@ const Redis = require('ioredis') const logger = require('./logger') + logger.info('Connecting to redis') const redis = new Redis({ @@ -14,7 +15,7 @@ redis.on('connect', () => { logger.info('Connected to redis') }) -redis.on('error', e => { +redis.on('error', (e) => { logger.warn('Redis error %o', e) }) diff --git a/src/oracle/shared/wait.js b/src/oracle/shared/wait.js new file mode 100644 index 0000000..f5c02c0 --- /dev/null +++ b/src/oracle/shared/wait.js @@ -0,0 +1,24 @@ +const logger = require('./logger') + +async function delay(ms) { + await new Promise((res) => setTimeout(res, ms)) +} + +async function retry(getPromise, n = -1, sleep = 3000) { + while (n) { + try { + return await getPromise() + } catch (e) { + logger.debug(`Promise failed, retrying, ${n - 1} attempts left`) + await delay(sleep) + // eslint-disable-next-line no-param-reassign + n -= 1 + } + } + return null +} + +module.exports = { + delay, + retry +} diff --git a/src/oracle/tss-keygen/Dockerfile b/src/oracle/tss-keygen/Dockerfile index 72ed8ca..fd34ce2 100644 --- a/src/oracle/tss-keygen/Dockerfile +++ b/src/oracle/tss-keygen/Dockerfile @@ -9,7 +9,7 @@ COPY ./tss-keygen/package.json /tss/ RUN npm install -COPY ./tss-keygen/keygen-entrypoint.sh ./tss-keygen/keygen.js ./shared/logger.js ./shared/amqp.js ./shared/crypto.js /tss/ +COPY ./tss-keygen/keygen-entrypoint.sh ./tss-keygen/keygen.js ./shared/logger.js ./shared/amqp.js ./shared/crypto.js ./shared/wait.js /tss/ COPY --from=tss /tss/target/release/gg18_keygen_client /tss/ diff --git a/src/oracle/tss-keygen/keygen.js b/src/oracle/tss-keygen/keygen.js index 77dfc80..18fcfc4 100644 --- a/src/oracle/tss-keygen/keygen.js +++ b/src/oracle/tss-keygen/keygen.js @@ -1,79 +1,161 @@ const exec = require('child_process') const fs = require('fs') const express = require('express') +const axios = require('axios') const logger = require('./logger') const { connectRabbit, assertQueue } = require('./amqp') const { publicKeyToAddress } = require('./crypto') +const { delay } = require('./wait') const { RABBITMQ_URL, PROXY_URL } = process.env +const KEYGEN_ATTEMPT_TIMEOUT = parseInt(process.env.KEYGEN_ATTEMPT_TIMEOUT, 10) +const KEYGEN_EPOCH_CHECK_INTERVAL = parseInt(process.env.KEYGEN_EPOCH_CHECK_INTERVAL, 10) + +const KEYGEN_OK = 0 +const KEYGEN_EPOCH_INTERRUPT = 1 +const KEYGEN_FAILED = 2 const app = express() -app.get('/start', (req, res) => { - logger.info('Ready to start') - ready = true - res.send() -}) -app.listen(8001, () => logger.debug('Listening on 8001')) +const proxyClient = axios.create({ baseURL: PROXY_URL }) + +let channel let currentKeygenEpoch = null let ready = false -async function main () { - logger.info('Connecting to RabbitMQ server') - const channel = await connectRabbit(RABBITMQ_URL) - logger.info('Connecting to epoch events queue') - const keygenQueue = await assertQueue(channel, 'keygenQueue') - const cancelKeygenQueue = await assertQueue(channel, 'cancelKeygenQueue') +async function confirmKeygen({ x, y }, epoch) { + await proxyClient.post('/confirmKeygen', { + x, + y, + epoch + }) +} - while (!ready) { - await new Promise(res => setTimeout(res, 1000)) - } +function writeParams(parties, threshold) { + logger.debug('Writing params') + fs.writeFileSync('./params', JSON.stringify({ + parties: parties.toString(), + threshold: (threshold - 1).toString() + })) +} - channel.prefetch(1) - keygenQueue.consume(msg => { - const { epoch, parties, threshold } = JSON.parse(msg.content) - logger.info(`Consumed new epoch event, starting keygen for epoch ${epoch}`) +function killKeygen() { + exec.execSync('pkill gg18_keygen || true') +} - const keysFile = `/keys/keys${epoch}.store` +function restart(req, res) { + logger.info('Manual cancelling current keygen attempt') + killKeygen() + res.send('Done') +} - logger.info('Running ./keygen-entrypoint.sh') - currentKeygenEpoch = epoch +function keygen(keysFile, epoch) { + let restartTimeoutId + let epochDaemonIntervalId + let epochInterrupt - logger.debug('Writing params') - fs.writeFileSync('./params', JSON.stringify({ parties: parties.toString(), threshold: threshold.toString() })) - const cmd = exec.execFile('./keygen-entrypoint.sh', [ PROXY_URL, keysFile ], async () => { + return new Promise((resolve) => { + const cmd = exec.execFile('./keygen-entrypoint.sh', [PROXY_URL, keysFile], (error) => { + logger.trace('Keygen entrypoint exited, %o', error) + clearTimeout(restartTimeoutId) + clearInterval(epochDaemonIntervalId) currentKeygenEpoch = null if (fs.existsSync(keysFile)) { logger.info(`Finished keygen for epoch ${epoch}`) - const publicKey = JSON.parse(fs.readFileSync(keysFile))[5] - logger.warn(`Generated multisig account in binance chain: ${publicKeyToAddress(publicKey)}`) - - logger.info('Sending keys confirmation') - await confirmKeygen(keysFile) + resolve(KEYGEN_OK) } else { - logger.warn(`Keygen for epoch ${epoch} failed`) + logger.warn(`Keygen for epoch ${epoch} failed, will start new attempt`) + resolve(epochInterrupt ? KEYGEN_EPOCH_INTERRUPT : KEYGEN_FAILED) } - logger.debug('Ack for keygen message') - channel.ack(msg) }) - cmd.stdout.on('data', data => logger.debug(data.toString())) - cmd.stderr.on('data', data => logger.debug(data.toString())) + cmd.stdout.on('data', (data) => { + const str = data.toString() + if (str.includes('Got all party signups')) { + restartTimeoutId = setTimeout(killKeygen, KEYGEN_ATTEMPT_TIMEOUT) + } + logger.debug(str) + }) + cmd.stderr.on('data', (data) => logger.debug(data.toString())) + + // Kill keygen if keygen for current epoch is already confirmed + epochDaemonIntervalId = setInterval(async () => { + logger.info(`Checking if bridge has confirmations keygen for epoch ${epoch}`) + const { bridgeEpoch, bridgeStatus } = (await proxyClient.get('/status')).data + logger.trace(`Current bridge epoch: ${bridgeEpoch}, current bridge status: ${bridgeStatus}`) + if (bridgeEpoch > epoch || bridgeStatus > 3) { + logger.info(`Bridge has already confirmed keygen for epoch ${epoch}`) + epochInterrupt = true + // Additional delay, maybe keygen will eventually finish + await delay(5000) + killKeygen() + } + }, KEYGEN_EPOCH_CHECK_INTERVAL) }) +} + +async function keygenConsumer(msg) { + const { epoch, parties, threshold } = JSON.parse(msg.content) + logger.info(`Consumed new epoch event, starting keygen for epoch ${epoch}`) + + const keysFile = `/keys/keys${epoch}.store` - cancelKeygenQueue.consume(async msg => { + logger.info('Running ./keygen-entrypoint.sh') + currentKeygenEpoch = epoch + + writeParams(parties, threshold) + + while (true) { + const keygenResult = await keygen(keysFile, epoch) + + if (keygenResult === KEYGEN_OK) { + const publicKey = JSON.parse(fs.readFileSync(keysFile))[5] + logger.warn(`Generated multisig account in binance chain: ${publicKeyToAddress(publicKey)}`) + + logger.info('Sending keys confirmation') + await confirmKeygen(publicKey, epoch) + break + } else if (keygenResult === KEYGEN_EPOCH_INTERRUPT) { + logger.warn('Keygen was interrupted by epoch daemon') + break + } + + await delay(1000) + } + logger.info('Acking message') + channel.ack(msg) +} + +async function main() { + channel = await connectRabbit(RABBITMQ_URL) + logger.info('Connecting to epoch events queue') + const keygenQueue = await assertQueue(channel, 'keygenQueue') + const cancelKeygenQueue = await assertQueue(channel, 'cancelKeygenQueue') + + while (!ready) { + await delay(1000) + } + + channel.prefetch(1) + keygenQueue.consume(keygenConsumer) + + cancelKeygenQueue.consume(async (msg) => { const { epoch } = JSON.parse(msg.content) logger.info(`Consumed new cancel event for epoch ${epoch} keygen`) if (currentKeygenEpoch === epoch) { logger.info('Cancelling current keygen') - exec.execSync('pkill gg18_keygen || true') + killKeygen() } channel.ack(msg) }) } -main() +app.get('/restart', restart) +app.get('/start', (req, res) => { + logger.info('Ready to start') + ready = true + res.send() +}) +app.listen(8001, () => logger.debug('Listening on 8001')) -async function confirmKeygen (keysFile) { - exec.execSync(`curl -X POST -H "Content-Type: application/json" -d @"${keysFile}" "${PROXY_URL}/confirmKeygen"`, { stdio: 'pipe' }) -} +main() diff --git a/src/oracle/tss-keygen/package.json b/src/oracle/tss-keygen/package.json index 64c6c24..fb1d8db 100644 --- a/src/oracle/tss-keygen/package.json +++ b/src/oracle/tss-keygen/package.json @@ -3,9 +3,13 @@ "version": "0.0.1", "dependencies": { "amqplib": "0.5.3", + "axios": "0.19.0", "bech32": "1.1.3", "pino": "5.13.4", "pino-pretty": "3.2.1", "express": "4.17.1" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/oracle/tss-sign/Dockerfile b/src/oracle/tss-sign/Dockerfile index 4d53236..0b14ac5 100644 --- a/src/oracle/tss-sign/Dockerfile +++ b/src/oracle/tss-sign/Dockerfile @@ -10,7 +10,7 @@ COPY ./tss-sign/package.json /tss/ RUN npm install --no-optional -COPY ./tss-sign/sign-entrypoint.sh ./tss-sign/signer.js ./tss-sign/tx.js ./shared/logger.js ./shared/amqp.js ./shared/crypto.js /tss/ +COPY ./tss-sign/sign-entrypoint.sh ./tss-sign/signer.js ./tss-sign/tx.js ./shared/logger.js ./shared/amqp.js ./shared/crypto.js ./shared/wait.js /tss/ COPY --from=tss /tss/target/release/gg18_sign_client /tss/ diff --git a/src/oracle/tss-sign/package.json b/src/oracle/tss-sign/package.json index 141a555..7d0c822 100644 --- a/src/oracle/tss-sign/package.json +++ b/src/oracle/tss-sign/package.json @@ -9,5 +9,8 @@ "express": "4.17.1", "pino": "5.13.4", "pino-pretty": "3.2.1" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/oracle/tss-sign/signer.js b/src/oracle/tss-sign/signer.js index 5077e6a..b7e0d14 100644 --- a/src/oracle/tss-sign/signer.js +++ b/src/oracle/tss-sign/signer.js @@ -1,145 +1,41 @@ const exec = require('child_process') const fs = require('fs') const BN = require('bignumber.js') +const axios = require('axios') const express = require('express') const logger = require('./logger') const { connectRabbit, assertQueue } = require('./amqp') const { publicKeyToAddress, sha256 } = require('./crypto') +const { delay, retry } = require('./wait') + +const Transaction = require('./tx') const app = express() -app.get('/restart/:attempt', restart) -app.get('/start', (req, res) => { - logger.info('Ready to start') - ready = true - res.send() -}) -app.listen(8001, () => logger.debug('Listening on 8001')) -const { RABBITMQ_URL, FOREIGN_URL, PROXY_URL, FOREIGN_ASSET } = process.env -const Transaction = require('./tx') -const axios = require('axios') +const { + RABBITMQ_URL, FOREIGN_URL, PROXY_URL, FOREIGN_ASSET +} = process.env +const SIGN_ATTEMPT_TIMEOUT = parseInt(process.env.SIGN_ATTEMPT_TIMEOUT, 10) +const SIGN_NONCE_CHECK_INTERVAL = parseInt(process.env.SIGN_NONCE_CHECK_INTERVAL, 10) +const SEND_TIMEOUT = parseInt(process.env.SEND_TIMEOUT, 10) const httpClient = axios.create({ baseURL: FOREIGN_URL }) +const proxyClient = axios.create({ baseURL: PROXY_URL }) + +const SIGN_OK = 0 +const SIGN_NONCE_INTERRUPT = 1 +const SIGN_FAILED = 2 -let attempt -let nextAttempt = null let cancelled let ready = false let exchangeQueue let channel -async function main () { - logger.info('Connecting to RabbitMQ server') - channel = await connectRabbit(RABBITMQ_URL) - logger.info('Connecting to signature events queue') - exchangeQueue = await assertQueue(channel, 'exchangeQueue') - const signQueue = await assertQueue(channel, 'signQueue') - - while (!ready) { - await new Promise(res => setTimeout(res, 1000)) - } - - channel.prefetch(1) - signQueue.consume(async msg => { - const data = JSON.parse(msg.content) - - logger.info('Consumed sign event: %o', data) - const { nonce, epoch, newEpoch, parties, threshold } = data - - const keysFile = `/keys/keys${epoch}.store` - const { address: from, publicKey } = getAccountFromFile(keysFile) - if (from === '') { - logger.info('No keys found, acking message') - channel.ack(msg) - return - } - const account = await getAccount(from) - - logger.debug('Writing params') - fs.writeFileSync('./params', JSON.stringify({ parties: parties.toString(), threshold: threshold.toString() })) - - attempt = 1 - - if (!newEpoch) { - const exchanges = await getExchangeMessages(nonce) - const exchangesData = exchanges.map(msg => JSON.parse(msg.content)) - - if (exchanges.length > 0 && account.sequence <= nonce) { - const recipients = exchangesData.map(({ value, recipient }) => ({ to: recipient, tokens: value })) - - while (true) { - logger.info(`Building corresponding transfer transaction, nonce ${nonce}`) - - const tx = new Transaction({ - from, - accountNumber: account.account_number, - sequence: nonce, - recipients, - asset: FOREIGN_ASSET, - memo: `Attempt ${attempt}` - }) - - const hash = sha256(tx.getSignBytes()) - logger.info(`Starting signature generation for transaction hash ${hash}`) - const done = await sign(keysFile, hash, tx, publicKey) && await waitForAccountNonce(from, nonce + 1) - - if (done) { - exchanges.forEach(msg => channel.ack(msg)) - break - } - attempt = nextAttempt ? nextAttempt : attempt + 1 - logger.warn(`Sign failed, starting next attempt ${attempt}`) - nextAttempt = null - await new Promise(resolve => setTimeout(resolve, 1000)) - } - } - } else if (account.sequence <= nonce) { - const newKeysFile = `/keys/keys${newEpoch}.store` - const { address: to } = getAccountFromFile(newKeysFile) - - while (to !== '') { - logger.info(`Building corresponding transaction for transferring all funds, nonce ${nonce}, recipient ${to}`) - const tx = new Transaction({ - from, - accountNumber: account.account_number, - sequence: nonce, - recipients: [ { - to, - tokens: account.balances.find(x => x.symbol === FOREIGN_ASSET).free, - bnbs: new BN(account.balances.find(x => x.symbol === 'BNB').free).minus(new BN(60000).div(10 ** 8)), - } ], - asset: FOREIGN_ASSET, - memo: `Attempt ${attempt}` - }) - - const hash = sha256(tx.getSignBytes()) - logger.info(`Starting signature generation for transaction hash ${hash}`) - const done = await sign(keysFile, hash, tx, publicKey) && await waitForAccountNonce(from, nonce + 1) - - if (done) { - await confirmFundsTransfer() - break - } - attempt = nextAttempt ? nextAttempt : attempt + 1 - logger.warn(`Sign failed, starting next attempt ${attempt}`) - nextAttempt = null - await new Promise(resolve => setTimeout(resolve, 1000)) - } - } else { - logger.debug('Tx has been already sent') - } - logger.info('Acking message') - channel.ack(msg) - }) -} - -main() - -async function getExchangeMessages (nonce) { +async function getExchangeMessages(nonce) { logger.debug('Getting exchange messages') const messages = [] - do { + while (true) { const msg = await exchangeQueue.get() if (msg === false) { break @@ -151,51 +47,35 @@ async function getExchangeMessages (nonce) { break } messages.push(msg) - } while (true) + } logger.debug(`Found ${messages.length} messages`) return messages } -function sign (keysFile, hash, tx, publicKey) { - return new Promise(resolve => { - const cmd = exec.execFile('./sign-entrypoint.sh', [ PROXY_URL, keysFile, hash ], async (error) => { - if (fs.existsSync('signature')) { - logger.info('Finished signature generation') - const signature = JSON.parse(fs.readFileSync('signature')) - logger.debug('%o', signature) - - logger.info('Building signed transaction') - const signedTx = tx.addSignature(publicKey, { r: signature[1], s: signature[3] }) - - logger.info('Sending transaction') - logger.debug(signedTx) - await sendTx(signedTx) - resolve(true) - } else if (error === null || error.code === 0) { - resolve(true) - } else { - logger.warn('Sign failed') - resolve(false) - } - }) - cmd.stdout.on('data', data => logger.debug(data.toString())) - cmd.stderr.on('data', data => logger.debug(data.toString())) - }) +function killSigner() { + exec.execSync('pkill gg18_sign || true') } -function restart (req, res) { - logger.info('Cancelling current sign') - nextAttempt = req.params.attempt - exec.execSync('pkill gg18_sign || true') +function restart(req, res) { + logger.info('Manual cancelling current sign attempt') + killSigner() cancelled = true - res.send('Cancelled') + res.send('Done') } -function confirmFundsTransfer () { - exec.execSync(`curl -X POST -H "Content-Type: application/json" "${PROXY_URL}/confirmFundsTransfer"`, { stdio: 'pipe' }) +async function confirmFundsTransfer(epoch) { + await proxyClient.post('/confirmFundsTransfer', { + epoch + }) } -function getAccountFromFile (file) { +async function confirmCloseEpoch(epoch) { + await proxyClient.post('/confirmCloseEpoch', { + epoch + }) +} + +function getAccountFromFile(file) { logger.debug(`Reading ${file}`) if (!fs.existsSync(file)) { logger.debug('No keys found, skipping') @@ -204,48 +84,272 @@ function getAccountFromFile (file) { const publicKey = JSON.parse(fs.readFileSync(file))[5] return { address: publicKeyToAddress(publicKey), - publicKey: publicKey + publicKey } } -async function waitForAccountNonce (address, nonce) { +async function getAccount(address) { + logger.info(`Getting account ${address} data`) + const response = await retry(() => httpClient.get(`/api/v1/account/${address}`)) + return response.data +} + +async function getFee() { + logger.info('Getting fees') + const response = await retry(() => httpClient.get('/api/v1/fees')) + const multiTransferFee = response.data.find((fee) => fee.multi_transfer_fee).multi_transfer_fee + return new BN(multiTransferFee * 2).div(10 ** 8) +} + +async function waitForAccountNonce(address, nonce) { cancelled = false logger.info(`Waiting for account ${address} to have nonce ${nonce}`) while (!cancelled) { - const sequence = (await getAccount(address)).sequence - if (sequence >= nonce) + const { sequence } = await getAccount(address) + if (sequence >= nonce) { break - await new Promise(resolve => setTimeout(resolve, 1000)) + } + await delay(1000) logger.debug('Waiting for needed account nonce') } logger.info('Account nonce is OK') return !cancelled } -function getAccount (address) { - logger.info(`Getting account ${address} data`) - return httpClient - .get(`/api/v1/account/${address}`) - .then(res => res.data) - .catch(() => { - logger.debug('Retrying') - return getAccount(address) - }) +async function sendTx(tx) { + while (true) { + try { + return await httpClient.post('/api/v1/broadcast?sync=true', tx, { + headers: { + 'Content-Type': 'text/plain' + } + }) + } catch (err) { + logger.trace('Error, response data %o', err.response.data) + if (err.response.data.message.includes('Tx already exists in cache')) { + logger.debug('Tx already exists in cache') + return true + } + if (err.response.data.message.includes(' < ')) { + logger.warn('Insufficient funds, waiting for funds') + await delay(60000) + } else { + logger.info('Something failed, restarting: %o', err.response) + await delay(10000) + } + } + } } -function sendTx (tx) { - return httpClient - .post(`/api/v1/broadcast?sync=true`, tx, { - headers: { - 'Content-Type': 'text/plain' +function sign(keysFile, tx, publicKey, signerAddress) { + let restartTimeoutId + let nonceDaemonIntervalId + let nonceInterrupt = false + + const hash = sha256(tx.getSignBytes()) + logger.info(`Starting signature generation for transaction hash ${hash}`) + + return new Promise((resolve) => { + const cmd = exec.execFile('./sign-entrypoint.sh', [PROXY_URL, keysFile, hash], async (error) => { + logger.trace('Sign entrypoint exited, %o', error) + clearInterval(nonceDaemonIntervalId) + clearTimeout(restartTimeoutId) + if (fs.existsSync('signature')) { // if signature was generated + logger.info('Finished signature generation') + const signature = JSON.parse(fs.readFileSync('signature')) + logger.debug('%o', signature) + + logger.info('Building signed transaction') + const signedTx = tx.addSignature(publicKey, { + r: signature[1], + s: signature[3] + }) + + logger.info('Sending transaction') + logger.debug(signedTx) + await sendTx(signedTx) + // if nonce does not update in some time, cancel process, consider sign as failed + const sendTimeoutId = setTimeout(() => { + cancelled = true + }, SEND_TIMEOUT) + const waitResponse = await waitForAccountNonce(signerAddress, tx.tx.sequence + 1) + clearTimeout(sendTimeoutId) + resolve(waitResponse ? SIGN_OK : SIGN_FAILED) + } else if (error === null || error.code === 0) { // if was already enough parties + const signTimeoutId = setTimeout(() => { + cancelled = true + }, SIGN_ATTEMPT_TIMEOUT) + const waitResponse = await waitForAccountNonce(signerAddress, tx.tx.sequence + 1) + clearTimeout(signTimeoutId) + resolve(waitResponse ? SIGN_OK : SIGN_FAILED) + } else if (error.code === 143) { // if process was killed + logger.warn('Sign process was killed') + resolve(nonceInterrupt ? SIGN_NONCE_INTERRUPT : SIGN_FAILED) + } else if (error.code !== null && error.code !== 0) { // if process has failed + logger.warn('Sign process has failed') + resolve(SIGN_FAILED) + } else { + logger.warn('Unknown error state %o', error) + resolve(SIGN_FAILED) } }) - .catch(err => { - if (err.response.data.message.includes('Tx already exists in cache')) - logger.debug('Tx already exists in cache') - else { - logger.info('Something failed, restarting: %o', err.response) - return new Promise(resolve => setTimeout(() => resolve(sendTx(tx)), 1000)) + cmd.stdout.on('data', (data) => { + const str = data.toString() + if (str.includes('Got all party ids')) { + restartTimeoutId = setTimeout(killSigner, SIGN_ATTEMPT_TIMEOUT) } + logger.debug(str) }) + cmd.stderr.on('data', (data) => logger.debug(data.toString())) + + // Kill signer if current nonce is already processed at some time + nonceDaemonIntervalId = setInterval(async () => { + logger.info(`Checking if account ${signerAddress} has nonce ${tx.tx.sequence + 1}`) + const { sequence } = await getAccount(signerAddress) + if (sequence > tx.tx.sequence) { + logger.info('Account already has needed nonce, cancelling current sign process') + nonceInterrupt = true + // Additional delay, maybe signer will eventually finish + await delay(5000) + killSigner() + } + }, SIGN_NONCE_CHECK_INTERVAL) + }) +} + +function getAccountBalance(account, asset) { + return account.balances.find((token) => token.symbol === asset).free } + +async function buildTx(from, account, data) { + const { closeEpoch, newEpoch, nonce } = data + + const txOptions = { + from, + accountNumber: account.account_number, + sequence: nonce, + asset: FOREIGN_ASSET + } + let exchanges + + if (closeEpoch) { + logger.info(`Building corresponding account flags transaction, nonce ${nonce}`) + + txOptions.flags = 0x01 + } else if (newEpoch) { + const newKeysFile = `/keys/keys${newEpoch}.store` + const to = getAccountFromFile(newKeysFile).address + + if (to === '') { + return { tx: null } + } + + logger.info(`Building corresponding transaction for transferring all funds, nonce ${nonce}, recipient ${to}`) + const fee = await getFee() + + txOptions.recipients = [{ + to, + tokens: getAccountBalance(account, FOREIGN_ASSET), + bnbs: new BN(getAccountBalance(account, 'BNB')).minus(fee) + }] + } else { + logger.info(`Building corresponding transfer transaction, nonce ${nonce}`) + exchanges = await getExchangeMessages(nonce) + const exchangesData = exchanges.map((exchangeMsg) => JSON.parse(exchangeMsg.content)) + + txOptions.recipients = exchangesData.map(({ value, recipient }) => ({ + to: recipient, + tokens: value + })) + } + + const tx = new Transaction(txOptions) + + return { + tx, + exchanges + } +} + +function writeParams(parties, threshold) { + logger.debug('Writing params') + fs.writeFileSync('./params', JSON.stringify({ + parties: parties.toString(), + threshold: (threshold - 1).toString() + })) +} + +async function consumer(msg) { + const data = JSON.parse(msg.content) + + logger.info('Consumed sign event: %o', data) + const { + nonce, epoch, newEpoch, parties, threshold, closeEpoch + } = data + + const keysFile = `/keys/keys${epoch || closeEpoch}.store` + const { address: from, publicKey } = getAccountFromFile(keysFile) + if (from === '') { + logger.info('No keys found, acking message') + channel.ack(msg) + return + } + const account = await getAccount(from) + + if (nonce > account.sequence) { + logger.debug('Tx has been already sent') + logger.info('Acking message (skipped nonce)') + channel.ack(msg) + return + } + + writeParams(parties, threshold) + + const { tx, exchanges } = await buildTx(from, account, data) + + while (tx !== null) { + const signResult = await sign(keysFile, tx, publicKey, from) + + if (signResult === SIGN_OK || signResult === SIGN_NONCE_INTERRUPT) { + if (closeEpoch) { + await confirmCloseEpoch(closeEpoch) + } else if (newEpoch) { + await confirmFundsTransfer(epoch) + } else { + // eslint-disable-next-line no-loop-func + exchanges.forEach((exchangeMsg) => channel.ack(exchangeMsg)) + } + break + } + + logger.warn('Sign failed, starting next attempt') + await delay(1000) + } + logger.info('Acking message') + channel.ack(msg) +} + + +async function main() { + channel = await connectRabbit(RABBITMQ_URL) + logger.info('Connecting to signature events queue') + exchangeQueue = await assertQueue(channel, 'exchangeQueue') + const signQueue = await assertQueue(channel, 'signQueue') + + while (!ready) { + await delay(1000) + } + + channel.prefetch(1) + signQueue.consume(consumer) +} + +app.get('/restart', restart) +app.get('/start', (req, res) => { + logger.info('Ready to start') + ready = true + res.send() +}) +app.listen(8001, () => logger.debug('Listening on 8001')) + +main() diff --git a/src/oracle/tss-sign/tx.js b/src/oracle/tss-sign/tx.js index 351e3a6..032d4e8 100644 --- a/src/oracle/tss-sign/tx.js +++ b/src/oracle/tss-sign/tx.js @@ -10,60 +10,86 @@ const { FOREIGN_CHAIN_ID } = process.env const BNB_ASSET = 'BNB' class Transaction { - constructor (options) { - const { from, accountNumber, sequence, recipients, asset, memo = '' } = options + constructor(options) { + const { + from, accountNumber, sequence, recipients, asset, memo = '', flags + } = options - const totalTokens = recipients.reduce((sum, { tokens }) => sum.plus(new BN(tokens || 0)), new BN(0)) - const totalBnbs = recipients.reduce((sum, { bnbs }) => sum.plus(new BN(bnbs || 0)), new BN(0)) - const senderCoins = [] - if (asset && totalTokens.isGreaterThan(0)) { - senderCoins.push({ - denom: asset, - amount: totalTokens.multipliedBy(10 ** 8).toNumber(), - }) - } - if (totalBnbs.isGreaterThan(0)) { - senderCoins.push({ - denom: BNB_ASSET, - amount: totalBnbs.multipliedBy(10 ** 8).toNumber(), - }) - } - senderCoins.sort((a, b) => a.denom > b.denom) + let msg + if (flags) { + msg = { + from: crypto.decodeAddress(from), + flags, + msgType: 'NewOrderMsg' // until 'SetAccountFlagsMsg' is not available + } - const inputs = [ { - address: from, - coins: senderCoins - } ] - const outputs = recipients.map(({ to, tokens, bnbs }) => { - const receiverCoins = [] - if (asset && tokens) { - receiverCoins.push({ + this.signMsg = { + flags, + from + } + } else { + const totalTokens = recipients.reduce( + (sum, { tokens }) => sum.plus(new BN(tokens || 0)), new BN(0) + ) + const totalBnbs = recipients.reduce( + (sum, { bnbs }) => sum.plus(new BN(bnbs || 0)), new BN(0) + ) + const senderCoins = [] + if (asset && totalTokens.isGreaterThan(0)) { + senderCoins.push({ denom: asset, - amount: new BN(tokens).multipliedBy(10 ** 8).toNumber(), + amount: totalTokens.multipliedBy(10 ** 8).toNumber() }) } - if (bnbs) { - receiverCoins.push({ + if (totalBnbs.isGreaterThan(0)) { + senderCoins.push({ denom: BNB_ASSET, - amount: new BN(bnbs).multipliedBy(10 ** 8).toNumber(), + amount: totalBnbs.multipliedBy(10 ** 8).toNumber() }) } - receiverCoins.sort((a, b) => a.denom > b.denom) - return { - address: to, - coins: receiverCoins - } - }) + senderCoins.sort((a, b) => a.denom > b.denom) - const msg = { - inputs: inputs.map((x) => ({...x, address: crypto.decodeAddress(x.address)})), - outputs: outputs.map((x) => ({...x, address: crypto.decodeAddress(x.address)})), - msgType: 'MsgSend' - } + const inputs = [{ + address: from, + coins: senderCoins + }] + const outputs = recipients.map(({ to, tokens, bnbs }) => { + const receiverCoins = [] + if (asset && tokens) { + receiverCoins.push({ + denom: asset, + amount: new BN(tokens).multipliedBy(10 ** 8).toNumber() + }) + } + if (bnbs) { + receiverCoins.push({ + denom: BNB_ASSET, + amount: new BN(bnbs).multipliedBy(10 ** 8).toNumber() + }) + } + receiverCoins.sort((a, b) => a.denom > b.denom) + return { + address: to, + coins: receiverCoins + } + }) - this.signMsg = { - inputs, - outputs + msg = { + inputs: inputs.map((x) => ({ + ...x, + address: crypto.decodeAddress(x.address) + })), + outputs: outputs.map((x) => ({ + ...x, + address: crypto.decodeAddress(x.address) + })), + msgType: 'MsgSend' + } + + this.signMsg = { + inputs, + outputs + } } this.tx = new TransactionBnc({ @@ -72,30 +98,32 @@ class Transaction { memo, msg, sequence, - type: msg.msgType, + type: msg.msgType }) } - getSignBytes () { + getSignBytes() { return this.tx.getSignBytes(this.signMsg) } - addSignature (publicKey, signature) { + addSignature(publicKey, signature) { const yLast = parseInt(publicKey.y[publicKey.y.length - 1], 16) const n = new BN('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141', 16) const s = new BN(signature.s, 16) if (s.gt(n.div(2))) { logger.debug('Normalizing s') + // eslint-disable-next-line no-param-reassign signature.s = n.minus(s).toString(16) } - const publicKeyEncoded = Buffer.from('eb5ae98721' + (yLast % 2 ? '03' : '02') + padZeros(publicKey.x, 64), 'hex') - this.tx.signatures = [ { + const publicKeyEncoded = Buffer.from(`eb5ae98721${yLast % 2 ? '03' : '02'}${padZeros(publicKey.x, 64)}`, 'hex') + this.tx.signatures = [{ pub_key: publicKeyEncoded, signature: Buffer.from(padZeros(signature.r, 64) + padZeros(signature.s, 64), 'hex'), account_number: this.tx.account_number, - sequence: this.tx.sequence, - } ] + sequence: this.tx.sequence + }] return this.tx.serialize() + .replace(/ce6dc043/, 'bea6e301') // until 'SetAccountFlagsMsg' is not available } } diff --git a/src/test-services/.eslintrc b/src/test-services/.eslintrc new file mode 100644 index 0000000..3703c0a --- /dev/null +++ b/src/test-services/.eslintrc @@ -0,0 +1,8 @@ +{ + "extends": [ + "../../.eslintrc" + ], + "rules": { + "no-console": 0 + } +} diff --git a/src/test-services/.keys.development.example b/src/test-services/.keys.development.example deleted file mode 100644 index 6224ee0..0000000 --- a/src/test-services/.keys.development.example +++ /dev/null @@ -1 +0,0 @@ -FOREIGN_PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000000 diff --git a/src/test-services/binanceBalance/.dockerignore b/src/test-services/binanceBalance/.dockerignore new file mode 100644 index 0000000..4119e2e --- /dev/null +++ b/src/test-services/binanceBalance/.dockerignore @@ -0,0 +1,4 @@ +.dockerignore +Dockerfile +run.sh +.env.* diff --git a/src/test-services/binanceBalance/.env.development b/src/test-services/binanceBalance/.env.development index 4f96a09..b6021c1 100644 --- a/src/test-services/binanceBalance/.env.development +++ b/src/test-services/binanceBalance/.env.development @@ -1,2 +1,2 @@ -FOREIGN_URL=https://testnet-dex.binance.org/ -FOREIGN_ASSET=KFT-94F +FOREIGN_URL=http://http-api:8000 +FOREIGN_ASSET=DEV-9BA diff --git a/src/test-services/binanceBalance/package.json b/src/test-services/binanceBalance/package.json index 993e8f9..c1bf42e 100644 --- a/src/test-services/binanceBalance/package.json +++ b/src/test-services/binanceBalance/package.json @@ -3,5 +3,8 @@ "version": "0.0.1", "dependencies": { "axios": "0.19.0" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/test-services/binanceBalance/run.sh b/src/test-services/binanceBalance/run.sh index ec82b26..35375b0 100755 --- a/src/test-services/binanceBalance/run.sh +++ b/src/test-services/binanceBalance/run.sh @@ -9,4 +9,8 @@ TARGET_NETWORK=${TARGET_NETWORK:=development} docker build -t binance-balance . > /dev/null -docker run --rm --env-file ".env.$TARGET_NETWORK" binance-balance $@ +if [[ "$TARGET_NETWORK" == "development" ]]; then + docker run --rm --network binance_net --env-file ".env.$TARGET_NETWORK" binance-balance $@ +else + docker run --rm --env-file ".env.$TARGET_NETWORK" binance-balance $@ +fi \ No newline at end of file diff --git a/src/test-services/binanceBalance/testGetBinanceBalance.js b/src/test-services/binanceBalance/testGetBinanceBalance.js index 21d6e8d..6d356b0 100644 --- a/src/test-services/binanceBalance/testGetBinanceBalance.js +++ b/src/test-services/binanceBalance/testGetBinanceBalance.js @@ -5,10 +5,14 @@ const { FOREIGN_URL, FOREIGN_ASSET } = process.env const address = process.argv[2] const httpClient = axios.create({ baseURL: FOREIGN_URL }) -httpClient - .get(`/api/v1/account/${address}`) - .then(res => { - console.log(`BNB: ${parseFloat(res.data.balances.find(x => x.symbol === 'BNB').free)}`) - console.log(`${FOREIGN_ASSET}: ${parseFloat(res.data.balances.find(x => x.symbol === FOREIGN_ASSET).free)}`) - }) - .catch(console.log) +function main() { + httpClient + .get(`/api/v1/account/${address}`) + .then((res) => { + console.log(`BNB: ${parseFloat(res.data.balances.find((token) => token.symbol === 'BNB').free)}`) + console.log(`${FOREIGN_ASSET}: ${parseFloat(res.data.balances.find((token) => token.symbol === FOREIGN_ASSET).free)}`) + }) + .catch(console.log) +} + +main() diff --git a/src/test-services/binanceSend/.dockerignore b/src/test-services/binanceSend/.dockerignore new file mode 100644 index 0000000..4119e2e --- /dev/null +++ b/src/test-services/binanceSend/.dockerignore @@ -0,0 +1,4 @@ +.dockerignore +Dockerfile +run.sh +.env.* diff --git a/src/test-services/binanceSend/.env.development b/src/test-services/binanceSend/.env.development index 9660ff3..9de3d9e 100644 --- a/src/test-services/binanceSend/.env.development +++ b/src/test-services/binanceSend/.env.development @@ -1,4 +1,4 @@ -FOREIGN_URL=https://testnet-dex.binance.org/ -FOREIGN_ASSET=KFT-94F +FOREIGN_URL=http://http-api:8000 +FOREIGN_ASSET=DEV-9BA -#FOREIGN_PRIVATE_KEY is taken from src/test-services/.keys.development +FOREIGN_PRIVATE_KEY=dd5ec5a7abe9d1fff21170ae591085f000fc6fd9ca0107fe047593f44e328e40 diff --git a/src/test-services/binanceSend/package.json b/src/test-services/binanceSend/package.json index a7d38dd..c09151a 100644 --- a/src/test-services/binanceSend/package.json +++ b/src/test-services/binanceSend/package.json @@ -3,5 +3,8 @@ "version": "0.0.1", "dependencies": { "@binance-chain/javascript-sdk": "2.14.4" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/test-services/binanceSend/run.sh b/src/test-services/binanceSend/run.sh index e96570c..908a2b4 100755 --- a/src/test-services/binanceSend/run.sh +++ b/src/test-services/binanceSend/run.sh @@ -9,4 +9,8 @@ TARGET_NETWORK=${TARGET_NETWORK:=development} docker build -t binance-send . > /dev/null -docker run --rm --env-file ".env.$TARGET_NETWORK" --env-file "../.keys.$TARGET_NETWORK" -e "PRIVATE_KEY=$PRIVATE_KEY" binance-send $@ +if [[ "$TARGET_NETWORK" == "development" ]]; then + docker run --rm --network binance_net --env-file ".env.$TARGET_NETWORK" -e "PRIVATE_KEY=$PRIVATE_KEY" binance-send $@ +else + docker run --rm --env-file ".env.$TARGET_NETWORK" --env-file "../.keys.$TARGET_NETWORK" -e "PRIVATE_KEY=$PRIVATE_KEY" binance-send $@ +fi diff --git a/src/test-services/binanceSend/testBinanceSend.js b/src/test-services/binanceSend/testBinanceSend.js index 46678d7..9dfaee7 100644 --- a/src/test-services/binanceSend/testBinanceSend.js +++ b/src/test-services/binanceSend/testBinanceSend.js @@ -6,7 +6,7 @@ const PRIVATE_KEY = process.env.PRIVATE_KEY || FOREIGN_PRIVATE_KEY const client = new Bnc(FOREIGN_URL) -async function main () { +async function main() { client.chooseNetwork('testnet') await client.setPrivateKey(PRIVATE_KEY) @@ -40,13 +40,14 @@ async function main () { receipt = await client.multiSend(from, outputs, 'funding') } else { console.log(`From ${from} to ${to}, ${tokens} ${FOREIGN_ASSET}'`) - receipt = await client.transfer(from, to, tokens, FOREIGN_ASSET, 'exchange') + receipt = await client.transfer(from, to, tokens, FOREIGN_ASSET, '') } - if (receipt.status === 200) + if (receipt.status === 200) { console.log(receipt.result[0].hash) - else + } else { console.log(receipt) + } } main() diff --git a/src/test-services/ethereumBalance/.dockerignore b/src/test-services/ethereumBalance/.dockerignore new file mode 100644 index 0000000..4119e2e --- /dev/null +++ b/src/test-services/ethereumBalance/.dockerignore @@ -0,0 +1,4 @@ +.dockerignore +Dockerfile +run.sh +.env.* diff --git a/src/test-services/ethereumBalance/.env.staging b/src/test-services/ethereumBalance/.env.staging index 4e7f9da..99f7e77 100644 --- a/src/test-services/ethereumBalance/.env.staging +++ b/src/test-services/ethereumBalance/.env.staging @@ -1,2 +1,2 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0 -HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc +HOME_TOKEN_ADDRESS=0x7c7daEf752C80A6d229D4a642B9336ceCd7e26b0 diff --git a/src/test-services/ethereumBalance/Dockerfile b/src/test-services/ethereumBalance/Dockerfile index 7b6b094..0086b3e 100644 --- a/src/test-services/ethereumBalance/Dockerfile +++ b/src/test-services/ethereumBalance/Dockerfile @@ -6,6 +6,6 @@ COPY package.json /test/ RUN npm install -COPY testGetEthereumBalance.js IERC20.json /test/ +COPY testGetEthereumBalance.js /test/ ENTRYPOINT ["node", "testGetEthereumBalance.js"] diff --git a/src/test-services/ethereumBalance/IERC20.json b/src/test-services/ethereumBalance/IERC20.json deleted file mode 100644 index 066d309..0000000 --- a/src/test-services/ethereumBalance/IERC20.json +++ /dev/null @@ -1,1884 +0,0 @@ -{ - "contractName": "IERC20", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "recipient", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "spender", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "sender", - "type": "address" - }, - { - "name": "recipient", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } - ], - "metadata": "{\"compiler\":{\"version\":\"0.5.9+commit.e560f70d\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"sender\",\"type\":\"address\"},{\"name\":\"recipient\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"recipient\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"}],\"devdoc\":{\"details\":\"Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see `ERC20Detailed`.\",\"methods\":{\"allowance(address,address)\":{\"details\":\"Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through `transferFrom`. This is zero by default. * This value changes when `approve` or `transferFrom` are called.\"},\"approve(address,uint256)\":{\"details\":\"Sets `amount` as the allowance of `spender` over the caller's tokens. * Returns a boolean value indicating whether the operation succeeded. * > Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * Emits an `Approval` event.\"},\"balanceOf(address)\":{\"details\":\"Returns the amount of tokens owned by `account`.\"},\"totalSupply()\":{\"details\":\"Returns the amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"details\":\"Moves `amount` tokens from the caller's account to `recipient`. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event.\"}}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":\"IERC20\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":3},\"remappings\":[]},\"sources\":{\"/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x90e8c2521653bbb1768b05889c5760031e688d9cd361f167489b89215e201b95\",\"urls\":[\"bzzr://aa8b45b57edafc3d67bc5d916327ea16807fae33f753ca163ae0c4061b789766\",\"dweb:/ipfs/QmP5NaEwZthQeM2ESz4WTT3osrP7jhbvu7ocbttBi2JAw6\"]}},\"version\":1}", - "bytecode": "0x", - "deployedBytecode": "0x", - "sourceMap": "", - "deployedSourceMap": "", - "source": "pragma solidity ^0.5.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see `ERC20Detailed`.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a `Transfer` event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through `transferFrom`. This is\n * zero by default.\n *\n * This value changes when `approve` or `transferFrom` are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * > Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an `Approval` event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a `Transfer` event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to `approve`. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n", - "sourcePath": "/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "ast": { - "absolutePath": "/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "exportedSymbols": { - "IERC20": [ - 9841 - ] - }, - "id": 9842, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 9774, - "literals": [ - "solidity", - "^", - "0.5", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "0:23:114" - }, - { - "baseContracts": [], - "contractDependencies": [], - "contractKind": "interface", - "documentation": "@dev Interface of the ERC20 standard as defined in the EIP. Does not include\nthe optional functions; to access them see `ERC20Detailed`.", - "fullyImplemented": false, - "id": 9841, - "linearizedBaseContracts": [ - 9841 - ], - "name": "IERC20", - "nodeType": "ContractDefinition", - "nodes": [ - { - "body": null, - "documentation": "@dev Returns the amount of tokens in existence.", - "id": 9779, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "totalSupply", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9775, - "nodeType": "ParameterList", - "parameters": [], - "src": "290:2:114" - }, - "returnParameters": { - "id": 9778, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9777, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9779, - "src": "316:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9776, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "316:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "315:9:114" - }, - "scope": 9841, - "src": "270:55:114", - "stateMutability": "view", - "superFunction": 12575, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the amount of tokens owned by `account`.", - "id": 9786, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "balanceOf", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9782, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9781, - "name": "account", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "427:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9780, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "427:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "426:17:114" - }, - "returnParameters": { - "id": 9785, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9784, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "467:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9783, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "467:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "466:9:114" - }, - "scope": 9841, - "src": "408:68:114", - "stateMutability": "view", - "superFunction": 12582, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from the caller's account to `recipient`.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9795, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9791, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9788, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "714:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9787, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "714:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9790, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "733:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9789, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "733:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "713:35:114" - }, - "returnParameters": { - "id": 9794, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9793, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "767:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9792, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "767:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "766:6:114" - }, - "scope": 9841, - "src": "696:77:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the remaining number of tokens that `spender` will be\nallowed to spend on behalf of `owner` through `transferFrom`. This is\nzero by default.\n * This value changes when `approve` or `transferFrom` are called.", - "id": 9804, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "allowance", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9800, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9797, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1067:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9796, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1067:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9799, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1082:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9798, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1082:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1066:32:114" - }, - "returnParameters": { - "id": 9803, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9802, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1122:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9801, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1122:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1121:9:114" - }, - "scope": 9841, - "src": "1048:83:114", - "stateMutability": "view", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n * Returns a boolean value indicating whether the operation succeeded.\n * > Beware that changing an allowance with this method brings the risk\nthat someone may use both the old and the new allowance by unfortunate\ntransaction ordering. One possible solution to mitigate this race\ncondition is to first reduce the spender's allowance to 0 and set the\ndesired value afterwards:\nhttps://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * Emits an `Approval` event.", - "id": 9813, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "approve", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9809, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9806, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1792:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9805, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1792:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9808, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1809:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9807, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1809:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1791:33:114" - }, - "returnParameters": { - "id": 9812, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9811, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1843:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9810, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1843:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1842:6:114" - }, - "scope": 9841, - "src": "1775:74:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from `sender` to `recipient` using the\nallowance mechanism. `amount` is then deducted from the caller's\nallowance.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9824, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transferFrom", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9820, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9815, - "name": "sender", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2178:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9814, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2178:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9817, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2194:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9816, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2194:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9819, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2213:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9818, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2213:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2177:51:114" - }, - "returnParameters": { - "id": 9823, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9822, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2247:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9821, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "2247:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2246:6:114" - }, - "scope": 9841, - "src": "2156:97:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when `value` tokens are moved from one account (`from`) to\nanother (`to`).\n * Note that `value` may be zero.", - "id": 9832, - "name": "Transfer", - "nodeType": "EventDefinition", - "parameters": { - "id": 9831, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9826, - "indexed": true, - "name": "from", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2437:20:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9825, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2437:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9828, - "indexed": true, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2459:18:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9827, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2459:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9830, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2479:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9829, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2479:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2436:57:114" - }, - "src": "2422:72:114" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when the allowance of a `spender` for an `owner` is set by\na call to `approve`. `value` is the new allowance.", - "id": 9840, - "name": "Approval", - "nodeType": "EventDefinition", - "parameters": { - "id": 9839, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9834, - "indexed": true, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2668:21:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9833, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2668:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9836, - "indexed": true, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2691:23:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9835, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2691:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9838, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2716:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9837, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2716:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2667:63:114" - }, - "src": "2653:78:114" - } - ], - "scope": 9842, - "src": "176:2557:114" - } - ], - "src": "0:2734:114" - }, - "legacyAST": { - "absolutePath": "/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "exportedSymbols": { - "IERC20": [ - 9841 - ] - }, - "id": 9842, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 9774, - "literals": [ - "solidity", - "^", - "0.5", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "0:23:114" - }, - { - "baseContracts": [], - "contractDependencies": [], - "contractKind": "interface", - "documentation": "@dev Interface of the ERC20 standard as defined in the EIP. Does not include\nthe optional functions; to access them see `ERC20Detailed`.", - "fullyImplemented": false, - "id": 9841, - "linearizedBaseContracts": [ - 9841 - ], - "name": "IERC20", - "nodeType": "ContractDefinition", - "nodes": [ - { - "body": null, - "documentation": "@dev Returns the amount of tokens in existence.", - "id": 9779, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "totalSupply", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9775, - "nodeType": "ParameterList", - "parameters": [], - "src": "290:2:114" - }, - "returnParameters": { - "id": 9778, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9777, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9779, - "src": "316:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9776, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "316:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "315:9:114" - }, - "scope": 9841, - "src": "270:55:114", - "stateMutability": "view", - "superFunction": 12575, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the amount of tokens owned by `account`.", - "id": 9786, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "balanceOf", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9782, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9781, - "name": "account", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "427:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9780, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "427:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "426:17:114" - }, - "returnParameters": { - "id": 9785, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9784, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "467:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9783, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "467:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "466:9:114" - }, - "scope": 9841, - "src": "408:68:114", - "stateMutability": "view", - "superFunction": 12582, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from the caller's account to `recipient`.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9795, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9791, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9788, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "714:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9787, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "714:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9790, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "733:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9789, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "733:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "713:35:114" - }, - "returnParameters": { - "id": 9794, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9793, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "767:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9792, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "767:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "766:6:114" - }, - "scope": 9841, - "src": "696:77:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the remaining number of tokens that `spender` will be\nallowed to spend on behalf of `owner` through `transferFrom`. This is\nzero by default.\n * This value changes when `approve` or `transferFrom` are called.", - "id": 9804, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "allowance", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9800, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9797, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1067:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9796, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1067:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9799, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1082:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9798, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1082:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1066:32:114" - }, - "returnParameters": { - "id": 9803, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9802, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1122:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9801, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1122:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1121:9:114" - }, - "scope": 9841, - "src": "1048:83:114", - "stateMutability": "view", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n * Returns a boolean value indicating whether the operation succeeded.\n * > Beware that changing an allowance with this method brings the risk\nthat someone may use both the old and the new allowance by unfortunate\ntransaction ordering. One possible solution to mitigate this race\ncondition is to first reduce the spender's allowance to 0 and set the\ndesired value afterwards:\nhttps://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * Emits an `Approval` event.", - "id": 9813, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "approve", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9809, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9806, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1792:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9805, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1792:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9808, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1809:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9807, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1809:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1791:33:114" - }, - "returnParameters": { - "id": 9812, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9811, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1843:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9810, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1843:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1842:6:114" - }, - "scope": 9841, - "src": "1775:74:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from `sender` to `recipient` using the\nallowance mechanism. `amount` is then deducted from the caller's\nallowance.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9824, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transferFrom", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9820, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9815, - "name": "sender", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2178:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9814, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2178:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9817, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2194:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9816, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2194:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9819, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2213:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9818, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2213:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2177:51:114" - }, - "returnParameters": { - "id": 9823, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9822, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2247:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9821, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "2247:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2246:6:114" - }, - "scope": 9841, - "src": "2156:97:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when `value` tokens are moved from one account (`from`) to\nanother (`to`).\n * Note that `value` may be zero.", - "id": 9832, - "name": "Transfer", - "nodeType": "EventDefinition", - "parameters": { - "id": 9831, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9826, - "indexed": true, - "name": "from", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2437:20:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9825, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2437:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9828, - "indexed": true, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2459:18:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9827, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2459:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9830, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2479:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9829, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2479:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2436:57:114" - }, - "src": "2422:72:114" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when the allowance of a `spender` for an `owner` is set by\na call to `approve`. `value` is the new allowance.", - "id": 9840, - "name": "Approval", - "nodeType": "EventDefinition", - "parameters": { - "id": 9839, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9834, - "indexed": true, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2668:21:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9833, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2668:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9836, - "indexed": true, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2691:23:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9835, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2691:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9838, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2716:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9837, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2716:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2667:63:114" - }, - "src": "2653:78:114" - } - ], - "scope": 9842, - "src": "176:2557:114" - } - ], - "src": "0:2734:114" - }, - "compiler": { - "name": "solc", - "version": "0.5.9+commit.e560f70d.Emscripten.clang" - }, - "networks": {}, - "schemaVersion": "3.0.11", - "updatedAt": "2019-07-17T07:17:15.653Z", - "devdoc": { - "details": "Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see `ERC20Detailed`.", - "methods": { - "allowance(address,address)": { - "details": "Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through `transferFrom`. This is zero by default. * This value changes when `approve` or `transferFrom` are called." - }, - "approve(address,uint256)": { - "details": "Sets `amount` as the allowance of `spender` over the caller's tokens. * Returns a boolean value indicating whether the operation succeeded. * > Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * Emits an `Approval` event." - }, - "balanceOf(address)": { - "details": "Returns the amount of tokens owned by `account`." - }, - "totalSupply()": { - "details": "Returns the amount of tokens in existence." - }, - "transfer(address,uint256)": { - "details": "Moves `amount` tokens from the caller's account to `recipient`. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event." - }, - "transferFrom(address,address,uint256)": { - "details": "Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event." - } - } - }, - "userdoc": { - "methods": {} - } -} \ No newline at end of file diff --git a/src/test-services/ethereumBalance/package.json b/src/test-services/ethereumBalance/package.json index fcb5d8c..6865e58 100644 --- a/src/test-services/ethereumBalance/package.json +++ b/src/test-services/ethereumBalance/package.json @@ -2,7 +2,10 @@ "name": "ethereum-balance", "version": "0.0.1", "dependencies": { - "web3": "1.0.0-beta.55", + "ethers": "4.0.39", "bignumber.js": "9.0.0" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/test-services/ethereumBalance/run.sh b/src/test-services/ethereumBalance/run.sh index 369a2b5..58dc621 100755 --- a/src/test-services/ethereumBalance/run.sh +++ b/src/test-services/ethereumBalance/run.sh @@ -9,4 +9,8 @@ TARGET_NETWORK=${TARGET_NETWORK:=development} docker build -t ethereum-balance . > /dev/null -docker run --network blockchain_home --rm --env-file ".env.$TARGET_NETWORK" ethereum-balance $@ +if [[ "$TARGET_NETWORK" == "development" ]]; then + docker run --network ethereum_home_rpc_net --rm --env-file ".env.$TARGET_NETWORK" ethereum-balance $@ +else + docker run --rm --env-file ".env.$TARGET_NETWORK" ethereum-balance $@ +fi diff --git a/src/test-services/ethereumBalance/testGetEthereumBalance.js b/src/test-services/ethereumBalance/testGetEthereumBalance.js index 3d0e9ea..582707c 100644 --- a/src/test-services/ethereumBalance/testGetEthereumBalance.js +++ b/src/test-services/ethereumBalance/testGetEthereumBalance.js @@ -1,18 +1,28 @@ -const Web3 = require('web3') +const ethers = require('ethers') const BN = require('bignumber.js') const { HOME_RPC_URL, HOME_TOKEN_ADDRESS } = process.env -const abiToken = require('./IERC20').abi +const tokenAbi = [ + 'function balanceOf(address account) view returns (uint256)' +] -const web3 = new Web3(HOME_RPC_URL, null, { transactionConfirmationBlocks: 1 }) -const token = new web3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS) +const provider = new ethers.providers.JsonRpcProvider(HOME_RPC_URL) +const token = new ethers.Contract(HOME_TOKEN_ADDRESS, tokenAbi, provider) -const address = process.argv[2] +async function main() { + const address = process.argv[2] -web3.eth.getBalance(address).then(x => console.log(`${x.toString()} wei`)) + const ethBalance = await provider.getBalance(address) + console.log(`${ethBalance.toString()} wei`) -token.methods.balanceOf(address).call() - .then(x => parseFloat(new BN(x).dividedBy(10 ** 18).toFixed(8, 3))) - .then(x => console.log(`${x.toString()} tokens`)) - .catch(() => console.log('0 tokens')) + try { + const ercBalance = await token.balanceOf(address) + const floatBalance = new BN(ercBalance).dividedBy(10 ** 18).toFixed(8, 3) + console.log(`${floatBalance.toString()} tokens`) + } catch (e) { + console.log('0 tokens') + } +} + +main() diff --git a/src/test-services/ethereumSend/.dockerignore b/src/test-services/ethereumSend/.dockerignore new file mode 100644 index 0000000..4119e2e --- /dev/null +++ b/src/test-services/ethereumSend/.dockerignore @@ -0,0 +1,4 @@ +.dockerignore +Dockerfile +run.sh +.env.* diff --git a/src/test-services/ethereumSend/.env.staging b/src/test-services/ethereumSend/.env.staging index adfeac7..b18ceb8 100644 --- a/src/test-services/ethereumSend/.env.staging +++ b/src/test-services/ethereumSend/.env.staging @@ -1,5 +1,5 @@ HOME_RPC_URL=https://kovan.infura.io/v3/5d7bd94c50ed43fab1cb8e74f58678b0 -HOME_BRIDGE_ADDRESS=0x6ADCa5e691341fb9de8927d15c0a89B83A4E665e -HOME_TOKEN_ADDRESS=0x57d2533B640cfb58f8f1F69C14c089968Da9fdFc +HOME_BRIDGE_ADDRESS=0x01eD0d6350542E7643cB7bba4bccc96FedE0B616 +HOME_TOKEN_ADDRESS=0x7c7daEf752C80A6d229D4a642B9336ceCd7e26b0 #HOME_PRIVATE_KEY is taken from src/test-services/.keys.staging diff --git a/src/test-services/ethereumSend/Bridge.json b/src/test-services/ethereumSend/Bridge.json deleted file mode 100644 index ff90709..0000000 --- a/src/test-services/ethereumSend/Bridge.json +++ /dev/null @@ -1,29782 +0,0 @@ -{ - "contractName": "Bridge", - "abi": [ - { - "constant": true, - "inputs": [], - "name": "status", - "outputs": [ - { - "name": "", - "type": "uint8" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "name": "votes", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "name": "dbTransfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "tokenContract", - "outputs": [ - { - "name": "", - "type": "address" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "epoch", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "name": "votesCount", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "nextEpoch", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "", - "type": "bytes32" - } - ], - "name": "dbTransferCount", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "threshold", - "type": "uint256" - }, - { - "name": "validators", - "type": "address[]" - }, - { - "name": "_tokenContract", - "type": "address" - }, - { - "name": "limits", - "type": "uint256[2]" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "ExchangeRequest", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "oldEpoch", - "type": "uint256" - }, - { - "indexed": true, - "name": "newEpoch", - "type": "uint256" - } - ], - "name": "NewEpoch", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "epoch", - "type": "uint256" - } - ], - "name": "NewEpochCancelled", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "oldEpoch", - "type": "uint256" - }, - { - "indexed": true, - "name": "newEpoch", - "type": "uint256" - } - ], - "name": "NewFundsTransfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "epoch", - "type": "uint256" - }, - { - "indexed": false, - "name": "x", - "type": "uint256" - }, - { - "indexed": false, - "name": "y", - "type": "uint256" - } - ], - "name": "EpochStart", - "type": "event" - }, - { - "constant": false, - "inputs": [ - { - "name": "value", - "type": "uint256" - } - ], - "name": "exchange", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "hash", - "type": "bytes32" - }, - { - "name": "to", - "type": "address" - }, - { - "name": "value", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "x", - "type": "uint256" - }, - { - "name": "y", - "type": "uint256" - } - ], - "name": "confirmKeygen", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "confirmFundsTransfer", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getNextParties", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getParties", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_epoch", - "type": "uint256" - } - ], - "name": "getParties", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getNextThreshold", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getThreshold", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "_epoch", - "type": "uint256" - } - ], - "name": "getThreshold", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getX", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getY", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getPartyId", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "a", - "type": "address" - } - ], - "name": "getNextPartyId", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getValidators", - "outputs": [ - { - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [], - "name": "getNextValidators", - "outputs": [ - { - "name": "", - "type": "address[]" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "startVoting", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "validator", - "type": "address" - } - ], - "name": "voteAddValidator", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "validator", - "type": "address" - } - ], - "name": "voteRemoveValidator", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "threshold", - "type": "uint256" - } - ], - "name": "voteChangeThreshold", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "voteStartKeygen", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [], - "name": "voteCancelKeygen", - "outputs": [], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } - ], - "metadata": "{\"compiler\":{\"version\":\"0.5.9+commit.e560f70d\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":true,\"inputs\":[],\"name\":\"getNextParties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getY\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"a\",\"type\":\"address\"}],\"name\":\"getNextPartyId\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"startVoting\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"status\",\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"votes\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getPartyId\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"voteCancelKeygen\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"hash\",\"type\":\"bytes32\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNextValidators\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_epoch\",\"type\":\"uint256\"}],\"name\":\"getParties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"_epoch\",\"type\":\"uint256\"}],\"name\":\"getThreshold\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"dbTransfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getX\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"exchange\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"tokenContract\",\"outputs\":[{\"name\":\"\",\"type\":\"address\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"validator\",\"type\":\"address\"}],\"name\":\"voteAddValidator\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getNextThreshold\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"epoch\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"voteStartKeygen\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"validator\",\"type\":\"address\"}],\"name\":\"voteRemoveValidator\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"x\",\"type\":\"uint256\"},{\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"confirmKeygen\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getParties\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"votesCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"nextEpoch\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getValidators\",\"outputs\":[{\"name\":\"\",\"type\":\"address[]\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"threshold\",\"type\":\"uint256\"}],\"name\":\"voteChangeThreshold\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"\",\"type\":\"bytes32\"}],\"name\":\"dbTransferCount\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[],\"name\":\"confirmFundsTransfer\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"getThreshold\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"threshold\",\"type\":\"uint256\"},{\"name\":\"validators\",\"type\":\"address[]\"},{\"name\":\"_tokenContract\",\"type\":\"address\"},{\"name\":\"limits\",\"type\":\"uint256[2]\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"ExchangeRequest\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"oldEpoch\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"newEpoch\",\"type\":\"uint256\"}],\"name\":\"NewEpoch\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"epoch\",\"type\":\"uint256\"}],\"name\":\"NewEpochCancelled\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"oldEpoch\",\"type\":\"uint256\"},{\"indexed\":true,\"name\":\"newEpoch\",\"type\":\"uint256\"}],\"name\":\"NewFundsTransfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"epoch\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"x\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"y\",\"type\":\"uint256\"}],\"name\":\"EpochStart\",\"type\":\"event\"}],\"devdoc\":{\"methods\":{}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/Bridge.sol\":\"Bridge\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":3},\"remappings\":[]},\"sources\":{\"/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/Bridge.sol\":{\"keccak256\":\"0xb6dedd38aa6fa77b6a773e2bc87673d94587af628b2bc99a7fa7343b52e9afd7\",\"urls\":[\"bzzr://ac452822ae25877586c3e6280f8c5ca00bbe37a5558e4560f70d18448ee92122\",\"dweb:/ipfs/QmZ6bwZLh8Jzs5Aw2ec347YrXapwRWDZBgFqUkPHASoChU\"]},\"/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x90e8c2521653bbb1768b05889c5760031e688d9cd361f167489b89215e201b95\",\"urls\":[\"bzzr://aa8b45b57edafc3d67bc5d916327ea16807fae33f753ca163ae0c4061b789766\",\"dweb:/ipfs/QmP5NaEwZthQeM2ESz4WTT3osrP7jhbvu7ocbttBi2JAw6\"]}},\"version\":1}", - "bytecode": "0x60806040523480156200001157600080fd5b5060405162001b6b38038062001b6b833981810160405260a08110156200003757600080fd5b8151602083018051919392830192916401000000008111156200005957600080fd5b820160208101848111156200006d57600080fd5b81518560208202830111640100000000821117156200008b57600080fd5b5050602082015181519194509250604090910190620000a957600080fd5b82518410620000b757600080fd5b600a80546001600160a01b0384166001600160a01b0319909116179055600060068190556005805460ff1916600217905560016007819055604080516080810182528681526020808201899052918101849052606081018490529183529182528051805191927fada5013122d395ba3c54772283fb069b10426056ef8ca54750cb9bb552a59e7d926200014e9284920190620001bd565b506020820151600182015560408201516002820155606090910151600390910155806000602002015160085580600160200201516009556040516001906000907f3ef85928df9ae51bdb3eb4c00ec73b92b82307f319ac1b029de14796a0972609908290a35050505062000251565b82805482825590600052602060002090810192821562000215579160200282015b828111156200021557825182546001600160a01b0319166001600160a01b03909116178255602090920191600190910190620001de565b506200022392915062000227565b5090565b6200024e91905b80821115620002235780546001600160a01b03191681556001016200022e565b90565b61190a80620002616000396000f3fe608060405234801561001057600080fd5b506004361061016a5760003560e01c8063073ce82d1461016f5780630b7f166514610189578063197d6ca4146101915780631ec6b60a146101b7578063200d2ed2146101c15780632b38cd96146101ed5780632fb0fc6f1461021e57806339f0ebb1146102265780633feb1bd81461022e57806340cddab314610260578063447fe289146102b85780634615d5e9146102d557806349f92f63146102f25780635197c7aa1461030f578063535565591461031757806355a373d61461033457806357456f22146103585780638199d3fd1461037e578063900cf0cf14610386578063915eb0e71461038e5780639bf6a74a14610396578063a7699d02146103bc578063a8311aa8146103df578063aae46bab146103e7578063aea0e78b14610404578063b7ab4db51461040c578063cc8ee06514610414578063d09fc00414610431578063df7852301461044e578063e75235b814610456575b600080fd5b61017761045e565b60408051918252519081900360200190f35b610177610471565b610177600480360360208110156101a757600080fd5b50356001600160a01b0316610489565b6101bf6104f6565b005b6101c9610621565b604051808260038111156101d957fe5b60ff16815260200191505060405180910390f35b61020a6004803603602081101561020357600080fd5b503561062a565b604080519115158252519081900360200190f35b61017761063f565b6101bf6106a9565b6101bf6004803603606081101561024457600080fd5b508035906001600160a01b036020820135169060400135610795565b6102686108f5565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102a457818101518382015260200161028c565b505050509050019250505060405180910390f35b610177600480360360208110156102ce57600080fd5b5035610960565b610177600480360360208110156102eb57600080fd5b5035610972565b61020a6004803603602081101561030857600080fd5b5035610987565b61017761099c565b6101bf6004803603602081101561032d57600080fd5b50356109b4565b61033c610af8565b604080516001600160a01b039092168252519081900360200190f35b6101bf6004803603602081101561036e57600080fd5b50356001600160a01b0316610b07565b610177610c47565b610177610c54565b6101bf610c5a565b6101bf600480360360208110156103ac57600080fd5b50356001600160a01b0316610d49565b6101bf600480360360408110156103d257600080fd5b5080359060200135610e58565b610177610fc4565b610177600480360360208110156103fd57600080fd5b5035610fd1565b610177610fe3565b610268610fe9565b6101bf6004803603602081101561042a57600080fd5b5035611052565b6101776004803603602081101561044757600080fd5b503561111b565b6101bf61112d565b61017761127d565b600061046b600754610960565b90505b90565b60065460009081526020819052604090206003015490565b600060606104956108f5565b905060005b6104a261045e565b8110156104ea57836001600160a01b03168282815181106104bf57fe5b60200260200101516001600160a01b031614156104e25760010191506104f19050565b60010161049a565b5060009150505b919050565b600060055460ff16600381111561050957fe5b14806105255750600160055460ff16600381111561052357fe5b145b610575576040805162461bcd60e51b815260206004820152601c60248201527b4e6f7420696e207265616479206f7220766f74696e6720737461746560201b604482015290519081900360640190fd5b61057d61063f565b6105bc576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b6105c6600261128a565b1561061f576007805460019081018083556005805460ff19168317905560068054600090815260208190526040808220850154938252808220909401929092555481528181209254815220815461061d92906117bb565b505b565b60055460ff1681565b60046020526000908152604090205460ff1681565b6000606061064b610fe9565b905060005b610658610fc4565b8110156106a057336001600160a01b031682828151811061067557fe5b60200260200101516001600160a01b0316141561069857600101915061046e9050565b600101610650565b50600091505090565b600260055460ff1660038111156106bc57fe5b14610704576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e206b657967656e20737461746560681b604482015290519081900360640190fd5b61070c61063f565b61074b576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610755600761128a565b1561061f576005805460ff191660011790556007546040517fddbb65cfe1ae4aec03cef0f9667c6d7ba3740927d0c60f4dd4d7104cc31d180a90600090a2565b600060055460ff1660038111156107a857fe5b14806107c45750600160055460ff1660038111156107c257fe5b145b610814576040805162461bcd60e51b815260206004820152601c60248201527b4e6f7420696e207265616479206f7220766f74696e6720737461746560201b604482015290519081900360640190fd5b61081c61063f565b61085b576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b61086860088484846112e1565b156108f057600a546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156108c357600080fd5b505af11580156108d7573d6000803e3d6000fd5b505050506040513d60208110156108ed57600080fd5b50505b505050565b6007546000908152602081815260409182902080548351818402810184019094528084526060939283018282801561095657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610938575b5050505050905090565b60009081526020819052604090205490565b60009081526020819052604090206001015490565b60026020526000908152604090205460ff1681565b60065460009081526020819052604090206002015490565b600060055460ff1660038111156109c757fe5b14610a0e576040805162461bcd60e51b81526020600482015260126024820152714e6f7420696e20726561647920737461746560701b604482015290519081900360640190fd5b6008548110158015610a2557506402540be4008110155b8015610a3357506009548111155b610a3c57600080fd5b600a54604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610a9657600080fd5b505af1158015610aaa573d6000803e3d6000fd5b505050506040513d6020811015610ac057600080fd5b50506040805182815290517f62e1f484b3909b2c013673bad76a9f14b010600ba983f11ad26e83082883570e9181900360200190a150565b600a546001600160a01b031681565b600160055460ff166003811115610b1a57fe5b14610b62576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b610b6a61063f565b610ba9576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610bb281610489565b15610bfa576040805162461bcd60e51b815260206004820152601360248201527220b63932b0b23c9030903b30b634b230ba37b960691b604482015290519081900360640190fd5b610c0560038261135e565b1561061d576007546000908152602081815260408220805460018101825590835291200180546001600160a01b0383166001600160a01b031990911617905550565b600061046b600754610972565b60065481565b600160055460ff166003811115610c6d57fe5b14610cb5576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b610cbd61063f565b610cfc576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610d06600661128a565b1561061f576005805460ff191660021790556007546006546040517f3ef85928df9ae51bdb3eb4c00ec73b92b82307f319ac1b029de14796a097260990600090a3565b600160055460ff166003811115610d5c57fe5b14610da4576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b610dac61063f565b610deb576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610df481610489565b610e3f576040805162461bcd60e51b815260206004820152601760248201527620b63932b0b23c903737ba1030903b30b634b230ba37b960491b604482015290519081900360640190fd5b610e4a60048261135e565b1561061d5761061d816113d3565b600260055460ff166003811115610e6b57fe5b14610eb3576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e206b657967656e20737461746560681b604482015290519081900360640190fd5b610ebc33610489565b610f04576040805162461bcd60e51b81526020600482015260146024820152732737ba1030903732bc3a103b30b634b230ba37b960611b604482015290519081900360640190fd5b610f1060008383611520565b15610fc057600780546000908152602081905260408082206002018590558254825290206003018290555460011415610f83576005805460ff1916905560075460068190556040805184815260208101849052815160008051602061186e833981519152929181900390910190a2610fc0565b6005805460ff191660031790556007546006546040517ff4735b85cc98f9a712832825ecab4cfb1649d658f9a73c57a00ea7dde735c79b90600090a35b5050565b600061046b600654610960565b60036020526000908152604090205481565b60075481565b60065460009081526020818152604091829020805483518184028101840190945280845260609392830182828015610956576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610938575050505050905090565b600160055460ff16600381111561106557fe5b146110ad576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b6110b561063f565b6110f4576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b6110ff600582611589565b1561061d57600754600090815260208190526040902060010155565b60016020526000908152604090205481565b600360055460ff16600381111561114057fe5b14611190576040805162461bcd60e51b815260206004820152601b60248201527a4e6f7420696e2066756e6473207472616e7366657220737461746560281b604482015290519081900360640190fd5b61119861063f565b6111d7576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b6000600654116112185760405162461bcd60e51b815260040180806020018281038252602881526020018061188e6028913960400191505060405180910390fd5b61122260016115e1565b1561061f576005805460ff191690556007546006819055600081815260208181526040918290206002810154600390910154835191825291810191909152815160008051602061186e833981519152929181900390910190a2565b600061046b600654610972565b60008082600754604051602001808360088111156112a457fe5b60ff1660f81b8152600101828152602001925050506040516020818303038152906040528051906020012090506112da81611631565b9392505050565b60008085858585604051602001808560088111156112fb57fe5b60ff1660f81b8152600101848152602001836001600160a01b03166001600160a01b031660601b815260140182815260200194505050505060405160208183030381529060405280519060200120905061135481611631565b9695505050505050565b60008083600754846040516020018084600881111561137957fe5b60ff1660f81b8152600101838152602001826001600160a01b03166001600160a01b031660601b815260140193505050506040516020818303038152906040528051906020012090506113cb81611631565b949350505050565b60005b60016113e061045e565b038110156114c157600754600090815260208190526040902080546001600160a01b03841691908390811061141157fe5b6000918252602090912001546001600160a01b031614156114b9576007546000908152602081905260409020600161144761045e565b038154811061145257fe5b6000918252602080832090910154600754835290829052604090912080546001600160a01b03909216918390811061148657fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506114c1565b6001016113d6565b50600754600090815260208190526040902060016114dd61045e565b03815481106114e857fe5b6000918252602080832090910180546001600160a01b0319169055600754825281905260409020805490610fc090600019830161180b565b6000808460075485856040516020018085600881111561153c57fe5b60ff1660f81b815260010184815260200183815260200182815260200194505050505060405160208183030381529060405280519060200120905061158081611704565b95945050505050565b6000808360075484604051602001808460088111156115a457fe5b60ff1660f81b815260010183815260200182815260200193505050506040516020818303038152906040528051906020012090506113cb81611631565b60008082600754604051602001808360088111156115fb57fe5b60ff1660f81b8152600101828152602001925050506040516020818303038152906040528051906020012090506112da81611704565b60008061163d8361178c565b60008181526004602052604090205490915060ff1615611694576040805162461bcd60e51b815260206004820152600d60248201526c566f74656420616c726561647960981b604482015290519081900360640190fd5b6000818152600460205260409020805460ff191660011790556116b561127d565b60008481526003602052604090205414156116e85750506000818152600360205260409020600160ff1b905560016104f1565b50506000818152600360205260408120805460010190556104f1565b6000806117108361178c565b60008181526004602052604090205490915060ff161561176b576040805162461bcd60e51b8152602060048201526011602482015270436f6e6669726d656420616c726561647960781b604482015290519081900360640190fd5b6000818152600460205260409020805460ff191660011790556116b5610c47565b604080516020808201939093523360601b81830152815180820360340181526054909101909152805191012090565b8280548282559060005260206000209081019282156117fb5760005260206000209182015b828111156117fb5782548255916001019190600101906117e0565b5061180792915061182f565b5090565b8154818355818111156108f0576000838152602090206108f0918101908301611853565b61046e91905b808211156118075780546001600160a01b0319168155600101611835565b61046e91905b80821115611807576000815560010161185956fec33272939f066c227e913a4b3434d860794f185c551685c29451a3a38b9b259c46697273742065706f636820646f6573206e6f74206e6565642066756e6473207472616e736665724e6f7420612063757272656e742076616c696461746f72000000000000000000a265627a7a72305820d9301198933836c8992bbab8e6c0ca596e021ff34c7db645c59302c42a24ea3264736f6c63430005090032", - "deployedBytecode": "0x608060405234801561001057600080fd5b506004361061016a5760003560e01c8063073ce82d1461016f5780630b7f166514610189578063197d6ca4146101915780631ec6b60a146101b7578063200d2ed2146101c15780632b38cd96146101ed5780632fb0fc6f1461021e57806339f0ebb1146102265780633feb1bd81461022e57806340cddab314610260578063447fe289146102b85780634615d5e9146102d557806349f92f63146102f25780635197c7aa1461030f578063535565591461031757806355a373d61461033457806357456f22146103585780638199d3fd1461037e578063900cf0cf14610386578063915eb0e71461038e5780639bf6a74a14610396578063a7699d02146103bc578063a8311aa8146103df578063aae46bab146103e7578063aea0e78b14610404578063b7ab4db51461040c578063cc8ee06514610414578063d09fc00414610431578063df7852301461044e578063e75235b814610456575b600080fd5b61017761045e565b60408051918252519081900360200190f35b610177610471565b610177600480360360208110156101a757600080fd5b50356001600160a01b0316610489565b6101bf6104f6565b005b6101c9610621565b604051808260038111156101d957fe5b60ff16815260200191505060405180910390f35b61020a6004803603602081101561020357600080fd5b503561062a565b604080519115158252519081900360200190f35b61017761063f565b6101bf6106a9565b6101bf6004803603606081101561024457600080fd5b508035906001600160a01b036020820135169060400135610795565b6102686108f5565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156102a457818101518382015260200161028c565b505050509050019250505060405180910390f35b610177600480360360208110156102ce57600080fd5b5035610960565b610177600480360360208110156102eb57600080fd5b5035610972565b61020a6004803603602081101561030857600080fd5b5035610987565b61017761099c565b6101bf6004803603602081101561032d57600080fd5b50356109b4565b61033c610af8565b604080516001600160a01b039092168252519081900360200190f35b6101bf6004803603602081101561036e57600080fd5b50356001600160a01b0316610b07565b610177610c47565b610177610c54565b6101bf610c5a565b6101bf600480360360208110156103ac57600080fd5b50356001600160a01b0316610d49565b6101bf600480360360408110156103d257600080fd5b5080359060200135610e58565b610177610fc4565b610177600480360360208110156103fd57600080fd5b5035610fd1565b610177610fe3565b610268610fe9565b6101bf6004803603602081101561042a57600080fd5b5035611052565b6101776004803603602081101561044757600080fd5b503561111b565b6101bf61112d565b61017761127d565b600061046b600754610960565b90505b90565b60065460009081526020819052604090206003015490565b600060606104956108f5565b905060005b6104a261045e565b8110156104ea57836001600160a01b03168282815181106104bf57fe5b60200260200101516001600160a01b031614156104e25760010191506104f19050565b60010161049a565b5060009150505b919050565b600060055460ff16600381111561050957fe5b14806105255750600160055460ff16600381111561052357fe5b145b610575576040805162461bcd60e51b815260206004820152601c60248201527b4e6f7420696e207265616479206f7220766f74696e6720737461746560201b604482015290519081900360640190fd5b61057d61063f565b6105bc576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b6105c6600261128a565b1561061f576007805460019081018083556005805460ff19168317905560068054600090815260208190526040808220850154938252808220909401929092555481528181209254815220815461061d92906117bb565b505b565b60055460ff1681565b60046020526000908152604090205460ff1681565b6000606061064b610fe9565b905060005b610658610fc4565b8110156106a057336001600160a01b031682828151811061067557fe5b60200260200101516001600160a01b0316141561069857600101915061046e9050565b600101610650565b50600091505090565b600260055460ff1660038111156106bc57fe5b14610704576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e206b657967656e20737461746560681b604482015290519081900360640190fd5b61070c61063f565b61074b576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610755600761128a565b1561061f576005805460ff191660011790556007546040517fddbb65cfe1ae4aec03cef0f9667c6d7ba3740927d0c60f4dd4d7104cc31d180a90600090a2565b600060055460ff1660038111156107a857fe5b14806107c45750600160055460ff1660038111156107c257fe5b145b610814576040805162461bcd60e51b815260206004820152601c60248201527b4e6f7420696e207265616479206f7220766f74696e6720737461746560201b604482015290519081900360640190fd5b61081c61063f565b61085b576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b61086860088484846112e1565b156108f057600a546040805163a9059cbb60e01b81526001600160a01b038581166004830152602482018590529151919092169163a9059cbb9160448083019260209291908290030181600087803b1580156108c357600080fd5b505af11580156108d7573d6000803e3d6000fd5b505050506040513d60208110156108ed57600080fd5b50505b505050565b6007546000908152602081815260409182902080548351818402810184019094528084526060939283018282801561095657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610938575b5050505050905090565b60009081526020819052604090205490565b60009081526020819052604090206001015490565b60026020526000908152604090205460ff1681565b60065460009081526020819052604090206002015490565b600060055460ff1660038111156109c757fe5b14610a0e576040805162461bcd60e51b81526020600482015260126024820152714e6f7420696e20726561647920737461746560701b604482015290519081900360640190fd5b6008548110158015610a2557506402540be4008110155b8015610a3357506009548111155b610a3c57600080fd5b600a54604080516323b872dd60e01b81523360048201523060248201526044810184905290516001600160a01b03909216916323b872dd916064808201926020929091908290030181600087803b158015610a9657600080fd5b505af1158015610aaa573d6000803e3d6000fd5b505050506040513d6020811015610ac057600080fd5b50506040805182815290517f62e1f484b3909b2c013673bad76a9f14b010600ba983f11ad26e83082883570e9181900360200190a150565b600a546001600160a01b031681565b600160055460ff166003811115610b1a57fe5b14610b62576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b610b6a61063f565b610ba9576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610bb281610489565b15610bfa576040805162461bcd60e51b815260206004820152601360248201527220b63932b0b23c9030903b30b634b230ba37b960691b604482015290519081900360640190fd5b610c0560038261135e565b1561061d576007546000908152602081815260408220805460018101825590835291200180546001600160a01b0383166001600160a01b031990911617905550565b600061046b600754610972565b60065481565b600160055460ff166003811115610c6d57fe5b14610cb5576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b610cbd61063f565b610cfc576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610d06600661128a565b1561061f576005805460ff191660021790556007546006546040517f3ef85928df9ae51bdb3eb4c00ec73b92b82307f319ac1b029de14796a097260990600090a3565b600160055460ff166003811115610d5c57fe5b14610da4576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b610dac61063f565b610deb576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b610df481610489565b610e3f576040805162461bcd60e51b815260206004820152601760248201527620b63932b0b23c903737ba1030903b30b634b230ba37b960491b604482015290519081900360640190fd5b610e4a60048261135e565b1561061d5761061d816113d3565b600260055460ff166003811115610e6b57fe5b14610eb3576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e206b657967656e20737461746560681b604482015290519081900360640190fd5b610ebc33610489565b610f04576040805162461bcd60e51b81526020600482015260146024820152732737ba1030903732bc3a103b30b634b230ba37b960611b604482015290519081900360640190fd5b610f1060008383611520565b15610fc057600780546000908152602081905260408082206002018590558254825290206003018290555460011415610f83576005805460ff1916905560075460068190556040805184815260208101849052815160008051602061186e833981519152929181900390910190a2610fc0565b6005805460ff191660031790556007546006546040517ff4735b85cc98f9a712832825ecab4cfb1649d658f9a73c57a00ea7dde735c79b90600090a35b5050565b600061046b600654610960565b60036020526000908152604090205481565b60075481565b60065460009081526020818152604091829020805483518184028101840190945280845260609392830182828015610956576020028201919060005260206000209081546001600160a01b03168152600190910190602001808311610938575050505050905090565b600160055460ff16600381111561106557fe5b146110ad576040805162461bcd60e51b81526020600482015260136024820152724e6f7420696e20766f74696e6720737461746560681b604482015290519081900360640190fd5b6110b561063f565b6110f4576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b6110ff600582611589565b1561061d57600754600090815260208190526040902060010155565b60016020526000908152604090205481565b600360055460ff16600381111561114057fe5b14611190576040805162461bcd60e51b815260206004820152601b60248201527a4e6f7420696e2066756e6473207472616e7366657220737461746560281b604482015290519081900360640190fd5b61119861063f565b6111d7576040805162461bcd60e51b815260206004820152601760248201526000805160206118b6833981519152604482015290519081900360640190fd5b6000600654116112185760405162461bcd60e51b815260040180806020018281038252602881526020018061188e6028913960400191505060405180910390fd5b61122260016115e1565b1561061f576005805460ff191690556007546006819055600081815260208181526040918290206002810154600390910154835191825291810191909152815160008051602061186e833981519152929181900390910190a2565b600061046b600654610972565b60008082600754604051602001808360088111156112a457fe5b60ff1660f81b8152600101828152602001925050506040516020818303038152906040528051906020012090506112da81611631565b9392505050565b60008085858585604051602001808560088111156112fb57fe5b60ff1660f81b8152600101848152602001836001600160a01b03166001600160a01b031660601b815260140182815260200194505050505060405160208183030381529060405280519060200120905061135481611631565b9695505050505050565b60008083600754846040516020018084600881111561137957fe5b60ff1660f81b8152600101838152602001826001600160a01b03166001600160a01b031660601b815260140193505050506040516020818303038152906040528051906020012090506113cb81611631565b949350505050565b60005b60016113e061045e565b038110156114c157600754600090815260208190526040902080546001600160a01b03841691908390811061141157fe5b6000918252602090912001546001600160a01b031614156114b9576007546000908152602081905260409020600161144761045e565b038154811061145257fe5b6000918252602080832090910154600754835290829052604090912080546001600160a01b03909216918390811061148657fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506114c1565b6001016113d6565b50600754600090815260208190526040902060016114dd61045e565b03815481106114e857fe5b6000918252602080832090910180546001600160a01b0319169055600754825281905260409020805490610fc090600019830161180b565b6000808460075485856040516020018085600881111561153c57fe5b60ff1660f81b815260010184815260200183815260200182815260200194505050505060405160208183030381529060405280519060200120905061158081611704565b95945050505050565b6000808360075484604051602001808460088111156115a457fe5b60ff1660f81b815260010183815260200182815260200193505050506040516020818303038152906040528051906020012090506113cb81611631565b60008082600754604051602001808360088111156115fb57fe5b60ff1660f81b8152600101828152602001925050506040516020818303038152906040528051906020012090506112da81611704565b60008061163d8361178c565b60008181526004602052604090205490915060ff1615611694576040805162461bcd60e51b815260206004820152600d60248201526c566f74656420616c726561647960981b604482015290519081900360640190fd5b6000818152600460205260409020805460ff191660011790556116b561127d565b60008481526003602052604090205414156116e85750506000818152600360205260409020600160ff1b905560016104f1565b50506000818152600360205260408120805460010190556104f1565b6000806117108361178c565b60008181526004602052604090205490915060ff161561176b576040805162461bcd60e51b8152602060048201526011602482015270436f6e6669726d656420616c726561647960781b604482015290519081900360640190fd5b6000818152600460205260409020805460ff191660011790556116b5610c47565b604080516020808201939093523360601b81830152815180820360340181526054909101909152805191012090565b8280548282559060005260206000209081019282156117fb5760005260206000209182015b828111156117fb5782548255916001019190600101906117e0565b5061180792915061182f565b5090565b8154818355818111156108f0576000838152602090206108f0918101908301611853565b61046e91905b808211156118075780546001600160a01b0319168155600101611835565b61046e91905b80821115611807576000815560010161185956fec33272939f066c227e913a4b3434d860794f185c551685c29451a3a38b9b259c46697273742065706f636820646f6573206e6f74206e6565642066756e6473207472616e736665724e6f7420612063757272656e742076616c696461746f72000000000000000000a265627a7a72305820d9301198933836c8992bbab8e6c0ca596e021ff34c7db645c59302c42a24ea3264736f6c63430005090032", - "sourceMap": "93:9593:0:-;;;1361:482;8:9:-1;5:2;;;30:1;27;20:12;5:2;1361:482:0;;;;;;;;;;;;;;;13:3:-1;8;5:12;2:2;;;30:1;27;20:12;2:2;1361:482:0;;;;;;;;;;;;;;19:11:-1;11:20;;8:2;;;44:1;41;34:12;8:2;62:21;;123:4;114:14;;138:31;;;135:2;;;182:1;179;172:12;135:2;219:3;213:10;331:9;325:2;311:12;307:21;289:16;285:44;282:59;261:11;247:12;244:29;233:116;230:2;;;362:1;359;352:12;230:2;-1:-1;;1361:482:0;;;;1490:17;;1361:482;;-1:-1:-1;1361:482:0;-1:-1:-1;1361:482:0;;;;;1482:30;;;;;;1542:10;:17;1530:9;:29;1522:38;;;;;;1571:13;:38;;-1:-1:-1;;;;;1571:38:0;;-1:-1:-1;;;;;;1571:38:0;;;;;;-1:-1:-1;1620:5:0;:9;;;1639:6;:22;;-1:-1:-1;;1639:22:0;1648:13;1639:22;;;-1:-1:-1;1671:9:0;:13;;;1707:34;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1695:9;;;;;;:46;;;;1707:34;;1695:9;;:46;;:9;;:46;;;:::i;:::-;-1:-1:-1;1695:46:0;;;;;;;;;;;;;;;;;;;;;;;;;;1765:6;-1:-1:-1;1765:9:0;;;;1752:10;:22;1797:6;1804:1;1797:9;;;;1784:10;:22;1822:14;;1834:1;;1831;;1822:14;;1831:1;;1822:14;1361:482;;;;93:9593;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;;93:9593:0;-1:-1:-1;;;;;93:9593:0;;;;;;;;;;;-1:-1:-1;93:9593:0;;;;;;;-1:-1:-1;93:9593:0;;;-1:-1:-1;93:9593:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;-1:-1:-1;;;;;;93:9593:0;;;;;;;;;:::o;:::-;;;;;;;", - "deployedSourceMap": "93:9593:0:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;93:9593:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4085:98;;;:::i;:::-;;;;;;;;;;;;;;;;4723:82;;;:::i;5081:276::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;5081:276:0;-1:-1:-1;;;;;5081:276:0;;:::i;5607:317::-;;;:::i;:::-;;1240:20;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1196:37;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1196:37:0;;:::i;:::-;;;;;;;;;;;;;;;;;;4811:264;;;:::i;7356:203::-;;;:::i;2829:213::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;2829:213:0;;;-1:-1:-1;;;;;2829:213:0;;;;;;;;;;:::i;5481:120::-;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8:100:-1;33:3;30:1;27:10;8:100;;;90:11;;;84:18;71:11;;;64:39;52:2;45:10;8:100;;;12:14;5481:120:0;;;;;;;;;;;;;;;;;4189:116;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;4189:116:0;;:::i;4519:110::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;4519:110:0;;:::i;1100:42::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1100:42:0;;:::i;4635:82::-;;;:::i;2583:240::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;2583:240:0;;:::i;1849:27::-;;;:::i;:::-;;;;-1:-1:-1;;;;;1849:27:0;;;;;;;;;;;;;;5930:278;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;5930:278:0;-1:-1:-1;;;;;5930:278:0;;:::i;4411:102::-;;;:::i;1267:17::-;;;:::i;7151:199::-;;;:::i;6214:271::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;6214:271:0;-1:-1:-1;;;;;6214:271:0;;:::i;3048:578::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;3048:578:0;;;;;;;:::i;3989:90::-;;;:::i;1148:42::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1148:42:0;;:::i;1290:21::-;;;:::i;5363:112::-;;;:::i;6942:203::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;6942:203:0;;:::i;1047:47::-;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;1047:47:0;;:::i;3632:351::-;;;:::i;4311:94::-;;;:::i;4085:98::-;4132:4;4155:21;4166:9;;4155:10;:21::i;:::-;4148:28;;4085:98;;:::o;4723:82::-;4790:5;;4760:4;4783:13;;;;;;;;;;:15;;;4723:82;:::o;5081:276::-;5137:4;5153:27;5183:19;:17;:19::i;:::-;5153:49;-1:-1:-1;5217:6:0;5212:121;5233:16;:14;:16::i;:::-;5229:1;:20;5212:121;;;5291:1;-1:-1:-1;;;;;5274:18:0;:10;5285:1;5274:13;;;;;;;;;;;;;;-1:-1:-1;;;;;5274:18:0;;5270:52;;;5321:1;5317:5;;-1:-1:-1;5310:12:0;;-1:-1:-1;5310:12:0;5270:52;5251:3;;5212:121;;;;5349:1;5342:8;;;5081:276;;;;:::o;5607:317::-;2036:12;2026:6;;;;:22;;;;;;;;;:49;;;-1:-1:-1;2062:13:0;2052:6;;;;:23;;;;;;;;;2026:49;2018:90;;;;;-1:-1:-1;;;2018:90:0;;;;;;;;;;;;-1:-1:-1;;;2018:90:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;5682:26;5690:17;5682:7;:26::i;:::-;5678:240;;;5724:9;:11;;;;;;;;;5749:6;:22;;-1:-1:-1;;5749:22:0;;;;;5822:5;;;-1:-1:-1;5815:13:0;;;;;;;;;;;:23;;;5785:17;;;;;;:27;;;:53;;;;5890:5;5883:13;;;;;5859:9;;5852:17;;;:55;;;;5883:13;5852:55;:::i;:::-;;5678:240;5607:317::o;1240:20::-;;;;;;:::o;1196:37::-;;;;;;;;;;;;;;;:::o;4811:264::-;4854:4;4870:27;4900:15;:13;:15::i;:::-;4870:45;-1:-1:-1;4930:6:0;4925:126;4946:12;:10;:12::i;:::-;4942:1;:16;4925:126;;;5000:10;-1:-1:-1;;;;;4983:27:0;:10;4994:1;4983:13;;;;;;;;;;;;;;-1:-1:-1;;;;;4983:27:0;;4979:61;;;5039:1;5035:5;;-1:-1:-1;5028:12:0;;-1:-1:-1;5028:12:0;4979:61;4960:3;;4925:126;;;;5067:1;5060:8;;;4811:264;:::o;7356:203::-;2281:13;2271:6;;;;:23;;;;;;;;;2263:55;;;;;-1:-1:-1;;;2263:55:0;;;;;;;;;;;;-1:-1:-1;;;2263:55:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;7429:27;7437:18;7429:7;:27::i;:::-;7425:128;;;7472:6;:22;;-1:-1:-1;;7472:22:0;7481:13;7472:22;;;7532:9;;7514:28;;;;-1:-1:-1;;7514:28:0;7356:203::o;2829:213::-;2036:12;2026:6;;;;:22;;;;;;;;;:49;;;-1:-1:-1;2062:13:0;2052:6;;;;:23;;;;;;;;;2026:49;2018:90;;;;;-1:-1:-1;;;2018:90:0;;;;;;;;;;;;-1:-1:-1;;;2018:90:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;2937:39;2945:13;2960:4;2966:2;2970:5;2937:7;:39::i;:::-;2933:103;;;2992:13;;:33;;;-1:-1:-1;;;2992:33:0;;-1:-1:-1;;;;;2992:33:0;;;;;;;;;;;;;;;:13;;;;;:22;;:33;;;;;;;;;;;;;;:13;;:33;;;5:2:-1;;;;30:1;27;20:12;5:2;2992:33:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2992:33:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;2933:103:0;2829:213;;;:::o;5481:120::-;5573:9;;5566:6;:17;;;;;;;;;;;;5559:35;;;;;;;;;;;;;;;;;5531:16;;5559:35;;;5566:17;5559:35;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5559:35:0;;;;;;;;;;;;;;;;;;;;;;;5481:120;:::o;4189:116::-;4243:4;4266:14;;;;;;;;;;:32;;4189:116::o;4519:110::-;4575:4;4598:14;;;;;;;;;;:24;;;;4519:110::o;1100:42::-;;;;;;;;;;;;;;;:::o;4635:82::-;4702:5;;4672:4;4695:13;;;;;;;;;;:15;;;4635:82;:::o;2583:240::-;1926:12;1916:6;;;;:22;;;;;;;;;1908:53;;;;;-1:-1:-1;;;1908:53:0;;;;;;;;;;;;-1:-1:-1;;;1908:53:0;;;;;;;;;;;;;;;2653:10;;2644:5;:19;;:40;;;;;2676:8;2667:5;:17;;2644:40;:63;;;;;2697:10;;2688:5;:19;;2644:63;2636:72;;;;;;2719:13;;:60;;;-1:-1:-1;;;2719:60:0;;2746:10;2719:60;;;;2766:4;2719:60;;;;;;;;;;;;-1:-1:-1;;;;;2719:13:0;;;;:26;;:60;;;;;;;;;;;;;;;:13;;:60;;;5:2:-1;;;;30:1;27;20:12;5:2;2719:60:0;;;;8:9:-1;5:2;;;45:16;42:1;39;24:38;77:16;74:1;67:27;5:2;2719:60:0;;;;;;;13:2:-1;8:3;5:11;2:2;;;29:1;26;19:12;2:2;-1:-1;;2794:22:0;;;;;;;;;;;;;2719:60;2794:22;;;2583:240;:::o;1849:27::-;;;-1:-1:-1;;;;;1849:27:0;;:::o;5930:278::-;2176:13;2166:6;;;;:23;;;;;;;;;2158:55;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;6024:25;6039:9;6024:14;:25::i;:::-;:30;6016:62;;;;;-1:-1:-1;;;6016:62:0;;;;;;;;;;;;-1:-1:-1;;;6016:62:0;;;;;;;;;;;;;;;6093:38;6101:18;6121:9;6093:7;:38::i;:::-;6089:113;;;6154:9;;6147:6;:17;;;;;;;;;;27:10:-1;;39:1;23:18;;45:23;;6147:44:0;;;;;;;;-1:-1:-1;;;;;6147:44:0;;-1:-1:-1;;;;;;6147:44:0;;;;;;5930:278;:::o;4411:102::-;4460:4;4483:23;4496:9;;4483:12;:23::i;1267:17::-;;;;:::o;7151:199::-;2176:13;2166:6;;;;:23;;;;;;;;;2158:55;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;7223:26;7231:17;7223:7;:26::i;:::-;7219:125;;;7265:6;:22;;-1:-1:-1;;7265:22:0;7274:13;7265:22;;;7323:9;;7316:5;;7307:26;;;;-1:-1:-1;;7307:26:0;7151:199::o;6214:271::-;2176:13;2166:6;;;;:23;;;;;;;;;2158:55;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;6311:25;6326:9;6311:14;:25::i;:::-;6303:66;;;;;-1:-1:-1;;;6303:66:0;;;;;;;;;;;;-1:-1:-1;;;6303:66:0;;;;;;;;;;;;;;;6384:41;6392:21;6415:9;6384:7;:41::i;:::-;6380:99;;;6441:27;6458:9;6441:16;:27::i;3048:578::-;2281:13;2271:6;;;;:23;;;;;;;;;2263:55;;;;;-1:-1:-1;;;2263:55:0;;;;;;;;;;;;-1:-1:-1;;;2263:55:0;;;;;;;;;;;;;;;3119:26;3134:10;3119:14;:26::i;:::-;3111:64;;;;;-1:-1:-1;;;3111:64:0;;;;;;;;;;;;-1:-1:-1;;;3111:64:0;;;;;;;;;;;;;;;3190:37;3201:19;3222:1;3225;3190:10;:37::i;:::-;3186:434;;;3250:9;;;3243:6;:17;;;;;;;;;;;:19;;:23;;;3287:9;;3280:17;;;;:19;;:23;;;3321:9;3334:1;3321:14;3317:293;;;3355:6;:21;;-1:-1:-1;;3355:21:0;;;3402:9;;3394:5;:17;;;3434:23;;;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;3434:23:0;;;;;;;;;;3317:293;;;3508:6;:30;;-1:-1:-1;;3508:30:0;3517:21;3508:30;;;3585:9;;3578:5;;3561:34;;;;-1:-1:-1;;3561:34:0;3317:293;3048:578;;:::o;3989:90::-;4032:4;4055:17;4066:5;;4055:10;:17::i;1148:42::-;;;;;;;;;;;;;:::o;1290:21::-;;;;:::o;5363:112::-;5451:5;;5444:6;:13;;;;;;;;;;;;5437:31;;;;;;;;;;;;;;;;;5409:16;;5437:31;;;5444:13;5437:31;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;5437:31:0;;;;;;;;;;;;;;;;;;;;;;5363:112;:::o;6942:203::-;2176:13;2166:6;;;;:23;;;;;;;;;2158:55;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;-1:-1:-1;;;2158:55:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;7032:41;7040:21;7063:9;7032:7;:41::i;:::-;7028:111;;;7096:9;;7089:6;:17;;;;;;;;;;:27;;:39;6942:203::o;1047:47::-;;;;;;;;;;;;;:::o;3632:351::-;2393:21;2383:6;;;;:31;;;;;;;;;2375:71;;;;;-1:-1:-1;;;2375:71:0;;;;;;;;;;;;-1:-1:-1;;;2375:71:0;;;;;;;;;;;;;;;2514:12;:10;:12::i;:::-;2506:53;;;;;-1:-1:-1;;;2506:53:0;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;2506:53:0;;;;;;;;;;;;;;;3728:1;3720:5;;:9;3712:62;;;;-1:-1:-1;;;3712:62:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;3789:39;3800:27;3789:10;:39::i;:::-;3785:192;;;3844:6;:21;;-1:-1:-1;;3844:21:0;;;3887:9;;3879:5;:17;;;3853:12;3933:13;;;;;;;;;;;;:15;;;;3950;;;;;3915:51;;;;;;;;;;;;;;-1:-1:-1;;;;;;;;;;;3915:51:0;;;;;;;;;;3632:351::o;4311:94::-;4356:4;4379:19;4392:5;;4379:12;:19::i;7565:165::-;7614:4;7630:12;7672:8;7682:9;;7655:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;7655:37:0;;;7645:48;;;;;;7630:63;;7710:13;7718:4;7710:7;:13::i;:::-;7703:20;7565:165;-1:-1:-1;;;7565:165:0:o;8113:209::-;8200:4;8216:12;8258:8;8268:4;8274:2;8278:5;8241:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;8241:43:0;-1:-1:-1;;;;;8241:43:0;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;8241:43:0;;;8231:54;;;;;;8216:69;;8302:13;8310:4;8302:7;:13::i;:::-;8295:20;8113:209;-1:-1:-1;;;;;;8113:209:0:o;7736:185::-;7799:4;7815:12;7857:8;7867:9;;7878:4;7840:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;;;;;7840:43:0;-1:-1:-1;;;;;7840:43:0;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;7840:43:0;;;7830:54;;;;;;7815:69;;7901:13;7909:4;7901:7;:13::i;:::-;7894:20;7736:185;-1:-1:-1;;;;7736:185:0:o;6491:445::-;6559:6;6554:262;6594:1;6575:16;:14;:16::i;:::-;:20;6571:1;:24;6554:262;;;6627:9;;6620:6;:17;;;;;;;;;;:31;;-1:-1:-1;;;;;6620:44:0;;;:17;6649:1;;6620:31;;;;;;;;;;;;;;;;-1:-1:-1;;;;;6620:31:0;:44;6616:190;;;6725:9;;6718:6;:17;;;;;;;;;;6766:1;6747:16;:14;:16::i;:::-;:20;6718:50;;;;;;;;;;;;;;;;;;;;6691:9;;6684:17;;;;;;;;;;:31;;-1:-1:-1;;;;;6718:50:0;;;;6713:1;;6684:31;;;;;;;;;;;;;;:84;;;;;-1:-1:-1;;;;;6684:84:0;;;;;-1:-1:-1;;;;;6684:84:0;;;;;;6786:5;;6616:190;6597:3;;6554:262;;;-1:-1:-1;6839:9:0;;6832:6;:17;;;;;;;;;;6880:1;6861:16;:14;:16::i;:::-;:20;6832:50;;;;;;;;;;;;;;;;;;;6825:57;;-1:-1:-1;;;;;;6825:57:0;;;6899:9;;6892:17;;;;;;;;:37;;;;;-1:-1:-1;;6892:37:0;;;:::i;8505:193::-;8573:4;8589:12;8631:8;8641:9;;8652:1;8655;8614:43;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;8614:43:0;;;8604:54;;;;;;8589:69;;8675:16;8686:4;8675:10;:16::i;:::-;8668:23;8505:193;-1:-1:-1;;;;;8505:193:0:o;7927:180::-;7986:4;8002:12;8044:8;8054:9;;8065:3;8027:42;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;8027:42:0;;;8017:53;;;;;;8002:68;;8087:13;8095:4;8087:7;:13::i;8328:171::-;8380:4;8396:12;8438:8;8448:9;;8421:37;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;49:4:-1;39:7;30;26:21;22:32;13:7;6:49;8421:37:0;;;8411:48;;;;;;8396:63;;8476:16;8487:4;8476:10;:16::i;8704:409::-;8752:4;8768:20;8791:21;8807:4;8791:15;:21::i;:::-;8831:19;;;;:5;:19;;;;;;8768:44;;-1:-1:-1;8831:19:0;;8830:20;8822:46;;;;;-1:-1:-1;;;8822:46:0;;;;;;;;;;;;-1:-1:-1;;;8822:46:0;;;;;;;;;;;;;;;8879:19;;;;:5;:19;;;;;:26;;-1:-1:-1;;8879:26:0;8901:4;8879:26;;;8939:14;:12;:14::i;:::-;8919:16;;;;:10;:16;;;;;;:34;8915:192;;;-1:-1:-1;;8969:16:0;;;;:10;:16;;;;;-1:-1:-1;;;8969:27:0;;9017:4;9010:11;;8915:192;-1:-1:-1;;9052:16:0;;;;:10;:16;;;;;:18;;;;;;9084:12;;9119:420;9170:4;9186:20;9209:21;9225:4;9209:15;:21::i;:::-;9249:19;;;;:5;:19;;;;;;9186:44;;-1:-1:-1;9249:19:0;;9248:20;9240:50;;;;;-1:-1:-1;;;9240:50:0;;;;;;;;;;;;-1:-1:-1;;;9240:50:0;;;;;;;;;;;;;;;9301:19;;;;:5;:19;;;;;:26;;-1:-1:-1;;9301:26:0;9323:4;9301:26;;;9361:18;:16;:18::i;9545:139::-;9642:34;;;;;;;;;;;9665:10;9642:34;;;;;;;;26:21:-1;;;22:32;;6:49;;9642:34:0;;;;;;;9632:45;;;;;;9545:139::o;93:9593::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;93:9593:0;;;-1:-1:-1;93:9593:0;:::i;:::-;;;:::o;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;;;;;;;;;;;;;-1:-1:-1;;;;;;93:9593:0;;;;;;;;;;;;;;;;;;;;;;;;", - "source": "pragma solidity ^0.5.0;\n\nimport './openzeppelin-solidity/contracts/token/ERC20/IERC20.sol';\n\ncontract Bridge {\n event ExchangeRequest(uint value);\n event NewEpoch(uint indexed oldEpoch, uint indexed newEpoch);\n event NewEpochCancelled(uint indexed epoch);\n event NewFundsTransfer(uint indexed oldEpoch, uint indexed newEpoch);\n event EpochStart(uint indexed epoch, uint x, uint y);\n\n struct State {\n address[] validators;\n uint threshold;\n uint x;\n uint y;\n }\n\n enum Status {\n READY, // bridge is in ready to perform operations\n VOTING, // voting for changing in next epoch, but still ready\n KEYGEN, //keygen, can be cancelled\n FUNDS_TRANSFER // funds transfer, cannot be cancelled\n }\n\n enum Vote {\n CONFIRM_KEYGEN,\n CONFIRM_FUNDS_TRANSFER,\n START_VOTING,\n ADD_VALIDATOR,\n REMOVE_VALIDATOR,\n CHANGE_THRESHOLD,\n START_KEYGEN,\n CANCEL_KEYGEN,\n TRANSFER\n }\n\n mapping(uint => State) states;\n\n mapping(bytes32 => uint) public dbTransferCount;\n mapping(bytes32 => bool) public dbTransfer;\n mapping(bytes32 => uint) public votesCount;\n mapping(bytes32 => bool) public votes;\n\n Status public status;\n\n uint public epoch;\n uint public nextEpoch;\n\n uint minTxLimit;\n uint maxTxLimit;\n\n constructor(uint threshold, address[] memory validators, address _tokenContract, uint[2] memory limits) public {\n require(validators.length > 0);\n require(threshold < validators.length);\n\n tokenContract = IERC20(_tokenContract);\n\n epoch = 0;\n status = Status.KEYGEN;\n nextEpoch = 1;\n\n states[1] = State(validators, threshold, 0, 0);\n\n minTxLimit = limits[0];\n maxTxLimit = limits[1];\n\n emit NewEpoch(0, 1);\n }\n\n IERC20 public tokenContract;\n\n modifier ready {\n require(status == Status.READY, \"Not in ready state\");\n _;\n }\n\n modifier readyOrVoting {\n require(status == Status.READY || status == Status.VOTING, \"Not in ready or voting state\");\n _;\n }\n\n modifier voting {\n require(status == Status.VOTING, \"Not in voting state\");\n _;\n }\n\n modifier keygen {\n require(status == Status.KEYGEN, \"Not in keygen state\");\n _;\n }\n\n modifier fundsTransfer {\n require(status == Status.FUNDS_TRANSFER, \"Not in funds transfer state\");\n _;\n }\n\n modifier currentValidator {\n require(getPartyId() != 0, \"Not a current validator\");\n _;\n }\n\n function exchange(uint value) public ready {\n require(value >= minTxLimit && value >= 10 ** 10 && value <= maxTxLimit);\n\n tokenContract.transferFrom(msg.sender, address(this), value);\n emit ExchangeRequest(value);\n }\n\n function transfer(bytes32 hash, address to, uint value) public readyOrVoting currentValidator {\n if (tryVote(Vote.TRANSFER, hash, to, value)) {\n tokenContract.transfer(to, value);\n }\n }\n\n function confirmKeygen(uint x, uint y) public keygen {\n require(getNextPartyId(msg.sender) != 0, \"Not a next validator\");\n\n if (tryConfirm(Vote.CONFIRM_KEYGEN, x, y)) {\n states[nextEpoch].x = x;\n states[nextEpoch].y = y;\n if (nextEpoch == 1) {\n status = Status.READY;\n epoch = nextEpoch;\n emit EpochStart(epoch, x, y);\n }\n else {\n status = Status.FUNDS_TRANSFER;\n emit NewFundsTransfer(epoch, nextEpoch);\n }\n }\n }\n\n function confirmFundsTransfer() public fundsTransfer currentValidator {\n require(epoch > 0, \"First epoch does not need funds transfer\");\n\n if (tryConfirm(Vote.CONFIRM_FUNDS_TRANSFER)) {\n status = Status.READY;\n epoch = nextEpoch;\n emit EpochStart(epoch, states[epoch].x, states[epoch].y);\n }\n }\n\n function getParties() view public returns (uint) {\n return getParties(epoch);\n }\n\n function getNextParties() view public returns (uint) {\n return getParties(nextEpoch);\n }\n\n function getParties(uint _epoch) view public returns (uint) {\n return states[_epoch].validators.length;\n }\n\n function getThreshold() view public returns (uint) {\n return getThreshold(epoch);\n }\n\n function getNextThreshold() view public returns (uint) {\n return getThreshold(nextEpoch);\n }\n\n function getThreshold(uint _epoch) view public returns (uint) {\n return states[_epoch].threshold;\n }\n\n function getX() view public returns (uint) {\n return states[epoch].x;\n }\n\n function getY() view public returns (uint) {\n return states[epoch].y;\n }\n\n function getPartyId() view public returns (uint) {\n address[] memory validators = getValidators();\n for (uint i = 0; i < getParties(); i++) {\n if (validators[i] == msg.sender)\n return i + 1;\n }\n return 0;\n }\n\n function getNextPartyId(address a) view public returns (uint) {\n address[] memory validators = getNextValidators();\n for (uint i = 0; i < getNextParties(); i++) {\n if (validators[i] == a)\n return i + 1;\n }\n return 0;\n }\n\n function getValidators() view public returns (address[] memory) {\n return states[epoch].validators;\n }\n\n function getNextValidators() view public returns (address[] memory) {\n return states[nextEpoch].validators;\n }\n\n function startVoting() public readyOrVoting currentValidator {\n if (tryVote(Vote.START_VOTING)) {\n nextEpoch++;\n status = Status.VOTING;\n states[nextEpoch].threshold = states[epoch].threshold;\n states[nextEpoch].validators = states[epoch].validators;\n }\n }\n\n function voteAddValidator(address validator) public voting currentValidator {\n require(getNextPartyId(validator) == 0, \"Already a validator\");\n\n if (tryVote(Vote.ADD_VALIDATOR, validator)) {\n states[nextEpoch].validators.push(validator);\n }\n }\n\n function voteRemoveValidator(address validator) public voting currentValidator {\n require(getNextPartyId(validator) != 0, \"Already not a validator\");\n\n if (tryVote(Vote.REMOVE_VALIDATOR, validator)) {\n _removeValidator(validator);\n }\n }\n\n function _removeValidator(address validator) private {\n for (uint i = 0; i < getNextParties() - 1; i++) {\n if (states[nextEpoch].validators[i] == validator) {\n states[nextEpoch].validators[i] = states[nextEpoch].validators[getNextParties() - 1];\n break;\n }\n }\n delete states[nextEpoch].validators[getNextParties() - 1];\n states[nextEpoch].validators.length--;\n }\n\n function voteChangeThreshold(uint threshold) public voting currentValidator {\n if (tryVote(Vote.CHANGE_THRESHOLD, threshold)) {\n states[nextEpoch].threshold = threshold;\n }\n }\n\n function voteStartKeygen() public voting currentValidator {\n if (tryVote(Vote.START_KEYGEN)) {\n status = Status.KEYGEN;\n\n emit NewEpoch(epoch, nextEpoch);\n }\n }\n\n function voteCancelKeygen() public keygen currentValidator {\n if (tryVote(Vote.CANCEL_KEYGEN)) {\n status = Status.VOTING;\n\n emit NewEpochCancelled(nextEpoch);\n }\n }\n\n function tryVote(Vote voteType) private returns (bool) {\n bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch));\n return putVote(vote);\n }\n\n function tryVote(Vote voteType, address addr) private returns (bool) {\n bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch, addr));\n return putVote(vote);\n }\n\n function tryVote(Vote voteType, uint num) private returns (bool) {\n bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch, num));\n return putVote(vote);\n }\n\n function tryVote(Vote voteType, bytes32 hash, address to, uint value) private returns (bool) {\n bytes32 vote = keccak256(abi.encodePacked(voteType, hash, to, value));\n return putVote(vote);\n }\n\n function tryConfirm(Vote voteType) private returns (bool) {\n bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch));\n return putConfirm(vote);\n }\n\n function tryConfirm(Vote voteType, uint x, uint y) private returns (bool) {\n bytes32 vote = keccak256(abi.encodePacked(voteType, nextEpoch, x, y));\n return putConfirm(vote);\n }\n\n function putVote(bytes32 vote) private returns (bool) {\n bytes32 personalVote = personalizeVote(vote);\n require(!votes[personalVote], \"Voted already\");\n\n votes[personalVote] = true;\n if (votesCount[vote] == getThreshold()) {\n votesCount[vote] = 2 ** 255;\n return true;\n } else {\n votesCount[vote]++;\n return false;\n }\n }\n\n function putConfirm(bytes32 vote) private returns (bool) {\n bytes32 personalVote = personalizeVote(vote);\n require(!votes[personalVote], \"Confirmed already\");\n\n votes[personalVote] = true;\n if (votesCount[vote] == getNextThreshold()) {\n votesCount[vote] = 2 ** 255;\n return true;\n } else {\n votesCount[vote]++;\n return false;\n }\n }\n\n function personalizeVote(bytes32 vote) private view returns (bytes32) {\n return keccak256(abi.encodePacked(vote, msg.sender));\n }\n}\n", - "sourcePath": "/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/Bridge.sol", - "ast": { - "absolutePath": "/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/Bridge.sol", - "exportedSymbols": { - "Bridge": [ - 1138 - ] - }, - "id": 1139, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 1, - "literals": [ - "solidity", - "^", - "0.5", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "0:23:0" - }, - { - "absolutePath": "/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "file": "./openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "id": 2, - "nodeType": "ImportDirective", - "scope": 1139, - "sourceUnit": 9774, - "src": "25:66:0", - "symbolAliases": [], - "unitAlias": "" - }, - { - "baseContracts": [], - "contractDependencies": [], - "contractKind": "contract", - "documentation": null, - "fullyImplemented": true, - "id": 1138, - "linearizedBaseContracts": [ - 1138 - ], - "name": "Bridge", - "nodeType": "ContractDefinition", - "nodes": [ - { - "anonymous": false, - "documentation": null, - "id": 6, - "name": "ExchangeRequest", - "nodeType": "EventDefinition", - "parameters": { - "id": 5, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 4, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 6, - "src": "137:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 3, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "137:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "136:12:0" - }, - "src": "115:34:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 12, - "name": "NewEpoch", - "nodeType": "EventDefinition", - "parameters": { - "id": 11, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 8, - "indexed": true, - "name": "oldEpoch", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "169:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 7, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "169:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 10, - "indexed": true, - "name": "newEpoch", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "192:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "192:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "168:46:0" - }, - "src": "154:61:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 16, - "name": "NewEpochCancelled", - "nodeType": "EventDefinition", - "parameters": { - "id": 15, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 14, - "indexed": true, - "name": "epoch", - "nodeType": "VariableDeclaration", - "scope": 16, - "src": "244:18:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 13, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "244:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "243:20:0" - }, - "src": "220:44:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 22, - "name": "NewFundsTransfer", - "nodeType": "EventDefinition", - "parameters": { - "id": 21, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 18, - "indexed": true, - "name": "oldEpoch", - "nodeType": "VariableDeclaration", - "scope": 22, - "src": "292:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 17, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "292:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 20, - "indexed": true, - "name": "newEpoch", - "nodeType": "VariableDeclaration", - "scope": 22, - "src": "315:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 19, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "315:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "291:46:0" - }, - "src": "269:69:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 30, - "name": "EpochStart", - "nodeType": "EventDefinition", - "parameters": { - "id": 29, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 24, - "indexed": true, - "name": "epoch", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "360:18:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 23, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "360:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 26, - "indexed": false, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "380:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 25, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "380:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 28, - "indexed": false, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "388:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 27, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "388:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "359:36:0" - }, - "src": "343:53:0" - }, - { - "canonicalName": "Bridge.State", - "id": 40, - "members": [ - { - "constant": false, - "id": 33, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "425:20:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 31, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "425:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 32, - "length": null, - "nodeType": "ArrayTypeName", - "src": "425:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 35, - "name": "threshold", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "455:14:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 34, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "455:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 37, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "479:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 36, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "479:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 39, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "495:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 38, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "495:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "name": "State", - "nodeType": "StructDefinition", - "scope": 1138, - "src": "402:106:0", - "visibility": "public" - }, - { - "canonicalName": "Bridge.Status", - "id": 45, - "members": [ - { - "id": 41, - "name": "READY", - "nodeType": "EnumValue", - "src": "536:5:0" - }, - { - "id": 42, - "name": "VOTING", - "nodeType": "EnumValue", - "src": "595:6:0" - }, - { - "id": 43, - "name": "KEYGEN", - "nodeType": "EnumValue", - "src": "665:6:0" - }, - { - "id": 44, - "name": "FUNDS_TRANSFER", - "nodeType": "EnumValue", - "src": "708:14:0" - } - ], - "name": "Status", - "nodeType": "EnumDefinition", - "src": "514:253:0" - }, - { - "canonicalName": "Bridge.Vote", - "id": 55, - "members": [ - { - "id": 46, - "name": "CONFIRM_KEYGEN", - "nodeType": "EnumValue", - "src": "793:14:0" - }, - { - "id": 47, - "name": "CONFIRM_FUNDS_TRANSFER", - "nodeType": "EnumValue", - "src": "817:22:0" - }, - { - "id": 48, - "name": "START_VOTING", - "nodeType": "EnumValue", - "src": "849:12:0" - }, - { - "id": 49, - "name": "ADD_VALIDATOR", - "nodeType": "EnumValue", - "src": "871:13:0" - }, - { - "id": 50, - "name": "REMOVE_VALIDATOR", - "nodeType": "EnumValue", - "src": "894:16:0" - }, - { - "id": 51, - "name": "CHANGE_THRESHOLD", - "nodeType": "EnumValue", - "src": "920:16:0" - }, - { - "id": 52, - "name": "START_KEYGEN", - "nodeType": "EnumValue", - "src": "946:12:0" - }, - { - "id": 53, - "name": "CANCEL_KEYGEN", - "nodeType": "EnumValue", - "src": "968:13:0" - }, - { - "id": 54, - "name": "TRANSFER", - "nodeType": "EnumValue", - "src": "991:8:0" - } - ], - "name": "Vote", - "nodeType": "EnumDefinition", - "src": "773:232:0" - }, - { - "constant": false, - "id": 59, - "name": "states", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1011:29:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State)" - }, - "typeName": { - "id": 58, - "keyType": { - "id": 56, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1019:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Mapping", - "src": "1011:22:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State)" - }, - "valueType": { - "contractScope": null, - "id": 57, - "name": "State", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 40, - "src": "1027:5:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage_ptr", - "typeString": "struct Bridge.State" - } - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 63, - "name": "dbTransferCount", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1047:47:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "typeName": { - "id": 62, - "keyType": { - "id": 60, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1055:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1047:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "valueType": { - "id": 61, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1066:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 67, - "name": "dbTransfer", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1100:42:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "typeName": { - "id": 66, - "keyType": { - "id": 64, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1108:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1100:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "valueType": { - "id": 65, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1119:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 71, - "name": "votesCount", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1148:42:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "typeName": { - "id": 70, - "keyType": { - "id": 68, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1156:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1148:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "valueType": { - "id": 69, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1167:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 75, - "name": "votes", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1196:37:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "typeName": { - "id": 74, - "keyType": { - "id": 72, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1204:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1196:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "valueType": { - "id": 73, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1215:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 77, - "name": "status", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1240:20:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "typeName": { - "contractScope": null, - "id": 76, - "name": "Status", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 45, - "src": "1240:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 79, - "name": "epoch", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1267:17:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 78, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1267:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 81, - "name": "nextEpoch", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1290:21:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 80, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1290:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 83, - "name": "minTxLimit", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1318:15:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 82, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1318:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 85, - "name": "maxTxLimit", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1339:15:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 84, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1339:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "body": { - "id": 160, - "nodeType": "Block", - "src": "1472:371:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 103, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 100, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "1490:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 101, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1490:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 102, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1510:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "1490:21:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "id": 99, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12832, - "src": "1482:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", - "typeString": "function (bool) pure" - } - }, - "id": 104, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1482:30:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 105, - "nodeType": "ExpressionStatement", - "src": "1482:30:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 110, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 107, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 87, - "src": "1530:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 108, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "1542:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 109, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1542:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1530:29:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "id": 106, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12832, - "src": "1522:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", - "typeString": "function (bool) pure" - } - }, - "id": 111, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1522:38:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 112, - "nodeType": "ExpressionStatement", - "src": "1522:38:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 117, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 113, - "name": "tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 163, - "src": "1571:13:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 115, - "name": "_tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 92, - "src": "1594:14:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 114, - "name": "IERC20", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 9773, - "src": "1587:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_IERC20_$9773_$", - "typeString": "type(contract IERC20)" - } - }, - "id": 116, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1587:22:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "src": "1571:38:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "id": 118, - "nodeType": "ExpressionStatement", - "src": "1571:38:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 121, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 119, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "1620:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "30", - "id": 120, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1628:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "1620:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 122, - "nodeType": "ExpressionStatement", - "src": "1620:9:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 126, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 123, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "1639:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 124, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "1648:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 125, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1648:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "1639:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 127, - "nodeType": "ExpressionStatement", - "src": "1639:22:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 130, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 128, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "1671:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "31", - "id": 129, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1683:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "1671:13:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 131, - "nodeType": "ExpressionStatement", - "src": "1671:13:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 141, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 132, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "1695:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 134, - "indexExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 133, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1702:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "1695:9:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 136, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "1713:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - { - "argumentTypes": null, - "id": 137, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 87, - "src": "1725:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "hexValue": "30", - "id": 138, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1736:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - { - "argumentTypes": null, - "hexValue": "30", - "id": 139, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1739:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 135, - "name": "State", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 40, - "src": "1707:5:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_struct$_State_$40_storage_ptr_$", - "typeString": "type(struct Bridge.State storage pointer)" - } - }, - "id": 140, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "structConstructorCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1707:34:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_memory", - "typeString": "struct Bridge.State memory" - } - }, - "src": "1695:46:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 142, - "nodeType": "ExpressionStatement", - "src": "1695:46:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 147, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 143, - "name": "minTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 83, - "src": "1752:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 144, - "name": "limits", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 96, - "src": "1765:6:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_memory_ptr", - "typeString": "uint256[2] memory" - } - }, - "id": 146, - "indexExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 145, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1772:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "1765:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1752:22:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 148, - "nodeType": "ExpressionStatement", - "src": "1752:22:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 153, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 149, - "name": "maxTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 85, - "src": "1784:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 150, - "name": "limits", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 96, - "src": "1797:6:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_memory_ptr", - "typeString": "uint256[2] memory" - } - }, - "id": 152, - "indexExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 151, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1804:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "1797:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1784:22:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 154, - "nodeType": "ExpressionStatement", - "src": "1784:22:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "hexValue": "30", - "id": 156, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1831:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - { - "argumentTypes": null, - "hexValue": "31", - "id": 157, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1834:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - } - ], - "id": 155, - "name": "NewEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12, - "src": "1822:8:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256)" - } - }, - "id": 158, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1822:14:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 159, - "nodeType": "EmitStatement", - "src": "1817:19:0" - } - ] - }, - "documentation": null, - "id": 161, - "implemented": true, - "kind": "constructor", - "modifiers": [], - "name": "", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 97, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 87, - "name": "threshold", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1373:14:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 86, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1373:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 90, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1389:27:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 88, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1389:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 89, - "length": null, - "nodeType": "ArrayTypeName", - "src": "1389:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 92, - "name": "_tokenContract", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1418:22:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 91, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1418:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 96, - "name": "limits", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1442:21:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_memory_ptr", - "typeString": "uint256[2]" - }, - "typeName": { - "baseType": { - "id": 93, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1442:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 95, - "length": { - "argumentTypes": null, - "hexValue": "32", - "id": 94, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1447:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "ArrayTypeName", - "src": "1442:7:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_storage_ptr", - "typeString": "uint256[2]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1372:92:0" - }, - "returnParameters": { - "id": 98, - "nodeType": "ParameterList", - "parameters": [], - "src": "1472:0:0" - }, - "scope": 1138, - "src": "1361:482:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "constant": false, - "id": 163, - "name": "tokenContract", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1849:27:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - }, - "typeName": { - "contractScope": null, - "id": 162, - "name": "IERC20", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 9773, - "src": "1849:6:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "value": null, - "visibility": "public" - }, - { - "body": { - "id": 174, - "nodeType": "Block", - "src": "1898:81:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 169, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 166, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "1916:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 167, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "1926:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 168, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1926:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "1916:22:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e207265616479207374617465", - "id": 170, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1940:20:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_965c39c15b78dbcd8a954511641ca86e15fc1ae6d6c30a67536872ccde75b679", - "typeString": "literal_string \"Not in ready state\"" - }, - "value": "Not in ready state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_965c39c15b78dbcd8a954511641ca86e15fc1ae6d6c30a67536872ccde75b679", - "typeString": "literal_string \"Not in ready state\"" - } - ], - "id": 165, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "1908:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 171, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1908:53:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 172, - "nodeType": "ExpressionStatement", - "src": "1908:53:0" - }, - { - "id": 173, - "nodeType": "PlaceholderStatement", - "src": "1971:1:0" - } - ] - }, - "documentation": null, - "id": 175, - "name": "ready", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 164, - "nodeType": "ParameterList", - "parameters": [], - "src": "1898:0:0" - }, - "src": "1883:96:0", - "visibility": "internal" - }, - { - "body": { - "id": 191, - "nodeType": "Block", - "src": "2008:118:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 186, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 181, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 178, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2026:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 179, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2036:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 180, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2036:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2026:22:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "||", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 185, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 182, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2052:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 183, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2062:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 184, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2062:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2052:23:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2026:49:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e207265616479206f7220766f74696e67207374617465", - "id": 187, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2077:30:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_7e3f7359baa731593d4e3921720b92600c22ed1d950d208e0c826ad2eddebe96", - "typeString": "literal_string \"Not in ready or voting state\"" - }, - "value": "Not in ready or voting state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_7e3f7359baa731593d4e3921720b92600c22ed1d950d208e0c826ad2eddebe96", - "typeString": "literal_string \"Not in ready or voting state\"" - } - ], - "id": 177, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2018:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 188, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2018:90:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 189, - "nodeType": "ExpressionStatement", - "src": "2018:90:0" - }, - { - "id": 190, - "nodeType": "PlaceholderStatement", - "src": "2118:1:0" - } - ] - }, - "documentation": null, - "id": 192, - "name": "readyOrVoting", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 176, - "nodeType": "ParameterList", - "parameters": [], - "src": "2008:0:0" - }, - "src": "1985:141:0", - "visibility": "internal" - }, - { - "body": { - "id": 203, - "nodeType": "Block", - "src": "2148:83:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 198, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 195, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2166:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 196, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2176:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 197, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2176:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2166:23:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e20766f74696e67207374617465", - "id": 199, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2191:21:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_0cbee9834b110b21e0730bf5c3d2972fb9867ff221df239e7ae60883592f05d1", - "typeString": "literal_string \"Not in voting state\"" - }, - "value": "Not in voting state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_0cbee9834b110b21e0730bf5c3d2972fb9867ff221df239e7ae60883592f05d1", - "typeString": "literal_string \"Not in voting state\"" - } - ], - "id": 194, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2158:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 200, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2158:55:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 201, - "nodeType": "ExpressionStatement", - "src": "2158:55:0" - }, - { - "id": 202, - "nodeType": "PlaceholderStatement", - "src": "2223:1:0" - } - ] - }, - "documentation": null, - "id": 204, - "name": "voting", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 193, - "nodeType": "ParameterList", - "parameters": [], - "src": "2148:0:0" - }, - "src": "2132:99:0", - "visibility": "internal" - }, - { - "body": { - "id": 215, - "nodeType": "Block", - "src": "2253:83:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 210, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 207, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2271:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 208, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2281:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 209, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2281:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2271:23:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e206b657967656e207374617465", - "id": 211, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2296:21:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_ed0fee6382e0651a224348a21558d03a4a439c3bd5edc24945894a3417c14010", - "typeString": "literal_string \"Not in keygen state\"" - }, - "value": "Not in keygen state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_ed0fee6382e0651a224348a21558d03a4a439c3bd5edc24945894a3417c14010", - "typeString": "literal_string \"Not in keygen state\"" - } - ], - "id": 206, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2263:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 212, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2263:55:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 213, - "nodeType": "ExpressionStatement", - "src": "2263:55:0" - }, - { - "id": 214, - "nodeType": "PlaceholderStatement", - "src": "2328:1:0" - } - ] - }, - "documentation": null, - "id": 216, - "name": "keygen", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 205, - "nodeType": "ParameterList", - "parameters": [], - "src": "2253:0:0" - }, - "src": "2237:99:0", - "visibility": "internal" - }, - { - "body": { - "id": 227, - "nodeType": "Block", - "src": "2365:99:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 222, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 219, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2383:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 220, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2393:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 221, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "FUNDS_TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2393:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2383:31:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e2066756e6473207472616e73666572207374617465", - "id": 223, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2416:29:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_6347c9fecd6f58520ad10dfd1347ce3dc42cc0eed7a4182ca64dd11c69fc3008", - "typeString": "literal_string \"Not in funds transfer state\"" - }, - "value": "Not in funds transfer state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_6347c9fecd6f58520ad10dfd1347ce3dc42cc0eed7a4182ca64dd11c69fc3008", - "typeString": "literal_string \"Not in funds transfer state\"" - } - ], - "id": 218, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2375:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 224, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2375:71:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 225, - "nodeType": "ExpressionStatement", - "src": "2375:71:0" - }, - { - "id": 226, - "nodeType": "PlaceholderStatement", - "src": "2456:1:0" - } - ] - }, - "documentation": null, - "id": 228, - "name": "fundsTransfer", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 217, - "nodeType": "ParameterList", - "parameters": [], - "src": "2365:0:0" - }, - "src": "2342:122:0", - "visibility": "internal" - }, - { - "body": { - "id": 239, - "nodeType": "Block", - "src": "2496:81:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 234, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 231, - "name": "getPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 552, - "src": "2514:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 232, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2514:12:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 233, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2530:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "2514:17:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420612063757272656e742076616c696461746f72", - "id": 235, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2533:25:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_8dc18d5bb1361900b9758b388df331056e31071cae84b276c0f03794c4dc634a", - "typeString": "literal_string \"Not a current validator\"" - }, - "value": "Not a current validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_8dc18d5bb1361900b9758b388df331056e31071cae84b276c0f03794c4dc634a", - "typeString": "literal_string \"Not a current validator\"" - } - ], - "id": 230, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2506:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 236, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2506:53:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 237, - "nodeType": "ExpressionStatement", - "src": "2506:53:0" - }, - { - "id": 238, - "nodeType": "PlaceholderStatement", - "src": "2569:1:0" - } - ] - }, - "documentation": null, - "id": 240, - "name": "currentValidator", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 229, - "nodeType": "ParameterList", - "parameters": [], - "src": "2496:0:0" - }, - "src": "2470:107:0", - "visibility": "internal" - }, - { - "body": { - "id": 278, - "nodeType": "Block", - "src": "2626:197:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 260, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 256, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 250, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 248, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2644:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "argumentTypes": null, - "id": 249, - "name": "minTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 83, - "src": "2653:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "2644:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "&&", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 255, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 251, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2667:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_rational_10000000000_by_1", - "typeString": "int_const 10000000000" - }, - "id": 254, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "hexValue": "3130", - "id": 252, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2676:2:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_10_by_1", - "typeString": "int_const 10" - }, - "value": "10" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "argumentTypes": null, - "hexValue": "3130", - "id": 253, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2682:2:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_10_by_1", - "typeString": "int_const 10" - }, - "value": "10" - }, - "src": "2676:8:0", - "typeDescriptions": { - "typeIdentifier": "t_rational_10000000000_by_1", - "typeString": "int_const 10000000000" - } - }, - "src": "2667:17:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2644:40:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "&&", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 259, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 257, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2688:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<=", - "rightExpression": { - "argumentTypes": null, - "id": 258, - "name": "maxTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 85, - "src": "2697:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "2688:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2644:63:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "id": 247, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12832, - "src": "2636:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", - "typeString": "function (bool) pure" - } - }, - "id": 261, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2636:72:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 262, - "nodeType": "ExpressionStatement", - "src": "2636:72:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 266, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "2746:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 267, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2746:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - }, - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 269, - "name": "this", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12845, - "src": "2766:4:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_Bridge_$1138", - "typeString": "contract Bridge" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_contract$_Bridge_$1138", - "typeString": "contract Bridge" - } - ], - "id": 268, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "2758:7:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": "address" - }, - "id": 270, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2758:13:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 271, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2773:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 263, - "name": "tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 163, - "src": "2719:13:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "id": 265, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "transferFrom", - "nodeType": "MemberAccess", - "referencedDeclaration": 9756, - "src": "2719:26:0", - "typeDescriptions": { - "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (address,address,uint256) external returns (bool)" - } - }, - "id": 272, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2719:60:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 273, - "nodeType": "ExpressionStatement", - "src": "2719:60:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 275, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2810:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 274, - "name": "ExchangeRequest", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 6, - "src": "2794:15:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", - "typeString": "function (uint256)" - } - }, - "id": 276, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2794:22:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 277, - "nodeType": "EmitStatement", - "src": "2789:27:0" - } - ] - }, - "documentation": null, - "id": 279, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 245, - "modifierName": { - "argumentTypes": null, - "id": 244, - "name": "ready", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 175, - "src": "2620:5:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "2620:5:0" - } - ], - "name": "exchange", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 243, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 242, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 279, - "src": "2601:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 241, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "2601:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2600:12:0" - }, - "returnParameters": { - "id": 246, - "nodeType": "ParameterList", - "parameters": [], - "src": "2626:0:0" - }, - "scope": 1138, - "src": "2583:240:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 308, - "nodeType": "Block", - "src": "2923:119:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 293, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "2945:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 294, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2945:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 295, - "name": "hash", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 281, - "src": "2960:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "argumentTypes": null, - "id": 296, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 283, - "src": "2966:2:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 297, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 285, - "src": "2970:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 292, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 962, - "src": "2937:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_bytes32_$_t_address_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,bytes32,address,uint256) returns (bool)" - } - }, - "id": 298, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2937:39:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 307, - "nodeType": "IfStatement", - "src": "2933:103:0", - "trueBody": { - "id": 306, - "nodeType": "Block", - "src": "2978:58:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 302, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 283, - "src": "3015:2:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 303, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 285, - "src": "3019:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 299, - "name": "tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 163, - "src": "2992:13:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "id": 301, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "transfer", - "nodeType": "MemberAccess", - "referencedDeclaration": 9727, - "src": "2992:22:0", - "typeDescriptions": { - "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (address,uint256) external returns (bool)" - } - }, - "id": 304, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2992:33:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 305, - "nodeType": "ExpressionStatement", - "src": "2992:33:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 309, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 288, - "modifierName": { - "argumentTypes": null, - "id": 287, - "name": "readyOrVoting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 192, - "src": "2892:13:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "2892:13:0" - }, - { - "arguments": null, - "id": 290, - "modifierName": { - "argumentTypes": null, - "id": 289, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "2906:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "2906:16:0" - } - ], - "name": "transfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 286, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 281, - "name": "hash", - "nodeType": "VariableDeclaration", - "scope": 309, - "src": "2847:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 280, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "2847:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 283, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 309, - "src": "2861:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 282, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2861:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 285, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 309, - "src": "2873:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 284, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "2873:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2846:38:0" - }, - "returnParameters": { - "id": 291, - "nodeType": "ParameterList", - "parameters": [], - "src": "2923:0:0" - }, - "scope": 1138, - "src": "2829:213:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 381, - "nodeType": "Block", - "src": "3101:525:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 324, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 320, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "3134:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 321, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3134:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - ], - "id": 319, - "name": "getNextPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 592, - "src": "3119:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) view returns (uint256)" - } - }, - "id": 322, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3119:26:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 323, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3149:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "3119:31:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f742061206e6578742076616c696461746f72", - "id": 325, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3152:22:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_44981c92ce908443b2fa5f878c54791e1a0c95d4cc04ea4f4d9224b3ec030922", - "typeString": "literal_string \"Not a next validator\"" - }, - "value": "Not a next validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_44981c92ce908443b2fa5f878c54791e1a0c95d4cc04ea4f4d9224b3ec030922", - "typeString": "literal_string \"Not a next validator\"" - } - ], - "id": 318, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "3111:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 326, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3111:64:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 327, - "nodeType": "ExpressionStatement", - "src": "3111:64:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 329, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "3201:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 330, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CONFIRM_KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3201:19:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 331, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 311, - "src": "3222:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 332, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 313, - "src": "3225:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 328, - "name": "tryConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 984, - 1012 - ], - "referencedDeclaration": 1012, - "src": "3190:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_uint256_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,uint256,uint256) returns (bool)" - } - }, - "id": 333, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3190:37:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 380, - "nodeType": "IfStatement", - "src": "3186:434:0", - "trueBody": { - "id": 379, - "nodeType": "Block", - "src": "3229:391:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 339, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 334, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3243:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 336, - "indexExpression": { - "argumentTypes": null, - "id": 335, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3250:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3243:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 337, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "x", - "nodeType": "MemberAccess", - "referencedDeclaration": 37, - "src": "3243:19:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 338, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 311, - "src": "3265:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3243:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 340, - "nodeType": "ExpressionStatement", - "src": "3243:23:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 346, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 341, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3280:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 343, - "indexExpression": { - "argumentTypes": null, - "id": 342, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3287:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3280:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 344, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "y", - "nodeType": "MemberAccess", - "referencedDeclaration": 39, - "src": "3280:19:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 345, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 313, - "src": "3302:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3280:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 347, - "nodeType": "ExpressionStatement", - "src": "3280:23:0" - }, - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 350, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 348, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3321:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 349, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3334:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "3321:14:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": { - "id": 377, - "nodeType": "Block", - "src": "3490:120:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 370, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 367, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "3508:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 368, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "3517:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 369, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "FUNDS_TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3517:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "3508:30:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 371, - "nodeType": "ExpressionStatement", - "src": "3508:30:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 373, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3578:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 374, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3585:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 372, - "name": "NewFundsTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 22, - "src": "3561:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256)" - } - }, - "id": 375, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3561:34:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 376, - "nodeType": "EmitStatement", - "src": "3556:39:0" - } - ] - }, - "id": 378, - "nodeType": "IfStatement", - "src": "3317:293:0", - "trueBody": { - "id": 366, - "nodeType": "Block", - "src": "3337:135:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 354, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 351, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "3355:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 352, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "3364:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 353, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3364:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "3355:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 355, - "nodeType": "ExpressionStatement", - "src": "3355:21:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 358, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 356, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3394:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 357, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3402:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3394:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 359, - "nodeType": "ExpressionStatement", - "src": "3394:17:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 361, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3445:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 362, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 311, - "src": "3452:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 363, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 313, - "src": "3455:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 360, - "name": "EpochStart", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 30, - "src": "3434:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256,uint256)" - } - }, - "id": 364, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3434:23:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 365, - "nodeType": "EmitStatement", - "src": "3429:28:0" - } - ] - } - } - ] - } - } - ] - }, - "documentation": null, - "id": 382, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 316, - "modifierName": { - "argumentTypes": null, - "id": 315, - "name": "keygen", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 216, - "src": "3094:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "3094:6:0" - } - ], - "name": "confirmKeygen", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 314, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 311, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 382, - "src": "3071:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 310, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "3071:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 313, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 382, - "src": "3079:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 312, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "3079:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "3070:16:0" - }, - "returnParameters": { - "id": 317, - "nodeType": "ParameterList", - "parameters": [], - "src": "3101:0:0" - }, - "scope": 1138, - "src": "3048:578:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 423, - "nodeType": "Block", - "src": "3702:281:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 392, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 390, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3720:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 391, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3728:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "3720:9:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "46697273742065706f636820646f6573206e6f74206e6565642066756e6473207472616e73666572", - "id": 393, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3731:42:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_8ddae2cc9da30ed8c59c39c6a950ef823ea484ac89ff6f37abb0317fb5f679a1", - "typeString": "literal_string \"First epoch does not need funds transfer\"" - }, - "value": "First epoch does not need funds transfer" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_8ddae2cc9da30ed8c59c39c6a950ef823ea484ac89ff6f37abb0317fb5f679a1", - "typeString": "literal_string \"First epoch does not need funds transfer\"" - } - ], - "id": 389, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "3712:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 394, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3712:62:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 395, - "nodeType": "ExpressionStatement", - "src": "3712:62:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 397, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "3800:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 398, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CONFIRM_FUNDS_TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3800:27:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 396, - "name": "tryConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 984, - 1012 - ], - "referencedDeclaration": 984, - "src": "3789:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 399, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3789:39:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 422, - "nodeType": "IfStatement", - "src": "3785:192:0", - "trueBody": { - "id": 421, - "nodeType": "Block", - "src": "3830:147:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 403, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 400, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "3844:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 401, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "3853:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 402, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3853:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "3844:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 404, - "nodeType": "ExpressionStatement", - "src": "3844:21:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 407, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 405, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3879:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 406, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3887:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3879:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 408, - "nodeType": "ExpressionStatement", - "src": "3879:17:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 410, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3926:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 411, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3933:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 413, - "indexExpression": { - "argumentTypes": null, - "id": 412, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3940:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3933:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 414, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "x", - "nodeType": "MemberAccess", - "referencedDeclaration": 37, - "src": "3933:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 415, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3950:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 417, - "indexExpression": { - "argumentTypes": null, - "id": 416, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3957:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3950:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 418, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "y", - "nodeType": "MemberAccess", - "referencedDeclaration": 39, - "src": "3950:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 409, - "name": "EpochStart", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 30, - "src": "3915:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256,uint256)" - } - }, - "id": 419, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3915:51:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 420, - "nodeType": "EmitStatement", - "src": "3910:56:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 424, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 385, - "modifierName": { - "argumentTypes": null, - "id": 384, - "name": "fundsTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 228, - "src": "3671:13:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "3671:13:0" - }, - { - "arguments": null, - "id": 387, - "modifierName": { - "argumentTypes": null, - "id": 386, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "3685:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "3685:16:0" - } - ], - "name": "confirmFundsTransfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 383, - "nodeType": "ParameterList", - "parameters": [], - "src": "3661:2:0" - }, - "returnParameters": { - "id": 388, - "nodeType": "ParameterList", - "parameters": [], - "src": "3702:0:0" - }, - "scope": 1138, - "src": "3632:351:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 433, - "nodeType": "Block", - "src": "4038:41:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 430, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4066:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 429, - "name": "getParties", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 434, - 458 - ], - "referencedDeclaration": 458, - "src": "4055:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 431, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4055:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 428, - "id": 432, - "nodeType": "Return", - "src": "4048:24:0" - } - ] - }, - "documentation": null, - "id": 434, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getParties", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 425, - "nodeType": "ParameterList", - "parameters": [], - "src": "4008:2:0" - }, - "returnParameters": { - "id": 428, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 427, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 434, - "src": "4032:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 426, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4032:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4031:6:0" - }, - "scope": 1138, - "src": "3989:90:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 443, - "nodeType": "Block", - "src": "4138:45:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 440, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "4166:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 439, - "name": "getParties", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 434, - 458 - ], - "referencedDeclaration": 458, - "src": "4155:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 441, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4155:21:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 438, - "id": 442, - "nodeType": "Return", - "src": "4148:28:0" - } - ] - }, - "documentation": null, - "id": 444, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextParties", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 435, - "nodeType": "ParameterList", - "parameters": [], - "src": "4108:2:0" - }, - "returnParameters": { - "id": 438, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 437, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 444, - "src": "4132:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 436, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4132:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4131:6:0" - }, - "scope": 1138, - "src": "4085:98:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 457, - "nodeType": "Block", - "src": "4249:56:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 451, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4266:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 453, - "indexExpression": { - "argumentTypes": null, - "id": 452, - "name": "_epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 446, - "src": "4273:6:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4266:14:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 454, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "4266:25:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 455, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "4266:32:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 450, - "id": 456, - "nodeType": "Return", - "src": "4259:39:0" - } - ] - }, - "documentation": null, - "id": 458, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getParties", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 447, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 446, - "name": "_epoch", - "nodeType": "VariableDeclaration", - "scope": 458, - "src": "4209:11:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 445, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4209:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4208:13:0" - }, - "returnParameters": { - "id": 450, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 449, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 458, - "src": "4243:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 448, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4243:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4242:6:0" - }, - "scope": 1138, - "src": "4189:116:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 467, - "nodeType": "Block", - "src": "4362:43:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 464, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4392:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 463, - "name": "getThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 468, - 491 - ], - "referencedDeclaration": 491, - "src": "4379:12:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 465, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4379:19:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 462, - "id": 466, - "nodeType": "Return", - "src": "4372:26:0" - } - ] - }, - "documentation": null, - "id": 468, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 459, - "nodeType": "ParameterList", - "parameters": [], - "src": "4332:2:0" - }, - "returnParameters": { - "id": 462, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 461, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 468, - "src": "4356:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 460, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4356:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4355:6:0" - }, - "scope": 1138, - "src": "4311:94:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 477, - "nodeType": "Block", - "src": "4466:47:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 474, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "4496:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 473, - "name": "getThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 468, - 491 - ], - "referencedDeclaration": 491, - "src": "4483:12:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 475, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4483:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 472, - "id": 476, - "nodeType": "Return", - "src": "4476:30:0" - } - ] - }, - "documentation": null, - "id": 478, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 469, - "nodeType": "ParameterList", - "parameters": [], - "src": "4436:2:0" - }, - "returnParameters": { - "id": 472, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 471, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 478, - "src": "4460:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 470, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4460:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4459:6:0" - }, - "scope": 1138, - "src": "4411:102:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 490, - "nodeType": "Block", - "src": "4581:48:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 485, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4598:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 487, - "indexExpression": { - "argumentTypes": null, - "id": 486, - "name": "_epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 480, - "src": "4605:6:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4598:14:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 488, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "4598:24:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 484, - "id": 489, - "nodeType": "Return", - "src": "4591:31:0" - } - ] - }, - "documentation": null, - "id": 491, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 481, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 480, - "name": "_epoch", - "nodeType": "VariableDeclaration", - "scope": 491, - "src": "4541:11:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 479, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4541:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4540:13:0" - }, - "returnParameters": { - "id": 484, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 483, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 491, - "src": "4575:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 482, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4575:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4574:6:0" - }, - "scope": 1138, - "src": "4519:110:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 501, - "nodeType": "Block", - "src": "4678:39:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 496, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4695:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 498, - "indexExpression": { - "argumentTypes": null, - "id": 497, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4702:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4695:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 499, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "x", - "nodeType": "MemberAccess", - "referencedDeclaration": 37, - "src": "4695:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 495, - "id": 500, - "nodeType": "Return", - "src": "4688:22:0" - } - ] - }, - "documentation": null, - "id": 502, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getX", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 492, - "nodeType": "ParameterList", - "parameters": [], - "src": "4648:2:0" - }, - "returnParameters": { - "id": 495, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 494, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 502, - "src": "4672:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 493, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4672:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4671:6:0" - }, - "scope": 1138, - "src": "4635:82:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 512, - "nodeType": "Block", - "src": "4766:39:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 507, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4783:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 509, - "indexExpression": { - "argumentTypes": null, - "id": 508, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4790:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4783:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 510, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "y", - "nodeType": "MemberAccess", - "referencedDeclaration": 39, - "src": "4783:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 506, - "id": 511, - "nodeType": "Return", - "src": "4776:22:0" - } - ] - }, - "documentation": null, - "id": 513, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getY", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 503, - "nodeType": "ParameterList", - "parameters": [], - "src": "4736:2:0" - }, - "returnParameters": { - "id": 506, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 505, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 513, - "src": "4760:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 504, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4760:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4759:6:0" - }, - "scope": 1138, - "src": "4723:82:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 551, - "nodeType": "Block", - "src": "4860:215:0", - "statements": [ - { - "assignments": [ - 521 - ], - "declarations": [ - { - "constant": false, - "id": 521, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 551, - "src": "4870:27:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 519, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "4870:7:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 520, - "length": null, - "nodeType": "ArrayTypeName", - "src": "4870:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 524, - "initialValue": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 522, - "name": "getValidators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 604, - "src": "4900:13:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_array$_t_address_$dyn_memory_ptr_$", - "typeString": "function () view returns (address[] memory)" - } - }, - "id": 523, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4900:15:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "4870:45:0" - }, - { - "body": { - "id": 547, - "nodeType": "Block", - "src": "4965:86:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 541, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 536, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 521, - "src": "4983:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 538, - "indexExpression": { - "argumentTypes": null, - "id": 537, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "4994:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4983:13:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 539, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "5000:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 540, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "5000:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - }, - "src": "4983:27:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 546, - "nodeType": "IfStatement", - "src": "4979:61:0", - "trueBody": { - "expression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 544, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 542, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "5035:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "+", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 543, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5039:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "5035:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 517, - "id": 545, - "nodeType": "Return", - "src": "5028:12:0" - } - } - ] - }, - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 532, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 529, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "4942:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 530, - "name": "getParties", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 434, - 458 - ], - "referencedDeclaration": 434, - "src": "4946:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 531, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4946:12:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "4942:16:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 548, - "initializationExpression": { - "assignments": [ - 526 - ], - "declarations": [ - { - "constant": false, - "id": 526, - "name": "i", - "nodeType": "VariableDeclaration", - "scope": 548, - "src": "4930:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 525, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4930:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 528, - "initialValue": { - "argumentTypes": null, - "hexValue": "30", - "id": 527, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "4939:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "nodeType": "VariableDeclarationStatement", - "src": "4930:10:0" - }, - "loopExpression": { - "expression": { - "argumentTypes": null, - "id": 534, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "4960:3:0", - "subExpression": { - "argumentTypes": null, - "id": 533, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "4960:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 535, - "nodeType": "ExpressionStatement", - "src": "4960:3:0" - }, - "nodeType": "ForStatement", - "src": "4925:126:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "30", - "id": 549, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5067:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "functionReturnParameters": 517, - "id": 550, - "nodeType": "Return", - "src": "5060:8:0" - } - ] - }, - "documentation": null, - "id": 552, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getPartyId", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 514, - "nodeType": "ParameterList", - "parameters": [], - "src": "4830:2:0" - }, - "returnParameters": { - "id": 517, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 516, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 552, - "src": "4854:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 515, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4854:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4853:6:0" - }, - "scope": 1138, - "src": "4811:264:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 591, - "nodeType": "Block", - "src": "5143:214:0", - "statements": [ - { - "assignments": [ - 562 - ], - "declarations": [ - { - "constant": false, - "id": 562, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 591, - "src": "5153:27:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 560, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5153:7:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 561, - "length": null, - "nodeType": "ArrayTypeName", - "src": "5153:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 565, - "initialValue": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 563, - "name": "getNextValidators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 616, - "src": "5183:17:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_array$_t_address_$dyn_memory_ptr_$", - "typeString": "function () view returns (address[] memory)" - } - }, - "id": 564, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5183:19:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "5153:49:0" - }, - { - "body": { - "id": 587, - "nodeType": "Block", - "src": "5256:77:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 581, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 577, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 562, - "src": "5274:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 579, - "indexExpression": { - "argumentTypes": null, - "id": 578, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5285:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5274:13:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "id": 580, - "name": "a", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 554, - "src": "5291:1:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "5274:18:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 586, - "nodeType": "IfStatement", - "src": "5270:52:0", - "trueBody": { - "expression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 584, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 582, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5317:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "+", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 583, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5321:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "5317:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 558, - "id": 585, - "nodeType": "Return", - "src": "5310:12:0" - } - } - ] - }, - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 573, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 570, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5229:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 571, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "5233:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 572, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5233:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "5229:20:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 588, - "initializationExpression": { - "assignments": [ - 567 - ], - "declarations": [ - { - "constant": false, - "id": 567, - "name": "i", - "nodeType": "VariableDeclaration", - "scope": 588, - "src": "5217:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 566, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "5217:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 569, - "initialValue": { - "argumentTypes": null, - "hexValue": "30", - "id": 568, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5226:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "nodeType": "VariableDeclarationStatement", - "src": "5217:10:0" - }, - "loopExpression": { - "expression": { - "argumentTypes": null, - "id": 575, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "5251:3:0", - "subExpression": { - "argumentTypes": null, - "id": 574, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5251:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 576, - "nodeType": "ExpressionStatement", - "src": "5251:3:0" - }, - "nodeType": "ForStatement", - "src": "5212:121:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "30", - "id": 589, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5349:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "functionReturnParameters": 558, - "id": 590, - "nodeType": "Return", - "src": "5342:8:0" - } - ] - }, - "documentation": null, - "id": 592, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextPartyId", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 555, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 554, - "name": "a", - "nodeType": "VariableDeclaration", - "scope": 592, - "src": "5105:9:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 553, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5105:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5104:11:0" - }, - "returnParameters": { - "id": 558, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 557, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 592, - "src": "5137:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 556, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "5137:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5136:6:0" - }, - "scope": 1138, - "src": "5081:276:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 603, - "nodeType": "Block", - "src": "5427:48:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 598, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5444:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 600, - "indexExpression": { - "argumentTypes": null, - "id": 599, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "5451:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5444:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 601, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5444:24:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "functionReturnParameters": 597, - "id": 602, - "nodeType": "Return", - "src": "5437:31:0" - } - ] - }, - "documentation": null, - "id": 604, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getValidators", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 593, - "nodeType": "ParameterList", - "parameters": [], - "src": "5385:2:0" - }, - "returnParameters": { - "id": 597, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 596, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 604, - "src": "5409:16:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 594, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5409:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 595, - "length": null, - "nodeType": "ArrayTypeName", - "src": "5409:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5408:18:0" - }, - "scope": 1138, - "src": "5363:112:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 615, - "nodeType": "Block", - "src": "5549:52:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 610, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5566:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 612, - "indexExpression": { - "argumentTypes": null, - "id": 611, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5573:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5566:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 613, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5566:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "functionReturnParameters": 609, - "id": 614, - "nodeType": "Return", - "src": "5559:35:0" - } - ] - }, - "documentation": null, - "id": 616, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextValidators", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 605, - "nodeType": "ParameterList", - "parameters": [], - "src": "5507:2:0" - }, - "returnParameters": { - "id": 609, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 608, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 616, - "src": "5531:16:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 606, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5531:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 607, - "length": null, - "nodeType": "ArrayTypeName", - "src": "5531:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5530:18:0" - }, - "scope": 1138, - "src": "5481:120:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 657, - "nodeType": "Block", - "src": "5668:256:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 624, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "5690:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 625, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "START_VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "5690:17:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 623, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 882, - "src": "5682:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 626, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5682:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 656, - "nodeType": "IfStatement", - "src": "5678:240:0", - "trueBody": { - "id": 655, - "nodeType": "Block", - "src": "5710:208:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 628, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "5724:11:0", - "subExpression": { - "argumentTypes": null, - "id": 627, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5724:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 629, - "nodeType": "ExpressionStatement", - "src": "5724:11:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 633, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 630, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "5749:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 631, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "5758:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 632, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "5758:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "5749:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 634, - "nodeType": "ExpressionStatement", - "src": "5749:22:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 643, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 635, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5785:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 637, - "indexExpression": { - "argumentTypes": null, - "id": 636, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5792:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5785:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 638, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "5785:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 639, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5815:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 641, - "indexExpression": { - "argumentTypes": null, - "id": 640, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "5822:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5815:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 642, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "5815:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "5785:53:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 644, - "nodeType": "ExpressionStatement", - "src": "5785:53:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 653, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 645, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5852:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 647, - "indexExpression": { - "argumentTypes": null, - "id": 646, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5859:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5852:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 648, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5852:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 649, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5883:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 651, - "indexExpression": { - "argumentTypes": null, - "id": 650, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "5890:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5883:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 652, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5883:24:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "src": "5852:55:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 654, - "nodeType": "ExpressionStatement", - "src": "5852:55:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 658, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 619, - "modifierName": { - "argumentTypes": null, - "id": 618, - "name": "readyOrVoting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 192, - "src": "5637:13:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5637:13:0" - }, - { - "arguments": null, - "id": 621, - "modifierName": { - "argumentTypes": null, - "id": 620, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "5651:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5651:16:0" - } - ], - "name": "startVoting", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 617, - "nodeType": "ParameterList", - "parameters": [], - "src": "5627:2:0" - }, - "returnParameters": { - "id": 622, - "nodeType": "ParameterList", - "parameters": [], - "src": "5668:0:0" - }, - "scope": 1138, - "src": "5607:317:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 691, - "nodeType": "Block", - "src": "6006:202:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 672, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 669, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 660, - "src": "6039:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 668, - "name": "getNextPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 592, - "src": "6024:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) view returns (uint256)" - } - }, - "id": 670, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6024:25:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 671, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6053:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "6024:30:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "416c726561647920612076616c696461746f72", - "id": 673, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6056:21:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_aeb0fe100da2796aa6136a3b1c66282f002b435141be331237dfa7127e6df6ff", - "typeString": "literal_string \"Already a validator\"" - }, - "value": "Already a validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_aeb0fe100da2796aa6136a3b1c66282f002b435141be331237dfa7127e6df6ff", - "typeString": "literal_string \"Already a validator\"" - } - ], - "id": 667, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "6016:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 674, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6016:62:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 675, - "nodeType": "ExpressionStatement", - "src": "6016:62:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 677, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "6101:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 678, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "ADD_VALIDATOR", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6101:18:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 679, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 660, - "src": "6121:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 676, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 907, - "src": "6093:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_address_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,address) returns (bool)" - } - }, - "id": 680, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6093:38:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 690, - "nodeType": "IfStatement", - "src": "6089:113:0", - "trueBody": { - "id": 689, - "nodeType": "Block", - "src": "6133:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 686, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 660, - "src": "6181:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 681, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6147:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 683, - "indexExpression": { - "argumentTypes": null, - "id": 682, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6154:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6147:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 684, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6147:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 685, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "push", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6147:33:0", - "typeDescriptions": { - "typeIdentifier": "t_function_arraypush_nonpayable$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) returns (uint256)" - } - }, - "id": 687, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6147:44:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 688, - "nodeType": "ExpressionStatement", - "src": "6147:44:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 692, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 663, - "modifierName": { - "argumentTypes": null, - "id": 662, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "5982:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5982:6:0" - }, - { - "arguments": null, - "id": 665, - "modifierName": { - "argumentTypes": null, - "id": 664, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "5989:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5989:16:0" - } - ], - "name": "voteAddValidator", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 661, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 660, - "name": "validator", - "nodeType": "VariableDeclaration", - "scope": 692, - "src": "5956:17:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 659, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5956:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5955:19:0" - }, - "returnParameters": { - "id": 666, - "nodeType": "ParameterList", - "parameters": [], - "src": "6006:0:0" - }, - "scope": 1138, - "src": "5930:278:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 721, - "nodeType": "Block", - "src": "6293:192:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 706, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 703, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 694, - "src": "6326:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 702, - "name": "getNextPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 592, - "src": "6311:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) view returns (uint256)" - } - }, - "id": 704, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6311:25:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 705, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6340:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "6311:30:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "416c7265616479206e6f7420612076616c696461746f72", - "id": 707, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6343:25:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_2332ed568e8af3d64f1f2b0b098c504cab97ba4128fb9f08cfa3f851ced05961", - "typeString": "literal_string \"Already not a validator\"" - }, - "value": "Already not a validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_2332ed568e8af3d64f1f2b0b098c504cab97ba4128fb9f08cfa3f851ced05961", - "typeString": "literal_string \"Already not a validator\"" - } - ], - "id": 701, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "6303:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 708, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6303:66:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 709, - "nodeType": "ExpressionStatement", - "src": "6303:66:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 711, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "6392:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 712, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "REMOVE_VALIDATOR", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6392:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 713, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 694, - "src": "6415:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 710, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 907, - "src": "6384:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_address_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,address) returns (bool)" - } - }, - "id": 714, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6384:41:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 720, - "nodeType": "IfStatement", - "src": "6380:99:0", - "trueBody": { - "id": 719, - "nodeType": "Block", - "src": "6427:52:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 716, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 694, - "src": "6458:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 715, - "name": "_removeValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 789, - "src": "6441:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$returns$__$", - "typeString": "function (address)" - } - }, - "id": 717, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6441:27:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 718, - "nodeType": "ExpressionStatement", - "src": "6441:27:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 722, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 697, - "modifierName": { - "argumentTypes": null, - "id": 696, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "6269:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "6269:6:0" - }, - { - "arguments": null, - "id": 699, - "modifierName": { - "argumentTypes": null, - "id": 698, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "6276:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "6276:16:0" - } - ], - "name": "voteRemoveValidator", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 695, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 694, - "name": "validator", - "nodeType": "VariableDeclaration", - "scope": 722, - "src": "6243:17:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 693, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "6243:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "6242:19:0" - }, - "returnParameters": { - "id": 700, - "nodeType": "ParameterList", - "parameters": [], - "src": "6293:0:0" - }, - "scope": 1138, - "src": "6214:271:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 788, - "nodeType": "Block", - "src": "6544:392:0", - "statements": [ - { - "body": { - "id": 768, - "nodeType": "Block", - "src": "6602:214:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 747, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 740, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6620:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 742, - "indexExpression": { - "argumentTypes": null, - "id": 741, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6627:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6620:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 743, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6620:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 745, - "indexExpression": { - "argumentTypes": null, - "id": 744, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6649:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6620:31:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "id": 746, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 724, - "src": "6655:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "6620:44:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 767, - "nodeType": "IfStatement", - "src": "6616:190:0", - "trueBody": { - "id": 766, - "nodeType": "Block", - "src": "6666:140:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 763, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 748, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6684:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 750, - "indexExpression": { - "argumentTypes": null, - "id": 749, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6691:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6684:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 751, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6684:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 753, - "indexExpression": { - "argumentTypes": null, - "id": 752, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6713:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "6684:31:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 754, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6718:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 756, - "indexExpression": { - "argumentTypes": null, - "id": 755, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6725:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6718:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 757, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6718:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 762, - "indexExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 761, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 758, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "6747:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 759, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6747:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 760, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6766:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "6747:20:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6718:50:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "6684:84:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 764, - "nodeType": "ExpressionStatement", - "src": "6684:84:0" - }, - { - "id": 765, - "nodeType": "Break", - "src": "6786:5:0" - } - ] - } - } - ] - }, - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 736, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 731, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6571:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 735, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 732, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "6575:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 733, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6575:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 734, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6594:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "6575:20:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "6571:24:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 769, - "initializationExpression": { - "assignments": [ - 728 - ], - "declarations": [ - { - "constant": false, - "id": 728, - "name": "i", - "nodeType": "VariableDeclaration", - "scope": 769, - "src": "6559:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 727, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "6559:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 730, - "initialValue": { - "argumentTypes": null, - "hexValue": "30", - "id": 729, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6568:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "nodeType": "VariableDeclarationStatement", - "src": "6559:10:0" - }, - "loopExpression": { - "expression": { - "argumentTypes": null, - "id": 738, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "6597:3:0", - "subExpression": { - "argumentTypes": null, - "id": 737, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6597:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 739, - "nodeType": "ExpressionStatement", - "src": "6597:3:0" - }, - "nodeType": "ForStatement", - "src": "6554:262:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 779, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "delete", - "prefix": true, - "src": "6825:57:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 770, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6832:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 772, - "indexExpression": { - "argumentTypes": null, - "id": 771, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6839:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6832:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 773, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6832:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 778, - "indexExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 777, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 774, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "6861:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 775, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6861:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 776, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6880:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "6861:20:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "6832:50:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 780, - "nodeType": "ExpressionStatement", - "src": "6825:57:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 786, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "--", - "prefix": false, - "src": "6892:37:0", - "subExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 781, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6892:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 783, - "indexExpression": { - "argumentTypes": null, - "id": 782, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6899:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6892:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 784, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6892:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 785, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6892:35:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 787, - "nodeType": "ExpressionStatement", - "src": "6892:37:0" - } - ] - }, - "documentation": null, - "id": 789, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_removeValidator", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 725, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 724, - "name": "validator", - "nodeType": "VariableDeclaration", - "scope": 789, - "src": "6517:17:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 723, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "6517:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "6516:19:0" - }, - "returnParameters": { - "id": 726, - "nodeType": "ParameterList", - "parameters": [], - "src": "6544:0:0" - }, - "scope": 1138, - "src": "6491:445:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 812, - "nodeType": "Block", - "src": "7018:127:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 799, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "7040:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 800, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CHANGE_THRESHOLD", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7040:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 801, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 791, - "src": "7063:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 798, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 932, - "src": "7032:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,uint256) returns (bool)" - } - }, - "id": 802, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7032:41:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 811, - "nodeType": "IfStatement", - "src": "7028:111:0", - "trueBody": { - "id": 810, - "nodeType": "Block", - "src": "7075:64:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 808, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 803, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "7089:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 805, - "indexExpression": { - "argumentTypes": null, - "id": 804, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7096:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "7089:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 806, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "7089:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 807, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 791, - "src": "7119:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "7089:39:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 809, - "nodeType": "ExpressionStatement", - "src": "7089:39:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 813, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 794, - "modifierName": { - "argumentTypes": null, - "id": 793, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "6994:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "6994:6:0" - }, - { - "arguments": null, - "id": 796, - "modifierName": { - "argumentTypes": null, - "id": 795, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "7001:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7001:16:0" - } - ], - "name": "voteChangeThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 792, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 791, - "name": "threshold", - "nodeType": "VariableDeclaration", - "scope": 813, - "src": "6971:14:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 790, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "6971:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "6970:16:0" - }, - "returnParameters": { - "id": 797, - "nodeType": "ParameterList", - "parameters": [], - "src": "7018:0:0" - }, - "scope": 1138, - "src": "6942:203:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 836, - "nodeType": "Block", - "src": "7209:141:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 821, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "7231:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 822, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "START_KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7231:17:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 820, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 882, - "src": "7223:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 823, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7223:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 835, - "nodeType": "IfStatement", - "src": "7219:125:0", - "trueBody": { - "id": 834, - "nodeType": "Block", - "src": "7251:93:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 827, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 824, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "7265:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 825, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "7274:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 826, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7274:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "7265:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 828, - "nodeType": "ExpressionStatement", - "src": "7265:22:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 830, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "7316:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 831, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7323:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 829, - "name": "NewEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12, - "src": "7307:8:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256)" - } - }, - "id": 832, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7307:26:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 833, - "nodeType": "EmitStatement", - "src": "7302:31:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 837, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 816, - "modifierName": { - "argumentTypes": null, - "id": 815, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "7185:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7185:6:0" - }, - { - "arguments": null, - "id": 818, - "modifierName": { - "argumentTypes": null, - "id": 817, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "7192:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7192:16:0" - } - ], - "name": "voteStartKeygen", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 814, - "nodeType": "ParameterList", - "parameters": [], - "src": "7175:2:0" - }, - "returnParameters": { - "id": 819, - "nodeType": "ParameterList", - "parameters": [], - "src": "7209:0:0" - }, - "scope": 1138, - "src": "7151:199:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 859, - "nodeType": "Block", - "src": "7415:144:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 845, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "7437:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 846, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CANCEL_KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7437:18:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 844, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 882, - "src": "7429:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 847, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7429:27:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 858, - "nodeType": "IfStatement", - "src": "7425:128:0", - "trueBody": { - "id": 857, - "nodeType": "Block", - "src": "7458:95:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 851, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 848, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "7472:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 849, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "7481:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 850, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7481:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "7472:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 852, - "nodeType": "ExpressionStatement", - "src": "7472:22:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 854, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7532:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 853, - "name": "NewEpochCancelled", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 16, - "src": "7514:17:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", - "typeString": "function (uint256)" - } - }, - "id": 855, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7514:28:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 856, - "nodeType": "EmitStatement", - "src": "7509:33:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 860, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 840, - "modifierName": { - "argumentTypes": null, - "id": 839, - "name": "keygen", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 216, - "src": "7391:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7391:6:0" - }, - { - "arguments": null, - "id": 842, - "modifierName": { - "argumentTypes": null, - "id": 841, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "7398:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7398:16:0" - } - ], - "name": "voteCancelKeygen", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 838, - "nodeType": "ParameterList", - "parameters": [], - "src": "7381:2:0" - }, - "returnParameters": { - "id": 843, - "nodeType": "ParameterList", - "parameters": [], - "src": "7415:0:0" - }, - "scope": 1138, - "src": "7356:203:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 881, - "nodeType": "Block", - "src": "7620:110:0", - "statements": [ - { - "assignments": [ - 868 - ], - "declarations": [ - { - "constant": false, - "id": 868, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 881, - "src": "7630:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 867, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "7630:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 876, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 872, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 862, - "src": "7672:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 873, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7682:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 870, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "7655:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 871, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7655:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 874, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7655:37:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 869, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "7645:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 875, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7645:48:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "7630:63:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 878, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 868, - "src": "7718:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 877, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "7710:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 879, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7710:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 866, - "id": 880, - "nodeType": "Return", - "src": "7703:20:0" - } - ] - }, - "documentation": null, - "id": 882, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 863, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 862, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 882, - "src": "7582:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 861, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "7582:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7581:15:0" - }, - "returnParameters": { - "id": 866, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 865, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 882, - "src": "7614:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 864, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "7614:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7613:6:0" - }, - "scope": 1138, - "src": "7565:165:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 906, - "nodeType": "Block", - "src": "7805:116:0", - "statements": [ - { - "assignments": [ - 892 - ], - "declarations": [ - { - "constant": false, - "id": 892, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 906, - "src": "7815:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 891, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "7815:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 901, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 896, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 884, - "src": "7857:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 897, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7867:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 898, - "name": "addr", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 886, - "src": "7878:4:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "expression": { - "argumentTypes": null, - "id": 894, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "7840:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 895, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7840:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 899, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7840:43:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 893, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "7830:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 900, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7830:54:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "7815:69:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 903, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 892, - "src": "7909:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 902, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "7901:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 904, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7901:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 890, - "id": 905, - "nodeType": "Return", - "src": "7894:20:0" - } - ] - }, - "documentation": null, - "id": 907, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 887, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 884, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 907, - "src": "7753:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 883, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "7753:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 886, - "name": "addr", - "nodeType": "VariableDeclaration", - "scope": 907, - "src": "7768:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 885, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "7768:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7752:29:0" - }, - "returnParameters": { - "id": 890, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 889, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 907, - "src": "7799:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 888, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "7799:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7798:6:0" - }, - "scope": 1138, - "src": "7736:185:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 931, - "nodeType": "Block", - "src": "7992:115:0", - "statements": [ - { - "assignments": [ - 917 - ], - "declarations": [ - { - "constant": false, - "id": 917, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 931, - "src": "8002:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 916, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8002:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 926, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 921, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 909, - "src": "8044:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 922, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "8054:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 923, - "name": "num", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 911, - "src": "8065:3:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 919, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8027:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 920, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8027:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 924, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8027:42:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 918, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8017:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 925, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8017:53:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8002:68:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 928, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 917, - "src": "8095:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 927, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "8087:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 929, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8087:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 915, - "id": 930, - "nodeType": "Return", - "src": "8080:20:0" - } - ] - }, - "documentation": null, - "id": 932, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 912, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 909, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 932, - "src": "7944:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 908, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "7944:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 911, - "name": "num", - "nodeType": "VariableDeclaration", - "scope": 932, - "src": "7959:8:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 910, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "7959:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7943:25:0" - }, - "returnParameters": { - "id": 915, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 914, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 932, - "src": "7986:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 913, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "7986:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7985:6:0" - }, - "scope": 1138, - "src": "7927:180:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 961, - "nodeType": "Block", - "src": "8206:116:0", - "statements": [ - { - "assignments": [ - 946 - ], - "declarations": [ - { - "constant": false, - "id": 946, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 961, - "src": "8216:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 945, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8216:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 956, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 950, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 934, - "src": "8258:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 951, - "name": "hash", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 936, - "src": "8268:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "argumentTypes": null, - "id": 952, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 938, - "src": "8274:2:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 953, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 940, - "src": "8278:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 948, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8241:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 949, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8241:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 954, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8241:43:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 947, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8231:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 955, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8231:54:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8216:69:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 958, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 946, - "src": "8310:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 957, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "8302:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 959, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8302:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 944, - "id": 960, - "nodeType": "Return", - "src": "8295:20:0" - } - ] - }, - "documentation": null, - "id": 962, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 941, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 934, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8130:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 933, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "8130:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 936, - "name": "hash", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8145:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 935, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8145:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 938, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8159:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 937, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "8159:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 940, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8171:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 939, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "8171:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8129:53:0" - }, - "returnParameters": { - "id": 944, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 943, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8200:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 942, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8200:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8199:6:0" - }, - "scope": 1138, - "src": "8113:209:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 983, - "nodeType": "Block", - "src": "8386:113:0", - "statements": [ - { - "assignments": [ - 970 - ], - "declarations": [ - { - "constant": false, - "id": 970, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 983, - "src": "8396:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 969, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8396:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 978, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 974, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 964, - "src": "8438:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 975, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "8448:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 972, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8421:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 973, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8421:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 976, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8421:37:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 971, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8411:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 977, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8411:48:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8396:63:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 980, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 970, - "src": "8487:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 979, - "name": "putConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1120, - "src": "8476:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 981, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8476:16:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 968, - "id": 982, - "nodeType": "Return", - "src": "8469:23:0" - } - ] - }, - "documentation": null, - "id": 984, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryConfirm", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 965, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 964, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 984, - "src": "8348:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 963, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "8348:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8347:15:0" - }, - "returnParameters": { - "id": 968, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 967, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 984, - "src": "8380:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 966, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8380:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8379:6:0" - }, - "scope": 1138, - "src": "8328:171:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1011, - "nodeType": "Block", - "src": "8579:119:0", - "statements": [ - { - "assignments": [ - 996 - ], - "declarations": [ - { - "constant": false, - "id": 996, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1011, - "src": "8589:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 995, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8589:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 1006, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1000, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 986, - "src": "8631:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 1001, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "8641:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 1002, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 988, - "src": "8652:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 1003, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 990, - "src": "8655:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 998, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8614:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 999, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8614:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 1004, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8614:43:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 997, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8604:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 1005, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8604:54:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8589:69:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1008, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 996, - "src": "8686:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 1007, - "name": "putConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1120, - "src": "8675:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 1009, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8675:16:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 994, - "id": 1010, - "nodeType": "Return", - "src": "8668:23:0" - } - ] - }, - "documentation": null, - "id": 1012, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryConfirm", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 991, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 986, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8525:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 985, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "8525:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 988, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8540:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 987, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "8540:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 990, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8548:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 989, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "8548:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8524:31:0" - }, - "returnParameters": { - "id": 994, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 993, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8573:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 992, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8573:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8572:6:0" - }, - "scope": 1138, - "src": "8505:193:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1065, - "nodeType": "Block", - "src": "8758:355:0", - "statements": [ - { - "assignments": [ - 1020 - ], - "declarations": [ - { - "constant": false, - "id": 1020, - "name": "personalVote", - "nodeType": "VariableDeclaration", - "scope": 1065, - "src": "8768:20:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1019, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8768:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 1024, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1022, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "8807:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 1021, - "name": "personalizeVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1137, - "src": "8791:15:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_bytes32_$returns$_t_bytes32_$", - "typeString": "function (bytes32) view returns (bytes32)" - } - }, - "id": 1023, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8791:21:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8768:44:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1029, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "!", - "prefix": true, - "src": "8830:20:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1026, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "8831:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1028, - "indexExpression": { - "argumentTypes": null, - "id": 1027, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1020, - "src": "8837:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "8831:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "566f74656420616c7265616479", - "id": 1030, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8852:15:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_230c30109b60c15b21799291aaf5c571045da3dc3f224d8bbd2f2e688c149a47", - "typeString": "literal_string \"Voted already\"" - }, - "value": "Voted already" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_230c30109b60c15b21799291aaf5c571045da3dc3f224d8bbd2f2e688c149a47", - "typeString": "literal_string \"Voted already\"" - } - ], - "id": 1025, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "8822:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 1031, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8822:46:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 1032, - "nodeType": "ExpressionStatement", - "src": "8822:46:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 1037, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1033, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "8879:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1035, - "indexExpression": { - "argumentTypes": null, - "id": 1034, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1020, - "src": "8885:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "8879:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1036, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8901:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "src": "8879:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 1038, - "nodeType": "ExpressionStatement", - "src": "8879:26:0" - }, - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 1044, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1039, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "8919:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1041, - "indexExpression": { - "argumentTypes": null, - "id": 1040, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "8930:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "8919:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 1042, - "name": "getThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 468, - 491 - ], - "referencedDeclaration": 468, - "src": "8939:12:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 1043, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8939:14:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "8919:34:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": { - "id": 1063, - "nodeType": "Block", - "src": "9038:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1059, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "9052:18:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1056, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9052:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1058, - "indexExpression": { - "argumentTypes": null, - "id": 1057, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "9063:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9052:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1060, - "nodeType": "ExpressionStatement", - "src": "9052:18:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "66616c7365", - "id": 1061, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9091:5:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "false" - }, - "functionReturnParameters": 1018, - "id": 1062, - "nodeType": "Return", - "src": "9084:12:0" - } - ] - }, - "id": 1064, - "nodeType": "IfStatement", - "src": "8915:192:0", - "trueBody": { - "id": 1055, - "nodeType": "Block", - "src": "8955:77:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1051, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1045, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "8969:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1047, - "indexExpression": { - "argumentTypes": null, - "id": 1046, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "8980:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "8969:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - }, - "id": 1050, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "hexValue": "32", - "id": 1048, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8988:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "argumentTypes": null, - "hexValue": "323535", - "id": 1049, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8993:3:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_255_by_1", - "typeString": "int_const 255" - }, - "value": "255" - }, - "src": "8988:8:0", - "typeDescriptions": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - } - }, - "src": "8969:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1052, - "nodeType": "ExpressionStatement", - "src": "8969:27:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1053, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9017:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 1018, - "id": 1054, - "nodeType": "Return", - "src": "9010:11:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 1066, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "putVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 1015, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1014, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1066, - "src": "8721:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1013, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8721:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8720:14:0" - }, - "returnParameters": { - "id": 1018, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1017, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1066, - "src": "8752:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 1016, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8752:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8751:6:0" - }, - "scope": 1138, - "src": "8704:409:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1119, - "nodeType": "Block", - "src": "9176:363:0", - "statements": [ - { - "assignments": [ - 1074 - ], - "declarations": [ - { - "constant": false, - "id": 1074, - "name": "personalVote", - "nodeType": "VariableDeclaration", - "scope": 1119, - "src": "9186:20:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1073, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9186:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 1078, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1076, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9225:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 1075, - "name": "personalizeVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1137, - "src": "9209:15:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_bytes32_$returns$_t_bytes32_$", - "typeString": "function (bytes32) view returns (bytes32)" - } - }, - "id": 1077, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9209:21:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "9186:44:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1083, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "!", - "prefix": true, - "src": "9248:20:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1080, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "9249:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1082, - "indexExpression": { - "argumentTypes": null, - "id": 1081, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1074, - "src": "9255:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "9249:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "436f6e6669726d656420616c7265616479", - "id": 1084, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9270:19:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_762a97ce67d271844ad9c09d89a5271fde7fe7537af208da055a904cd67ac7bc", - "typeString": "literal_string \"Confirmed already\"" - }, - "value": "Confirmed already" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_762a97ce67d271844ad9c09d89a5271fde7fe7537af208da055a904cd67ac7bc", - "typeString": "literal_string \"Confirmed already\"" - } - ], - "id": 1079, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "9240:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 1085, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9240:50:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 1086, - "nodeType": "ExpressionStatement", - "src": "9240:50:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 1091, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1087, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "9301:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1089, - "indexExpression": { - "argumentTypes": null, - "id": 1088, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1074, - "src": "9307:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9301:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1090, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9323:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "src": "9301:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 1092, - "nodeType": "ExpressionStatement", - "src": "9301:26:0" - }, - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 1098, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1093, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9341:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1095, - "indexExpression": { - "argumentTypes": null, - "id": 1094, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9352:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "9341:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 1096, - "name": "getNextThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 478, - "src": "9361:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 1097, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9361:18:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "9341:38:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": { - "id": 1117, - "nodeType": "Block", - "src": "9464:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1113, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "9478:18:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1110, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9478:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1112, - "indexExpression": { - "argumentTypes": null, - "id": 1111, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9489:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9478:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1114, - "nodeType": "ExpressionStatement", - "src": "9478:18:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "66616c7365", - "id": 1115, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9517:5:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "false" - }, - "functionReturnParameters": 1072, - "id": 1116, - "nodeType": "Return", - "src": "9510:12:0" - } - ] - }, - "id": 1118, - "nodeType": "IfStatement", - "src": "9337:196:0", - "trueBody": { - "id": 1109, - "nodeType": "Block", - "src": "9381:77:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1105, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1099, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9395:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1101, - "indexExpression": { - "argumentTypes": null, - "id": 1100, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9406:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9395:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - }, - "id": 1104, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "hexValue": "32", - "id": 1102, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9414:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "argumentTypes": null, - "hexValue": "323535", - "id": 1103, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9419:3:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_255_by_1", - "typeString": "int_const 255" - }, - "value": "255" - }, - "src": "9414:8:0", - "typeDescriptions": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - } - }, - "src": "9395:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1106, - "nodeType": "ExpressionStatement", - "src": "9395:27:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1107, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9443:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 1072, - "id": 1108, - "nodeType": "Return", - "src": "9436:11:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 1120, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "putConfirm", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 1069, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1068, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1120, - "src": "9139:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1067, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9139:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9138:14:0" - }, - "returnParameters": { - "id": 1072, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1071, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1120, - "src": "9170:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 1070, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "9170:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9169:6:0" - }, - "scope": 1138, - "src": "9119:420:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1136, - "nodeType": "Block", - "src": "9615:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1130, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1122, - "src": "9659:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 1131, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "9665:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 1132, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "9665:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - ], - "expression": { - "argumentTypes": null, - "id": 1128, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "9642:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 1129, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "9642:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 1133, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9642:34:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 1127, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "9632:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 1134, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9632:45:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "functionReturnParameters": 1126, - "id": 1135, - "nodeType": "Return", - "src": "9625:52:0" - } - ] - }, - "documentation": null, - "id": 1137, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "personalizeVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 1123, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1122, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1137, - "src": "9570:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1121, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9570:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9569:14:0" - }, - "returnParameters": { - "id": 1126, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1125, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1137, - "src": "9606:7:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1124, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9606:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9605:9:0" - }, - "scope": 1138, - "src": "9545:139:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "private" - } - ], - "scope": 1139, - "src": "93:9593:0" - } - ], - "src": "0:9687:0" - }, - "legacyAST": { - "absolutePath": "/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/Bridge.sol", - "exportedSymbols": { - "Bridge": [ - 1138 - ] - }, - "id": 1139, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 1, - "literals": [ - "solidity", - "^", - "0.5", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "0:23:0" - }, - { - "absolutePath": "/Users/kirillfedoseev/Innopolis/My own projects/bridge/bridge/src/deploy/deploy-home/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "file": "./openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "id": 2, - "nodeType": "ImportDirective", - "scope": 1139, - "sourceUnit": 9774, - "src": "25:66:0", - "symbolAliases": [], - "unitAlias": "" - }, - { - "baseContracts": [], - "contractDependencies": [], - "contractKind": "contract", - "documentation": null, - "fullyImplemented": true, - "id": 1138, - "linearizedBaseContracts": [ - 1138 - ], - "name": "Bridge", - "nodeType": "ContractDefinition", - "nodes": [ - { - "anonymous": false, - "documentation": null, - "id": 6, - "name": "ExchangeRequest", - "nodeType": "EventDefinition", - "parameters": { - "id": 5, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 4, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 6, - "src": "137:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 3, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "137:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "136:12:0" - }, - "src": "115:34:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 12, - "name": "NewEpoch", - "nodeType": "EventDefinition", - "parameters": { - "id": 11, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 8, - "indexed": true, - "name": "oldEpoch", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "169:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 7, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "169:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 10, - "indexed": true, - "name": "newEpoch", - "nodeType": "VariableDeclaration", - "scope": 12, - "src": "192:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "192:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "168:46:0" - }, - "src": "154:61:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 16, - "name": "NewEpochCancelled", - "nodeType": "EventDefinition", - "parameters": { - "id": 15, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 14, - "indexed": true, - "name": "epoch", - "nodeType": "VariableDeclaration", - "scope": 16, - "src": "244:18:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 13, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "244:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "243:20:0" - }, - "src": "220:44:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 22, - "name": "NewFundsTransfer", - "nodeType": "EventDefinition", - "parameters": { - "id": 21, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 18, - "indexed": true, - "name": "oldEpoch", - "nodeType": "VariableDeclaration", - "scope": 22, - "src": "292:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 17, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "292:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 20, - "indexed": true, - "name": "newEpoch", - "nodeType": "VariableDeclaration", - "scope": 22, - "src": "315:21:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 19, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "315:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "291:46:0" - }, - "src": "269:69:0" - }, - { - "anonymous": false, - "documentation": null, - "id": 30, - "name": "EpochStart", - "nodeType": "EventDefinition", - "parameters": { - "id": 29, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 24, - "indexed": true, - "name": "epoch", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "360:18:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 23, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "360:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 26, - "indexed": false, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "380:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 25, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "380:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 28, - "indexed": false, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 30, - "src": "388:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 27, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "388:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "359:36:0" - }, - "src": "343:53:0" - }, - { - "canonicalName": "Bridge.State", - "id": 40, - "members": [ - { - "constant": false, - "id": 33, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "425:20:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 31, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "425:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 32, - "length": null, - "nodeType": "ArrayTypeName", - "src": "425:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 35, - "name": "threshold", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "455:14:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 34, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "455:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 37, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "479:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 36, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "479:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 39, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 40, - "src": "495:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 38, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "495:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "name": "State", - "nodeType": "StructDefinition", - "scope": 1138, - "src": "402:106:0", - "visibility": "public" - }, - { - "canonicalName": "Bridge.Status", - "id": 45, - "members": [ - { - "id": 41, - "name": "READY", - "nodeType": "EnumValue", - "src": "536:5:0" - }, - { - "id": 42, - "name": "VOTING", - "nodeType": "EnumValue", - "src": "595:6:0" - }, - { - "id": 43, - "name": "KEYGEN", - "nodeType": "EnumValue", - "src": "665:6:0" - }, - { - "id": 44, - "name": "FUNDS_TRANSFER", - "nodeType": "EnumValue", - "src": "708:14:0" - } - ], - "name": "Status", - "nodeType": "EnumDefinition", - "src": "514:253:0" - }, - { - "canonicalName": "Bridge.Vote", - "id": 55, - "members": [ - { - "id": 46, - "name": "CONFIRM_KEYGEN", - "nodeType": "EnumValue", - "src": "793:14:0" - }, - { - "id": 47, - "name": "CONFIRM_FUNDS_TRANSFER", - "nodeType": "EnumValue", - "src": "817:22:0" - }, - { - "id": 48, - "name": "START_VOTING", - "nodeType": "EnumValue", - "src": "849:12:0" - }, - { - "id": 49, - "name": "ADD_VALIDATOR", - "nodeType": "EnumValue", - "src": "871:13:0" - }, - { - "id": 50, - "name": "REMOVE_VALIDATOR", - "nodeType": "EnumValue", - "src": "894:16:0" - }, - { - "id": 51, - "name": "CHANGE_THRESHOLD", - "nodeType": "EnumValue", - "src": "920:16:0" - }, - { - "id": 52, - "name": "START_KEYGEN", - "nodeType": "EnumValue", - "src": "946:12:0" - }, - { - "id": 53, - "name": "CANCEL_KEYGEN", - "nodeType": "EnumValue", - "src": "968:13:0" - }, - { - "id": 54, - "name": "TRANSFER", - "nodeType": "EnumValue", - "src": "991:8:0" - } - ], - "name": "Vote", - "nodeType": "EnumDefinition", - "src": "773:232:0" - }, - { - "constant": false, - "id": 59, - "name": "states", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1011:29:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State)" - }, - "typeName": { - "id": 58, - "keyType": { - "id": 56, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1019:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Mapping", - "src": "1011:22:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State)" - }, - "valueType": { - "contractScope": null, - "id": 57, - "name": "State", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 40, - "src": "1027:5:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage_ptr", - "typeString": "struct Bridge.State" - } - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 63, - "name": "dbTransferCount", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1047:47:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "typeName": { - "id": 62, - "keyType": { - "id": 60, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1055:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1047:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "valueType": { - "id": 61, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1066:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 67, - "name": "dbTransfer", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1100:42:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "typeName": { - "id": 66, - "keyType": { - "id": 64, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1108:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1100:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "valueType": { - "id": 65, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1119:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 71, - "name": "votesCount", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1148:42:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "typeName": { - "id": 70, - "keyType": { - "id": 68, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1156:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1148:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - }, - "valueType": { - "id": 69, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1167:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 75, - "name": "votes", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1196:37:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "typeName": { - "id": 74, - "keyType": { - "id": 72, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "1204:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "Mapping", - "src": "1196:24:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - }, - "valueType": { - "id": 73, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1215:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 77, - "name": "status", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1240:20:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "typeName": { - "contractScope": null, - "id": 76, - "name": "Status", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 45, - "src": "1240:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 79, - "name": "epoch", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1267:17:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 78, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1267:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 81, - "name": "nextEpoch", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1290:21:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 80, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1290:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "public" - }, - { - "constant": false, - "id": 83, - "name": "minTxLimit", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1318:15:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 82, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1318:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 85, - "name": "maxTxLimit", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1339:15:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 84, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1339:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "body": { - "id": 160, - "nodeType": "Block", - "src": "1472:371:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 103, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 100, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "1490:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 101, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1490:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 102, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1510:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "1490:21:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "id": 99, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12832, - "src": "1482:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", - "typeString": "function (bool) pure" - } - }, - "id": 104, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1482:30:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 105, - "nodeType": "ExpressionStatement", - "src": "1482:30:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 110, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 107, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 87, - "src": "1530:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 108, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "1542:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 109, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1542:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1530:29:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "id": 106, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12832, - "src": "1522:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", - "typeString": "function (bool) pure" - } - }, - "id": 111, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1522:38:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 112, - "nodeType": "ExpressionStatement", - "src": "1522:38:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 117, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 113, - "name": "tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 163, - "src": "1571:13:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 115, - "name": "_tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 92, - "src": "1594:14:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 114, - "name": "IERC20", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 9773, - "src": "1587:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_contract$_IERC20_$9773_$", - "typeString": "type(contract IERC20)" - } - }, - "id": 116, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1587:22:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "src": "1571:38:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "id": 118, - "nodeType": "ExpressionStatement", - "src": "1571:38:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 121, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 119, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "1620:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "30", - "id": 120, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1628:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "1620:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 122, - "nodeType": "ExpressionStatement", - "src": "1620:9:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 126, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 123, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "1639:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 124, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "1648:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 125, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1648:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "1639:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 127, - "nodeType": "ExpressionStatement", - "src": "1639:22:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 130, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 128, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "1671:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "31", - "id": 129, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1683:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "1671:13:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 131, - "nodeType": "ExpressionStatement", - "src": "1671:13:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 141, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 132, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "1695:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 134, - "indexExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 133, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1702:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "1695:9:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 136, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 90, - "src": "1713:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - { - "argumentTypes": null, - "id": 137, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 87, - "src": "1725:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "hexValue": "30", - "id": 138, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1736:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - { - "argumentTypes": null, - "hexValue": "30", - "id": 139, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1739:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - } - ], - "id": 135, - "name": "State", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 40, - "src": "1707:5:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_struct$_State_$40_storage_ptr_$", - "typeString": "type(struct Bridge.State storage pointer)" - } - }, - "id": 140, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "structConstructorCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1707:34:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_memory", - "typeString": "struct Bridge.State memory" - } - }, - "src": "1695:46:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 142, - "nodeType": "ExpressionStatement", - "src": "1695:46:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 147, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 143, - "name": "minTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 83, - "src": "1752:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 144, - "name": "limits", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 96, - "src": "1765:6:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_memory_ptr", - "typeString": "uint256[2] memory" - } - }, - "id": 146, - "indexExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 145, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1772:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "1765:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1752:22:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 148, - "nodeType": "ExpressionStatement", - "src": "1752:22:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 153, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 149, - "name": "maxTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 85, - "src": "1784:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 150, - "name": "limits", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 96, - "src": "1797:6:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_memory_ptr", - "typeString": "uint256[2] memory" - } - }, - "id": 152, - "indexExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 151, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1804:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "1797:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "1784:22:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 154, - "nodeType": "ExpressionStatement", - "src": "1784:22:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "hexValue": "30", - "id": 156, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1831:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - { - "argumentTypes": null, - "hexValue": "31", - "id": 157, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1834:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - } - ], - "id": 155, - "name": "NewEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12, - "src": "1822:8:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256)" - } - }, - "id": 158, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1822:14:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 159, - "nodeType": "EmitStatement", - "src": "1817:19:0" - } - ] - }, - "documentation": null, - "id": 161, - "implemented": true, - "kind": "constructor", - "modifiers": [], - "name": "", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 97, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 87, - "name": "threshold", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1373:14:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 86, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1373:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 90, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1389:27:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 88, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1389:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 89, - "length": null, - "nodeType": "ArrayTypeName", - "src": "1389:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 92, - "name": "_tokenContract", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1418:22:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 91, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1418:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 96, - "name": "limits", - "nodeType": "VariableDeclaration", - "scope": 161, - "src": "1442:21:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_memory_ptr", - "typeString": "uint256[2]" - }, - "typeName": { - "baseType": { - "id": 93, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "1442:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 95, - "length": { - "argumentTypes": null, - "hexValue": "32", - "id": 94, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1447:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "ArrayTypeName", - "src": "1442:7:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_uint256_$2_storage_ptr", - "typeString": "uint256[2]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1372:92:0" - }, - "returnParameters": { - "id": 98, - "nodeType": "ParameterList", - "parameters": [], - "src": "1472:0:0" - }, - "scope": 1138, - "src": "1361:482:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "constant": false, - "id": 163, - "name": "tokenContract", - "nodeType": "VariableDeclaration", - "scope": 1138, - "src": "1849:27:0", - "stateVariable": true, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - }, - "typeName": { - "contractScope": null, - "id": 162, - "name": "IERC20", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 9773, - "src": "1849:6:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "value": null, - "visibility": "public" - }, - { - "body": { - "id": 174, - "nodeType": "Block", - "src": "1898:81:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 169, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 166, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "1916:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 167, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "1926:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 168, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "1926:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "1916:22:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e207265616479207374617465", - "id": 170, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "1940:20:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_965c39c15b78dbcd8a954511641ca86e15fc1ae6d6c30a67536872ccde75b679", - "typeString": "literal_string \"Not in ready state\"" - }, - "value": "Not in ready state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_965c39c15b78dbcd8a954511641ca86e15fc1ae6d6c30a67536872ccde75b679", - "typeString": "literal_string \"Not in ready state\"" - } - ], - "id": 165, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "1908:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 171, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "1908:53:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 172, - "nodeType": "ExpressionStatement", - "src": "1908:53:0" - }, - { - "id": 173, - "nodeType": "PlaceholderStatement", - "src": "1971:1:0" - } - ] - }, - "documentation": null, - "id": 175, - "name": "ready", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 164, - "nodeType": "ParameterList", - "parameters": [], - "src": "1898:0:0" - }, - "src": "1883:96:0", - "visibility": "internal" - }, - { - "body": { - "id": 191, - "nodeType": "Block", - "src": "2008:118:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 186, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 181, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 178, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2026:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 179, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2036:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 180, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2036:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2026:22:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "||", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 185, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 182, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2052:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 183, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2062:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 184, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2062:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2052:23:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2026:49:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e207265616479206f7220766f74696e67207374617465", - "id": 187, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2077:30:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_7e3f7359baa731593d4e3921720b92600c22ed1d950d208e0c826ad2eddebe96", - "typeString": "literal_string \"Not in ready or voting state\"" - }, - "value": "Not in ready or voting state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_7e3f7359baa731593d4e3921720b92600c22ed1d950d208e0c826ad2eddebe96", - "typeString": "literal_string \"Not in ready or voting state\"" - } - ], - "id": 177, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2018:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 188, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2018:90:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 189, - "nodeType": "ExpressionStatement", - "src": "2018:90:0" - }, - { - "id": 190, - "nodeType": "PlaceholderStatement", - "src": "2118:1:0" - } - ] - }, - "documentation": null, - "id": 192, - "name": "readyOrVoting", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 176, - "nodeType": "ParameterList", - "parameters": [], - "src": "2008:0:0" - }, - "src": "1985:141:0", - "visibility": "internal" - }, - { - "body": { - "id": 203, - "nodeType": "Block", - "src": "2148:83:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 198, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 195, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2166:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 196, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2176:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 197, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2176:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2166:23:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e20766f74696e67207374617465", - "id": 199, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2191:21:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_0cbee9834b110b21e0730bf5c3d2972fb9867ff221df239e7ae60883592f05d1", - "typeString": "literal_string \"Not in voting state\"" - }, - "value": "Not in voting state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_0cbee9834b110b21e0730bf5c3d2972fb9867ff221df239e7ae60883592f05d1", - "typeString": "literal_string \"Not in voting state\"" - } - ], - "id": 194, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2158:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 200, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2158:55:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 201, - "nodeType": "ExpressionStatement", - "src": "2158:55:0" - }, - { - "id": 202, - "nodeType": "PlaceholderStatement", - "src": "2223:1:0" - } - ] - }, - "documentation": null, - "id": 204, - "name": "voting", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 193, - "nodeType": "ParameterList", - "parameters": [], - "src": "2148:0:0" - }, - "src": "2132:99:0", - "visibility": "internal" - }, - { - "body": { - "id": 215, - "nodeType": "Block", - "src": "2253:83:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 210, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 207, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2271:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 208, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2281:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 209, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2281:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2271:23:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e206b657967656e207374617465", - "id": 211, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2296:21:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_ed0fee6382e0651a224348a21558d03a4a439c3bd5edc24945894a3417c14010", - "typeString": "literal_string \"Not in keygen state\"" - }, - "value": "Not in keygen state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_ed0fee6382e0651a224348a21558d03a4a439c3bd5edc24945894a3417c14010", - "typeString": "literal_string \"Not in keygen state\"" - } - ], - "id": 206, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2263:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 212, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2263:55:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 213, - "nodeType": "ExpressionStatement", - "src": "2263:55:0" - }, - { - "id": 214, - "nodeType": "PlaceholderStatement", - "src": "2328:1:0" - } - ] - }, - "documentation": null, - "id": 216, - "name": "keygen", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 205, - "nodeType": "ParameterList", - "parameters": [], - "src": "2253:0:0" - }, - "src": "2237:99:0", - "visibility": "internal" - }, - { - "body": { - "id": 227, - "nodeType": "Block", - "src": "2365:99:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - }, - "id": 222, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 219, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "2383:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 220, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "2393:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 221, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "FUNDS_TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2393:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "2383:31:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420696e2066756e6473207472616e73666572207374617465", - "id": 223, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2416:29:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_6347c9fecd6f58520ad10dfd1347ce3dc42cc0eed7a4182ca64dd11c69fc3008", - "typeString": "literal_string \"Not in funds transfer state\"" - }, - "value": "Not in funds transfer state" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_6347c9fecd6f58520ad10dfd1347ce3dc42cc0eed7a4182ca64dd11c69fc3008", - "typeString": "literal_string \"Not in funds transfer state\"" - } - ], - "id": 218, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2375:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 224, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2375:71:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 225, - "nodeType": "ExpressionStatement", - "src": "2375:71:0" - }, - { - "id": 226, - "nodeType": "PlaceholderStatement", - "src": "2456:1:0" - } - ] - }, - "documentation": null, - "id": 228, - "name": "fundsTransfer", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 217, - "nodeType": "ParameterList", - "parameters": [], - "src": "2365:0:0" - }, - "src": "2342:122:0", - "visibility": "internal" - }, - { - "body": { - "id": 239, - "nodeType": "Block", - "src": "2496:81:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 234, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 231, - "name": "getPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 552, - "src": "2514:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 232, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2514:12:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 233, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2530:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "2514:17:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f7420612063757272656e742076616c696461746f72", - "id": 235, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2533:25:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_8dc18d5bb1361900b9758b388df331056e31071cae84b276c0f03794c4dc634a", - "typeString": "literal_string \"Not a current validator\"" - }, - "value": "Not a current validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_8dc18d5bb1361900b9758b388df331056e31071cae84b276c0f03794c4dc634a", - "typeString": "literal_string \"Not a current validator\"" - } - ], - "id": 230, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "2506:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 236, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2506:53:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 237, - "nodeType": "ExpressionStatement", - "src": "2506:53:0" - }, - { - "id": 238, - "nodeType": "PlaceholderStatement", - "src": "2569:1:0" - } - ] - }, - "documentation": null, - "id": 240, - "name": "currentValidator", - "nodeType": "ModifierDefinition", - "parameters": { - "id": 229, - "nodeType": "ParameterList", - "parameters": [], - "src": "2496:0:0" - }, - "src": "2470:107:0", - "visibility": "internal" - }, - { - "body": { - "id": 278, - "nodeType": "Block", - "src": "2626:197:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 260, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "id": 256, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 250, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 248, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2644:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "argumentTypes": null, - "id": 249, - "name": "minTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 83, - "src": "2653:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "2644:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "&&", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 255, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 251, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2667:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">=", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_rational_10000000000_by_1", - "typeString": "int_const 10000000000" - }, - "id": 254, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "hexValue": "3130", - "id": 252, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2676:2:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_10_by_1", - "typeString": "int_const 10" - }, - "value": "10" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "argumentTypes": null, - "hexValue": "3130", - "id": 253, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "2682:2:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_10_by_1", - "typeString": "int_const 10" - }, - "value": "10" - }, - "src": "2676:8:0", - "typeDescriptions": { - "typeIdentifier": "t_rational_10000000000_by_1", - "typeString": "int_const 10000000000" - } - }, - "src": "2667:17:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2644:40:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "BinaryOperation", - "operator": "&&", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 259, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 257, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2688:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<=", - "rightExpression": { - "argumentTypes": null, - "id": 258, - "name": "maxTxLimit", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 85, - "src": "2697:10:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "2688:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "src": "2644:63:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - ], - "id": 247, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12832, - "src": "2636:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$returns$__$", - "typeString": "function (bool) pure" - } - }, - "id": 261, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2636:72:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 262, - "nodeType": "ExpressionStatement", - "src": "2636:72:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 266, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "2746:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 267, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2746:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - }, - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 269, - "name": "this", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12845, - "src": "2766:4:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_Bridge_$1138", - "typeString": "contract Bridge" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_contract$_Bridge_$1138", - "typeString": "contract Bridge" - } - ], - "id": 268, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "nodeType": "ElementaryTypeNameExpression", - "src": "2758:7:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_address_$", - "typeString": "type(address)" - }, - "typeName": "address" - }, - "id": 270, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "typeConversion", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2758:13:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 271, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2773:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 263, - "name": "tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 163, - "src": "2719:13:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "id": 265, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "transferFrom", - "nodeType": "MemberAccess", - "referencedDeclaration": 9756, - "src": "2719:26:0", - "typeDescriptions": { - "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_address_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (address,address,uint256) external returns (bool)" - } - }, - "id": 272, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2719:60:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 273, - "nodeType": "ExpressionStatement", - "src": "2719:60:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 275, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 242, - "src": "2810:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 274, - "name": "ExchangeRequest", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 6, - "src": "2794:15:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", - "typeString": "function (uint256)" - } - }, - "id": 276, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2794:22:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 277, - "nodeType": "EmitStatement", - "src": "2789:27:0" - } - ] - }, - "documentation": null, - "id": 279, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 245, - "modifierName": { - "argumentTypes": null, - "id": 244, - "name": "ready", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 175, - "src": "2620:5:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "2620:5:0" - } - ], - "name": "exchange", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 243, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 242, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 279, - "src": "2601:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 241, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "2601:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2600:12:0" - }, - "returnParameters": { - "id": 246, - "nodeType": "ParameterList", - "parameters": [], - "src": "2626:0:0" - }, - "scope": 1138, - "src": "2583:240:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 308, - "nodeType": "Block", - "src": "2923:119:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 293, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "2945:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 294, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "2945:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 295, - "name": "hash", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 281, - "src": "2960:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "argumentTypes": null, - "id": 296, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 283, - "src": "2966:2:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 297, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 285, - "src": "2970:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 292, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 962, - "src": "2937:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_bytes32_$_t_address_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,bytes32,address,uint256) returns (bool)" - } - }, - "id": 298, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2937:39:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 307, - "nodeType": "IfStatement", - "src": "2933:103:0", - "trueBody": { - "id": 306, - "nodeType": "Block", - "src": "2978:58:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 302, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 283, - "src": "3015:2:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 303, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 285, - "src": "3019:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 299, - "name": "tokenContract", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 163, - "src": "2992:13:0", - "typeDescriptions": { - "typeIdentifier": "t_contract$_IERC20_$9773", - "typeString": "contract IERC20" - } - }, - "id": 301, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "transfer", - "nodeType": "MemberAccess", - "referencedDeclaration": 9727, - "src": "2992:22:0", - "typeDescriptions": { - "typeIdentifier": "t_function_external_nonpayable$_t_address_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (address,uint256) external returns (bool)" - } - }, - "id": 304, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "2992:33:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 305, - "nodeType": "ExpressionStatement", - "src": "2992:33:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 309, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 288, - "modifierName": { - "argumentTypes": null, - "id": 287, - "name": "readyOrVoting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 192, - "src": "2892:13:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "2892:13:0" - }, - { - "arguments": null, - "id": 290, - "modifierName": { - "argumentTypes": null, - "id": 289, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "2906:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "2906:16:0" - } - ], - "name": "transfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 286, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 281, - "name": "hash", - "nodeType": "VariableDeclaration", - "scope": 309, - "src": "2847:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 280, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "2847:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 283, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 309, - "src": "2861:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 282, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2861:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 285, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 309, - "src": "2873:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 284, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "2873:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2846:38:0" - }, - "returnParameters": { - "id": 291, - "nodeType": "ParameterList", - "parameters": [], - "src": "2923:0:0" - }, - "scope": 1138, - "src": "2829:213:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 381, - "nodeType": "Block", - "src": "3101:525:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 324, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 320, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "3134:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 321, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3134:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - ], - "id": 319, - "name": "getNextPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 592, - "src": "3119:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) view returns (uint256)" - } - }, - "id": 322, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3119:26:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 323, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3149:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "3119:31:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "4e6f742061206e6578742076616c696461746f72", - "id": 325, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3152:22:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_44981c92ce908443b2fa5f878c54791e1a0c95d4cc04ea4f4d9224b3ec030922", - "typeString": "literal_string \"Not a next validator\"" - }, - "value": "Not a next validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_44981c92ce908443b2fa5f878c54791e1a0c95d4cc04ea4f4d9224b3ec030922", - "typeString": "literal_string \"Not a next validator\"" - } - ], - "id": 318, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "3111:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 326, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3111:64:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 327, - "nodeType": "ExpressionStatement", - "src": "3111:64:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 329, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "3201:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 330, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CONFIRM_KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3201:19:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 331, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 311, - "src": "3222:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 332, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 313, - "src": "3225:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 328, - "name": "tryConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 984, - 1012 - ], - "referencedDeclaration": 1012, - "src": "3190:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_uint256_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,uint256,uint256) returns (bool)" - } - }, - "id": 333, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3190:37:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 380, - "nodeType": "IfStatement", - "src": "3186:434:0", - "trueBody": { - "id": 379, - "nodeType": "Block", - "src": "3229:391:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 339, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 334, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3243:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 336, - "indexExpression": { - "argumentTypes": null, - "id": 335, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3250:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3243:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 337, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "x", - "nodeType": "MemberAccess", - "referencedDeclaration": 37, - "src": "3243:19:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 338, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 311, - "src": "3265:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3243:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 340, - "nodeType": "ExpressionStatement", - "src": "3243:23:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 346, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 341, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3280:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 343, - "indexExpression": { - "argumentTypes": null, - "id": 342, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3287:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3280:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 344, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "y", - "nodeType": "MemberAccess", - "referencedDeclaration": 39, - "src": "3280:19:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 345, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 313, - "src": "3302:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3280:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 347, - "nodeType": "ExpressionStatement", - "src": "3280:23:0" - }, - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 350, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 348, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3321:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 349, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3334:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "3321:14:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": { - "id": 377, - "nodeType": "Block", - "src": "3490:120:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 370, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 367, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "3508:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 368, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "3517:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 369, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "FUNDS_TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3517:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "3508:30:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 371, - "nodeType": "ExpressionStatement", - "src": "3508:30:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 373, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3578:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 374, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3585:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 372, - "name": "NewFundsTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 22, - "src": "3561:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256)" - } - }, - "id": 375, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3561:34:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 376, - "nodeType": "EmitStatement", - "src": "3556:39:0" - } - ] - }, - "id": 378, - "nodeType": "IfStatement", - "src": "3317:293:0", - "trueBody": { - "id": 366, - "nodeType": "Block", - "src": "3337:135:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 354, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 351, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "3355:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 352, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "3364:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 353, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3364:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "3355:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 355, - "nodeType": "ExpressionStatement", - "src": "3355:21:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 358, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 356, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3394:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 357, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3402:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3394:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 359, - "nodeType": "ExpressionStatement", - "src": "3394:17:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 361, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3445:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 362, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 311, - "src": "3452:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 363, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 313, - "src": "3455:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 360, - "name": "EpochStart", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 30, - "src": "3434:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256,uint256)" - } - }, - "id": 364, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3434:23:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 365, - "nodeType": "EmitStatement", - "src": "3429:28:0" - } - ] - } - } - ] - } - } - ] - }, - "documentation": null, - "id": 382, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 316, - "modifierName": { - "argumentTypes": null, - "id": 315, - "name": "keygen", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 216, - "src": "3094:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "3094:6:0" - } - ], - "name": "confirmKeygen", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 314, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 311, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 382, - "src": "3071:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 310, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "3071:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 313, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 382, - "src": "3079:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 312, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "3079:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "3070:16:0" - }, - "returnParameters": { - "id": 317, - "nodeType": "ParameterList", - "parameters": [], - "src": "3101:0:0" - }, - "scope": 1138, - "src": "3048:578:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 423, - "nodeType": "Block", - "src": "3702:281:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 392, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 390, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3720:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": ">", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 391, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3728:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "3720:9:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "46697273742065706f636820646f6573206e6f74206e6565642066756e6473207472616e73666572", - "id": 393, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "3731:42:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_8ddae2cc9da30ed8c59c39c6a950ef823ea484ac89ff6f37abb0317fb5f679a1", - "typeString": "literal_string \"First epoch does not need funds transfer\"" - }, - "value": "First epoch does not need funds transfer" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_8ddae2cc9da30ed8c59c39c6a950ef823ea484ac89ff6f37abb0317fb5f679a1", - "typeString": "literal_string \"First epoch does not need funds transfer\"" - } - ], - "id": 389, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "3712:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 394, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3712:62:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 395, - "nodeType": "ExpressionStatement", - "src": "3712:62:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 397, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "3800:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 398, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CONFIRM_FUNDS_TRANSFER", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3800:27:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 396, - "name": "tryConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 984, - 1012 - ], - "referencedDeclaration": 984, - "src": "3789:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 399, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3789:39:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 422, - "nodeType": "IfStatement", - "src": "3785:192:0", - "trueBody": { - "id": 421, - "nodeType": "Block", - "src": "3830:147:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 403, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 400, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "3844:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 401, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "3853:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 402, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "READY", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "3853:12:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "3844:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 404, - "nodeType": "ExpressionStatement", - "src": "3844:21:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 407, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 405, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3879:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 406, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "3887:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "3879:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 408, - "nodeType": "ExpressionStatement", - "src": "3879:17:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 410, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3926:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 411, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3933:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 413, - "indexExpression": { - "argumentTypes": null, - "id": 412, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3940:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3933:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 414, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "x", - "nodeType": "MemberAccess", - "referencedDeclaration": 37, - "src": "3933:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 415, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "3950:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 417, - "indexExpression": { - "argumentTypes": null, - "id": 416, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "3957:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "3950:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 418, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "y", - "nodeType": "MemberAccess", - "referencedDeclaration": 39, - "src": "3950:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 409, - "name": "EpochStart", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 30, - "src": "3915:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256,uint256)" - } - }, - "id": 419, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "3915:51:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 420, - "nodeType": "EmitStatement", - "src": "3910:56:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 424, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 385, - "modifierName": { - "argumentTypes": null, - "id": 384, - "name": "fundsTransfer", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 228, - "src": "3671:13:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "3671:13:0" - }, - { - "arguments": null, - "id": 387, - "modifierName": { - "argumentTypes": null, - "id": 386, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "3685:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "3685:16:0" - } - ], - "name": "confirmFundsTransfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 383, - "nodeType": "ParameterList", - "parameters": [], - "src": "3661:2:0" - }, - "returnParameters": { - "id": 388, - "nodeType": "ParameterList", - "parameters": [], - "src": "3702:0:0" - }, - "scope": 1138, - "src": "3632:351:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 433, - "nodeType": "Block", - "src": "4038:41:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 430, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4066:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 429, - "name": "getParties", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 434, - 458 - ], - "referencedDeclaration": 458, - "src": "4055:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 431, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4055:17:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 428, - "id": 432, - "nodeType": "Return", - "src": "4048:24:0" - } - ] - }, - "documentation": null, - "id": 434, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getParties", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 425, - "nodeType": "ParameterList", - "parameters": [], - "src": "4008:2:0" - }, - "returnParameters": { - "id": 428, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 427, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 434, - "src": "4032:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 426, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4032:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4031:6:0" - }, - "scope": 1138, - "src": "3989:90:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 443, - "nodeType": "Block", - "src": "4138:45:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 440, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "4166:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 439, - "name": "getParties", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 434, - 458 - ], - "referencedDeclaration": 458, - "src": "4155:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 441, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4155:21:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 438, - "id": 442, - "nodeType": "Return", - "src": "4148:28:0" - } - ] - }, - "documentation": null, - "id": 444, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextParties", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 435, - "nodeType": "ParameterList", - "parameters": [], - "src": "4108:2:0" - }, - "returnParameters": { - "id": 438, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 437, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 444, - "src": "4132:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 436, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4132:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4131:6:0" - }, - "scope": 1138, - "src": "4085:98:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 457, - "nodeType": "Block", - "src": "4249:56:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 451, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4266:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 453, - "indexExpression": { - "argumentTypes": null, - "id": 452, - "name": "_epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 446, - "src": "4273:6:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4266:14:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 454, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "4266:25:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 455, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "4266:32:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 450, - "id": 456, - "nodeType": "Return", - "src": "4259:39:0" - } - ] - }, - "documentation": null, - "id": 458, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getParties", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 447, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 446, - "name": "_epoch", - "nodeType": "VariableDeclaration", - "scope": 458, - "src": "4209:11:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 445, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4209:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4208:13:0" - }, - "returnParameters": { - "id": 450, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 449, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 458, - "src": "4243:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 448, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4243:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4242:6:0" - }, - "scope": 1138, - "src": "4189:116:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 467, - "nodeType": "Block", - "src": "4362:43:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 464, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4392:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 463, - "name": "getThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 468, - 491 - ], - "referencedDeclaration": 491, - "src": "4379:12:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 465, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4379:19:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 462, - "id": 466, - "nodeType": "Return", - "src": "4372:26:0" - } - ] - }, - "documentation": null, - "id": 468, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 459, - "nodeType": "ParameterList", - "parameters": [], - "src": "4332:2:0" - }, - "returnParameters": { - "id": 462, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 461, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 468, - "src": "4356:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 460, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4356:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4355:6:0" - }, - "scope": 1138, - "src": "4311:94:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 477, - "nodeType": "Block", - "src": "4466:47:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 474, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "4496:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 473, - "name": "getThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 468, - 491 - ], - "referencedDeclaration": 491, - "src": "4483:12:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_uint256_$returns$_t_uint256_$", - "typeString": "function (uint256) view returns (uint256)" - } - }, - "id": 475, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4483:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 472, - "id": 476, - "nodeType": "Return", - "src": "4476:30:0" - } - ] - }, - "documentation": null, - "id": 478, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 469, - "nodeType": "ParameterList", - "parameters": [], - "src": "4436:2:0" - }, - "returnParameters": { - "id": 472, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 471, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 478, - "src": "4460:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 470, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4460:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4459:6:0" - }, - "scope": 1138, - "src": "4411:102:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 490, - "nodeType": "Block", - "src": "4581:48:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 485, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4598:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 487, - "indexExpression": { - "argumentTypes": null, - "id": 486, - "name": "_epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 480, - "src": "4605:6:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4598:14:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 488, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "4598:24:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 484, - "id": 489, - "nodeType": "Return", - "src": "4591:31:0" - } - ] - }, - "documentation": null, - "id": 491, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 481, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 480, - "name": "_epoch", - "nodeType": "VariableDeclaration", - "scope": 491, - "src": "4541:11:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 479, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4541:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4540:13:0" - }, - "returnParameters": { - "id": 484, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 483, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 491, - "src": "4575:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 482, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4575:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4574:6:0" - }, - "scope": 1138, - "src": "4519:110:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 501, - "nodeType": "Block", - "src": "4678:39:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 496, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4695:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 498, - "indexExpression": { - "argumentTypes": null, - "id": 497, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4702:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4695:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 499, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "x", - "nodeType": "MemberAccess", - "referencedDeclaration": 37, - "src": "4695:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 495, - "id": 500, - "nodeType": "Return", - "src": "4688:22:0" - } - ] - }, - "documentation": null, - "id": 502, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getX", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 492, - "nodeType": "ParameterList", - "parameters": [], - "src": "4648:2:0" - }, - "returnParameters": { - "id": 495, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 494, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 502, - "src": "4672:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 493, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4672:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4671:6:0" - }, - "scope": 1138, - "src": "4635:82:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 512, - "nodeType": "Block", - "src": "4766:39:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 507, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "4783:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 509, - "indexExpression": { - "argumentTypes": null, - "id": 508, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "4790:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4783:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 510, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "y", - "nodeType": "MemberAccess", - "referencedDeclaration": 39, - "src": "4783:15:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 506, - "id": 511, - "nodeType": "Return", - "src": "4776:22:0" - } - ] - }, - "documentation": null, - "id": 513, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getY", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 503, - "nodeType": "ParameterList", - "parameters": [], - "src": "4736:2:0" - }, - "returnParameters": { - "id": 506, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 505, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 513, - "src": "4760:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 504, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4760:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4759:6:0" - }, - "scope": 1138, - "src": "4723:82:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 551, - "nodeType": "Block", - "src": "4860:215:0", - "statements": [ - { - "assignments": [ - 521 - ], - "declarations": [ - { - "constant": false, - "id": 521, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 551, - "src": "4870:27:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 519, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "4870:7:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 520, - "length": null, - "nodeType": "ArrayTypeName", - "src": "4870:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 524, - "initialValue": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 522, - "name": "getValidators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 604, - "src": "4900:13:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_array$_t_address_$dyn_memory_ptr_$", - "typeString": "function () view returns (address[] memory)" - } - }, - "id": 523, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4900:15:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "4870:45:0" - }, - { - "body": { - "id": 547, - "nodeType": "Block", - "src": "4965:86:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 541, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 536, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 521, - "src": "4983:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 538, - "indexExpression": { - "argumentTypes": null, - "id": 537, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "4994:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "4983:13:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 539, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "5000:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 540, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "5000:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - }, - "src": "4983:27:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 546, - "nodeType": "IfStatement", - "src": "4979:61:0", - "trueBody": { - "expression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 544, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 542, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "5035:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "+", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 543, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5039:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "5035:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 517, - "id": 545, - "nodeType": "Return", - "src": "5028:12:0" - } - } - ] - }, - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 532, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 529, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "4942:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 530, - "name": "getParties", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 434, - 458 - ], - "referencedDeclaration": 434, - "src": "4946:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 531, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "4946:12:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "4942:16:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 548, - "initializationExpression": { - "assignments": [ - 526 - ], - "declarations": [ - { - "constant": false, - "id": 526, - "name": "i", - "nodeType": "VariableDeclaration", - "scope": 548, - "src": "4930:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 525, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4930:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 528, - "initialValue": { - "argumentTypes": null, - "hexValue": "30", - "id": 527, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "4939:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "nodeType": "VariableDeclarationStatement", - "src": "4930:10:0" - }, - "loopExpression": { - "expression": { - "argumentTypes": null, - "id": 534, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "4960:3:0", - "subExpression": { - "argumentTypes": null, - "id": 533, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 526, - "src": "4960:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 535, - "nodeType": "ExpressionStatement", - "src": "4960:3:0" - }, - "nodeType": "ForStatement", - "src": "4925:126:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "30", - "id": 549, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5067:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "functionReturnParameters": 517, - "id": 550, - "nodeType": "Return", - "src": "5060:8:0" - } - ] - }, - "documentation": null, - "id": 552, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getPartyId", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 514, - "nodeType": "ParameterList", - "parameters": [], - "src": "4830:2:0" - }, - "returnParameters": { - "id": 517, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 516, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 552, - "src": "4854:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 515, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "4854:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "4853:6:0" - }, - "scope": 1138, - "src": "4811:264:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 591, - "nodeType": "Block", - "src": "5143:214:0", - "statements": [ - { - "assignments": [ - 562 - ], - "declarations": [ - { - "constant": false, - "id": 562, - "name": "validators", - "nodeType": "VariableDeclaration", - "scope": 591, - "src": "5153:27:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 560, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5153:7:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 561, - "length": null, - "nodeType": "ArrayTypeName", - "src": "5153:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 565, - "initialValue": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 563, - "name": "getNextValidators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 616, - "src": "5183:17:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_array$_t_address_$dyn_memory_ptr_$", - "typeString": "function () view returns (address[] memory)" - } - }, - "id": 564, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5183:19:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "5153:49:0" - }, - { - "body": { - "id": 587, - "nodeType": "Block", - "src": "5256:77:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 581, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 577, - "name": "validators", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 562, - "src": "5274:10:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[] memory" - } - }, - "id": 579, - "indexExpression": { - "argumentTypes": null, - "id": 578, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5285:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5274:13:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "id": 580, - "name": "a", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 554, - "src": "5291:1:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "5274:18:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 586, - "nodeType": "IfStatement", - "src": "5270:52:0", - "trueBody": { - "expression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 584, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 582, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5317:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "+", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 583, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5321:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "5317:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "functionReturnParameters": 558, - "id": 585, - "nodeType": "Return", - "src": "5310:12:0" - } - } - ] - }, - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 573, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 570, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5229:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 571, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "5233:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 572, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5233:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "5229:20:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 588, - "initializationExpression": { - "assignments": [ - 567 - ], - "declarations": [ - { - "constant": false, - "id": 567, - "name": "i", - "nodeType": "VariableDeclaration", - "scope": 588, - "src": "5217:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 566, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "5217:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 569, - "initialValue": { - "argumentTypes": null, - "hexValue": "30", - "id": 568, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5226:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "nodeType": "VariableDeclarationStatement", - "src": "5217:10:0" - }, - "loopExpression": { - "expression": { - "argumentTypes": null, - "id": 575, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "5251:3:0", - "subExpression": { - "argumentTypes": null, - "id": 574, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 567, - "src": "5251:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 576, - "nodeType": "ExpressionStatement", - "src": "5251:3:0" - }, - "nodeType": "ForStatement", - "src": "5212:121:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "30", - "id": 589, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "5349:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "functionReturnParameters": 558, - "id": 590, - "nodeType": "Return", - "src": "5342:8:0" - } - ] - }, - "documentation": null, - "id": 592, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextPartyId", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 555, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 554, - "name": "a", - "nodeType": "VariableDeclaration", - "scope": 592, - "src": "5105:9:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 553, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5105:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5104:11:0" - }, - "returnParameters": { - "id": 558, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 557, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 592, - "src": "5137:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 556, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "5137:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5136:6:0" - }, - "scope": 1138, - "src": "5081:276:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 603, - "nodeType": "Block", - "src": "5427:48:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 598, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5444:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 600, - "indexExpression": { - "argumentTypes": null, - "id": 599, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "5451:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5444:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 601, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5444:24:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "functionReturnParameters": 597, - "id": 602, - "nodeType": "Return", - "src": "5437:31:0" - } - ] - }, - "documentation": null, - "id": 604, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getValidators", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 593, - "nodeType": "ParameterList", - "parameters": [], - "src": "5385:2:0" - }, - "returnParameters": { - "id": 597, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 596, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 604, - "src": "5409:16:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 594, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5409:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 595, - "length": null, - "nodeType": "ArrayTypeName", - "src": "5409:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5408:18:0" - }, - "scope": 1138, - "src": "5363:112:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 615, - "nodeType": "Block", - "src": "5549:52:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 610, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5566:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 612, - "indexExpression": { - "argumentTypes": null, - "id": 611, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5573:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5566:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 613, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5566:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "functionReturnParameters": 609, - "id": 614, - "nodeType": "Return", - "src": "5559:35:0" - } - ] - }, - "documentation": null, - "id": 616, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "getNextValidators", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 605, - "nodeType": "ParameterList", - "parameters": [], - "src": "5507:2:0" - }, - "returnParameters": { - "id": 609, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 608, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 616, - "src": "5531:16:0", - "stateVariable": false, - "storageLocation": "memory", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_memory_ptr", - "typeString": "address[]" - }, - "typeName": { - "baseType": { - "id": 606, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5531:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 607, - "length": null, - "nodeType": "ArrayTypeName", - "src": "5531:9:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage_ptr", - "typeString": "address[]" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5530:18:0" - }, - "scope": 1138, - "src": "5481:120:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 657, - "nodeType": "Block", - "src": "5668:256:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 624, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "5690:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 625, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "START_VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "5690:17:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 623, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 882, - "src": "5682:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 626, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "5682:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 656, - "nodeType": "IfStatement", - "src": "5678:240:0", - "trueBody": { - "id": 655, - "nodeType": "Block", - "src": "5710:208:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 628, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "5724:11:0", - "subExpression": { - "argumentTypes": null, - "id": 627, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5724:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 629, - "nodeType": "ExpressionStatement", - "src": "5724:11:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 633, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 630, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "5749:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 631, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "5758:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 632, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "5758:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "5749:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 634, - "nodeType": "ExpressionStatement", - "src": "5749:22:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 643, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 635, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5785:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 637, - "indexExpression": { - "argumentTypes": null, - "id": 636, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5792:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5785:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 638, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "5785:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 639, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5815:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 641, - "indexExpression": { - "argumentTypes": null, - "id": 640, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "5822:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5815:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 642, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "5815:23:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "5785:53:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 644, - "nodeType": "ExpressionStatement", - "src": "5785:53:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 653, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 645, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5852:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 647, - "indexExpression": { - "argumentTypes": null, - "id": 646, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "5859:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5852:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 648, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5852:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 649, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "5883:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 651, - "indexExpression": { - "argumentTypes": null, - "id": 650, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "5890:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "5883:13:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 652, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "5883:24:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "src": "5852:55:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 654, - "nodeType": "ExpressionStatement", - "src": "5852:55:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 658, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 619, - "modifierName": { - "argumentTypes": null, - "id": 618, - "name": "readyOrVoting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 192, - "src": "5637:13:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5637:13:0" - }, - { - "arguments": null, - "id": 621, - "modifierName": { - "argumentTypes": null, - "id": 620, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "5651:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5651:16:0" - } - ], - "name": "startVoting", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 617, - "nodeType": "ParameterList", - "parameters": [], - "src": "5627:2:0" - }, - "returnParameters": { - "id": 622, - "nodeType": "ParameterList", - "parameters": [], - "src": "5668:0:0" - }, - "scope": 1138, - "src": "5607:317:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 691, - "nodeType": "Block", - "src": "6006:202:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 672, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 669, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 660, - "src": "6039:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 668, - "name": "getNextPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 592, - "src": "6024:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) view returns (uint256)" - } - }, - "id": 670, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6024:25:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 671, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6053:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "6024:30:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "416c726561647920612076616c696461746f72", - "id": 673, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6056:21:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_aeb0fe100da2796aa6136a3b1c66282f002b435141be331237dfa7127e6df6ff", - "typeString": "literal_string \"Already a validator\"" - }, - "value": "Already a validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_aeb0fe100da2796aa6136a3b1c66282f002b435141be331237dfa7127e6df6ff", - "typeString": "literal_string \"Already a validator\"" - } - ], - "id": 667, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "6016:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 674, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6016:62:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 675, - "nodeType": "ExpressionStatement", - "src": "6016:62:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 677, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "6101:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 678, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "ADD_VALIDATOR", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6101:18:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 679, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 660, - "src": "6121:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 676, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 907, - "src": "6093:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_address_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,address) returns (bool)" - } - }, - "id": 680, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6093:38:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 690, - "nodeType": "IfStatement", - "src": "6089:113:0", - "trueBody": { - "id": 689, - "nodeType": "Block", - "src": "6133:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 686, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 660, - "src": "6181:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 681, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6147:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 683, - "indexExpression": { - "argumentTypes": null, - "id": 682, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6154:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6147:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 684, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6147:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 685, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "push", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6147:33:0", - "typeDescriptions": { - "typeIdentifier": "t_function_arraypush_nonpayable$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) returns (uint256)" - } - }, - "id": 687, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6147:44:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 688, - "nodeType": "ExpressionStatement", - "src": "6147:44:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 692, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 663, - "modifierName": { - "argumentTypes": null, - "id": 662, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "5982:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5982:6:0" - }, - { - "arguments": null, - "id": 665, - "modifierName": { - "argumentTypes": null, - "id": 664, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "5989:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "5989:16:0" - } - ], - "name": "voteAddValidator", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 661, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 660, - "name": "validator", - "nodeType": "VariableDeclaration", - "scope": 692, - "src": "5956:17:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 659, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "5956:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "5955:19:0" - }, - "returnParameters": { - "id": 666, - "nodeType": "ParameterList", - "parameters": [], - "src": "6006:0:0" - }, - "scope": 1138, - "src": "5930:278:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 721, - "nodeType": "Block", - "src": "6293:192:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 706, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 703, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 694, - "src": "6326:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 702, - "name": "getNextPartyId", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 592, - "src": "6311:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_address_$returns$_t_uint256_$", - "typeString": "function (address) view returns (uint256)" - } - }, - "id": 704, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6311:25:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "!=", - "rightExpression": { - "argumentTypes": null, - "hexValue": "30", - "id": 705, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6340:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "src": "6311:30:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "416c7265616479206e6f7420612076616c696461746f72", - "id": 707, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6343:25:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_2332ed568e8af3d64f1f2b0b098c504cab97ba4128fb9f08cfa3f851ced05961", - "typeString": "literal_string \"Already not a validator\"" - }, - "value": "Already not a validator" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_2332ed568e8af3d64f1f2b0b098c504cab97ba4128fb9f08cfa3f851ced05961", - "typeString": "literal_string \"Already not a validator\"" - } - ], - "id": 701, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "6303:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 708, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6303:66:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 709, - "nodeType": "ExpressionStatement", - "src": "6303:66:0" - }, - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 711, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "6392:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 712, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "REMOVE_VALIDATOR", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6392:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 713, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 694, - "src": "6415:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 710, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 907, - "src": "6384:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_address_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,address) returns (bool)" - } - }, - "id": 714, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6384:41:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 720, - "nodeType": "IfStatement", - "src": "6380:99:0", - "trueBody": { - "id": 719, - "nodeType": "Block", - "src": "6427:52:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 716, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 694, - "src": "6458:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "id": 715, - "name": "_removeValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 789, - "src": "6441:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_address_$returns$__$", - "typeString": "function (address)" - } - }, - "id": 717, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6441:27:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 718, - "nodeType": "ExpressionStatement", - "src": "6441:27:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 722, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 697, - "modifierName": { - "argumentTypes": null, - "id": 696, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "6269:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "6269:6:0" - }, - { - "arguments": null, - "id": 699, - "modifierName": { - "argumentTypes": null, - "id": 698, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "6276:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "6276:16:0" - } - ], - "name": "voteRemoveValidator", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 695, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 694, - "name": "validator", - "nodeType": "VariableDeclaration", - "scope": 722, - "src": "6243:17:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 693, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "6243:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "6242:19:0" - }, - "returnParameters": { - "id": 700, - "nodeType": "ParameterList", - "parameters": [], - "src": "6293:0:0" - }, - "scope": 1138, - "src": "6214:271:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 788, - "nodeType": "Block", - "src": "6544:392:0", - "statements": [ - { - "body": { - "id": 768, - "nodeType": "Block", - "src": "6602:214:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "id": 747, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 740, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6620:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 742, - "indexExpression": { - "argumentTypes": null, - "id": 741, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6627:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6620:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 743, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6620:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 745, - "indexExpression": { - "argumentTypes": null, - "id": 744, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6649:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6620:31:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "id": 746, - "name": "validator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 724, - "src": "6655:9:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "6620:44:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 767, - "nodeType": "IfStatement", - "src": "6616:190:0", - "trueBody": { - "id": 766, - "nodeType": "Block", - "src": "6666:140:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 763, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 748, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6684:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 750, - "indexExpression": { - "argumentTypes": null, - "id": 749, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6691:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6684:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 751, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6684:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 753, - "indexExpression": { - "argumentTypes": null, - "id": 752, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6713:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "6684:31:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 754, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6718:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 756, - "indexExpression": { - "argumentTypes": null, - "id": 755, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6725:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6718:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 757, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6718:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 762, - "indexExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 761, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 758, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "6747:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 759, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6747:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 760, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6766:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "6747:20:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6718:50:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "src": "6684:84:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "id": 764, - "nodeType": "ExpressionStatement", - "src": "6684:84:0" - }, - { - "id": 765, - "nodeType": "Break", - "src": "6786:5:0" - } - ] - } - } - ] - }, - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 736, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "id": 731, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6571:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "<", - "rightExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 735, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 732, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "6575:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 733, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6575:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 734, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6594:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "6575:20:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "6571:24:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 769, - "initializationExpression": { - "assignments": [ - 728 - ], - "declarations": [ - { - "constant": false, - "id": 728, - "name": "i", - "nodeType": "VariableDeclaration", - "scope": 769, - "src": "6559:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 727, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "6559:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 730, - "initialValue": { - "argumentTypes": null, - "hexValue": "30", - "id": 729, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6568:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_0_by_1", - "typeString": "int_const 0" - }, - "value": "0" - }, - "nodeType": "VariableDeclarationStatement", - "src": "6559:10:0" - }, - "loopExpression": { - "expression": { - "argumentTypes": null, - "id": 738, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "6597:3:0", - "subExpression": { - "argumentTypes": null, - "id": 737, - "name": "i", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 728, - "src": "6597:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 739, - "nodeType": "ExpressionStatement", - "src": "6597:3:0" - }, - "nodeType": "ForStatement", - "src": "6554:262:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 779, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "delete", - "prefix": true, - "src": "6825:57:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 770, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6832:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 772, - "indexExpression": { - "argumentTypes": null, - "id": 771, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6839:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6832:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 773, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6832:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 778, - "indexExpression": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 777, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 774, - "name": "getNextParties", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 444, - "src": "6861:14:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 775, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "6861:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "-", - "rightExpression": { - "argumentTypes": null, - "hexValue": "31", - "id": 776, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "6880:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_1_by_1", - "typeString": "int_const 1" - }, - "value": "1" - }, - "src": "6861:20:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "6832:50:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 780, - "nodeType": "ExpressionStatement", - "src": "6825:57:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 786, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "--", - "prefix": false, - "src": "6892:37:0", - "subExpression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 781, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "6892:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 783, - "indexExpression": { - "argumentTypes": null, - "id": 782, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "6899:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "6892:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 784, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "memberName": "validators", - "nodeType": "MemberAccess", - "referencedDeclaration": 33, - "src": "6892:28:0", - "typeDescriptions": { - "typeIdentifier": "t_array$_t_address_$dyn_storage", - "typeString": "address[] storage ref" - } - }, - "id": 785, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "length", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "6892:35:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 787, - "nodeType": "ExpressionStatement", - "src": "6892:37:0" - } - ] - }, - "documentation": null, - "id": 789, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "_removeValidator", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 725, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 724, - "name": "validator", - "nodeType": "VariableDeclaration", - "scope": 789, - "src": "6517:17:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 723, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "6517:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "6516:19:0" - }, - "returnParameters": { - "id": 726, - "nodeType": "ParameterList", - "parameters": [], - "src": "6544:0:0" - }, - "scope": 1138, - "src": "6491:445:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 812, - "nodeType": "Block", - "src": "7018:127:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 799, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "7040:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 800, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CHANGE_THRESHOLD", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7040:21:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 801, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 791, - "src": "7063:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 798, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 932, - "src": "7032:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$_t_uint256_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote,uint256) returns (bool)" - } - }, - "id": 802, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7032:41:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 811, - "nodeType": "IfStatement", - "src": "7028:111:0", - "trueBody": { - "id": 810, - "nodeType": "Block", - "src": "7075:64:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 808, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 803, - "name": "states", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 59, - "src": "7089:6:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_uint256_$_t_struct$_State_$40_storage_$", - "typeString": "mapping(uint256 => struct Bridge.State storage ref)" - } - }, - "id": 805, - "indexExpression": { - "argumentTypes": null, - "id": 804, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7096:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "7089:17:0", - "typeDescriptions": { - "typeIdentifier": "t_struct$_State_$40_storage", - "typeString": "struct Bridge.State storage ref" - } - }, - "id": 806, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "memberName": "threshold", - "nodeType": "MemberAccess", - "referencedDeclaration": 35, - "src": "7089:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "id": 807, - "name": "threshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 791, - "src": "7119:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "7089:39:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 809, - "nodeType": "ExpressionStatement", - "src": "7089:39:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 813, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 794, - "modifierName": { - "argumentTypes": null, - "id": 793, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "6994:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "6994:6:0" - }, - { - "arguments": null, - "id": 796, - "modifierName": { - "argumentTypes": null, - "id": 795, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "7001:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7001:16:0" - } - ], - "name": "voteChangeThreshold", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 792, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 791, - "name": "threshold", - "nodeType": "VariableDeclaration", - "scope": 813, - "src": "6971:14:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 790, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "6971:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "6970:16:0" - }, - "returnParameters": { - "id": 797, - "nodeType": "ParameterList", - "parameters": [], - "src": "7018:0:0" - }, - "scope": 1138, - "src": "6942:203:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 836, - "nodeType": "Block", - "src": "7209:141:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 821, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "7231:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 822, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "START_KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7231:17:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 820, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 882, - "src": "7223:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 823, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7223:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 835, - "nodeType": "IfStatement", - "src": "7219:125:0", - "trueBody": { - "id": 834, - "nodeType": "Block", - "src": "7251:93:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 827, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 824, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "7265:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 825, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "7274:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 826, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7274:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "7265:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 828, - "nodeType": "ExpressionStatement", - "src": "7265:22:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 830, - "name": "epoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 79, - "src": "7316:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 831, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7323:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 829, - "name": "NewEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12, - "src": "7307:8:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$_t_uint256_$returns$__$", - "typeString": "function (uint256,uint256)" - } - }, - "id": 832, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7307:26:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 833, - "nodeType": "EmitStatement", - "src": "7302:31:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 837, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 816, - "modifierName": { - "argumentTypes": null, - "id": 815, - "name": "voting", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 204, - "src": "7185:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7185:6:0" - }, - { - "arguments": null, - "id": 818, - "modifierName": { - "argumentTypes": null, - "id": 817, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "7192:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7192:16:0" - } - ], - "name": "voteStartKeygen", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 814, - "nodeType": "ParameterList", - "parameters": [], - "src": "7175:2:0" - }, - "returnParameters": { - "id": 819, - "nodeType": "ParameterList", - "parameters": [], - "src": "7209:0:0" - }, - "scope": 1138, - "src": "7151:199:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 859, - "nodeType": "Block", - "src": "7415:144:0", - "statements": [ - { - "condition": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 845, - "name": "Vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 55, - "src": "7437:4:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Vote_$55_$", - "typeString": "type(enum Bridge.Vote)" - } - }, - "id": 846, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "CANCEL_KEYGEN", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7437:18:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - ], - "id": 844, - "name": "tryVote", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 882, - 907, - 932, - 962 - ], - "referencedDeclaration": 882, - "src": "7429:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_enum$_Vote_$55_$returns$_t_bool_$", - "typeString": "function (enum Bridge.Vote) returns (bool)" - } - }, - "id": 847, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7429:27:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": null, - "id": 858, - "nodeType": "IfStatement", - "src": "7425:128:0", - "trueBody": { - "id": 857, - "nodeType": "Block", - "src": "7458:95:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 851, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "id": 848, - "name": "status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 77, - "src": "7472:6:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 849, - "name": "Status", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 45, - "src": "7481:6:0", - "typeDescriptions": { - "typeIdentifier": "t_type$_t_enum$_Status_$45_$", - "typeString": "type(enum Bridge.Status)" - } - }, - "id": 850, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "VOTING", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7481:13:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "src": "7472:22:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Status_$45", - "typeString": "enum Bridge.Status" - } - }, - "id": 852, - "nodeType": "ExpressionStatement", - "src": "7472:22:0" - }, - { - "eventCall": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 854, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7532:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "id": 853, - "name": "NewEpochCancelled", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 16, - "src": "7514:17:0", - "typeDescriptions": { - "typeIdentifier": "t_function_event_nonpayable$_t_uint256_$returns$__$", - "typeString": "function (uint256)" - } - }, - "id": 855, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7514:28:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 856, - "nodeType": "EmitStatement", - "src": "7509:33:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 860, - "implemented": true, - "kind": "function", - "modifiers": [ - { - "arguments": null, - "id": 840, - "modifierName": { - "argumentTypes": null, - "id": 839, - "name": "keygen", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 216, - "src": "7391:6:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7391:6:0" - }, - { - "arguments": null, - "id": 842, - "modifierName": { - "argumentTypes": null, - "id": 841, - "name": "currentValidator", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 240, - "src": "7398:16:0", - "typeDescriptions": { - "typeIdentifier": "t_modifier$__$", - "typeString": "modifier ()" - } - }, - "nodeType": "ModifierInvocation", - "src": "7398:16:0" - } - ], - "name": "voteCancelKeygen", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 838, - "nodeType": "ParameterList", - "parameters": [], - "src": "7381:2:0" - }, - "returnParameters": { - "id": 843, - "nodeType": "ParameterList", - "parameters": [], - "src": "7415:0:0" - }, - "scope": 1138, - "src": "7356:203:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "public" - }, - { - "body": { - "id": 881, - "nodeType": "Block", - "src": "7620:110:0", - "statements": [ - { - "assignments": [ - 868 - ], - "declarations": [ - { - "constant": false, - "id": 868, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 881, - "src": "7630:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 867, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "7630:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 876, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 872, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 862, - "src": "7672:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 873, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7682:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 870, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "7655:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 871, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7655:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 874, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7655:37:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 869, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "7645:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 875, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7645:48:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "7630:63:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 878, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 868, - "src": "7718:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 877, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "7710:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 879, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7710:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 866, - "id": 880, - "nodeType": "Return", - "src": "7703:20:0" - } - ] - }, - "documentation": null, - "id": 882, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 863, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 862, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 882, - "src": "7582:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 861, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "7582:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7581:15:0" - }, - "returnParameters": { - "id": 866, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 865, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 882, - "src": "7614:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 864, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "7614:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7613:6:0" - }, - "scope": 1138, - "src": "7565:165:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 906, - "nodeType": "Block", - "src": "7805:116:0", - "statements": [ - { - "assignments": [ - 892 - ], - "declarations": [ - { - "constant": false, - "id": 892, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 906, - "src": "7815:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 891, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "7815:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 901, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 896, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 884, - "src": "7857:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 897, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "7867:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 898, - "name": "addr", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 886, - "src": "7878:4:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - } - ], - "expression": { - "argumentTypes": null, - "id": 894, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "7840:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 895, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "7840:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 899, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7840:43:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 893, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "7830:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 900, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7830:54:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "7815:69:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 903, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 892, - "src": "7909:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 902, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "7901:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 904, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "7901:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 890, - "id": 905, - "nodeType": "Return", - "src": "7894:20:0" - } - ] - }, - "documentation": null, - "id": 907, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 887, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 884, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 907, - "src": "7753:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 883, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "7753:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 886, - "name": "addr", - "nodeType": "VariableDeclaration", - "scope": 907, - "src": "7768:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 885, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "7768:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7752:29:0" - }, - "returnParameters": { - "id": 890, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 889, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 907, - "src": "7799:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 888, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "7799:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7798:6:0" - }, - "scope": 1138, - "src": "7736:185:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 931, - "nodeType": "Block", - "src": "7992:115:0", - "statements": [ - { - "assignments": [ - 917 - ], - "declarations": [ - { - "constant": false, - "id": 917, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 931, - "src": "8002:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 916, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8002:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 926, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 921, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 909, - "src": "8044:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 922, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "8054:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 923, - "name": "num", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 911, - "src": "8065:3:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 919, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8027:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 920, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8027:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 924, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8027:42:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 918, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8017:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 925, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8017:53:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8002:68:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 928, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 917, - "src": "8095:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 927, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "8087:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 929, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8087:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 915, - "id": 930, - "nodeType": "Return", - "src": "8080:20:0" - } - ] - }, - "documentation": null, - "id": 932, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 912, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 909, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 932, - "src": "7944:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 908, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "7944:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 911, - "name": "num", - "nodeType": "VariableDeclaration", - "scope": 932, - "src": "7959:8:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 910, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "7959:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7943:25:0" - }, - "returnParameters": { - "id": 915, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 914, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 932, - "src": "7986:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 913, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "7986:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "7985:6:0" - }, - "scope": 1138, - "src": "7927:180:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 961, - "nodeType": "Block", - "src": "8206:116:0", - "statements": [ - { - "assignments": [ - 946 - ], - "declarations": [ - { - "constant": false, - "id": 946, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 961, - "src": "8216:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 945, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8216:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 956, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 950, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 934, - "src": "8258:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 951, - "name": "hash", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 936, - "src": "8268:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "argumentTypes": null, - "id": 952, - "name": "to", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 938, - "src": "8274:2:0", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - { - "argumentTypes": null, - "id": 953, - "name": "value", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 940, - "src": "8278:5:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address", - "typeString": "address" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 948, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8241:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 949, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8241:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 954, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8241:43:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 947, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8231:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 955, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8231:54:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8216:69:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 958, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 946, - "src": "8310:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 957, - "name": "putVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1066, - "src": "8302:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 959, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8302:13:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 944, - "id": 960, - "nodeType": "Return", - "src": "8295:20:0" - } - ] - }, - "documentation": null, - "id": 962, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 941, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 934, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8130:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 933, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "8130:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 936, - "name": "hash", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8145:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 935, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8145:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 938, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8159:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 937, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "8159:7:0", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 940, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8171:10:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 939, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "8171:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8129:53:0" - }, - "returnParameters": { - "id": 944, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 943, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 962, - "src": "8200:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 942, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8200:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8199:6:0" - }, - "scope": 1138, - "src": "8113:209:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 983, - "nodeType": "Block", - "src": "8386:113:0", - "statements": [ - { - "assignments": [ - 970 - ], - "declarations": [ - { - "constant": false, - "id": 970, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 983, - "src": "8396:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 969, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8396:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 978, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 974, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 964, - "src": "8438:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 975, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "8448:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 972, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8421:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 973, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8421:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 976, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8421:37:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 971, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8411:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 977, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8411:48:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8396:63:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 980, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 970, - "src": "8487:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 979, - "name": "putConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1120, - "src": "8476:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 981, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8476:16:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 968, - "id": 982, - "nodeType": "Return", - "src": "8469:23:0" - } - ] - }, - "documentation": null, - "id": 984, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryConfirm", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 965, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 964, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 984, - "src": "8348:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 963, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "8348:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8347:15:0" - }, - "returnParameters": { - "id": 968, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 967, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 984, - "src": "8380:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 966, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8380:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8379:6:0" - }, - "scope": 1138, - "src": "8328:171:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1011, - "nodeType": "Block", - "src": "8579:119:0", - "statements": [ - { - "assignments": [ - 996 - ], - "declarations": [ - { - "constant": false, - "id": 996, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1011, - "src": "8589:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 995, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8589:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 1006, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1000, - "name": "voteType", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 986, - "src": "8631:8:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - { - "argumentTypes": null, - "id": 1001, - "name": "nextEpoch", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 81, - "src": "8641:9:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 1002, - "name": "x", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 988, - "src": "8652:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - { - "argumentTypes": null, - "id": 1003, - "name": "y", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 990, - "src": "8655:1:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - ], - "expression": { - "argumentTypes": null, - "id": 998, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "8614:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 999, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "8614:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 1004, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8614:43:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 997, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "8604:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 1005, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8604:54:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8589:69:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1008, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 996, - "src": "8686:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 1007, - "name": "putConfirm", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1120, - "src": "8675:10:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_nonpayable$_t_bytes32_$returns$_t_bool_$", - "typeString": "function (bytes32) returns (bool)" - } - }, - "id": 1009, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8675:16:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "functionReturnParameters": 994, - "id": 1010, - "nodeType": "Return", - "src": "8668:23:0" - } - ] - }, - "documentation": null, - "id": 1012, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "tryConfirm", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 991, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 986, - "name": "voteType", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8525:13:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - }, - "typeName": { - "contractScope": null, - "id": 985, - "name": "Vote", - "nodeType": "UserDefinedTypeName", - "referencedDeclaration": 55, - "src": "8525:4:0", - "typeDescriptions": { - "typeIdentifier": "t_enum$_Vote_$55", - "typeString": "enum Bridge.Vote" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 988, - "name": "x", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8540:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 987, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "8540:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 990, - "name": "y", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8548:6:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 989, - "name": "uint", - "nodeType": "ElementaryTypeName", - "src": "8548:4:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8524:31:0" - }, - "returnParameters": { - "id": 994, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 993, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1012, - "src": "8573:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 992, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8573:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8572:6:0" - }, - "scope": 1138, - "src": "8505:193:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1065, - "nodeType": "Block", - "src": "8758:355:0", - "statements": [ - { - "assignments": [ - 1020 - ], - "declarations": [ - { - "constant": false, - "id": 1020, - "name": "personalVote", - "nodeType": "VariableDeclaration", - "scope": 1065, - "src": "8768:20:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1019, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8768:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 1024, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1022, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "8807:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 1021, - "name": "personalizeVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1137, - "src": "8791:15:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_bytes32_$returns$_t_bytes32_$", - "typeString": "function (bytes32) view returns (bytes32)" - } - }, - "id": 1023, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8791:21:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "8768:44:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1029, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "!", - "prefix": true, - "src": "8830:20:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1026, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "8831:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1028, - "indexExpression": { - "argumentTypes": null, - "id": 1027, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1020, - "src": "8837:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "8831:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "566f74656420616c7265616479", - "id": 1030, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8852:15:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_230c30109b60c15b21799291aaf5c571045da3dc3f224d8bbd2f2e688c149a47", - "typeString": "literal_string \"Voted already\"" - }, - "value": "Voted already" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_230c30109b60c15b21799291aaf5c571045da3dc3f224d8bbd2f2e688c149a47", - "typeString": "literal_string \"Voted already\"" - } - ], - "id": 1025, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "8822:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 1031, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8822:46:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 1032, - "nodeType": "ExpressionStatement", - "src": "8822:46:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 1037, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1033, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "8879:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1035, - "indexExpression": { - "argumentTypes": null, - "id": 1034, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1020, - "src": "8885:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "8879:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1036, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8901:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "src": "8879:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 1038, - "nodeType": "ExpressionStatement", - "src": "8879:26:0" - }, - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 1044, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1039, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "8919:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1041, - "indexExpression": { - "argumentTypes": null, - "id": 1040, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "8930:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "8919:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 1042, - "name": "getThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 468, - 491 - ], - "referencedDeclaration": 468, - "src": "8939:12:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 1043, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "8939:14:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "8919:34:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": { - "id": 1063, - "nodeType": "Block", - "src": "9038:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1059, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "9052:18:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1056, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9052:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1058, - "indexExpression": { - "argumentTypes": null, - "id": 1057, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "9063:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9052:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1060, - "nodeType": "ExpressionStatement", - "src": "9052:18:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "66616c7365", - "id": 1061, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9091:5:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "false" - }, - "functionReturnParameters": 1018, - "id": 1062, - "nodeType": "Return", - "src": "9084:12:0" - } - ] - }, - "id": 1064, - "nodeType": "IfStatement", - "src": "8915:192:0", - "trueBody": { - "id": 1055, - "nodeType": "Block", - "src": "8955:77:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1051, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1045, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "8969:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1047, - "indexExpression": { - "argumentTypes": null, - "id": 1046, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1014, - "src": "8980:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "8969:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - }, - "id": 1050, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "hexValue": "32", - "id": 1048, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8988:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "argumentTypes": null, - "hexValue": "323535", - "id": 1049, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "8993:3:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_255_by_1", - "typeString": "int_const 255" - }, - "value": "255" - }, - "src": "8988:8:0", - "typeDescriptions": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - } - }, - "src": "8969:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1052, - "nodeType": "ExpressionStatement", - "src": "8969:27:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1053, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9017:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 1018, - "id": 1054, - "nodeType": "Return", - "src": "9010:11:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 1066, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "putVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 1015, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1014, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1066, - "src": "8721:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1013, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "8721:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8720:14:0" - }, - "returnParameters": { - "id": 1018, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1017, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1066, - "src": "8752:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 1016, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "8752:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "8751:6:0" - }, - "scope": 1138, - "src": "8704:409:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1119, - "nodeType": "Block", - "src": "9176:363:0", - "statements": [ - { - "assignments": [ - 1074 - ], - "declarations": [ - { - "constant": false, - "id": 1074, - "name": "personalVote", - "nodeType": "VariableDeclaration", - "scope": 1119, - "src": "9186:20:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1073, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9186:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "id": 1078, - "initialValue": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1076, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9225:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - ], - "id": 1075, - "name": "personalizeVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1137, - "src": "9209:15:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$_t_bytes32_$returns$_t_bytes32_$", - "typeString": "function (bytes32) view returns (bytes32)" - } - }, - "id": 1077, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9209:21:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "nodeType": "VariableDeclarationStatement", - "src": "9186:44:0" - }, - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1083, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "!", - "prefix": true, - "src": "9248:20:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1080, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "9249:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1082, - "indexExpression": { - "argumentTypes": null, - "id": 1081, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1074, - "src": "9255:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "9249:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - { - "argumentTypes": null, - "hexValue": "436f6e6669726d656420616c7265616479", - "id": 1084, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "string", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9270:19:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_stringliteral_762a97ce67d271844ad9c09d89a5271fde7fe7537af208da055a904cd67ac7bc", - "typeString": "literal_string \"Confirmed already\"" - }, - "value": "Confirmed already" - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - { - "typeIdentifier": "t_stringliteral_762a97ce67d271844ad9c09d89a5271fde7fe7537af208da055a904cd67ac7bc", - "typeString": "literal_string \"Confirmed already\"" - } - ], - "id": 1079, - "name": "require", - "nodeType": "Identifier", - "overloadedDeclarations": [ - 12832, - 12833 - ], - "referencedDeclaration": 12833, - "src": "9240:7:0", - "typeDescriptions": { - "typeIdentifier": "t_function_require_pure$_t_bool_$_t_string_memory_ptr_$returns$__$", - "typeString": "function (bool,string memory) pure" - } - }, - "id": 1085, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9240:50:0", - "typeDescriptions": { - "typeIdentifier": "t_tuple$__$", - "typeString": "tuple()" - } - }, - "id": 1086, - "nodeType": "ExpressionStatement", - "src": "9240:50:0" - }, - { - "expression": { - "argumentTypes": null, - "id": 1091, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1087, - "name": "votes", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 75, - "src": "9301:5:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_bool_$", - "typeString": "mapping(bytes32 => bool)" - } - }, - "id": 1089, - "indexExpression": { - "argumentTypes": null, - "id": 1088, - "name": "personalVote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1074, - "src": "9307:12:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9301:19:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1090, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9323:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "src": "9301:26:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "id": 1092, - "nodeType": "ExpressionStatement", - "src": "9301:26:0" - }, - { - "condition": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "id": 1098, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1093, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9341:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1095, - "indexExpression": { - "argumentTypes": null, - "id": 1094, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9352:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": false, - "nodeType": "IndexAccess", - "src": "9341:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "BinaryOperation", - "operator": "==", - "rightExpression": { - "argumentTypes": null, - "arguments": [], - "expression": { - "argumentTypes": [], - "id": 1096, - "name": "getNextThreshold", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 478, - "src": "9361:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_internal_view$__$returns$_t_uint256_$", - "typeString": "function () view returns (uint256)" - } - }, - "id": 1097, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9361:18:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "src": "9341:38:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "falseBody": { - "id": 1117, - "nodeType": "Block", - "src": "9464:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1113, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "nodeType": "UnaryOperation", - "operator": "++", - "prefix": false, - "src": "9478:18:0", - "subExpression": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1110, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9478:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1112, - "indexExpression": { - "argumentTypes": null, - "id": 1111, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9489:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9478:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1114, - "nodeType": "ExpressionStatement", - "src": "9478:18:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "66616c7365", - "id": 1115, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9517:5:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "false" - }, - "functionReturnParameters": 1072, - "id": 1116, - "nodeType": "Return", - "src": "9510:12:0" - } - ] - }, - "id": 1118, - "nodeType": "IfStatement", - "src": "9337:196:0", - "trueBody": { - "id": 1109, - "nodeType": "Block", - "src": "9381:77:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "id": 1105, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "leftHandSide": { - "argumentTypes": null, - "baseExpression": { - "argumentTypes": null, - "id": 1099, - "name": "votesCount", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 71, - "src": "9395:10:0", - "typeDescriptions": { - "typeIdentifier": "t_mapping$_t_bytes32_$_t_uint256_$", - "typeString": "mapping(bytes32 => uint256)" - } - }, - "id": 1101, - "indexExpression": { - "argumentTypes": null, - "id": 1100, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1068, - "src": "9406:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "isConstant": false, - "isLValue": true, - "isPure": false, - "lValueRequested": true, - "nodeType": "IndexAccess", - "src": "9395:16:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "nodeType": "Assignment", - "operator": "=", - "rightHandSide": { - "argumentTypes": null, - "commonType": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - }, - "id": 1104, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "leftExpression": { - "argumentTypes": null, - "hexValue": "32", - "id": 1102, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9414:1:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_2_by_1", - "typeString": "int_const 2" - }, - "value": "2" - }, - "nodeType": "BinaryOperation", - "operator": "**", - "rightExpression": { - "argumentTypes": null, - "hexValue": "323535", - "id": 1103, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "number", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9419:3:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_rational_255_by_1", - "typeString": "int_const 255" - }, - "value": "255" - }, - "src": "9414:8:0", - "typeDescriptions": { - "typeIdentifier": "t_rational_57896044618658097711785492504343953926634992332820282019728792003956564819968_by_1", - "typeString": "int_const 5789...(69 digits omitted)...9968" - } - }, - "src": "9395:27:0", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "id": 1106, - "nodeType": "ExpressionStatement", - "src": "9395:27:0" - }, - { - "expression": { - "argumentTypes": null, - "hexValue": "74727565", - "id": 1107, - "isConstant": false, - "isLValue": false, - "isPure": true, - "kind": "bool", - "lValueRequested": false, - "nodeType": "Literal", - "src": "9443:4:0", - "subdenomination": null, - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "value": "true" - }, - "functionReturnParameters": 1072, - "id": 1108, - "nodeType": "Return", - "src": "9436:11:0" - } - ] - } - } - ] - }, - "documentation": null, - "id": 1120, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "putConfirm", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 1069, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1068, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1120, - "src": "9139:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1067, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9139:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9138:14:0" - }, - "returnParameters": { - "id": 1072, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1071, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1120, - "src": "9170:4:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 1070, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "9170:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9169:6:0" - }, - "scope": 1138, - "src": "9119:420:0", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "private" - }, - { - "body": { - "id": 1136, - "nodeType": "Block", - "src": "9615:69:0", - "statements": [ - { - "expression": { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "arguments": [ - { - "argumentTypes": null, - "id": 1130, - "name": "vote", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 1122, - "src": "9659:4:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - { - "argumentTypes": null, - "expression": { - "argumentTypes": null, - "id": 1131, - "name": "msg", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12829, - "src": "9665:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_message", - "typeString": "msg" - } - }, - "id": 1132, - "isConstant": false, - "isLValue": false, - "isPure": false, - "lValueRequested": false, - "memberName": "sender", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "9665:10:0", - "typeDescriptions": { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - { - "typeIdentifier": "t_address_payable", - "typeString": "address payable" - } - ], - "expression": { - "argumentTypes": null, - "id": 1128, - "name": "abi", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12816, - "src": "9642:3:0", - "typeDescriptions": { - "typeIdentifier": "t_magic_abi", - "typeString": "abi" - } - }, - "id": 1129, - "isConstant": false, - "isLValue": false, - "isPure": true, - "lValueRequested": false, - "memberName": "encodePacked", - "nodeType": "MemberAccess", - "referencedDeclaration": null, - "src": "9642:16:0", - "typeDescriptions": { - "typeIdentifier": "t_function_abiencodepacked_pure$__$returns$_t_bytes_memory_ptr_$", - "typeString": "function () pure returns (bytes memory)" - } - }, - "id": 1133, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9642:34:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - } - ], - "expression": { - "argumentTypes": [ - { - "typeIdentifier": "t_bytes_memory_ptr", - "typeString": "bytes memory" - } - ], - "id": 1127, - "name": "keccak256", - "nodeType": "Identifier", - "overloadedDeclarations": [], - "referencedDeclaration": 12823, - "src": "9632:9:0", - "typeDescriptions": { - "typeIdentifier": "t_function_keccak256_pure$_t_bytes_memory_ptr_$returns$_t_bytes32_$", - "typeString": "function (bytes memory) pure returns (bytes32)" - } - }, - "id": 1134, - "isConstant": false, - "isLValue": false, - "isPure": false, - "kind": "functionCall", - "lValueRequested": false, - "names": [], - "nodeType": "FunctionCall", - "src": "9632:45:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "functionReturnParameters": 1126, - "id": 1135, - "nodeType": "Return", - "src": "9625:52:0" - } - ] - }, - "documentation": null, - "id": 1137, - "implemented": true, - "kind": "function", - "modifiers": [], - "name": "personalizeVote", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 1123, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1122, - "name": "vote", - "nodeType": "VariableDeclaration", - "scope": 1137, - "src": "9570:12:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1121, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9570:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9569:14:0" - }, - "returnParameters": { - "id": 1126, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 1125, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 1137, - "src": "9606:7:0", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - }, - "typeName": { - "id": 1124, - "name": "bytes32", - "nodeType": "ElementaryTypeName", - "src": "9606:7:0", - "typeDescriptions": { - "typeIdentifier": "t_bytes32", - "typeString": "bytes32" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "9605:9:0" - }, - "scope": 1138, - "src": "9545:139:0", - "stateMutability": "view", - "superFunction": null, - "visibility": "private" - } - ], - "scope": 1139, - "src": "93:9593:0" - } - ], - "src": "0:9687:0" - }, - "compiler": { - "name": "solc", - "version": "0.5.9+commit.e560f70d.Emscripten.clang" - }, - "networks": { - "44": { - "events": { - "0x3ef85928df9ae51bdb3eb4c00ec73b92b82307f319ac1b029de14796a0972609": { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "oldEpoch", - "type": "uint256" - }, - { - "indexed": true, - "name": "newEpoch", - "type": "uint256" - } - ], - "name": "NewEpoch", - "type": "event", - "signature": "0x3ef85928df9ae51bdb3eb4c00ec73b92b82307f319ac1b029de14796a0972609" - }, - "0xddbb65cfe1ae4aec03cef0f9667c6d7ba3740927d0c60f4dd4d7104cc31d180a": { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "epoch", - "type": "uint256" - } - ], - "name": "NewEpochCancelled", - "type": "event", - "signature": "0xddbb65cfe1ae4aec03cef0f9667c6d7ba3740927d0c60f4dd4d7104cc31d180a" - }, - "0xf4735b85cc98f9a712832825ecab4cfb1649d658f9a73c57a00ea7dde735c79b": { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "oldEpoch", - "type": "uint256" - }, - { - "indexed": true, - "name": "newEpoch", - "type": "uint256" - } - ], - "name": "NewFundsTransfer", - "type": "event", - "signature": "0xf4735b85cc98f9a712832825ecab4cfb1649d658f9a73c57a00ea7dde735c79b" - }, - "0xc33272939f066c227e913a4b3434d860794f185c551685c29451a3a38b9b259c": { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "epoch", - "type": "uint256" - }, - { - "indexed": false, - "name": "x", - "type": "uint256" - }, - { - "indexed": false, - "name": "y", - "type": "uint256" - } - ], - "name": "EpochStart", - "type": "event", - "signature": "0xc33272939f066c227e913a4b3434d860794f185c551685c29451a3a38b9b259c" - }, - "0x62e1f484b3909b2c013673bad76a9f14b010600ba983f11ad26e83082883570e": { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "ExchangeRequest", - "type": "event", - "signature": "0x62e1f484b3909b2c013673bad76a9f14b010600ba983f11ad26e83082883570e" - } - }, - "links": {}, - "address": "0x44c158FE850821ae69DaF37AADF5c539e9d0025B", - "transactionHash": "0x6235a54e4ed6f582e79b17c216471dba7a35d27b2ee4f2c3e4ce2326b5d5c8c5" - } - }, - "schemaVersion": "3.0.16", - "updatedAt": "2019-10-09T13:30:27.734Z", - "devdoc": { - "methods": {} - }, - "userdoc": { - "methods": {} - } -} \ No newline at end of file diff --git a/src/test-services/ethereumSend/Dockerfile b/src/test-services/ethereumSend/Dockerfile index 80808a1..15d2e34 100644 --- a/src/test-services/ethereumSend/Dockerfile +++ b/src/test-services/ethereumSend/Dockerfile @@ -6,6 +6,6 @@ COPY package.json /test/ RUN npm install -COPY testEthereumSend.js IERC20.json Bridge.json /test/ +COPY testEthereumSend.js /test/ ENTRYPOINT ["node", "testEthereumSend.js"] diff --git a/src/test-services/ethereumSend/IERC20.json b/src/test-services/ethereumSend/IERC20.json deleted file mode 100644 index 066d309..0000000 --- a/src/test-services/ethereumSend/IERC20.json +++ /dev/null @@ -1,1884 +0,0 @@ -{ - "contractName": "IERC20", - "abi": [ - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "from", - "type": "address" - }, - { - "indexed": true, - "name": "to", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Transfer", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "name": "owner", - "type": "address" - }, - { - "indexed": true, - "name": "spender", - "type": "address" - }, - { - "indexed": false, - "name": "value", - "type": "uint256" - } - ], - "name": "Approval", - "type": "event" - }, - { - "constant": true, - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "account", - "type": "address" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "recipient", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": true, - "inputs": [ - { - "name": "owner", - "type": "address" - }, - { - "name": "spender", - "type": "address" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "", - "type": "uint256" - } - ], - "payable": false, - "stateMutability": "view", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "spender", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, - { - "constant": false, - "inputs": [ - { - "name": "sender", - "type": "address" - }, - { - "name": "recipient", - "type": "address" - }, - { - "name": "amount", - "type": "uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - } - ], - "metadata": "{\"compiler\":{\"version\":\"0.5.9+commit.e560f70d\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"constant\":false,\"inputs\":[{\"name\":\"spender\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"sender\",\"type\":\"address\"},{\"name\":\"recipient\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"recipient\",\"type\":\"address\"},{\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"owner\",\"type\":\"address\"},{\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"}],\"devdoc\":{\"details\":\"Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see `ERC20Detailed`.\",\"methods\":{\"allowance(address,address)\":{\"details\":\"Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through `transferFrom`. This is zero by default. * This value changes when `approve` or `transferFrom` are called.\"},\"approve(address,uint256)\":{\"details\":\"Sets `amount` as the allowance of `spender` over the caller's tokens. * Returns a boolean value indicating whether the operation succeeded. * > Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * Emits an `Approval` event.\"},\"balanceOf(address)\":{\"details\":\"Returns the amount of tokens owned by `account`.\"},\"totalSupply()\":{\"details\":\"Returns the amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"details\":\"Moves `amount` tokens from the caller's account to `recipient`. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event.\"}}},\"userdoc\":{\"methods\":{}}},\"settings\":{\"compilationTarget\":{\"/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":\"IERC20\"},\"evmVersion\":\"petersburg\",\"libraries\":{},\"optimizer\":{\"enabled\":true,\"runs\":3},\"remappings\":[]},\"sources\":{\"/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol\":{\"keccak256\":\"0x90e8c2521653bbb1768b05889c5760031e688d9cd361f167489b89215e201b95\",\"urls\":[\"bzzr://aa8b45b57edafc3d67bc5d916327ea16807fae33f753ca163ae0c4061b789766\",\"dweb:/ipfs/QmP5NaEwZthQeM2ESz4WTT3osrP7jhbvu7ocbttBi2JAw6\"]}},\"version\":1}", - "bytecode": "0x", - "deployedBytecode": "0x", - "sourceMap": "", - "deployedSourceMap": "", - "source": "pragma solidity ^0.5.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP. Does not include\n * the optional functions; to access them see `ERC20Detailed`.\n */\ninterface IERC20 {\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `recipient`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a `Transfer` event.\n */\n function transfer(address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through `transferFrom`. This is\n * zero by default.\n *\n * This value changes when `approve` or `transferFrom` are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * > Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an `Approval` event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `sender` to `recipient` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a `Transfer` event.\n */\n function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);\n\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to `approve`. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n", - "sourcePath": "/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "ast": { - "absolutePath": "/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "exportedSymbols": { - "IERC20": [ - 9841 - ] - }, - "id": 9842, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 9774, - "literals": [ - "solidity", - "^", - "0.5", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "0:23:114" - }, - { - "baseContracts": [], - "contractDependencies": [], - "contractKind": "interface", - "documentation": "@dev Interface of the ERC20 standard as defined in the EIP. Does not include\nthe optional functions; to access them see `ERC20Detailed`.", - "fullyImplemented": false, - "id": 9841, - "linearizedBaseContracts": [ - 9841 - ], - "name": "IERC20", - "nodeType": "ContractDefinition", - "nodes": [ - { - "body": null, - "documentation": "@dev Returns the amount of tokens in existence.", - "id": 9779, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "totalSupply", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9775, - "nodeType": "ParameterList", - "parameters": [], - "src": "290:2:114" - }, - "returnParameters": { - "id": 9778, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9777, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9779, - "src": "316:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9776, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "316:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "315:9:114" - }, - "scope": 9841, - "src": "270:55:114", - "stateMutability": "view", - "superFunction": 12575, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the amount of tokens owned by `account`.", - "id": 9786, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "balanceOf", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9782, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9781, - "name": "account", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "427:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9780, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "427:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "426:17:114" - }, - "returnParameters": { - "id": 9785, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9784, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "467:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9783, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "467:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "466:9:114" - }, - "scope": 9841, - "src": "408:68:114", - "stateMutability": "view", - "superFunction": 12582, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from the caller's account to `recipient`.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9795, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9791, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9788, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "714:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9787, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "714:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9790, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "733:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9789, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "733:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "713:35:114" - }, - "returnParameters": { - "id": 9794, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9793, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "767:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9792, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "767:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "766:6:114" - }, - "scope": 9841, - "src": "696:77:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the remaining number of tokens that `spender` will be\nallowed to spend on behalf of `owner` through `transferFrom`. This is\nzero by default.\n * This value changes when `approve` or `transferFrom` are called.", - "id": 9804, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "allowance", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9800, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9797, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1067:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9796, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1067:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9799, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1082:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9798, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1082:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1066:32:114" - }, - "returnParameters": { - "id": 9803, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9802, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1122:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9801, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1122:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1121:9:114" - }, - "scope": 9841, - "src": "1048:83:114", - "stateMutability": "view", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n * Returns a boolean value indicating whether the operation succeeded.\n * > Beware that changing an allowance with this method brings the risk\nthat someone may use both the old and the new allowance by unfortunate\ntransaction ordering. One possible solution to mitigate this race\ncondition is to first reduce the spender's allowance to 0 and set the\ndesired value afterwards:\nhttps://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * Emits an `Approval` event.", - "id": 9813, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "approve", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9809, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9806, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1792:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9805, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1792:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9808, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1809:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9807, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1809:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1791:33:114" - }, - "returnParameters": { - "id": 9812, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9811, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1843:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9810, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1843:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1842:6:114" - }, - "scope": 9841, - "src": "1775:74:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from `sender` to `recipient` using the\nallowance mechanism. `amount` is then deducted from the caller's\nallowance.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9824, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transferFrom", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9820, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9815, - "name": "sender", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2178:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9814, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2178:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9817, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2194:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9816, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2194:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9819, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2213:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9818, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2213:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2177:51:114" - }, - "returnParameters": { - "id": 9823, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9822, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2247:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9821, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "2247:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2246:6:114" - }, - "scope": 9841, - "src": "2156:97:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when `value` tokens are moved from one account (`from`) to\nanother (`to`).\n * Note that `value` may be zero.", - "id": 9832, - "name": "Transfer", - "nodeType": "EventDefinition", - "parameters": { - "id": 9831, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9826, - "indexed": true, - "name": "from", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2437:20:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9825, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2437:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9828, - "indexed": true, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2459:18:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9827, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2459:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9830, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2479:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9829, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2479:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2436:57:114" - }, - "src": "2422:72:114" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when the allowance of a `spender` for an `owner` is set by\na call to `approve`. `value` is the new allowance.", - "id": 9840, - "name": "Approval", - "nodeType": "EventDefinition", - "parameters": { - "id": 9839, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9834, - "indexed": true, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2668:21:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9833, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2668:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9836, - "indexed": true, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2691:23:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9835, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2691:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9838, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2716:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9837, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2716:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2667:63:114" - }, - "src": "2653:78:114" - } - ], - "scope": 9842, - "src": "176:2557:114" - } - ], - "src": "0:2734:114" - }, - "legacyAST": { - "absolutePath": "/build/contracts/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol", - "exportedSymbols": { - "IERC20": [ - 9841 - ] - }, - "id": 9842, - "nodeType": "SourceUnit", - "nodes": [ - { - "id": 9774, - "literals": [ - "solidity", - "^", - "0.5", - ".0" - ], - "nodeType": "PragmaDirective", - "src": "0:23:114" - }, - { - "baseContracts": [], - "contractDependencies": [], - "contractKind": "interface", - "documentation": "@dev Interface of the ERC20 standard as defined in the EIP. Does not include\nthe optional functions; to access them see `ERC20Detailed`.", - "fullyImplemented": false, - "id": 9841, - "linearizedBaseContracts": [ - 9841 - ], - "name": "IERC20", - "nodeType": "ContractDefinition", - "nodes": [ - { - "body": null, - "documentation": "@dev Returns the amount of tokens in existence.", - "id": 9779, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "totalSupply", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9775, - "nodeType": "ParameterList", - "parameters": [], - "src": "290:2:114" - }, - "returnParameters": { - "id": 9778, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9777, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9779, - "src": "316:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9776, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "316:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "315:9:114" - }, - "scope": 9841, - "src": "270:55:114", - "stateMutability": "view", - "superFunction": 12575, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the amount of tokens owned by `account`.", - "id": 9786, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "balanceOf", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9782, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9781, - "name": "account", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "427:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9780, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "427:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "426:17:114" - }, - "returnParameters": { - "id": 9785, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9784, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9786, - "src": "467:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9783, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "467:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "466:9:114" - }, - "scope": 9841, - "src": "408:68:114", - "stateMutability": "view", - "superFunction": 12582, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from the caller's account to `recipient`.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9795, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transfer", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9791, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9788, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "714:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9787, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "714:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9790, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "733:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9789, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "733:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "713:35:114" - }, - "returnParameters": { - "id": 9794, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9793, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9795, - "src": "767:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9792, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "767:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "766:6:114" - }, - "scope": 9841, - "src": "696:77:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Returns the remaining number of tokens that `spender` will be\nallowed to spend on behalf of `owner` through `transferFrom`. This is\nzero by default.\n * This value changes when `approve` or `transferFrom` are called.", - "id": 9804, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "allowance", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9800, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9797, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1067:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9796, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1067:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9799, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1082:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9798, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1082:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1066:32:114" - }, - "returnParameters": { - "id": 9803, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9802, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9804, - "src": "1122:7:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9801, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1122:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1121:9:114" - }, - "scope": 9841, - "src": "1048:83:114", - "stateMutability": "view", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n * Returns a boolean value indicating whether the operation succeeded.\n * > Beware that changing an allowance with this method brings the risk\nthat someone may use both the old and the new allowance by unfortunate\ntransaction ordering. One possible solution to mitigate this race\ncondition is to first reduce the spender's allowance to 0 and set the\ndesired value afterwards:\nhttps://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n * Emits an `Approval` event.", - "id": 9813, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "approve", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9809, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9806, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1792:15:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9805, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "1792:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9808, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1809:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9807, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "1809:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1791:33:114" - }, - "returnParameters": { - "id": 9812, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9811, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9813, - "src": "1843:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9810, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "1843:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "1842:6:114" - }, - "scope": 9841, - "src": "1775:74:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "body": null, - "documentation": "@dev Moves `amount` tokens from `sender` to `recipient` using the\nallowance mechanism. `amount` is then deducted from the caller's\nallowance.\n * Returns a boolean value indicating whether the operation succeeded.\n * Emits a `Transfer` event.", - "id": 9824, - "implemented": false, - "kind": "function", - "modifiers": [], - "name": "transferFrom", - "nodeType": "FunctionDefinition", - "parameters": { - "id": 9820, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9815, - "name": "sender", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2178:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9814, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2178:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9817, - "name": "recipient", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2194:17:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9816, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2194:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9819, - "name": "amount", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2213:14:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9818, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2213:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2177:51:114" - }, - "returnParameters": { - "id": 9823, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9822, - "name": "", - "nodeType": "VariableDeclaration", - "scope": 9824, - "src": "2247:4:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - }, - "typeName": { - "id": 9821, - "name": "bool", - "nodeType": "ElementaryTypeName", - "src": "2247:4:114", - "typeDescriptions": { - "typeIdentifier": "t_bool", - "typeString": "bool" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2246:6:114" - }, - "scope": 9841, - "src": "2156:97:114", - "stateMutability": "nonpayable", - "superFunction": null, - "visibility": "external" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when `value` tokens are moved from one account (`from`) to\nanother (`to`).\n * Note that `value` may be zero.", - "id": 9832, - "name": "Transfer", - "nodeType": "EventDefinition", - "parameters": { - "id": 9831, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9826, - "indexed": true, - "name": "from", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2437:20:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9825, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2437:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9828, - "indexed": true, - "name": "to", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2459:18:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9827, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2459:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9830, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9832, - "src": "2479:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9829, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2479:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2436:57:114" - }, - "src": "2422:72:114" - }, - { - "anonymous": false, - "documentation": "@dev Emitted when the allowance of a `spender` for an `owner` is set by\na call to `approve`. `value` is the new allowance.", - "id": 9840, - "name": "Approval", - "nodeType": "EventDefinition", - "parameters": { - "id": 9839, - "nodeType": "ParameterList", - "parameters": [ - { - "constant": false, - "id": 9834, - "indexed": true, - "name": "owner", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2668:21:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9833, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2668:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9836, - "indexed": true, - "name": "spender", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2691:23:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - }, - "typeName": { - "id": 9835, - "name": "address", - "nodeType": "ElementaryTypeName", - "src": "2691:7:114", - "stateMutability": "nonpayable", - "typeDescriptions": { - "typeIdentifier": "t_address", - "typeString": "address" - } - }, - "value": null, - "visibility": "internal" - }, - { - "constant": false, - "id": 9838, - "indexed": false, - "name": "value", - "nodeType": "VariableDeclaration", - "scope": 9840, - "src": "2716:13:114", - "stateVariable": false, - "storageLocation": "default", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - }, - "typeName": { - "id": 9837, - "name": "uint256", - "nodeType": "ElementaryTypeName", - "src": "2716:7:114", - "typeDescriptions": { - "typeIdentifier": "t_uint256", - "typeString": "uint256" - } - }, - "value": null, - "visibility": "internal" - } - ], - "src": "2667:63:114" - }, - "src": "2653:78:114" - } - ], - "scope": 9842, - "src": "176:2557:114" - } - ], - "src": "0:2734:114" - }, - "compiler": { - "name": "solc", - "version": "0.5.9+commit.e560f70d.Emscripten.clang" - }, - "networks": {}, - "schemaVersion": "3.0.11", - "updatedAt": "2019-07-17T07:17:15.653Z", - "devdoc": { - "details": "Interface of the ERC20 standard as defined in the EIP. Does not include the optional functions; to access them see `ERC20Detailed`.", - "methods": { - "allowance(address,address)": { - "details": "Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through `transferFrom`. This is zero by default. * This value changes when `approve` or `transferFrom` are called." - }, - "approve(address,uint256)": { - "details": "Sets `amount` as the allowance of `spender` over the caller's tokens. * Returns a boolean value indicating whether the operation succeeded. * > Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * Emits an `Approval` event." - }, - "balanceOf(address)": { - "details": "Returns the amount of tokens owned by `account`." - }, - "totalSupply()": { - "details": "Returns the amount of tokens in existence." - }, - "transfer(address,uint256)": { - "details": "Moves `amount` tokens from the caller's account to `recipient`. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event." - }, - "transferFrom(address,address,uint256)": { - "details": "Moves `amount` tokens from `sender` to `recipient` using the allowance mechanism. `amount` is then deducted from the caller's allowance. * Returns a boolean value indicating whether the operation succeeded. * Emits a `Transfer` event." - } - } - }, - "userdoc": { - "methods": {} - } -} \ No newline at end of file diff --git a/src/test-services/ethereumSend/package.json b/src/test-services/ethereumSend/package.json index db04192..55e8eb7 100644 --- a/src/test-services/ethereumSend/package.json +++ b/src/test-services/ethereumSend/package.json @@ -2,7 +2,9 @@ "name": "ethereum-send", "version": "0.0.1", "dependencies": { - "bignumber.js": "9.0.0", - "web3": "1.0.0-beta.55" + "ethers": "4.0.39" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/test-services/ethereumSend/run.sh b/src/test-services/ethereumSend/run.sh index 30d683e..8980f27 100755 --- a/src/test-services/ethereumSend/run.sh +++ b/src/test-services/ethereumSend/run.sh @@ -9,4 +9,8 @@ TARGET_NETWORK=${TARGET_NETWORK:=development} docker build -t ethereum-send . > /dev/null -docker run --network blockchain_home --rm --env-file ".env.$TARGET_NETWORK" --env-file "../.keys.$TARGET_NETWORK" -e "PRIVATE_KEY=$PRIVATE_KEY" ethereum-send $@ +if [[ "$TARGET_NETWORK" == "development" ]]; then + docker run --network ethereum_home_rpc_net --rm --env-file ".env.$TARGET_NETWORK" -e "PRIVATE_KEY=$PRIVATE_KEY" ethereum-send $@ +else + docker run --rm --env-file ".env.$TARGET_NETWORK" --env-file "../.keys.$TARGET_NETWORK" -e "PRIVATE_KEY=$PRIVATE_KEY" ethereum-send $@ +fi diff --git a/src/test-services/ethereumSend/testEthereumSend.js b/src/test-services/ethereumSend/testEthereumSend.js index 345658e..7d3397d 100644 --- a/src/test-services/ethereumSend/testEthereumSend.js +++ b/src/test-services/ethereumSend/testEthereumSend.js @@ -1,102 +1,61 @@ -const Web3 = require('web3') -const BN = require('bignumber.js') +const ethers = require('ethers') -const { HOME_RPC_URL, HOME_BRIDGE_ADDRESS, HOME_PRIVATE_KEY, HOME_TOKEN_ADDRESS } = process.env +const { + HOME_RPC_URL, HOME_BRIDGE_ADDRESS, HOME_PRIVATE_KEY, HOME_TOKEN_ADDRESS +} = process.env -const abiToken = require('./IERC20').abi -const abiBridge = require('./Bridge').abi +const tokenAbi = [ + 'function transfer(address to, uint256 value)', + 'function approve(address to, uint256 value)' +] +const bridgeAbi = [ + 'function exchange(uint96 value)' +] const PRIVATE_KEY = process.env.PRIVATE_KEY || HOME_PRIVATE_KEY -const web3 = new Web3(HOME_RPC_URL, null, { transactionConfirmationBlocks: 1 }) -const token = new web3.eth.Contract(abiToken, HOME_TOKEN_ADDRESS) -const bridge = new web3.eth.Contract(abiBridge, HOME_BRIDGE_ADDRESS) +const provider = new ethers.providers.JsonRpcProvider(HOME_RPC_URL) +const wallet = new ethers.Wallet(PRIVATE_KEY, provider) +const token = new ethers.Contract(HOME_TOKEN_ADDRESS, tokenAbi, wallet) +const bridge = new ethers.Contract(HOME_BRIDGE_ADDRESS, bridgeAbi, wallet) -const sender = web3.eth.accounts.privateKeyToAccount(`0x${PRIVATE_KEY}`).address - -async function main () { - const HOME_CHAIN_ID = await web3.eth.net.getId() - const blockGasLimit = (await web3.eth.getBlock("latest", false)).gasLimit +const sender = wallet.address +async function main() { const to = process.argv[2] - const amount = parseInt(process.argv[3]) - let coins = process.argv[4] - - const txCount = await web3.eth.getTransactionCount(sender) + const amount = process.argv[3] + const native = process.argv[4] - if (to === "bridge" && amount !== 0) { + if (to === 'bridge' && amount !== '0') { console.log(`Transfer from ${sender} to ${HOME_BRIDGE_ADDRESS}, ${amount} tokens`) - const queryApprove = token.methods.approve(HOME_BRIDGE_ADDRESS, '0x'+(new BN(amount).multipliedBy(10 ** 18).toString(16))) - const txApprove = { - data: queryApprove.encodeABI(), - from: sender, - to: HOME_TOKEN_ADDRESS, - nonce: txCount, - chainId: HOME_CHAIN_ID - } - txApprove.gas = Math.min(Math.ceil(await queryApprove.estimateGas({ - from: sender - }) * 1.5), blockGasLimit) - const signedTxApprove = await web3.eth.accounts.signTransaction(txApprove, PRIVATE_KEY) - - const receiptApprove = await web3.eth.sendSignedTransaction(signedTxApprove.rawTransaction) - console.log('txHash approve: ' + receiptApprove.transactionHash) + const txApprove = await token.approve(HOME_BRIDGE_ADDRESS, ethers.utils.parseEther(amount)) + const receiptApprove = await txApprove.wait() + console.log(`txHash approve: ${receiptApprove.transactionHash}`) - const queryExchange = bridge.methods.exchange('0x'+(new BN(amount).multipliedBy(10 ** 18).toString(16))) - const txExchange = { - data: queryExchange.encodeABI(), - from: sender, - to: HOME_BRIDGE_ADDRESS, - nonce: txCount + 1, - chainId: HOME_CHAIN_ID - } - txExchange.gas = Math.min(Math.ceil(await queryExchange.estimateGas({ - from: sender - }) * 1.5), blockGasLimit) - const signedTxExchange = await web3.eth.accounts.signTransaction(txExchange, PRIVATE_KEY) - - const receiptExchange = await web3.eth.sendSignedTransaction(signedTxExchange.rawTransaction) - console.log('txHash exchange: ' + receiptExchange.transactionHash) - } else if (amount !== 0) { + const txExchange = await bridge.exchange(ethers.utils.parseEther(amount)) + const receiptExchange = await txExchange.wait() + console.log(`txHash exchange: ${receiptExchange.transactionHash}`) + } else if (amount !== '0') { console.log(`Transfer from ${sender} to ${to}, ${amount} tokens`) - const query = token.methods.transfer(to, '0x'+(new BN(amount).multipliedBy(10 ** 18).toString(16))) - const tx = { - data: query.encodeABI(), - from: sender, - to: HOME_TOKEN_ADDRESS, - nonce: txCount, - chainId: HOME_CHAIN_ID - } - tx.gas = Math.min(Math.ceil(await query.estimateGas({ - from: sender - }) * 1.5), blockGasLimit) - const signedTx = await web3.eth.accounts.signTransaction(tx, PRIVATE_KEY) - const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction) - console.log('txHash transfer: ' + receipt.transactionHash) + const tx = await token.transfer(to, ethers.utils.parseEther(amount)) + const receipt = await tx.wait() + console.log(`txHash transfer: ${receipt.transactionHash}`) } - if (coins) { - coins = parseFloat(coins) - console.log(`Transfer from ${sender} to ${to}, ${coins} coins`) + if (native) { + console.log(`Transfer from ${sender} to ${to}, ${native} coins`) - const tx = { - data: '0x', - from: sender, - to: to, - nonce: await web3.eth.getTransactionCount(sender), - chainId: HOME_CHAIN_ID, - value: web3.utils.toWei(new BN(coins).toString(), 'ether'), - gas: 21000 - } - const signedTx = await web3.eth.accounts.signTransaction(tx, PRIVATE_KEY) + const tx = await wallet.sendTransaction({ + to, + value: ethers.utils.parseEther(native) + }) - const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction) - console.log('txHash: ' + receipt.transactionHash) + const receipt = await tx.wait() + console.log(`txHash: ${receipt.transactionHash}`) } - } main() diff --git a/src/test-services/getAddresses/.dockerignore b/src/test-services/getAddresses/.dockerignore new file mode 100644 index 0000000..4635bd2 --- /dev/null +++ b/src/test-services/getAddresses/.dockerignore @@ -0,0 +1,3 @@ +.dockerignore +Dockerfile +run.sh diff --git a/src/test-services/getAddresses/package.json b/src/test-services/getAddresses/package.json index de27143..edcb0cf 100644 --- a/src/test-services/getAddresses/package.json +++ b/src/test-services/getAddresses/package.json @@ -4,5 +4,8 @@ "dependencies": { "ethers": "4.0.37", "bech32": "1.1.3" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/test-services/getAddresses/testGetAddresses.js b/src/test-services/getAddresses/testGetAddresses.js index e51c3c6..0c7c01a 100644 --- a/src/test-services/getAddresses/testGetAddresses.js +++ b/src/test-services/getAddresses/testGetAddresses.js @@ -2,24 +2,28 @@ const { utils } = require('ethers') const bech32 = require('bech32') const crypto = require('crypto') -const privateKey = process.argv[2].startsWith('0x') ? process.argv[2] : '0x' + process.argv[2] - -const ethAddress = utils.computeAddress(privateKey) -const publicKey = utils.computePublicKey(privateKey, true) +function sha256(bytes) { + return crypto.createHash('sha256').update(bytes).digest('hex') +} -console.log(`Eth address: ${ethAddress}\nBnc address: ${publicKeyToAddress(publicKey)}`) +function ripemd160(bytes) { + return crypto.createHash('ripemd160').update(bytes).digest('hex') +} -function publicKeyToAddress (publicKey) { +function publicKeyToAddress(publicKey) { const sha256Hash = sha256(Buffer.from(publicKey.substr(2), 'hex')) const hash = ripemd160(Buffer.from(sha256Hash, 'hex')) const words = bech32.toWords(Buffer.from(hash, 'hex')) return bech32.encode('tbnb', words) } -function sha256 (bytes) { - return crypto.createHash('sha256').update(bytes).digest('hex') -} +function main() { + const privateKey = process.argv[2].startsWith('0x') ? process.argv[2] : `0x${process.argv[2]}` -function ripemd160 (bytes) { - return crypto.createHash('ripemd160').update(bytes).digest('hex') + const ethAddress = utils.computeAddress(privateKey) + const publicKey = utils.computePublicKey(privateKey, true) + + console.log(`Eth address: ${ethAddress}\nBnc address: ${publicKeyToAddress(publicKey)}`) } + +main() diff --git a/src/test-services/sidePrefund/.dockerignore b/src/test-services/sidePrefund/.dockerignore new file mode 100644 index 0000000..4119e2e --- /dev/null +++ b/src/test-services/sidePrefund/.dockerignore @@ -0,0 +1,4 @@ +.dockerignore +Dockerfile +run.sh +.env.* diff --git a/src/test-services/sidePrefund/Dockerfile b/src/test-services/sidePrefund/Dockerfile index 15d2e34..fd40822 100644 --- a/src/test-services/sidePrefund/Dockerfile +++ b/src/test-services/sidePrefund/Dockerfile @@ -6,6 +6,6 @@ COPY package.json /test/ RUN npm install -COPY testEthereumSend.js /test/ +COPY testSidePrefund.js /test/ -ENTRYPOINT ["node", "testEthereumSend.js"] +ENTRYPOINT ["node", "testSidePrefund.js"] diff --git a/src/test-services/sidePrefund/package.json b/src/test-services/sidePrefund/package.json index d115535..371f08f 100644 --- a/src/test-services/sidePrefund/package.json +++ b/src/test-services/sidePrefund/package.json @@ -2,7 +2,9 @@ "name": "side-prefund", "version": "0.0.1", "dependencies": { - "bignumber.js": "9.0.0", - "web3": "1.0.0-beta.55" + "ethers": "4.0.39" + }, + "engines": { + "node": ">=10.6.0" } } diff --git a/src/test-services/sidePrefund/run.sh b/src/test-services/sidePrefund/run.sh index 88df060..c63a220 100755 --- a/src/test-services/sidePrefund/run.sh +++ b/src/test-services/sidePrefund/run.sh @@ -11,4 +11,8 @@ echo "Using $TARGET_NETWORK network" docker build -t side-prefund . > /dev/null -docker run --network blockchain_side --rm --env-file ".env.$TARGET_NETWORK" --env-file "../.keys.$TARGET_NETWORK" side-prefund $@ +if [[ "$TARGET_NETWORK" == "development" ]]; then + docker run --network ethereum_side_rpc_net --rm --env-file ".env.$TARGET_NETWORK" side-prefund $@ +else + docker run --rm --env-file ".env.$TARGET_NETWORK" --env-file "../.keys.$TARGET_NETWORK" side-prefund $@ +fi diff --git a/src/test-services/sidePrefund/testEthereumSend.js b/src/test-services/sidePrefund/testEthereumSend.js deleted file mode 100644 index 731af3e..0000000 --- a/src/test-services/sidePrefund/testEthereumSend.js +++ /dev/null @@ -1,34 +0,0 @@ -const Web3 = require('web3') -const BN = require('bignumber.js') - -const { SIDE_RPC_URL, SIDE_PRIVATE_KEY } = process.env - -const web3 = new Web3(SIDE_RPC_URL, null, { transactionConfirmationBlocks: 1 }) - -const sender = web3.eth.accounts.privateKeyToAccount(`0x${SIDE_PRIVATE_KEY}`).address - -async function main () { - const SIDE_CHAIN_ID = await web3.eth.net.getId() - - const to = process.argv[2] - const amount = parseFloat(process.argv[3]) - - console.log(`Transfer from ${sender} to ${to}, ${amount} eth`) - - const tx_coins = { - data: '0x', - from: sender, - to: to, - nonce: await web3.eth.getTransactionCount(sender), - chainId: SIDE_CHAIN_ID, - value: web3.utils.toWei(new BN(amount).toString(), 'ether'), - gas: 21000 - } - const signedTx = await web3.eth.accounts.signTransaction(tx_coins, SIDE_PRIVATE_KEY) - - const receipt = await web3.eth.sendSignedTransaction(signedTx.rawTransaction) - console.log('txHash: ' + receipt.transactionHash) - -} - -main() diff --git a/src/test-services/sidePrefund/testSidePrefund.js b/src/test-services/sidePrefund/testSidePrefund.js new file mode 100644 index 0000000..0d5c50b --- /dev/null +++ b/src/test-services/sidePrefund/testSidePrefund.js @@ -0,0 +1,26 @@ +const ethers = require('ethers') + +const { SIDE_RPC_URL, SIDE_PRIVATE_KEY } = process.env + +const provider = new ethers.providers.JsonRpcProvider(SIDE_RPC_URL) +const wallet = new ethers.Wallet(SIDE_PRIVATE_KEY, provider) + +const sender = wallet.address + +async function main() { + const to = process.argv[2] + const amount = process.argv[3] + + console.log(`Transfer from ${sender} to ${to}, ${amount} eth`) + + const txCoins = { + to, + value: ethers.utils.parseEther(amount) + } + + const tx = await wallet.sendTransaction(txCoins) + const receipt = await tx.wait() + console.log(`txHash: ${receipt.transactionHash}`) +} + +main() diff --git a/src/tss/Dockerfile b/src/tss/Dockerfile index 5921579..9b509e8 100644 --- a/src/tss/Dockerfile +++ b/src/tss/Dockerfile @@ -3,24 +3,24 @@ FROM ubuntu:19.10 RUN apt-get update && \ apt-get install -y curl build-essential git openssl pkg-config libssl-dev libgmp3-dev -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y - +RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly-2019-08-28 -y ENV PATH=/root/.cargo/bin:$PATH +RUN cargo --version -WORKDIR /repo - -RUN git clone https://github.com/KZen-networks/multi-party-ecdsa.git . +WORKDIR /tss -RUN mkdir -p /tss/src && \ - cp /repo/Cargo.toml /tss/ && \ - cp /repo/src/lib.rs /tss/src/ +COPY ./multi-party-ecdsa/Cargo.lock ./multi-party-ecdsa/Cargo.toml /tss/ +COPY ./multi-party-ecdsa/src/lib.rs /tss/src/lib.rs -WORKDIR /tss +# Download all dependencies +RUN cargo fetch +# Build dependencies RUN cargo build --release || true -RUN cp -Tr /repo /tss +COPY ./multi-party-ecdsa /tss/ +# Build final executables RUN cargo build --release CMD echo Done diff --git a/src/tss/Dockerfile-local b/src/tss/Dockerfile-local deleted file mode 100644 index 909a9b8..0000000 --- a/src/tss/Dockerfile-local +++ /dev/null @@ -1,22 +0,0 @@ -FROM ubuntu:19.10 - -RUN apt-get update && \ - apt-get install -y curl build-essential git openssl pkg-config libssl-dev libgmp3-dev - -RUN curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly -y - -ENV PATH=/root/.cargo/bin:$PATH - -WORKDIR /tss - -COPY ./multi-party-ecdsa/Cargo.toml /tss/ -COPY ./multi-party-ecdsa/Cargo.lock /tss/ -COPY ./multi-party-ecdsa/src/lib.rs /tss/src/lib.rs - -RUN cargo build --locked --release || true - -COPY ./multi-party-ecdsa /tss/ - -RUN cargo build --locked --release - -CMD echo Done diff --git a/src/tss/multi-party-ecdsa b/src/tss/multi-party-ecdsa index 73a6db9..1eb620d 160000 --- a/src/tss/multi-party-ecdsa +++ b/src/tss/multi-party-ecdsa @@ -1 +1 @@ -Subproject commit 73a6db93f4805b27f5c0f2b2c139869e8cecf581 +Subproject commit 1eb620d9a37f9839d3c391a3765062846e07039f diff --git a/tests/.dockerignore b/tests/.dockerignore new file mode 100644 index 0000000..51e9d4a --- /dev/null +++ b/tests/.dockerignore @@ -0,0 +1,5 @@ +.dockerignore +Dockerfile +init.sh +run.sh +results.xml diff --git a/tests/.env b/tests/.env new file mode 100644 index 0000000..a7cb16f --- /dev/null +++ b/tests/.env @@ -0,0 +1,11 @@ +HOME_RPC_URL=http://ganache_home:8545 +HOME_BRIDGE_ADDRESS=0x44c158FE850821ae69DaF37AADF5c539e9d0025B +HOME_TOKEN_ADDRESS=0xd5fE0D28e058D375b0b038fFbB446Da37E85fFdc +HOME_PRIVATE_KEY=e2aeb24eaa63102d0c0821717c3b6384abdabd7af2ad4ec8e650dce300798b27 + +SIDE_RPC_URL=http://ganache_side:8545 + +FOREIGN_URL=http://http-api:8000 +FOREIGN_CHAIN_ID=Binance-Dev +FOREIGN_ASSET=DEV-9BA +FOREIGN_PRIVATE_KEY=dd5ec5a7abe9d1fff21170ae591085f000fc6fd9ca0107fe047593f44e328e40 diff --git a/tests/.eslintrc b/tests/.eslintrc new file mode 100644 index 0000000..8fb9bf8 --- /dev/null +++ b/tests/.eslintrc @@ -0,0 +1,12 @@ +{ + "extends": [ + "../.eslintrc" + ], + "env": { + "mocha": true + }, + "rules": { + "prefer-arrow-callback": 0, + "func-names": 0 + } +} diff --git a/tests/.mocharc.yml b/tests/.mocharc.yml new file mode 100644 index 0000000..c7ff00a --- /dev/null +++ b/tests/.mocharc.yml @@ -0,0 +1,6 @@ +exit: true +timeout: 60000 +bail: true +reporter: mocha-multi-reporters +reporter-option: + - configFile=./reportersConfig.json diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 0000000..118d266 --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,16 @@ +FROM node:10.16.0-alpine + +WORKDIR /tests + +RUN npm install -g mocha mocha-junit-reporter mocha-multi-reporters + +RUN apk update && apk add libssl1.1 eudev-dev libressl-dev curl build-base python linux-headers libusb-dev + +COPY ./package.json . + +RUN npm install + +COPY config.json .mocharc.yml reportersConfig.json ./ +COPY test ./test + +ENTRYPOINT ["mocha"] diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..ca6edab --- /dev/null +++ b/tests/README.md @@ -0,0 +1,34 @@ +# Ethereum to Binance Chain / E2E tests + +## Prerequisites + +To run the tests you need to have +[Docker](https://www.docker.com/community-edition) and +[Docker Compose](https://docs.docker.com/compose/install/) installed. + +## Correlation with CircleCI tests + +CircleCI uses this tests for testing the code base. + +## Running + +To run the bridge tests, you first need to clean old test environment, and then initialize a new one: +```bash +./tests/init.sh +``` +This will create a clean development environment, using `./demo/start-environment.sh`. +Then, this command will start 3 validators in daemon mode (using `./demo/validator-demo.sh`), +and wait until they are ready. + +Next, you can run the tests: +```bash +./tests/run.sh +``` + +After tests are done, all active docker containers should be killed automatically. +Or you can do it manually: +```bash +docker kill $(docker ps | grep validator[1-3]_ | awk '{print $1}') +docker kill $(docker ps | grep ethereum-testnet_ | awk '{print $1}') +docker kill $(docker ps | grep binance-testnet_ | awk '{print $1}') +``` diff --git a/tests/config.json b/tests/config.json new file mode 100644 index 0000000..8307d15 --- /dev/null +++ b/tests/config.json @@ -0,0 +1,24 @@ +{ + "users": [ + { + "privateKey": "7ed93ad7753e00b52265a73dfbbcd2296256772965323fcb9a6320b5cd084b89", + "ethAddress": "0x4db6b4bd0a3fdc03b027a60f1c48f05c572312aa", + "bncAddress": "tbnb14r3z8xk7qsar3vwj05w8cd8gqwk7g6gfurlt5l" + }, + { + "privateKey": "2ad6e3a232ad3ea058b61352302118a99085600ff8b6eec4ccf0066a33756231", + "ethAddress": "0xf7ca4aed1795e424433498cef43f6a3825c88731", + "bncAddress": "tbnb1efjg7xt98t67ql2cmwjc5860lgayet9l8m55ym" + }, + { + "privateKey": "eb6dd328677b3fa2822fb8e834507e569bda52e8ffa49266df0f2de239c4ec98", + "ethAddress": "0xad6c8127143032d843a260c5d379d8d9b3d51f15", + "bncAddress": "tbnb12epcy4p7ktas0nlyrfuektcyh0e83dwzuq73f4" + } + ], + "validators": [ + "0x99Eb3D86663c6Db090eFFdBC20510Ca9f836DCE3", + "0xAa006899B0EC407De930bA8A166DEfe59bBfd3DC", + "0x6352e3e6038e05b9da00C84AE851308f9774F883" + ] +} diff --git a/tests/init.sh b/tests/init.sh new file mode 100755 index 0000000..eea9c62 --- /dev/null +++ b/tests/init.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -e + +echo "Cleaning previous demo environment" +./demo/clean.sh + +echo "Building tss clients" +docker build -t tss ./src/tss + +echo "Starting ethereum test networks" +BLOCK_TIME=3 ./demo/start-ethereum-environment.sh +echo "Starting binance test network" +./demo/start-binance-environment.sh + +echo "Starting validator daemons" +N=1 ./demo/validator-demo.sh -d +N=2 ./demo/validator-demo.sh -d +N=3 ./demo/validator-demo.sh -d + +echo "Waiting until validators are ready" +until curl -X GET http://localhost:5001/info > /dev/null 2>&1; do sleep 1; done +until curl -X GET http://localhost:5002/info > /dev/null 2>&1; do sleep 1; done +until curl -X GET http://localhost:5003/info > /dev/null 2>&1; do sleep 1; done diff --git a/tests/package.json b/tests/package.json new file mode 100644 index 0000000..ffc0554 --- /dev/null +++ b/tests/package.json @@ -0,0 +1,13 @@ +{ + "name": "tests", + "version": "0.0.1", + "dependencies": { + "ethers": "4.0.38", + "axios": "0.19.0", + "@binance-chain/javascript-sdk": "2.16.1", + "bignumber.js": "9.0.0" + }, + "engines": { + "node": ">=10.6.0" + } +} diff --git a/tests/reportersConfig.json b/tests/reportersConfig.json new file mode 100644 index 0000000..47582db --- /dev/null +++ b/tests/reportersConfig.json @@ -0,0 +1,6 @@ +{ + "reporterEnabled": "spec, mocha-junit-reporter", + "mochaJunitReporterReporterOptions": { + "mochaFile": "./results.xml" + } +} diff --git a/tests/run.sh b/tests/run.sh new file mode 100755 index 0000000..23b28be --- /dev/null +++ b/tests/run.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +set -e + +echo "Building tests main image" +docker build -t tests ./tests + +echo "Creating tests container" +docker rm tests > /dev/null 2>&1 || true +docker create --name tests --env-file ./tests/.env tests $@ + +echo "Connecting tests container to test networks" +docker network connect binance_net tests +docker network connect ethereum_home_rpc_net tests +docker network connect ethereum_side_rpc_net tests +docker network connect validator1_test_network tests +docker network connect validator2_test_network tests +docker network connect validator3_test_network tests + +echo "Starting tests" +docker start -a tests || true + +echo "Saving test results" +docker cp "tests:/tests/results.xml" "./tests/results.xml" > /dev/null 2>&1 || true + +echo "Killing all remaining docker containers" +docker kill $(docker ps | grep validator[1-3]_ | awk '{print $1}') > /dev/null 2>&1 || true +docker kill $(docker ps | grep ethereum-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true +docker kill $(docker ps | grep binance-testnet_ | awk '{print $1}') > /dev/null 2>&1 || true diff --git a/tests/test/addValidator.js b/tests/test/addValidator.js new file mode 100644 index 0000000..f30bb53 --- /dev/null +++ b/tests/test/addValidator.js @@ -0,0 +1,167 @@ +const assert = require('assert') + +const { waitPromise, delay } = require('./utils/wait') +const { getBepBalance, getBncFlags, getBncSequence } = require('./utils/bncController') + +const { controller1, controller3 } = require('./utils/proxyController') + +const { HOME_BRIDGE_ADDRESS } = process.env + +module.exports = (getUsers, newValidator) => { + describe('add validator', function () { + let info + let initialInfo + let nextValidators + let user + let bncBridgeSequence + let bncBalance + + before(async function () { + initialInfo = await controller1.getInfo() + // eslint-disable-next-line prefer-destructuring + user = getUsers()[0] + bncBalance = await user.getBepBalance() + info = initialInfo + bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress) + nextValidators = [...info.validators, newValidator] + }) + + it('should start closing epoch process', async function () { + await controller1.voteStartVoting() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'ready', 'Should not change state after one vote') + + await user.approveErc(HOME_BRIDGE_ADDRESS, 5) + await user.exchangeErc(5) + + await controller3.voteStartVoting() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'closing_epoch') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + + await controller3.voteStartVoting() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'closing_epoch', 'Should not do anything after duplicate vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote') + }) + + it('should make forced sign', async function () { + this.timeout(300000) + await waitPromise( + () => getBncSequence(info.foreignBridgeAddress), + (sequence) => sequence === bncBridgeSequence + 1 + ) + const newBncBalance = await user.getBepBalance() + assert.strictEqual(newBncBalance, bncBalance + 5, `Balance of ${user.bncAddress} did not updated as expected`) + }) + + it('should finish close epoch process and start voting process', async function () { + this.timeout(120000) + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'voting') + const flags = await getBncFlags(initialInfo.foreignBridgeAddress) + assert.strictEqual(flags, 1, 'Foreign bridge flags are not set correctly') + }) + + it('should add validator', async function () { + await controller1.voteAddValidator(newValidator) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + + await controller3.voteAddValidator(newValidator) + info = await waitPromise( + controller1.getInfo, + (newInfo) => newInfo.nextValidators.length === nextValidators.length + ) + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Next validators are not set correctly') + + await controller3.voteAddValidator(newValidator) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not do anything after duplicate vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Incorrect set of next validators after third vote') + }) + + it('should change close epoch', async function () { + await controller1.voteChangeCloseEpoch(false) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Next validators are not set correctly') + assert.strictEqual(info.closeEpoch, true, 'Current close epoch is not set correctly') + assert.strictEqual(info.nextCloseEpoch, true, 'Next close epoch is not set correctly') + + await controller3.voteChangeCloseEpoch(false) + info = await waitPromise( + controller1.getInfo, + (newInfo) => !newInfo.nextCloseEpoch + ) + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Next validators are not set correctly') + assert.strictEqual(info.closeEpoch, true, 'Current close epoch is not set correctly') + + await controller3.voteChangeCloseEpoch(false) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not do anything after duplicate vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Incorrect set of next validators after third vote') + assert.strictEqual(info.closeEpoch, true, 'Current close epoch is not set correctly') + assert.strictEqual(info.nextCloseEpoch, false, 'Next close epoch is not set correctly') + }) + + it('should start keygen process', async function () { + await controller1.voteStartKeygen() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + + await controller3.voteStartKeygen() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'keygen') + + await controller3.voteStartKeygen() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'keygen', 'Should not do anything after duplicate vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Incorrect set of next validators after third vote') + }) + + it('should finish keygen process and start funds transfer', async function () { + this.timeout(120000) + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'funds_transfer') + }) + + it('should transfer all funds to new account and start new epoch', async function () { + this.timeout(300000) + info = await waitPromise( + controller1.getInfo, + (newInfo) => newInfo.epoch === initialInfo.epoch + 1 + ) + assert.deepStrictEqual(info.validators, nextValidators, 'Incorrect set of validators in new epoch') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Incorrect next epoch') + assert.strictEqual(info.bridgeStatus, 'ready', 'Incorrect bridge state in new epoch') + await delay(5000) + const prevBalance = await getBepBalance(initialInfo.foreignBridgeAddress) + const newBalance = await getBepBalance(info.foreignBridgeAddress) + assert.strictEqual(prevBalance, 0, 'Did not transfer all funds') + assert.strictEqual(newBalance, initialInfo.foreignBalanceTokens - 5, 'Funds are lost somewhere') + }) + }) +} diff --git a/tests/test/bncToEth.js b/tests/test/bncToEth.js new file mode 100644 index 0000000..da41899 --- /dev/null +++ b/tests/test/bncToEth.js @@ -0,0 +1,31 @@ +const { waitPromise } = require('./utils/wait') + +const { controller1 } = require('./utils/proxyController') + +module.exports = (getUsers) => { + describe('exchange of tokens in bnc => eth direction', function () { + let users + let info + let ethBalances + + before(async function () { + users = getUsers() + info = await controller1.getInfo() + ethBalances = await Promise.all(users.map((user) => user.getErcBalance())) + + await Promise.all(users.map((user, i) => user.exchangeBep(info.foreignBridgeAddress, 3 + i))) + }) + + it('should make correct exchange transactions on eth side', async function () { + this.timeout(120000) + for (let i = 0; i < 3; i += 1) { + const user = users[i] + await waitPromise( + user.getErcBalance, + // eslint-disable-next-line no-loop-func + (newEthBalance) => newEthBalance === ethBalances[i] + 3 + i + ) + } + }) + }) +} diff --git a/tests/test/changeThreshold.js b/tests/test/changeThreshold.js new file mode 100644 index 0000000..6090f42 --- /dev/null +++ b/tests/test/changeThreshold.js @@ -0,0 +1,131 @@ +const assert = require('assert') + +const { waitPromise, delay } = require('./utils/wait') +const { getBepBalance, getBncFlags } = require('./utils/bncController') +const { getNonce } = require('./utils/sideController') +const { controller1, controller2, controller3 } = require('./utils/proxyController') +const { keygenController1 } = require('./utils/keygenController') + +const { validators } = require('../config') + +module.exports = (newThreshold) => { + describe('change threshold', function () { + let info + let initialInfo + let validatorNonce + + before(async function () { + initialInfo = await controller1.getInfo() + validatorNonce = await getNonce(validators[0]) + info = initialInfo + }) + + it('should start voting process', async function () { + await controller1.voteStartVoting() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'ready', 'Should not change state after one vote') + + await controller2.voteStartVoting() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'closingEpoch' || newInfo.bridgeStatus === 'voting') + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not started closing epoch after previous epoch') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + + await controller3.voteStartVoting() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not do anything after third vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote') + }) + + it('should change threshold', async function () { + await controller1.voteChangeThreshold(newThreshold) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + assert.strictEqual(info.threshold, initialInfo.threshold, 'Threshold not set correctly') + assert.strictEqual(info.nextThreshold, initialInfo.threshold, 'Next threshold is not set correctly') + + await controller2.voteChangeThreshold(newThreshold) + info = await waitPromise( + controller1.getInfo, + (newInfo) => newInfo.nextThreshold === newThreshold + ) + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + assert.strictEqual(info.threshold, initialInfo.threshold, 'Threshold not set correctly') + + await controller3.voteChangeThreshold(newThreshold) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not do anything after third vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote') + assert.strictEqual(info.threshold, initialInfo.threshold, 'Threshold not set correctly') + assert.strictEqual(info.nextThreshold, newThreshold, 'Next threshold is not set correctly') + }) + + it('should start keygen process', async function () { + await controller1.voteStartKeygen() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + + await controller2.voteStartKeygen() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'keygen') + + await controller3.voteStartKeygen() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'keygen', 'Should not do anything after third vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote') + assert.strictEqual(info.threshold, initialInfo.threshold, 'Threshold not set correctly') + assert.strictEqual(info.nextThreshold, newThreshold, 'Next threshold is not set correctly') + }) + + it('should start keys generation', async function () { + this.timeout(120000) + await waitPromise( + () => getNonce(validators[0]), + (nonce) => nonce > validatorNonce + 2 + ) + }) + + it('should restart keygen generation and regenerate keys properly, should start funds transfer', async function () { + this.timeout(360000) + await keygenController1.restart() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'funds_transfer') + const flags = await getBncFlags(initialInfo.foreignBridgeAddress) + assert.strictEqual(flags, 0, 'Foreign bridge flags are not set correctly') + }) + + it('should transfer all funds to new account and start new epoch', async function () { + this.timeout(300000) + info = await waitPromise( + controller1.getInfo, + (newInfo) => newInfo.epoch === initialInfo.epoch + 1 + ) + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Incorrect set of validators in new epoch') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Incorrect next epoch') + assert.strictEqual(info.bridgeStatus, 'ready', 'Incorrect bridge state in new epoch') + assert.strictEqual(info.threshold, newThreshold, 'Threshold not set correctly') + assert.strictEqual(info.nextThreshold, newThreshold, 'Next threshold is not set correctly') + await delay(5000) + const prevBalance = await getBepBalance(initialInfo.foreignBridgeAddress) + const newBalance = await getBepBalance(info.foreignBridgeAddress) + assert.strictEqual(prevBalance, 0, 'Did not transfer all funds') + assert.strictEqual(newBalance, initialInfo.foreignBalanceTokens, 'Funds are lost somewhere') + }) + }) +} diff --git a/tests/test/ethToBnc.js b/tests/test/ethToBnc.js new file mode 100644 index 0000000..c01a5dc --- /dev/null +++ b/tests/test/ethToBnc.js @@ -0,0 +1,67 @@ +const assert = require('assert') + +const { getBncSequence } = require('./utils/bncController') +const { waitPromise, delay, seqMap } = require('./utils/wait') + +const { HOME_BRIDGE_ADDRESS } = process.env + +const { controller1 } = require('./utils/proxyController') + +module.exports = (getUsers, amount = 5, getBncPrefundedUser = null) => { + describe('exchange of tokens in eth => bnc direction', function () { + let info + let users + let ethBalances + let bncBalances + let bncBridgeSequence + let bncPrefundedUser + + before(async function () { + users = getUsers() + info = await controller1.getInfo() + ethBalances = await Promise.all(users.map((user) => user.getErcBalance())) + bncBalances = await seqMap(users, (user) => user.getBepBalance()) + if (getBncPrefundedUser) { + bncPrefundedUser = getBncPrefundedUser() + } + bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress) + await Promise.all(users.map((user, i) => user.approveErc(HOME_BRIDGE_ADDRESS, amount + i))) + }) + + it('should accept exchange requests', async function () { + await Promise.all(users.map((user, i) => user.exchangeErc(amount + i))) + const newEthBalances = await Promise.all(users.map((user) => user.getErcBalance())) + for (let i = 0; i < 3; i += 1) { + assert.strictEqual(newEthBalances[i], ethBalances[i] - amount - i, `Balance of ${users[i].ethAddress} did not updated as expected`) + } + }) + + if (getBncPrefundedUser) { + it('should make exchange transaction on bnc side after already enough funds', async function () { + this.timeout(300000) + await delay(120000) + await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, amount * 3 + 10, 0) + await waitPromise( + () => getBncSequence(info.foreignBridgeAddress), + (sequence) => sequence === bncBridgeSequence + 1 + ) + }) + } else { + it('should make exchange transaction on bnc side', async function () { + this.timeout(300000) + await waitPromise( + () => getBncSequence(info.foreignBridgeAddress), + (sequence) => sequence === bncBridgeSequence + 1 + ) + }) + } + + it('should make correct exchange transaction', async function () { + await delay(10000) + const newBncBalances = await Promise.all(users.map((user) => user.getBepBalance())) + for (let i = 0; i < 3; i += 1) { + assert.strictEqual(newBncBalances[i], bncBalances[i] + amount + i, `Balance of ${users[i].bncAddress} did not updated as expected`) + } + }) + }) +} diff --git a/tests/test/ethToBncWithRestart.js b/tests/test/ethToBncWithRestart.js new file mode 100644 index 0000000..8f5aa1e --- /dev/null +++ b/tests/test/ethToBncWithRestart.js @@ -0,0 +1,74 @@ +const assert = require('assert') + +const { getBncSequence } = require('./utils/bncController') +const { waitPromise, delay, seqMap } = require('./utils/wait') + +const { controller1 } = require('./utils/proxyController') +const { getNonce } = require('./utils/sideController') +const { signerController1, signerController2 } = require('./utils/signerController') + +const { validators } = require('../config') + +const { HOME_BRIDGE_ADDRESS } = process.env + +module.exports = (getUsers) => { + describe('exchange of tokens in eth => bnc direction with restart', function () { + let info + let users + let ethBalances + let bncBalances + let bncBridgeSequence + let validatorNonces + let newValidatorNonces + + before(async function () { + users = getUsers() + info = await controller1.getInfo() + ethBalances = await Promise.all(users.map((user) => user.getErcBalance())) + bncBalances = await seqMap(users, (user) => user.getBepBalance()) + validatorNonces = await Promise.all(validators.map(getNonce)) + + bncBridgeSequence = await getBncSequence(info.foreignBridgeAddress) + await Promise.all(users.map((user, i) => user.approveErc(HOME_BRIDGE_ADDRESS, 5 + i))) + }) + + it('should accept exchange requests', async function () { + await Promise.all(users.map((user, i) => user.exchangeErc(5 + i))) + const newEthBalances = await Promise.all(users.map((user) => user.getErcBalance())) + for (let i = 0; i < 3; i += 1) { + assert.strictEqual(newEthBalances[i], ethBalances[i] - 5 - i, `Balance of ${users[i].ethAddress} did not updated as expected`) + } + }) + + it('should start signing transaction', async function () { + this.timeout(120000) + newValidatorNonces = await waitPromise( + () => Promise.all(validators.map(getNonce)), + (nonces) => nonces[0] > validatorNonces[0] + 2 + || nonces[1] > validatorNonces[1] + 2 + || nonces[2] > validatorNonces[2] + 2 + ) + }) + + it('should restart signature generation and regenerate signature properly', async function () { + this.timeout(360000) + if (newValidatorNonces[0] > validatorNonces[0] + 2) { + await signerController1.restart() + } else { + await signerController2.restart() + } + await waitPromise( + () => getBncSequence(info.foreignBridgeAddress), + (sequence) => sequence === bncBridgeSequence + 1 + ) + }) + + it('should make correct exchange transaction', async function () { + await delay(10000) + const newBncBalances = await Promise.all(users.map((user) => user.getBepBalance())) + for (let i = 0; i < 3; i += 1) { + assert.strictEqual(newBncBalances[i], bncBalances[i] + 5 + i, `Balance of ${users[i].bncAddress} did not updated as expected`) + } + }) + }) +} diff --git a/tests/test/index.js b/tests/test/index.js new file mode 100644 index 0000000..52841d4 --- /dev/null +++ b/tests/test/index.js @@ -0,0 +1,83 @@ +const assert = require('assert') + +const createUser = require('./utils/user') +const { waitPromise, seqMap } = require('./utils/wait') + +const testEthToBnc = require('./ethToBnc') +const testEthToBncWithRestart = require('./ethToBncWithRestart') +const testBncToEth = require('./bncToEth') +const testRemoveValidator = require('./removeValidator') +const testAddValidator = require('./addValidator') +const testChangeThreshold = require('./changeThreshold') + +const usersConfig = require('../config').users +const validatorsConfig = require('../config').validators + +const { HOME_PRIVATE_KEY, FOREIGN_PRIVATE_KEY, HOME_BRIDGE_ADDRESS } = process.env + +const { controller1 } = require('./utils/proxyController') + +describe('bridge tests', function () { + let users + let bncPrefundedUser + let ethPrefundedUser + + before(async function () { + ethPrefundedUser = await createUser(HOME_PRIVATE_KEY, 'eth') + bncPrefundedUser = await createUser(FOREIGN_PRIVATE_KEY, 'bnc') + + for (let i = 0; i < 3; i += 1) { + // user eth balance is already prefunded with 100 eth in genesis block + await ethPrefundedUser.transferErc(usersConfig[i].ethAddress, 10000) + await bncPrefundedUser.transferBepBnb(usersConfig[i].bncAddress, 10000, 100) + } + + users = await seqMap(usersConfig, (user) => createUser(user.privateKey)) + }) + + describe('generation of initial epoch keys', function () { + let info + + it('should generate keys', async function () { + this.timeout(120000) + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.epoch === 1) + }) + + it('should start correct epoch', async function () { + assert.deepStrictEqual(info.validators, validatorsConfig, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, validatorsConfig, 'Next validators are not set correctly') + assert.strictEqual(info.closeEpoch, true, 'Current close epoch is not set correctly') + assert.strictEqual(info.nextCloseEpoch, true, 'Next close epoch is not set correctly') + assert.strictEqual(info.threshold, 2, 'Threshold not set correctly') + assert.strictEqual(info.nextThreshold, 2, 'Next threshold is not set correctly') + }) + + after(async function () { + await bncPrefundedUser.transferBepBnb(info.foreignBridgeAddress, 1000, 50) + await ethPrefundedUser.transferErc(HOME_BRIDGE_ADDRESS, 1000) + }) + }) + + testEthToBnc(() => users) + testBncToEth(() => users) + testEthToBnc(() => users) + + testRemoveValidator(validatorsConfig[1]) + + testEthToBnc(() => users, 500, () => bncPrefundedUser) + testBncToEth(() => users) + testEthToBnc(() => users) + + testAddValidator(() => users, validatorsConfig[1]) + + testEthToBnc(() => users) + testBncToEth(() => users) + testEthToBncWithRestart(() => users) + + testChangeThreshold(3) + + testEthToBnc(() => users) + testBncToEth(() => users) + testEthToBncWithRestart(() => users) + testEthToBnc(() => users) +}) diff --git a/tests/test/removeValidator.js b/tests/test/removeValidator.js new file mode 100644 index 0000000..befcede --- /dev/null +++ b/tests/test/removeValidator.js @@ -0,0 +1,114 @@ +const assert = require('assert') + +const { waitPromise, delay } = require('./utils/wait') +const { getBepBalance, getBncFlags } = require('./utils/bncController') + +const { controller1, controller2, controller3 } = require('./utils/proxyController') + +module.exports = (oldValidator) => { + describe('remove validator', function () { + let info + let initialInfo + let nextValidators + + before(async function () { + initialInfo = await controller1.getInfo() + info = initialInfo + nextValidators = initialInfo.validators.filter((validator) => validator !== oldValidator) + }) + + it('should start closing epoch process', async function () { + await controller1.voteStartVoting() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'ready', 'Should not change state after one vote') + + await controller2.voteStartVoting() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'closing_epoch') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + + await controller3.voteStartVoting() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'closing_epoch', 'Should not do anything after third vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Incorrect set of next validators after third vote') + }) + + it('should finish close epoch process and start voting process', async function () { + this.timeout(120000) + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'voting') + const flags = await getBncFlags(initialInfo.foreignBridgeAddress) + assert.strictEqual(flags, 1, 'Foreign bridge flags are not set correctly') + }) + + it('should remove validator', async function () { + await controller1.voteRemoveValidator(oldValidator) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, initialInfo.validators, 'Next validators are not set correctly') + + await controller2.voteRemoveValidator(oldValidator) + info = await waitPromise( + controller1.getInfo, + (newInfo) => newInfo.nextValidators.length === nextValidators.length + ) + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Next validators are not set correctly') + + await controller3.voteRemoveValidator(oldValidator) + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not do anything after third vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Incorrect set of next validators after third vote') + }) + + it('should start keygen process', async function () { + await controller1.voteStartKeygen() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'voting', 'Should not change state after one vote') + + await controller2.voteStartKeygen() + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'keygen') + + await controller3.voteStartKeygen() + await delay(5000) + info = await controller1.getInfo() + assert.strictEqual(info.bridgeStatus, 'keygen', 'Should not do anything after third vote') + assert.strictEqual(info.epoch, initialInfo.epoch, 'Current epoch is not set correctly') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Next epoch is not set correctly') + assert.deepStrictEqual(info.validators, initialInfo.validators, 'Validators are not set correctly') + assert.deepStrictEqual(info.nextValidators, nextValidators, 'Incorrect set of next validators after third vote') + }) + + it('should finish keygen process and start funds transfer', async function () { + this.timeout(120000) + info = await waitPromise(controller1.getInfo, (newInfo) => newInfo.bridgeStatus === 'funds_transfer') + }) + + it('should transfer all funds to new account and start new epoch', async function () { + this.timeout(300000) + info = await waitPromise( + controller1.getInfo, + (newInfo) => newInfo.epoch === initialInfo.epoch + 1 + ) + assert.deepStrictEqual(info.validators, nextValidators, 'Incorrect set of validators in new epoch') + assert.strictEqual(info.nextEpoch, initialInfo.epoch + 1, 'Incorrect next epoch') + assert.strictEqual(info.bridgeStatus, 'ready', 'Incorrect bridge state in new epoch') + await delay(5000) + const prevBalance = await getBepBalance(initialInfo.foreignBridgeAddress) + const newBalance = await getBepBalance(info.foreignBridgeAddress) + assert.strictEqual(prevBalance, 0, 'Did not transfer all funds') + assert.strictEqual(newBalance, initialInfo.foreignBalanceTokens, 'Funds are lost somewhere') + }) + }) +} diff --git a/tests/test/utils/bncClient.js b/tests/test/utils/bncClient.js new file mode 100644 index 0000000..bd18a30 --- /dev/null +++ b/tests/test/utils/bncClient.js @@ -0,0 +1,42 @@ +const Bnc = require('@binance-chain/javascript-sdk') + +const { delay } = require('./wait') + +const { FOREIGN_URL, FOREIGN_ASSET } = process.env + +module.exports = async function main(privateKey) { + const client = new Bnc(FOREIGN_URL) + client.chooseNetwork('testnet') + + await client.setPrivateKey(privateKey) + + await client.initChain() + const from = client.getClientKeyAddress() + + await delay(1000) + + return { + async transfer(to, tokens, bnbs) { + const outputs = [{ + to, + coins: [] + }] + if (tokens) { + outputs[0].coins.push({ + denom: FOREIGN_ASSET, + amount: tokens + }) + } + if (bnbs) { + outputs[0].coins.push({ + denom: 'BNB', + amount: bnbs + }) + } + await client.multiSend(from, outputs, 'funding') + }, + async exchange(to, value) { + await client.transfer(from, to, value.toString(), FOREIGN_ASSET, '') + } + } +} diff --git a/tests/test/utils/bncController.js b/tests/test/utils/bncController.js new file mode 100644 index 0000000..93237d7 --- /dev/null +++ b/tests/test/utils/bncController.js @@ -0,0 +1,31 @@ +const axios = require('axios') + +const { retry } = require('./wait') + +const { FOREIGN_URL, FOREIGN_ASSET } = process.env + +const bnc = axios.create({ + baseURL: FOREIGN_URL, + timeout: 10000 +}) + +module.exports = { + async getBnbBalance(address) { + const response = await retry(() => bnc.get(`/api/v1/account/${address}`)) + const tokens = response.data.balances.find((x) => x.symbol === 'BNB') + return response && tokens ? parseFloat(tokens.free) : 0 + }, + async getBepBalance(address) { + const response = await retry(() => bnc.get(`/api/v1/account/${address}`)) + const tokens = response.data.balances.find((x) => x.symbol === FOREIGN_ASSET) + return response && tokens ? parseFloat(tokens.free) : 0 + }, + async getBncSequence(address) { + const response = await retry(() => bnc.get(`/api/v1/account/${address}/sequence`)) + return response ? response.data.sequence : 0 + }, + async getBncFlags(address) { + const response = await retry(() => bnc.get(`/api/v1/account/${address}`)) + return response.data.flags + } +} diff --git a/tests/test/utils/homeContracts.js b/tests/test/utils/homeContracts.js new file mode 100644 index 0000000..b753e47 --- /dev/null +++ b/tests/test/utils/homeContracts.js @@ -0,0 +1,24 @@ +const ethers = require('ethers') + +const { HOME_RPC_URL, HOME_TOKEN_ADDRESS, HOME_BRIDGE_ADDRESS } = process.env + +const abiToken = [ + 'function balanceOf(address account) view returns (uint)', + 'function transfer(address to, uint value)', + 'function approve(address to, uint value)', + 'function allowance(address owner, address spender) view returns (uint)' +] +const abiBridge = [ + 'function exchange(uint96 value)' +] + +const provider = new ethers.providers.JsonRpcProvider(HOME_RPC_URL) + +const tokenContract = new ethers.Contract(HOME_TOKEN_ADDRESS, abiToken, provider) +const bridgeContract = new ethers.Contract(HOME_BRIDGE_ADDRESS, abiBridge, provider) + +module.exports = { + tokenContract, + bridgeContract, + provider +} diff --git a/tests/test/utils/keygenController.js b/tests/test/utils/keygenController.js new file mode 100644 index 0000000..e670eaa --- /dev/null +++ b/tests/test/utils/keygenController.js @@ -0,0 +1,22 @@ +const axios = require('axios') + +function createController(validatorId) { + const url = `http://validator${validatorId}_keygen_1:8001/` + + const keygenClient = axios.create({ + baseURL: url, + timeout: 10000 + }) + + return { + async restart() { + await keygenClient.get('/restart') + } + } +} + +module.exports = { + keygenController1: createController(1), + keygenController2: createController(2), + keygenController3: createController(3) +} diff --git a/tests/test/utils/proxyController.js b/tests/test/utils/proxyController.js new file mode 100644 index 0000000..db028c8 --- /dev/null +++ b/tests/test/utils/proxyController.js @@ -0,0 +1,42 @@ +const axios = require('axios') + +const { retry } = require('./wait') + +function createController(validatorId) { + const url = `http://validator${validatorId}_proxy_1:8002/` + + const proxy = axios.create({ + baseURL: url, + timeout: 10000 + }) + + return { + async getInfo() { + return (await retry(() => proxy.get('/info'))).data + }, + async voteStartVoting() { + return (await retry(() => proxy.get('/vote/startVoting'))).data + }, + async voteStartKeygen() { + return (await retry(() => proxy.get('/vote/startKeygen'))).data + }, + async voteAddValidator(validatorAddress) { + return (await retry(() => proxy.get(`/vote/addValidator/${validatorAddress}`))).data + }, + async voteRemoveValidator(validatorAddress) { + return (await retry(() => proxy.get(`/vote/removeValidator/${validatorAddress}`))).data + }, + async voteChangeThreshold(threshold) { + return (await retry(() => proxy.get(`/vote/changeThreshold/${threshold}`))).data + }, + async voteChangeCloseEpoch(closeEpoch) { + return (await retry(() => proxy.get(`/vote/changeCloseEpoch/${closeEpoch}`))).data + } + } +} + +module.exports = { + controller1: createController(1), + controller2: createController(2), + controller3: createController(3) +} diff --git a/tests/test/utils/sideController.js b/tests/test/utils/sideController.js new file mode 100644 index 0000000..24fac5e --- /dev/null +++ b/tests/test/utils/sideController.js @@ -0,0 +1,11 @@ +const ethers = require('ethers') + +const { SIDE_RPC_URL } = process.env + +const provider = new ethers.providers.JsonRpcProvider(SIDE_RPC_URL) + +module.exports = { + async getNonce(address) { + return await provider.getTransactionCount(address) + } +} diff --git a/tests/test/utils/signerController.js b/tests/test/utils/signerController.js new file mode 100644 index 0000000..98f3eed --- /dev/null +++ b/tests/test/utils/signerController.js @@ -0,0 +1,22 @@ +const axios = require('axios') + +function createController(validatorId) { + const url = `http://validator${validatorId}_signer_1:8001/` + + const signerClient = axios.create({ + baseURL: url, + timeout: 10000 + }) + + return { + async restart() { + await signerClient.get('/restart') + } + } +} + +module.exports = { + signerController1: createController(1), + signerController2: createController(2), + signerController3: createController(3) +} diff --git a/tests/test/utils/user.js b/tests/test/utils/user.js new file mode 100644 index 0000000..a0c035c --- /dev/null +++ b/tests/test/utils/user.js @@ -0,0 +1,108 @@ +const ethers = require('ethers') +const BN = require('bignumber.js') +const { getAddressFromPrivateKey } = require('@binance-chain/javascript-sdk/lib/crypto') + +const createBncClient = require('./bncClient') +const { getBnbBalance, getBepBalance } = require('./bncController') +const { tokenContract, bridgeContract, provider } = require('./homeContracts') +const { delay } = require('./wait') + +const txOptions = { + gasLimit: 200000 +} + +const { SIDE_RPC_URL } = process.env + +async function createUser(privateKey, network) { + const opts = {} + if (network !== 'bnc') { + opts.providerSide = new ethers.providers.JsonRpcProvider(SIDE_RPC_URL) + opts.walletSide = new ethers.Wallet(privateKey, opts.providerSide) + opts.wallet = new ethers.Wallet(privateKey, provider) + opts.ethAddress = opts.wallet.address + opts.token = tokenContract.connect(opts.wallet) + opts.bridge = bridgeContract.connect(opts.wallet) + } + if (network !== 'eth') { + opts.bncAddress = getAddressFromPrivateKey(privateKey) + opts.bncClient = await createBncClient(privateKey) + } + + return { + ethAddress: opts.ethAddress, + bncAddress: opts.bncAddress, + async getEthBalance() { + const balance = await opts.wallet.getBalance() + return parseFloat(new BN(balance).dividedBy(10 ** 18).toFixed(8, 3)) + }, + async getSideEthBalance() { + const balance = await opts.walletSide.getBalance() + return parseFloat(new BN(balance).dividedBy(10 ** 18).toFixed(8, 3)) + }, + async getErcBalance() { + const balance = await opts.token.balanceOf(opts.ethAddress) + return parseFloat(new BN(balance).dividedBy(10 ** 18).toFixed(8, 3)) + }, + async transferEth(to, value) { + const tx = await opts.wallet.sendTransaction( + { + to, + value: `0x${new BN(value).multipliedBy(10 ** 18).toString(16)}` + }, + txOptions + ) + await tx.wait() + }, + async transferEthSide(to, value) { + const tx = await opts.walletSide.sendTransaction( + { + to, + value: `0x${new BN(value).multipliedBy(10 ** 18).toString(16)}` + }, + txOptions + ) + await tx.wait() + }, + async transferErc(to, value) { + const tx = await opts.token.transfer( + to, + `0x${new BN(value).multipliedBy(10 ** 18).toString(16)}`, + txOptions + ) + await tx.wait() + }, + async approveErc(to, value) { + const tx = await opts.token.approve( + to, + `0x${new BN(value).multipliedBy(10 ** 18).toString(16)}`, + txOptions + ) + await tx.wait() + }, + async exchangeErc(value) { + const tx = await opts.bridge.exchange( + `0x${new BN(value).multipliedBy(10 ** 18).toString(16)}`, + txOptions + ) + await tx.wait() + }, + async getBnbBalance() { + const balance = await getBnbBalance(opts.bncAddress) + await delay(1000) + return balance + }, + async getBepBalance() { + const balance = await getBepBalance(opts.bncAddress) + await delay(1000) + return balance + }, + async transferBepBnb(to, tokens, bnbs) { + return await opts.bncClient.transfer(to, tokens, bnbs) + }, + async exchangeBep(bridgeAddress, value) { + return await opts.bncClient.exchange(bridgeAddress, value) + } + } +} + +module.exports = createUser diff --git a/tests/test/utils/wait.js b/tests/test/utils/wait.js new file mode 100644 index 0000000..aef08fa --- /dev/null +++ b/tests/test/utils/wait.js @@ -0,0 +1,41 @@ +async function delay(ms) { + await new Promise((res) => setTimeout(res, ms)) +} + +async function waitPromise(getPromise, checker) { + while (true) { + const result = await getPromise() + if (checker(result)) { + return result + } + await delay(1000) + } +} + +async function retry(getPromise, n = -1, sleep = 3000) { + while (n) { + try { + return await getPromise() + } catch (e) { + await delay(sleep) + // eslint-disable-next-line no-param-reassign + n -= 1 + } + } + return null +} + +async function seqMap(arr, transition) { + const results = [] + for (let i = 0; i < arr.length; i += 1) { + results[i] = await transition(arr[i]) + } + return results +} + +module.exports = { + waitPromise, + delay, + retry, + seqMap +}