From e4d9f618e73fcb58020870d12437e8734131837b Mon Sep 17 00:00:00 2001 From: Michael Zaikin Date: Mon, 13 May 2024 18:25:28 +0100 Subject: [PATCH] Run test & build CI --- .circleci/config.yml | 111 --- .dockerignore | 4 + .github/workflows/packages.yml | 56 ++ .github/workflows/releases.yml | 31 + .github/workflows/tests.yml | 29 + .gitignore | 4 +- Makefile | 3 + crates/dkg-cli/Dockerfile | 19 +- crates/dkg-cli/README.md | 1 - crates/dkg-cli/artifacts/dkg.bin | 1 + crates/dkg-cli/artifacts/dkg.json | 1 + crates/dkg-cli/build.rs | 9 +- crates/dkg-cli/dkg.json | 1 + crates/dkg-cli/src/actions.rs | 2 +- crates/dkg-cli/src/dkg_contract.rs | 1366 ++++++++++++++++++++++++++++ 15 files changed, 1509 insertions(+), 129 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .dockerignore create mode 100644 .github/workflows/packages.yml create mode 100644 .github/workflows/releases.yml create mode 100644 .github/workflows/tests.yml create mode 100644 crates/dkg-cli/artifacts/dkg.bin create mode 100644 crates/dkg-cli/artifacts/dkg.json create mode 100644 crates/dkg-cli/dkg.json create mode 100644 crates/dkg-cli/src/dkg_contract.rs diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 53eb486..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,111 +0,0 @@ -version: 2 - -jobs: - contracts: - docker: - - image: cimg/node:lts - steps: - - checkout - - run: - name: Test Contracts - command: | - cd solidity - yarn - yarn build - yarn test - - cross-ios: - macos: - xcode: 13.3.0 - working_directory: ~/work - steps: - - checkout - - run: - name: Install rustup - command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - - run: - name: Install Rust 1.64 - command: rustup install 1.64.0 && rustup default 1.64.0 - - run: - name: Install iOS targets - command: rustup target add aarch64-apple-ios x86_64-apple-ios - - run: - name: Build iOS - command: cd crates/threshold-bls-ffi/cross && make ios - - store_artifacts: - path: ~/work/cross/react-native/ios - - test: - docker: - - image: cimg/rust:1.64.0 - resource_class: large - steps: - - checkout - - run: - name: Install Dependencies - command: | - cargo install cargo-audit - mkdir -p "$HOME/bin" - wget -q https://github.com/ethereum/solidity/releases/download/v0.6.6/solc-static-linux -O $HOME/bin/solc - chmod u+x "$HOME/bin/solc" - export PATH=$HOME/bin:$PATH - solc --version - - run: - name: Tests - command: | - export PATH=$HOME/bin:$PATH - cargo test --all - - run: - name: Check style - command: | - cargo fmt --all -- --check - cargo clippy --all-targets --all-features -- -D warnings -Aclippy::upper_case_acronyms - - run: - name: Audit Dependencies - command: cargo audit --ignore RUSTSEC-2019-0031 # ignore lazy static warning - - wasm: - docker: - - image: cimg/rust:1.64.0 - steps: - - checkout - - run: - name: Install wasm-pack - command: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - - run: - name: Build wasm - command: cd crates/threshold-bls-ffi && wasm-pack build - - cross-android: - docker: - - image: cimg/rust:1.64.0 - working_directory: ~/work - steps: - - checkout - - run: - name: Install Python - command: sudo apt install python - - run: - name: Install Android targets - command: rustup target add aarch64-linux-android armv7-linux-androideabi arm-linux-androideabi i686-linux-android x86_64-linux-android - - run: - name: Download NDK - command: cd crates/threshold-bls-ffi && wget https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip && unzip android-ndk-r21-linux-x86_64.zip - - run: - name: Create standalone toolchain - command: cd crates/threshold-bls-ffi/cross && NDK_HOME=$PWD/../android-ndk-r21 ./create-ndk-standalone.sh - - run: - name: Build Android - command: cd crates/threshold-bls-ffi/cross && make android - - store_artifacts: - path: ~/work/cross/react-native/android - -workflows: - version: 2 - build_and_test: - jobs: - - contracts - - test - - wasm - - cross-android - - cross-ios diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a88cbc0 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +target/ +keypair +.env +solidity/cache diff --git a/.github/workflows/packages.yml b/.github/workflows/packages.yml new file mode 100644 index 0000000..3dbab2a --- /dev/null +++ b/.github/workflows/packages.yml @@ -0,0 +1,56 @@ +name: Packages + +on: + push: + branches: + - 'master' + tags: + - '*.*.*' + pull_request: + branches: + - 'master' + +jobs: + build: + name: Build and push docker images to ghcr.io + runs-on: ubuntu-latest + env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE_BASE: ${{ github.repository_owner }} + outputs: + operator: ${{ steps.meta-tezos-operator.outputs.tags }} + steps: + - name: Check out the repo + uses: actions/checkout@v2 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Log in to the registry + uses: docker/login-action@v1 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set image tags & labels + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_BASE }}/dkg-cli + + - name: Image build & push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64, + file: crates/dkg-cli/Dockerfile + push: true + cache-from: type=gha + cache-to: type=gha,mode=max + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml new file mode 100644 index 0000000..07d8e74 --- /dev/null +++ b/.github/workflows/releases.yml @@ -0,0 +1,31 @@ +name: Releases + +on: + push: + tags: + - '*.*.*' + pull_request: + branches: + - 'master' + +jobs: + build: + name: Build and publish static binaries + runs-on: ubuntu-latest + + strategy: + matrix: + target: [x86_64-unknown-linux-gnu] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + + - name: Build + run: RUSTFLAGS="-C target-feature=-crt-static" NO_SOLC_BUILD=1 cargo build --release --target=${{ matrix.target }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..2b29898 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,29 @@ +name: Tests + +on: + pull_request: + push: + branches: + - 'master' + +jobs: + test: + name: Check formatting and run unit tests + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Check formatting + run: cargo fmt --check + + - name: Run tests + run: NO_SOLC_BUILD=1 cargo test diff --git a/.gitignore b/.gitignore index a2570d8..562e80c 100644 --- a/.gitignore +++ b/.gitignore @@ -20,11 +20,9 @@ react-native solidity/cache solidity/build +solidity/artifacts *.swp -*.bin .DS_Store -*.json -crates/dkg-cli/src/dkg_contract.rs keypair dkg-output diff --git a/Makefile b/Makefile index 4809a78..7935627 100644 --- a/Makefile +++ b/Makefile @@ -14,3 +14,6 @@ run: start: ./target/release/dkg-cli start -n $(NODE_URL) -p $(PRIVATE_KEY) -c $(CONTRACT_ADDRESS) + +image: + docker build -t dkg-cli -f crates/dkg-cli/Dockerfile . diff --git a/crates/dkg-cli/Dockerfile b/crates/dkg-cli/Dockerfile index 54c8b2d..71a0997 100644 --- a/crates/dkg-cli/Dockerfile +++ b/crates/dkg-cli/Dockerfile @@ -1,13 +1,10 @@ -FROM cimg/rust:1.65.0 - -ENV HOME=/home/circleci -ENV PATH=$HOME/bin:$PATH - -RUN cd $HOME && git clone https://github.com/m-kus/threshold-bls-rs -RUN mkdir $HOME/bin && wget -q https://github.com/ethereum/solidity/releases/download/v0.6.6/solc-static-linux -O $HOME/bin/solc && chmod u+x $HOME/bin/solc && solc --version -RUN cd $HOME && cd threshold-bls-rs/crates/dkg-cli && RUSTFLAGS="-C target-feature=-crt-static" cargo build --release +FROM rust:1.76 +WORKDIR /root +COPY . /root/dkg-tooling/ +#RUN git clone https://github.com/trilitech/dkg-tooling +RUN cd $HOME/dkg-tooling/crates/dkg-cli \ + && RUSTFLAGS="-C target-feature=-crt-static" NO_SOLC_BUILD=1 cargo build --release FROM ubuntu:22.04 -COPY --from=0 /home/circleci/threshold-bls-rs/target/release/dkg-cli /dkgbin -WORKDIR /dkg -ENTRYPOINT [ "/dkgbin" ] +COPY --from=0 /root/dkg-tooling/target/release/dkg-cli /usr/bin/ +ENTRYPOINT [ "dkg-cli" ] diff --git a/crates/dkg-cli/README.md b/crates/dkg-cli/README.md index aa1719b..fbf2544 100644 --- a/crates/dkg-cli/README.md +++ b/crates/dkg-cli/README.md @@ -13,7 +13,6 @@ in the [Solidity docs](https://solidity.readthedocs.io/en/latest/installing-soli Install the DKG CLI with `cargo build --release`. -We will use the Alfajores testnet for this example, which you can access by using `https://alfajores-forno.celo-testnet.org` as a `NODE_URL`. You can fund your account by inserting your `address` to the [Alfajores faucet](https://celo.org/developers/faucet). 1. `dkg-cli keygen --path ./keypair` diff --git a/crates/dkg-cli/artifacts/dkg.bin b/crates/dkg-cli/artifacts/dkg.bin new file mode 100644 index 0000000..4e3d027 --- /dev/null +++ b/crates/dkg-cli/artifacts/dkg.bin @@ -0,0 +1 @@ +60c06040525f600655348015610013575f80fd5b506040516127da3803806127da833981810160405281019061003591906100c3565b80608081815250508160a081815250503360075f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505050610101565b5f80fd5b5f819050919050565b6100a281610090565b81146100ac575f80fd5b50565b5f815190506100bd81610099565b92915050565b5f80604083850312156100d9576100d861008c565b5b5f6100e6858286016100af565b92505060206100f7858286016100af565b9150509250929050565b60805160a0516126876101535f395f8181610729015261111a01525f81816104b5015281816104e601528181610523015281816105df0152818161080c015281816109100152610a2001526126875ff3fe608060405234801561000f575f80fd5b506004361061012a575f3560e01c806382fbdc9c116100ab578063be9a65551161006f578063be9a655514610333578063cc5ef0091461033d578063cd5e38371461035b578063ce7c2ac21461038b578063d73fe0aa146103bb5761012a565b806382fbdc9c146102a05780638da5cb5b146102bc578063a7cd52cb146102da578063a8194596146102f6578063b0ef8179146103155761012a565b80634ae2b849116100f25780634ae2b849146101fa5780635aa68ac014610218578063670d14b214610236578063785ffb37146102665780637fd28346146102845761012a565b80630c8f81b51461012e5780630ea656481461015e578063221f95111461018e57806335c1d349146101ac57806348cd4cb1146101dc575b5f80fd5b61014860048036038101906101439190611882565b6103d9565b6040516101559190611920565b60405180910390f35b61017860048036038101906101739190611882565b6103f5565b60405161018591906119c3565b60405180910390f35b610196610490565b6040516101a391906119fb565b60405180910390f35b6101c660048036038101906101c19190611a3e565b61059c565b6040516101d39190611a78565b60405180910390f35b6101e46105d7565b6040516101f191906119fb565b60405180910390f35b6102026105dd565b60405161020f91906119fb565b60405180910390f35b610220610601565b60405161022d9190611b48565b60405180910390f35b610250600480360381019061024b9190611882565b61068c565b60405161025d91906119c3565b60405180910390f35b61026e610727565b60405161027b91906119fb565b60405180910390f35b61029e60048036038101906102999190611bc9565b61074b565b005b6102ba60048036038101906102b59190611bc9565b610b70565b005b6102c4610d78565b6040516102d19190611a78565b60405180910390f35b6102f460048036038101906102ef9190611882565b610d9d565b005b6102fe610f85565b60405161030c929190611d17565b60405180910390f35b61031d611143565b60405161032a9190611d45565b60405180910390f35b61033b6112dc565b005b6103456113b8565b6040516103529190611d45565b60405180910390f35b61037560048036038101906103709190611882565b611551565b60405161038291906119c3565b60405180910390f35b6103a560048036038101906103a09190611882565b6115ec565b6040516103b291906119c3565b60405180910390f35b6103c3611687565b6040516103d09190611d45565b60405180910390f35b5f602052805f5260405f205f915054906101000a900460ff1681565b6003602052805f5260405f205f91509050805461041190611d92565b80601f016020809104026020016040519081016040528092919081815260200182805461043d90611d92565b80156104885780601f1061045f57610100808354040283529160200191610488565b820191905f5260205f20905b81548152906001019060200180831161046b57829003601f168201915b505050505081565b5f80600654036104a2575f9050610599565b5f600654436104b19190611def565b90507f000000000000000000000000000000000000000000000000000000000000000081116104e4576001915050610599565b7f000000000000000000000000000000000000000000000000000000000000000060026105119190611e22565b8111610521576002915050610599565b7f0000000000000000000000000000000000000000000000000000000000000000600361054e9190611e22565b811161055e576003915050610599565b6040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161059090611ebd565b60405180910390fd5b90565b600581815481106105ab575f80fd5b905f5260205f20015f915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60065481565b7f000000000000000000000000000000000000000000000000000000000000000081565b6060600580548060200260200160405190810160405280929190818152602001828054801561068257602002820191905f5260205f20905b815f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311610639575b5050505050905090565b6001602052805f5260405f205f9150905080546106a890611d92565b80601f01602080910402602001604051908101604052809291908181526020018280546106d490611d92565b801561071f5780601f106106f65761010080835404028352916020019161071f565b820191905f5260205f20905b81548152906001019060200180831161070257829003601f168201915b505050505081565b7f000000000000000000000000000000000000000000000000000000000000000081565b60028081111561075e5761075d6118ad565b5b5f803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff1660028111156107b9576107b86118ad565b5b146107f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107f090611f25565b60405180910390fd5b5f600654436108089190611def565b90507f0000000000000000000000000000000000000000000000000000000000000000811161090e575f60025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805461087a90611d92565b9050146108bc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b390611fb3565b60405180910390fd5b828260025f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2091826109089291906121a5565b50610b6b565b7f0000000000000000000000000000000000000000000000000000000000000000600261093b9190611e22565b8111610a1e575f60035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805461098a90611d92565b9050146109cc576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109c3906122e2565b60405180910390fd5b828260035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f209182610a189291906121a5565b50610b6a565b7f00000000000000000000000000000000000000000000000000000000000000006003610a4b9190611e22565b8111610b2e575f60045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f208054610a9a90611d92565b905014610adc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ad390612370565b60405180910390fd5b828260045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f209182610b289291906121a5565b50610b69565b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b60906123d8565b60405180910390fd5b5b5b505050565b5f60065414610bb4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bab90612440565b60405180910390fd5b60016002811115610bc857610bc76118ad565b5b5f803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff166002811115610c2357610c226118ad565b5b14610c63576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c5a906124ce565b60405180910390fd5b600533908060018154018082558091505060019003905f5260205f20015f9091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550818160015f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f209182610d0f9291906121a5565b5060025f803373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff02191690836002811115610d6f57610d6e6118ad565b5b02179055505050565b60075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b5f60065414610de1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610dd890612440565b60405180910390fd5b60075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610e70576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6790612536565b60405180910390fd5b5f6002811115610e8357610e826118ad565b5b5f808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f9054906101000a900460ff166002811115610ede57610edd6118ad565b5b14610f1e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f159061259e565b60405180910390fd5b60015f808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f6101000a81548160ff02191690836002811115610f7d57610f7c6118ad565b5b021790555050565b5f60605f60058054905067ffffffffffffffff811115610fa857610fa7611fdb565b5b604051908082528060200260200182016040528015610fdb57816020015b6060815260200190600190039081610fc65790505b5090505f5b6005805490508110156111175760015f60058381548110611004576110036125bc565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805461107090611d92565b80601f016020809104026020016040519081016040528092919081815260200182805461109c90611d92565b80156110e75780601f106110be576101008083540402835291602001916110e7565b820191905f5260205f20905b8154815290600101906020018083116110ca57829003601f168201915b50505050508282815181106110ff576110fe6125bc565b5b60200260200101819052508080600101915050610fe0565b507f00000000000000000000000000000000000000000000000000000000000000008192509250509091565b60605f60058054905067ffffffffffffffff81111561116557611164611fdb565b5b60405190808252806020026020018201604052801561119857816020015b60608152602001906001900390816111835790505b5090505f5b6005805490508110156112d45760045f600583815481106111c1576111c06125bc565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805461122d90611d92565b80601f016020809104026020016040519081016040528092919081815260200182805461125990611d92565b80156112a45780601f1061127b576101008083540402835291602001916112a4565b820191905f5260205f20905b81548152906001019060200180831161128757829003601f168201915b50505050508282815181106112bc576112bb6125bc565b5b6020026020010181905250808060010191505061119d565b508091505090565b5f60065414611320576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161131790612440565b60405180910390fd5b60075f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146113af576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113a690612633565b60405180910390fd5b43600681905550565b60605f60058054905067ffffffffffffffff8111156113da576113d9611fdb565b5b60405190808252806020026020018201604052801561140d57816020015b60608152602001906001900390816113f85790505b5090505f5b6005805490508110156115495760035f60058381548110611436576114356125bc565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f2080546114a290611d92565b80601f01602080910402602001604051908101604052809291908181526020018280546114ce90611d92565b80156115195780601f106114f057610100808354040283529160200191611519565b820191905f5260205f20905b8154815290600101906020018083116114fc57829003601f168201915b5050505050828281518110611531576115306125bc565b5b60200260200101819052508080600101915050611412565b508091505090565b6004602052805f5260405f205f91509050805461156d90611d92565b80601f016020809104026020016040519081016040528092919081815260200182805461159990611d92565b80156115e45780601f106115bb576101008083540402835291602001916115e4565b820191905f5260205f20905b8154815290600101906020018083116115c757829003601f168201915b505050505081565b6002602052805f5260405f205f91509050805461160890611d92565b80601f016020809104026020016040519081016040528092919081815260200182805461163490611d92565b801561167f5780601f106116565761010080835404028352916020019161167f565b820191905f5260205f20905b81548152906001019060200180831161166257829003601f168201915b505050505081565b60605f60058054905067ffffffffffffffff8111156116a9576116a8611fdb565b5b6040519080825280602002602001820160405280156116dc57816020015b60608152602001906001900390816116c75790505b5090505f5b6005805490508110156118185760025f60058381548110611705576117046125bc565b5b905f5260205f20015f9054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f20805461177190611d92565b80601f016020809104026020016040519081016040528092919081815260200182805461179d90611d92565b80156117e85780601f106117bf576101008083540402835291602001916117e8565b820191905f5260205f20905b8154815290600101906020018083116117cb57829003601f168201915b5050505050828281518110611800576117ff6125bc565b5b602002602001018190525080806001019150506116e1565b508091505090565b5f80fd5b5f80fd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61185182611828565b9050919050565b61186181611847565b811461186b575f80fd5b50565b5f8135905061187c81611858565b92915050565b5f6020828403121561189757611896611820565b5b5f6118a48482850161186e565b91505092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602160045260245ffd5b600381106118eb576118ea6118ad565b5b50565b5f8190506118fb826118da565b919050565b5f61190a826118ee565b9050919050565b61191a81611900565b82525050565b5f6020820190506119335f830184611911565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f5b83811015611970578082015181840152602081019050611955565b5f8484015250505050565b5f601f19601f8301169050919050565b5f61199582611939565b61199f8185611943565b93506119af818560208601611953565b6119b88161197b565b840191505092915050565b5f6020820190508181035f8301526119db818461198b565b905092915050565b5f819050919050565b6119f5816119e3565b82525050565b5f602082019050611a0e5f8301846119ec565b92915050565b611a1d816119e3565b8114611a27575f80fd5b50565b5f81359050611a3881611a14565b92915050565b5f60208284031215611a5357611a52611820565b5b5f611a6084828501611a2a565b91505092915050565b611a7281611847565b82525050565b5f602082019050611a8b5f830184611a69565b92915050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b611ac381611847565b82525050565b5f611ad48383611aba565b60208301905092915050565b5f602082019050919050565b5f611af682611a91565b611b008185611a9b565b9350611b0b83611aab565b805f5b83811015611b3b578151611b228882611ac9565b9750611b2d83611ae0565b925050600181019050611b0e565b5085935050505092915050565b5f6020820190508181035f830152611b608184611aec565b905092915050565b5f80fd5b5f80fd5b5f80fd5b5f8083601f840112611b8957611b88611b68565b5b8235905067ffffffffffffffff811115611ba657611ba5611b6c565b5b602083019150836001820283011115611bc257611bc1611b70565b5b9250929050565b5f8060208385031215611bdf57611bde611820565b5b5f83013567ffffffffffffffff811115611bfc57611bfb611824565b5b611c0885828601611b74565b92509250509250929050565b5f81519050919050565b5f82825260208201905092915050565b5f819050602082019050919050565b5f82825260208201905092915050565b5f611c5782611939565b611c618185611c3d565b9350611c71818560208601611953565b611c7a8161197b565b840191505092915050565b5f611c908383611c4d565b905092915050565b5f602082019050919050565b5f611cae82611c14565b611cb88185611c1e565b935083602082028501611cca85611c2e565b805f5b85811015611d055784840389528151611ce68582611c85565b9450611cf183611c98565b925060208a01995050600181019050611ccd565b50829750879550505050505092915050565b5f604082019050611d2a5f8301856119ec565b8181036020830152611d3c8184611ca4565b90509392505050565b5f6020820190508181035f830152611d5d8184611ca4565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f6002820490506001821680611da957607f821691505b602082108103611dbc57611dbb611d65565b5b50919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f611df9826119e3565b9150611e04836119e3565b9250828203905081811115611e1c57611e1b611dc2565b5b92915050565b5f611e2c826119e3565b9150611e37836119e3565b9250828202611e45816119e3565b91508282048414831517611e5c57611e5b611dc2565b5b5092915050565b5f82825260208201905092915050565b7f444b4720456e64656400000000000000000000000000000000000000000000005f82015250565b5f611ea7600983611e63565b9150611eb282611e73565b602082019050919050565b5f6020820190508181035f830152611ed481611e9b565b9050919050565b7f796f7520617265206e6f742072656769737465726564210000000000000000005f82015250565b5f611f0f601783611e63565b9150611f1a82611edb565b602082019050919050565b5f6020820190508181035f830152611f3c81611f03565b9050919050565b7f796f75206861766520616c7265616479207075626c697368656420796f7572205f8201527f7368617265730000000000000000000000000000000000000000000000000000602082015250565b5f611f9d602683611e63565b9150611fa882611f43565b604082019050919050565b5f6020820190508181035f830152611fca81611f91565b9050919050565b5f82905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f600883026120647fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82612029565b61206e8683612029565b95508019841693508086168417925050509392505050565b5f819050919050565b5f6120a96120a461209f846119e3565b612086565b6119e3565b9050919050565b5f819050919050565b6120c28361208f565b6120d66120ce826120b0565b848454612035565b825550505050565b5f90565b6120ea6120de565b6120f58184846120b9565b505050565b5b818110156121185761210d5f826120e2565b6001810190506120fb565b5050565b601f82111561215d5761212e81612008565b6121378461201a565b81016020851015612146578190505b61215a6121528561201a565b8301826120fa565b50505b505050565b5f82821c905092915050565b5f61217d5f1984600802612162565b1980831691505092915050565b5f612195838361216e565b9150826002028217905092915050565b6121af8383611fd1565b67ffffffffffffffff8111156121c8576121c7611fdb565b5b6121d28254611d92565b6121dd82828561211c565b5f601f83116001811461220a575f84156121f8578287013590505b612202858261218a565b865550612269565b601f19841661221886612008565b5f5b8281101561223f5784890135825560018201915060208501945060208101905061221a565b8683101561225c5784890135612258601f89168261216e565b8355505b6001600288020188555050505b50505050505050565b7f796f75206861766520616c7265616479207075626c697368656420796f7572205f8201527f726573706f6e7365730000000000000000000000000000000000000000000000602082015250565b5f6122cc602983611e63565b91506122d782612272565b604082019050919050565b5f6020820190508181035f8301526122f9816122c0565b9050919050565b7f796f75206861766520616c7265616479207075626c697368656420796f7572205f8201527f6a757374696669636174696f6e73000000000000000000000000000000000000602082015250565b5f61235a602e83611e63565b915061236582612300565b604082019050919050565b5f6020820190508181035f8301526123878161234e565b9050919050565b7f444b472068617320656e646564000000000000000000000000000000000000005f82015250565b5f6123c2600d83611e63565b91506123cd8261238e565b602082019050919050565b5f6020820190508181035f8301526123ef816123b6565b9050919050565b7f444b472068617320616c726561647920737461727465640000000000000000005f82015250565b5f61242a601783611e63565b9150612435826123f6565b602082019050919050565b5f6020820190508181035f8301526124578161241e565b9050919050565b7f75736572206973206e6f7420616c6c6f776c6973746564206f722068617320615f8201527f6c72656164792072656769737465726564000000000000000000000000000000602082015250565b5f6124b8603183611e63565b91506124c38261245e565b604082019050919050565b5f6020820190508181035f8301526124e5816124ac565b9050919050565b7f6f6e6c79206f776e6572206d617920616c6c6f776c69737420757365727300005f82015250565b5f612520601e83611e63565b915061252b826124ec565b602082019050919050565b5f6020820190508181035f83015261254d81612514565b9050919050565b7f7573657220697320616c726561647920616c6c6f776c697374656400000000005f82015250565b5f612588601b83611e63565b915061259382612554565b602082019050919050565b5f6020820190508181035f8301526125b58161257c565b9050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b7f6f6e6c79206f776e6572206d61792073746172742074686520444b47000000005f82015250565b5f61261d601c83611e63565b9150612628826125e9565b602082019050919050565b5f6020820190508181035f83015261264a81612611565b905091905056fea26469706673582212202157e56989a7e50c0d50b1a094b57d9ca7ceaafe7e754152b83eb780d50bb23d64736f6c63430008190033 \ No newline at end of file diff --git a/crates/dkg-cli/artifacts/dkg.json b/crates/dkg-cli/artifacts/dkg.json new file mode 100644 index 0000000..37e0c71 --- /dev/null +++ b/crates/dkg-cli/artifacts/dkg.json @@ -0,0 +1 @@ +{"language":"Solidity","sources":{"contracts/DKG.sol":{"content":"// Using the ABIEncoderV2 poses little risk here because we only use it for fetching the byte arrays\n// of shares/responses/justifications\npragma experimental ABIEncoderV2;\npragma solidity ^0.8;\n\ncontract DKG {\n enum UserState {\n CannotRegister,\n CanRegister,\n Registered\n }\n\n /// Mapping of Ethereum Address => UserState for the actions a user can do\n mapping(address => UserState) public userState;\n\n /// Mapping of Ethereum Address => BLS public keys\n mapping(address => bytes) public keys;\n\n /// Mapping of Ethereum Address => DKG Phase 1 Shares\n mapping(address => bytes) public shares;\n\n /// Mapping of Ethereum Address => DKG Phase 2 Responses\n mapping(address => bytes) public responses;\n\n /// Mapping of Ethereum Address => DKG Phase 3 Justifications\n mapping(address => bytes) public justifications;\n\n /// List of registered Ethereum keys (used for conveniently fetching data)\n address[] public participants;\n\n /// The duration of each phase\n uint256 public immutable PHASE_DURATION;\n\n /// The threshold of the DKG\n uint256 public immutable THRESHOLD;\n\n /// If it's 0 then the DKG is still pending start. If >0, it is the DKG's start block\n uint256 public startBlock = 0;\n\n /// The owner of the DKG is the address which can call the `start` function\n address public owner;\n\n /// A registered participant is one whose pubkey's length > 0\n modifier onlyRegistered() {\n require(userState[msg.sender] == UserState.Registered, \"you are not registered!\");\n _;\n }\n\n /// The DKG starts when startBlock > 0\n modifier onlyWhenNotStarted() {\n require(startBlock == 0, \"DKG has already started\");\n _;\n }\n\n constructor(uint256 threshold, uint256 duration) public {\n PHASE_DURATION = duration;\n THRESHOLD = threshold;\n owner = msg.sender;\n }\n\n /// Kickoff function which starts the counter\n function start() external onlyWhenNotStarted {\n require(msg.sender == owner, \"only owner may start the DKG\");\n startBlock = block.number;\n }\n\n /// The administrator must allowlist an addrss for participation in the DKG\n function allowlist(address user) external onlyWhenNotStarted {\n require(msg.sender == owner, \"only owner may allowlist users\");\n\n require(userState[user] == UserState.CannotRegister, \"user is already allowlisted\");\n userState[user] = UserState.CanRegister;\n }\n\n /// This function ties a DKG participant's on-chain address with their BLS Public Key\n function register(bytes calldata blsPublicKey) external onlyWhenNotStarted {\n require(userState[msg.sender] == UserState.CanRegister, \"user is not allowlisted or has already registered\");\n\n participants.push(msg.sender);\n keys[msg.sender] = blsPublicKey;\n\n // the user is now registered\n userState[msg.sender] = UserState.Registered;\n }\n\n /// Participant publishes their data and depending on the phase the data gets inserted\n /// in the shares, responses or justifications mapping. Reverts if the participant\n /// has already published their data for a phase or if the DKG has ended.\n function publish(bytes calldata value) external onlyRegistered {\n uint256 blocksSinceStart = block.number - startBlock;\n\n if (blocksSinceStart <= PHASE_DURATION) {\n require(\n shares[msg.sender].length == 0,\n \"you have already published your shares\"\n );\n shares[msg.sender] = value;\n } else if (blocksSinceStart <= 2 * PHASE_DURATION) {\n require(\n responses[msg.sender].length == 0,\n \"you have already published your responses\"\n );\n responses[msg.sender] = value;\n } else if (blocksSinceStart <= 3 * PHASE_DURATION) {\n require(\n justifications[msg.sender].length == 0,\n \"you have already published your justifications\"\n );\n justifications[msg.sender] = value;\n } else {\n revert(\"DKG has ended\");\n }\n }\n\n // Helpers to fetch data in the mappings. If a participant has registered but not\n // published their data for a phase, the array element at their index is expected to be 0\n\n /// Gets the participants' shares\n function getShares() external view returns (bytes[] memory) {\n bytes[] memory _shares = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _shares[i] = shares[participants[i]];\n }\n\n return _shares;\n }\n\n /// Gets the participants' responses\n function getResponses() external view returns (bytes[] memory) {\n bytes[] memory _responses = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _responses[i] = responses[participants[i]];\n }\n\n return _responses;\n }\n\n /// Gets the participants' justifications\n function getJustifications() external view returns (bytes[] memory) {\n bytes[] memory _justifications = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _justifications[i] = justifications[participants[i]];\n }\n\n return _justifications;\n }\n\n /// Gets the participants' ethereum addresses\n function getParticipants() external view returns (address[] memory) {\n return participants;\n }\n\n /// Gets the participants' BLS keys along with the thershold of the DKG\n function getBlsKeys() external view returns (uint256, bytes[] memory) {\n bytes[] memory _keys = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _keys[i] = keys[participants[i]];\n }\n\n return (THRESHOLD, _keys);\n }\n\n /// Returns the current phase of the DKG.\n function inPhase() public view returns (uint256) {\n if (startBlock == 0) {\n return 0;\n }\n\n uint256 blocksSinceStart = block.number - startBlock;\n\n if (blocksSinceStart <= PHASE_DURATION) {\n return 1;\n }\n\n if (blocksSinceStart <= 2 * PHASE_DURATION) {\n return 2;\n }\n\n if (blocksSinceStart <= 3 * PHASE_DURATION) {\n return 3;\n }\n\n revert(\"DKG Ended\");\n }\n}\n"}},"settings":{"optimizer":{"enabled":false,"runs":200},"outputSelection":{"*":{"":["ast"],"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"evmVersion":"shanghai","libraries":{}}} \ No newline at end of file diff --git a/crates/dkg-cli/build.rs b/crates/dkg-cli/build.rs index 31d4416..d1f27cf 100644 --- a/crates/dkg-cli/build.rs +++ b/crates/dkg-cli/build.rs @@ -10,6 +10,10 @@ const CONTRACT_PATH: &str = "../../solidity/contracts/DKG.sol"; const CONTRACT_NAME: &str = "DKG"; // Generates the bindings under `src/` fn main() { + if option_env!("NO_SOLC_BUILD").is_some() { + return; + } + // Only re-run the builder script if the contract changes println!("cargo:rerun-if-changed={}", PATH); @@ -25,7 +29,7 @@ fn main() { let compiler_output = project.compile().unwrap(); let contract = compiler_output.find(full_path, CONTRACT_NAME).unwrap(); - let mut f = File::create("dkg.bin").expect("could not create DKG bytecode file"); + let mut f = File::create("artifacts/dkg.bin").expect("could not create DKG bytecode file"); let bytecode: String = contract.bytecode.clone().unwrap().object.encode_hex(); f.write_all(bytecode.as_bytes()) @@ -46,7 +50,8 @@ fn main() { let verification_input = project .standard_json_input(project.sources_path().join("DKG.sol")) .unwrap(); - let mut j = File::create("dkg.json").expect("could not create DKG standard sol input file"); + let mut j = + File::create("artifacts/dkg.json").expect("could not create DKG standard sol input file"); j.write_all( serde_json::to_string(&verification_input) diff --git a/crates/dkg-cli/dkg.json b/crates/dkg-cli/dkg.json new file mode 100644 index 0000000..37e0c71 --- /dev/null +++ b/crates/dkg-cli/dkg.json @@ -0,0 +1 @@ +{"language":"Solidity","sources":{"contracts/DKG.sol":{"content":"// Using the ABIEncoderV2 poses little risk here because we only use it for fetching the byte arrays\n// of shares/responses/justifications\npragma experimental ABIEncoderV2;\npragma solidity ^0.8;\n\ncontract DKG {\n enum UserState {\n CannotRegister,\n CanRegister,\n Registered\n }\n\n /// Mapping of Ethereum Address => UserState for the actions a user can do\n mapping(address => UserState) public userState;\n\n /// Mapping of Ethereum Address => BLS public keys\n mapping(address => bytes) public keys;\n\n /// Mapping of Ethereum Address => DKG Phase 1 Shares\n mapping(address => bytes) public shares;\n\n /// Mapping of Ethereum Address => DKG Phase 2 Responses\n mapping(address => bytes) public responses;\n\n /// Mapping of Ethereum Address => DKG Phase 3 Justifications\n mapping(address => bytes) public justifications;\n\n /// List of registered Ethereum keys (used for conveniently fetching data)\n address[] public participants;\n\n /// The duration of each phase\n uint256 public immutable PHASE_DURATION;\n\n /// The threshold of the DKG\n uint256 public immutable THRESHOLD;\n\n /// If it's 0 then the DKG is still pending start. If >0, it is the DKG's start block\n uint256 public startBlock = 0;\n\n /// The owner of the DKG is the address which can call the `start` function\n address public owner;\n\n /// A registered participant is one whose pubkey's length > 0\n modifier onlyRegistered() {\n require(userState[msg.sender] == UserState.Registered, \"you are not registered!\");\n _;\n }\n\n /// The DKG starts when startBlock > 0\n modifier onlyWhenNotStarted() {\n require(startBlock == 0, \"DKG has already started\");\n _;\n }\n\n constructor(uint256 threshold, uint256 duration) public {\n PHASE_DURATION = duration;\n THRESHOLD = threshold;\n owner = msg.sender;\n }\n\n /// Kickoff function which starts the counter\n function start() external onlyWhenNotStarted {\n require(msg.sender == owner, \"only owner may start the DKG\");\n startBlock = block.number;\n }\n\n /// The administrator must allowlist an addrss for participation in the DKG\n function allowlist(address user) external onlyWhenNotStarted {\n require(msg.sender == owner, \"only owner may allowlist users\");\n\n require(userState[user] == UserState.CannotRegister, \"user is already allowlisted\");\n userState[user] = UserState.CanRegister;\n }\n\n /// This function ties a DKG participant's on-chain address with their BLS Public Key\n function register(bytes calldata blsPublicKey) external onlyWhenNotStarted {\n require(userState[msg.sender] == UserState.CanRegister, \"user is not allowlisted or has already registered\");\n\n participants.push(msg.sender);\n keys[msg.sender] = blsPublicKey;\n\n // the user is now registered\n userState[msg.sender] = UserState.Registered;\n }\n\n /// Participant publishes their data and depending on the phase the data gets inserted\n /// in the shares, responses or justifications mapping. Reverts if the participant\n /// has already published their data for a phase or if the DKG has ended.\n function publish(bytes calldata value) external onlyRegistered {\n uint256 blocksSinceStart = block.number - startBlock;\n\n if (blocksSinceStart <= PHASE_DURATION) {\n require(\n shares[msg.sender].length == 0,\n \"you have already published your shares\"\n );\n shares[msg.sender] = value;\n } else if (blocksSinceStart <= 2 * PHASE_DURATION) {\n require(\n responses[msg.sender].length == 0,\n \"you have already published your responses\"\n );\n responses[msg.sender] = value;\n } else if (blocksSinceStart <= 3 * PHASE_DURATION) {\n require(\n justifications[msg.sender].length == 0,\n \"you have already published your justifications\"\n );\n justifications[msg.sender] = value;\n } else {\n revert(\"DKG has ended\");\n }\n }\n\n // Helpers to fetch data in the mappings. If a participant has registered but not\n // published their data for a phase, the array element at their index is expected to be 0\n\n /// Gets the participants' shares\n function getShares() external view returns (bytes[] memory) {\n bytes[] memory _shares = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _shares[i] = shares[participants[i]];\n }\n\n return _shares;\n }\n\n /// Gets the participants' responses\n function getResponses() external view returns (bytes[] memory) {\n bytes[] memory _responses = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _responses[i] = responses[participants[i]];\n }\n\n return _responses;\n }\n\n /// Gets the participants' justifications\n function getJustifications() external view returns (bytes[] memory) {\n bytes[] memory _justifications = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _justifications[i] = justifications[participants[i]];\n }\n\n return _justifications;\n }\n\n /// Gets the participants' ethereum addresses\n function getParticipants() external view returns (address[] memory) {\n return participants;\n }\n\n /// Gets the participants' BLS keys along with the thershold of the DKG\n function getBlsKeys() external view returns (uint256, bytes[] memory) {\n bytes[] memory _keys = new bytes[](participants.length);\n for (uint256 i = 0; i < participants.length; i++) {\n _keys[i] = keys[participants[i]];\n }\n\n return (THRESHOLD, _keys);\n }\n\n /// Returns the current phase of the DKG.\n function inPhase() public view returns (uint256) {\n if (startBlock == 0) {\n return 0;\n }\n\n uint256 blocksSinceStart = block.number - startBlock;\n\n if (blocksSinceStart <= PHASE_DURATION) {\n return 1;\n }\n\n if (blocksSinceStart <= 2 * PHASE_DURATION) {\n return 2;\n }\n\n if (blocksSinceStart <= 3 * PHASE_DURATION) {\n return 3;\n }\n\n revert(\"DKG Ended\");\n }\n}\n"}},"settings":{"optimizer":{"enabled":false,"runs":200},"outputSelection":{"*":{"":["ast"],"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers"]}},"evmVersion":"shanghai","libraries":{}}} \ No newline at end of file diff --git a/crates/dkg-cli/src/actions.rs b/crates/dkg-cli/src/actions.rs index 1bf3c4c..a45bc07 100644 --- a/crates/dkg-cli/src/actions.rs +++ b/crates/dkg-cli/src/actions.rs @@ -60,7 +60,7 @@ where pub async fn deploy(opts: DeployOpts) -> Result<()> { // hard-code the contract's bytecode when deploying - let bytecode = include_str!["../dkg.bin"]; + let bytecode = include_str!["../artifacts/dkg.bin"]; let bytecode = bytecode.from_hex::>()?; let provider = Provider::::try_from(opts.node_url.as_str())? diff --git a/crates/dkg-cli/src/dkg_contract.rs b/crates/dkg-cli/src/dkg_contract.rs new file mode 100644 index 0000000..f2db27b --- /dev/null +++ b/crates/dkg-cli/src/dkg_contract.rs @@ -0,0 +1,1366 @@ +pub use dkg::*; +/// This module was auto-generated with ethers-rs Abigen. +/// More information at: +#[allow( + clippy::enum_variant_names, + clippy::too_many_arguments, + clippy::upper_case_acronyms, + clippy::type_complexity, + dead_code, + non_camel_case_types +)] +pub mod dkg { + #[allow(deprecated)] + fn __abi() -> ::ethers::core::abi::Abi { + ::ethers::core::abi::ethabi::Contract { + constructor: ::core::option::Option::Some(::ethers::core::abi::ethabi::Constructor { + inputs: ::std::vec![ + ::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("threshold"), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + }, + ::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("duration"), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + }, + ], + }), + functions: ::core::convert::From::from([ + ( + ::std::borrow::ToOwned::to_owned("PHASE_DURATION"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("PHASE_DURATION"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("THRESHOLD"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("THRESHOLD"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("allowlist"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("allowlist"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("user"), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::NonPayable, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("getBlsKeys"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("getBlsKeys"), + inputs: ::std::vec![], + outputs: ::std::vec![ + ::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + }, + ::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Bytes, + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes[]"), + ), + }, + ], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("getJustifications"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("getJustifications"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Bytes, + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes[]"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("getParticipants"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("getParticipants"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Address, + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address[]"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("getResponses"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("getResponses"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Bytes, + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes[]"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("getShares"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("getShares"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Array( + ::std::boxed::Box::new( + ::ethers::core::abi::ethabi::ParamType::Bytes, + ), + ), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes[]"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("inPhase"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("inPhase"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("justifications"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("justifications"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("keys"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("keys"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("owner"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("owner"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("participants"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("participants"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + },], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("publish"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("publish"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("value"), + kind: ::ethers::core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes"), + ), + },], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::NonPayable, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("register"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("register"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::borrow::ToOwned::to_owned("blsPublicKey"), + kind: ::ethers::core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes"), + ), + },], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::NonPayable, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("responses"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("responses"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("shares"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("shares"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Bytes, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("bytes"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("start"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("start"), + inputs: ::std::vec![], + outputs: ::std::vec![], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::NonPayable, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("startBlock"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("startBlock"), + inputs: ::std::vec![], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(256usize,), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("uint256"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ( + ::std::borrow::ToOwned::to_owned("userState"), + ::std::vec![::ethers::core::abi::ethabi::Function { + name: ::std::borrow::ToOwned::to_owned("userState"), + inputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Address, + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("address"), + ), + },], + outputs: ::std::vec![::ethers::core::abi::ethabi::Param { + name: ::std::string::String::new(), + kind: ::ethers::core::abi::ethabi::ParamType::Uint(8usize), + internal_type: ::core::option::Option::Some( + ::std::borrow::ToOwned::to_owned("enum DKG.UserState"), + ), + },], + constant: ::core::option::Option::None, + state_mutability: ::ethers::core::abi::ethabi::StateMutability::View, + },], + ), + ]), + events: ::std::collections::BTreeMap::new(), + errors: ::std::collections::BTreeMap::new(), + receive: false, + fallback: false, + } + } + ///The parsed JSON ABI of the contract. + pub static DKG_ABI: ::ethers::contract::Lazy<::ethers::core::abi::Abi> = + ::ethers::contract::Lazy::new(__abi); + pub struct DKG(::ethers::contract::Contract); + impl ::core::clone::Clone for DKG { + fn clone(&self) -> Self { + Self(::core::clone::Clone::clone(&self.0)) + } + } + impl ::core::ops::Deref for DKG { + type Target = ::ethers::contract::Contract; + fn deref(&self) -> &Self::Target { + &self.0 + } + } + impl ::core::ops::DerefMut for DKG { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.0 + } + } + impl ::core::fmt::Debug for DKG { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_tuple(::core::stringify!(DKG)) + .field(&self.address()) + .finish() + } + } + impl DKG { + /// Creates a new contract instance with the specified `ethers` client at + /// `address`. The contract derefs to a `ethers::Contract` object. + pub fn new>( + address: T, + client: ::std::sync::Arc, + ) -> Self { + Self(::ethers::contract::Contract::new( + address.into(), + DKG_ABI.clone(), + client, + )) + } + ///Calls the contract's `PHASE_DURATION` (0x4ae2b849) function + pub fn phase_duration( + &self, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([74, 226, 184, 73], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `THRESHOLD` (0x785ffb37) function + pub fn threshold( + &self, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([120, 95, 251, 55], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `allowlist` (0xa7cd52cb) function + pub fn allowlist( + &self, + user: ::ethers::core::types::Address, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([167, 205, 82, 203], user) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `getBlsKeys` (0xa8194596) function + pub fn get_bls_keys( + &self, + ) -> ::ethers::contract::builders::ContractCall< + M, + ( + ::ethers::core::types::U256, + ::std::vec::Vec<::ethers::core::types::Bytes>, + ), + > { + self.0 + .method_hash([168, 25, 69, 150], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `getJustifications` (0xb0ef8179) function + pub fn get_justifications( + &self, + ) -> ::ethers::contract::builders::ContractCall< + M, + ::std::vec::Vec<::ethers::core::types::Bytes>, + > { + self.0 + .method_hash([176, 239, 129, 121], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `getParticipants` (0x5aa68ac0) function + pub fn get_participants( + &self, + ) -> ::ethers::contract::builders::ContractCall< + M, + ::std::vec::Vec<::ethers::core::types::Address>, + > { + self.0 + .method_hash([90, 166, 138, 192], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `getResponses` (0xcc5ef009) function + pub fn get_responses( + &self, + ) -> ::ethers::contract::builders::ContractCall< + M, + ::std::vec::Vec<::ethers::core::types::Bytes>, + > { + self.0 + .method_hash([204, 94, 240, 9], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `getShares` (0xd73fe0aa) function + pub fn get_shares( + &self, + ) -> ::ethers::contract::builders::ContractCall< + M, + ::std::vec::Vec<::ethers::core::types::Bytes>, + > { + self.0 + .method_hash([215, 63, 224, 170], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `inPhase` (0x221f9511) function + pub fn in_phase( + &self, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([34, 31, 149, 17], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `justifications` (0xcd5e3837) function + pub fn justifications( + &self, + p0: ::ethers::core::types::Address, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([205, 94, 56, 55], p0) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `keys` (0x670d14b2) function + pub fn keys( + &self, + p0: ::ethers::core::types::Address, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([103, 13, 20, 178], p0) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `owner` (0x8da5cb5b) function + pub fn owner( + &self, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([141, 165, 203, 91], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `participants` (0x35c1d349) function + pub fn participants( + &self, + p0: ::ethers::core::types::U256, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([53, 193, 211, 73], p0) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `publish` (0x7fd28346) function + pub fn publish( + &self, + value: ::ethers::core::types::Bytes, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([127, 210, 131, 70], value) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `register` (0x82fbdc9c) function + pub fn register( + &self, + bls_public_key: ::ethers::core::types::Bytes, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([130, 251, 220, 156], bls_public_key) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `responses` (0x0ea65648) function + pub fn responses( + &self, + p0: ::ethers::core::types::Address, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([14, 166, 86, 72], p0) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `shares` (0xce7c2ac2) function + pub fn shares( + &self, + p0: ::ethers::core::types::Address, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([206, 124, 42, 194], p0) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `start` (0xbe9a6555) function + pub fn start(&self) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([190, 154, 101, 85], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `startBlock` (0x48cd4cb1) function + pub fn start_block( + &self, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([72, 205, 76, 177], ()) + .expect("method not found (this should never happen)") + } + ///Calls the contract's `userState` (0x0c8f81b5) function + pub fn user_state( + &self, + p0: ::ethers::core::types::Address, + ) -> ::ethers::contract::builders::ContractCall { + self.0 + .method_hash([12, 143, 129, 181], p0) + .expect("method not found (this should never happen)") + } + } + impl From<::ethers::contract::Contract> for DKG { + fn from(contract: ::ethers::contract::Contract) -> Self { + Self::new(contract.address(), contract.client()) + } + } + ///Container type for all input parameters for the `PHASE_DURATION` function with signature `PHASE_DURATION()` and selector `0x4ae2b849` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "PHASE_DURATION", abi = "PHASE_DURATION()")] + pub struct PhaseDurationCall; + ///Container type for all input parameters for the `THRESHOLD` function with signature `THRESHOLD()` and selector `0x785ffb37` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "THRESHOLD", abi = "THRESHOLD()")] + pub struct ThresholdCall; + ///Container type for all input parameters for the `allowlist` function with signature `allowlist(address)` and selector `0xa7cd52cb` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "allowlist", abi = "allowlist(address)")] + pub struct AllowlistCall { + pub user: ::ethers::core::types::Address, + } + ///Container type for all input parameters for the `getBlsKeys` function with signature `getBlsKeys()` and selector `0xa8194596` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "getBlsKeys", abi = "getBlsKeys()")] + pub struct GetBlsKeysCall; + ///Container type for all input parameters for the `getJustifications` function with signature `getJustifications()` and selector `0xb0ef8179` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "getJustifications", abi = "getJustifications()")] + pub struct GetJustificationsCall; + ///Container type for all input parameters for the `getParticipants` function with signature `getParticipants()` and selector `0x5aa68ac0` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "getParticipants", abi = "getParticipants()")] + pub struct GetParticipantsCall; + ///Container type for all input parameters for the `getResponses` function with signature `getResponses()` and selector `0xcc5ef009` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "getResponses", abi = "getResponses()")] + pub struct GetResponsesCall; + ///Container type for all input parameters for the `getShares` function with signature `getShares()` and selector `0xd73fe0aa` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "getShares", abi = "getShares()")] + pub struct GetSharesCall; + ///Container type for all input parameters for the `inPhase` function with signature `inPhase()` and selector `0x221f9511` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "inPhase", abi = "inPhase()")] + pub struct InPhaseCall; + ///Container type for all input parameters for the `justifications` function with signature `justifications(address)` and selector `0xcd5e3837` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "justifications", abi = "justifications(address)")] + pub struct JustificationsCall(pub ::ethers::core::types::Address); + ///Container type for all input parameters for the `keys` function with signature `keys(address)` and selector `0x670d14b2` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "keys", abi = "keys(address)")] + pub struct KeysCall(pub ::ethers::core::types::Address); + ///Container type for all input parameters for the `owner` function with signature `owner()` and selector `0x8da5cb5b` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "owner", abi = "owner()")] + pub struct OwnerCall; + ///Container type for all input parameters for the `participants` function with signature `participants(uint256)` and selector `0x35c1d349` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "participants", abi = "participants(uint256)")] + pub struct ParticipantsCall(pub ::ethers::core::types::U256); + ///Container type for all input parameters for the `publish` function with signature `publish(bytes)` and selector `0x7fd28346` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "publish", abi = "publish(bytes)")] + pub struct PublishCall { + pub value: ::ethers::core::types::Bytes, + } + ///Container type for all input parameters for the `register` function with signature `register(bytes)` and selector `0x82fbdc9c` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "register", abi = "register(bytes)")] + pub struct RegisterCall { + pub bls_public_key: ::ethers::core::types::Bytes, + } + ///Container type for all input parameters for the `responses` function with signature `responses(address)` and selector `0x0ea65648` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "responses", abi = "responses(address)")] + pub struct ResponsesCall(pub ::ethers::core::types::Address); + ///Container type for all input parameters for the `shares` function with signature `shares(address)` and selector `0xce7c2ac2` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "shares", abi = "shares(address)")] + pub struct SharesCall(pub ::ethers::core::types::Address); + ///Container type for all input parameters for the `start` function with signature `start()` and selector `0xbe9a6555` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "start", abi = "start()")] + pub struct StartCall; + ///Container type for all input parameters for the `startBlock` function with signature `startBlock()` and selector `0x48cd4cb1` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "startBlock", abi = "startBlock()")] + pub struct StartBlockCall; + ///Container type for all input parameters for the `userState` function with signature `userState(address)` and selector `0x0c8f81b5` + #[derive( + Clone, + ::ethers::contract::EthCall, + ::ethers::contract::EthDisplay, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + #[ethcall(name = "userState", abi = "userState(address)")] + pub struct UserStateCall(pub ::ethers::core::types::Address); + ///Container type for all of the contract's call + #[derive(Clone, ::ethers::contract::EthAbiType, Debug, PartialEq, Eq, Hash)] + pub enum DKGCalls { + PhaseDuration(PhaseDurationCall), + Threshold(ThresholdCall), + Allowlist(AllowlistCall), + GetBlsKeys(GetBlsKeysCall), + GetJustifications(GetJustificationsCall), + GetParticipants(GetParticipantsCall), + GetResponses(GetResponsesCall), + GetShares(GetSharesCall), + InPhase(InPhaseCall), + Justifications(JustificationsCall), + Keys(KeysCall), + Owner(OwnerCall), + Participants(ParticipantsCall), + Publish(PublishCall), + Register(RegisterCall), + Responses(ResponsesCall), + Shares(SharesCall), + Start(StartCall), + StartBlock(StartBlockCall), + UserState(UserStateCall), + } + impl ::ethers::core::abi::AbiDecode for DKGCalls { + fn decode( + data: impl AsRef<[u8]>, + ) -> ::core::result::Result { + let data = data.as_ref(); + if let Ok(decoded) = ::decode(data) + { + return Ok(Self::PhaseDuration(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Threshold(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Allowlist(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::GetBlsKeys(decoded)); + } + if let Ok(decoded) = + ::decode(data) + { + return Ok(Self::GetJustifications(decoded)); + } + if let Ok(decoded) = + ::decode(data) + { + return Ok(Self::GetParticipants(decoded)); + } + if let Ok(decoded) = ::decode(data) + { + return Ok(Self::GetResponses(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::GetShares(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::InPhase(decoded)); + } + if let Ok(decoded) = + ::decode(data) + { + return Ok(Self::Justifications(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Keys(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Owner(decoded)); + } + if let Ok(decoded) = ::decode(data) + { + return Ok(Self::Participants(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Publish(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Register(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Responses(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Shares(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::Start(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::StartBlock(decoded)); + } + if let Ok(decoded) = ::decode(data) { + return Ok(Self::UserState(decoded)); + } + Err(::ethers::core::abi::Error::InvalidData.into()) + } + } + impl ::ethers::core::abi::AbiEncode for DKGCalls { + fn encode(self) -> Vec { + match self { + Self::PhaseDuration(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Threshold(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Allowlist(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::GetBlsKeys(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::GetJustifications(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::GetParticipants(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::GetResponses(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::GetShares(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::InPhase(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Justifications(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Keys(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Owner(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Participants(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Publish(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Register(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Responses(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Shares(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::Start(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::StartBlock(element) => ::ethers::core::abi::AbiEncode::encode(element), + Self::UserState(element) => ::ethers::core::abi::AbiEncode::encode(element), + } + } + } + impl ::core::fmt::Display for DKGCalls { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Self::PhaseDuration(element) => ::core::fmt::Display::fmt(element, f), + Self::Threshold(element) => ::core::fmt::Display::fmt(element, f), + Self::Allowlist(element) => ::core::fmt::Display::fmt(element, f), + Self::GetBlsKeys(element) => ::core::fmt::Display::fmt(element, f), + Self::GetJustifications(element) => ::core::fmt::Display::fmt(element, f), + Self::GetParticipants(element) => ::core::fmt::Display::fmt(element, f), + Self::GetResponses(element) => ::core::fmt::Display::fmt(element, f), + Self::GetShares(element) => ::core::fmt::Display::fmt(element, f), + Self::InPhase(element) => ::core::fmt::Display::fmt(element, f), + Self::Justifications(element) => ::core::fmt::Display::fmt(element, f), + Self::Keys(element) => ::core::fmt::Display::fmt(element, f), + Self::Owner(element) => ::core::fmt::Display::fmt(element, f), + Self::Participants(element) => ::core::fmt::Display::fmt(element, f), + Self::Publish(element) => ::core::fmt::Display::fmt(element, f), + Self::Register(element) => ::core::fmt::Display::fmt(element, f), + Self::Responses(element) => ::core::fmt::Display::fmt(element, f), + Self::Shares(element) => ::core::fmt::Display::fmt(element, f), + Self::Start(element) => ::core::fmt::Display::fmt(element, f), + Self::StartBlock(element) => ::core::fmt::Display::fmt(element, f), + Self::UserState(element) => ::core::fmt::Display::fmt(element, f), + } + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: PhaseDurationCall) -> Self { + Self::PhaseDuration(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: ThresholdCall) -> Self { + Self::Threshold(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: AllowlistCall) -> Self { + Self::Allowlist(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: GetBlsKeysCall) -> Self { + Self::GetBlsKeys(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: GetJustificationsCall) -> Self { + Self::GetJustifications(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: GetParticipantsCall) -> Self { + Self::GetParticipants(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: GetResponsesCall) -> Self { + Self::GetResponses(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: GetSharesCall) -> Self { + Self::GetShares(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: InPhaseCall) -> Self { + Self::InPhase(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: JustificationsCall) -> Self { + Self::Justifications(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: KeysCall) -> Self { + Self::Keys(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: OwnerCall) -> Self { + Self::Owner(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: ParticipantsCall) -> Self { + Self::Participants(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: PublishCall) -> Self { + Self::Publish(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: RegisterCall) -> Self { + Self::Register(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: ResponsesCall) -> Self { + Self::Responses(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: SharesCall) -> Self { + Self::Shares(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: StartCall) -> Self { + Self::Start(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: StartBlockCall) -> Self { + Self::StartBlock(value) + } + } + impl ::core::convert::From for DKGCalls { + fn from(value: UserStateCall) -> Self { + Self::UserState(value) + } + } + ///Container type for all return fields from the `PHASE_DURATION` function with signature `PHASE_DURATION()` and selector `0x4ae2b849` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct PhaseDurationReturn(pub ::ethers::core::types::U256); + ///Container type for all return fields from the `THRESHOLD` function with signature `THRESHOLD()` and selector `0x785ffb37` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct ThresholdReturn(pub ::ethers::core::types::U256); + ///Container type for all return fields from the `getBlsKeys` function with signature `getBlsKeys()` and selector `0xa8194596` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct GetBlsKeysReturn( + pub ::ethers::core::types::U256, + pub ::std::vec::Vec<::ethers::core::types::Bytes>, + ); + ///Container type for all return fields from the `getJustifications` function with signature `getJustifications()` and selector `0xb0ef8179` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct GetJustificationsReturn(pub ::std::vec::Vec<::ethers::core::types::Bytes>); + ///Container type for all return fields from the `getParticipants` function with signature `getParticipants()` and selector `0x5aa68ac0` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct GetParticipantsReturn(pub ::std::vec::Vec<::ethers::core::types::Address>); + ///Container type for all return fields from the `getResponses` function with signature `getResponses()` and selector `0xcc5ef009` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct GetResponsesReturn(pub ::std::vec::Vec<::ethers::core::types::Bytes>); + ///Container type for all return fields from the `getShares` function with signature `getShares()` and selector `0xd73fe0aa` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct GetSharesReturn(pub ::std::vec::Vec<::ethers::core::types::Bytes>); + ///Container type for all return fields from the `inPhase` function with signature `inPhase()` and selector `0x221f9511` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct InPhaseReturn(pub ::ethers::core::types::U256); + ///Container type for all return fields from the `justifications` function with signature `justifications(address)` and selector `0xcd5e3837` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct JustificationsReturn(pub ::ethers::core::types::Bytes); + ///Container type for all return fields from the `keys` function with signature `keys(address)` and selector `0x670d14b2` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct KeysReturn(pub ::ethers::core::types::Bytes); + ///Container type for all return fields from the `owner` function with signature `owner()` and selector `0x8da5cb5b` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct OwnerReturn(pub ::ethers::core::types::Address); + ///Container type for all return fields from the `participants` function with signature `participants(uint256)` and selector `0x35c1d349` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct ParticipantsReturn(pub ::ethers::core::types::Address); + ///Container type for all return fields from the `responses` function with signature `responses(address)` and selector `0x0ea65648` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct ResponsesReturn(pub ::ethers::core::types::Bytes); + ///Container type for all return fields from the `shares` function with signature `shares(address)` and selector `0xce7c2ac2` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct SharesReturn(pub ::ethers::core::types::Bytes); + ///Container type for all return fields from the `startBlock` function with signature `startBlock()` and selector `0x48cd4cb1` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct StartBlockReturn(pub ::ethers::core::types::U256); + ///Container type for all return fields from the `userState` function with signature `userState(address)` and selector `0x0c8f81b5` + #[derive( + Clone, + ::ethers::contract::EthAbiType, + ::ethers::contract::EthAbiCodec, + Default, + Debug, + PartialEq, + Eq, + Hash, + )] + pub struct UserStateReturn(pub u8); +}